@mcpjam/inspector 3.25.3 → 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-D8p1xxJL.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-_lcmAHBS.js → chunk-D32TOXHM-CyuI5mIj.js} +5 -5
  6. package/dist/client/assets/{dead-clicks-autocapture--Cc80oY_.js → dead-clicks-autocapture-DPDniRFT.js} +2 -2
  7. package/dist/client/assets/{error-reporting-B4cQ3ELy.js → error-reporting-B3uD72Mm.js} +1 -1
  8. package/dist/client/assets/{error-reporting-D-VMAV0k.js → error-reporting-B45ic1xn.js} +46 -46
  9. package/dist/client/assets/{exception-autocapture-DginYM1x.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-CXee3ser.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-DVVdSEhZ.js → jszip.min-mcFGNyxN.js} +2 -2
  15. package/dist/client/assets/{mermaid-MCJ5UELQ-DrjPVbUm.js → mermaid-MCJ5UELQ-C7LKilvg.js} +1 -1
  16. package/dist/client/assets/{posthog-recorder-DNy5bFB1.js → posthog-recorder-CPrlbyxV.js} +2 -2
  17. package/dist/client/assets/{preload-helper-BYOM8wou.js → preload-helper-DSOvb5Vt.js} +2 -2
  18. package/dist/client/assets/{project-route-CshTCVmQ.js → project-route-Nif61zEo.js} +3 -3
  19. package/dist/client/assets/{react-dom-y0CFBu2J.js → react-dom-DYqNESIg.js} +2 -2
  20. package/dist/client/assets/{rolldown-runtime-Ck0AUAe_.js → rolldown-runtime-B8IK0bAc.js} +1 -1
  21. package/dist/client/assets/{surveys-P23Cz34L.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-CWdGYeWw.js → trace-timeline-CKpfuLys.js} +1 -1
  25. package/dist/client/assets/{web-vitals-DgeVvuPL.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 +211 -56
  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-DZl0Ds5X.css +0 -2
  35. package/dist/client/assets/first-run-oauth-return-rF56NddK.js +0 -1872
  36. package/dist/client/assets/index-82wefelr.js +0 -4
  37. package/dist/client/assets/telemetry-files-2454aee542431dd3.js +0 -1
  38. package/dist/client/assets/trace-timeline-mjuETy67.js +0 -73
  39. package/dist/client/assets/use-reduced-motion-_Ge9sKbc.js +0 -42
@@ -1,73 +0,0 @@
1
- import{o as Xx}from"./rolldown-runtime-Ck0AUAe_.js";import{Dt as Ge,Gt as lf,It as nt,Kt as yo,Lt as Mr,Nt as br,Tt as Qt,Ut as ve,Vt as Sl,bt as xo,ft as zc,mt as GE,wt as Jx}from"./project-route-CshTCVmQ.js";import{Dt as QE,Gt as Wn,Ht as cf,Jt as YE,Kt as XE,Ot as JE,T as ZE,Ut as In,Wt as sc,Z as Zx,Zi as eM,c as tM,et as nM,fs as rM,hs as eb,ms as tb,ot as Mg,ps as iM,qt as sM,t as oM,w as Rg,y as aM}from"./error-reporting-D-VMAV0k.js";import{A as cs,C as lM,D as G,H as cM,I as nb,N as Ce,O as uM,S as hM,T as Ot,V as Mp,i as fM,j as dM,k as pM,n as mM,r as gM,t as vM,w as xe,z as yM}from"./use-reduced-motion-_Ge9sKbc.js";import{n as xM,t as bM}from"./react-dom-y0CFBu2J.js";import{i as wM}from"./preload-helper-BYOM8wou.js";import{a as SM,c as kM,n as CM,o as AM}from"./chunk-D32TOXHM-_lcmAHBS.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.25.3"};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d1b80e2e-4f29-4b37-8c68-07838df7c4e3",e._sentryDebugIdIdentifier="sentry-dbid-d1b80e2e-4f29-4b37-8c68-07838df7c4e3")}catch{}})();var g=Xx(xM(),1),pa=Xx(bM(),1),p=wM(),TM=Object.defineProperty,EM=(e,t)=>TM(e,"name",{value:t,configurable:!0}),Le=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=cs(`Primitive.${t}`),r=g.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),(0,p.jsx)(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Rp(e,t){e&&pa.flushSync(()=>e.dispatchEvent(t))}EM(Rp,"dispatchDiscreteCustomEvent");var MM=Object.defineProperty,RM=(e,t)=>MM(e,"name",{value:t,configurable:!0}),PM=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"}),IM=g.forwardRef(RM(function(t,n){return(0,p.jsx)(Le.span,{...t,ref:n,style:{...PM,...t.style}})},"VisuallyHidden")),OM=IM,DM=Object.defineProperty,Dt=(e,t)=>DM(e,"name",{value:t,configurable:!0});function NM(e,t){const n=g.createContext(t);n.displayName=e+"Context";const r=Dt(s=>{const{children:o,...a}=s,l=g.useMemo(()=>a,Object.values(a));return(0,p.jsx)(n.Provider,{value:l,children:o})},"Provider");r.displayName=e+"Provider";function i(s,o={}){const{optional:a=!1}=o,l=g.useContext(n);if(l)return l;if(t!==void 0)return t;if(!a)throw new Error(`\`${s}\` must be used within \`${e}\``)}return Dt(i,"useContext"),[r,i]}Dt(NM,"createContext");function cr(e,t=[]){let n=[];function r(s,o){const a=g.createContext(o);a.displayName=s+"Context";const l=n.length;n=[...n,o];const c=Dt(h=>{const{scope:f,children:d,...m}=h,v=f?.[e]?.[l]||a,y=g.useMemo(()=>m,Object.values(m));return(0,p.jsx)(v.Provider,{value:y,children:d})},"Provider");c.displayName=s+"Provider";function u(h,f,d={}){const{optional:m=!1}=d,v=f?.[e]?.[l]||a,y=g.useContext(v);if(y)return y;if(o!==void 0)return o;if(!m)throw new Error(`\`${h}\` must be used within \`${s}\``)}return Dt(u,"useContext"),[c,u]}Dt(r,"createContext");const i=Dt(()=>{const s=n.map(o=>g.createContext(o));return Dt(function(a){const l=a?.[e]||s;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])},"useScope")},"createScope");return i.scopeName=e,[r,rb(i,...t)]}Dt(cr,"createContextScope");function rb(...e){const t=e[0];if(e.length===1)return t;const n=Dt(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Dt(function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const u=l(s)[`__scope${c}`];return{...a,...u}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Dt(rb,"composeContextScopes");var LM=Object.defineProperty,Ye=(e,t)=>LM(e,"name",{value:t,configurable:!0});function Pp(e){const t=e+"CollectionProvider",[n,r]=cr(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Ye(v=>{const{scope:y,children:x}=v,b=g.useRef(null),w=g.useRef(new Map).current;return(0,p.jsx)(i,{scope:y,itemMap:w,collectionRef:b,children:x})},"CollectionProvider");o.displayName=t;const a=e+"CollectionSlot",l=cs(a),c=g.forwardRef((v,y)=>{const{scope:x,children:b}=v,w=s(a,x),S=Ce(y,w.collectionRef);return(0,p.jsx)(l,{ref:S,children:b})});c.displayName=a;const u=e+"CollectionItemSlot",h="data-radix-collection-item",f=cs(u),d=g.forwardRef((v,y)=>{const{scope:x,children:b,...w}=v,S=g.useRef(null),C=Ce(y,S),A=s(u,x);return g.useEffect(()=>(A.itemMap.set(S,{ref:S,...w}),()=>{A.itemMap.delete(S)})),(0,p.jsx)(f,{[h]:"",ref:C,children:b})});d.displayName=u;function m(v){const y=s(e+"CollectionConsumer",v);return g.useCallback(()=>{const x=y.collectionRef.current;if(!x)return[];const b=Array.from(x.querySelectorAll(`[${h}]`));return Array.from(y.itemMap.values()).sort((w,S)=>b.indexOf(w.ref.current)-b.indexOf(S.ref.current))},[y.collectionRef,y.itemMap])}return Ye(m,"useCollection"),[{Provider:o,Slot:c,ItemSlot:d},m,r]}Ye(Pp,"createCollection");var Pg=new WeakMap,$u=class dr extends Map{static{Ye(this,"OrderedDict")}#e;constructor(t){super(t),this.#e=[...super.keys()],Pg.set(this,!0)}set(t,n){return Pg.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 i=this.has(n),s=this.#e.length,o=Ip(t);let a=o>=0?o:s+o;const l=a<0||a>=s?-1:a;if(l===this.size||i&&l===this.size-1||l===-1)return this.set(n,r),this;const c=this.size+(i?0:1);o<0&&a++;const u=[...this.#e];let h,f=!1;for(let d=a;d<c;d++)if(a===d){let m=u[d];u[d]===n&&(m=u[d+1]),i&&this.delete(n),h=this.get(m),this.set(n,r)}else{!f&&u[d-1]===n&&(f=!0);const m=u[f?d:d-1],v=h;h=this.get(m),this.delete(m),this.set(m,v)}return this}with(t,n,r){const i=new dr(this);return i.insert(t,n,r),i}before(t){const n=this.#e.indexOf(t)-1;if(!(n<0))return this.entryAt(n)}setBefore(t,n,r){const i=this.#e.indexOf(t);return i===-1?this:this.insert(i,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 i=this.#e.indexOf(t);return i===-1?this:this.insert(i+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=kl(this.#e,t);if(n!==void 0)return this.get(n)}entryAt(t){const n=kl(this.#e,t);if(n!==void 0)return[n,this.get(n)]}indexOf(t){return this.#e.indexOf(t)}keyAt(t){return kl(this.#e,t)}from(t,n){const r=this.indexOf(t);if(r===-1)return;let i=r+n;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.at(i)}keyFrom(t,n){const r=this.indexOf(t);if(r===-1)return;let i=r+n;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.keyAt(i)}find(t,n){let r=0;for(const i of this){if(Reflect.apply(t,n,[i,r,this]))return i;r++}}findIndex(t,n){let r=0;for(const i of this){if(Reflect.apply(t,n,[i,r,this]))return r;r++}return-1}filter(t,n){const r=[];let i=0;for(const s of this)Reflect.apply(t,n,[s,i,this])&&r.push(s),i++;return new dr(r)}map(t,n){const r=[];let i=0;for(const s of this)r.push([s[0],Reflect.apply(t,n,[s,i,this])]),i++;return new dr(r)}reduce(...t){const[n,r]=t;let i=0,s=r??this.at(0);for(const o of this)i===0&&t.length===1?s=o:s=Reflect.apply(n,this,[s,o,i,this]),i++;return s}reduceRight(...t){const[n,r]=t;let i=r??this.at(-1);for(let s=this.size-1;s>=0;s--){const o=this.at(s);s===this.size-1&&t.length===1?i=o:i=Reflect.apply(n,this,[i,o,s,this])}return i}toSorted(t){const n=[...this.entries()].sort(t);return new dr(n)}toReversed(){const t=new dr;for(let n=this.size-1;n>=0;n--){const r=this.keyAt(n),i=this.get(r);t.set(r,i)}return t}toSpliced(...t){const n=[...this.entries()];return n.splice(...t),new dr(n)}slice(t,n){const r=new dr;let i=this.size-1;if(t===void 0)return r;t<0&&(t=t+this.size),n!==void 0&&n>0&&(i=n-1);for(let s=t;s<=i;s++){const o=this.keyAt(s),a=this.get(o);r.set(o,a)}return r}every(t,n){let r=0;for(const i of this){if(!Reflect.apply(t,n,[i,r,this]))return!1;r++}return!0}some(t,n){let r=0;for(const i of this){if(Reflect.apply(t,n,[i,r,this]))return!0;r++}return!1}};function kl(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=ib(e,t);return n===-1?void 0:e[n]}Ye(kl,"at");function ib(e,t){const n=e.length,r=Ip(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}Ye(ib,"toSafeIndex");function Ip(e){return e!==e||e===0?0:Math.trunc(e)}Ye(Ip,"toSafeInteger");function _M(e){const t=e+"CollectionProvider",[n,r]=cr(t),[i,s]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new $u,setItemMap:Ye(()=>{},"setItemMap")}),o=Ye(({state:b,...w})=>b?(0,p.jsx)(l,{...w,state:b}):(0,p.jsx)(a,{...w}),"CollectionProvider");o.displayName=t;const a=Ye(b=>{const w=y();return(0,p.jsx)(l,{...b,state:w})},"CollectionInit");a.displayName=t+"Init";const l=Ye(b=>{const{scope:w,children:S,state:C}=b,A=g.useRef(null),[k,E]=g.useState(null),T=Ce(A,E),[R,P]=C;return g.useEffect(()=>{if(!k)return;const M=ab(()=>{});return M.observe(k,{childList:!0,subtree:!0}),()=>{M.disconnect()}},[k]),(0,p.jsx)(i,{scope:w,itemMap:R,setItemMap:P,collectionRef:T,collectionRefObject:A,collectionElement:k,children:S})},"CollectionProviderImpl");l.displayName=t+"Impl";const c=e+"CollectionSlot",u=cs(c),h=g.forwardRef((b,w)=>{const{scope:S,children:C}=b,A=s(c,S),k=Ce(w,A.collectionRef);return(0,p.jsx)(u,{ref:k,children:C})});h.displayName=c;const f=e+"CollectionItemSlot",d="data-radix-collection-item",m=cs(f),v=g.forwardRef((b,w)=>{const{scope:S,children:C,...A}=b,k=g.useRef(null),[E,T]=g.useState(null),R=Ce(w,k,T),{setItemMap:P}=s(f,S),M=g.useRef(A);sb(M.current,A)||(M.current=A);const N=M.current;return g.useEffect(()=>{const L=N;return P(I=>E?I.has(E)?I.set(E,{...L,element:E}).toSorted(uf):(I.set(E,{...L,element:E}),I.toSorted(uf)):I),()=>{P(I=>!E||!I.has(E)?I:(I.delete(E),new $u(I)))}},[E,N,P]),(0,p.jsx)(m,{[d]:"",ref:R,children:C})});v.displayName=f;function y(){return g.useState(new $u)}Ye(y,"useInitCollection");function x(b){const{itemMap:w}=s(e+"CollectionConsumer",b);return w}return Ye(x,"useCollection"),[{Provider:o,Slot:h,ItemSlot:v},{createCollectionScope:r,useCollection:x,useInitCollection:y}]}Ye(_M,"createCollection");function sb(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 i of n)if(!Object.prototype.hasOwnProperty.call(t,i)||e[i]!==t[i])return!1;return!0}Ye(sb,"shallowEqual");function ob(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Ye(ob,"isElementPreceding");function uf(e,t){return!e[1].element||!t[1].element?0:ob(e[1].element,t[1].element)?-1:1}Ye(uf,"sortByDocumentPosition");function ab(e){return new MutationObserver(t=>{for(const n of t)if(n.type==="childList"){e();return}})}Ye(ab,"getChildListObserver");var jM=Object.defineProperty,Ms=(e,t)=>jM(e,"name",{value:t,configurable:!0}),lb=!!(typeof window<"u"&&window.document&&window.document.createElement);function te(e,t,{checkForDefaultPrevented:n=!0}={}){return Ms(function(i){if(e?.(i),n===!1||!i||!i.defaultPrevented)return t?.(i)},"handleEvent")}Ms(te,"composeEventHandlers");function BM(e){if(!lb)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}Ms(BM,"getOwnerWindow");function hf(e){if(!lb)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}Ms(hf,"getOwnerDocument");function cb(e,t=!1){const{activeElement:n}=hf(e);if(!n?.nodeName)return null;if(ub(n)&&n.contentDocument)return cb(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=hf(n).getElementById(r);if(i)return i}}return n}Ms(cb,"getActiveElement");function ub(e){return e.tagName==="IFRAME"}Ms(ub,"isFrame");var Rt=globalThis?.document?g.useLayoutEffect:()=>{},FM=Object.defineProperty,VM=(e,t)=>FM(e,"name",{value:t,configurable:!0}),Ig=g[" useEffectEvent ".trim().toString()],Og=g[" useInsertionEffect ".trim().toString()];function hb(e){if(typeof Ig=="function")return Ig(e);const t=g.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Og=="function"?Og(()=>{t.current=e}):Rt(()=>{t.current=e}),g.useMemo(()=>((...n)=>t.current?.(...n)),[])}VM(hb,"useEffectEvent");var zM=Object.defineProperty,ma=(e,t)=>zM(e,"name",{value:t,configurable:!0}),$M=g[" useInsertionEffect ".trim().toString()]||Rt;function ga({prop:e,defaultProp:t,onChange:n=ma(()=>{},"onChange"),caller:r}){const[i,s,o]=fb({defaultProp:t,onChange:n}),a=e!==void 0;return[a?e:i,g.useCallback(c=>{if(a){const u=db(c)?c(e):c;u!==e&&o.current?.(u)}else s(c)},[a,e,s,o])]}ma(ga,"useControllableState");function fb({defaultProp:e,onChange:t}){const[n,r]=g.useState(e),i=g.useRef(n),s=g.useRef(t);return $M(()=>{s.current=t},[t]),g.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}ma(fb,"useUncontrolledState");function db(e){return typeof e=="function"}ma(db,"isFunction");var Dg=Symbol("RADIX:SYNC_STATE");function HM(e,t,n,r){const{prop:i,defaultProp:s,onChange:o,caller:a}=t,l=i!==void 0,c=hb(o),u=[{...n,state:s}];r&&u.push(r);const[h,f]=g.useReducer((y,x)=>{if(x.type===Dg)return{...y,state:x.state};const b=e(y,x);return l&&!Object.is(b.state,y.state)&&c(b.state),b},...u),d=h.state,m=g.useRef(d);g.useEffect(()=>{m.current!==d&&(m.current=d,l||c(d))},[d,m,l]);const v=g.useMemo(()=>i!==void 0?{...h,state:i}:h,[h,i]);return g.useEffect(()=>{l&&!Object.is(i,h.state)&&f({type:Dg,state:i})},[i,h.state,l]),[v,f]}ma(HM,"useControllableStateReducer");var WM=Object.defineProperty,sr=(e,t)=>WM(e,"name",{value:t,configurable:!0});function pb(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}sr(pb,"useStateMachine");var Ln=sr(e=>{const{present:t,children:n}=e,r=mb(t),i=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),s=gb(r.ref,vb(i));return typeof n=="function"||r.isPresent?g.cloneElement(i,{ref:s}):null},"Presence");function mb(e){const[t,n]=g.useState(),r=g.useRef(null),i=g.useRef(e),s=g.useRef("none"),o=g.useRef(void 0),[a,l]=pb(e?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{a==="mounted"?(s.current=o.current??ji(r.current),o.current=void 0):s.current="none"},[a]),Rt(()=>{const c=r.current,u=i.current;if(u!==e){const h=s.current,f=ji(c);e?(o.current=f,l("MOUNT")):f==="none"||c?.display==="none"?l("UNMOUNT"):l(u&&h!==f?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),Rt(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,h=sr(d=>{const m=ji(r.current).includes(CSS.escape(d.animationName));if(d.target===t&&m&&(l("ANIMATION_END"),!i.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},"handleAnimationEnd"),f=sr(d=>{d.target===t&&(s.current=ji(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:g.useCallback(c=>{if(c){const u=getComputedStyle(c);r.current=u,o.current=ji(u)}else r.current=null;n(c)},[])}}sr(mb,"usePresence");function ff(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}sr(ff,"setRef");function gb(...e){const t=g.useRef(e);return t.current=e,g.useCallback(n=>{const r=t.current;let i=!1;const s=r.map(o=>{const a=ff(o,n);return!i&&typeof a=="function"&&(i=!0),a});if(i)return()=>{for(let o=0;o<s.length;o++){const a=s[o];typeof a=="function"?a():ff(r[o],null)}}},[])}sr(gb,"useStableComposedRefs");function ji(e){return e?.animationName||"none"}sr(ji,"getAnimationName");function vb(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)}sr(vb,"getElementRef");var UM=Object.defineProperty,qM=(e,t)=>UM(e,"name",{value:t,configurable:!0}),KM=g[" useId ".trim().toString()]||(()=>{}),GM=0;function di(e){const[t,n]=g.useState(KM());return Rt(()=>{e||n(r=>r??String(GM++))},[e]),e||(t?`radix-${t}`:"")}qM(di,"useId");var QM=Object.defineProperty,YM=(e,t)=>QM(e,"name",{value:t,configurable:!0}),XM=g.createContext(void 0);function $c(e){const t=g.useContext(XM);return e||t||"ltr"}YM($c,"useDirection");var JM=Object.defineProperty,ZM=(e,t)=>JM(e,"name",{value:t,configurable:!0});function Je(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useMemo(()=>((...n)=>t.current?.(...n)),[])}ZM(Je,"useCallbackRef");var eR=Object.defineProperty,Qe=(e,t)=>eR(e,"name",{value:t,configurable:!0}),df="dismissableLayer.update",tR="dismissableLayer.pointerDownOutside",nR="dismissableLayer.focusOutside",Ng,yb=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),xb=g.forwardRef(Qe(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...u}=t,h=g.useContext(yb),[f,d]=g.useState(null),m=f?.ownerDocument??globalThis?.document,[,v]=g.useState({}),y=Ce(n,d),x=Array.from(h.layers),[b]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),w=b?x.indexOf(b):-1,S=f?x.indexOf(f):-1,C=h.layersWithOutsidePointerEventsDisabled.size>0,A=S>=w,k=g.useRef(!1),E=bb(M=>{o?.(M),l?.(M),M.defaultPrevented||c?.()},{ownerDocument:m,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:h.dismissableSurfaces,shouldHandlePointerDownOutside:g.useCallback(M=>{if(!(M instanceof Node))return!1;const N=[...h.branches].some(L=>L.contains(M));return A&&!N},[h.branches,A])}),T=wb(M=>{if(i&&k.current)return;const N=M.target;[...h.branches].some(L=>L.contains(N))||(a?.(M),l?.(M),M.defaultPrevented||c?.())},m),R=f?S===x.length-1:!1,P=Je(M=>{M.key==="Escape"&&(s?.(M),!M.defaultPrevented&&c&&(M.preventDefault(),c()))});return g.useEffect(()=>{if(R)return m.addEventListener("keydown",P,{capture:!0}),()=>m.removeEventListener("keydown",P,{capture:!0})},[m,R,P]),g.useEffect(()=>{if(f)return r&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(Ng=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),pf(),()=>{r&&(h.layersWithOutsidePointerEventsDisabled.delete(f),h.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=Ng))}},[f,m,r,h]),g.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),pf())},[f,h]),g.useEffect(()=>{const M=Qe(()=>v({}),"handleUpdate");return document.addEventListener(df,M),()=>document.removeEventListener(df,M)},[]),(0,p.jsx)(Le.div,{...u,ref:y,style:{pointerEvents:C?A?"auto":"none":void 0,...t.style},onFocusCapture:te(t.onFocusCapture,T.onFocusCapture),onBlurCapture:te(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:te(t.onPointerDownCapture,E.onPointerDownCapture)})},"DismissableLayer"));function rR(){const e=g.useContext(yb),[t,n]=g.useState(null);return g.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}Qe(rR,"useDismissableLayerSurface");var iR=Qe(()=>!0,"IS_TRUE");function bb(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:s,shouldHandlePointerDownOutside:o=iR}=t,a=Je(e),l=g.useRef(!1),c=g.useRef(!1),u=g.useRef(new Map),h=g.useRef(()=>{});return g.useEffect(()=>{function f(){c.current=!1,i.current=!1,u.current.clear()}Qe(f,"resetOutsideInteraction");function d(){return Array.from(u.current.values()).some(Boolean)}Qe(d,"isOutsideInteractionIntercepted");function m(w){if(!c.current)return;const S=w.target;S instanceof Node&&[...s].some(C=>C.contains(S))||u.current.set(w.type,!0),w.type==="click"&&window.setTimeout(()=>{c.current&&h.current()},0)}Qe(m,"handleInteractionCapture");function v(w){c.current&&u.current.set(w.type,!1)}Qe(v,"handleInteractionBubble");const y=Qe(w=>{if(w.target&&!l.current){let S=function(){n.removeEventListener("click",h.current);const A=d();f(),A||Op(tR,a,C,{discrete:!0})};if(Qe(S,"handleAndDispatchPointerDownOutsideEvent"),!o(w.target)){n.removeEventListener("click",h.current),f(),l.current=!1;return}const C={originalEvent:w};c.current=!0,i.current=r&&w.button===0,u.current.clear(),!r||w.button!==0?S():(n.removeEventListener("click",h.current),h.current=S,n.addEventListener("click",h.current,{once:!0}))}else n.removeEventListener("click",h.current),f();l.current=!1},"handlePointerDown"),x=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const w of x)n.addEventListener(w,m,!0),n.addEventListener(w,v);const b=window.setTimeout(()=>{n.addEventListener("pointerdown",y)},0);return()=>{window.clearTimeout(b),n.removeEventListener("pointerdown",y),n.removeEventListener("click",h.current);for(const w of x)n.removeEventListener(w,m,!0),n.removeEventListener(w,v)}},[n,a,r,i,s,o]),{onPointerDownCapture:Qe(()=>l.current=!0,"onPointerDownCapture")}}Qe(bb,"usePointerDownOutside");function wb(e,t=globalThis?.document){const n=Je(e),r=g.useRef(!1);return g.useEffect(()=>{const i=Qe(s=>{s.target&&!r.current&&Op(nR,n,{originalEvent:s},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:Qe(()=>r.current=!0,"onFocusCapture"),onBlurCapture:Qe(()=>r.current=!1,"onBlurCapture")}}Qe(wb,"useFocusOutside");function pf(){const e=new CustomEvent(df);document.dispatchEvent(e)}Qe(pf,"dispatchUpdate");function Op(e,t,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Rp(i,s):i.dispatchEvent(s)}Qe(Op,"handleAndDispatchCustomEvent");var sR=Object.defineProperty,ft=(e,t)=>sR(e,"name",{value:t,configurable:!0}),Hu="focusScope.autoFocusOnMount",Wu="focusScope.autoFocusOnUnmount",Lg={bubbles:!1,cancelable:!0},oR=g.forwardRef(ft(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:s,onUnmountAutoFocus:o,...a}=t,[l,c]=g.useState(null),u=Je(s),h=Je(o),f=g.useRef(null),d=Ce(n,c),m=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(i){let y=function(S){if(m.paused||!l)return;const C=S.target;l.contains(C)?f.current=C:Hn(f.current,{select:!0})},x=function(S){if(m.paused||!l)return;const C=S.relatedTarget;C!==null&&(l.contains(C)||Hn(f.current,{select:!0}))},b=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Hn(l)};ft(y,"handleFocusIn"),ft(x,"handleFocusOut"),ft(b,"handleMutations"),document.addEventListener("focusin",y),document.addEventListener("focusout",x);const w=new MutationObserver(b);return l&&w.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",x),w.disconnect()}}},[i,l,m.paused]),g.useEffect(()=>{if(l){_g.add(m);const y=document.activeElement;if(!l.contains(y)){const x=new CustomEvent(Hu,Lg);l.addEventListener(Hu,u),l.dispatchEvent(x),x.defaultPrevented||(Sb(Eb(Dp(l)),{select:!0}),document.activeElement===y&&Hn(l))}return()=>{l.removeEventListener(Hu,u),setTimeout(()=>{const x=new CustomEvent(Wu,Lg);l.addEventListener(Wu,h),l.dispatchEvent(x),x.defaultPrevented||Hn(y??document.body,{select:!0}),l.removeEventListener(Wu,h),_g.remove(m)},0)}}},[l,u,h,m]);const v=g.useCallback(y=>{if(!r&&!i||m.paused)return;const x=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,b=document.activeElement;if(x&&b){const w=y.currentTarget,[S,C]=kb(w);S&&C?!y.shiftKey&&b===C?(y.preventDefault(),r&&Hn(S,{select:!0})):y.shiftKey&&b===S&&(y.preventDefault(),r&&Hn(C,{select:!0})):b===w&&y.preventDefault()}},[r,i,m.paused]);return(0,p.jsx)(Le.div,{tabIndex:-1,...a,ref:d,onKeyDown:v})},"FocusScope"));function Sb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Hn(r,{select:t}),document.activeElement!==n)return}ft(Sb,"focusFirst");function kb(e){const t=Dp(e);return[mf(t,e),mf(t.reverse(),e)]}ft(kb,"getTabbableEdges");function Dp(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:ft(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}ft(Dp,"getTabbableCandidates");function mf(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Cb(r,{upTo:t})))return r}ft(mf,"findVisible");function Cb(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}ft(Cb,"isHidden");function Ab(e){return e instanceof HTMLInputElement&&"select"in e}ft(Ab,"isSelectableInput");function Hn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ab(e)&&t&&e.select()}}ft(Hn,"focus");var _g=Tb();function Tb(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=gf(e,t),e.unshift(t)},remove(t){e=gf(e,t),e[0]?.resume()}}}ft(Tb,"createFocusScopesStack");function gf(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}ft(gf,"arrayRemove");function Eb(e){return e.filter(t=>t.tagName!=="A")}ft(Eb,"removeLinks");var aR=Object.defineProperty,lR=(e,t)=>aR(e,"name",{value:t,configurable:!0}),Mb=g.forwardRef(lR(function(t,n){const{container:r,...i}=t,[s,o]=g.useState(!1);Rt(()=>o(!0),[]);const a=r||s&&globalThis?.document?.body;return a?pa.createPortal((0,p.jsx)(Le.div,{...i,ref:n}),a):null},"Portal")),cR=Object.defineProperty,Np=(e,t)=>cR(e,"name",{value:t,configurable:!0}),Ba=0,Ei=null;function uR(e){return Lp(),e.children}Np(uR,"FocusGuards");function Lp(){g.useEffect(()=>{Ei||(Ei={start:vf(),end:vf()});const{start:e,end:t}=Ei;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Ba++,()=>{Ba===1&&(Ei?.start.remove(),Ei?.end.remove(),Ei=null),Ba=Math.max(0,Ba-1)}},[])}Np(Lp,"useFocusGuards");function vf(){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}Np(vf,"createFocusGuard");var kn=function(){return kn=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},kn.apply(this,arguments)};function Rb(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 i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function hR(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var Cl="right-scroll-bar-position",Al="width-before-scroll-bar",fR="with-scroll-bars-hidden",dR="--removed-body-scroll-bar-size";function Uu(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function pR(e,t){var n=(0,g.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var mR=typeof window<"u"?g.useLayoutEffect:g.useEffect,jg=new WeakMap;function gR(e,t){var n=pR(t||null,function(r){return e.forEach(function(i){return Uu(i,r)})});return mR(function(){var r=jg.get(n);if(r){var i=new Set(r),s=new Set(e),o=n.current;i.forEach(function(a){s.has(a)||Uu(a,null)}),s.forEach(function(a){i.has(a)||Uu(a,o)})}jg.set(n,e)},[e]),n}function vR(e){return e}function yR(e,t){t===void 0&&(t=vR);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(i){var s=t(i,r);return n.push(s),function(){n=n.filter(function(o){return o!==s})}},assignSyncMedium:function(i){for(r=!0;n.length;){var s=n;n=[],s.forEach(i)}n={push:function(o){return i(o)},filter:function(){return n}}},assignMedium:function(i){r=!0;var s=[];if(n.length){var o=n;n=[],o.forEach(i),s=n}var a=function(){var c=s;s=[],c.forEach(i)},l=function(){return Promise.resolve().then(a)};l(),n={push:function(c){s.push(c),l()},filter:function(c){return s=s.filter(c),n}}}}}function xR(e){e===void 0&&(e={});var t=yR(null);return t.options=kn({async:!0,ssr:!1},e),t}var Pb=function(e){var t=e.sideCar,n=Rb(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 g.createElement(r,kn({},n))};Pb.isSideCarExport=!0;function bR(e,t){return e.useMedium(t),Pb}var Ib=xR(),qu=function(){},Hc=g.forwardRef(function(e,t){var n=g.useRef(null),r=g.useState({onScrollCapture:qu,onWheelCapture:qu,onTouchMoveCapture:qu}),i=r[0],s=r[1],o=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,h=e.shards,f=e.sideCar,d=e.noRelative,m=e.noIsolation,v=e.inert,y=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,w=e.gapMode,S=Rb(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,A=gR([n,t]),k=kn(kn({},S),i);return g.createElement(g.Fragment,null,u&&g.createElement(C,{sideCar:Ib,removeScrollBar:c,shards:h,noRelative:d,noIsolation:m,inert:v,setCallbacks:s,allowPinchZoom:!!y,lockRef:n,gapMode:w}),o?g.cloneElement(g.Children.only(a),kn(kn({},k),{ref:A})):g.createElement(b,kn({},k,{className:l,ref:A}),a))});Hc.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Hc.classNames={fullWidth:Al,zeroRight:Cl};var Bg,wR=function(){if(Bg)return Bg;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function SR(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=wR();return t&&e.setAttribute("nonce",t),e}function kR(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function CR(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}var AR=function(){var e=0,t=null;return{add:function(n){e==0&&(t=SR())&&(kR(t,n),CR(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},TR=function(){var e=AR();return function(t,n){g.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ob=function(){var e=TR(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},ER={left:0,top:0,right:0,gap:0},Ku=function(e){return parseInt(e||"",10)||0},MR=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[Ku(n),Ku(r),Ku(i)]},RR=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ER;var t=MR(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])}},PR=Ob(),bo="data-scroll-locked",IR=function(e,t,n,r){var i=e.left,s=e.top,o=e.right,a=e.gap;return n===void 0&&(n="margin"),`
2
- .`.concat(fR,` {
3
- overflow: hidden `).concat(r,`;
4
- padding-right: `).concat(a,"px ").concat(r,`;
5
- }
6
- body[`).concat(bo,`] {
7
- overflow: hidden `).concat(r,`;
8
- overscroll-behavior: contain;
9
- `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
10
- padding-left: `.concat(i,`px;
11
- padding-top: `).concat(s,`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(Cl,` {
20
- right: `).concat(a,"px ").concat(r,`;
21
- }
22
-
23
- .`).concat(Al,` {
24
- margin-right: `).concat(a,"px ").concat(r,`;
25
- }
26
-
27
- .`).concat(Cl," .").concat(Cl,` {
28
- right: 0 `).concat(r,`;
29
- }
30
-
31
- .`).concat(Al," .").concat(Al,` {
32
- margin-right: 0 `).concat(r,`;
33
- }
34
-
35
- body[`).concat(bo,`] {
36
- `).concat(dR,": ").concat(a,`px;
37
- }
38
- `)},Fg=function(){var e=parseInt(document.body.getAttribute("data-scroll-locked")||"0",10);return isFinite(e)?e:0},OR=function(){g.useEffect(function(){return document.body.setAttribute(bo,(Fg()+1).toString()),function(){var e=Fg()-1;e<=0?document.body.removeAttribute(bo):document.body.setAttribute(bo,e.toString())}},[])},DR=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;OR();var s=g.useMemo(function(){return RR(i)},[i]);return g.createElement(PR,{styles:IR(s,!t,i,n?"":"!important")})},yf=!1;if(typeof window<"u")try{var Fa=Object.defineProperty({},"passive",{get:function(){return yf=!0,!0}});window.addEventListener("test",Fa,Fa),window.removeEventListener("test",Fa,Fa)}catch{yf=!1}var Mi=yf?{passive:!1}:!1,NR=function(e){return e.tagName==="TEXTAREA"},Db=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!NR(e)&&n[t]==="visible")},LR=function(e){return Db(e,"overflowY")},_R=function(e){return Db(e,"overflowX")},Vg=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host),Nb(e,r)){var i=Lb(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},jR=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},BR=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Nb=function(e,t){return e==="v"?LR(t):_R(t)},Lb=function(e,t){return e==="v"?jR(t):BR(t)},FR=function(e,t){return e==="h"&&t==="rtl"?-1:1},VR=function(e,t,n,r,i){var s=FR(e,window.getComputedStyle(t).direction),o=s*r,a=n.target,l=t.contains(a),c=!1,u=o>0,h=0,f=0;do{if(!a)break;var d=Lb(e,a),m=d[0],v=d[1]-d[2]-s*m;(m||v)&&Nb(e,a)&&(h+=v,f+=m);var y=a.parentNode;a=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&(i&&Math.abs(h)<1||!i&&o>h)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(c=!0),c},Va=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},zg=function(e){return[e.deltaX,e.deltaY]},$g=function(e){return e&&"current"in e?e.current:e},zR=function(e,t){return e[0]===t[0]&&e[1]===t[1]},$R=function(e){return`
39
- .block-interactivity-`.concat(e,` {pointer-events: none;}
40
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
41
- `)},HR=0,Ri=[];function WR(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(HR++)[0],s=g.useState(Ob)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var v=hR([e.lockRef.current],(e.shards||[]).map($g),!0).filter(Boolean);return v.forEach(function(y){return y.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,y){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var x=Va(v),b=n.current,w="deltaX"in v?v.deltaX:b[0]-x[0],S="deltaY"in v?v.deltaY:b[1]-x[1],C,A=v.target,k=Math.abs(w)>Math.abs(S)?"h":"v";if("touches"in v&&k==="h"&&A.type==="range")return!1;var E=window.getSelection(),T=E&&E.anchorNode;if(T&&(T===A||T.contains(A)))return!1;var R=Vg(k,A);if(!R)return!0;if(R?C=k:(C=k==="v"?"h":"v",R=Vg(k,A)),!R)return!1;if(!r.current&&"changedTouches"in v&&(w||S)&&(r.current=C),!C)return!0;var P=r.current||C;return VR(P,y,v,P==="h"?w:S,!0)},[]),l=g.useCallback(function(v){var y=v;if(!(!Ri.length||Ri[Ri.length-1]!==s)){var x="deltaY"in y?zg(y):Va(y),b=t.current.filter(function(S){return S.name===y.type&&(S.target===y.target||y.target===S.shadowParent)&&zR(S.delta,x)})[0];if(b&&b.should){y.cancelable&&y.preventDefault();return}if(!b){var w=(o.current.shards||[]).map($g).filter(Boolean).filter(function(S){return S.contains(y.target)});(w.length>0?a(y,w[0]):!o.current.noIsolation)&&y.cancelable&&y.preventDefault()}}},[]),c=g.useCallback(function(v,y,x,b){var w={name:v,delta:y,target:x,should:b,shadowParent:UR(x)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(S){return S!==w})},1)},[]),u=g.useCallback(function(v){n.current=Va(v),r.current=void 0},[]),h=g.useCallback(function(v){c(v.type,zg(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,Va(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return Ri.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Mi),document.addEventListener("touchmove",l,Mi),document.addEventListener("touchstart",u,Mi),function(){Ri=Ri.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,Mi),document.removeEventListener("touchmove",l,Mi),document.removeEventListener("touchstart",u,Mi)}},[]);var d=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:$R(i)}):null,d?g.createElement(DR,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function UR(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var qR=bR(Ib,WR),_b=g.forwardRef(function(e,t){return g.createElement(Hc,kn({},e,{ref:t,sideCar:qR}))});_b.classNames=Hc.classNames;var KR=function(e){return typeof document>"u"?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},Pi=new WeakMap,za=new WeakMap,$a={},Gu=0,jb=function(e){return e&&(e.host||jb(e.parentNode))},GR=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=jb(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})},QR=function(e,t,n,r){var i=GR(t,Array.isArray(e)?e:[e]);$a[n]||($a[n]=new WeakMap);var s=$a[n],o=[],a=new Set,l=new Set(i),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};i.forEach(c);var u=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(f){if(a.has(f))u(f);else try{var d=f.getAttribute(r),m=d!==null&&d!=="false",v=(Pi.get(f)||0)+1,y=(s.get(f)||0)+1;Pi.set(f,v),s.set(f,y),o.push(f),v===1&&m&&za.set(f,!0),y===1&&f.setAttribute(n,"true"),m||f.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",f,x)}})};return u(t),a.clear(),Gu++,function(){o.forEach(function(h){var f=Pi.get(h)-1,d=s.get(h)-1;Pi.set(h,f),s.set(h,d),f||(za.has(h)||h.removeAttribute(r),za.delete(h)),d||h.removeAttribute(n)}),Gu--,Gu||(Pi=new WeakMap,Pi=new WeakMap,za=new WeakMap,$a={})}},YR=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||KR(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),QR(r,i,n,"aria-hidden")):function(){return null}},XR=Object.defineProperty,JR=(e,t)=>XR(e,"name",{value:t,configurable:!0});function Bb(e){const[t,n]=g.useState(void 0);return Rt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.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}JR(Bb,"useSize");var ZR=["top","right","bottom","left"],Rr=Math.min,tr=Math.max,oc=Math.round,Ha=Math.floor,nr=e=>({x:e,y:e}),eP={left:"right",right:"left",bottom:"top",top:"bottom"};function Fb(e,t,n){return tr(e,Rr(t,n))}function or(e,t){return typeof e=="function"?e(t):e}function Pr(e){return e.split("-")[0]}function Rs(e){return e.split("-")[1]}function _p(e){return e==="x"?"y":"x"}function jp(e){return e==="y"?"height":"width"}function An(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Bp(e){return _p(An(e))}function tP(e,t,n){n===void 0&&(n=!1);const r=Rs(e),i=Bp(e),s=jp(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=ac(o)),[o,ac(o)]}function nP(e){const t=ac(e);return[xf(e),t,xf(t)]}function xf(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var Hg=["left","right"],Wg=["right","left"],rP=["top","bottom"],iP=["bottom","top"];function sP(e,t,n){switch(e){case"top":case"bottom":return n?t?Wg:Hg:t?Hg:Wg;case"left":case"right":return t?rP:iP;default:return[]}}function oP(e,t,n,r){const i=Rs(e);let s=sP(Pr(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(xf)))),s}function ac(e){const t=Pr(e);return eP[t]+e.slice(t.length)}function aP(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function Vb(e){return typeof e!="number"?aP(e):{top:e,right:e,bottom:e,left:e}}function lc(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Ug(e,t,n){let{reference:r,floating:i}=e;const s=An(t),o=Bp(t),a=jp(o),l=Pr(t),c=s==="y",u=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,f=r[a]/2-i[a]/2;let d;switch(l){case"top":d={x:u,y:r.y-i.height};break;case"bottom":d={x:u,y:r.y+r.height};break;case"right":d={x:r.x+r.width,y:h};break;case"left":d={x:r.x-i.width,y:h};break;default:d={x:r.x,y:r.y}}const m=Rs(t);return m&&(d[o]+=f*(m==="end"?1:-1)*(n&&c?-1:1)),d}async function lP(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:f=!1,padding:d=0}=or(t,e),m=Vb(d),v=a[f?h==="floating"?"reference":"floating":h],y=lc(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),x=h==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,b=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),w=await(s.isElement==null?void 0:s.isElement(b))&&await(s.getScale==null?void 0:s.getScale(b))||{x:1,y:1},S=lc(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:b,strategy:l}):x);return{top:(y.top-S.top+m.top)/w.y,bottom:(S.bottom-y.bottom+m.bottom)/w.y,left:(y.left-S.left+m.left)/w.x,right:(S.right-y.right+m.right)/w.x}}var cP=50,uP=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:lP},l=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:h}=Ug(c,r,l),f=r,d=0;const m={};for(let v=0;v<s.length;v++){const y=s[v];if(!y)continue;const{name:x,fn:b}=y,{x:w,y:S,data:C,reset:A}=await b({x:u,y:h,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:e,floating:t}});u=w??u,h=S??h,m[x]={...m[x],...C},A&&d<cP&&(d++,typeof A=="object"&&(A.placement&&(f=A.placement),A.rects&&(c=A.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):A.rects),{x:u,y:h}=Ug(c,f,l)),v=-1)}return{x:u,y:h,placement:f,strategy:i,middlewareData:m}},hP=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=or(e,t)||{};if(c==null)return{};const h=Vb(u),f={x:n,y:r},d=Bp(i),m=jp(d),v=await o.getDimensions(c),y=d==="y",x=y?"top":"left",b=y?"bottom":"right",w=y?"clientHeight":"clientWidth",S=s.reference[m]+s.reference[d]-f[d]-s.floating[m],C=f[d]-s.reference[d],A=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let k=A?A[w]:0;(!k||!await(o.isElement==null?void 0:o.isElement(A)))&&(k=a.floating[w]||s.floating[m]);const E=S/2-C/2,T=k/2-v[m]/2-1,R=Rr(h[x],T),P=Rr(h[b],T),M=k-v[m]-P,N=k/2-v[m]/2+E,L=Fb(R,N,M),I=!l.arrow&&Rs(i)!=null&&N!==L&&s.reference[m]/2-(N<R?R:P)-v[m]/2<0,_=I?N<R?N-R:N-M:0;return{[d]:f[d]+_,data:{[d]:L,centerOffset:N-L-_,...I&&{alignmentOffset:_}},reset:I}}}),fP=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:v=!0,...y}=or(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Pr(i),b=An(a),w=Pr(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=f||(w||!v?[ac(a)]:nP(a)),A=m!=="none";!f&&A&&C.push(...oP(a,v,m,S));const k=[a,...C],E=await l.detectOverflow(t,y),T=[];let R=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&T.push(E[x]),h){const L=tP(i,o,S);T.push(E[L[0]],E[L[1]])}if(R=[...R,{placement:i,overflows:T}],!T.every(L=>L<=0)){var P,M;const L=(((P=s.flip)==null?void 0:P.index)||0)+1,I=k[L];if(I&&(!(h==="alignment"&&b!==An(I))||R.every(j=>An(j.placement)===b?j.overflows[0]>0:!0)))return{data:{index:L,overflows:R},reset:{placement:I}};let _=(M=R.filter(j=>j.overflows[0]<=0).sort((j,$)=>j.overflows[1]-$.overflows[1])[0])==null?void 0:M.placement;if(!_)switch(d){case"bestFit":{var N;const j=(N=R.filter($=>{if(A){const B=An($.placement);return B===b||B==="y"}return!0}).map($=>[$.placement,$.overflows.filter(B=>B>0).reduce((B,D)=>B+D,0)]).sort(($,B)=>$[1]-B[1])[0])==null?void 0:N[0];j&&(_=j);break}case"initialPlacement":_=a}if(i!==_)return{reset:{placement:_}}}return{}}}};function qg(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Kg(e){return ZR.some(t=>e[t]>=0)}var dP=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=or(e,t);switch(i){case"referenceHidden":{const o=qg(await r.detectOverflow(t,{...s,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Kg(o)}}}case"escaped":{const o=qg(await r.detectOverflow(t,{...s,altBoundary:!0}),n.floating);return{data:{escapedOffsets:o,escaped:Kg(o)}}}default:return{}}}}},zb=new Set(["left","top"]);async function pP(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Pr(n),a=Rs(n),l=An(n)==="y",c=zb.has(o)?-1:1,u=s&&l?-1:1,h=or(t,e);let{mainAxis:f,crossAxis:d,alignmentAxis:m}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof m=="number"&&(d=a==="end"?m*-1:m),l?{x:d*u,y:f*c}:{x:f*c,y:d*u}}var mP=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=t,l=await pP(t,e);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},gP=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:b=>{let{x:w,y:S}=b;return{x:w,y:S}}},...c}=or(e,t),u={x:n,y:r},h=await s.detectOverflow(t,c),f=An(i),d=_p(f);let m=u[d],v=u[f];const y=(b,w)=>Fb(w+h[b==="y"?"top":"left"],w,w-h[b==="y"?"bottom":"right"]);o&&(m=y(d,m)),a&&(v=y(f,v));const x=l.fn({...t,[d]:m,[f]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[d]:o,[f]:a}}}}}},vP=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:s,placement:o,rects:a,middlewareData:l}=t,{offset:c=0,mainAxis:u=!0,crossAxis:h=!0}=or(e,t),f={x:i,y:s},d=An(o),m=_p(d);let v=f[m],y=f[d];const x=or(c,t),b=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:(n=x.mainAxis)!=null?n:0,crossAxis:(r=x.crossAxis)!=null?r:0};if(u){const C=m==="y"?"height":"width",A=a.reference[m]-a.floating[C]+b.mainAxis,k=a.reference[m]+a.reference[C]-b.mainAxis;v<A?v=A:v>k&&(v=k)}if(h){var w,S;const C=m==="y"?"width":"height",A=zb.has(Pr(o)),k=a.reference[d]-a.floating[C]+(A&&((w=l.offset)==null?void 0:w[d])||0)+(A?0:b.crossAxis),E=a.reference[d]+a.reference[C]+(A?0:((S=l.offset)==null?void 0:S[d])||0)-(A?b.crossAxis:0);y<k?y=k:y>E&&(y=E)}return{[m]:v,[d]:y}}}},yP=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:s}=t,{apply:o=()=>{},...a}=or(e,t),l=await i.detectOverflow(t,a),c=Pr(n),u=Rs(n),h=An(n)==="y",{width:f,height:d}=r.floating;let m,v;c==="top"||c==="bottom"?(m=c,v=u===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(v=c,m=u==="end"?"top":"bottom");const y=d-l.top-l.bottom,x=f-l.left-l.right,b=Rr(d-l[m],y),w=Rr(f-l[v],x),S=t.middlewareData.shift,C=!S;let A=b,k=w;S!=null&&S.enabled.x&&(k=x),S!=null&&S.enabled.y&&(A=y),C&&!u&&(h?k=f-2*tr(l.left,l.right):A=d-2*tr(l.top,l.bottom)),await o({...t,availableWidth:k,availableHeight:A});const E=await i.getDimensions(s.floating);return f!==E.width||d!==E.height?{reset:{rects:!0}}:{}}}};function Wc(){return typeof window<"u"}function Ps(e){return $b(e)?(e.nodeName||"").toLowerCase():"#document"}function yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ur(e){var t;return(t=($b(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function $b(e){return Wc()?e instanceof Node||e instanceof yt(e).Node:!1}function On(e){return Wc()?e instanceof Element||e instanceof yt(e).Element:!1}function Fr(e){return Wc()?e instanceof HTMLElement||e instanceof yt(e).HTMLElement:!1}function Gg(e){return!Wc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yt(e).ShadowRoot}function Uc(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function xP(e){return/^(table|td|th)$/.test(Ps(e))}function qc(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var bP=/transform|translate|scale|rotate|perspective|filter/,wP=/paint|layout|strict|content/,Ur=e=>!!e&&e!=="none",Qu;function Fp(e){const t=On(e)?Dn(e):e;return Ur(t.transform)||Ur(t.translate)||Ur(t.scale)||Ur(t.rotate)||Ur(t.perspective)||!Vp()&&(Ur(t.backdropFilter)||Ur(t.filter))||bP.test(t.willChange||"")||wP.test(t.contain||"")}function SP(e){let t=pi(e);for(;Fr(t)&&!Lo(t);){if(Fp(t))return t;if(qc(t))return null;t=pi(t)}return null}function Vp(){return Qu==null&&(Qu=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Qu}function Lo(e){return/^(html|body|#document)$/.test(Ps(e))}function Dn(e){return yt(e).getComputedStyle(e)}function Kc(e){return On(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function pi(e){if(Ps(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Gg(e)&&e.host||ur(e);return Gg(t)?t.host:t}function Hb(e){const t=pi(e);return Lo(t)?(e.ownerDocument||e).body:Fr(t)&&Uc(t)?t:Hb(t)}function _o(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=Hb(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=yt(i);if(s){const a=bf(o);return t.concat(o,o.visualViewport||[],Uc(i)?i:[],a&&n?_o(a):[])}else return t.concat(i,_o(i,[],n))}function bf(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Wb(e){const t=Dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Fr(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=oc(n)!==s||oc(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function zp(e){return On(e)?e:e.contextElement}function es(e){const t=zp(e);if(!Fr(t))return nr(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=Wb(t);let o=(s?oc(n.width):n.width)/r,a=(s?oc(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}var kP=nr(0);function Ub(e){const t=yt(e);return!Vp()||!t.visualViewport?kP:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function CP(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===yt(e)}function mi(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=zp(e);let o=nr(1);t&&(r?On(r)&&(o=es(r)):o=es(e));const a=CP(s,n,r)?Ub(s):nr(0);let l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,u=i.width/o.x,h=i.height/o.y;if(s&&r){const f=yt(s),d=On(r)?yt(r):r;let m=f,v=bf(m);for(;v&&d!==m;){const y=es(v),x=v.getBoundingClientRect(),b=Dn(v),w=x.left+(v.clientLeft+parseFloat(b.paddingLeft))*y.x,S=x.top+(v.clientTop+parseFloat(b.paddingTop))*y.y;l*=y.x,c*=y.y,u*=y.x,h*=y.y,l+=w,c+=S,m=yt(v),v=bf(m)}}return lc({width:u,height:h,x:l,y:c})}function Gc(e,t){const n=Kc(e).scrollLeft;return t?t.left+n:mi(ur(e)).left+n}function qb(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Gc(e,n),y:n.top+t.scrollTop}}function AP(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=ur(r),a=t?qc(t.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=nr(1);const u=nr(0),h=Fr(r);if((h||!s)&&((Ps(r)!=="body"||Uc(o))&&(l=Kc(r)),h)){const d=mi(r);c=es(r),u.x=d.x+r.clientLeft,u.y=d.y+r.clientTop}const f=o&&!h&&!s?qb(o,l):nr(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function TP(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function EP(e){const t=Kc(e),n=e.ownerDocument.body,r=tr(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=tr(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+Gc(e);const o=-t.scrollTop;return Dn(n).direction==="rtl"&&(s+=tr(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:s,y:o}}var MP=25;function RP(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=yt(e),s=ur(e),o=i.visualViewport;let a=s.clientWidth,l=s.clientHeight,c=0,u=0;if(o){const h=!Vp()||t==="fixed";r?h||(c=-o.offsetLeft,u=-o.offsetTop):(a=o.width,l=o.height,h&&(c=o.offsetLeft,u=o.offsetTop))}if(Gc(s)<=0){const h=s.ownerDocument,f=h.body,d=getComputedStyle(f),m=h.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,v=Math.abs(s.clientWidth-f.clientWidth-m),y=getComputedStyle(s).scrollbarGutter==="stable both-edges"?v/2:v;y<=MP&&(a-=y)}return{width:a,height:l,x:c,y:u}}function PP(e,t){const n=mi(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=es(e);return{width:e.clientWidth*s.x,height:e.clientHeight*s.y,x:i*s.x,y:r*s.y}}function Qg(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=RP(e,n,t);else if(t==="document")r=EP(ur(e));else if(On(t))r=PP(t,n);else{const i=Ub(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return lc(r)}function IP(e,t){const n=t.get(e);if(n)return n;let r=_o(e,[],!1).filter(a=>On(a)&&Ps(a)!=="body"),i=null;const s=Dn(e).position==="fixed";let o=s?pi(e):e;for(;On(o)&&!Lo(o);){const a=Dn(o),l=Fp(o),c=i?i.position:s?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?r=r.filter(u=>u!==o):i=a,o=pi(o)}return t.set(e,r),r}function OP(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const s=[...n==="clippingAncestors"?qc(t)?[]:IP(t,this._c):[].concat(n),r],o=Qg(t,s[0],i);let a=o.top,l=o.right,c=o.bottom,u=o.left;for(let h=1;h<s.length;h++){const f=Qg(t,s[h],i);a=tr(f.top,a),l=Rr(f.right,l),c=Rr(f.bottom,c),u=tr(f.left,u)}return{width:l-u,height:c-a,x:u,y:a}}function DP(e){const{width:t,height:n}=Wb(e);return{width:t,height:n}}function NP(e,t,n){const r=Fr(t),i=ur(t),s=n==="fixed",o=mi(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=nr(0);if((r||!s)&&((Ps(t)!=="body"||Uc(i))&&(a=Kc(t)),r)){const u=mi(t,!0,s,t);l.x=u.x+t.clientLeft,l.y=u.y+t.clientTop}!r&&i&&(l.x=Gc(i));const c=i&&!r&&!s?qb(i,a):nr(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 Yu(e){return Dn(e).position==="static"}function Yg(e,t){if(!Fr(e)||Dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ur(e)===n&&(n=n.ownerDocument.body),n}function Kb(e,t){const n=yt(e);if(qc(e))return n;if(!Fr(e)){let i=pi(e);for(;i&&!Lo(i);){if(On(i)&&!Yu(i))return i;i=pi(i)}return n}let r=Yg(e,t);for(;r&&xP(r)&&Yu(r);)r=Yg(r,t);return r&&Lo(r)&&Yu(r)&&!Fp(r)?n:r||SP(e)||n}var LP=async function(e){const t=this.getOffsetParent||Kb,n=this.getDimensions,r=await n(e.floating);return{reference:NP(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function _P(e){return Dn(e).direction==="rtl"}var jP={convertOffsetParentRelativeRectToViewportRelativeRect:AP,getDocumentElement:ur,getClippingRect:OP,getOffsetParent:Kb,getElementRects:LP,getClientRects:TP,getDimensions:DP,getScale:es,isElement:On,isRTL:_P};function Gb(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function BP(e,t,n){let r=null,i;const s=ur(e);function o(){var u;clearTimeout(i),(u=r)==null||u.disconnect(),r=null}function a(u,h){u===void 0&&(u=!1),h===void 0&&(h=1),o();const f=e.getBoundingClientRect(),{left:d,top:m,width:v,height:y}=f;if(u||t(),!v||!y)return;const x=Ha(m),b=Ha(s.clientWidth-(d+v)),w=Ha(s.clientHeight-(m+y)),S=Ha(d),C={rootMargin:-x+"px "+-b+"px "+-w+"px "+-S+"px",threshold:tr(0,Rr(1,h))||1};let A=!0;function k(E){const T=E[0].intersectionRatio;if(!Gb(f,e.getBoundingClientRect()))return a();if(T!==h){if(!A)return a();T?a(!1,T):i=setTimeout(()=>{a(!1,1e-7)},1e3)}A=!1}try{r=new IntersectionObserver(k,{...C,root:s.ownerDocument})}catch{r=new IntersectionObserver(k,C)}r.observe(e)}const l=yt(e),c=()=>a(n);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),o()}}function FP(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=zp(e),u=i||s?[...c?_o(c):[],...t?_o(t):[]]:[];u.forEach(x=>{i&&x.addEventListener("scroll",n),s&&x.addEventListener("resize",n)});const h=c&&a?BP(c,n,s):null;let f=-1,d=null;o&&(d=new ResizeObserver(x=>{let[b]=x;b&&b.target===c&&d&&t&&(d.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var w;(w=d)==null||w.observe(t)})),n()}),c&&!l&&d.observe(c),t&&d.observe(t));let m,v=l?mi(e):null;l&&y();function y(){const x=mi(e);v&&!Gb(v,x)&&n(),v=x,m=requestAnimationFrame(y)}return n(),()=>{var x;u.forEach(b=>{i&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),h?.(),(x=d)==null||x.disconnect(),d=null,l&&cancelAnimationFrame(m)}}var VP=mP,zP=gP,$P=fP,HP=yP,WP=dP,Xg=hP,UP=vP,qP=(e,t,n)=>{const r=new Map,i=n??{},s={...jP,...i.platform,_c:r};return uP(e,t,{...i,platform:s})},Tl=typeof document<"u"?g.useLayoutEffect:function(){};function cc(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,i;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(!cc(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!cc(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Qb(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Jg(e,t){const n=Qb(e);return Math.round(t*n)/n}function Xu(e){const t=g.useRef(e);return Tl(()=>{t.current=e}),t}function KP(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,h]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,d]=g.useState(r);cc(f,r)||d(r);const[m,v]=g.useState(null),[y,x]=g.useState(null),b=g.useCallback($=>{$!==A.current&&(A.current=$,v($))},[]),w=g.useCallback($=>{$!==k.current&&(k.current=$,x($))},[]),S=s||m,C=o||y,A=g.useRef(null),k=g.useRef(null),E=g.useRef(u),T=l!=null,R=Xu(l),P=Xu(i),M=Xu(c),N=g.useCallback(()=>{if(!A.current||!k.current)return;const $={placement:t,strategy:n,middleware:f};P.current&&($.platform=P.current),qP(A.current,k.current,$).then(B=>{const D={...B,isPositioned:M.current!==!1};L.current&&!cc(E.current,D)&&(E.current=D,pa.flushSync(()=>{h(D)}))})},[f,t,n,P,M]);Tl(()=>{c===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,h($=>({...$,isPositioned:!1})))},[c]);const L=g.useRef(!1);Tl(()=>(L.current=!0,()=>{L.current=!1}),[]),Tl(()=>{if(S&&(A.current=S),C&&(k.current=C),S&&C){if(R.current)return R.current(S,C,N);N()}},[S,C,N,R,T]);const I=g.useMemo(()=>({reference:A,floating:k,setReference:b,setFloating:w}),[b,w]),_=g.useMemo(()=>({reference:S,floating:C}),[S,C]),j=g.useMemo(()=>{const $={position:n,left:0,top:0};if(!_.floating)return $;const B=Jg(_.floating,u.x),D=Jg(_.floating,u.y);return a?{...$,transform:"translate("+B+"px, "+D+"px)",...Qb(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:B,top:D}},[n,a,_.floating,u.x,u.y]);return g.useMemo(()=>({...u,update:N,refs:I,elements:_,floatingStyles:j}),[u,N,I,_,j])}var GP=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Xg({element:r.current,padding:i}).fn(n):{}:r?Xg({element:r,padding:i}).fn(n):{}}}},QP=(e,t)=>{const n=VP(e);return{name:n.name,fn:n.fn,options:[e,t]}},YP=(e,t)=>{const n=zP(e);return{name:n.name,fn:n.fn,options:[e,t]}},XP=(e,t)=>({fn:UP(e).fn,options:[e,t]}),JP=(e,t)=>{const n=$P(e);return{name:n.name,fn:n.fn,options:[e,t]}},ZP=(e,t)=>{const n=HP(e);return{name:n.name,fn:n.fn,options:[e,t]}},eI=(e,t)=>{const n=WP(e);return{name:n.name,fn:n.fn,options:[e,t]}},tI=(e,t)=>{const n=GP(e);return{name:n.name,fn:n.fn,options:[e,t]}},nI=Object.defineProperty,rI=(e,t)=>nI(e,"name",{value:t,configurable:!0}),iI=g.forwardRef(rI(function(t,n){const{children:r,width:i=10,height:s=5,...o}=t;return(0,p.jsx)(Le.svg,{...o,ref:n,width:i,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:(0,p.jsx)("polygon",{points:"0,0 30,0 15,10"})})},"Arrow")),sI=iI,oI=Object.defineProperty,rr=(e,t)=>oI(e,"name",{value:t,configurable:!0}),Yb="Popper",[Xb,Qc]=cr(Yb),[aI,Jb]=Xb(Yb),lI=rr(e=>{const{__scopePopper:t,children:n}=e,[r,i]=g.useState(null),[s,o]=g.useState(void 0);return(0,p.jsx)(aI,{scope:t,anchor:r,onAnchorChange:i,placementState:s,setPlacementState:o,children:n})},"Popper"),cI="PopperAnchor",uI=g.forwardRef(rr(function(t,n){const{__scopePopper:r,virtualRef:i,...s}=t,o=Jb(cI,r),a=g.useRef(null),l=o.onAnchorChange,c=g.useCallback(v=>{a.current=v,v&&l(v)},[l]),u=Ce(n,c),h=g.useRef(null);g.useEffect(()=>{if(!i)return;const v=h.current;h.current=i.current,v!==h.current&&l(h.current)});const f=o.placementState&&Yc(o.placementState),d=f?.[0],m=f?.[1];return i?null:(0,p.jsx)(Le.div,{"data-radix-popper-side":d,"data-radix-popper-align":m,...s,ref:u})},"PopperAnchor")),Zb="PopperContent",[hI,fI]=Xb(Zb),dI=g.forwardRef(rr(function(t,n){const{__scopePopper:r,side:i="bottom",sideOffset:s=0,align:o="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:h=0,sticky:f="partial",hideWhenDetached:d=!1,updatePositionStrategy:m="optimized",onPlaced:v,...y}=t,x=Jb(Zb,r),[b,w]=g.useState(null),S=Ce(n,w),[C,A]=g.useState(null),k=Bb(C),E=k?.width??0,T=k?.height??0,R=i+(o!=="center"?"-"+o:""),P=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(u)?u:[u],N=M.length>0,L={padding:P,boundary:M.filter(ew),altBoundary:N},{refs:I,floatingStyles:_,placement:j,isPositioned:$,middlewareData:B}=KP({strategy:"fixed",placement:R,whileElementsMounted:rr((...oe)=>FP(...oe,{animationFrame:m==="always"}),"whileElementsMounted"),elements:{reference:x.anchor},middleware:[QP({mainAxis:s+T,alignmentAxis:a}),c&&YP({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?XP():void 0,...L}),c&&JP({...L}),ZP({...L,apply:rr(({elements:oe,rects:pe,availableWidth:ae,availableHeight:at})=>{const{width:et,height:Re}=pe.reference,ze=oe.floating.style;ze.setProperty("--radix-popper-available-width",`${ae}px`),ze.setProperty("--radix-popper-available-height",`${at}px`),ze.setProperty("--radix-popper-anchor-width",`${et}px`),ze.setProperty("--radix-popper-anchor-height",`${Re}px`)},"apply")}),C&&tI({element:C,padding:l}),vI({arrowWidth:E,arrowHeight:T}),d&&eI({strategy:"referenceHidden",...L,boundary:N?L.boundary:void 0})]}),D=x.setPlacementState;Rt(()=>(D(j),()=>{D(void 0)}),[j,D]);const[se,ne]=Yc(j),F=Je(v);Rt(()=>{$&&F?.()},[$,F]);const q=B.arrow?.x,K=B.arrow?.y,Y=B.arrow?.centerOffset!==0,[H,X]=g.useState();return Rt(()=>{b&&X(window.getComputedStyle(b).zIndex)},[b]),(0,p.jsx)("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{..._,transform:$?_.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:H,"--radix-popper-transform-origin":[B.transformOrigin?.x,B.transformOrigin?.y].join(" "),...B.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:(0,p.jsx)(hI,{scope:r,placedSide:se,placedAlign:ne,onArrowChange:A,arrowX:q,arrowY:K,shouldHideArrow:Y,children:(0,p.jsx)(Le.div,{"data-side":se,"data-align":ne,...y,ref:S,style:{...y.style,animation:$?y.style?.animation:"none"}})})})},"PopperContent")),pI="PopperArrow",mI={top:"bottom",right:"left",bottom:"top",left:"right"},gI=g.forwardRef(rr(function(t,n){const{__scopePopper:r,...i}=t,s=fI(pI,r),o=mI[s.placedSide];return(0,p.jsx)("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:(0,p.jsx)(sI,{...i,ref:n,style:{...i.style,display:"block"}})})},"PopperArrow"));function ew(e){return e!==null}rr(ew,"isNotNull");var vI=rr(e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,s=i.arrow?.centerOffset!==0,o=s?0:e.arrowWidth,a=s?0:e.arrowHeight,[l,c]=Yc(n),u={start:"0%",center:"50%",end:"100%"}[c],h=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+a/2;let d="",m="";return l==="bottom"?(d=s?u:`${h}px`,m=`${-a}px`):l==="top"?(d=s?u:`${h}px`,m=`${r.floating.height+a}px`):l==="right"?(d=`${-a}px`,m=s?u:`${f}px`):l==="left"&&(d=`${r.floating.width+a}px`,m=s?u:`${f}px`),{data:{x:d,y:m}}}}),"transformOrigin");function Yc(e){const[t,n="center"]=e.split("-");return[t,n]}rr(Yc,"getSideAndAlignFromPlacement");var $p=lI,tw=uI,nw=dI,yI=gI,xI=Object.defineProperty,Hp=(e,t)=>xI(e,"name",{value:t,configurable:!0}),Ju=!1;function rw(){const[e,t]=g.useState(Ju);return g.useEffect(()=>{Ju||(Ju=!0,t(!0))},[]),e}Hp(rw,"useIsHydrated");var iw=g[" useSyncExternalStore ".trim().toString()];function sw(){return()=>{}}Hp(sw,"subscribe");function ow(){return iw(sw,()=>!0,()=>!1)}Hp(ow,"useIsHydratedModern");var bI=typeof iw=="function"?ow:rw,wI=Object.defineProperty,Si=(e,t)=>wI(e,"name",{value:t,configurable:!0}),Zu="rovingFocusGroup.onEntryFocus",SI={bubbles:!1,cancelable:!0},Xc="RovingFocusGroup",[wf,aw,kI]=Pp(Xc),[CI,lw]=cr(Xc,[kI]),[AI,TI]=CI(Xc),EI=g.forwardRef(Si(function(t,n){return(0,p.jsx)(wf.Provider,{scope:t.__scopeRovingFocusGroup,children:(0,p.jsx)(wf.Slot,{scope:t.__scopeRovingFocusGroup,children:(0,p.jsx)(MI,{...t,ref:n})})})},"RovingFocusGroup")),MI=g.forwardRef(Si(function(t,n){const{__scopeRovingFocusGroup:r,orientation:i,loop:s=!1,dir:o,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:h=!1,...f}=t,d=g.useRef(null),m=Ce(n,d),v=$c(o),[y,x]=ga({prop:a,defaultProp:l??null,onChange:c,caller:Xc}),[b,w]=g.useState(!1),S=Je(u),C=aw(r),A=g.useRef(!1),[k,E]=g.useState(0);return g.useEffect(()=>{const T=d.current;if(T)return T.addEventListener(Zu,S),()=>T.removeEventListener(Zu,S)},[S]),(0,p.jsx)(AI,{scope:r,orientation:i,dir:v,loop:s,currentTabStopId:y,onItemFocus:g.useCallback(T=>x(T),[x]),onItemShiftTab:g.useCallback(()=>w(!0),[]),onFocusableItemAdd:g.useCallback(()=>E(T=>T+1),[]),onFocusableItemRemove:g.useCallback(()=>E(T=>T-1),[]),children:(0,p.jsx)(Le.div,{tabIndex:b||k===0?-1:0,"data-orientation":i,...f,ref:m,style:{outline:"none",...t.style},onMouseDown:te(t.onMouseDown,()=>{A.current=!0}),onFocus:te(t.onFocus,T=>{const R=!A.current;if(T.target===T.currentTarget&&R&&!b){const P=new CustomEvent(Zu,SI);if(T.currentTarget.dispatchEvent(P),!P.defaultPrevented){const M=C().filter(N=>N.focusable);Wp([M.find(N=>N.active),M.find(N=>N.id===y),...M].filter(Boolean).map(N=>N.ref.current),h)}}A.current=!1}),onBlur:te(t.onBlur,()=>w(!1))})})},"RovingFocusGroupImpl")),RI="RovingFocusGroupItem",PI=g.forwardRef(Si(function(t,n){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:s=!1,tabStopId:o,children:a,...l}=t,c=di(),u=o||c,h=TI(RI,r),f=h.currentTabStopId===u,d=aw(r),{onFocusableItemAdd:m,onFocusableItemRemove:v,currentTabStopId:y}=h,x=bI();return Rt(()=>{if(!(!x||!i))return m(),()=>v()},[x,i,m,v]),g.useEffect(()=>{if(!(x||!i))return m(),()=>v()},[x,i,m,v]),(0,p.jsx)(wf.ItemSlot,{scope:r,id:u,focusable:i,active:s,children:(0,p.jsx)(Le.span,{tabIndex:f?0:-1,"data-orientation":h.orientation,...l,ref:n,onMouseDown:te(t.onMouseDown,b=>{i?h.onItemFocus(u):b.preventDefault()}),onFocus:te(t.onFocus,()=>h.onItemFocus(u)),onKeyDown:te(t.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){h.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const w=uw(b,h.orientation,h.dir);if(w!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let S=d().filter(C=>C.focusable).map(C=>C.ref.current);if(w==="last")S.reverse();else if(w==="prev"||w==="next"){w==="prev"&&S.reverse();const C=S.indexOf(b.currentTarget);S=h.loop?hw(S,C+1):S.slice(C+1)}setTimeout(()=>Wp(S))}}),children:typeof a=="function"?a({isCurrentTabStop:f,hasTabStop:y!=null}):a})})},"RovingFocusGroupItem")),II={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cw(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}Si(cw,"getDirectionAwareKey");function uw(e,t,n){const r=cw(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return II[r]}Si(uw,"getFocusIntent");function Wp(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Si(Wp,"focusFirst");function hw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Si(hw,"wrapArray");var OI=EI,DI=PI,NI=Object.defineProperty,de=(e,t)=>NI(e,"name",{value:t,configurable:!0}),Sf=["Enter"," "],LI=["ArrowDown","PageUp","Home"],fw=["ArrowUp","PageDown","End"],_I=[...LI,...fw],jI={ltr:[...Sf,"ArrowRight"],rtl:[...Sf,"ArrowLeft"]},BI={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Jc="Menu",[jo,FI,VI]=Pp(Jc),[ki,dw]=cr(Jc,[VI,Qc,lw]),Zc=Qc(),pw=lw(),[mw,Vr]=ki(Jc),[zI,va]=ki(Jc),$I=de(e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Zc(t),[l,c]=g.useState(null),u=g.useRef(!1),h=Je(s),f=$c(i);return g.useEffect(()=>{const d=de(()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},"handleKeyDown"),m=de(()=>u.current=!1,"handlePointer");return document.addEventListener("keydown",d,{capture:!0}),()=>{document.removeEventListener("keydown",d,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),g.useEffect(()=>{if(!n)return;const d=de(()=>h(!1),"handleBlur");return window.addEventListener("blur",d),()=>window.removeEventListener("blur",d)},[n,h]),(0,p.jsx)($p,{...a,children:(0,p.jsx)(mw,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:(0,p.jsx)(zI,{scope:t,onClose:g.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},"Menu"),gw=g.forwardRef(de(function(t,n){const{__scopeMenu:r,...i}=t,s=Zc(r);return(0,p.jsx)(tw,{...s,...i,ref:n})},"MenuAnchor")),vw="MenuPortal",[HI,yw]=ki(vw,{forceMount:void 0}),WI=de(e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Vr(vw,t);return(0,p.jsx)(HI,{scope:t,forceMount:n,children:(0,p.jsx)(Ln,{present:n||s.open,children:(0,p.jsx)(Mb,{asChild:!0,container:i,children:r})})})},"MenuPortal"),en="MenuContent",[UI,Up]=ki(en),qI=g.forwardRef(de(function(t,n){const r=yw(en,t.__scopeMenu),{forceMount:i=r.forceMount,...s}=t,o=Vr(en,t.__scopeMenu),a=va(en,t.__scopeMenu);return(0,p.jsx)(jo.Provider,{scope:t.__scopeMenu,children:(0,p.jsx)(Ln,{present:i||o.open,children:(0,p.jsx)(jo.Slot,{scope:t.__scopeMenu,children:a.modal?(0,p.jsx)(KI,{...s,ref:n}):(0,p.jsx)(GI,{...s,ref:n})})})})},"MenuContent")),KI=g.forwardRef(de(function(t,n){const r=Vr(en,t.__scopeMenu),i=g.useRef(null),s=Ce(n,i);return g.useEffect(()=>{const o=i.current;if(o)return YR(o)},[]),(0,p.jsx)(qp,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:te(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),GI=g.forwardRef(de(function(t,n){const r=Vr(en,t.__scopeMenu);return(0,p.jsx)(qp,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),QI=cs("MenuContent.ScrollLock"),qp=g.forwardRef(de(function(t,n){const{__scopeMenu:r,loop:i=!1,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:d,onDismiss:m,disableOutsideScroll:v,...y}=t,x=Vr(en,r),b=va(en,r),w=Zc(r),S=pw(r),C=FI(r),[A,k]=g.useState(null),E=g.useRef(null),T=Ce(n,E,x.onContentChange),R=g.useRef(0),P=g.useRef(""),M=g.useRef(0),N=g.useRef(null),L=g.useRef("right"),I=g.useRef(0),_=v?_b:g.Fragment,j=v?{as:QI,allowPinchZoom:!0}:void 0,$=de(D=>{const se=P.current+D,ne=C().filter(H=>!H.disabled),F=document.activeElement,q=ne.find(H=>H.ref.current===F)?.textValue,K=Tw(ne.map(H=>H.textValue),se,q),Y=ne.find(H=>H.textValue===K)?.ref.current;de((function H(X){P.current=X,window.clearTimeout(R.current),X!==""&&(R.current=window.setTimeout(()=>H(""),1e3))}),"updateSearch")(se),Y&&setTimeout(()=>Y.focus())},"handleTypeaheadSearch");g.useEffect(()=>()=>window.clearTimeout(R.current),[]),Lp();const B=g.useCallback(D=>L.current===N.current?.side&&Mw(D,N.current?.area),[]);return(0,p.jsx)(UI,{scope:r,searchRef:P,onItemEnter:g.useCallback(D=>{B(D)&&D.preventDefault()},[B]),onItemLeave:g.useCallback(D=>{B(D)||(E.current?.focus(),k(null))},[B]),onTriggerLeave:g.useCallback(D=>{B(D)&&D.preventDefault()},[B]),pointerGraceTimerRef:M,onPointerGraceIntentChange:g.useCallback(D=>{N.current=D},[]),children:(0,p.jsx)(_,{...j,children:(0,p.jsx)(oR,{asChild:!0,trapped:s,onMountAutoFocus:te(o,D=>{D.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:(0,p.jsx)(xb,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:d,onDismiss:m,children:(0,p.jsx)(OI,{asChild:!0,...S,dir:b.dir,orientation:"vertical",loop:i,currentTabStopId:A,onCurrentTabStopIdChange:k,onEntryFocus:te(c,D=>{b.isUsingKeyboardRef.current||D.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,p.jsx)(nw,{role:"menu","aria-orientation":"vertical","data-state":Gp(x.open),"data-radix-menu-content":"",dir:b.dir,...w,...y,ref:T,style:{outline:"none",...y.style},onKeyDown:te(y.onKeyDown,D=>{const se=D.target.closest("[data-radix-menu-content]")===D.currentTarget,ne=D.ctrlKey||D.altKey||D.metaKey,F=D.key.length===1;se&&(D.key==="Tab"&&D.preventDefault(),!ne&&F&&$(D.key));const q=E.current;if(D.target!==q||!_I.includes(D.key))return;D.preventDefault();const K=C().filter(Y=>!Y.disabled).map(Y=>Y.ref.current);fw.includes(D.key)&&K.reverse(),Cw(K)}),onBlur:te(t.onBlur,D=>{D.currentTarget.contains(D.target)||(window.clearTimeout(R.current),P.current="")}),onPointerMove:te(t.onPointerMove,us(D=>{const se=D.target,ne=I.current!==D.clientX;if(D.currentTarget.contains(se)&&ne){const F=D.clientX>I.current?"right":"left";L.current=F,I.current=D.clientX}}))})})})})})})},"MenuContentImpl")),YI=g.forwardRef(de(function(t,n){const{__scopeMenu:r,...i}=t;return(0,p.jsx)(Le.div,{role:"group",...i,ref:n})},"MenuGroup")),XI=g.forwardRef(de(function(t,n){const{__scopeMenu:r,...i}=t;return(0,p.jsx)(Le.div,{...i,ref:n})},"MenuLabel")),kf="MenuItem",Zg="menu.itemSelect",Kp=g.forwardRef(de(function(t,n){const{disabled:r=!1,onSelect:i,...s}=t,o=g.useRef(null),a=va(kf,t.__scopeMenu),l=Up(kf,t.__scopeMenu),c=Ce(n,o),u=g.useRef(!1),h=de(()=>{const f=o.current;if(!r&&f){const d=new CustomEvent(Zg,{bubbles:!0,cancelable:!0});f.addEventListener(Zg,m=>i?.(m),{once:!0}),Rp(f,d),d.defaultPrevented?u.current=!1:a.onClose()}},"handleSelect");return(0,p.jsx)(xw,{...s,ref:c,disabled:r,onClick:te(t.onClick,h),onPointerDown:f=>{t.onPointerDown?.(f),u.current=!0},onPointerUp:te(t.onPointerUp,f=>{u.current||f.currentTarget?.click()}),onKeyDown:te(t.onKeyDown,f=>{r||f.target!==f.currentTarget||l.searchRef.current!==""&&f.key===" "||Sf.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})},"MenuItem")),xw=g.forwardRef(de(function(t,n){const{__scopeMenu:r,disabled:i=!1,textValue:s,...o}=t,a=Up(kf,r),l=pw(r),c=g.useRef(null),u=Ce(n,c),[h,f]=g.useState(!1),[d,m]=g.useState("");return g.useEffect(()=>{const v=c.current;v&&m((v.textContent??"").trim())},[o.children]),(0,p.jsx)(jo.ItemSlot,{scope:r,disabled:i,textValue:s??d,children:(0,p.jsx)(DI,{asChild:!0,...l,focusable:!i,children:(0,p.jsx)(Le.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...o,ref:u,onPointerMove:te(t.onPointerMove,us(v=>{i?a.onItemLeave(v):(a.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:te(t.onPointerLeave,us(v=>a.onItemLeave(v))),onFocus:te(t.onFocus,()=>f(!0)),onBlur:te(t.onBlur,()=>f(!1))})})})},"MenuItemImpl")),JI=g.forwardRef(de(function(t,n){const{checked:r=!1,onCheckedChange:i,...s}=t;return(0,p.jsx)(ww,{scope:t.__scopeMenu,checked:r,children:(0,p.jsx)(Kp,{role:"menuitemcheckbox","aria-checked":Bo(r)?"mixed":r,...s,ref:n,"data-state":eu(r),onSelect:te(s.onSelect,()=>i?.(Bo(r)?!0:!r),{checkForDefaultPrevented:!1})})})},"MenuCheckboxItem")),[ZI,eO]=ki("MenuRadioGroup",{value:void 0,onValueChange:de(()=>{},"onValueChange")}),tO=g.forwardRef(de(function(t,n){const{value:r,onValueChange:i,...s}=t,o=Je(i);return(0,p.jsx)(ZI,{scope:t.__scopeMenu,value:r,onValueChange:o,children:(0,p.jsx)(YI,{...s,ref:n})})},"MenuRadioGroup")),nO="MenuRadioItem",rO=g.forwardRef(de(function(t,n){const{value:r,...i}=t,s=eO(nO,t.__scopeMenu),o=r===s.value;return(0,p.jsx)(ww,{scope:t.__scopeMenu,checked:o,children:(0,p.jsx)(Kp,{role:"menuitemradio","aria-checked":o,...i,ref:n,"data-state":eu(o),onSelect:te(i.onSelect,()=>s.onValueChange?.(r),{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),bw="MenuItemIndicator",[ww,iO]=ki(bw,{checked:!1}),sO=g.forwardRef(de(function(t,n){const{__scopeMenu:r,forceMount:i,...s}=t,o=iO(bw,r);return(0,p.jsx)(Ln,{present:i||Bo(o.checked)||o.checked===!0,children:(0,p.jsx)(Le.span,{...s,ref:n,"data-state":eu(o.checked)})})},"MenuItemIndicator")),oO=g.forwardRef(de(function(t,n){const{__scopeMenu:r,...i}=t;return(0,p.jsx)(Le.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})},"MenuSeparator")),Sw="MenuSub",[aO,kw]=ki(Sw),lO=de(e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=Vr(Sw,t),o=Zc(t),[a,l]=g.useState(null),[c,u]=g.useState(null),h=Je(i);return g.useEffect(()=>(s.open===!1&&h(!1),()=>h(!1)),[s.open,h]),(0,p.jsx)($p,{...o,children:(0,p.jsx)(mw,{scope:t,open:r,onOpenChange:h,content:c,onContentChange:u,children:(0,p.jsx)(aO,{scope:t,contentId:di(),triggerId:di(),trigger:a,onTriggerChange:l,children:n})})})},"MenuSub"),Wa="MenuSubTrigger",cO=g.forwardRef(de(function(t,n){const r=Vr(Wa,t.__scopeMenu),i=va(Wa,t.__scopeMenu),s=kw(Wa,t.__scopeMenu),o=Up(Wa,t.__scopeMenu),a=g.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=o,u={__scopeMenu:t.__scopeMenu},h=g.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);g.useEffect(()=>h,[h]),g.useEffect(()=>{const d=l.current;return()=>{window.clearTimeout(d),c(null)}},[l,c]);const f=Ce(n,s.onTriggerChange);return(0,p.jsx)(gw,{asChild:!0,...u,children:(0,p.jsx)(xw,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?s.contentId:void 0,"data-state":Gp(r.open),...t,ref:f,onClick:d=>{t.onClick?.(d),!(t.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:te(t.onPointerMove,us(d=>{o.onItemEnter(d),!d.defaultPrevented&&!t.disabled&&!r.open&&!a.current&&(o.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{r.onOpenChange(!0),h()},100))})),onPointerLeave:te(t.onPointerLeave,us(d=>{h();const m=r.content?.getBoundingClientRect();if(m){const v=r.content?.dataset.side,y=v==="right",x=y?-5:5,b=m[y?"left":"right"],w=m[y?"right":"left"];o.onPointerGraceIntentChange({area:[{x:d.clientX+x,y:d.clientY},{x:b,y:m.top},{x:w,y:m.top},{x:w,y:m.bottom},{x:b,y:m.bottom}],side:v}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(d),d.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:te(t.onKeyDown,d=>{t.disabled||d.target!==d.currentTarget||o.searchRef.current!==""&&d.key===" "||jI[i.dir].includes(d.key)&&(r.onOpenChange(!0),r.content?.focus(),d.preventDefault())})})})},"MenuSubTrigger")),uO="MenuSubContent",hO=g.forwardRef(de(function(t,n){const r=yw(en,t.__scopeMenu),{forceMount:i=r.forceMount,align:s="start",...o}=t,a=Vr(en,t.__scopeMenu),l=va(en,t.__scopeMenu),c=kw(uO,t.__scopeMenu),u=g.useRef(null),h=Ce(n,u);return(0,p.jsx)(jo.Provider,{scope:t.__scopeMenu,children:(0,p.jsx)(Ln,{present:i||a.open,children:(0,p.jsx)(jo.Slot,{scope:t.__scopeMenu,children:(0,p.jsx)(qp,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:h,align:s,side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{l.isUsingKeyboardRef.current&&u.current?.focus(),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:te(t.onFocusOutside,f=>{f.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:te(t.onEscapeKeyDown,f=>{l.onClose(),f.preventDefault()}),onKeyDown:te(t.onKeyDown,f=>{const d=f.currentTarget.contains(f.target),m=BI[l.dir].includes(f.key);d&&m&&(a.onOpenChange(!1),c.trigger?.focus(),f.preventDefault())})})})})})},"MenuSubContent"));function Gp(e){return e?"open":"closed"}de(Gp,"getOpenState");function Bo(e){return e==="indeterminate"}de(Bo,"isIndeterminate");function eu(e){return Bo(e)?"indeterminate":e?"checked":"unchecked"}de(eu,"getCheckedState");function Cw(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}de(Cw,"focusFirst");function Aw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}de(Aw,"wrapArray");function Tw(e,t,n){const r=t.length>1&&Array.from(t).every(a=>a===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=Aw(e,Math.max(i,0));r.length===1&&(s=s.filter(a=>a!==n));const o=s.find(a=>a.toLowerCase().startsWith(r.toLowerCase()));return o!==n?o:void 0}de(Tw,"getNextMatch");function Ew(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,h=l.x,f=l.y;u>r!=f>r&&n<(h-c)*(r-u)/(f-u)+c&&(i=!i)}return i}de(Ew,"isPointInPolygon");function Mw(e,t){return t?Ew({x:e.clientX,y:e.clientY},t):!1}de(Mw,"isPointerInGraceArea");function us(e){return t=>t.pointerType==="mouse"?e(t):void 0}de(us,"whenMouse");var fO=$I,dO=gw,pO=WI,mO=qI,gO=XI,vO=Kp,yO=JI,xO=tO,bO=rO,wO=sO,SO=oO,kO=lO,CO=cO,AO=hO,TO=Object.defineProperty,xt=(e,t)=>TO(e,"name",{value:t,configurable:!0}),Qp="DropdownMenu",[EO,g6]=cr(Qp,[dw]),bt=dw(),[MO,Rw]=EO(Qp),RO=xt(e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=bt(t),c=g.useRef(null),[u,h]=ga({prop:i,defaultProp:s??!1,onChange:o,caller:Qp});return(0,p.jsx)(MO,{scope:t,triggerId:di(),triggerRef:c,contentId:di(),open:u,onOpenChange:h,onOpenToggle:g.useCallback(()=>h(f=>!f),[h]),modal:a,children:(0,p.jsx)(fO,{...l,open:u,onOpenChange:h,dir:r,modal:a,children:n})})},"DropdownMenu"),PO="DropdownMenuTrigger",IO=g.forwardRef(xt(function(t,n){const{__scopeDropdownMenu:r,disabled:i=!1,...s}=t,o=Rw(PO,r),a=bt(r),l=Ce(n,o.triggerRef);return(0,p.jsx)(dO,{asChild:!0,...a,children:(0,p.jsx)(Le.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":i?"":void 0,disabled:i,...s,ref:l,onPointerDown:te(t.onPointerDown,c=>{!i&&c.button===0&&c.ctrlKey===!1&&(o.onOpenToggle(),o.open||c.preventDefault())}),onKeyDown:te(t.onKeyDown,c=>{i||(["Enter"," "].includes(c.key)&&o.onOpenToggle(),c.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})},"DropdownMenuTrigger")),OO=xt(e=>{const{__scopeDropdownMenu:t,...n}=e,r=bt(t);return(0,p.jsx)(pO,{...r,...n})},"DropdownMenuPortal"),DO="DropdownMenuContent",NO=g.forwardRef(xt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=Rw(DO,r),o=bt(r),a=g.useRef(!1);return(0,p.jsx)(mO,{id:s.contentId,"aria-labelledby":s.triggerId,...o,...i,ref:n,onCloseAutoFocus:te(t.onCloseAutoFocus,l=>{a.current||s.triggerRef.current?.focus(),a.current=!1,l.preventDefault()}),onInteractOutside:te(t.onInteractOutside,l=>{const c=l.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,h=c.button===2||u;(!s.modal||h)&&(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")),LO=g.forwardRef(xt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=bt(r);return(0,p.jsx)(gO,{...s,...i,ref:n})},"DropdownMenuLabel")),_O=g.forwardRef(xt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=bt(r);return(0,p.jsx)(vO,{...s,...i,ref:n})},"DropdownMenuItem")),jO=g.forwardRef(xt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=bt(r);return(0,p.jsx)(yO,{...s,...i,ref:n})},"DropdownMenuCheckboxItem")),BO=g.forwardRef(xt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=bt(r);return(0,p.jsx)(xO,{...s,...i,ref:n})},"DropdownMenuRadioGroup")),FO=g.forwardRef(xt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=bt(r);return(0,p.jsx)(bO,{...s,...i,ref:n})},"DropdownMenuRadioItem")),VO=g.forwardRef(xt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=bt(r);return(0,p.jsx)(wO,{...s,...i,ref:n})},"DropdownMenuItemIndicator")),zO=g.forwardRef(xt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=bt(r);return(0,p.jsx)(SO,{...s,...i,ref:n})},"DropdownMenuSeparator")),$O=xt(e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=bt(t),[a,l]=ga({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return(0,p.jsx)(kO,{...o,open:a,onOpenChange:l,children:n})},"DropdownMenuSub"),HO=g.forwardRef(xt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=bt(r);return(0,p.jsx)(CO,{...s,...i,ref:n})},"DropdownMenuSubTrigger")),WO=g.forwardRef(xt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=bt(r);return(0,p.jsx)(AO,{...s,...i,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")),UO=RO,qO=IO,KO=OO,GO=NO,QO=LO,YO=_O,XO=jO,JO=BO,ZO=FO,Pw=VO,eD=zO,tD=$O,nD=HO,rD=WO,iD=Object.defineProperty,sD=(e,t)=>iD(e,"name",{value:t,configurable:!0});function Iw(e,[t,n]){return Math.min(n,Math.max(t,e))}sD(Iw,"clamp");var oD=Object.defineProperty,he=(e,t)=>oD(e,"name",{value:t,configurable:!0});function Ow(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}he(Ow,"useStateMachine");var Dw="ScrollArea",[Nw,v6]=cr(Dw),[aD,Ft]=Nw(Dw),lD=g.forwardRef(he(function(t,n){const{__scopeScrollArea:r,type:i="hover",dir:s,scrollHideDelay:o=600,...a}=t,[l,c]=g.useState(null),[u,h]=g.useState(null),[f,d]=g.useState(null),[m,v]=g.useState(null),[y,x]=g.useState(null),[b,w]=g.useState(0),[S,C]=g.useState(0),[A,k]=g.useState(!1),[E,T]=g.useState(!1),R=Ce(n,c),P=$c(s);return(0,p.jsx)(aD,{scope:r,type:i,dir:P,scrollHideDelay:o,scrollArea:l,viewport:u,onViewportChange:h,content:f,onContentChange:d,scrollbarX:m,onScrollbarXChange:v,scrollbarXEnabled:A,onScrollbarXEnabledChange:k,scrollbarY:y,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:T,onCornerWidthChange:w,onCornerHeightChange:C,children:(0,p.jsx)(Le.div,{dir:P,...a,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":S+"px",...t.style}})})},"ScrollArea")),cD="ScrollAreaViewport",uD=g.forwardRef(he(function(t,n){const{__scopeScrollArea:r,children:i,nonce:s,...o}=t,a=Ft(cD,r),l=g.useRef(null),c=Ce(n,l,a.onViewportChange);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(hD,{nonce:s}),(0,p.jsx)(Le.div,{"data-radix-scroll-area-viewport":"",...o,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...t.style},children:(0,p.jsx)("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})},"ScrollAreaViewport")),hD=g.memo(he(function({nonce:t}){return(0,p.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),hr="ScrollAreaScrollbar",fD=g.forwardRef(he(function(t,n){const{forceMount:r,...i}=t,s=Ft(hr,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:a}=s,l=t.orientation==="horizontal";return g.useEffect(()=>(l?o(!0):a(!0),()=>{l?o(!1):a(!1)}),[l,o,a]),s.type==="hover"?(0,p.jsx)(dD,{...i,ref:n,forceMount:r}):s.type==="scroll"?(0,p.jsx)(pD,{...i,ref:n,forceMount:r}):s.type==="auto"?(0,p.jsx)(Lw,{...i,ref:n,forceMount:r}):s.type==="always"?(0,p.jsx)(Yp,{...i,ref:n,"data-state":"visible"}):null},"ScrollAreaScrollbar")),dD=g.forwardRef(he(function(t,n){const{forceMount:r,...i}=t,s=Ft(hr,t.__scopeScrollArea),[o,a]=g.useState(!1);return g.useEffect(()=>{const l=s.scrollArea;let c=0;if(l){const u=he(()=>{window.clearTimeout(c),a(!0)},"handlePointerEnter"),h=he(()=>{c=window.setTimeout(()=>a(!1),s.scrollHideDelay)},"handlePointerLeave");return l.addEventListener("pointerenter",u),l.addEventListener("pointerleave",h),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",u),l.removeEventListener("pointerleave",h)}}},[s.scrollArea,s.scrollHideDelay]),(0,p.jsx)(Ln,{present:r||o,children:(0,p.jsx)(Lw,{"data-state":o?"visible":"hidden",...i,ref:n})})},"ScrollAreaScrollbarHover")),pD=g.forwardRef(he(function(t,n){const{forceMount:r,...i}=t,s=Ft(hr,t.__scopeScrollArea),o=t.orientation==="horizontal",a=xa(()=>c("SCROLL_END"),100),[l,c]=Ow("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 g.useEffect(()=>{if(l==="idle"){const u=window.setTimeout(()=>c("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(u)}},[l,s.scrollHideDelay,c]),g.useEffect(()=>{const u=s.viewport,h=o?"scrollLeft":"scrollTop";if(u){let f=u[h];const d=he(()=>{const m=u[h];f!==m&&(c("SCROLL"),a()),f=m},"handleScroll");return u.addEventListener("scroll",d),()=>u.removeEventListener("scroll",d)}},[s.viewport,o,c,a]),(0,p.jsx)(Ln,{present:r||l!=="hidden",children:(0,p.jsx)(Yp,{"data-state":l==="hidden"?"hidden":"visible",...i,ref:n,onPointerEnter:te(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:te(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})},"ScrollAreaScrollbarScroll")),Lw=g.forwardRef(he(function(t,n){const r=Ft(hr,t.__scopeScrollArea),{forceMount:i,...s}=t,[o,a]=g.useState(!1),l=t.orientation==="horizontal",c=xa(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,h=r.viewport.offsetHeight<r.viewport.scrollHeight;a(l?u:h)}},10);return gi(r.viewport,c),gi(r.content,c),(0,p.jsx)(Ln,{present:i||o,children:(0,p.jsx)(Yp,{"data-state":o?"visible":"hidden",...s,ref:n})})},"ScrollAreaScrollbarAuto")),Yp=g.forwardRef(he(function(t,n){const{orientation:r="vertical",...i}=t,s=Ft(hr,t.__scopeScrollArea),o=g.useRef(null),a=g.useRef(0),[l,c]=g.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Xp(l.viewport,l.content),h={...i,sizes:l,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:he(d=>o.current=d,"onThumbChange"),onThumbPointerUp:he(()=>a.current=0,"onThumbPointerUp"),onThumbPointerDown:he(d=>a.current=d,"onThumbPointerDown")};function f(d,m){return Fw(d,a.current,l,m)}return he(f,"getScrollPosition"),r==="horizontal"?(0,p.jsx)(mD,{...h,ref:n,onThumbPositionChange:()=>{if(s.viewport&&o.current){const d=s.viewport.scrollLeft,m=Af(d,l,s.dir);o.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:d=>{s.viewport&&(s.viewport.scrollLeft=d)},onDragScroll:d=>{s.viewport&&(s.viewport.scrollLeft=f(d,s.dir))}}):r==="vertical"?(0,p.jsx)(gD,{...h,ref:n,onThumbPositionChange:()=>{if(s.viewport&&o.current){const d=s.viewport.scrollTop,m=Af(d,l);o.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:d=>{s.viewport&&(s.viewport.scrollTop=d)},onDragScroll:d=>{s.viewport&&(s.viewport.scrollTop=f(d))}}):null},"ScrollAreaScrollbarVisible")),mD=g.forwardRef(he(function(t,n){const{sizes:r,onSizesChange:i,...s}=t,o=Ft(hr,t.__scopeScrollArea),[a,l]=g.useState(),c=g.useRef(null),u=Ce(n,c,o.onScrollbarXChange);return g.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,p.jsx)(jw,{"data-orientation":"horizontal",...s,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":ya(r)+"px",...t.style},onThumbPointerDown:h=>t.onThumbPointerDown(h.x),onDragScroll:h=>t.onDragScroll(h.x),onWheelScroll:(h,f)=>{if(o.viewport){const d=o.viewport.scrollLeft+h.deltaX;t.onWheelScroll(d),Zp(d,f)&&h.preventDefault()}},onResize:()=>{c.current&&o.viewport&&a&&i({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Fo(a.paddingLeft),paddingEnd:Fo(a.paddingRight)}})}})},"ScrollAreaScrollbarX")),gD=g.forwardRef(he(function(t,n){const{sizes:r,onSizesChange:i,...s}=t,o=Ft(hr,t.__scopeScrollArea),[a,l]=g.useState(),c=g.useRef(null),u=Ce(n,c,o.onScrollbarYChange);return g.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,p.jsx)(jw,{"data-orientation":"vertical",...s,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":ya(r)+"px",...t.style},onThumbPointerDown:h=>t.onThumbPointerDown(h.y),onDragScroll:h=>t.onDragScroll(h.y),onWheelScroll:(h,f)=>{if(o.viewport){const d=o.viewport.scrollTop+h.deltaY;t.onWheelScroll(d),Zp(d,f)&&h.preventDefault()}},onResize:()=>{c.current&&o.viewport&&a&&i({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Fo(a.paddingTop),paddingEnd:Fo(a.paddingBottom)}})}})},"ScrollAreaScrollbarY")),[vD,_w]=Nw(hr),jw=g.forwardRef(he(function(t,n){const{__scopeScrollArea:r,sizes:i,hasThumb:s,onThumbChange:o,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:h,onResize:f,...d}=t,m=Ft(hr,r),[v,y]=g.useState(null),x=Ce(n,y),b=g.useRef(null),w=g.useRef(""),S=m.viewport,C=i.content-i.viewport,A=Je(h),k=Je(c),E=xa(f,10);function T(R){if(b.current){const P=R.clientX-b.current.left,M=R.clientY-b.current.top;u({x:P,y:M})}}return he(T,"handleDragScroll"),g.useEffect(()=>{const R=he(P=>{const M=P.target;v?.contains(M)&&A(P,C)},"handleWheel");return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,C,A]),g.useEffect(k,[i,k]),gi(v,E),gi(m.content,E),(0,p.jsx)(vD,{scope:r,scrollbar:v,hasThumb:s,onThumbChange:Je(o),onThumbPointerUp:Je(a),onThumbPositionChange:k,onThumbPointerDown:Je(l),children:(0,p.jsx)(Le.div,{...d,ref:x,style:{position:"absolute",...d.style},onPointerDown:te(t.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),b.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),T(R))}),onPointerMove:te(t.onPointerMove,T),onPointerUp:te(t.onPointerUp,R=>{const P=R.target;P.hasPointerCapture(R.pointerId)&&P.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=w.current,m.viewport&&(m.viewport.style.scrollBehavior=""),b.current=null})})})},"ScrollAreaScrollbarImpl")),Cf="ScrollAreaThumb",yD=g.forwardRef(he(function(t,n){const{forceMount:r,...i}=t,s=_w(Cf,t.__scopeScrollArea);return(0,p.jsx)(Ln,{present:r||s.hasThumb,children:(0,p.jsx)(xD,{ref:n,...i})})},"ScrollAreaThumb")),xD=g.forwardRef(he(function(t,n){const{__scopeScrollArea:r,style:i,...s}=t,o=Ft(Cf,r),a=_w(Cf,r),{onThumbPositionChange:l}=a,c=Ce(n,a.onThumbChange),u=g.useRef(void 0),h=xa(()=>{u.current&&(u.current(),u.current=void 0)},100);return g.useEffect(()=>{const f=o.viewport;if(f){const d=he(()=>{if(h(),!u.current){const m=SD(f,l);u.current=m,l()}},"handleScroll");return l(),f.addEventListener("scroll",d),()=>f.removeEventListener("scroll",d)}},[o.viewport,h,l]),(0,p.jsx)(Le.div,{"data-state":a.hasThumb?"visible":"hidden",...s,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:te(t.onPointerDownCapture,f=>{const d=f.target.getBoundingClientRect(),m=f.clientX-d.left,v=f.clientY-d.top;a.onThumbPointerDown({x:m,y:v})}),onPointerUp:te(t.onPointerUp,a.onThumbPointerUp)})},"ScrollAreaThumbImpl")),Bw="ScrollAreaCorner",bD=g.forwardRef(he(function(t,n){const r=Ft(Bw,t.__scopeScrollArea),i=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&i?(0,p.jsx)(wD,{...t,ref:n}):null},"ScrollAreaCorner")),wD=g.forwardRef(he(function(t,n){const{__scopeScrollArea:r,...i}=t,s=Ft(Bw,r),[o,a]=g.useState(0),[l,c]=g.useState(0),u=!!(o&&l),{onCornerWidthChange:h,onCornerHeightChange:f}=s;return gi(s.scrollbarX,()=>{const d=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(d),c(d)}),gi(s.scrollbarY,()=>{const d=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(d),a(d)}),g.useEffect(()=>()=>{h(0),f(0)},[h,f]),u?(0,p.jsx)(Le.div,{...i,ref:n,style:{width:o,height:l,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null},"ScrollAreaCornerImpl"));function Fo(e){return e?parseInt(e,10):0}he(Fo,"toInt");function Xp(e,t){const n=e/t;return isNaN(n)?0:n}he(Xp,"getThumbRatio");function ya(e){const t=Xp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}he(ya,"getThumbSize");function Fw(e,t,n,r="ltr"){const i=ya(n),s=i/2,o=t||s,a=i-o,l=n.scrollbar.paddingStart+o,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,u=n.content-n.viewport,h=r==="ltr"?[0,u]:[u*-1,0];return Jp([l,c],h)(e)}he(Fw,"getScrollPositionFromPointer");function Af(e,t,n="ltr"){const r=ya(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-i,o=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,o]:[o*-1,0],c=Iw(e,l);return Jp([0,o],[0,a])(c)}he(Af,"getThumbOffsetFromScroll");function Jp(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])}}he(Jp,"linearScale");function Zp(e,t){return e>0&&e<t}he(Zp,"isScrollingWithinScrollbarBounds");var SD=he((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return he((function i(){const s={left:e.scrollLeft,top:e.scrollTop},o=n.left!==s.left,a=n.top!==s.top;(o||a)&&t(),n=s,r=window.requestAnimationFrame(i)}),"loop")(),()=>window.cancelAnimationFrame(r)},"addUnlinkedScrollListener");function xa(e,t){const n=Je(e),r=g.useRef(0);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),g.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}he(xa,"useDebounceCallback");function gi(e,t){const n=Je(t);Rt(()=>{let r=0;if(e){const i=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return i.observe(e),()=>{window.cancelAnimationFrame(r),i.unobserve(e)}}},[e,n])}he(gi,"useResizeObserver");var kD=lD,CD=uD,AD=bD,TD=Object.defineProperty,qe=(e,t)=>TD(e,"name",{value:t,configurable:!0}),[em,y6]=cr("Tooltip",[Qc]),tu=Qc(),ED="TooltipProvider",MD=700,Tf="tooltip.open",[RD,tm]=em(ED),PD=qe(e=>{const{__scopeTooltip:t,delayDuration:n=MD,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),(0,p.jsx)(RD,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{r<=0||(window.clearTimeout(l.current),o.current=!1)},[r]),onClose:g.useCallback(()=>{r<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:g.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})},"TooltipProvider"),Ef="Tooltip",[ID,ba]=em(Ef),OD=qe(e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=tm(Ef,e.__scopeTooltip),c=tu(t),[u,h]=g.useState(null),[f,d]=g.useState(void 0),m=di(),v=g.useRef(0),y=o??l.disableHoverableContent,x=a??l.delayDuration,b=g.useRef(!1),[w,S]=ga({prop:r,defaultProp:i??!1,onChange:qe(R=>{R?(l.onOpen(),document.dispatchEvent(new CustomEvent(Tf))):l.onClose(),s?.(R)},"onChange"),caller:Ef}),C=g.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),A=g.useCallback(()=>{window.clearTimeout(v.current),v.current=0,b.current=!1,S(!0)},[S]),k=g.useCallback(()=>{window.clearTimeout(v.current),v.current=0,S(!1)},[S]),E=g.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{b.current=!0,S(!0),v.current=0},x)},[x,S]);g.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]);const T=f??m;return(0,p.jsx)($p,{...c,children:(0,p.jsx)(ID,{scope:t,contentId:T,setContentId:d,open:w,stateAttribute:C,trigger:u,onTriggerChange:h,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?E():A()},[l.isOpenDelayedRef,E,A]),onTriggerLeave:g.useCallback(()=>{y?k():(window.clearTimeout(v.current),v.current=0)},[k,y]),onOpen:A,onClose:k,disableHoverableContent:y,children:n})})},"Tooltip"),ev="TooltipTrigger",DD=g.forwardRef(qe(function(t,n){const{__scopeTooltip:r,...i}=t,s=ba(ev,r),o=tm(ev,r),a=tu(r),l=g.useRef(null),c=Ce(n,l,s.onTriggerChange),u=g.useRef(!1),h=g.useRef(!1),f=g.useCallback(()=>u.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),(0,p.jsx)(tw,{asChild:!0,...a,children:(0,p.jsx)(Le.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...i,ref:c,onPointerMove:te(t.onPointerMove,d=>{d.pointerType!=="touch"&&!h.current&&!o.isPointerInTransitRef.current&&(s.onTriggerEnter(),h.current=!0)}),onPointerLeave:te(t.onPointerLeave,()=>{s.onTriggerLeave(),h.current=!1}),onPointerDown:te(t.onPointerDown,()=>{s.open&&s.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:te(t.onFocus,()=>{u.current||s.onOpen()}),onBlur:te(t.onBlur,s.onClose),onClick:te(t.onClick,s.onClose)})})},"TooltipTrigger")),Vw="TooltipPortal",[ND,LD]=em(Vw,{forceMount:void 0}),_D=qe(e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=ba(Vw,t);return(0,p.jsx)(ND,{scope:t,forceMount:n,children:(0,p.jsx)(Ln,{present:n||s.open,children:(0,p.jsx)(Mb,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),Vo="TooltipContent",jD=g.forwardRef(qe(function(t,n){const r=LD(Vo,t.__scopeTooltip),{forceMount:i=r.forceMount,side:s="top",...o}=t,a=ba(Vo,t.__scopeTooltip);return(0,p.jsx)(Ln,{present:i||a.open,children:a.disableHoverableContent?(0,p.jsx)(zw,{side:s,...o,ref:n}):(0,p.jsx)(BD,{side:s,...o,ref:n})})},"TooltipContent")),BD=g.forwardRef(qe(function(t,n){const r=ba(Vo,t.__scopeTooltip),i=tm(Vo,t.__scopeTooltip),s=g.useRef(null),o=Ce(n,s),[a,l]=g.useState(null),{trigger:c,onClose:u}=r,h=s.current,{onPointerInTransitChange:f}=i,d=g.useCallback(()=>{l(null),f(!1)},[f]),m=g.useCallback((v,y)=>{const x=v.currentTarget,b={x:v.clientX,y:v.clientY},w=Hw(b,$w(b,x.getBoundingClientRect())),S=Ww(y.getBoundingClientRect()),C=qw([...w,...S]);l(C),f(!0)},[f]);return g.useEffect(()=>()=>d(),[d]),g.useEffect(()=>{if(c&&h){const v=qe(x=>m(x,h),"handleTriggerLeave"),y=qe(x=>m(x,c),"handleContentLeave");return c.addEventListener("pointerleave",v),h.addEventListener("pointerleave",y),()=>{c.removeEventListener("pointerleave",v),h.removeEventListener("pointerleave",y)}}},[c,h,m,d]),g.useEffect(()=>{if(a){const v=qe(y=>{const x=y.target,b={x:y.clientX,y:y.clientY},w=c?.contains(x)||h?.contains(x),S=!Uw(b,a);w?d():S&&(d(),u())},"handleTrackPointerGrace");return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,h,a,u,d]),(0,p.jsx)(zw,{...t,ref:o})},"TooltipContentHoverable")),FD=dM("TooltipContent"),zw=g.forwardRef(qe(function(t,n){const{__scopeTooltip:r,children:i,"aria-label":s,id:o,onEscapeKeyDown:a,onPointerDownOutside:l,...c}=t,u=ba(Vo,r),h=tu(r),{onClose:f}=u;g.useEffect(()=>(document.addEventListener(Tf,f),()=>document.removeEventListener(Tf,f)),[f]),g.useEffect(()=>{if(u.trigger){const m=qe(v=>{v.target instanceof Node&&v.target.contains(u.trigger)&&f()},"handleScroll");return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[u.trigger,f]);const{setContentId:d}=u;return Rt(()=>(d(o),()=>{d(void 0)}),[o,d]),(0,p.jsx)(xb,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:m=>m.preventDefault(),onDismiss:f,children:(0,p.jsxs)(nw,{"data-state":u.stateAttribute,role:s?void 0:"tooltip",id:s?void 0:u.contentId,...h,...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,p.jsx)(FD,{children:i}),s?(0,p.jsx)(OM,{id:u.contentId,role:"tooltip",children:s}):null]})})},"TooltipContentImpl")),VD=g.forwardRef(qe(function(t,n){const{__scopeTooltip:r,...i}=t,s=tu(r);return(0,p.jsx)(yI,{...s,...i,ref:n})},"TooltipArrow"));function $w(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}qe($w,"getExitSideFromRect");function Hw(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}qe(Hw,"getPaddedExitPoints");function Ww(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}qe(Ww,"getPointsFromRect");function Uw(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,h=l.x,f=l.y;u>r!=f>r&&n<(h-c)*(r-u)/(f-u)+c&&(i=!i)}return i}qe(Uw,"isPointInPolygon");function qw(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),Kw(t)}qe(qw,"getHull");function Kw(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}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)}qe(Kw,"getHullPresorted");var zD=PD,$D=OD,HD=DD,WD=_D,UD=jD,qD=VD,Gw={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"}]]};Gw.node;var KD=xe(Gw),Qw={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};Qw.node;var hs=xe(Qw),Yw={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};Yw.node;var Xw=xe(Yw),Jw={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Jw.node;var fs=xe(Jw),Zw={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"]};Zw.node;var GD=xe(Zw),eS={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};eS.node;var tv=xe(eS),tS={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"}]]};tS.node;var ts=xe(tS),nS={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"}]]};nS.node;var QD=xe(nS),rS={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"}]]};rS.node;var YD=xe(rS),iS={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"}]]};iS.node;var XD=xe(iS),sS={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"]};sS.node;var JD=xe(sS),oS={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]};oS.node;var ZD=xe(oS),aS={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"}]]};aS.node;var nv=xe(aS),lS={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"}]]};lS.node;var eN=xe(lS),cS={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"}]]};cS.node;var tN=xe(cS),uS={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"}]]};uS.node;var nN=xe(uS),hS={name:"minus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}]]};hS.node;var rN=xe(hS),fS={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"}]]};fS.node;var iN=xe(fS),dS={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"}]]};dS.node;var sN=xe(dS),pS={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};pS.node;var oN=xe(pS),mS={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"}]]};mS.node;var aN=xe(mS),gS={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"}]]};gS.node;var lN=xe(gS),vS={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"]};vS.node;var cN=xe(vS),yS={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"]};yS.node;var nu=xe(yS),xS={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"}]]};xS.node;var uN=xe(xS),bS={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"]};bS.node;var hN=xe(bS),wS={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"}]]};wS.node;var fN=xe(wS),SS={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"}]]};SS.node;var dN=xe(SS);function pN(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function mN(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0}function gN(e){const t=Object.entries(e).filter(([,n])=>n!==void 0);return t.length>0?Object.fromEntries(t):void 0}var vN=["uncachedInputTokens","cacheReadTokens","cacheWriteTokens","cacheWrite1hTokens","outputTokens","reasoningTokens","webSearchRequests"];function yN(e){const t=pN(e);if(!t)return;const n={};for(const r of vN){const i=mN(t[r]);i!==void 0&&(n[r]=i)}return gN(n)}var zo=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,Gn=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0,Mf=e=>typeof e=="string"&&e.length>0?e:void 0;function Yr(e,t){return t.includes(e)?e:void 0}function kr(e,t,n){const r={};for(const i of t){const s=n(e[i]);s!==void 0&&(r[i]=s)}return r}var rv=["input","output","cacheRead","cacheWrite","cacheWrite1h"];function xN(e){const t=zo(e);if(!t||t.currency!=="USD")return;const n=kr(t,[...rv,"webSearchPerThousand"],Gn);if(n.input===void 0||n.output===void 0)return;const r=(Array.isArray(t.tiers)?t.tiers:[]).map(zo).filter(i=>Gn(i?.aboveInputTokens)!==void 0).map(i=>kr(i,["aboveInputTokens",...rv],Gn));return{...n,currency:"USD",...r.length>0?{tiers:r}:{}}}function bN(e){const t=zo(e),n=Yr(t?.source,["list_price","customer_rate"]),r=xN(t?.rates),i=Mf(t?.modelId);if(!t||!n||!r||!i)return;const s=Array.isArray(t.assumptions)?t.assumptions.filter(o=>typeof o=="string"):[];return{source:n,rates:r,modelId:i,...kr(t,["provider","versionId"],Mf),...kr(t,["effectiveAt","retrievedAt"],Gn),...s.length>0?{assumptions:s}:{}}}function kS(e){const t=zo(e);if(!t||t.currency!=="USD")return;const n=Yr(t.completeness,["complete","partial","unavailable"]),r=Gn(t.calculationVersion),i=Gn(t.amountUsd),s=Yr(t.source,["provider_reported","list_price","customer_rate","runner_reported"]);if(!n||r===void 0||n==="unavailable"!=(i===void 0)||i!==void 0&&!s)return;const o=kr(zo(t.parts)??{},["input","cacheRead","cacheWrite","output","webSearch"],Gn),a=(Array.isArray(t.missing)?t.missing:[]).filter(d=>Yr(d,["usage","input_tokens","output_tokens","rate","cache_read_rate","cache_write_rate","cache_write_1h_rate","web_search_rate"])!==void 0),l=Yr(t.reason,["no_usage","no_rate","invalid_rate","unsupported_currency"]),c=Yr(t.funding,["mcpjam","customer"]),u=Yr(t.usageSource,["provider","runner","interrupted_estimate"]),h=yN(t.usage),f=bN(t.rate);return{calculationVersion:r,currency:"USD",completeness:n,...i!==void 0?{amountUsd:i}:{},...s?{source:s}:{},...Object.keys(o).length>0?{parts:o}:{},...a.length>0?{missing:a}:{},...l?{reason:l}:{},...kr(t,["tierAboveInputTokens"],Gn),...f?{rate:f}:{},...kr(t,["reporter"],Mf),...c?{funding:c}:{},...h?{usage:h}:{},...u?{usageSource:u}:{},...kr(t,["recordedAt"],Gn)}}var iv=1000000000000000n,CS=1e15;function wN(e){return BigInt(Math.round(e*CS))}function SN(e){const t=e/iv,n=e%iv;return Number(t)+Number(n)/CS}var kN=["provider_reported","customer_rate","list_price","runner_reported"];function CN(e){let t=0n,n=0,r=0,i=0;const s=new Set;for(const l of e){if(!l||l.amountUsd===void 0||l.currency!=="USD"){i+=1;continue}t+=wN(l.amountUsd),l.source&&s.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:SN(t),completeness:a,totalCalls:o,completeCalls:n,partialCalls:r,unavailableCalls:i,sources:kN.filter(l=>s.has(l))}}function Xr(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 AN=["completed","failed","cancelled","expired"];function no(e){return AN.includes(e)}var TN=250,EN=3e5,MN=1e3,RN=6e4;function sv(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:0}function Ii(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function Hs(e){return{...e,respondedInputKeys:[...e.respondedInputKeys],terminal:no(e.status)}}var x6=class{records=new Map;now;absoluteFloorMs;maximumIntervalMs;backoffBaseMs;backoffMaxMs;userMinimumIntervalMs;callbacks;constructor(e={}){this.now=e.now??(()=>Date.now()),this.absoluteFloorMs=e.absoluteFloorMs??TN,this.maximumIntervalMs=e.maximumIntervalMs??EN,this.backoffBaseMs=e.errorBackoffBaseMs??MN,this.backoffMaxMs=e.errorBackoffMaxMs??RN,this.userMinimumIntervalMs=sv(e.userMinimumIntervalMs),this.callbacks=e.callbacks??{}}setCallbacks(e){this.callbacks=e}setUserMinimumIntervalMs(e){this.userMinimumIntervalMs=sv(e);for(const t of this.records.values()){if(no(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=Ii(e.pollIntervalMs)??0,i=e.consecutiveErrors>0?Math.min(this.backoffBaseMs*2**(e.consecutiveErrors-1),this.backoffMaxMs):0,s=e.retryAfterUntil?Math.max(0,e.retryAfterUntil-n):0,o=Math.min(Math.max(this.absoluteFloorMs,this.userMinimumIntervalMs,i),Math.max(this.maximumIntervalMs,this.absoluteFloorMs));return Math.max(o,r,s)}get(e){return this.records.get(Xr(e))}getByKey(e){return this.records.get(e)}snapshot(e){const t=this.get(e);return t?Hs(t):void 0}all(){return[...this.records.values()].map(Hs)}register(e,t={}){const n=Xr(e),r=this.records.get(n);if(r)return r;const i=this.now(),s={key:n,identity:{...e},status:t.status??"unknown",createdAt:t.createdAt,ttlMs:t.ttlMs??null,pollIntervalMs:Ii(t.pollIntervalMs),nextPollAt:typeof t.nextPollAt=="number"&&Number.isFinite(t.nextPollAt)?Math.max(i,t.nextPollAt):i,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,s),t.restored||this.callbacks.onTaskCreated?.(Hs(s)),s}forget(e){this.records.delete(Xr(e))}clear(){this.records.clear()}observe(e,t,n="poll"){const r=this.register(e,{restored:!0}),i=r.status,s=this.now();if(no(r.status)&&!r.restored)return r.lastObservedAt=s,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=Ii(t.pollIntervalMs)),r.inputRequests=t.inputRequests,r.result=t.result,r.error=t.error,r.raw=t.raw,r.lastObservedAt=s,n!=="notification"&&(r.consecutiveErrors=0,r.retryAfterUntil=void 0);const o=no(r.status);o?r.nextPollAt=Number.POSITIVE_INFINITY:n==="notification"&&r.consecutiveErrors>0?r.nextPollAt=Math.min(r.nextPollAt,s+this.effectiveIntervalMs(r,s)):r.nextPollAt=s+this.effectiveIntervalMs(r,s);const a=Hs(r);return i!==r.status?(this.callbacks.onState?.(a,i),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 i=Ii(t.retryAfterMs);return i!==void 0&&(n.retryAfterUntil=r+i),n.nextPollAt=r+this.effectiveIntervalMs(n,r),n}applyRetryAfter(e,t){const n=this.register(e,{restored:!0}),r=this.now(),i=Ii(t);i!==void 0&&(n.retryAfterUntil=r+i,n.nextPollAt=Math.max(n.nextPollAt,r+i))}clearErrorBackoff(e){const t=this.records.get(Xr(e));if(!t)return;const n=this.now();t.consecutiveErrors=0;const r=Ii(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=Hs(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 no(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(Xr(e));return!n||n.pollInFlight?!1:(n.pollInFlight=!0,this.reserve([n],t),!0)}releasePoll(e){const t=this.records.get(Xr(e));t&&(t.pollInFlight=!1)}batchIntervalMs(e,t){const n=t??this.now();let r=Math.max(this.absoluteFloorMs,this.userMinimumIntervalMs);for(const i of e)r=Math.max(r,this.effectiveIntervalMs(i,n));return r}},AS=(0,g.createContext)({});function PN(e){const t=(0,g.useRef)(null);return t.current===null&&(t.current=e()),t.current}var IN=typeof window<"u",ov=IN?g.useLayoutEffect:g.useEffect,ru=(0,g.createContext)(null);function nm(e,t){e.indexOf(t)===-1&&e.push(t)}function uc(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}var fr=(e,t,n)=>n>t?t:n<e?e:n,iu=()=>{},vi=()=>{},ar={},rm=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),TS=e=>typeof e=="object"&&e!==null,im=e=>/^0[^.\s]+$/u.test(e);function ES(e){let t;return()=>(t===void 0&&(t=e()),t)}var tn=e=>e,wa=(...e)=>e.reduce((t,n)=>r=>n(t(r))),$o=(e,t,n)=>{const r=t-e;return r?(n-e)/r:1},hc=class{constructor(){this.subscriptions=[]}add(e){return nm(this.subscriptions,e),()=>this.remove(e)}remove(e){uc(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 i=0;i<r;i++){const s=this.subscriptions[i];s&&s(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},Pt=e=>e*1e3,Lt=e=>e/1e3,MS=(e,t)=>t?e*(1e3/t):0,RS=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,ON=1e-7,DN=12;function NN(e,t,n,r,i){let s,o,a=0;do o=t+(n-t)/2,s=RS(o,r,i)-e,s>0?n=o:t=o;while(Math.abs(s)>ON&&++a<DN);return o}function Sa(e,t,n,r){if(e===t&&n===r)return tn;const i=s=>NN(s,0,1,e,n);return s=>s===0||s===1?s:RS(i(s),t,r)}var PS=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,IS=e=>t=>1-e(1-t),OS=Sa(.33,1.53,.69,.99),sm=IS(OS),DS=PS(sm),NS=e=>e>=1?1:(e*=2)<1?.5*sm(e):.5*(2-Math.pow(2,-10*(e-1))),om=e=>1-Math.sin(Math.acos(e)),LS=IS(om),_S=PS(om),LN=Sa(.42,0,1,1),_N=Sa(0,0,.58,1),am=Sa(.42,0,.58,1),jN=e=>Array.isArray(e)&&typeof e[0]!="number",jS=e=>Array.isArray(e)&&typeof e[0]=="number",av={linear:tn,easeIn:LN,easeInOut:am,easeOut:_N,circIn:om,circInOut:_S,circOut:LS,backIn:sm,backInOut:DS,backOut:OS,anticipate:NS},BN=e=>typeof e=="string",lv=e=>{if(jS(e)){vi(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,r,i]=e;return Sa(t,n,r,i)}else if(BN(e))return vi(av[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),av[e];return e},We={delta:0,timestamp:0,isProcessing:!1},El;function FN(){El=void 0}var it={now:()=>(El===void 0&&it.set(We.isProcessing||ar.useManualTiming?We.timestamp:performance.now()),El),set:e=>{El=e,queueMicrotask(FN)}},ns=e=>Math.round(e*1e5)/1e5,BS=e=>t=>typeof t=="string"&&t.startsWith(e),FS=BS("--"),VN=BS("var(--"),lm=e=>VN(e)?zN.test(e.split("/*")[0].trim()):!1,zN=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function cv(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}var Is={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Ho={...Is,transform:e=>fr(0,1,e)},Ua={...Is,default:1},cm=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function $N(e){return e==null}var HN=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,um=(e,t)=>n=>!!(typeof n=="string"&&HN.test(n)&&n.startsWith(e)||t&&!$N(n)&&Object.prototype.hasOwnProperty.call(n,t)),VS=(e,t,n)=>r=>{if(typeof r!="string")return r;const[i,s,o,a]=r.match(cm);return{[e]:parseFloat(i),[t]:parseFloat(s),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},WN=e=>fr(0,255,e),eh={...Is,transform:e=>Math.round(WN(e))},ni={test:um("rgb","red"),parse:VS("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+eh.transform(e)+", "+eh.transform(t)+", "+eh.transform(n)+", "+ns(Ho.transform(r))+")"};function UN(e){let t="",n="",r="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var Rf={test:um("#"),parse:UN,transform:ni.transform},ka=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Vn=ka("deg"),Pn=ka("%"),Q=ka("px"),qN=ka("vh"),KN=ka("vw"),uv={...Pn,parse:e=>Pn.parse(e)/100,transform:e=>Pn.transform(e*100)},Wi={test:um("hsl","hue"),parse:VS("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+Pn.transform(ns(t))+", "+Pn.transform(ns(n))+", "+ns(Ho.transform(r))+")"},Ue={test:e=>ni.test(e)||Rf.test(e)||Wi.test(e),parse:e=>ni.test(e)?ni.parse(e):Wi.test(e)?Wi.parse(e):Rf.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?ni.transform(e):Wi.transform(e),getAnimatableNone:e=>{const t=Ue.parse(e);return t.alpha=0,Ue.transform(t)}},GN=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,zS=new RegExp(cm.source),$S=new RegExp(GN.source,"i");function QN(e){return isNaN(e)&&typeof e=="string"&&(zS.test(e)||$S.test(e))}var HS="number",WS="color",YN="var",XN="var(",hv="${}",JN=/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 ZN(e){const t=e.toString();return zS.test(t)||$S.test(t)}function Wo(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[];let s=0;return{values:n,split:t.replace(JN,o=>(Ue.test(o)?(r.color.push(s),i.push(WS),n.push(Ue.parse(o))):o.startsWith(XN)?(r.var.push(s),i.push(YN),n.push(o)):(r.number.push(s),i.push(HS),n.push(parseFloat(o))),++s,hv)).split(hv),indexes:r,types:i}}function e2(e){return Wo(e).values}function US({split:e,types:t}){const n=e.length;return r=>{let i="";for(let s=0;s<n;s++)if(i+=e[s],r[s]!==void 0){const o=t[s];o===HS?i+=ns(r[s]):o===WS?i+=Ue.transform(r[s]):i+=r[s]}return i}}function t2(e){return US(Wo(e))}var n2=e=>typeof e=="number"?0:Ue.test(e)?Ue.getAnimatableNone(e):e,r2=(e,t)=>typeof e=="number"?t?.trim().endsWith("/")?e:0:n2(e);function i2(e){const t=Wo(e);return US(t)(t.values.map((n,r)=>r2(n,t.split[r])))}var It={test:QN,parse:e2,createTransformer:t2,getAnimatableNone:i2};function th(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 s2({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,s=0,o=0;if(!t)i=s=o=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;i=th(l,a,e+1/3),s=th(l,a,e),o=th(l,a,e-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(o*255),alpha:r}}function fc(e,t){return n=>n>0?t:e}var ye=(e,t,n)=>e+(t-e)*n,nh=(e,t,n)=>{const r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},o2=[Rf,ni,Wi],a2=e=>o2.find(t=>t.test(e));function fv(e){const t=a2(e);if(!t)return iu(!1,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!1;let n=t.parse(e);return t===Wi&&(n=s2(n)),n}var dv=(e,t)=>{const n=fv(e),r=fv(t);if(!n||!r)return fc(e,t);const i={...n};return s=>(i.red=nh(n.red,r.red,s),i.green=nh(n.green,r.green,s),i.blue=nh(n.blue,r.blue,s),i.alpha=ye(n.alpha,r.alpha,s),ni.transform(i))},Pf=new Set(["none","hidden"]);function l2(e,t){return Pf.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function c2(e,t){return n=>ye(e,t,n)}function hm(e){return typeof e=="number"?c2:typeof e=="string"?lm(e)?fc:Ue.test(e)?dv:f2:Array.isArray(e)?qS:typeof e=="object"?Ue.test(e)?dv:u2:fc}function qS(e,t){const n=[...e],r=n.length,i=e.map((s,o)=>hm(s)(s,t[o]));return s=>{for(let o=0;o<r;o++)n[o]=i[o](s);return n}}function u2(e,t){const n={...e,...t},r={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=hm(e[i])(e[i],t[i]));return i=>{for(const s in r)n[s]=r[s](i);return n}}function h2(e,t){const n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const s=t.types[i],o=e.indexes[s][r[s]],a=e.values[o]??0;n[i]=a,r[s]++}return n}var f2=(e,t)=>{const n=It.createTransformer(t),r=Wo(e),i=Wo(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Pf.has(e)&&!i.values.length||Pf.has(t)&&!r.values.length?l2(e,t):wa(qS(h2(r,i),i.values),n):(iu(!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"),fc(e,t))},pv=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function d2(e,t){const n=pv.exec(e);if(!n)return;const r=pv.exec(t);if(!r||n[2]!==r[2])return;const i=n[2],s=parseFloat(n[1]),o=parseFloat(r[1]);return a=>ns(ye(s,o,a))+i}function fm(e,t,n){if(typeof e=="number"&&typeof t=="number"&&typeof n=="number")return ye(e,t,n);if(typeof e=="string"&&typeof t=="string"){const r=d2(e,t);if(r)return r}return hm(e)(e,t)}var qa=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function p2(e){let t=new Set,n=new Set,r=!1,i=!1;const s=new Set;let o={delta:0,timestamp:0,isProcessing:!1};function a(c){s.has(c)&&(n.add(c),e()),c(o)}const l={schedule:(c,u=!1,h=!1)=>{const f=h&&r?t:n;return u&&s.add(c),f.add(c),c},cancel:c=>{n.delete(c),s.delete(c)},process:c=>{if(o=c,r){i=!0;return}r=!0;const u=t;t=n,n=u,t.forEach(a),t.clear(),r=!1,i&&(i=!1,l.process(c))}};return l}var m2=40;function KS(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0;const s=()=>r=!0,o=qa.reduce((w,S)=>(w[S]=p2(s),w),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:u,update:h,preRender:f,render:d,postRender:m}=o,v=()=>{const w=ar.useManualTiming,S=w?n.timestamp:performance.now();r=!1,w||(n.delta=i?1e3/60:Math.max(Math.min(S-n.timestamp,m2),1)),n.timestamp=S,n.isProcessing=!0,a.process(n),l.process(n),c.process(n),u.process(n),h.process(n),f.process(n),d.process(n),m.process(n),n.isProcessing=!1,r&&t&&(i=!1,e(v))},y=()=>{r=!0,i=!0,n.isProcessing||e(v)};return{schedule:qa.reduce((w,S)=>{const C=o[S];return w[S]=(A,k=!1,E=!1)=>(r||y(),C.schedule(A,k,E)),w},{}),cancel:w=>{for(let S=0;S<qa.length;S++)o[qa[S]].cancel(w)},state:n,steps:o}}var{schedule:we,cancel:Ir,steps:rh}=KS(typeof requestAnimationFrame<"u"?requestAnimationFrame:tn,!0,We),g2=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>we.update(t,n),stop:()=>Ir(t),now:()=>We.isProcessing?We.timestamp:it.now()}},GS=(e,t,n=10)=>{let r="";const i=Math.max(Math.round(t/n),2);for(let s=0;s<i;s++)r+=Math.round(e(s/(i-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},dm=2e4;function pm(e,t=50,n=dm,r){let i=0,s=e.next(i);for(r?.push(s.value);!s.done&&i<n;)i+=t,s=e.next(i),r?.push(s.value);return i>=n?1/0:i}function v2(e,t=100,n){const r=n({...e,keyframes:[0,t]}),i=Math.min(pm(r),dm);return{type:"keyframes",ease:s=>r.next(i*s).value/t,duration:Lt(i)}}var Xe={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},QS=e=>e<0?1/Math.max(1+e,Xe.minDamping):Math.max(1-e,Xe.minDamping);function YS(e,t){if(!(e>1))return 1;const n=Math.sqrt(e*e-1),r=e-n,i=e+n,s=2*n*Math.exp(-t)*(1+t);return XS(o=>i*Math.exp(-r*o)-r*Math.exp(-i*o)-s,o=>Math.exp(-i*o)-Math.exp(-r*o),t)/t}function If(e,t){return e*Math.sqrt(1-t*t)}var y2=12;function XS(e,t,n){let r=n;for(let i=1;i<y2;i++)r=r-e(r)/t(r);return r}var mv=.001;function x2({duration:e=Xe.duration,bounce:t=Xe.bounce}){let n,r;iu(e<=Pt(Xe.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");const i=QS(t);e=fr(Xe.minDuration,Xe.maxDuration,Lt(e)),i<1?(n=c=>{const u=c*i,h=u*e,f=If(c,i),d=Math.exp(-h);return mv-u/f*d},r=c=>{const u=c*i*e,h=i*i*c*c*e,f=Math.exp(-u),d=If(c*c,i);return(-n(c)+mv>0?-1:1)*-h*f/d}):(n=c=>-.001+Math.exp(-c*e)*(c*e+1),r=c=>Math.exp(-c*e)*(-c*(e*e)));const s=5/e,o=XS(n,r,s),a=o*YS(i,o*e),l=a*a;return{stiffness:l,damping:i*2*Math.sqrt(l),duration:Pt(e)}}var Of=(e,t)=>(t?e>=0:e>0)&&e<1/0;function ih(e,t){if(Of(e,t))return e}function b2(e){const t=ih(e.stiffness),n=ih(e.damping,!0),r=ih(e.mass),i={...e,stiffness:t??Xe.stiffness,damping:n??Xe.damping,mass:r??Xe.mass,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(i.isTimeDefined){if(e.visualDuration){const s=QS(e.bounce||0),o=2*Math.PI/(e.visualDuration*1.2)*YS(s,2*Math.PI/1.2);i.stiffness=o*o,i.damping=2*s*Math.sqrt(i.stiffness)}else Object.assign(i,x2(i)),i.isResolvedFromDuration=!0;(!Of(i.stiffness)||!Of(i.damping,!0))&&(i.stiffness=Xe.stiffness,i.damping=Xe.damping)}return i}function dc(e=Xe.visualDuration,t=Xe.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e,r=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],s={done:!1,value:r},{stiffness:o,damping:a,mass:l,duration:c,isResolvedFromDuration:u,isTimeDefined:h}=b2({...n}),f=k=>h?0:-Lt(k),d=a/(2*Math.sqrt(o*l)),m=Lt(Math.sqrt(o/l)),v=d*m,y={target:i,delta:i-r,velocity:f(n.velocity||0)||0,restSpeed:0,restDelta:0},x=()=>{const k=Math.abs(y.delta)<5;y.restSpeed=n.restSpeed||(k?Xe.restSpeed.granular:Xe.restSpeed.default),y.restDelta=n.restDelta||(k?Xe.restDelta.granular:Xe.restDelta.default)};x();let b,w,S;if(d<1){const k=If(m,d),E={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};S=()=>{E.A=(y.velocity+v*y.delta)/k,E.sinC=v*E.A+y.delta*k,E.cosC=v*y.delta-E.A*k};const T=R=>{R!==E.t&&(E.t=R,E.env=Math.exp(-v*R),E.sin=Math.sin(k*R),E.cos=Math.cos(k*R))};b=R=>(T(R),y.target-E.env*(E.A*E.sin+y.delta*E.cos)),w=R=>(T(R),E.env*(E.sinC*E.sin+E.cosC*E.cos))}else if(d===1){b=E=>y.target-Math.exp(-m*E)*(y.delta+(y.velocity+m*y.delta)*E);const k={C:0};S=()=>{k.C=y.velocity+m*y.delta},w=E=>Math.exp(-m*E)*(m*k.C*E-y.velocity)}else{const k=m*Math.sqrt(d*d-1),E=v-k,T=v+k,R=h?1/0:300/k,P=(N,L)=>Math.exp(L>R?-N*R-v*(L-R):-N*L),M={S:0,F:0};S=()=>{const N=(y.velocity+v*y.delta)/k;M.S=(y.delta+N)/2,M.F=(y.delta-N)/2},b=N=>y.target-M.S*P(E,N)-M.F*P(T,N),w=N=>E*M.S*P(E,N)+T*M.F*P(T,N)}S();const C=u&&c||null,A={calculatedDuration:C,retarget:(k,E)=>{y.target=k[k.length-1],y.delta=y.target-k[0],y.velocity=f(E),n.restSpeed&&n.restDelta||x(),A.calculatedDuration=C,s.done=!1,S()},velocity:k=>Pt(w(k)),next:k=>{const E=b(k);if(u)s.done=k>=c;else{const T=Pt(w(k));s.done=Math.abs(T)<=y.restSpeed&&Math.abs(y.target-E)<=y.restDelta}return s.value=s.done?y.target:E,s},toString:()=>{const k=Math.min(pm(A),dm),E=GS(T=>A.next(k*T).value,k,30);return k+"ms "+E},toTransition:()=>{}};return A}dc.applyToOptions=e=>{const t=v2(e,100,dc);return e.ease=t.ease,e.duration=Pt(t.duration),e.type="keyframes",e};function Df({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:s=500,modifyTarget:o,min:a,max:l,restDelta:c=.5,restSpeed:u}){const h=e[0],f={done:!1,value:h},d=k=>k<a||k>l,m=k=>a===void 0?l:l===void 0||Math.abs(a-k)<Math.abs(l-k)?a:l;let v=n*t;const y=h+v,x=o===void 0?y:o(y);x!==y&&(v=x-h);const b=k=>-v*Math.exp(-k/r),w=k=>{const E=b(k);f.done=Math.abs(E)<=c,f.value=f.done?x:x+E};let S,C;const A=k=>{d(f.value)&&(S=k,C=dc({keyframes:[f.value,m(f.value)],velocity:-b(k)/r*1e3,damping:i,stiffness:s,restDelta:c,restSpeed:u}))};return A(0),{calculatedDuration:null,next:k=>{let E=!1;return!C&&S===void 0&&(E=!0,w(k),A(k)),S!==void 0&&k>=S?C.next(k-S):(!E&&w(k),f)}}}function w2(e,t,n){const r=[],i=n||ar.mix||fm,s=e.length-1;for(let o=0;o<s;o++){let a=i(e[o],e[o+1]);if(t){const l=Array.isArray(t)?t[o]||tn:t;a=wa(l,a)}r.push(a)}return r}function S2(e,t,{clamp:n=!0,ease:r,mixer:i}={}){const s=e.length;if(vi(s===t.length,"Both input and output ranges must be the same length","range-length"),s===1)return()=>t[0];if(s===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[s-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=w2(t,r,i),l=a.length,c=u=>{if(o&&u<e[0])return t[0];let h=0;if(l>1)for(;h<e.length-2&&!(u<e[h+1]);h++);const f=$o(e[h],e[h+1],u);return a[h](f)};return n?u=>c(fr(e[0],e[s-1],u)):c}function k2(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const i=$o(0,t,r);e.push(ye(n,1,i))}}function C2(e){const t=[0];return k2(t,e.length-1),t}function A2(e,t){return e.map(n=>n*t)}function T2(e,t){return e.map(()=>t||am).splice(0,e.length-1)}function wo({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const i=jN(r)?r.map(lv):lv(r)||am,s={done:!1,value:t[0]};if(t.length===2&&!Array.isArray(i)&&(!n||n.length!==2||n[0]===0&&n[1]===1)){const[l,c]=t,u=l===c?void 0:(ar.mix||fm)(l,c);return{calculatedDuration:e,next:h=>(s.value=u?u(i(e>0?fr(0,1,h/e):1)):c,s.done=h>=e,s)}}const o=A2(n&&n.length===t.length?n:C2(t),e),a=S2(o,t,{ease:Array.isArray(i)?i:T2(t,i)});return{calculatedDuration:e,next:l=>(s.value=a(l),s.done=l>=e,s)}}var E2=5;function M2(e,t,n){const r=Math.max(t-E2,0);return MS(n-e(r),t-r)}function R2(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):M2(r=>e.next(r).value,t,e.next(t).value)}var P2=e=>e!==null;function su(e,{repeat:t,repeatType:n="loop"},r,i=1){const s=e.filter(P2),o=i<0||t&&n!=="loop"&&t%2===1?0:s.length-1;return!o||r===void 0?s[o]:r}var I2={decay:Df,inertia:Df,tween:wo,keyframes:wo,spring:dc};function JS(e){typeof e.type=="string"&&(e.type=I2[e.type])}function ZS(e,t){return{kind:e,animation:t,timestamp:it.now(),frameTimestamp:We.timestamp,frameIsProcessing:We.isProcessing}}function ek(e,t,n){const r=globalThis.__MOTION_INSPECT__;if(r)try{r({...ZS("animation-start",e),options:n?{...t,...n}:t})}catch{}}function O2(e,t){const n=globalThis.__MOTION_INSPECT__;if(n)try{n({...ZS("layout-animation-start",e),node:t})}catch{}}var mm=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)}},D2=e=>e/100,pc=class extends mm{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!==it.now()&&this.tick(it.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),ek(this,this.options)}initAnimation(){const{options:e}=this;JS(e);const{type:t=wo,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:s=0}=e;let{keyframes:o}=e;const a=t||wo;a!==wo&&typeof o[0]!="number"&&(this.mixKeyframes=wa(D2,fm(o[0],o[1])),o=[0,100]);const l=a(o===e.keyframes?e:{...e,keyframes:o});i==="mirror"&&(this.mirroredGenerator=a({...e,keyframes:[...o].reverse(),velocity:-s})),l.calculatedDuration===null&&(l.calculatedDuration=pm(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:i,mirroredGenerator:s,resolvedDuration:o,calculatedDuration:a}=this;if(this.startTime===null)return n.next(0);const{delay:l=0,keyframes:c,repeat:u,repeatType:h,repeatDelay:f,type:d,onUpdate:m,finalKeyframe:v}=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 y=this.currentTime-l*(this.playbackSpeed>=0?1:-1),x=this.playbackSpeed>=0?y<0:y>r;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let b=this.currentTime,w=n;if(u){const k=Math.min(this.currentTime,r)/o;let E=Math.floor(k),T=k%1;!T&&k>=1&&(T=1),T===1&&E--,E=Math.min(E,u+1),E%2&&(h==="reverse"?(T=1-T,f&&(T-=f/o)):h==="mirror"&&(w=s)),b=fr(0,1,T)*o}let S;x?(this.delayState.value=c[0],S=this.delayState):S=w.next(b),i&&!x&&(S.value=i(S.value));let{done:C}=S;!x&&a!==null&&(C=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const A=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&C);return A&&d!==Df&&(S.value=su(c,this.options,v,this.speed)),m&&m(S.value),A&&this.finish(),S}then(e,t){return this.finished.then(e,t)}get duration(){return Lt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Lt(e)}get time(){return Lt(this.currentTime)}set time(e){e=Pt(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 R2(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(it.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Lt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=g2,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(it.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)}},N2=new Set(["brightness","contrast","saturate","opacity"]);function L2(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(cm)||[];if(!r)return e;const i=n.replace(r,"");let s=N2.has(t)?1:0;return r!==n&&(s*=100),t+"("+s+i+")"}var _2=/\b([a-z-]*)\(.*?\)/gu,Nf={...It,getAnimatableNone:e=>{const t=e.match(_2);return t?t.map(L2).join(" "):e}},Lf={...It,getAnimatableNone:e=>{const t=It.parse(e);return It.createTransformer(e)(t.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},gv={...Is,transform:Math.round},j2={rotate:Vn,pathRotation:Vn,rotateX:Vn,rotateY:Vn,rotateZ:Vn,scale:Ua,scaleX:Ua,scaleY:Ua,scaleZ:Ua,skew:Vn,skewX:Vn,skewY:Vn,distance:Q,translateX:Q,translateY:Q,translateZ:Q,x:Q,y:Q,z:Q,perspective:Q,transformPerspective:Q,opacity:Ho,originX:uv,originY:uv,originZ:Q},mc={borderWidth:Q,borderTopWidth:Q,borderRightWidth:Q,borderBottomWidth:Q,borderLeftWidth:Q,borderRadius:Q,borderTopLeftRadius:Q,borderTopRightRadius:Q,borderBottomRightRadius:Q,borderBottomLeftRadius:Q,width:Q,maxWidth:Q,height:Q,maxHeight:Q,top:Q,right:Q,bottom:Q,left:Q,inset:Q,insetBlock:Q,insetBlockStart:Q,insetBlockEnd:Q,insetInline:Q,insetInlineStart:Q,insetInlineEnd:Q,padding:Q,paddingTop:Q,paddingRight:Q,paddingBottom:Q,paddingLeft:Q,paddingBlock:Q,paddingBlockStart:Q,paddingBlockEnd:Q,paddingInline:Q,paddingInlineStart:Q,paddingInlineEnd:Q,margin:Q,marginTop:Q,marginRight:Q,marginBottom:Q,marginLeft:Q,marginBlock:Q,marginBlockStart:Q,marginBlockEnd:Q,marginInline:Q,marginInlineStart:Q,marginInlineEnd:Q,fontSize:Q,backgroundPositionX:Q,backgroundPositionY:Q,...j2,zIndex:gv,fillOpacity:Ho,strokeOpacity:Ho,numOctaves:gv},B2={...mc,color:Ue,backgroundColor:Ue,outlineColor:Ue,fill:Ue,stroke:Ue,borderColor:Ue,borderTopColor:Ue,borderRightColor:Ue,borderBottomColor:Ue,borderLeftColor:Ue,filter:Nf,WebkitFilter:Nf,mask:Lf,WebkitMask:Lf},tk=e=>B2[e],F2=new Set([Nf,Lf]);function gm(e,t){let n=tk(e);return F2.has(n)||(n=It),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function V2(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var ri=e=>e*180/Math.PI,_f=e=>{const t=ri(Math.atan2(e[1],e[0]));return jf(t)},z2={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:_f,rotateZ:_f,skewX:e=>ri(Math.atan(e[1])),skewY:e=>ri(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},jf=e=>(e=e%360,e<0&&(e+=360),e),vv=_f,yv=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),xv=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),$2={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:yv,scaleY:xv,scale:e=>(yv(e)+xv(e))/2,rotateX:e=>jf(ri(Math.atan2(e[6],e[5]))),rotateY:e=>jf(ri(Math.atan2(-e[2],e[0]))),rotateZ:vv,rotate:vv,skewX:e=>ri(Math.atan(e[4])),skewY:e=>ri(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Uo(e){return e.includes("scale")?1:0}function Bf(e,t){if(!e||e==="none")return Uo(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=$2,i=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=z2,i=a}if(!i)return Uo(t);const s=r[t],o=i[1].split(",").map(W2);return typeof s=="function"?s(o):o[s]}var H2=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Bf(n,t)};function W2(e){return parseFloat(e.trim())}var Os=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Er=new Set([...Os,"pathRotation"]),bv=e=>e===Is||e===Q,U2=new Set(["x","y","z"]),q2=Os.filter(e=>!U2.has(e));function K2(e){const t=[];return q2.forEach(n=>{const r=e.getValue(n);if(r!==void 0){const i=r.get(),s=n.startsWith("scale")?1:0;if(i===s)return;t.push([n,i]),r.set(s)}}),t}var G2=new Set(["bottom","right"]);function wv(e,t,n,r,i,s){const o=parseFloat(e);if(!isNaN(o))return o;const{min:a,max:l}=t()[n],c=l-a;return s==="border-box"?c:c-parseFloat(r)-parseFloat(i)}var si={width:({width:e,paddingLeft:t="0",paddingRight:n="0",boxSizing:r},i)=>wv(e,i,"x",t,n,r),height:({height:e,paddingTop:t="0",paddingBottom:n="0",boxSizing:r},i)=>wv(e,i,"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})=>Bf(e,"x"),y:({transform:e})=>Bf(e,"y")};si.translateX=si.x;si.translateY=si.y;var oi=new Set,Ff=!1,Vf=!1,zf=!1;function nk(){if(Vf){const e=[],t=new Set,n=new Set;oi.forEach(i=>{i.needsMeasurement&&(e.push(i),t.add(i.element),G2.has(i.name)&&n.add(i.element))});const r=new Map;n.forEach(i=>{const s=K2(i);s.length&&(r.set(i,s),i.render())}),e.forEach(i=>i.measureInitialState()),t.forEach(i=>{i.render();const s=r.get(i);s&&s.forEach(([o,a])=>{i.getValue(o)?.set(a)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}Vf=!1,Ff=!1,oi.forEach(e=>e.complete(zf)),oi.clear()}function rk(){oi.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Vf=!0)})}function Q2(){zf=!0,rk(),nk(),zf=!1}function Y2(e,t,n){if(typeof e=="string"){if(rm(e)||im(e))return parseFloat(e);if(!It.test(e)&&It.test(n))return gm(t,n)}return e??void 0}var vm=class{constructor(e,t,n,r,i,s=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=s}scheduleResolve(){this.state="scheduled",this.isAsync?(oi.add(this),Ff||(Ff=!0,we.read(rk),we.resolveKeyframes(nk))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){const i=r?.get(),s=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){const o=Y2(n.readValue(t,s),t,s);o!==void 0&&(e[0]=o)}e[0]===void 0&&(e[0]=s),r&&i===void 0&&r.set(e[0])}V2(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),oi.delete(this)}cancel(){this.state==="scheduled"&&(oi.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}},X2=e=>e.startsWith("--");function ik(e,t,n){X2(t)?e.style.setProperty(t,n):e.style[t]=n}var J2={};function sk(e,t){const n=ES(e);return()=>J2[t]??n()}var Z2=sk(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),ok=sk(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),ro=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Sv={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:ro([0,.65,.55,1]),circOut:ro([.55,0,1,.45]),backIn:ro([.31,.01,.66,-.59]),backOut:ro([.33,1.53,.69,.99])};function ak(e,t){if(e)return typeof e=="function"?ok()?GS(e,t):"ease-out":jS(e)?ro(e):Array.isArray(e)?e.map(n=>ak(n,t)||Sv.easeOut):Sv[e]}function eL(e,t,n,{delay:r=0,duration:i=300,repeat:s=0,repeatType:o="loop",ease:a="easeOut",times:l}={},c=void 0){const u={[t]:n};l&&(u.offset=l);const h=ak(a,i);Array.isArray(h)&&(u.easing=h);const f={delay:r,duration:i,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:s+1,direction:o==="reverse"?"alternate":"normal"};return c&&(f.pseudoElement=c),e.animate(u,f)}function lk(e){return typeof e=="function"&&"applyToOptions"in e}function tL({type:e,...t}){return lk(e)&&ok()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}var ck=class extends mm{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:s=!1,finalKeyframe:o,onComplete:a}=e;this.isPseudoElement=!!i,this.allowFlatten=s,this.options=e,vi(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const l=tL(e);this.animation=eL(t,n,r,l,i),l.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){const c=su(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(c),ik(t,n,c),this.animation.cancel()}a?.(),this.notifyFinished()},ek(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 Lt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Lt(e)}get time(){return Lt(Number(this.animation.currentTime)||0)}set time(e){const t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Pt(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&&Z2()?(this.animation.timeline=e,Object.assign(this.animation,r),t?.(this.animation),tn):n(this)}},uk={anticipate:NS,backInOut:DS,circInOut:_S};function nL(e){return e in uk}function rL(e){typeof e.ease=="string"&&nL(e.ease)&&(e.ease=uk[e.ease])}var sh=10,iL=class extends ck{constructor(e){rL(e),JS(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:i,...s}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}const o=new pc({...s,autoplay:!1}),a=Math.max(sh,it.now()-this.startTime),l=fr(0,sh,a-sh),c=o.sample(a).value,{name:u}=this.options;i&&u&&ik(i,u,c),t.setWithVelocity(o.sample(Math.max(0,a-l)).value,c,l),o.stop()}},kv=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(It.test(e)||e==="0")&&!e.startsWith("url("));function sL(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 oL(e,t,n,r){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const s=e[e.length-1],o=kv(i,t),a=kv(s,t);return!o||!a?(o!==a&&iu(!1,`You are trying to animate ${t} from "${i}" to "${s}". "${o?s:i}" is not an animatable value.`,"value-not-animatable"),!1):sL(e)||(n==="spring"||lk(n))&&r}function $f(e){e.duration=0,e.type="keyframes"}var Hf=new Set(["opacity","clipPath","filter","transform","backgroundColor"]),aL=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function lL(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&aL.test(e[t]))return!0;return!1}var Cv=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),cL=ES(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function uL(e){const{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:s,type:o,keyframes:a}=e;if(!n||!(Hf.has(n)||Cv.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 cL()&&(Hf.has(n)||Cv.has(n)&&lL(a))&&(n!=="transform"||!u)&&!c&&!r&&i!=="mirror"&&s!==0&&o!=="inertia"}var hL=40,fL=class extends mm{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=it.now();const{keyframes:t,name:n,motionValue:r,element:i}=e,s=e;s.autoplay??(s.autoplay=!0),s.delay??(s.delay=0),s.type??(s.type="keyframes"),s.repeat??(s.repeat=0),s.repeatDelay??(s.repeatDelay=0),s.repeatType??(s.repeatType="loop");const o=i?.KeyframeResolver||vm;this.keyframeResolver=new o(t,(a,l,c)=>this.onKeyframesResolved(a,l,s,!c),n,r,i),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;const{name:i,type:s,velocity:o,delay:a,isHandoff:l,onUpdate:c}=n;this.resolvedAt=it.now();let u=!0;oL(e,i,s,o)||(u=!1,(ar.instantAnimations||!a)&&c?.(su(e,n,t)),e[0]=e[e.length-1],$f(n),n.repeat=0);const h=r?this.resolvedAt?this.resolvedAt-this.createdAt>hL?this.resolvedAt:this.createdAt:this.createdAt:void 0,{onComplete:f}=n;n.startTime??(n.startTime=h),n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{f?.(),this.notifyFinished()};const d=u&&!l&&uL(n);let m;if(d){n.element=n.motionValue?.owner?.current;try{m=new iL(n)}catch{m=new pc(n)}}else m=new pc(n);this.pendingTimeline&&(this.stopTimeline=m.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=m}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(),Q2()),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 hk(e,t,n,r=0,i=1){const s=Array.from(e).sort((l,c)=>l.sortNodePosition(c)).indexOf(t),o=e.size,a=(o-1)*r;return typeof n=="function"?n(s,o):i===1?s*r:a-s*r}var Av=30,dL=e=>!isNaN(parseFloat(e)),Tv={current:void 0},pL=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{const r=it.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&(this.notifyChange(),this.dependents))for(const i of this.dependents)i.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=it.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=dL(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 hc)).add(t)}onChangeSubscribe(e){const{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new hc,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(){we.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 Tv.current&&Tv.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const e=it.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Av)return 0;const t=Math.min(this.updatedAt-this.prevUpdatedAt,Av);return MS(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 ds(e,t){return new pL(e,t)}function fk(e,t){if(e?.inherit&&t){const{inherit:n,...r}=e;return{...t,...r}}return e}function ym(e,t){const n=e?.[t]??e?.default??e;return n!==e?fk(n,e):n}var mL={type:"spring",stiffness:500,damping:25,restSpeed:10},gL=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),vL={type:"keyframes",duration:.8},yL={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},xL=(e,{keyframes:t})=>t.length>2?vL:Er.has(e)?e.startsWith("scale")?gL(t[1]):mL:yL,bL=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function wL(e){for(const t in e)if(!bL.has(t))return!0;return!1}var xm=(e,t,n,r={},i,s)=>o=>{const a=ym(r,e)||{},l=a.delay||r.delay||0;let{elapsed:c=0}=r;c=c-Pt(l);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-c,onUpdate:f=>{t.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:s?void 0:i};wL(a)||Object.assign(u,xL(e,u)),u.duration&&(u.duration=Pt(u.duration)),u.repeatDelay&&(u.repeatDelay=Pt(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let h=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&($f(u),u.delay===0&&(h=!0)),(ar.instantAnimations||ar.skipAnimations||i?.shouldSkipAnimations||a.skipAnimations)&&(h=!0,$f(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,h&&!s&&t.get()!==void 0){const f=su(u.keyframes,a);if(f!==void 0){we.update(()=>{u.onUpdate(f),u.onComplete()});return}}return a.isSync?new pc(u):new fL(u)},SL=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function kL(e){const t=SL.exec(e);if(!t)return[,];const[,n,r,i]=t;return[`--${n??r}`,i]}var CL=4;function dk(e,t,n=1){vi(n<=CL,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,i]=kL(e);if(!r)return;const s=window.getComputedStyle(t).getPropertyValue(r);if(s){const o=s.trim();return rm(o)?parseFloat(o):o}return lm(i)?dk(i,t,n+1):i}function AL(e){const t=[{},{}];return e?.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function pk(e,t,n,r){const i=s=>typeof s=="function"?s(n!==void 0?n:e.custom,...AL(r)):s;return t=i(t),typeof t=="string"&&(t=e.variants&&e.variants[t]),i(t)}function ai(e,t,n){return pk(e.getProps(),t,n,e)}var mk=(e,t)=>t==="exit"?e.presenceContext?.custom:void 0,gk=new Set(["width","height","top","left","right","bottom",...Os]),TL=e=>Array.isArray(e);function EL(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,ds(n))}function ML(e){return TL(e)?e[e.length-1]||0:e}function RL(e,t){let{transitionEnd:n={},transition:r={},...i}=ai(e,t)||{};i={...i,...n};for(const s in i)EL(e,s,ML(i[s]))}var st=e=>!!(e&&e.getVelocity);function PL(e){return!!(st(e)&&e.add)}function Wf(e,t){const n=e.getValue("willChange");if(PL(n))return n.add(t);if(!n&&ar.WillChange){const r=new ar.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function bm(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var IL="framerAppearId",vk="data-"+bm(IL);function yk(e){return e.props[vk]}var OL=typeof window<"u";function DL({protectedKeys:e,needsAnimating:t},n){const r=n in e&&!t[n];return t[n]=!1,r}function xk(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:s,transitionEnd:o,...a}=t;const l=e.getDefaultTransition();s=s?fk(s,l):l;const c=s?.reduceMotion,u=s?.skipAnimations;r&&(s=r);const h=[],f=i&&e.animationState?.getState()[i],d=s?.path;d&&d.animateVisualElement(e,a,s,n,h);for(const m in a){const v=e.getValue(m,e.latestValues[m]??null),y=a[m];if(y===void 0||f&&DL(f,m))continue;const x={delay:n,...ym(s||{},m)};u&&(x.skipAnimations=!0);const b=v.get();if(b!==void 0&&!v.isAnimating()&&!Array.isArray(y)&&y===b&&!x.velocity){we.update(()=>v.set(y));continue}let w=!1;if(OL&&window.MotionHandoffAnimation){const A=yk(e);if(A){const k=window.MotionHandoffAnimation(A,m,we);k!==null&&(x.startTime=k,w=!0)}}Wf(e,m);const S=c??e.shouldReduceMotion;v.start(xm(m,v,y,S&&gk.has(m)?{type:!1}:x,e,w));const C=v.animation;C&&h.push(C)}if(o){const m=()=>we.update(()=>{o&&RL(e,o)});h.length?Promise.all(h).then(m):m()}return h}function Uf(e,t,n={}){const r=ai(e,t,mk(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),s=()=>Promise.all(r?xk(e,r,n):[]),o=(l=0)=>{const{variantChildren:c}=e,{delayChildren:u=0,staggerChildren:h,staggerDirection:f}=i,d=[];return c?.forEach(m=>{m.notify("AnimationStart",t),d.push(Uf(m,t,{...n,delay:l+(typeof u=="function"?0:u)+hk(c,m,u,h,f)}).then(()=>m.notify("AnimationComplete",t)))}),Promise.all(d)},{when:a}=i;return a?a==="beforeChildren"?s().then(()=>o()):o().then(s):Promise.all([s(),o(n.delay)])}function NL(e,t,n={}){return e.notify("AnimationStart",t),(Array.isArray(t)?Promise.all(t.map(r=>Uf(e,r,n))):typeof t=="string"?Uf(e,t,n):Promise.all(xk(e,ai(e,t,n.custom),n))).then(()=>{e.notify("AnimationComplete",t)})}var LL={test:e=>e==="auto",parse:e=>e},_L=e=>t=>t.test(e),jL=[Is,Q,Pn,Vn,KN,qN,LL],Ev=e=>jL.find(_L(e));function BL(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||im(e):!0}var FL=new Set(["auto","none","0"]);function VL(e,t,n){let r=0,i;for(;r<e.length&&!i;){const s=e[r];typeof s=="string"&&!FL.has(s)&&ZN(s)&&(i=e[r]),r++}if(i&&n)for(const s of t)e[s]!==i&&(e[s]=gm(n,i))}var zL=class extends vm{constructor(e,t,n,r,i){super(e,t,n,r,i,!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(),lm(l))){const c=dk(l,t.current);c!==void 0&&(e[a]=c),a===e.length-1&&(this.finalKeyframe=l)}}if(this.resolveNoneKeyframes(),!gk.has(n)||e.length!==2)return;const[r,i]=e;if(typeof r=="number"&&typeof i=="number")return;const s=Ev(r),o=Ev(i);if(cv(r)!==cv(i)&&si[n]){this.needsMeasurement=!0;return}if(s!==o)if(bv(s)&&bv(o))for(let a=0;a<e.length;a++){const l=e[a];typeof l=="string"&&(e[a]=parseFloat(l))}else si[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:t}=this,n=[];for(let r=0;r<e.length;r++)(e[r]===null||BL(e[r]))&&n.push(r);n.length&&VL(e,n,t)}measure(){const{element:e,name:t}=this;return si[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(([i,s])=>{e.getValue(i).set(s)}),this.resolveNoneKeyframes()}},wm=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"];function $L(e){return TS(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}function Sm(e){return TS(e)&&"ownerSVGElement"in e}var qf=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function bk(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 i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(r=>r!=null)}var HL={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},WL=Os.length;function UL(e,t,n){let r="",i=!0;for(let o=0;o<WL;o++){const a=Os[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=qf(l,mc[a]);if(!c){i=!1;const h=HL[a]||a;r+=`${h}(${u}) `}n&&(t[a]=u)}}const s=e.pathRotation;return s&&(i=!1,r+=`rotate(${qf(s,mc.pathRotation)}) `),r=r.trim(),n?r=n(t,i?"":r):i&&(r="none"),r}function km(e,t,n){const{style:r,vars:i,transformOrigin:s}=e;let o=!1,a=!1;for(const l in t){const c=t[l];if(Er.has(l)){o=!0;continue}else if(FS(l)){i[l]=c;continue}else{const u=qf(c,mc[l]);l.startsWith("origin")?(a=!0,s[l]=u):r[l]=u}}if(t.transform||(o||n?r.transform=UL(t,e.transform,n):r.transform&&(r.transform="none")),a){const{originX:l="50%",originY:c="50%",originZ:u=0}=s;r.transformOrigin=`${l} ${c} ${u}`}}var qL={offset:"stroke-dashoffset",array:"stroke-dasharray"},KL={offset:"strokeDashoffset",array:"strokeDasharray"};function GL(e,t,n=1,r=0,i=!0){e.pathLength=1;const s=i?qL:KL;e[s.offset]=`${-r}`,e[s.array]=`${t} ${n}`}var wk=["transform","opacity","offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Sk(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:s=1,pathOffset:o=0,...a},l,c,u){if(km(e,a,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:h,style:f}=e;for(const d of wk)h[d]!==void 0&&(f[d]=h[d],delete h[d]);(f.transform||h.transformOrigin)&&(f.transformOrigin=h.transformOrigin??"50% 50%",delete h.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??"fill-box",delete h.transformBox),t!==void 0&&(h.x=t),n!==void 0&&(h.y=n),r!==void 0&&(h.scale=r),i!==void 0&&GL(h,i,s,o,!1)}function kk({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function QL({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function YL(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 oh(e){return e===void 0||e===1}function Kf({scale:e,scaleX:t,scaleY:n}){return!oh(e)||!oh(t)||!oh(n)}function Jr(e){return Kf(e)||Ck(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ck(e){return Mv(e.x)||Mv(e.y)}function Mv(e){return e&&e!=="0%"}function gc(e,t,n){return n+t*(e-n)}function Rv(e,t,n,r,i){return i!==void 0&&(e=gc(e,i,r)),gc(e,n,r)+t}function Gf(e,t=0,n=1,r,i){e.min=Rv(e.min,t,n,r,i),e.max=Rv(e.max,t,n,r,i)}function Ak(e,{x:t,y:n}){Gf(e.x,t.translate,t.scale,t.originPoint),Gf(e.y,n.translate,n.scale,n.originPoint)}var Pv=.999999999999,Iv=1.0000000000001;function XL(e,t,n,r=!1){const i=n.length;if(!i)return;t.x=t.y=1;let s,o;for(let a=0;a<i;a++){s=n[a],o=s.projectionDelta;const{visualElement:l}=s.options;l&&l.props.style&&l.props.style.display==="contents"||(r&&s.options.layoutScroll&&s.scroll&&s!==s.root&&(Sn(e.x,-s.scroll.offset.x),Sn(e.y,-s.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Ak(e,o)),r&&Jr(s.latestValues)&&Ml(e,s.latestValues,s.layout?.layoutBox))}t.x<Iv&&t.x>Pv&&(t.x=1),t.y<Iv&&t.y>Pv&&(t.y=1)}function Sn(e,t){e.min+=t,e.max+=t}function Ov(e,t,n,r,i=.5){Gf(e,t,n,ye(e.min,e.max,i),r)}function Dv(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Ml(e,t,n){const r=n??e;Ov(e.x,Dv(t.x,r.x),t.scaleX,t.scale,t.originX),Ov(e.y,Dv(t.y,r.y),t.scaleY,t.scale,t.originY)}function Tk(e,t){return kk(YL(e.getBoundingClientRect(),t))}function JL(e,t,n){const r=Tk(e,n),{scroll:i}=t;return i&&(Sn(r.x,i.offset.x),Sn(r.y,i.offset.y)),r}var{schedule:Cm,cancel:b6}=KS(queueMicrotask,!1),Kt={x:!1,y:!1};function Ek(){return Kt.x||Kt.y}function ZL(e){return e==="x"||e==="y"?Kt[e]?null:(Kt[e]=!0,()=>{Kt[e]=!1}):Kt.x||Kt.y?null:(Kt.x=Kt.y=!0,()=>{Kt.x=Kt.y=!1})}function Mk(e,t){const n=bk(e),r=new AbortController,i={passive:!0,...t,signal:r.signal};return[n,i,()=>r.abort()]}function e_(e){return!(e.pointerType==="touch"||Ek())}function t_(e,t,n={}){const[r,i,s]=Mk(e,n);return r.forEach(o=>{let a=!1,l=!1,c;const u=()=>{o.removeEventListener("pointerleave",m)},h=y=>{c&&(c(y),c=void 0),u()},f=y=>{a=!1,window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f),l&&(l=!1,h(y))},d=()=>{a=!0,window.addEventListener("pointerup",f,i),window.addEventListener("pointercancel",f,i)},m=y=>{if(y.pointerType!=="touch"){if(a){l=!0;return}h(y)}},v=y=>{if(!e_(y))return;l=!1;const x=t(o,y);typeof x=="function"&&(c=x,o.addEventListener("pointerleave",m,i))};o.addEventListener("pointerenter",v,i),o.addEventListener("pointerdown",d,i)}),s}var Rk=(e,t)=>t?e===t?!0:Rk(e,t.parentElement):!1,Am=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,n_=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function r_(e){return n_.has(e.tagName)||e.isContentEditable===!0}var i_=new Set(["INPUT","SELECT","TEXTAREA"]);function s_(e){return i_.has(e.tagName)||e.isContentEditable===!0}var Rl=new WeakSet;function Nv(e){return t=>{t.key==="Enter"&&e(t)}}function ah(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}var o_=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=Nv(()=>{if(Rl.has(n))return;ah(n,"down");const i=Nv(()=>{ah(n,"up")}),s=()=>ah(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",s,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function Lv(e){return Am(e)&&!Ek()}var _v=new WeakSet;function a_(e,t,n={}){const[r,i,s]=Mk(e,n),o=a=>{const l=a.currentTarget;if(!Lv(a)||_v.has(a))return;Rl.add(l),n.stopPropagation&&_v.add(a);const c=t(l,a),u={...i,capture:!0},h=(m,v)=>{window.removeEventListener("pointerup",f,u),window.removeEventListener("pointercancel",d,u),Rl.has(l)&&Rl.delete(l),Lv(m)&&typeof c=="function"&&c(m,{success:v})},f=m=>{h(m,l===window||l===document||n.useGlobalTarget||Rk(l,m.target))},d=m=>{h(m,!1)};window.addEventListener("pointerup",f,u),window.addEventListener("pointercancel",d,u)};return r.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),$L(a)&&(a.addEventListener("focus",l=>o_(l,i)),!r_(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),s}var Pl=new WeakMap,Il,Pk=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+"Size"]:Sm(r)&&"getBBox"in r?r.getBBox()[t]:r[n],l_=Pk("inline","width","offsetWidth"),c_=Pk("block","height","offsetHeight");function u_({target:e,borderBoxSize:t}){Pl.get(e)?.forEach(n=>{n(e,{get width(){return l_(e,t)},get height(){return c_(e,t)}})})}function h_(e){e.forEach(u_)}function f_(){typeof ResizeObserver>"u"||(Il=new ResizeObserver(h_))}function d_(e,t){Il||f_();const n=bk(e);return n.forEach(r=>{let i=Pl.get(r);i||(i=new Set,Pl.set(r,i)),i.add(t),Il?.observe(r)}),()=>{n.forEach(r=>{const i=Pl.get(r);i?.delete(t),i?.size||Il?.unobserve(r)})}}var Ol=new Set,Ui;function p_(){Ui=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Ol.forEach(t=>t(e))},window.addEventListener("resize",Ui)}function m_(e){return Ol.add(e),Ui||p_(),()=>{Ol.delete(e),!Ol.size&&typeof Ui=="function"&&(window.removeEventListener("resize",Ui),Ui=void 0)}}function jv(e,t){return typeof e=="function"?m_(e):d_(e,t)}var Bi={value:null,addProjectionMetrics:null};function g_(e){return Sm(e)&&e.tagName==="svg"}var Bv=e=>typeof e=="number"?e:parseFloat(e),Fv=()=>({translate:0,scale:1,origin:0,originPoint:0}),qi=()=>({x:Fv(),y:Fv()}),Vv=()=>({min:0,max:0}),He=()=>({x:Vv(),y:Vv()}),v_=new WeakMap;function ou(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function qo(e){return typeof e=="string"||Array.isArray(e)}var Tm=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],zv=["initial",...Tm];function au(e){if(ou(e.animate))return!0;for(let t=0;t<zv.length;t++)if(qo(e[zv[t]]))return!0;return!1}function Ik(e){return!!(au(e)||e.variants)}function y_(e,t,n){for(const r in t){const i=t[r],s=n[r];if(st(i))e.addValue(r,i);else if(st(s))e.addValue(r,ds(i,{owner:e}));else if(s!==i)if(e.hasValue(r)){const o=e.getValue(r);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=e.getStaticValue(r);e.addValue(r,ds(o!==void 0?o:i,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}var $v=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],vc={};function Ok(e){vc=e}function x_(){return vc}var b_=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:s,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=vm,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 f=it.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,we.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=i,this.options=a,this.blockInitialAnimation=!!s,this.isControllingVariants=au(t),this.isVariantNode=Ik(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:u,...h}=this.scrapeMotionValuesFromProps(t,{},this);for(const f in h){const d=h[f];l[f]!==void 0&&st(d)&&d.set(l[f])}}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,v_.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:(gM.current||mM(),this.shouldReduceMotion=fM.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(),Ir(this.notifyUpdate),Ir(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&&Hf.has(e)&&this.current instanceof HTMLElement){const{factory:s,keyframes:o,times:a,ease:l,duration:c}=t.accelerate,u=new ck({element:this.current,name:e,keyframes:o,times:a,ease:l,duration:Pt(c)}),h=s(u);this.valueSubscriptions.set(e,()=>{h(),u.cancel()});return}const n=Er.has(e);n&&this.onBindTransform&&this.onBindTransform();const r=t.on("change",s=>{this.latestValues[e]=s,this.props.onUpdate&&we.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let i;typeof window<"u"&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}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 vc){const t=vc[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 i=this.features[e];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):He()}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<$v.length;n++){const r=$v[n];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const i=e["on"+r];i&&(this.propEventSubscriptions[r]=this.on(r,i))}this.prevMotionValues=y_(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=ds(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"&&(rm(n)||im(n))?n=parseFloat(n):typeof n!="number"&&!It.test(n)&&It.test(t)&&(n=gm(e,t)),this.setBaseTarget(e,st(n)?n.get():n)),st(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new hc),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Cm.render(this.render)}},Dk=class extends b_{constructor(){super(...arguments),this.KeyframeResolver=zL}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;st(e)&&(this.childSubscription=e.on("change",t=>{this.current&&(this.current.textContent=`${t}`)}))}},zr=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Nk(e,{style:t,vars:n},r,i){const s=e.style;let o;for(o in t)s[o]=t[o];i?.applyProjectionStyles(s,r);for(o in n)s.setProperty(o,n[o])}var Ko={};function Lk(e,{layout:t,layoutId:n}){return Er.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Ko[e]||e==="opacity")}function Em(e,t,n){const r=e.style,i=t?.style,s={};if(!r)return s;for(const o in r)(st(r[o])||i&&st(i[o])||Lk(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(s[o]=r[o]);return s}function w_(e){return window.getComputedStyle(e)}var S_=class extends Dk{constructor(){super(...arguments),this.type="html",this.renderInstance=Nk}mount(e){vi(!!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(Er.has(t))return this.projection?.isProjecting?Uo(t):H2(e,t);{const n=w_(e),r=(FS(t)?n.getPropertyValue(t):n[t])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Tk(e,t)}build(e,t,n){km(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Em(e,t,n)}},_k=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"]),jk=e=>typeof e=="string"&&e.toLowerCase()==="svg";function k_(e,t,n,r){Nk(e,t,void 0,r);for(const i in t.attrs)e.setAttribute(_k.has(i)?i:bm(i),t.attrs[i])}function Bk(e,t,n){const r=Em(e,t,n);for(const i in e)if(st(e[i])||st(t[i])){const s=Os.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[s]=e[i]}return r}var C_=class extends Dk{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=He}getBaseTargetFromProps(e,t){return Er.has(t)?super.getBaseTargetFromProps(e,t)??Uo(t):e[t]}getDefaultValue(e){return Er.has(e)?this.latestValues[e]??Uo(e):void 0}readValueFromInstance(e,t){if(Er.has(t)){const n=tk(t);return n&&n.default||0}if(wk.includes(t)){const n=getComputedStyle(e)[t];if(typeof n=="string"&&n)return n.trim()}return t=_k.has(t)?t:bm(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Bk(e,t,n)}build(e,t,n){Sk(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){k_(e,t,n,r)}mount(e){this.isSVGTag=jk(e.tagName),super.mount(e)}};function Fk(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 A_=[...Tm].reverse();function T_(e){let t=a=>Promise.all(a.map(({animation:l,options:c})=>NL(e,l,c))),n=Hv(),r=!0,i=!1;function s(a){const{props:l,parent:c,manuallyAnimateOnMount:u}=e,h=r||i,f=[],d=new Set;let m={},v=1/0,y=e;do y=y.props.inherit!==!1&&y.parent;while(y&&!y.isControllingVariants);if(A_.forEach((b,w)=>{const S=n[b],C=l[b],A=y&&y.props[b],k=C!==void 0?C:qo(A)||A===!1?A:void 0,E=qo(k),T=b===a?S.isActive:null;T===!1&&(v=w);const R=E&&C===void 0&&!(h&&u);if(S.protectedKeys={...m},!S.isActive&&T===null||!k&&!S.prevProp||ou(k)||typeof k=="boolean")return;if(b==="exit"&&S.isActive&&T!==!0){m={...m,...S.prevResolvedValues};return}const P=E_(S.prevProp,k);let M=P||E&&(T&&!R||w>v),N=!1;const L=Array.isArray(k)?k:[k];let I={};if(T!==!1)for(const j of L){const{transition:$,transitionEnd:B,...D}=ai(e,j,mk(e,b))||{};I={...I,...D,...B}}const{prevResolvedValues:_}=S;for(const j in{..._,...I}){if(j in m)continue;const $=I[j],B=_[j],D=Array.isArray($)&&Array.isArray(B)?!Fk($,B)||P:$!==B;if(D&&$==null)d.add(j);else if(D||$!==void 0&&d.has(j)){M=!0,d.delete(j)&&(N=!0),S.needsAnimating[j]=!0;const se=e.getValue(j);se&&(se.liveStyle=!1)}else S.protectedKeys[j]=!0}if(S.prevProp=k,S.prevResolvedValues=I,S.isActive&&(m={...m,...I}),M&&(!(R&&P)||N))for(const j of L){const $={type:b};if(typeof j=="string"&&h&&u&&c?.enteringChildren){const B=ai(c,j)?.transition?.delayChildren;$.delay=hk(c.enteringChildren,e,B)}f.push({animation:j,options:$})}}),d.size){const{initial:b}=l,w={},S=typeof b!="boolean"&&ai(e,Array.isArray(b)?b[0]:b,e.presenceContext?.custom);S&&S.transition&&(w.transition=S.transition),d.forEach(C=>{const A=e.getValue(C);A&&(A.liveStyle=!0);const k=S&&!Array.isArray(b)?S[C]:void 0,E=e.getBaseTargetFromProps(l,C);w[C]=(k!==void 0?k:E!==void 0&&!st(E)?E:e.initialValues[C]===void 0?e.baseTarget[C]:void 0)??null}),f.push({animation:w})}const x=h&&e.blockInitialAnimation||r&&!u&&(l.initial===!1||l.initial===l.animate);return r=i=!1,!x&&f.length?t(f):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=s(a);for(const u in n)n[u].protectedKeys={};return c}return{animateChanges:s,setActive:o,setAnimateFunction:a=>{t=a(e)},getState:()=>n,reset:()=>{n=Hv(),i=!0}}}function E_(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Fk(t,e):!1}function Hv(){const e={};for(const t of Tm)e[t]={isActive:t==="animate",protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function Qf(e,t){e.min=t.min,e.max=t.max}function Ht(e,t){Qf(e.x,t.x),Qf(e.y,t.y)}function Wv(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var M_=.9999,R_=1.0001,P_=-.01,I_=.01;function dt(e){return e.max-e.min}function O_(e,t,n){return Math.abs(e-t)<=n}function Uv(e,t,n,r=.5){e.origin=r,e.originPoint=ye(t.min,t.max,e.origin),e.scale=dt(n)/dt(t),e.translate=ye(n.min,n.max,e.origin)-e.originPoint,(e.scale>=M_&&e.scale<=R_||isNaN(e.scale))&&(e.scale=1),(e.translate>=P_&&e.translate<=I_||isNaN(e.translate))&&(e.translate=0)}function So(e,t,n,r){Uv(e.x,t.x,n.x,r?r.originX:void 0),Uv(e.y,t.y,n.y,r?r.originY:void 0)}function qv(e,t,n,r=0){e.min=(r?ye(n.min,n.max,r):n.min)+t.min,e.max=e.min+dt(t)}function D_(e,t,n,r){qv(e.x,t.x,n.x,r?.x),qv(e.y,t.y,n.y,r?.y)}function Kv(e,t,n,r=0){const i=r?ye(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+dt(t)}function yc(e,t,n,r){Kv(e.x,t.x,n.x,r?.x),Kv(e.y,t.y,n.y,r?.y)}function Gv(e,t,n,r,i){return e-=t,e=gc(e,1/n,r),i!==void 0&&(e=gc(e,1/i,r)),e}function N_(e,t=0,n=1,r=.5,i,s=e,o=e){if(Pn.test(t)&&(t=parseFloat(t),t=ye(o.min,o.max,t/100)-o.min),typeof t!="number")return;let a=ye(s.min,s.max,r);e===s&&(a-=t),e.min=Gv(e.min,t,n,a,i),e.max=Gv(e.max,t,n,a,i)}function Qv(e,t,[n,r,i],s,o){N_(e,t[n],t[r],t[i],t.scale,s,o)}var L_=["x","scaleX","originX"],__=["y","scaleY","originY"];function Yv(e,t,n,r){Qv(e.x,t,L_,n?n.x:void 0,r?r.x:void 0),Qv(e.y,t,__,n?n.y:void 0,r?r.y:void 0)}function Xv(e){return e.translate===0&&e.scale===1}function Vk(e){return Xv(e.x)&&Xv(e.y)}function Jv(e,t){return e.min===t.min&&e.max===t.max}function j_(e,t){return Jv(e.x,t.x)&&Jv(e.y,t.y)}function Zv(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function zk(e,t){return Zv(e.x,t.x)&&Zv(e.y,t.y)}function e0(e){return dt(e.x)/dt(e.y)}function t0(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function bn(e){return[e("x"),e("y")]}function n0(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var Ws={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Q.test(e))e=parseFloat(e);else return e;return`${n0(e,t.target.x)}% ${n0(e,t.target.y)}%`}},B_={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,i=It.parse(e);if(i.length>5)return r;const s=It.createTransformer(e),o=typeof i[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;i[0+o]/=a,i[1+o]/=l;const c=ye(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=c),typeof i[3+o]=="number"&&(i[3+o]/=c),s(i)}};function F_(e,t,n){let r="";const i=e.x.translate/t.x,s=e.y.translate/t.y,o=n?.z||0;if((i||s||o)&&(r=`translate3d(${i}px, ${s}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:c,rotate:u,pathRotation:h,rotateX:f,rotateY:d,skewX:m,skewY:v}=n;c&&(r=`perspective(${c}px) ${r}`),u&&(r+=`rotate(${u}deg) `),h&&(r+=`rotate(${h}deg) `),f&&(r+=`rotateX(${f}deg) `),d&&(r+=`rotateY(${d}deg) `),m&&(r+=`skewX(${m}deg) `),v&&(r+=`skewY(${v}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 V_=wm.length,r0=e=>typeof e=="number"||Q.test(e);function z_(e,t,n,r,i,s){i?(e.opacity=ye(0,n.opacity??1,$_(r)),e.opacityExit=ye(t.opacity??1,0,H_(r))):s&&(e.opacity=ye(t.opacity??1,n.opacity??1,r));for(let o=0;o<V_;o++){const a=wm[o];let l=i0(t,a),c=i0(n,a);l===void 0&&c===void 0||(l||(l=0),c||(c=0),l===0||c===0||r0(l)===r0(c)?(e[a]=Math.max(ye(Bv(l),Bv(c),r),0),(Pn.test(c)||Pn.test(l))&&(e[a]+="%")):e[a]=c)}(t.rotate||n.rotate)&&(e.rotate=ye(t.rotate||0,n.rotate||0,r))}function i0(e,t){return e[t]!==void 0?e[t]:e.borderRadius}var $_=$k(0,.5,LS),H_=$k(.5,.95,tn);function $k(e,t,n){return r=>r<e?0:r>t?1:n($o(e,t,r))}function W_(e,t,n){const r=st(e)?e:ds(e);return r.start(xm("",r,t,n)),r.animation}function Go(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var U_=(e,t)=>e.depth-t.depth,q_=class{constructor(){this.children=[],this.isDirty=!1}add(e){nm(this.children,e),this.isDirty=!0}remove(e){uc(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(U_),this.isDirty=!1,this.children.forEach(e)}};function K_(e,t){const n=it.now(),r=({timestamp:i})=>{const s=i-n;s>=t&&(Ir(r),e(s-t))};return we.setup(r,!0),()=>Ir(r)}function Dl(e){return st(e)?e.get():e}var G_=class{constructor(){this.members=[]}add(e){nm(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&&(uc(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(uc(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:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},Q_={borderRadius:{...Ws,applyTo:[...wm]},borderTopLeftRadius:Ws,borderTopRightRadius:Ws,borderBottomLeftRadius:Ws,borderBottomRightRadius:Ws,boxShadow:B_},Nl={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(Ko,{...Q_,...Ko});var Zr={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},lh=["","X","Y","Z"],Y_=1e3,X_=0;function ch(e,t,n,r){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Hk(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=yk(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:s}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",we,!(i||s))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Hk(r)}function Wk({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(o={},a=t?.()){this.id=X_++,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,Bi.value&&(Zr.nodes=Zr.calculatedTargetDeltas=Zr.calculatedProjections=0),this.nodes.forEach(ej),this.nodes.forEach(aj),this.nodes.forEach(lj),this.nodes.forEach(tj),Bi.addProjectionMetrics&&Bi.addProjectionMetrics(Zr)},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 q_)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new hc),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=Sm(o)&&!g_(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,h=0;const f=()=>this.root.updateBlockedByResize=!1;we.read(()=>{h=window.innerWidth}),e(o,()=>{const d=window.innerWidth;d!==h&&(h=d,this.root.updateBlockedByResize=!0,u&&u(),u=K_(f,250),Nl.hasAnimatedSinceResize&&(Nl.hasAnimatedSinceResize=!1,this.nodes.forEach(a0)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:h,hasRelativeLayoutChanged:f,layout:d})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const m=this.options.transition||c.getDefaultTransition()||dj,{onLayoutAnimationStart:v,onLayoutAnimationComplete:y}=c.getProps(),x=!this.targetLayout||!zk(this.targetLayout,d),b=!h&&f;if(this.options.layoutRoot||this.resumeFrom||b||h&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const w={...ym(m,"layout"),onPlay:v,onComplete:y};(c.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(u,b,w.path)}else h||a0(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=d})}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(),Ir(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(cj),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&&Hk(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const h=this.path[u];h.shouldResetTransform=!0,(typeof h.latestValues.x=="string"||typeof h.latestValues.y=="string")&&(h.isLayoutDirty=!0),h.updateScroll("snapshot"),h.options.layoutRoot&&h.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(rj),this.nodes.forEach(s0);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(o0);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ij),this.nodes.forEach(sj),this.nodes.forEach(oj),this.nodes.forEach(J_),this.nodes.forEach(Z_)):this.nodes.forEach(o0),this.clearAllSnapshots();const o=it.now();We.delta=fr(0,1e3/60,o-We.timestamp),We.timestamp=o,We.isProcessing=!0,rh.update.process(We),rh.preRender.process(We),rh.render.process(We),We.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Cm.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(nj),this.sharedNodes.forEach(uj)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,we.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){we.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!dt(this.snapshot.measuredBox.x)&&!dt(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=He()),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(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Vk(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;o&&this.instance&&(a||Jr(this.latestValues)||u)&&(i(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)),pj(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return He();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(mj))){const{scroll:l}=this.root;l&&(Sn(a.x,l.offset.x),Sn(a.y,l.offset.y))}return a}removeElementScroll(o){const a=He();if(Ht(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const c=this.path[l],{scroll:u,options:h}=c;c!==this.root&&u&&h.layoutScroll&&(u.wasRoot&&Ht(a,o),Sn(a.x,u.offset.x),Sn(a.y,u.offset.y))}return a}applyTransform(o,a=!1,l){const c=l||He();Ht(c,o);for(let u=0;u<this.path.length;u++){const h=this.path[u];!a&&h.options.layoutScroll&&h.scroll&&h!==h.root&&(Sn(c.x,-h.scroll.offset.x),Sn(c.y,-h.scroll.offset.y)),Jr(h.latestValues)&&Ml(c,h.latestValues,h.layout?.layoutBox)}return Jr(this.latestValues)&&Ml(c,this.latestValues,this.layout?.layoutBox),c}removeTransform(o){const a=He();Ht(a,o);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!Jr(c.latestValues))continue;let u;c.instance&&(Kf(c.latestValues)&&c.updateSnapshot(),u=He(),Ht(u,c.measurePageBox())),Yv(a,c.latestValues,c.snapshot?.layoutBox,u)}return Jr(this.latestValues)&&Yv(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!==We.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=We.timestamp;const h=this.getClosestProjectingParent();!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&h&&h.layout?this.createRelativeTarget(h,this.layout.layoutBox,h.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=He(),this.targetWithTransforms=He()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),D_(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Ht(this.target,this.layout.layoutBox),Ak(this.target,this.targetDelta)):Ht(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&h&&!!h.resumingFrom==!!this.resumingFrom&&!h.options.layoutScroll&&h.target&&this.animationProgress!==1?this.createRelativeTarget(h,this.target,h.target):this.relativeParent=this.relativeTarget=void 0),Bi.value&&Zr.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Kf(this.parent.latestValues)||Ck(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=He(),this.relativeTargetOrigin=He(),yc(this.relativeTargetOrigin,a,l,this.options.layoutAnchor||void 0),Ht(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===We.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;Ht(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,f=this.treeScale.y;XL(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=He());const{target:d}=o;if(!d){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Wv(this.prevProjectionDelta.x,this.projectionDelta.x),Wv(this.prevProjectionDelta.y,this.projectionDelta.y)),So(this.projectionDelta,this.layoutCorrected,d,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==f||!t0(this.projectionDelta.x,this.prevProjectionDelta.x)||!t0(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",d)),Bi.value&&Zr.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=qi(),this.projectionDelta=qi(),this.projectionDeltaWithTransform=qi()}setAnimationOrigin(o,a=!1,l){const c=this.snapshot,u=c?c.latestValues:{},h={...this.latestValues},f=qi();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const d=He(),m=(c?c.source:void 0)!==(this.layout?this.layout.source:void 0),v=this.getStack(),y=!v||v.members.length<=1,x=!!(m&&!y&&this.options.crossfade===!0&&!this.path.some(fj));this.animationProgress=0;let b;const w=l?.interpolateProjection(o);this.mixTargetDelta=S=>{const C=S/1e3,A=w?.(C);A?(f.x.translate=A.x,f.x.scale=ye(o.x.scale,1,C),f.x.origin=o.x.origin,f.x.originPoint=o.x.originPoint,f.y.translate=A.y,f.y.scale=ye(o.y.scale,1,C),f.y.origin=o.y.origin,f.y.originPoint=o.y.originPoint):(l0(f.x,o.x,C),l0(f.y,o.y,C)),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(yc(d,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),hj(this.relativeTarget,this.relativeTargetOrigin,d,C),b&&j_(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=He()),Ht(b,this.relativeTarget)),m&&(this.animationValues=h,z_(h,u,this.latestValues,C,x,y)),A&&A.rotate!==void 0&&(this.animationValues||(this.animationValues=h),this.animationValues.pathRotation=A.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=C},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Ir(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=we.update(()=>{Nl.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=ds(0)),this.motionValue.jump(0,!1),this.currentAnimation=W_(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()}}),O2(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(Y_),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&&Uk(this.options.animationType,this.layout.layoutBox,l.layoutBox)){u=this.target||He();const h=dt(this.layout.layoutBox.x);u.x.min=o.target.x.min,u.x.max=u.x.min+h;const f=dt(this.layout.layoutBox.y);u.y.min=o.target.y.min,u.y.max=u.y.min+f}Ht(a,u),Ml(a,c),So(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new G_),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&&ch("z",o,c,this.animationValues);for(let u=0;u<lh.length;u++)ch(`rotate${lh[u]}`,o,c,this.animationValues),ch(`skew${lh[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=Dl(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=Dl(a?.pointerEvents)||""),this.hasProjected&&!Jr(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let h=F_(this.projectionDeltaWithTransform,this.treeScale,u);l&&(h=l(u,h)),o.transform=h;const{x:f,y:d}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${d.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 m in Ko){if(u[m]===void 0)continue;const{correct:v,applyTo:y,isCSSVariable:x}=Ko[m],b=h==="none"?u[m]:v(u[m],c);if(y){const w=y.length;for(let S=0;S<w;S++)o[y[S]]=b}else x?this.options.visualElement.renderState.vars[m]=b:o[m]=b}this.options.layoutId&&(o.pointerEvents=c===this?Dl(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(s0),this.root.sharedNodes.clear()}}}function J_(e){e.updateLayout()}function Z_(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:i}=e.options,s=t.source!==e.layout.source;if(i==="size")bn(u=>{const h=s?t.measuredBox[u]:t.layoutBox[u],f=dt(h);h.min=n[u].min,h.max=h.min+f});else if(i==="x"||i==="y"){const u=i==="x"?"y":"x";Qf(s?t.measuredBox[u]:t.layoutBox[u],n[u])}else Uk(i,t.layoutBox,n)&&bn(u=>{const h=s?t.measuredBox[u]:t.layoutBox[u],f=dt(n[u]);h.max=h.min+f,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[u].max=e.relativeTarget[u].min+f)});const o=qi();So(o,n,t.layoutBox);const a=qi();s?So(a,e.applyTransform(r,!0),t.measuredBox):So(a,n,t.layoutBox);const l=!Vk(o);let c=!1;if(!e.resumeFrom){const u=e.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:h,layout:f}=u;if(h&&f){const d=e.options.layoutAnchor||void 0,m=He();yc(m,t.layoutBox,h.layoutBox,d);const v=He();yc(v,n,f.layoutBox,d),zk(m,v)||(c=!0),u.options.layoutRoot&&(e.relativeTarget=v,e.relativeTargetOrigin=m,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 ej(e){Bi.value&&Zr.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 tj(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function nj(e){e.clearSnapshot()}function s0(e){e.clearMeasurements()}function rj(e){e.isLayoutDirty=!0,e.updateLayout()}function o0(e){e.isLayoutDirty=!1}function ij(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function sj(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function oj(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function a0(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function aj(e){e.resolveTargetDelta()}function lj(e){e.calcProjection()}function cj(e){e.resetSkewAndRotation()}function uj(e){e.removeLeadSnapshot()}function l0(e,t,n){e.translate=ye(t.translate,0,n),e.scale=ye(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function c0(e,t,n,r){e.min=ye(t.min,n.min,r),e.max=ye(t.max,n.max,r)}function hj(e,t,n,r){c0(e.x,t.x,n.x,r),c0(e.y,t.y,n.y,r)}function fj(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var dj={duration:.45,ease:[.4,0,.1,1]},u0=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),h0=u0("applewebkit/")&&!u0("chrome/")?Math.round:tn;function f0(e){e.min=h0(e.min),e.max=h0(e.max)}function pj(e){f0(e.x),f0(e.y)}function Uk(e,t,n){return e==="position"||e==="preserve-aspect"&&!O_(e0(t),e0(n),.2)}function mj(e){return e!==e.root&&e.scroll?.wasRoot}var gj=Wk({attachResizeListener:(e,t)=>Go(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),uh={current:void 0},qk=Wk({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!uh.current){const e=new gj({});e.mount(window),e.setOptions({layoutScroll:!0}),uh.current=e}return uh.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Kk=(0,g.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function vj(e=!0){const t=(0,g.useContext)(ru);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:i}=t,s=(0,g.useId)();(0,g.useEffect)(()=>{if(e)return i(s)},[e]);const o=(0,g.useCallback)(()=>e&&r&&r(s),[s,r,e]);return!n&&r?[!1,o]:[!0]}function S6(){return yj((0,g.useContext)(ru))}function yj(e){return e===null?!0:e.isPresent}var Gk=(0,g.createContext)({strict:!1}),d0={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"]},p0=!1;function xj(){if(p0)return;const e={};for(const t in d0)e[t]={isEnabled:n=>d0[t].some(r=>!!n[r])};Ok(e),p0=!0}function Qk(){return xj(),x_()}function bj(e){const t=Qk();for(const n in e)t[n]={...t[n],...e[n]};Ok(t)}var lu=(0,g.createContext)({});function wj(e,t){if(au(e)){const{initial:n,animate:r}=e;return{initial:n===!1||qo(n)?n:void 0,animate:qo(r)?r:void 0}}return e.inherit!==!1?t:{}}function Sj(e){const{initial:t,animate:n}=wj(e,(0,g.useContext)(lu));return(0,g.useMemo)(()=>({initial:t,animate:n}),[m0(t),m0(n)])}function m0(e){return Array.isArray(e)?e.join(" "):e}var Mm=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Yk(e,t,n){for(const r in t)!st(t[r])&&!Lk(r,n)&&(e[r]=t[r])}function kj({transformTemplate:e},t){return(0,g.useMemo)(()=>{const n=Mm();return km(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Cj(e,t){const n=e.style||{},r={};return Yk(r,n,e),Object.assign(r,kj(e,t)),r}function Aj(e,t){const n={},r=Cj(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 Xk=()=>({...Mm(),attrs:{}});function Tj(e,t,n,r){const i=(0,g.useMemo)(()=>{const s=Xk();return Sk(s,t,jk(r),e.transformTemplate,e.style),{...s.attrs,style:{...s.style}}},[t]);if(e.style){const s={};Yk(s,e.style,e),i.style={...s,...i.style}}return i}var Ej=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 xc(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Ej.has(e)}function Mj(e,t){return e.startsWith("on")?!xc(e):t?.(e)??!xc(e)}function Rj(e,t,n,r){const i={};for(const s in e)s==="values"&&typeof e.values=="object"||st(e[s])||(Mj(s,r)||n===!0&&xc(s)||!t&&!xc(s)||e.draggable&&s.startsWith("onDrag"))&&(i[s]=e[s]);return i}var Pj=["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 Rm(e){return typeof e!="string"||e.includes("-")?!1:!!(Pj.indexOf(e)>-1||/[A-Z]/u.test(e))}function Ij(e,t,n,{latestValues:r},i,s=!1,o,a){const l=(o??Rm(e)?Tj:Aj)(t,r,i,e),c=Rj(t,typeof e=="string",s,a),u=e!==g.Fragment?{...c,...l,ref:n}:{},{children:h}=t,f=(0,g.useMemo)(()=>st(h)?h.get():h,[h]);return(0,g.createElement)(e,{...u,children:f})}function Oj({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Dj(n,r,i,e),renderState:t()}}function Dj(e,t,n,r){const i={},s=r(e,{});for(const f in s)i[f]=Dl(s[f]);let{initial:o,animate:a}=e;const l=au(e),c=Ik(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 h=u?a:o;if(h&&typeof h!="boolean"&&!ou(h)){const f=Array.isArray(h)?h:[h];for(let d=0;d<f.length;d++){const m=pk(e,f[d]);if(m){const{transitionEnd:v,transition:y,...x}=m;for(const b in x){let w=x[b];if(Array.isArray(w)){const S=u?w.length-1:0;w=w[S]}w!==null&&(i[b]=w)}for(const b in v)i[b]=v[b]}}}return i}var Jk=e=>(t,n)=>{const r=(0,g.useContext)(lu),i=(0,g.useContext)(ru),s=()=>Oj(e,t,r,i);return n?s():PN(s)},Nj=Jk({scrapeMotionValuesFromProps:Em,createRenderState:Mm}),Lj=Jk({scrapeMotionValuesFromProps:Bk,createRenderState:Xk}),_j=Symbol.for("motionComponentSymbol");function jj(e,t,n){const r=(0,g.useRef)(n);(0,g.useInsertionEffect)(()=>{r.current=n});const i=(0,g.useRef)(null);return(0,g.useCallback)(s=>{s&&e.onMount?.(s),t&&(s?t.mount(s):t.unmount());const o=r.current;if(typeof o=="function")if(s){const a=o(s);typeof a=="function"&&(i.current=a)}else i.current?(i.current(),i.current=null):o(s);else o&&(o.current=s)},[t])}var Zk=(0,g.createContext)({});function Fi(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Bj(e,t,n,r,i,s){const{visualElement:o}=(0,g.useContext)(lu),a=(0,g.useContext)(Gk),l=(0,g.useContext)(ru),c=(0,g.useContext)(Kk),u=c.reducedMotion,h=c.skipAnimations,f=(0,g.useRef)(null),d=(0,g.useRef)(!1);r=r||a.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:u,skipAnimations:h,isSVG:s}),d.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));const m=f.current,v=(0,g.useContext)(Zk);m&&!m.projection&&i&&(m.type==="html"||m.type==="svg")&&Fj(f.current,n,i,v);const y=(0,g.useRef)(!1);(0,g.useInsertionEffect)(()=>{m&&y.current&&m.update(n,l)});const x=n[vk],b=(0,g.useRef)(!!x&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(x)&&window.MotionHasOptimisedAnimation?.(x));return ov(()=>{!d.current||!m||(m.animationState?.animateChanges(),m.enteringChildren=void 0)},[]),ov(()=>{d.current=!0,m&&(y.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),b.current&&m.animationState&&m.animationState.animateChanges())}),(0,g.useEffect)(()=>{m&&(!b.current&&m.animationState&&m.animationState.animateChanges(),b.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(x)}),b.current=!1),m.enteringChildren=void 0)}),m}function Fj(e,t,n,r){const{layoutId:i,layout:s,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:c,layoutAnchor:u,layoutCrossfade:h}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:e1(e.parent)),e.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!o||a&&Fi(a),visualElement:e,animationType:typeof s=="string"?s:"both",initialPromotionConfig:r,crossfade:h,layoutScroll:l,layoutRoot:c,layoutAnchor:u})}function e1(e){if(e)return e.options.allowProjection!==!1?e.projection:e1(e.parent)}function hh(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&bj(r);const s=n?n==="svg":Rm(e),o=s?Lj:Nj;function a(c,u){let h;const f={...(0,g.useContext)(Kk),...c,layoutId:Vj(c)},{isStatic:d,isValidProp:m}=f,v=Sj(c),y=o(c,d);if(!d&&typeof window<"u"){zj(f,r);const x=$j(f);h=x.MeasureLayout,v.visualElement=Bj(e,y,f,i,x.ProjectionNode,s)}return(0,p.jsxs)(lu.Provider,{value:v,children:[h&&v.visualElement?(0,p.jsx)(h,{visualElement:v.visualElement,...f}):null,Ij(e,c,jj(y,v.visualElement,u),y,d,t,s,m)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const l=(0,g.forwardRef)(a);return l[_j]=e,l}function Vj({layoutId:e}){const t=(0,g.useContext)(AS).id;return t&&e!==void 0?t+"-"+e:e}function zj(e,t){(0,g.useContext)(Gk).strict}function $j(e){const{drag:t,layout:n}=Qk();if(!t&&!n)return{};const r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function Hj(e,t){if(typeof Proxy>"u")return hh;const n=new Map,r=(s,o)=>hh(s,o,e,t),i=(s,o)=>r(s,o);return new Proxy(i,{get:(s,o)=>o==="create"?r:(n.has(o)||n.set(o,hh(o,void 0,e,t)),n.get(o))})}var Wj=(e,t)=>t.isSVG??Rm(e)?new C_(t):new S_(t,{allowProjection:e!==g.Fragment}),Uj=class extends zr{constructor(e){super(e),e.animationState||(e.animationState=T_(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();ou(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?.()}},qj=0,Kj=class extends zr{constructor(){super(...arguments),this.id=qj++}update(){const{presenceContext:e,prevPresenceContext:t,animationState:n}=this.node;if(!e||!n)return;const{isPresent:r,onExitComplete:i}=e,s=t?.isPresent;if(r===s)return;if(r&&s===!1){if(this.exit===!0){const{initial:a}=this.node.getProps();if(a&&!Array.isArray(a)){const{transition:l,transitionEnd:c,...u}=ai(this.node,a)||{};for(const h in u)this.node.getValue(h)?.jump(u[h])}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);i&&!r&&o.then(()=>{this.exit===o&&(this.exit=!0,i(this.id))})}mount(){const{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}},Gj={animation:{Feature:Uj},exit:{Feature:Kj}};function cu(e){return{point:{x:e.pageX,y:e.pageY}}}var Qj=e=>t=>Am(t)&&e(t,cu(t));function ko(e,t,n,r){return Go(e,t,Qj(n),r)}var t1=({current:e})=>e?e.ownerDocument.defaultView:null,g0=(e,t)=>Math.abs(e-t);function Yj(e,t){const n=g0(e.x,t.x),r=g0(e.y,t.y);return Math.sqrt(n**2+r**2)}var v0=new Set(["auto","scroll"]),n1=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:s=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=f=>{this.handleScroll(f.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.hasPendingMove=!1,this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Ka(this.lastRawMoveEventInfo,this.transformPagePoint));const f=fh(this.lastMoveEventInfo,this.history),d=this.startEvent!==null,m=Yj(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!d&&!m)return;const{point:v}=f;this.history.push({...v,timestamp:it.now()});const{onStart:y,onMove:x}=this.handlers;d||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,f)},this.handlePointerMove=(f,d)=>{this.lastMoveEvent=f,this.lastRawMoveEventInfo=d,this.lastMoveEventInfo=Ka(d,this.transformPagePoint),this.hasPendingMove=!0,we.update(this.updatePoint,!0)},this.handlePointerUp=(f,d)=>{this.hasPendingMove&&this.updatePoint(),this.end();const{onEnd:m,onSessionEnd:v,resumeAnimation:y}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&y&&y(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=fh(f.type==="pointercancel"?this.lastMoveEventInfo:Ka(d,this.transformPagePoint),this.history);this.startEvent&&m&&m(f,x),v&&v(f,x)},!Am(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=s,this.contextWindow=r||window;const a=Ka(cu(e),this.transformPagePoint),{point:l}=a,{timestamp:c}=We;this.history=[{...l,timestamp:c}];const{onSessionStart:u}=t;u&&u(e,fh(a,this.history));const h={passive:!0,capture:!0};this.removeListeners=wa(ko(this.contextWindow,"pointermove",this.handlePointerMove,h),ko(this.contextWindow,"pointerup",this.handlePointerUp,h),ko(this.contextWindow,"pointercancel",this.handlePointerUp,h)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){const n=getComputedStyle(t);(v0.has(n.overflowX)||v0.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},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),we.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Ir(this.updatePoint)}};function Ka(e,t){return t?{point:t(e.point)}:e}function y0(e,t){return{x:e.x-t.x,y:e.y-t.y}}function fh({point:e},t){return{point:e,delta:y0(e,r1(t)),offset:y0(e,Xj(t)),velocity:Jj(t,.1)}}function Xj(e){return e[0]}function r1(e){return e[e.length-1]}function Jj(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const i=r1(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Pt(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Pt(t)*2&&(r=e[1]);const s=Lt(i.timestamp-r.timestamp);if(s===0)return{x:0,y:0};const o={x:(i.x-r.x)/s,y:(i.y-r.y)/s};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Zj(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?ye(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?ye(n,e,r.max):Math.min(e,n)),e}function x0(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 eB(e,{top:t,left:n,bottom:r,right:i}){return{x:x0(e.x,n,i),y:x0(e.y,t,r)}}function b0(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 tB(e,t){return{x:b0(e.x,t.x),y:b0(e.y,t.y)}}function nB(e,t){let n=.5;const r=dt(e),i=dt(t);return i>r?n=$o(t.min,t.max-r,e.min):r>i&&(n=$o(e.min,e.max-i,t.min)),fr(0,1,n)}function rB(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 Yf=.35;function iB(e=Yf){return e===!1?e=0:e===!0&&(e=Yf),{x:w0(e,"left","right"),y:w0(e,"top","bottom")}}function w0(e,t,n){return{min:S0(e,t),max:S0(e,n)}}function S0(e,t){return typeof e=="number"?e:e[t]||0}var sB=new WeakMap,oB=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=He(),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 i=u=>{t&&this.snapToCursor(u),this.stopAnimation()},s=(u,h)=>{const{drag:f,dragPropagation:d,onDragStart:m}=this.getProps();if(f&&!d&&(this.openDragLock&&this.openDragLock(),this.openDragLock=ZL(f),!this.openDragLock))return;this.latestPointerEvent=u,this.latestPanInfo=h,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),bn(y=>{let x=this.getAxisMotionValue(y).get()||0;if(Pn.test(x)){const{projection:b}=this.visualElement;if(b&&b.layout){const w=b.layout.layoutBox[y];w&&(x=dt(w)*(parseFloat(x)/100))}}this.originPoint[y]=x}),m&&we.update(()=>m(u,h),!1,!0),Wf(this.visualElement,"transform");const{animationState:v}=this.visualElement;v&&v.setActive("whileDrag",!0)},o=(u,h)=>{this.latestPointerEvent=u,this.latestPanInfo=h;const{dragPropagation:f,dragDirectionLock:d,onDirectionLock:m,onDrag:v}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:y}=h;if(d&&this.currentDirection===null){this.currentDirection=lB(y),this.currentDirection!==null&&m&&m(this.currentDirection);return}this.updateAxis("x",h.point,y),this.updateAxis("y",h.point,y),this.visualElement.render(),v&&we.update(()=>v(u,h),!1,!0)},a=(u,h)=>{this.latestPointerEvent=u,this.latestPanInfo=h,this.stop(u,h),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 n1(e,{onSessionStart:i,onStart:s,onMove:o,onSessionEnd:a,resumeAnimation:l},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:n,contextWindow:t1(this.visualElement),element:this.visualElement.current})}stop(e,t){const n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;const{velocity:s}=r;this.startAnimation(s);const{onDragEnd:o}=this.getProps();o&&we.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||!Ga(e,r,this.currentDirection))return;const i=this.getAxisMotionValue(e);let s=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(s=Zj(s,this.constraints[e],this.elastic[e])),i.set(s)}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&&Fi(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&n?this.constraints=eB(n.layoutBox,e):this.constraints=!1,this.elastic=iB(t),r!==this.constraints&&!Fi(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&bn(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=rB(n.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Fi(e))return!1;const n=e.current;vi(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 i=JL(n,r.root,this.visualElement.getTransformPagePoint());let s=tB(r.layout.layoutBox,i);if(t){const o=t(QL(s));this.hasMutatedConstraints=!!o,o&&(s=kk(o))}return s}startAnimation(e){const{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:s,onDragTransitionEnd:o}=this.getProps(),a=this.constraints||{},l=bn(c=>{if(!Ga(c,t,this.currentDirection))return;let u=a&&a[c]||{};(s===!0||s===c)&&(u={min:0,max:0});const h=r?200:1e6,f=r?40:1e7,d={type:"inertia",velocity:n?e[c]:0,bounceStiffness:h,bounceDamping:f,timeConstant:750,restDelta:1,restSpeed:10,...i,...u};return this.startAxisValueAnimation(c,d)});return Promise.all(l).then(o)}startAxisValueAnimation(e,t){const n=this.getAxisMotionValue(e);return Wf(this.visualElement,e),n.start(xm(e,n,0,t,this.visualElement,!1))}stopAnimation(){bn(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},i=this.visualElement.getTransformPagePoint()?.(r)||r,s=this.visualElement.measureViewportBox();bn(o=>{if(!Ga(o,n,this.currentDirection))return;const a=this.getAxisMotionValue(o),{min:l,max:c}=s[o];a.set((a.get()||0)+i[o]-ye(l,c,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Fi(t)||!n||!this.constraints)return;this.stopAnimation();const r=this.constraints,i={x:0,y:0};bn(o=>{const a=this.getAxisMotionValue(o).get();i[o]=nB({min:a,max:a},r[o])});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),bn(o=>{const a=this.getAxisMotionValue(o);if(!Ga(o,e,null)||!a.get())return;const{min:l,max:c}=this.constraints[o];a.set(ye(l,c,i[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;sB.set(this.visualElement,this);const e=this.visualElement.current,t=ko(e,"pointerdown",l=>{const{drag:c,dragListener:u=!0}=this.getProps(),h=l.target,f=h!==e&&s_(h);c&&u&&!f&&this.start(l)});let n;const r=()=>{const{dragConstraints:l}=this.getProps();Fi(l)&&l.current&&(this.constraints=this.resolveRefConstraints(),n||(n=aB(e,l.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,s=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),we.read(r);const o=Go(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(bn(u=>{const h=this.getAxisMotionValue(u);h&&(this.originPoint[u]+=l[u].translate,h.set(h.get()+l[u].translate))}),this.visualElement.render())}));return()=>{o(),t(),s(),a&&a(),n&&n()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:s=Yf,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:s,dragMomentum:o}}};function k0(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function aB(e,t,n){const r=jv(e,k0(n)),i=jv(t,k0(n));return()=>{r(),i()}}function Ga(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function lB(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}var cB=class extends zr{constructor(e){super(e),this.removeGroupControls=tn,this.removeListeners=tn,this.controls=new oB(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||tn}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()}},dh=e=>(t,n)=>{e&&we.update(()=>e(t,n),!1,!0)},uB=class extends zr{constructor(){super(...arguments),this.removePointerDownListener=tn}onPointerDown(e){this.session=new n1(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:t1(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:dh(e),onStart:dh(t),onMove:dh(n),onEnd:(i,s)=>{delete this.session,r&&we.postRender(()=>r(i,s))}}}mount(){this.removePointerDownListener=ko(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},ph=!1,hB=class extends g.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),ph&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Nl.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:s}=n;return s&&(s.isPresent=i,e.layoutDependency!==t&&s.setOptions({...s.options,layoutDependency:t}),ph=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?s.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?s.promote():s.relegate()||we.postRender(()=>{const o=s.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(),Cm.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;ph=!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 i1(e){const[t,n]=vj(),r=(0,g.useContext)(AS);return(0,p.jsx)(hB,{...e,layoutGroup:r,switchLayoutGroup:(0,g.useContext)(Zk),isPresent:t,safeToRemove:n})}var fB={pan:{Feature:uB},drag:{Feature:cB,ProjectionNode:qk,MeasureLayout:i1}};function C0(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i=r["onHover"+n];i&&we.postRender(()=>i(t,cu(t)))}var dB=class extends zr{mount(){const{current:e}=this.node;e&&(this.unmount=t_(e,(t,n)=>(C0(this.node,n,"Start"),r=>C0(this.node,r,"End"))))}unmount(){}},pB=class extends zr{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=wa(Go(this.node.current,"focus",()=>this.onFocus()),Go(this.node.current,"blur",()=>this.onBlur()))}unmount(){}};function A0(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 i=r["onTap"+(n==="End"?"":n)];i&&we.postRender(()=>i(t,cu(t)))}var mB=class extends zr{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=a_(e,(r,i)=>(A0(this.node,i,"Start"),(s,{success:o})=>A0(this.node,s,o?"End":"Cancel")),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},Xf=new WeakMap,mh=new WeakMap,gB=e=>{const t=Xf.get(e.target);t&&t(e)},vB=e=>{e.forEach(gB)};function yB({root:e,...t}){const n=e||document;mh.has(n)||mh.set(n,{});const r=mh.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(vB,{root:e,...t})),r[i]}function xB(e,t,n){const r=yB(t);return Xf.set(e,n),r.observe(e),()=>{Xf.delete(e),r.unobserve(e)}}var bB={some:0,all:1},wB=class extends zr{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:i}=e,s={root:t?t.current:void 0,rootMargin:n,threshold:typeof r=="number"?r:bB[r]},o=a=>{const{isIntersecting:l}=a;if(this.isInView===l||(this.isInView=l,i&&!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(),h=l?c:u;h&&h(a)};this.stopObserver=xB(this.node.current,s,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(SB(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function SB({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var kB={inView:{Feature:wB},tap:{Feature:mB},focus:{Feature:pB},hover:{Feature:dB}},CB={layout:{ProjectionNode:qk,MeasureLayout:i1}},AB={...Gj,...kB,...fB,...CB},s1=Hj(AB,Wj);function TB(){return document.activeElement?.closest('[role="dialog"],[role="alertdialog"]')??document.body}async function uu(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",TB().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 EB="Project connection defaults are still syncing. Try again in a moment.",k6="Finishing setup.",MB=1e4,RB={hover:!0,touch:!1},PB={top:0,right:0,bottom:0,left:0},o1=["inline","pip","fullscreen"];function a1(){return{headers:{},requestTimeout:MB}}function C6(){return{version:1,connectionDefaults:a1(),clientCapabilities:zc()}}function A6(e){return{theme:e.theme,displayMode:e.displayMode,availableDisplayModes:o1,locale:e.locale,timeZone:e.timeZone,deviceCapabilities:e.deviceCapabilities,safeAreaInsets:e.safeAreaInsets}}function T6(e){if(!e||typeof e!="object")return!1;const t=e;return t.version===1&&(t.connectionDefaults===void 0||u1(t.connectionDefaults))&&ps(t.clientCapabilities)&&ps(t.hostContext)}function IB(e,t=zc()){return ps(e)?e:t}function OB(e,t={}){return ps(e)?e:t}function E6(e){return{version:1,connectionDefaults:l1(e?.connectionDefaults),clientCapabilities:IB(e?.clientCapabilities)}}function M6(e,t={}){return OB(e?.hostContext,t)}function l1(e,t=a1()){return u1(e)?{headers:h1(e.headers),requestTimeout:BB(e.requestTimeout,t.requestTimeout)}:t}function R6(e){return l1(e?.connectionDefaults)}function P6(e,t){return{...h1(e),...jB(t)}}function I6(e){return DB(e?.clientCapabilities??zc())}function DB(e){return GE(e)}function NB(e){const t=e?.availableDisplayModes;if(!Array.isArray(t))return o1;const n=t.filter(c1);return n.length>0?n:["inline"]}function LB(e){const t=e?.displayMode;return c1(t)?t:void 0}function O6(e){return _B(LB(e),NB(e))}function D6(e){const t=e?.theme;return t==="light"||t==="dark"?t:void 0}function N6(e,t="en-US"){return typeof e?.locale=="string"?e.locale:t}function L6(e,t="UTC"){return typeof e?.timeZone=="string"?e.timeZone:t}function _6(e,t=RB){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 j6(e,t=PB){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 _B(e,t){return e&&t.includes(e)?e:t[0]??"inline"}function c1(e){return e==="inline"||e==="pip"||e==="fullscreen"}function u1(e){return!ps(e)||e.headers!==void 0&&!ps(e.headers)?!1:e.requestTimeout===void 0||typeof e.requestTimeout=="number"&&Number.isFinite(e.requestTimeout)}function h1(e){return e?Object.fromEntries(Object.entries(e).filter(([t,n])=>t.trim()!==""&&t.toLowerCase()!=="authorization"&&typeof n=="string")):{}}function jB(e){return e?Object.fromEntries(Object.entries(e).filter(([t,n])=>t.trim()!==""&&typeof n=="string")):{}}function BB(e,t){return typeof e!="number"||!Number.isFinite(e)||e<=0?t:e}function ps(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var FB=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}},Jf="mcpjam:task-bookmarks-changed";function VB(){typeof window<"u"&&window.dispatchEvent(new Event(Jf))}function B6(e){return window.addEventListener(Jf,e),window.addEventListener("storage",e),()=>{window.removeEventListener(Jf,e),window.removeEventListener("storage",e)}}var zB=2e3,$B=6048e5;function F6(e){return e!=="working"&&e!=="input_required"}function V6(e,t){return Math.max(e,zB,t??0)}function HB(e,t){return e&&t?JSON.stringify(["owned-task-v1",e,t]):void 0}var hu,Qo;function WB(e){hu=e??void 0}function UB(){return hu}function qB(e,t){Qo=HB(e,t)}function Pm(){return Qo}function ms(e){return e.connectionId!==void 0||e.sourceExecutionId!==void 0}function Ca(e){return{...e,scope:e.scope??(ms(e)?Qo:hu)}}function f1(e){return ms(e)?Qo!==void 0&&e.scope===Qo:e.scope===hu}function Zf(e,t){const n=`${t?.scope??(t?.connectionId!==void 0?Pm():UB())??""}\0${e}`;return t?.wire!==void 0||t?.connectionId!==void 0?`${n}\0${t.wire??""}\0${t.connectionId??""}`:n}function Ds(e,t){return e.connectionId===t?.connectionId&&(t?.scope===void 0||e.scope===t.scope)&&(t?.wire===void 0||e.wire===t.wire)}var d1="mcp-tracked-tasks",p1="mcp-tracked-tasks-v4",Ll=4,KB=50,gs=1024,m1=100,GB=524288;function jt(e){return Xr(e)}function QB(e,t){const n=Date.parse(e.createdAt);return Number.isNaN(n)?!0:t-n<$B}function Wt(e){if(typeof e=="string")return e.length>gs?e.slice(0,gs):e}function Yt(e){if(typeof e=="string")return e.length>gs||e.includes("\0")?void 0:e}function qr(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function T0(e){if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e,n=Yt(t.taskId),r=Yt(t.serverId),i=Wt(t.createdAt);if(!n||!r)return;const s=Yt(t.connectionId),o=Yt(t.sourceExecutionId);if(t.connectionId!==void 0&&!s||t.sourceExecutionId!==void 0&&!o)return;const a=Yt(t.scope);if(t.scope!==void 0&&a===void 0||!i||Number.isNaN(Date.parse(i)))return;const l=t.wire==="extension"||t.wire==="legacy"?t.wire:"legacy",c=t.ttlMs===null?null:qr(t.ttlMs),u=Array.isArray(t.respondedInputKeys)?t.respondedInputKeys.filter(h=>typeof h=="string").slice(0,m1).map(h=>h.slice(0,gs)):void 0;return{taskId:n,serverId:r,wire:l,createdAt:i,...Wt(t.toolName)?{toolName:Wt(t.toolName)}:{},...t.primitiveType==="tool"||t.primitiveType==="prompt"||t.primitiveType==="resource"?{primitiveType:t.primitiveType}:{},...Wt(t.primitiveName)?{primitiveName:Wt(t.primitiveName)}:{},...t.dismissed===!0?{dismissed:!0}:{},...t.expired===!0?{expired:!0}:{},...a!==void 0?{scope:a}:{},...s!==void 0?{connectionId:s}:{},...o!==void 0?{sourceExecutionId:o}:{},...Wt(t.serverName)?{serverName:Wt(t.serverName)}:{},...Wt(t.lastUpdatedAt)?{lastUpdatedAt:Wt(t.lastUpdatedAt)}:{},...Wt(t.status)?{status:Wt(t.status)}:{},...c!==void 0?{ttlMs:c}:{},...qr(t.pollIntervalMs)!==void 0?{pollIntervalMs:qr(t.pollIntervalMs)}:{},...qr(t.nextPollAt)!==void 0?{nextPollAt:qr(t.nextPollAt)}:{},...qr(t.lastObservedAt)!==void 0?{lastObservedAt:qr(t.lastObservedAt)}:{},...u?.length?{respondedInputKeys:u}:{}}}function YB(e){if(Array.isArray(e))return e.map(T0).filter(n=>n!==void 0);if(typeof e!="object"||e===null)return[];const t=e;return typeof t.version=="number"&&t.version>Ll?[]:Array.isArray(t.tasks)?t.tasks.map(T0).filter(n=>n!==void 0):[]}function E0(e){try{const t=localStorage.getItem(e);return t?YB(JSON.parse(t)).filter(n=>QB(n,Date.now())):[]}catch{return[]}}function fu(){const e=E0(d1).filter(n=>!ms(n)),t=E0(p1);return[...new Map([...e,...t].map(n=>[jt(n),n])).values()]}function ln(){return fu().filter(f1)}function Aa(e){Im([...e,...fu().filter(t=>!f1(t))])}function Im(e){try{let t=e,n=JSON.stringify({version:Ll,tasks:t});for(;n.length>GB&&t.length>1;)t=t.slice(0,Math.floor(t.length/2)),n=JSON.stringify({version:Ll,tasks:t});localStorage.setItem(d1,JSON.stringify({version:3,tasks:t.filter(r=>!ms(r))})),localStorage.setItem(p1,JSON.stringify({version:Ll,tasks:t.filter(ms)})),VB()}catch{}}function z6(){return ln()}function $6(e,t,n,r){return ln().filter(i=>i.serverId===e&&!i.dismissed&&Ds(i,{wire:t,connectionId:n,scope:r}))}function H6(e,t,n){return ln().find(r=>r.taskId===e&&(t===void 0||r.serverId===t)&&Ds(r,n))}function W6(e){const t=Ca(e);if(ms(t)&&t.scope===void 0||Yt(t.taskId)===void 0||Yt(t.serverId)===void 0||t.scope!==void 0&&Yt(t.scope)===void 0||t.connectionId!==void 0&&!Yt(t.connectionId)||t.sourceExecutionId!==void 0&&!Yt(t.sourceExecutionId))return;const n=fu(),r=jt(t);if(n.some(o=>jt(o)===r))return;const i=o=>(o.scope??void 0)===(t.scope??void 0),s=n.filter(i);s.unshift({...t,dismissed:!1}),Im([...s.slice(0,KB),...n.filter(o=>!i(o))])}function XB(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 U6(e){if(e.length===0)return;const t=ln(),n=new Map(t.map(i=>[jt(i),i]));let r=!1;for(const{identity:i,observation:s}of e){const o=n.get(jt(Ca(i)));o&&(XB(o,s),r=!0)}r&&Aa(t)}function q6(e){const t=new Map;if(e.length===0)return t;const n=new Map;for(const r of e)n.set(jt(Ca(r)),jt(r));for(const r of ln()){const i=n.get(jt(r));i!==void 0&&t.set(i,{nextPollAt:r.nextPollAt,lastObservedAt:r.lastObservedAt,pollIntervalMs:r.pollIntervalMs,ttlMs:r.ttlMs,status:r.status,respondedInputKeys:r.respondedInputKeys??[]})}return t}function K6(e,t){if(t.length===0)return;const n=jt(Ca(e)),r=ln(),i=r.find(s=>jt(s)===n);i&&(i.respondedInputKeys=[...new Set([...i.respondedInputKeys??[],...t])].slice(0,m1).map(s=>s.slice(0,gs)),Aa(r))}function G6(e){const t=jt(Ca(e));return ln().find(n=>jt(n)===t)?.respondedInputKeys??[]}function Q6(e,t,n){const r=ln();for(const i of r)i.taskId===e&&(t===void 0||i.serverId===t)&&Ds(i,n)&&(i.expired=!0);Aa(r)}function Y6(e,t,n){const r=new Set(t),i=ln();for(const s of i)s.serverId===e&&r.has(s.taskId)&&Ds(s,n)&&(s.dismissed=!0);Aa(i)}var g1="mcp-dismissed-registry-tasks",JB=200;function Om(){try{const e=localStorage.getItem(g1);if(!e)return{};const t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))return{};const n={};for(const[r,i]of Object.entries(t))Array.isArray(i)&&(n[r]=i.filter(s=>typeof s=="string"&&s.length>0&&s.length<=gs).slice(0,JB));return n}catch{return{}}}function v1(e){try{localStorage.setItem(g1,JSON.stringify(e))}catch{}}function X6(e,t,n){if(n?.connectionId!==void 0&&n.scope===void 0&&Pm()===void 0)return;const r=t.filter(o=>Yt(o)!==void 0);if(r.length===0)return;const i=Om(),s=Zf(e,n);i[s]=[...new Set([...i[s]??[],...r])].slice(-200),v1(i)}function J6(e,t){if(t?.connectionId!==void 0&&t.scope===void 0&&Pm()===void 0)return new Set;const n=new Set(ln().filter(s=>s.serverId===e&&s.dismissed&&Ds(s,t)).map(s=>s.taskId)),r=Om(),i=[Zf(e,t)];t?.connectionId===void 0&&t?.scope===void 0&&i.push(Zf(e));for(const s of i)for(const o of r[s]??[])n.add(o);return n}function Z6(e,t){Aa(ln().filter(n=>n.serverId!==e||!Ds(n,t)))}function ZB(e){const t=e??void 0;Im(fu().filter(s=>(s.scope??void 0)!==t));const n=Om(),r=`${t??""}\0`;let i=!1;for(const s of Object.keys(n))s.startsWith(r)&&(delete n[s],i=!0);i&&v1(n)}var y1={projectId:null,serverIdsByName:{}},Z=y1,Gt=null,Or=0,ed=new Set,io=3e4,eF=3e3,tF=100,gh=null;function Dm(){Gt=null}var nF=1e4;async function rF(){if(Ki())return null;const e=Z.getAccessToken;if(!e)return null;const t=Or;Dm();let n;try{const r=await Promise.race([e({forceRefresh:!0}),new Promise(i=>{n=setTimeout(()=>i(null),nF)})]);return!r||t!==Or?null:(Gt={token:r,expiresAt:Date.now()+io,kind:"session"},r)}catch{return null}finally{clearTimeout(n)}}function x1(){Or+=1;for(const e of ed)e()}function e8(e){return ed.add(e),()=>{ed.delete(e)}}function t8(){return Or}var M0=null;function n8(e){const t=M0;if(t&&t.revision===Or&&t.serverNameOrId===e)return t.key;const n=Z.clientConfigSyncPending||!oF(e)?null:JSON.stringify([Ki(),uF(e)]);return M0={revision:Or,serverNameOrId:e,key:n},n}function iF(){throw new Error("Hosted API context is only available in hosted mode")}function Nm(){if(Z.clientConfigSyncPending)throw new Error(EB)}function sF(){return!Z.isAuthenticated&&!Z.hasSession}function Lm(){return!(Z.isAuthenticated||Z.hasSession)}function Ki(){return Lm()}function r8(e){const t=Z.projectId??void 0,n=e?.projectId??void 0;t&&n&&t!==n&&ZB(t),WB(n),qB(n,e?.taskOwnerId),Z=e?{...e,clientCapabilities:e.clientCapabilities??zc()}:y1,Dm(),x1()}function i8(e,t,n){Z.projectId===n&&Z.serverIdsByName[e]!==t&&(Z={...Z,serverIdsByName:{...Z.serverIdsByName,[e]:t}},x1())}function b1(){const e=Z.projectId;if(!e)throw new FB("provisioning-project","hosted projectId is not in the API context yet");return e}function oF(e){const t=Z.projectId;if(!t)return null;const n=Z.serverIdsByName[e];return n?{projectId:t,serverId:n}:Object.values(Z.serverIdsByName).includes(e)?{projectId:t,serverId:e}:null}function aF(e){const t=e.trim();return!(t.length<1||t.length>=20&&/^[a-z0-9]+$/i.test(t))}var lF="Hosted server not found. The server is not in your hosted project, or the server list is still loading.";function w1(e){const t=Z.serverIdsByName[e];if(t)return t;if(Object.values(Z.serverIdsByName).includes(e))return e;throw aF(e)?new Error(`Hosted server not found for "${e}"`):new Error(lF)}function Ta(e){return Object.entries(Z.serverIdsByName).find(([,t])=>t===e)?.[0]}function s8(e){return Ta(e)}function o8(e){}function a8(e){iF();const t=new Set,n=[];for(const r of e){if(typeof r!="string")continue;const i=r.trim();if(!i)continue;const s=Z.serverIdsByName[i]!==void 0?i:Ta(i)??i,o=s.toLowerCase();t.has(o)||(t.add(o),n.push(s))}return n}function cF(e){const t=new Set,n=[];for(const r of e){const i=w1(r);t.has(i)||(t.add(i),n.push({serverId:i,serverName:Z.serverIdsByName[r]!==void 0?r:Ta(i)??r}))}return n}function _m(){return Z.scenarioId}function S1(){return Z.accessVersion}function k1(){return _m()?"chat_v2":void 0}function jm(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 uF(e){Nm();const t=b1(),n=w1(e),r=_m(),i=S1(),s=k1();return{projectId:t,serverId:n,serverName:Z.serverIdsByName[e]!==void 0?e:Ta(n)??e,...Z.clientCapabilities?{clientCapabilities:Z.clientCapabilities}:{},...Z.clientInfo?{clientInfo:Z.clientInfo}:{},...Z.supportedProtocolVersions?.length?{supportedProtocolVersions:Z.supportedProtocolVersions}:{},...Z.mcpProtocolVersionsByServerId?.[n]?{mcpProtocolVersion:Z.mcpProtocolVersionsByServerId[n]}:{},...jm(Z),...Z.xaaPolicy?{xaaPolicy:Z.xaaPolicy}:{},...s?{accessScope:s}:{},...r?{scenarioId:r}:{},...r&&Number.isFinite(i)?{accessVersion:i}:{}}}function l8(e){Nm();const t=b1(),n=cF(e),r=n.map(c=>c.serverId),i=n.map(c=>c.serverName),s=C1(r),o=_m(),a=S1(),l=k1();return{projectId:t,serverIds:r,serverNames:i,...Z.clientCapabilities?{clientCapabilities:Z.clientCapabilities}:{},...Z.clientInfo?{clientInfo:Z.clientInfo}:{},...Z.supportedProtocolVersions?.length?{supportedProtocolVersions:Z.supportedProtocolVersions}:{},...s?{mcpProtocolVersionsByServerId:s}:{},...jm(Z),...Z.xaaPolicy?{xaaPolicy:Z.xaaPolicy}:{},...l?{accessScope:l}:{},...o?{scenarioId:o}:{},...o&&Number.isFinite(a)?{accessVersion:a}:{}}}function C1(e){const t=Z.mcpProtocolVersionsByServerId;if(!t)return;const n={};for(const r of e){const i=t[r];i&&(n[r]=i)}return Object.keys(n).length>0?n:void 0}function c8(e){Nm();const t=C1(e.serverIds);return{projectId:e.projectId,serverIds:e.serverIds,serverNames:e.serverNames,...Z.clientCapabilities?{clientCapabilities:Z.clientCapabilities}:{},...Z.clientInfo?{clientInfo:Z.clientInfo}:{},...Z.supportedProtocolVersions?.length?{supportedProtocolVersions:Z.supportedProtocolVersions}:{},...t?{mcpProtocolVersionsByServerId:t}:{},...jm(Z),...Z.xaaPolicy?{xaaPolicy:Z.xaaPolicy}:{},...e.accessScope?{accessScope:e.accessScope}:{},...e.scenarioId?{scenarioId:e.scenarioId}:{},...e.scenarioId&&Number.isFinite(e.accessVersion)?{accessVersion:e.accessVersion}:{}}}function hF(){return gh??=fF().finally(()=>{gh=null}),gh}async function fF(){const e=Date.now()+eF;for(;Date.now()<e;){if(await new Promise(n=>setTimeout(n,tF)),Lm())return null;const t=Z.getAccessToken;if(t)try{const n=await t();if(n)return n}catch{}}return null}async function A1(e=1){const t=Or,n=Ki(),r=()=>Or!==t||Ki()!==n,i=()=>e>0?A1(e-1):null,s=Date.now();if(Gt&&Gt.expiresAt>s)if(Gt.kind==="guest"&&!Ki())Gt=null;else return`Bearer ${Gt.token}`;if(Ki()){const l=await Mg();if(r())return i();if(l)return Gt={token:l,expiresAt:s+io,kind:"guest"},`Bearer ${l}`}const o=Z.getAccessToken;if(o)try{const l=await o();if(r())return i();if(l)return Gt={token:l,expiresAt:s+io,kind:"session"},`Bearer ${l}`}catch{}if(!Lm()){const l=await hF();return r()?i():l?(Gt={token:l,expiresAt:Date.now()+io,kind:"session"},`Bearer ${l}`):null}const a=await Mg();return r()?i():a?(Gt={token:a,expiresAt:s+io,kind:"guest"},`Bearer ${a}`):null}function dF(){const e=QE();if(e)return e;const t=JE()??"https://rt.mcpjam.com";return t&&typeof t=="string"?t.replace(".convex.cloud",".convex.site"):null}var pF=["billing_","credit_topup_","plan_limit_","plans_upgrade_confirm_","pricing_"];function mF(e){return pF.some(t=>e.startsWith(t))}function gF(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 td(e,t={}){const{location:n="unknown",platform:r,environment:i,...s}=t;try{const o=mF(e),a=o?s.organization_id:void 0,l=typeof a=="string"&&a.length>0?a:void 0,c=o?Object.fromEntries(Object.entries(s).filter(([u])=>!gF(u))):s;Zx.capture(e,{...c,...aM(n),...o?{organization_id:null,...l?{$groups:{organization:l}}:{}}:{}})}catch(o){console.warn(`[analytics] Failed to capture ${e}`,o)}}function u8(e,t,n=Rg()){const r=ZE();!n||Rg()!==n||r.policy.content!=="full"||e.capture("$set",{},{$set:r.policy.identity==="full"?t:{deployment:t.deployment}})}function vF(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 yF(e){if(e.status!==401)return!1;try{return typeof e.clone!="function"?!1:vF(await e.clone().json())}catch{return!1}}var Co=null,R0=!1,nd=!1;function T1(e){try{e()}catch{}}function xF(){R0||(R0=!0,Co?T1(Co):nd=!0)}function h8(e){return Co=e,nd&&(nd=!1,T1(e)),()=>{Co===e&&(Co=null)}}var vs=null,so=null,Bm=class extends Error{status;code;restarted;constructor(e,t,n=!1){super(`Failed to get session token: ${e}`),this.name="SessionTokenError",this.status=e,this.code=t,this.restarted=n}};function f8(e){return e instanceof Bm&&e.status===403}var P0={"/api/web/scenarios/bootstrap":"scenario"};function bF(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 P0[r.pathname]??null}catch{return P0[t]??null}}function wF(...e){const t={};for(const n of e)if(n){if(n instanceof Headers){n.forEach((r,i)=>{t[i]=r});continue}if(Array.isArray(n)){for(const[r,i]of n)t[r]=i;continue}Object.assign(t,n)}return t}function SF(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 Qa(e,t,n){const r=P1(e)?CF():void 0,i=n&&I1(e)?{Authorization:n}:void 0;return{...t,headers:wF(r,i,t?.headers)}}async function E1(e){const t=await fetch("/api/session-token",{headers:e?{"X-MCP-Session-Auth":`Bearer ${e}`}:{},cache:"no-store"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Bm(t.status,n.code,!!e)}if(!yM(e)||(await t.json()).ok!==!0)throw new Error("Invalid Inspector access response");return vs=e,cM(e),e}async function d8(){return vs||(so||(so=E1(Mp()).catch(e=>{throw so=null,e})),so)}async function kF(){vs=null,so=null;try{return await E1(Mp(!0))}catch(e){return e instanceof Bm&&e.code==="ACCESS_LINK_REQUIRED"&&window.dispatchEvent(new CustomEvent(nb,{detail:{restarted:e.restarted}})),null}}function du(){return vs||(Mp()??"")}function p8(){return!!du()}function CF(){const e=du();return e?{"X-MCP-Session-Auth":`Bearer ${e}`}:(console.warn("[Auth] Session token not available"),{})}function M1(e){return e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="[::1]"}function Fm(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 R1(e){return M1(e.hostname)?!0:typeof window<"u"&&e.origin===window.location.origin}function P1(e){const t=Fm(e);return t?R1(t)&&t.pathname.startsWith("/api/"):typeof e=="string"&&e.startsWith("/api/")}var AF=["/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 TF(e){if(typeof window<"u"&&e.origin===window.location.origin||M1(e.hostname))return!0;const t=dF();if(t)try{const n=new URL(t).hostname;if(e.hostname===n)return!0}catch{}return!1}var EF=[/^\/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 I0(e){return EF.some(t=>t.test(e))?!0:AF.some(t=>t.endsWith("/")?e.startsWith(t):e===t||e.startsWith(`${t}/`))}var MF=["/api/web/apps/plugin-instances/","/api/web/plugin-forms/"];function RF(e){const t=Fm(e),n=t?t.pathname:typeof e=="string"?e.split("?")[0]:"";return/^\/api\/(web|mcp)\/(chat-persistence|turn-authorization)\/?$/.test(n)||MF.some(r=>n.startsWith(r))}function PF(e){return e==null||typeof e=="string"||e instanceof FormData||e instanceof URLSearchParams||e instanceof Blob||e instanceof ArrayBuffer||ArrayBuffer.isView(e)}function I1(e){const t=Fm(e);if(t)return TF(t)?I0(t.pathname):!1;if(typeof e!="string"||!e.startsWith("/"))return!1;const n=e.split("?")[0];return I0(n)}function IF(e){const t=du();if(!t)return console.warn("[Auth] Session token not available for URL"),e;try{const n=new URL(e,window.location.origin);return R1(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 m8(e,t){const n=bF(e),r=SF(t?.headers),i=I1(e),s=i&&!r?await A1():null,o=Qa(e,t,s),a=await fetch(e,o);if(a.status===401&&i&&await yF(a))return xF(),a;if(a.status===401&&i&&!r&&RF(e)&&PF(t?.body)&&a.headers?.get("X-MCP-Auth-Required")!=="oauth"){const u=await rF();if(u)return t?.signal?.throwIfAborted(),fetch(e,Qa(e,t,`Bearer ${u}`))}if(a.status===401&&P1(e)&&a.headers?.get("X-MCPJam-Session")!=null){const u=du(),h=await kF();if(h&&h!==u){const f=Qa(e,t,s),d=await fetch(e,f);return d.status===401&&d.headers.get("X-MCPJam-Session")&&window.dispatchEvent(new CustomEvent(nb,{detail:{restarted:!0}})),d}}if(a.status!==401||!i||!sF()||r||a.headers?.get("X-MCP-Auth-Required")==="oauth")return a;Dm();const l=await nM();if(!l)return n&&td("guest_refresh_failure",{location:"auth_fetch",surface:n,auth_mode:"guest",status:"failure",error_kind:"guest_refresh_unavailable"}),a;n&&td("guest_refresh_success",{location:"auth_fetch",surface:n,auth_mode:"guest",status:"success"});const c=Qa(e,t,`Bearer ${l}`);return fetch(e,c)}var O0="1.46.0",Yo=Symbol.for("functionName"),OF=Symbol.for("toReferencePath");function DF(e){return e[OF]??null}function NF(e){return e.startsWith("function://")}function LF(e){let t;if(typeof e=="string")NF(e)?t={functionHandle:e}:t={name:e};else if(e[Yo])t={name:e[Yo]};else{const n=DF(e);if(!n)throw new Error(`${e} is not a functionReference`);t={reference:n}}return t}function pt(e){const t=LF(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[Yo];if(!n)throw new Error(`${e} is not a functionReference`);return n}function pu(e){return{[Yo]:e}}function O1(e=[]){return new Proxy({},{get(t,n){if(typeof n=="string")return O1([...e,n]);if(n===Yo){if(e.length<2){const s=["api",...e].join(".");throw new Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${s}\``)}const r=e.slice(0,-1).join("/"),i=e[e.length-1];return i==="default"?r:r+":"+i}else return n===Symbol.toStringTag?"FunctionReference":void 0}})}var g8=O1(),_F=Object.defineProperty,jF=(e,t,n)=>t in e?_F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,D0=(e,t,n)=>jF(e,typeof t!="symbol"?t+"":t,n),BF="color:rgb(0, 145, 255)";function D1(e){switch(e){case"query":return"Q";case"mutation":return"M";case"action":return"A";case"any":return"?"}}var N1=class{constructor(e){D0(this,"_onLogLineFuncs"),D0(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 L1(e){const t=new N1(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 _1(e){return new N1(e)}function bc(e,t,n,r,i){const s=D1(n);if(typeof i=="object"&&(i=`ConvexError ${JSON.stringify(i.errorData,null,2)}`),t==="info"){const o=i.match(/^\[.*?\] /);if(o===null){e.error(`[CONVEX ${s}(${r})] Could not parse console.log`);return}const a=i.slice(1,o[0].length-2),l=i.slice(o[0].length);e.log(`%c[CONVEX ${s}(${r})] [${a}]`,BF,l)}else e.error(`[CONVEX ${s}(${r})] ${i}`)}function FF(e,t){const n=`[CONVEX FATAL ERROR] ${t}`;return e.error(n),new Error(n)}function Gi(e,t,n){return`[CONVEX ${D1(e)}(${t})] ${n.errorMessage}
42
- Called by client`}function rd(e,t){return t.data=e.errorData,t}function yi(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 li(e,t){return JSON.stringify({udfPath:yi(e),args:In(t)})}function N0(e,t,n){const{initialNumItems:r,id:i}=n;return JSON.stringify({type:"paginated",udfPath:yi(e),args:In(t),options:In({initialNumItems:r,id:i})})}var VF=Object.defineProperty,zF=(e,t,n)=>t in e?VF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pn=(e,t,n)=>zF(e,typeof t!="symbol"?t+"":t,n),$F=class{constructor(){pn(this,"nextQueryId"),pn(this,"querySetVersion"),pn(this,"querySet"),pn(this,"queryIdToToken"),pn(this,"identityVersion"),pn(this,"auth"),pn(this,"outstandingQueriesOlderThanRestart"),pn(this,"outstandingAuthOlderThanRestart"),pn(this,"paused"),pn(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 i=yi(e),s=li(i,t),o=this.querySet.get(s);if(o!==void 0)return o.numSubscribers+=1,{queryToken:s,modification:null,unsubscribe:()=>this.removeSubscriber(s)};{const a=this.nextQueryId++,l={id:a,canonicalizedUdfPath:i,args:t,numSubscribers:1,journal:n,componentPath:r};this.querySet.set(s,l),this.queryIdToToken.set(a,s);const c=this.querySetVersion,u=this.querySetVersion+1,h={type:"Add",queryId:a,udfPath:i,args:[In(t)],journal:n,componentPath:r};return this.paused?this.pendingQuerySetModifications.set(a,h):this.querySetVersion=u,{queryToken:s,modification:{type:"ModifyQuerySet",baseVersion:c,newVersion:u,modifications:[h]},unsubscribe:()=>this.removeSubscriber(s)}}}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=yi(e),r=li(n,t),i=this.querySet.get(r);return i!==void 0?i.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 i={type:"Add",queryId:r.id,udfPath:r.canonicalizedUdfPath,args:[In(r.args)],journal:r.journal,componentPath:r.componentPath};e.push(i),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,i={type:"Remove",queryId:t.id};return this.paused?this.pendingQuerySetModifications.has(t.id)?this.pendingQuerySetModifications.delete(t.id):this.pendingQuerySetModifications.set(t.id,i):this.querySetVersion=r,{type:"ModifyQuerySet",baseVersion:n,newVersion:r,modifications:[i]}}}},HF=Object.defineProperty,WF=(e,t,n)=>t in e?HF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ya=(e,t,n)=>WF(e,typeof t!="symbol"?t+"":t,n),UF=class{constructor(e,t){this.logger=e,this.markConnectionStateDirty=t,Ya(this,"inflightRequests"),Ya(this,"requestsOlderThanRestart"),Ya(this,"inflightMutationsCount",0),Ya(this,"inflightActionsCount",0),this.inflightRequests=new Map,this.requestsOlderThanRestart=new Set}request(e,t){const n=new Promise(r=>{const i=t?"Requested":"NotSent";this.inflightRequests.set(e.requestId,{message:e,status:{status:i,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)bc(this.logger,"info",n,r,a);const i=t.status;let s,o;if(e.success)s={success:!0,logLines:e.logLines,value:sc(e.result)},o=()=>i.onResult(s);else{const a=e.result,{errorData:l}=e;bc(this.logger,"error",n,r,a),s={success:!1,errorMessage:a,errorData:l!==void 0?sc(l):void 0,logLines:e.logLines},o=()=>i.onResult(s)}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:s}):(t.status={status:"Completed",result:s,ts:e.ts,onResolve:o},null)}removeCompleted(e){const t=new Map;for(const[n,r]of this.inflightRequests.entries()){const i=r.status;i.status==="Completed"&&i.ts.lessThanOrEqual(e)&&(i.onResolve(),t.set(n,i.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}},qF=Object.defineProperty,KF=(e,t,n)=>t in e?qF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wc=(e,t,n)=>KF(e,typeof t!="symbol"?t+"":t,n),L0=class id{constructor(t){wc(this,"queryResults"),wc(this,"modifiedQueries"),this.queryResults=t,this.modifiedQueries=[]}getQuery(t,...n){const r=Wn(n[0]),i=pt(t),s=this.queryResults.get(li(i,r));if(s!==void 0)return id.queryValue(s.result)}getAllQueries(t){const n=[],r=pt(t);for(const i of this.queryResults.values())i.udfPath===yi(r)&&n.push({args:i.args,value:id.queryValue(i.result)});return n}setQuery(t,n,r){const i=Wn(n),s=pt(t),o=li(s,i);let a;r===void 0?a=void 0:a={success:!0,value:r,logLines:[]};const l={udfPath:s,args:i,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}},GF=class{constructor(){wc(this,"queryResults"),wc(this,"optimisticUpdates"),this.queryResults=new Map,this.optimisticUpdates=[]}ingestQueryResultsFromServer(e,t){this.optimisticUpdates=this.optimisticUpdates.filter(s=>!t.has(s.mutationId));const n=this.queryResults;this.queryResults=new Map(e);const r=new L0(this.queryResults);for(const s of this.optimisticUpdates)s.update(r);const i=[];for(const[s,o]of this.queryResults){const a=n.get(s);(a===void 0||a.result!==o.result)&&i.push(s)}return i}applyOptimisticUpdate(e,t){this.optimisticUpdates.push({update:e,mutationId:t});const n=new L0(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?rd(n,new cf(Gi("query",t.udfPath,n))):new Error(Gi("query",t.udfPath,n))}}hasQueryResult(e){return this.queryResults.get(e)!==void 0}queryLogs(e){return this.queryResults.get(e)?.result?.logLines}},QF=Object.defineProperty,YF=(e,t,n)=>t in e?QF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vh=(e,t,n)=>YF(e,typeof t!="symbol"?t+"":t,n),Ea=class zn{constructor(t,n){vh(this,"low"),vh(this,"high"),vh(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 zn(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?_0:t>=XF?JF:new zn(t%Ao|0,t/Ao|0)}toString(){return(BigInt(this.high)*BigInt(Ao)+BigInt(this.low)).toString()}equals(t){return zn.isLong(t)||(t=zn.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 zn.isLong(t)||(t=zn.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"?zn.fromNumber(t):new zn(t.low,t.high)}},_0=new Ea(0,0),j0=65536,Ao=j0*j0,XF=Ao*Ao,JF=new Ea(-1,-1),ZF=Object.defineProperty,eV=(e,t,n)=>t in e?ZF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xa=(e,t,n)=>eV(e,typeof t!="symbol"?t+"":t,n),B0=class{constructor(e,t){Xa(this,"version"),Xa(this,"remoteQuerySet"),Xa(this,"queryPath"),Xa(this,"logger"),this.version={querySet:0,ts:Ea.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 s of n.logLines)bc(this.logger,"info","query",r,s);const i=sc(n.value??null);this.remoteQuerySet.set(n.queryId,{success:!0,value:i,logLines:n.logLines});break}case"QueryFailed":{const r=this.queryPath(n.queryId);if(r)for(const s of n.logLines)bc(this.logger,"info","query",r,s);const{errorData:i}=n;this.remoteQuerySet.set(n.queryId,{success:!1,errorMessage:n.errorMessage,errorData:i!==void 0?sc(i):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 yh(e){const t=YE(e);return Ea.fromBytesLE(Array.from(t))}function tV(e){const t=new Uint8Array(e.toBytesLE());return sM(t)}function F0(e){switch(e.type){case"FatalError":case"AuthError":case"ActionResponse":case"TransitionChunk":case"Ping":return{...e};case"MutationResponse":return e.success?{...e,ts:yh(e.ts)}:{...e};case"Transition":return{...e,startVersion:{...e.startVersion,ts:yh(e.startVersion.ts)},endVersion:{...e.endVersion,ts:yh(e.endVersion.ts)}}}}function nV(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:tV(e.maxObservedTimestamp)}:{...e,maxObservedTimestamp:void 0}}}var rV=Object.defineProperty,iV=(e,t,n)=>t in e?rV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Be=(e,t,n)=>iV(e,typeof t!="symbol"?t+"":t,n),sV=1e3,oV=1001,aV=1005,lV=4040,_l;function Vi(){return _l===void 0&&(_l=Date.now()),typeof performance>"u"||!performance.now?Date.now():Math.round(_l+performance.now())}function V0(){return`t=${Math.round((Vi()-_l)/100)/10}s`}var j1={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 cV(e){if(e===void 0)return"Unknown";for(const t of Object.keys(j1))if(e.startsWith(t))return t;return"Unknown"}var uV=class{constructor(e,t,n,r,i,s){this.markConnectionStateDirty=i,this.debug=s,Be(this,"socket"),Be(this,"connectionCount"),Be(this,"_hasEverConnected",!1),Be(this,"lastCloseReason"),Be(this,"transitionChunkBuffer",null),Be(this,"defaultInitialBackoff"),Be(this,"maxBackoff"),Be(this,"retries"),Be(this,"serverInactivityThreshold"),Be(this,"reconnectDueToServerInactivityTimeout"),Be(this,"scheduledReconnect",null),Be(this,"networkOnlineHandler",null),Be(this,"pendingNetworkRecoveryInfo",null),Be(this,"uri"),Be(this,"onOpen"),Be(this,"onResume"),Be(this,"onMessage"),Be(this,"webSocketConstructor"),Be(this,"logger"),Be(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=F0(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:Vi()})),this.lastCloseReason!=="InitialConnect"&&(this.lastCloseReason?this.logger.log("WebSocket reconnected at",V0(),"after disconnect due to",this.lastCloseReason):this.logger.log("WebSocket reconnected at",V0())),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=F0(JSON.parse(t.data));if(this._logVerbose(`received ws message with type ${r.type}`),r.type!=="Ping"){if(r.type==="TransitionChunk"){const i=this.assembleTransition(r);if(!i)return;r=i,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!==sV&&t.code!==oV&&t.code!==aV&&t.code!==lV){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=cV(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=nV(e),r=JSON.stringify(n);let i=!1;try{this.socket.ws.send(r),i=!0}catch(s){this.logger.log(`Failed to send message on WebSocket, reconnecting: ${s}`),this.closeAndReconnect("FailedToSendMessage")}return this._logVerbose(`${i?"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=Vi(),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=Vi()-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:Vi()})):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:j1[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=Vi()-e.clientClockSkew-e.serverTs/1e6,r=`${Math.round(n)}ms`,i=`${Math.round(t/1e4)/100}MB`,s=t/(n/1e3),o=`${Math.round(s/1e4)/100}MB per second`;this._logVerbose(`received ${i} transition in ${r} at ${o}`),t>2e7?this.logger.log(`received query results totaling more that 20MB (${i}) which will take a long time to download on slower connections`):n>2e4&&this.logger.log(`received query results totaling ${i} which took more than 20s to arrive (${r})`),this.debug&&this.sendMessage({type:"Event",eventType:"ClientReceivedTransition",event:{transitionTransitTime:n,messageLength:t}})}};function hV(){return fV()}function fV(){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 oo=class extends Error{};oo.prototype.name="InvalidTokenError";function dV(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 pV(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 dV(t)}catch{return atob(t)}}function B1(e,t){if(typeof e!="string")throw new oo("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 oo(`Invalid token specified: missing part #${n+1}`);let i;try{i=pV(r)}catch(s){throw new oo(`Invalid token specified: invalid base64 for part #${n+1} (${s.message})`)}try{return JSON.parse(i)}catch(s){throw new oo(`Invalid token specified: invalid json for part #${n+1} (${s.message})`)}}var mV=Object.defineProperty,gV=(e,t,n)=>t in e?mV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vt=(e,t,n)=>gV(e,typeof t!="symbol"?t+"":t,n),vV=1728e6,z0=2,yV=class{constructor(e,t,n){vt(this,"authState",{state:"noAuth"}),vt(this,"configVersion",0),vt(this,"syncState"),vt(this,"authenticate"),vt(this,"stopSocket"),vt(this,"tryRestartSocket"),vt(this,"pauseSocket"),vt(this,"resumeSocket"),vt(this,"clearAuth"),vt(this,"logger"),vt(this,"refreshTokenLeewaySeconds"),vt(this,"initialAuthTokenReuse"),vt(this,"lastRefreshChange"),vt(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 i={fetchToken:e,onAuthChange:t,onRefreshChange:n};r.value?(this.setAuthState({state:"waitingForServerConfirmationOfCachedToken",config:i,hasRetried:!1}),this.authenticate(r.value)):(this.setAuthState({state:"initialRefetch",config:i}),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>=z0){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, ${z0-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:i}=n;if(!r||!i){this.logger.error("Auth token does not have required fields, cannot refetch the token");return}const s=i-r;if(s<=2){this.logger.error("Auth token does not live long enough, cannot refetch the token");return}let o;t!==void 0?(o=i-(Date.now()-t)/1e3,o<=0&&(o=0)):o=s;let a=Math.min(vV,(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 B1(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}]`)}},xV=["convexClientConstructed","convexWebSocketOpen","convexFirstMessageReceived"];function bV(e,t){const n={sessionId:t};typeof performance>"u"||!performance.mark||performance.mark(e,{detail:n})}function wV(e){let t=e.name.slice(6);return t=t.charAt(0).toLowerCase()+t.slice(1),{name:t,startTime:e.startTime}}function SV(e){if(typeof performance>"u"||!performance.getEntriesByName)return[];const t=[];for(const n of xV){const r=performance.getEntriesByName(n).filter(i=>i.entryType==="mark").filter(i=>i.detail.sessionId===e);t.push(...r)}return t.map(wV)}var kV=Object.defineProperty,CV=(e,t,n)=>t in e?kV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fe=(e,t,n)=>CV(e,typeof t!="symbol"?t+"":t,n),AV=class{constructor(e,t,n){if(Fe(this,"address"),Fe(this,"state"),Fe(this,"requestManager"),Fe(this,"webSocketManager"),Fe(this,"authenticationManager"),Fe(this,"remoteQuerySet"),Fe(this,"optimisticQueryResults"),Fe(this,"_transitionHandlerCounter",0),Fe(this,"_nextRequestId"),Fe(this,"_onTransitionFns",new Map),Fe(this,"_sessionId"),Fe(this,"firstMessageReceived",!1),Fe(this,"debug"),Fe(this,"logger"),Fe(this,"maxObservedTimestamp"),Fe(this,"connectionStateSubscribers",new Map),Fe(this,"nextConnectionStateSubscriberId",0),Fe(this,"_lastPublishedConnectionState"),Fe(this,"markConnectionStateDirty",()=>{Promise.resolve().then(()=>{const f=this.connectionState();if(JSON.stringify(f)!==JSON.stringify(this._lastPublishedConnectionState)){this._lastPublishedConnectionState=f;for(const d of this.connectionStateSubscribers.values())d(f)}})}),Fe(this,"mark",f=>{this.debug&&bV(f,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&&XE(e),n={...n};const r=n.authRefreshTokenLeewaySeconds??10;let i=n.webSocketConstructor;if(!i&&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");i=i||WebSocket,this.debug=n.reportDebugInfoToConvex??!1,this.address=e,this.logger=n.logger===!1?_1({verbose:n.verbose??!1}):n.logger!==!0&&n.logger?n.logger:L1({verbose:n.verbose??!1});const s=e.search("://");if(s===-1)throw new Error("Provided address was not an absolute URL.");const o=e.substring(s+3),a=e.substring(0,s);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/${O0}/sync`;this.state=new $F,this.remoteQuerySet=new B0(f=>this.state.queryPath(f),this.logger),this.requestManager=new UF(this.logger,this.markConnectionStateDirty);const u=()=>{this.webSocketManager.pause(),this.state.pause()};this.authenticationManager=new yV(this.state,{authenticate:f=>{const d=this.state.setAuth(f);return this.webSocketManager.sendMessage(d),d.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 GF,this.addOnTransitionHandler(f=>{t(f.queries.map(d=>d.token))}),this._nextRequestId=0,this._sessionId=hV();const{unsavedChangesWarning:h}=n;if(typeof window>"u"||typeof window.addEventListener>"u"){if(h===!0)throw new Error("unsavedChangesWarning requested, but window.addEventListener not found! Remove {unsavedChangesWarning: true} from Convex client options.")}else h!==!1&&window.addEventListener("beforeunload",f=>{if(this.requestManager.hasIncompleteRequests()){f.preventDefault();const d="Are you sure you want to leave? Your changes may not be saved.";return(f||window.event).returnValue=d,d}});this.webSocketManager=new uV(c,{onOpen:f=>{this.mark("convexWebSocketOpen"),this.webSocketManager.sendMessage({...f,type:"Connect",sessionId:this._sessionId,maxObservedTimestamp:this.maxObservedTimestamp}),this.remoteQuerySet=new B0(v=>this.state.queryPath(v),this.logger);const[d,m]=this.state.restart();m&&this.webSocketManager.sendMessage(m),this.webSocketManager.sendMessage(d);for(const v of this.requestManager.restart())this.webSocketManager.sendMessage(v)},onResume:()=>{const[f,d]=this.state.resume();d&&this.webSocketManager.sendMessage(d),f&&this.webSocketManager.sendMessage(f);for(const m of this.requestManager.resume())this.webSocketManager.sendMessage(m)},onMessage:f=>{switch(this.firstMessageReceived||(this.firstMessageReceived=!0,this.mark("convexFirstMessageReceived"),this.reportMarks()),f.type){case"Transition":{this.observedTimestamp(f.endVersion.ts),this.authenticationManager.onTransition(f),this.remoteQuerySet.transition(f),this.state.transition(f);const d=this.requestManager.removeCompleted(this.remoteQuerySet.timestamp());this.notifyOnQueryResultChanges(d);break}case"MutationResponse":{f.success&&this.observedTimestamp(f.ts);const d=this.requestManager.onResponse(f);d!==null&&this.notifyOnQueryResultChanges(new Map([[d.requestId,d.result]]));break}case"ActionResponse":this.requestManager.onResponse(f);break;case"AuthError":this.authenticationManager.onAuthError(f);break;case"FatalError":{const d=FF(this.logger,f.error);throw this.webSocketManager.terminate(),d}}return{hasSyncedPastLastReconnect:this.hasSyncedPastLastReconnect()}},onServerDisconnectError:n.onServerDisconnectError},i,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[i,s]of t){const o=this.state.queryToken(i);if(o!==null){const a={result:s,udfPath:this.state.queryPath(i),args:this.state.queryArgs(i)};n.set(o,a)}}const r=this.optimisticQueryResults.ingestQueryResultsFromServer(n,new Set(e.keys()));this.handleTransition({queries:r.map(i=>({token:i,modification:{kind:"Updated",result:this.optimisticQueryResults.rawQueryResult(i)}})),reflectedMutations:Array.from(e).map(([i,s])=>({requestId:i,result:s})),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?B1(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=Wn(t),{modification:i,queryToken:s,unsubscribe:o}=this.state.subscribe(e,r,n?.journal,n?.componentPath);return i!==null&&this.webSocketManager.sendMessage(i),{queryToken:s,unsubscribe:()=>{const a=o();a&&this.webSocketManager.sendMessage(a)}}}localQueryResult(e,t){const n=Wn(t),r=li(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=Wn(t),r=li(e,n);return this.optimisticQueryResults.queryLogs(r)}queryJournal(e,t){const n=Wn(t),r=li(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?rd(r,new cf(Gi("mutation",e,r))):new Error(Gi("mutation",e,r));return r.value}async mutationInternal(e,t,n,r){const{mutationPromise:i}=this.enqueueMutation(e,t,n,r);return i}enqueueMutation(e,t,n,r){const i=Wn(t);this.tryReportLongDisconnect();const s=this.nextRequestId;if(this._nextRequestId++,n!==void 0){const l=n.optimisticUpdate;if(l!==void 0){const c=h=>{l(h,i)instanceof Promise&&this.logger.warn("Optimistic update handler returned a Promise. Optimistic updates should be synchronous.")},u=this.optimisticQueryResults.applyOptimisticUpdate(c,s).map(h=>{const f=this.localQueryResultByToken(h);return{token:h,modification:{kind:"Updated",result:f===void 0?void 0:{success:!0,value:f,logLines:[]}}}});this.handleTransition({queries:u,reflectedMutations:[],timestamp:this.remoteQuerySet.timestamp()})}}const o={type:"Mutation",requestId:s,udfPath:e,componentPath:r,args:[In(i)]},a=this.webSocketManager.sendMessage(o);return{requestId:s,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?rd(n,new cf(Gi("action",e,n))):new Error(Gi("action",e,n));return n.value}async actionInternal(e,t,n){const r=Wn(t),i=this.nextRequestId;this._nextRequestId++,this.tryReportLongDisconnect();const s={type:"Action",requestId:i,udfPath:e,componentPath:n,args:[In(r)]},o=this.webSocketManager.sendMessage(s);return this.requestManager.request(s,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=SV(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-${O0}`},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 xh(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 TV=Object.defineProperty,EV=(e,t,n)=>t in e?TV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$0=(e,t,n)=>EV(e,typeof t!="symbol"?t+"":t,n),MV=class{constructor(e,t){this.client=e,this.onTransition=t,$0(this,"paginatedQuerySet",new Map),$0(this,"lastTransitionTs"),this.lastTransitionTs=Ea.fromNumber(0),this.client.addOnTransitionHandler(n=>this.onBaseTransition(n))}subscribe(e,t,n){const r=yi(e),i=N0(r,t,n),s=()=>this.removePaginatedQuerySubscriber(i),o=this.paginatedQuerySet.get(i);return o?(o.numSubscribers+=1,{paginatedQueryToken:i,unsubscribe:s}):(this.paginatedQuerySet.set(i,{token:i,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(i,null,n.initialNumItems),{paginatedQueryToken:i,unsubscribe:s})}localQueryResult(e,t,n){const r=yi(e),i=N0(r,t,n);return this.localQueryResultByToken(i)}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=[],i=!1,s=!1;for(const a of n){const l=this.client.localQueryResultByToken(a);if(l===void 0){i=!0,s=!1;continue}const c=xh(l);r=r.concat(c.page),s=!!c.isDone}let o;return i?o=r.length===0?"LoadingFirstPage":"LoadingMore":s?o="Exhausted":o="CanLoadMore",{results:r,status:o,loadMore:a=>this.loadMoreOfPaginatedQuery(e,a)}}onBaseTransition(e){const t=e.queries.map(s=>s.token),n=this.queriesContainingTokens(t);let r=[];n.length>0&&(this.processPaginatedQuerySplits(n,s=>this.client.localQueryResultByToken(s)),r=n.map(s=>({token:s,modification:{kind:"Updated",result:this.localQueryResultByToken(s)}})));const i={...e,paginatedQueries:r};this.onTransition(i)}loadMoreOfPaginatedQuery(e,t){this.mustGetPaginatedQuery(e);const n=this.queryTokenForLastPageOfPaginatedQuery(e),r=this.client.localQueryResultByToken(n);if(!r)return!1;const i=xh(r);if(i.isDone)return!1;this.addPageToPaginatedQuery(e,i.continueCursor,t);const s={timestamp:this.lastTransitionTs,reflectedMutations:[],queries:[],paginatedQueries:[{token:e,modification:{kind:"Updated",result:this.localQueryResultByToken(e)}}]};return this.onTransition(s),!0}queriesContainingTokens(e){if(e.length===0)return[];const t=[],n=new Set(e);for(const[r,i]of this.paginatedQuerySet)for(const s of this.allQueryTokens(i))if(n.has(s)){t.push(r);break}return t}processPaginatedQuerySplits(e,t){for(const n of e){const r=this.mustGetPaginatedQuery(n),{ongoingSplits:i,pageKeyToQuery:s,pageKeys:o}=r;for(const[a,[l,c]]of i)t(s.get(l).queryToken)!==void 0&&t(s.get(c).queryToken)!==void 0&&this.completePaginatedQuerySplit(r,a,l,c);for(const a of o){if(i.has(a))continue;const l=s.get(a);if(!l)throw new Error(`No page query for active pageKey ${a}`);const c=t(l.queryToken);if(!c)continue;const u=xh(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,i){const s=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(s,{...l,cursor:n});const c=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...a,cursor:r,endCursor:i}});e.pageKeyToQuery.set(o,{...c,cursor:r}),e.ongoingSplits.set(t,[s,o])}addPageToPaginatedQuery(e,t,n){const r=this.mustGetPaginatedQuery(e),i=r.nextPageKey++,s={cursor:t,numItems:n,id:r.id},o={...r.args,paginationOpts:s},a=this.client.subscribe(r.canonicalizedUdfPath,o);return r.pageKeys.push(i),r.pageKeyToQuery.set(i,{...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 i=e.pageKeyToQuery.get(t);e.pageKeyToQuery.delete(t);const s=e.pageKeys.indexOf(t);e.pageKeys.splice(s,1,n,r),e.ongoingSplits.delete(t),i.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 RV({getCurrentValue:e,subscribe:t}){const[n,r]=(0,g.useState)(()=>({getCurrentValue:e,subscribe:t,value:e()}));let i=n.value;return(n.getCurrentValue!==e||n.subscribe!==t)&&(i=e(),r({getCurrentValue:e,subscribe:t,value:i})),(0,g.useEffect)(()=>{let s=!1;const o=()=>{s||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(),()=>{s=!0,a()}},[e,t]),i}var PV=Object.defineProperty,IV=(e,t,n)=>t in e?PV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bn=(e,t,n)=>IV(e,typeof t!="symbol"?t+"":t,n),OV=5e3;if(typeof g.default>"u")throw new Error("Required dependency 'react' not found");function F1(e,t,n){function r(i){return LV(i),t.mutation(e,i,{optimisticUpdate:n})}return r.withOptimisticUpdate=function(s){if(n!==void 0)throw new Error(`Already specified optimistic update for mutation ${pt(e)}`);return F1(e,t,s)},r}function DV(e,t){return function(n){return t.action(e,n)}}var v8=class{constructor(e,t){if(Bn(this,"address"),Bn(this,"cachedSync"),Bn(this,"cachedPaginatedQueryClient"),Bn(this,"listeners"),Bn(this,"options"),Bn(this,"closed",!1),Bn(this,"_logger"),Bn(this,"adminAuth"),Bn(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?_1({verbose:t?.verbose??!1}):t?.logger!==!0&&t?.logger?t.logger:L1({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 AV(this.address,()=>{},this.options),this.adminAuth&&this.cachedSync.setAdminAuth(this.adminAuth,this.fakeUserIdentity),this.cachedPaginatedQueryClient=new MV(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,i=pt(e);return{onUpdate:s=>{const{queryToken:o,unsubscribe:a}=this.sync.subscribe(i,n,r),l=this.listeners.get(o);return l!==void 0?l.add(s):this.listeners.set(o,new Set([s])),()=>{if(this.closed)return;const c=this.listeners.get(o);c.delete(s),c.size===0&&this.listeners.delete(o),a()}},localQueryResult:()=>{if(this.cachedSync)return this.cachedSync.localQueryResult(i,n)},localQueryLogs:()=>{if(this.cachedSync)return this.cachedSync.localQueryLogs(i,n)},journal:()=>{if(this.cachedSync)return this.cachedSync.queryJournal(i,n)}}}prewarmQuery(e){const t=e.extendSubscriptionFor??OV,n=this.watchQuery(e.query,e.args||{}).onUpdate(()=>{});setTimeout(n,t)}watchPaginatedQuery(e,t,n){const r=pt(e);return{onUpdate:i=>{const{paginatedQueryToken:s,unsubscribe:o}=this.paginatedQueryClient.subscribe(r,t||{},n),a=this.listeners.get(s);return a!==void 0?a.add(i):this.listeners.set(s,new Set([i])),()=>{if(this.closed)return;const l=this.listeners.get(s);l.delete(i),l.size===0&&this.listeners.delete(s),o()}},localQueryResult:()=>this.paginatedQueryClient.localQueryResult(r,t,n)}}mutation(e,...t){const[n,r]=t,i=pt(e);return this.sync.mutation(i,n,r)}action(e,...t){const n=pt(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((i,s)=>{const o=n.onUpdate(()=>{o();try{i(n.localQueryResult())}catch(a){s(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()}}},mu=g.createContext(void 0);function NV(){return(0,g.useContext)(mu)}var y8=({client:e,children:t})=>g.createElement(mu.Provider,{value:e},t);function V1(e,...t){const n=t[0]==="skip",r=t[0]==="skip"?{}:Wn(t[0]),i=typeof e=="string"?pu(e):e,s=pt(i),o=(0,g.useMemo)(()=>n?{}:{query:{query:i,args:r}},[JSON.stringify(In(r)),s,n]),a=FV(o).query;if(a instanceof Error)throw a;return a}function x8(e){const t=typeof e=="string"?pu(e):e,n=(0,g.useContext)(mu);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,g.useMemo)(()=>F1(t,n),[n,pt(t)])}function b8(e){const t=(0,g.useContext)(mu),n=typeof e=="string"?pu(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,g.useMemo)(()=>DV(n,t),[t,pt(n)])}function LV(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 _V=Object.defineProperty,jV=(e,t,n)=>t in e?_V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bh=(e,t,n)=>jV(e,typeof t!="symbol"?t+"":t,n),BV=class{constructor(e){bh(this,"createWatch"),bh(this,"queries"),bh(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:i}=e[t];if(pt(n),this.queries[t]===void 0)this.addQuery(t,n,r,i?{paginationOptions:i}:{});else{const s=this.queries[t];(pt(n)!==pt(s.query)||JSON.stringify(In(r))!==JSON.stringify(In(s.args))||JSON.stringify(i)!==JSON.stringify(s.paginationOptions))&&(this.removeQuery(t),this.addQuery(t,n,r,i?{paginationOptions:i}:{}))}}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:i}=e[n],s=e[n].paginationOptions;pt(r);const o=this.createWatch(r,i,s?{paginationOptions:s}:{});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:i,paginationOptions:s}=this.queries[t],o="journal"in i?i.journal():void 0;this.removeQuery(t),this.addQuery(t,n,r,{...o?{journal:o}:[],...s?{paginationOptions:s}:{}})}}destroy(){for(const e of Object.keys(this.queries))this.removeQuery(e);this.listeners=new Set}addQuery(e,t,n,{paginationOptions:r,journal:i}){if(this.queries[e]!==void 0)throw new Error(`Tried to add a new query with identifier ${e} when it already exists.`);const s=this.createWatch(t,n,{...i?{journal:i}:[],...r?{paginationOptions:r}:{}}),o=s.onUpdate(()=>this.notifyListeners());this.queries[e]={query:t,args:n,watch:s,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 FV(e){const t=NV();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 VV(e,(0,g.useMemo)(()=>(n,r,{journal:i,paginationOptions:s})=>s?t.watchPaginatedQuery(n,r,s):t.watchQuery(n,r,i?{journal:i}:{}),[t]))}function VV(e,t){const[n]=(0,g.useState)(()=>new BV(t));n.createWatch!==t&&n.setCreateWatch(t),(0,g.useEffect)(()=>()=>n.destroy(),[n]);const r=(0,g.useMemo)(()=>({getCurrentValue:()=>n.getLocalResults(e),subscribe:i=>(n.setQueries(e),n.subscribe(i))}),[n,e]);return RV(r)}var Sc=class extends g.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),oM(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,p.jsx)("div",{className:"flex items-center justify-center min-h-[400px] p-6",children:(0,p.jsxs)("div",{className:"text-center max-w-md",children:[(0,p.jsx)(nu,{className:"h-12 w-12 text-destructive mx-auto mb-4"}),(0,p.jsx)("h2",{className:"text-xl font-semibold mb-2",children:"Something went wrong"}),(0,p.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:this.state.error?.message||"An unexpected error occurred"}),(0,p.jsx)(Ot,{onClick:this.handleReset,variant:"outline",children:"Try again"})]})}):this.props.children}},zV=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(r[s]=i[s])},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 $V=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 Ja,H0="__POSTHOG_REACT_SHARED_STATE__",W0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Xo;try{Xo=W0[H0]=W0[H0]||new WeakMap}catch{Xo=new WeakMap}Xo.has(g.createContext)||Xo.set(g.createContext,{});var ci=Xo.get(g.createContext),sd;function HV(e){(!ci.defaultPostHogInstance||ci.defaultPostHogInstance===sd)&&(ci.defaultPostHogInstance=e),sd=e}function od(){return sd}ci.context||(ci.context=(0,g.createContext)({get client(){return od()||ci.defaultPostHogInstance},bootstrap:void 0}));var Ns=ci.context;function z1(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),i=Object.keys(t);if(r.length!==i.length)return!1;for(var s=0,o=r;s<o.length;s++){var a=o[s];if(!i.includes(a)||!z1(e[a],t[a],n))return!1}return!0}function w8(e){var t,n,r=e.children,i=e.client,s=e.apiKey,o=e.options,a=(0,g.useRef)(null),l=(0,g.useMemo)(function(){if(i)return s&&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`."),i;var c=od();return s||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},[i,s,JSON.stringify(o)]);return(0,g.useEffect)(function(){if(!(i||!s)){var c=od(),u=a.current;u?(s!==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&&!z1(o,u.options)&&c.set_config(o),a.current={apiKey:s,options:o??{}}):(c.__loaded&&console.warn("[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues."),c.init(s,o),a.current={apiKey:s,options:o??{}})}},[i,s,JSON.stringify(o)]),g.createElement(Ns.Provider,{value:{client:l,bootstrap:(t=o?.bootstrap)!==null&&t!==void 0?t:(n=i?.config)===null||n===void 0?void 0:n.bootstrap}},r)}var wh=function(e){return typeof e=="function"},ad=function(e){return e===void 0};function $1(e,t){var n,r,i=(0,g.useContext)(Ns),s=i.client,o=i.bootstrap,a=(0,g.useState)(function(){return s.isFeatureEnabled(e)}),l=a[0],c=a[1];(0,g.useEffect)(function(){return s.onFeatureFlags(function(){c(s.isFeatureEnabled(e))})},[s,e]);var u=(n=o?.featureFlags)===null||n===void 0?void 0:n[e];return!(!((r=s?.featureFlags)===null||r===void 0)&&r.hasLoadedFlags)&&o?.featureFlags?ad(u)?t:!!u:ad(l)?t:l}function S8(){var e,t=(0,g.useContext)(Ns),n=t.client,r=t.bootstrap,i=(0,g.useState)(function(){return n.featureFlags.getFlags()}),s=i[0],o=i[1];return(0,g.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]}):s}function k8(e){var t,n=(0,g.useContext)(Ns),r=n.client,i=n.bootstrap,s=(0,g.useState)(function(){return r.getFeatureFlag(e)}),o=s[0],a=s[1];return(0,g.useEffect)(function(){return r.onFeatureFlags(function(){a(r.getFeatureFlag(e))})},[r,e]),!(!((t=r?.featureFlags)===null||t===void 0)&&t.hasLoadedFlags)&&i?.featureFlags?i.featureFlags[e]:o}var C8=function(){return(0,g.useContext)(Ns).client},jl=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]"},WV=function(e,t){try{Object.defineProperty(e,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch{}},UV=function(e,t){for(var n=new WeakSet,r=e;!n.has(r);){if(n.add(r),!jl(r.cause)){ad(r.cause)||(t.cause=r.cause),r.cause=t;return}r=r.cause}},qV=function(e,t){if(!t)return e;var n=new Error(jl(e)?e.message:"Primitive value captured as exception: ".concat(String(e)));return WV(n,"React ErrorBoundary ".concat(jl(e)?e.name:"Error")),n.stack=t,jl(e)?(UV(e,n),e):n},U0={componentStack:null,exceptionEvent:null,error:null},KV={INVALID_FALLBACK:"[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element."},A8=(Ja=(function(e){zV(t,e);function t(n){var r=e.call(this,n)||this;return r._resetError=function(){r.setState(U0)},r.state=U0,r}return t.prototype.componentDidCatch=function(n,r){var i=this.props.additionalProperties,s;wh(i)?s=i(n,r):typeof i=="object"&&(s=i);var o=this.context.client,a=r.componentStack,l=o.captureException(qV(n,a),s);this.setState({error:n,componentStack:a??null,exceptionEvent:l})},t.prototype.render=function(){var n=this.props,r=n.children,i=n.fallback,s=this.state;if(s.componentStack==null)return wh(r)?r():r;var o=wh(i)?g.createElement(i,{error:s.error,componentStack:s.componentStack,exceptionEvent:s.exceptionEvent,resetError:this._resetError}):i;return g.isValidElement(o)?o:(console.warn(KV.INVALID_FALLBACK),g.createElement(g.Fragment,null))},t})(g.Component),$V(Ja,"PostHogErrorBoundary"),(function(){Ja.contextType=Ns})(),Ja);HV(Zx);function Vm({...e}){return(0,p.jsx)(UO,{"data-slot":"dropdown-menu",...e})}function zm({...e}){return(0,p.jsx)(qO,{"data-slot":"dropdown-menu-trigger",...e})}function $m({className:e,sideOffset:t=4,...n}){return(0,p.jsx)(KO,{children:(0,p.jsx)(GO,{"data-slot":"dropdown-menu-content",sideOffset:t,className:G("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 Bl({className:e,inset:t,variant:n="default",...r}){return(0,p.jsx)(YO,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:G("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 T8({className:e,children:t,checked:n,...r}){return(0,p.jsxs)(XO,{"data-slot":"dropdown-menu-checkbox-item",className:G("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,p.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,p.jsx)(Pw,{children:(0,p.jsx)(hs,{className:"size-4"})})}),t]})}function GV({...e}){return(0,p.jsx)(JO,{"data-slot":"dropdown-menu-radio-group",...e})}function QV({className:e,children:t,hideIndicator:n=!1,...r}){return(0,p.jsxs)(ZO,{"data-slot":"dropdown-menu-radio-item",className:G("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,p.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,p.jsx)(Pw,{children:(0,p.jsx)(lM,{className:"size-2 fill-current"})})}),t]})}function YV({className:e,inset:t,...n}){return(0,p.jsx)(QO,{"data-slot":"dropdown-menu-label","data-inset":t,className:G("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...n})}function E8({className:e,...t}){return(0,p.jsx)(eD,{"data-slot":"dropdown-menu-separator",className:G("bg-border -mx-1 my-1 h-px",e),...t})}function M8({...e}){return(0,p.jsx)(tD,{"data-slot":"dropdown-menu-sub",...e})}function R8({className:e,inset:t,children:n,...r}){return(0,p.jsxs)(nD,{"data-slot":"dropdown-menu-sub-trigger","data-inset":t,className:G("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,p.jsx)(fs,{className:"ml-auto size-4"})]})}function P8({className:e,...t}){return(0,p.jsx)(rD,{"data-slot":"dropdown-menu-sub-content",className:G("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})}var XV=8192,JV=8192,Sh=64,ZV=new Set(["_truncated","bytes","limitBytes","reason","head"]);function Cr(e,t){let n=0,r=0;for(let i=0;i<e.length&&!(n>t);i++){const s=e.charCodeAt(i);if(s<128){n+=1,s===34||s===92?r+=1:s<32&&(r+=s===8||s===9||s===10||s===12||s===13?1:5);continue}if(s<2048){n+=2;continue}if(s>=55296&&s<=56319){const o=e.charCodeAt(i+1);if(o>=56320&&o<=57343){n+=4,i++;continue}}if(s>=55296&&s<=57343){n+=3,r+=3;continue}n+=3}return{utf8:n,json:n+r+2}}function ez(e){const t=e.charCodeAt(8191);return e.slice(0,t>=55296&&t<=56319?8191:JV)}var tz=8,H1=5e4;function W1(e,t){let n=0,r=0;const i=[e];for(;i.length>0;){if(n>t)return{bytes:n,exceeded:!0};if(++r>H1)return{bytes:n,exceeded:!0};const s=i.pop();if(typeof s=="string"){n+=Cr(s,t-n).json;continue}if(s===null||typeof s!="object"){n+=5;continue}if(Array.isArray(s)){n+=2+s.length;for(const o of s){if(n>t)return{bytes:n,exceeded:!0};i.push(o)}continue}n+=2;for(const o in s)if(Object.hasOwn(s,o)){if(n+=Cr(o,t-n).json+2,n>t)return{bytes:n,exceeded:!0};i.push(s[o])}}return{bytes:n,exceeded:n>t}}function nz(e,t){const n={_truncated:!0,limitBytes:t};if(typeof e!="object"||e===null||Array.isArray(e))return n;let r=0,i=0;const s=new Set,o=h=>h===void 0?{_truncated:!0}:{_truncated:!0,bytes:h},a=(h,f)=>{if(++i>H1)return o();if(typeof h=="string"){const m=Cr(h,t-r);if(h.length<=XV&&r+m.json<=t)return r+=m.json,h;const v=Cr(h,Number.POSITIVE_INFINITY).utf8,y=ez(h);if(y.length<h.length){const x=Cr(y,Number.POSITIVE_INFINITY).json;if(r+x+Sh<=t)return r+=x+Sh,{_truncated:!0,bytes:v,head:y}}return r+=Sh,o(v)}if(h===null||typeof h!="object")return r+=5,h;if(f>=tz||s.has(h))return o();if(s.add(h),Array.isArray(h)){r+=2;const m=[];for(const v of h){if(r+=1,r>t)return s.delete(h),o();m.push(a(v,f+1))}return s.delete(h),m}r+=2;const d={};for(const m in h)if(Object.hasOwn(h,m)){if(r+=Cr(m,t-r).json+2,r>t)return s.delete(h),o();d[m]=a(h[m],f+1)}return s.delete(h),d},l=a(e,0),c={};if(!rz(l)&&typeof l=="object"&&l!==null)for(const[h,f]of Object.entries(l))ZV.has(h)||(c[h]=f);const u={...c,...n};return W1(u,t).exceeded?n:u}function rz(e){return typeof e=="object"&&e!==null&&e._truncated===!0}function kh(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function I8(e){if(e.reason)return`Payload not recorded: ${e.reason}.`;const t=typeof e.limitBytes=="number"?`over the ${kh(e.limitBytes)} log limit`:"over the log size limit",n=typeof e.bytes=="number"?` It was ${kh(e.bytes)}.`:"";return typeof e.head=="string"?`Payload truncated — ${t}.${n} Showing the first ${kh(Cr(e.head,Number.POSITIVE_INFINITY).utf8)}.`:`Payload not recorded — ${t}.${n}`}function U1(e){try{return new URL(e).pathname}catch{return e}}function iz(e){return typeof e=="string"&&e.startsWith("Automatic resolved to ")}var ld=1e3,Ch=1048576,q1=8388608,K1=new WeakMap;function sz(e){const t=e.length>ld?e.slice(0,ld):e;let n=0;for(let r=0;r<t.length;r++)if(n+=K1.get(t[r])??0,n>q1&&r>0)return t.slice(0,r);return t}var ys=rM(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,ld)}))},addMcpServerLog:t=>{const n={...t,id:t.id??`${t.timestamp}-${Math.random().toString(36).slice(2)}`};K1.set(n,W1(n.payload,q1).bytes),e(r=>({mcpServerItems:sz(r.mcpServerItems.some(i=>i.id===n.id)?r.mcpServerItems.map(i=>i.id===n.id?n:i):[n,...r.mcpServerItems])}))},clear:()=>e({items:[],mcpServerItems:[]})}));function G1(e){return typeof e.eventId=="string"&&e.eventId.length>0?e.eventId:void 0}function O8(e){if(!Array.isArray(e)||e.length===0)return;const t=ys.getState();e.forEach(n=>{const r=G1(n);t.addMcpServerLog({...r?{id:r}:{},serverId:n.serverId,serverName:n.serverName,direction:n.direction.toUpperCase(),method:eb(n.message),timestamp:n.timestamp,payload:n.message})})}function D8(e){if(!Array.isArray(e)||e.length===0)return;const t=ys.getState();e.forEach(n=>{const r=G1(n);t.addMcpServerLog({...r?{id:r}:{},serverId:n.serverId,serverName:n.serverName,direction:"HTTP",method:`${n.exchange.request.method} ${U1(n.exchange.request.url)}`,timestamp:n.timestamp,payload:n.exchange,kind:"http"})})}function N8(e){const{serverId:t,serverName:n,trace:r}=e;if(!r||!Array.isArray(r.steps)||r.steps.length===0)return;const i=ys.getState();r.steps.forEach(s=>{const o=new Date(s.completedAt??s.startedAt).toISOString();iz(s.message)&&i.addMcpServerLog({id:`oauth:${t}:${r.source}:automatic_resolution:${s.startedAt}`,serverId:t,serverName:n,direction:"OAUTH",method:"Automatic Resolution",timestamp:o,payload:{source:r.source,step:"automatic_resolution",title:"Automatic Resolution",status:s.status,message:s.message,details:s.details,relatedStep:s.step},kind:"oauth",oauthStatus:s.status,oauthSource:r.source,oauthRecovered:s.recovered===!0}),i.addMcpServerLog({id:`oauth:${t}:${r.source}:${s.step}:${s.startedAt}`,serverId:t,serverName:n,direction:"OAUTH",method:s.title,timestamp:o,payload:{source:r.source,step:s.step,title:s.title,status:s.status,message:s.message,error:s.error,details:s.details,recovered:s.recovered,recoveredAt:s.recoveredAt,recoveryMessage:s.recoveryMessage,httpHistory:r.httpHistory.filter(a=>a.step===s.step)},kind:"oauth",oauthStatus:s.status,oauthSource:r.source,oauthRecovered:s.recovered===!0})})}var Fn=null,Us=0;function L8(){if(Us++,!Fn){const e=new URLSearchParams;e.set("replay","3"),e.set("_t",Date.now().toString()),Fn=new EventSource(IF(`/api/mcp/servers/rpc/stream?${e.toString()}`)),Fn.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;ys.getState().addMcpServerLog({...r?{id:r}:{},serverId:typeof n.serverId=="string"?n.serverId:"unknown",direction:"HTTP",method:`${l.request.method} ${U1(l.request.url)}`,timestamp:n.timestamp??new Date().toISOString(),payload:l,kind:"http"});return}if(n.type!=="rpc")return;const{serverId:i,direction:s,message:o,timestamp:a}=n;ys.getState().addMcpServerLog({...r?{id:r}:{},serverId:typeof i=="string"?i:"unknown",direction:typeof s=="string"?s.toUpperCase():"",method:eb(o),timestamp:a??new Date().toISOString(),payload:Cr(t.data,Ch).utf8>Ch?nz(o,Ch):o})}catch{}},Fn.onerror=()=>{Fn?.close(),Fn=null,Us=0}}return()=>{Us--,Us<=0&&Fn&&(Fn.close(),Fn=null,Us=0)}}var oz=uM("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 kc({className:e,variant:t,asChild:n=!1,...r}){const i=n?pM:"span";return(0,p.jsx)(i,{"data-slot":"badge",className:G(oz({variant:t}),e),...r})}function az({delayDuration:e=0,...t}){return(0,p.jsx)(zD,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function mr({...e}){return(0,p.jsx)(az,{children:(0,p.jsx)($D,{"data-slot":"tooltip",...e})})}function gr({...e}){return(0,p.jsx)(HD,{"data-slot":"tooltip-trigger",...e})}var Q1="rounded-md px-3 py-1.5 text-xs",Y1="bg-primary text-primary-foreground",X1="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]",_8=`${Q1} ${Y1}`,lz=`${X1} bg-primary fill-primary`;function vr({className:e,sideOffset:t=0,children:n,variant:r="default",...i}){const s=r==="muted";return(0,p.jsx)(WD,{children:(0,p.jsxs)(UD,{"data-slot":"tooltip-content",sideOffset:t,className:G("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)",Q1,s?"border border-border bg-popover text-popover-foreground shadow-md":Y1,e),...i,children:[n,(0,p.jsx)(qD,{className:s?G(X1,"fill-popover"):lz})]})})}function j8({reason:e,fallback:t,children:n,...r}){const i=e||t;return i?(0,p.jsxs)(mr,{children:[(0,p.jsx)(gr,{asChild:!0,children:e?(0,p.jsx)("span",{className:"inline-flex rounded-md outline-none focus-visible:ring-ring/50 focus-visible:ring-[3px]",tabIndex:0,children:n}):n}),(0,p.jsx)(vr,{...r,children:i})]}):n}function cz(e){try{ys.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 q0(e){cz({code:`workspace/${e.label}`,message:e.message,level:e.level,serverId:e.serverId,...e.serverName?{serverName:e.serverName}:{},...e.detail?{detail:e.detail}:{}})}var K0={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 B8(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(s=>typeof s=="string"):[];if(typeof t=="string"&&t.trim())return r.length&&!r.every(s=>t.includes(s))?`${t} (${r.join(", ")})`:t;const i=e&&typeof e=="object"&&"code"in e?String(e.code):void 0;return i&&K0[i]?K0[i]:e instanceof Error&&e.message&&!/^[A-Z_]+$/.test(e.message)?e.message:i?`The App couldn't open (${i}).`:"The App couldn't open."}var gu=(0,g.createContext)(null),F8=()=>(0,g.useContext)(gu),Hm=(0,g.createContext)(null),uz=512;function V8({value:e,children:t}){const n=(0,g.useMemo)(()=>tb(()=>({links:{}})),[e?.api]);return(0,p.jsx)(gu.Provider,{value:e,children:(0,p.jsx)(Hm.Provider,{value:n,children:t})})}function hz(e,t){const n=(0,g.useContext)(Hm),r=JSON.stringify([e,t.map(i=>[i.uri,i.name])]);(0,g.useEffect)(()=>{!n||!e||!t.length||n.setState(i=>{const s={...i.links};for(const a of t)s[a.uri]={serverId:e,name:a.name};const o=Object.keys(s);for(const a of o.slice(0,Math.max(0,o.length-uz)))delete s[a];return{links:s}})},[n,r])}var fz={},dz=tb(()=>({links:fz}));function pz(){const e=(0,g.useContext)(Hm);return iM(e??dz,t=>t.links)}function Fl(e,t){return!!e&&e.enabled!==!1&&!!t&&e.serverIds.includes(t.serverId)&&!!t.resourceUri}function mz(e,t){const[n,r]=(0,g.useState)({state:"closed"}),[i,s]=(0,g.useState)(!1),o=(0,g.useRef)(null),a=JSON.stringify([t?.serverId,t?.resourceUri]),l=(0,g.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&&Fl(l.current.actions,l.current.reference);(0,g.useEffect)(()=>(r({state:"closed"}),s(!1),()=>o.current?.abort()),[a,e?.api]);const u=async f=>{if(!(!Fl(e,t)||!c())){r({state:"closed"}),s(!1);try{await e.open(t.serverId,f)}catch{s(!0)}}};return{menu:n,setMenu:r,failed:i,activate:async()=>{if(!Fl(e,t)||!c())return;o.current?.abort();const f=new AbortController;o.current=f,s(!1),r({state:"loading"});try{const d=await e.api.discoverFile(t.serverId,t.resourceUri,f.signal);if(f.signal.aborted||!c())return;if(d.length===1){await u(d[0]);return}d.length===0&&q0({serverId:t.serverId,label:"file-viewer",level:"info",message:"No file viewer of this server accepts this file's extension."}),r({state:"ready",entries:d})}catch{if(f.signal.aborted||!c())return;r({state:"error"}),q0({serverId:t.serverId,label:"file-viewer",level:"error",message:"Couldn't list the file viewers for this file."})}},open:u}}var gz={onPointerDown:e=>e.preventDefault(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&e.preventDefault()}};function vz({menu:e,onOpen:t}){return(0,p.jsxs)($m,{align:"start",children:[(0,p.jsx)(YV,{className:"text-xs text-muted-foreground",children:"Open with…"}),e.state==="error"&&(0,p.jsx)(Bl,{disabled:!0,children:"Couldn't load viewers"}),e.state==="ready"&&e.entries.length===0&&(0,p.jsx)(Bl,{disabled:!0,children:"No viewer can open this file"}),e.state==="ready"&&e.entries.map(n=>(0,p.jsx)(Bl,{onSelect:()=>t(n),children:n.title},n.toolName))]})}function J1({reference:e,label:t,className:n}){const r=(0,g.useContext)(gu),i=mz(r,e);return Fl(r,e)?(0,p.jsxs)(Vm,{open:i.menu.state==="ready"||i.menu.state==="error",onOpenChange:s=>{s||i.setMenu({state:"closed"})},children:[(0,p.jsx)(zm,{asChild:!0,...gz,children:(0,p.jsxs)("button",{type:"button",onClick:s=>{s.stopPropagation(),i.activate()},className:G("inline-flex max-w-full items-center gap-1 text-left text-primary underline-offset-2 hover:underline",n),children:[(0,p.jsx)("span",{className:"truncate",children:t}),i.menu.state==="loading"?(0,p.jsx)(hM,{className:"size-3 shrink-0 animate-spin","aria-hidden":!0}):null]})}),(0,p.jsx)(vz,{menu:i.menu,onOpen:s=>{i.open(s)}}),i.failed&&(0,p.jsx)("span",{role:"alert",className:"ms-1 text-xs text-destructive",children:"Could not open viewer"})]}):(0,p.jsx)("span",{className:n,children:t})}function z8({result:e,serverId:t}){const n=(0,g.useContext)(gu);if(!n||!t||!n.serverIds.includes(t)||!e||typeof e!="object")return null;const r=e,i=r.content??r.value?.content;if(!Array.isArray(i))return null;const s=i.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 s.length?(0,p.jsx)(yz,{serverId:t,links:s}):null}function yz({serverId:e,links:t}){return hz(e,t),(0,p.jsx)("div",{className:"flex flex-wrap gap-2 px-3 pb-2",children:t.map((n,r)=>(0,p.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,p.jsx)(J1,{reference:{serverId:e,resourceUri:n.uri},label:n.name})},`${n.uri}:${r}`))})}var Z1=(0,g.createContext)(new Map);function $8(e){const t=(0,g.useContext)(Z1);return e?t.get(e):void 0}function xz({name:e}){return e?(0,p.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,p.jsx)(hN,{className:"size-2.5 shrink-0","aria-hidden":!0}),(0,p.jsx)("span",{className:"min-w-0 truncate",children:e})]}):null}var bz=50,Ah="null";function Oi(){return{line:1,column:1}}function wz(e){if(e===void 0)return Ah;try{return JSON.stringify(e,null,2)??Ah}catch{return Ah}}function Di(e){try{return{value:JSON.parse(e),error:null}}catch(t){return{value:void 0,error:t instanceof Error?t.message:"Invalid JSON"}}}function Ni(e){try{return JSON.stringify(e)}catch{return null}}function ui(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null)return ui(t)}catch{}return e}if(Array.isArray(e))return e.map(ui);if(typeof e=="object"&&e!==null){const t={};for(const[n,r]of Object.entries(e))t[n]=ui(r);return t}return e}function To(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[i,s]of Object.entries(e))n[i]=i in r?To(s,r[i]):s;return n}return Array.isArray(e)&&Array.isArray(t)?e.map((n,r)=>r<t.length?To(n,t[r]):n):e}function Za(e,t,n){return e!==void 0?e:wz(n?ui(t):t)}function Sz({initialValue:e,initialContent:t,onChange:n,onRawChange:r,onValidationError:i,expandJsonStrings:s=!1}){const o=(0,g.useRef)(null);if(o.current===null){const I=Za(t,e,s),_=Di(I);let j;_.error!==null?j=null:s?j=Ni(To(_.value,e)):j=Ni(_.value),o.current={content:I,lastEmitted:j,error:_.error}}const[a,l]=(0,g.useState)(o.current.content),c=(0,g.useRef)(e),u=(0,g.useRef)(o.current.content),h=(0,g.useRef)(o.current.content),f=(0,g.useRef)(o.current.lastEmitted),[d,m]=(0,g.useState)(o.current.error),[v,y]=(0,g.useState)(Oi),x=(0,g.useRef)([{content:o.current.content,cursorPosition:Oi()}]),b=(0,g.useRef)(0),w=(0,g.useCallback)(I=>{const _=Di(I);return m(_.error),i?.(_.error),_},[i]);(0,g.useEffect)(()=>{u.current=a},[a]);const S=(0,g.useRef)({value:e,content:t});if(e!==S.current.value||t!==S.current.content)if(S.current={value:e,content:t},t===void 0&&s){const I=Ni(e);I!==null&&I===f.current?(c.current=e,h.current=u.current):(c.current=e,h.current=Za(void 0,e,!0))}else c.current=e,h.current=Za(t,e,s);(0,g.useEffect)(()=>{const I=h.current;if(I===u.current)return;u.current=I,l(I),y(Oi()),x.current=[{content:I,cursorPosition:Oi()}],b.current=0,w(I);const _=Di(I);if(_.error===null&&s){const j=To(_.value,e);f.current=Ni(j)}else f.current=_.error===null?Ni(_.value):null},[e,t,w,s]);const C=(0,g.useCallback)((I,_,j)=>{r?.(I);const $=B=>{const D=s?To(B,c.current):B,se=Ni(D);if(se===null){n?.(D);return}se!==f.current&&(f.current=se,n?.(D))};if(j===void 0){const B=Di(I);B.error===null&&$(B.value);return}j===null&&$(_)},[n,r,s]),A=(0,g.useCallback)(I=>{if(I===u.current)return;u.current=I,l(I);const{value:_,error:j}=w(I),$=b.current;let B=x.current;$<B.length-1&&(B=B.slice(0,$+1));const D=B[B.length-1];(!D||D.content!==I)&&(B=[...B,{content:I,cursorPosition:v}]),B.length>bz&&(B=B.slice(-50)),x.current=B,b.current=B.length-1,C(I,_,j)},[v,C,w]),k=(0,g.useCallback)(I=>{u.current=I.content,l(I.content),y(I.cursorPosition);const{value:_,error:j}=w(I.content);C(I.content,_,j)},[C,w]),E=(0,g.useCallback)(()=>{const I=x.current,_=b.current;if(_>0){b.current=_-1;const j=I[_-1];k(j)}},[k]),T=(0,g.useCallback)(()=>{const I=x.current,_=b.current;if(_<I.length-1){b.current=_+1;const j=I[_+1];k(j)}},[k]),R=(0,g.useCallback)(()=>{const{value:I,error:_}=Di(a);if(_===null){const j=s?ui(I):I,$=JSON.stringify(j,null,2);A($)}},[a,A,s]),P=(0,g.useCallback)(()=>{c.current=e;const I=Za(t,e,s);h.current=I,u.current=I,l(I),y(Oi()),x.current=[{content:I,cursorPosition:Oi()}],b.current=0;const{value:_,error:j}=w(I);C(I,_,j)},[e,t,w,C,s]),M=(0,g.useCallback)(()=>{const{value:I,error:_}=Di(a);return _===null?I:void 0},[a]),N=b.current>0,L=b.current<x.current.length-1;return{content:a,setContent:A,isValid:d===null,validationError:d,cursorPosition:v,setCursorPosition:y,undo:E,redo:T,canUndo:N,canRedo:L,format:R,reset:P,getParsedValue:M,sourceContent:h.current}}function kz(e){return typeof e=="object"?e.key:e}function Cz(e,t){const n=e.length;return new Proxy(e,{get(r,i,s){if(typeof i=="string"){const o=i.charCodeAt(0);if(o>=48&&o<=57){const a=+i;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(i==="length")return n}return Reflect.get(r,i,s)}})}function Li(e,t,n){let r=n.initialDeps??[],i,s=!0;function o(){const a=e();return(a.length!==r.length||a.some((l,c)=>r[c]!==l))&&(r=a,i=t(...a),n?.onChange&&!(s&&n.skipInitialOnChange)&&n.onChange(i),s=!1),i}return o.updateDeps=a=>{r=a},o}function G0(e,t){if(e===void 0)throw new Error(`Unexpected undefined${t?`: ${t}`:""}`);return e}var Q0=(e,t)=>Math.abs(e-t)<1.01,Az=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},qs,Th=()=>{if(qs!==void 0)return qs;if(typeof navigator>"u")return qs=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return qs=!0;const e=navigator.maxTouchPoints;return qs=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Y0=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Tz=e=>e,Ez=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 i=0;i<n;i++)r[i]=t+i;return r},Mz=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const i=o=>{const{width:a,height:l}=o;t({width:Math.round(a),height:Math.round(l)})};if(i(Y0(n)),!r.ResizeObserver)return()=>{};const s=new r.ResizeObserver(o=>{const a=()=>{const l=o[0];if(l?.borderBoxSize){const c=l.borderBoxSize[0];if(c){i({width:c.inlineSize,height:c.blockSize});return}}i(Y0(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},Cc={passive:!0},Rz=typeof window>"u"?!0:"onscrollend"in window,Pz=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const i=e.targetWindow;if(!i)return;const s=e.options.useScrollendEvent&&Rz;let o=0;const a=s?null:Az(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),l=h=>()=>{o=n(r),a?.(),t(o,h)},c=l(!0),u=l(!1);return r.addEventListener("scroll",c,Cc),s&&r.addEventListener("scrollend",u,Cc),()=>{r.removeEventListener("scroll",c),s&&r.removeEventListener("scrollend",u),a?.cancel()}},Iz=(e,t)=>Pz(e,t,n=>{const{horizontal:r,isRtl:i}=e.options;return r?n.scrollLeft*(i&&-1||1):n.scrollTop}),Oz=(e,t,n)=>{if(n.options.useCachedMeasurements){const r=n.indexFromElement(e),i=n.options.getItemKey(r);return n.itemSizeCache.get(i)??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),i=n.options.getItemKey(r),s=n.itemSizeCache.get(i);if(s!==void 0)return s}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},Dz=(e,{adjustments:t=0,behavior:n},r)=>{var i,s;(s=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},Nz=Dz;function Lz(e,t,n,r){if(t===0)return!1;const i=r(0),s=new Set;let o=0;for(;o<e;){const l=n(o);if(l===i)break;s.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(s.has(r(l)))return!1;return!0}var _z=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(i=>{const s=()=>{const o=i.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,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()})}));return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),t=null},observe:r=>{var i;return(i=n())==null?void 0:i.observe(r,{box:"border-box"})},unobserve:r=>{var i;return(i=n())==null?void 0:i.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:Tz,rangeExtractor:Ez,onChange:()=>{},measureElement:Oz,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 h=t[u];h!==void 0&&(r[u]=h)}const i=this.options;let s=null,o=null,a=!1;if(i!==void 0&&i.enabled&&r.enabled&&r.anchorTo==="end"&&this.scrollElement!==null){const u=i.count,h=r.count,f=this.getMeasurements(),d=((n=this._singleLaneMeasurements)==null?void 0:n.items)??f,m=x=>kz(d[x]),v=u>0?m(0):null,y=u>0?m(u-1):null;if(h!==u||u>0&&h>0&&(r.getItemKey(0)!==v||r.getItemKey(h-1)!==y)){a=!0;const x=u>0?this.getVirtualItemForOffset(this.getScrollOffset())??f[0]:null;x&&(s=[x.key,this.getScrollOffset()-x.start]);const b=r.followOnAppend===!0?"auto":r.followOnAppend||null;b&&h>0&&this.isAtEnd(i.scrollEndThreshold)&&(u===0||r.getItemKey(h-1)!==y)&&(h>u||Lz(u,h,m,r.getItemKey))&&(o=b)}}this.options=r,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let l=!1,c=0;if(s&&this.scrollOffset!==null){const[u,h]=s,f=this.getMeasurements(),{count:d,getItemKey:m}=this.options;let v=0;for(;v<d&&m(v)!==u;)v++;if(v<d){const y=f[v];if(y){const x=Math.max(0,y.start+h);!o&&x!==this.scrollOffset&&(c=x-this.scrollOffset,this.scrollOffset=x,l=!0)}}}(l||o)&&(this.pendingScrollAnchor=[l?s[0]:null,l?s[1]:0,o,c])},this.notify=t=>{var n,r;(r=(n=this.options).onChange)==null||r.call(n,this,t)},this.maybeNotify=Li(()=>(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(s=>{this.observer.observe(s)}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{if(o&&this._intendedScrollOffset===null&&s===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(s-this._intendedScrollOffset)<1.5&&(s=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(s-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=o?a===s?this.scrollDirection:a<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=o,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const s=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,!(!Th()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};s.addEventListener("touchstart",o,Cc),s.addEventListener("touchend",a,Cc),this.unsubs.push(()=>{s.removeEventListener("touchstart",o),s.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 i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[s,o,a,l]=i;s!==null&&!a&&(Th()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):((n=this.scrollState)==null?void 0:n.behavior)==="smooth"&&!Q0(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=Li(()=>[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,i,s,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:i,enabled:s,lanes:o,laneAssignmentMode:a,gap:l}),{key:!1}),this.isIndexInRange=t=>t>=0&&t<this.options.count,this.getMeasurements=Li(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:n,scrollMargin:r,getItemKey:i,enabled:s,lanes:o,laneAssignmentMode:a,gap:l},c)=>{var u;const h=this.itemSizeCache;if(!s)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const x of this.laneAssignments.keys())x>=t&&this.laneAssignments.delete(x);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(x=>{this.itemSizeCache.set(x.key,x.size)}));const f=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),o===1){const x=t*2;let b=(u=this._singleLaneMeasurements)==null?void 0:u.flat;if(!b||b.length<x){const A=new Float64Array(x);b&&f>0&&A.set(b.subarray(0,f*2)),b=A}const w=f===0?new Array(t):this._singleLaneMeasurements.items.slice();let S;if(f===0)S=n+r;else{const A=f-1;S=b[A*2]+b[A*2+1]+l}for(let A=f;A<t;A++){const k=i(A);w[A]=k;const E=h.get(k),T=typeof E=="number"?E:this.options.estimateSize(A);b[A*2]=S,b[A*2+1]=T,S+=T+l}this._singleLaneMeasurements={flat:b,items:w};const C=Cz(w,b);return this.measurementsCache=C,C}const d=this.measurementsCache.slice(0,f),m=new Array(o).fill(void 0),v=new Float64Array(o);let y=0;for(let x=0;x<f;x++){const b=d[x];b&&(m[b.lane]===void 0&&y++,m[b.lane]=x,v[b.lane]=b.end)}for(let x=f;x<t;x++){const b=i(x),w=this.laneAssignments.get(x);let S,C;const A=a==="estimate"||h.has(b);if(w!==void 0&&this.options.lanes>1){S=w;const R=m[S],P=R!==void 0?d[R]:void 0;C=P?P.end+l:n+r}else if(y===o){let R=0,P=v[0],M=m[0];for(let N=1;N<o;N++){const L=v[N];(L<P||L===P&&m[N]<M)&&(R=N,P=L,M=m[N])}S=R,C=P+l,A&&this.laneAssignments.set(x,S)}else S=x%this.options.lanes,C=n+r,A&&this.laneAssignments.set(x,S);const k=h.get(b),E=typeof k=="number"?k:this.options.estimateSize(x),T=C+E;d[x]={index:x,start:C,size:E,end:T,key:b,lane:S},m[S]===void 0&&y++,m[S]=x,v[S]=T}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Li(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,n,r,i)=>t.length===0||n===0?(this.range=null,null):(this.range=Bz(t,n,r,i,i===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Li(()=>{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,i,s)=>i===null||s===null?[]:t({startIndex:i,endIndex:s,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 i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),s=Math.max(0,r-i),o=Math.min(this.options.count-1,r+i);return t>=s&&t<=o}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((s,o)=>{s.isConnected||(this.observer.unobserve(s),this.elementsCache.delete(o))});return}const n=this.indexFromElement(t);if(!this.isIndexInRange(n))return;const r=this.options.getItemKey(n),i=this.elementsCache.get(r);i!==t&&(i&&this.observer.unobserve(i),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,i,s;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 f=this.measurementsCache[t];if(!f)return;l=f.key,a=f.start,o=f.size}const u=this.itemSizeCache.get(l)??o,h=n-u;if(h!==0){const f=this.options.anchorTo==="end"&&((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,d=f?this.getTotalSize():0,m=this.getScrollOffset()+this.scrollAdjustments,v=this.itemSizeCache.has(l)?a+u<=m&&this.scrollDirection!=="backward":a<m,y=((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:l,start:a,size:o,end:a+o,lane:0},h,this):v);(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(l,n),this.itemSizeCacheVersion++;let x=!1;f?x=this.applyScrollAdjustment(this.getTotalSize()-d):y&&(x=this.applyScrollAdjustment(h)),this.notify(x),this._retryClampedAdjustment()}},this.getVirtualItems=Li(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,n)=>{const r=[];for(let i=0,s=t.length;i<s;i++){const o=n[t[i]];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 i=(n=this._singleLaneMeasurements)==null?void 0:n.flat,s=this.options.lanes===1&&i!=null,o=eC(0,r.length-1,s?a=>i[a*2]:a=>G0(r[a]).start,t);return G0(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 i=this.getSize(),s=this.getScrollOffset();n==="auto"&&(n=t>=s+i?"end":"start"),n==="center"?t+=(r-i)/2:n==="end"&&(t-=i);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(),i=this.getScrollOffset(),s=this.measurementsCache[t];if(!s)return;if(n==="auto")if(s.end>=i+r-this.options.scrollPaddingEnd)n="end";else if(s.start<=i+this.options.scrollPaddingStart)n="start";else return[i,n];if(n==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),n];const o=n==="end"?s.end+this.options.scrollPaddingEnd:s.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,n,s.size),n]},this.scrollToOffset=(t,{align:n="start",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0;const i=this.getOffsetForAlignment(t,n),s=this.now();this.scrollState={index:null,align:n,behavior:r,startedAt:s,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{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 i=this.getOffsetForIndex(t,n);if(!i)return;const[s,o]=i,a=this.now();this.scrollState={index:t,align:o,behavior:r,startedAt:a,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:n="auto"}={})=>{const r=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:i,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 i;if(r.length===0)i=this.options.paddingStart;else if(this.options.lanes===1){const s=r.length-1,o=(t=this._singleLaneMeasurements)==null?void 0:t.flat;o!=null?i=o[s*2]+o[s*2+1]:i=((n=r[s])==null?void 0:n.end)??0}else{const s=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&s.some(a=>a===null);){const a=r[o];s[a.lane]===null&&(s[a.lane]=a.end),o--}i=Math.max(...s.filter(a=>a!==null))}return Math.max(i-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(Th()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=e,!1;{const n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&("scrollHeight"in r||"document"in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}: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&&Q0(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 i=this.getSize()||600,s=Math.abs(t-this.getScrollOffset()),o=this.scrollState.behavior==="smooth"&&s>i;this.scrollState.lastTargetOffset=t,o||(this.scrollState.behavior="auto"),this._scrollToOffset(t,{adjustments:void 0,behavior:o?"smooth":"auto"})}this.scheduleScrollReconcile()}},eC=(e,t,n,r)=>{for(;e<=t;){const i=(e+t)/2|0,s=n(i);if(s<r)e=i+1;else if(s>r)t=i-1;else return i}return e>0?e-1:0};function jz(e,t,n){let r=0;for(;r<=t;){const i=(r+t)/2|0,s=e[i*2];if(s<n)r=i+1;else if(s>n)t=i-1;else return i}return r>0?r-1:0}function Bz(e,t,n,r,i){const s=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:s};if(r===1&&i!==null){const c=jz(i,s,n);let u=c;const h=n+t;for(;u<s&&i[u*2]+i[u*2+1]<h;)u++;return{startIndex:c,endIndex:u}}let a=eC(0,s,c=>e[c].start,n),l=a;if(r===1)for(;l<s&&e[l].end<n+t;)l++;else if(r>1){const c=Array(r).fill(0);for(;l<s&&c.some(h=>h<n+t);){const h=e[l];c[h.lane]=h.end,l++}const u=Array(r).fill(n+t);for(;a>=0&&u.some(h=>h>=n);){const h=e[a];u[h.lane]=h.start,a--}a=Math.max(0,a-a%r),l=Math.min(s,l+(r-1-l%r))}return{startIndex:a,endIndex:l}}var Eh=typeof document<"u"?g.useLayoutEffect:g.useEffect;function Fz({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...r}){const i=g.useReducer(h=>h+1,0)[1],s=g.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});s.current.enabled=t,s.current.mode=n;const o=g.useRef(!1),a=h=>{const f=s.current;if(!f.enabled||!f.container)return;const d=h.getTotalSize();if(d!==f.lastSize){f.lastSize=d;const m=h.options.horizontal?"width":"height";f.container.style[m]=`${d}px`}},l=h=>{const f=s.current;if(!f.enabled||!f.container)return;a(h);const d=!!h.options.horizontal,m=f.mode==="transform",v=d?"left":"top",y=h.options.scrollMargin,x=h.getVirtualItems();for(const b of x){const w=b.start-y,S=h.elementsCache.get(b.key);S&&f.lastPositions.get(S)!==w&&(f.lastPositions.set(S,w),m?S.style.transform=d?`translate3d(${w}px, 0, 0)`:`translate3d(0, ${w}px, 0)`:S.style[v]=`${w}px`)}},c={...r,onChange:(h,f)=>{var d;const m=s.current;let v=!0;if(m.enabled){l(h);const y=h.range,x=m.prevRange;v=!x||x.isScrolling!==h.isScrolling||x.startIndex!==y?.startIndex||x.endIndex!==y?.endIndex,v&&(m.prevRange=y?{startIndex:y.startIndex,endIndex:y.endIndex,isScrolling:h.isScrolling}:null)}v&&(e&&f&&!o.current?(0,pa.flushSync)(i):i()),(d=r.onChange)==null||d.call(r,h,f)}},[u]=g.useState(()=>{const h=new _z(c),f=h.measureElement;return h.measureElement=d=>{o.current=!0;try{f(d)}finally{o.current=!1}},Object.assign(h,{containerRef:d=>{const m=s.current;if(m.container=d,m.lastSize=null,d&&m.enabled){const v=h.getTotalSize();m.lastSize=v;const y=h.options.horizontal?"width":"height";d.style[y]=`${v}px`}}})});return u.setOptions(c),Eh(()=>u._didMount(),[]),Eh(()=>(a(u),u._willUpdate())),Eh(()=>{l(u)}),u}function Vz(e){return Fz({observeElementRect:Mz,observeElementOffset:Iz,scrollToFn:Nz,...e})}function zz(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}function tC(e){const t=[];let n=0;const r=()=>{for(;n<e.length&&/\s/.test(e[n]);)n++},i=()=>{const h=n;for(n++;n<e.length;)if(e[n]==="\\")n+=2;else if(e[n]==='"'){n++;break}else n++;return e.slice(h,n)},s=()=>{const h=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(h,n)},o=()=>{const h=n;for(;n<e.length&&/[a-z]/.test(e[n]);)n++;return e.slice(h,n)},a=[];let l=!1;const c=[];let u=null;for(;n<e.length&&(r(),!(n>=e.length));){const h=e[n],f=n;switch(h){case"{":t.push({type:"punctuation",value:"{",start:f,end:n+1}),a.push("object"),l=!0,u!==null&&(c.push(u),u=null),n++;break;case"}":t.push({type:"punctuation",value:"}",start:f,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:f,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:f,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:f,end:n+1}),l=!1,n++;break;case",":t.push({type:"punctuation",value:",",start:f,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 d=i();if(l&&a.length>0&&a[a.length-1]==="object"){let m;try{m=JSON.parse(d)}catch{m=d.slice(1,-1)}u=m,t.push({type:"key",value:d,start:f,end:n,path:[...c,m],keyName:m})}else{const m=u!==null?[...c,u]:[...c];t.push({type:"string",value:d,start:f,end:n,path:m,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 d=s(),m=u!==null?[...c,u]:[...c];t.push({type:"number",value:d,start:f,end:n,path:m,keyName:u??void 0}),u=null,l=!1;break}case"t":case"f":{const d=o(),m=u!==null?[...c,u]:[...c];d==="true"?t.push({type:"boolean",value:d,start:f,end:n,path:m,keyName:u??void 0}):d==="false"&&t.push({type:"boolean-false",value:d,start:f,end:n,path:m,keyName:u??void 0}),u=null,l=!1;break}case"n":{const d=o();if(d==="null"){const m=u!==null?[...c,u]:[...c];t.push({type:"null",value:d,start:f,end:n,path:m,keyName:u??void 0}),u=null}l=!1;break}default:n++}}return t}function nC(e){const t=tC(e);let n="",r=0;const i=s=>{s&&(n+=`<span class="json-punctuation">${X0(s)}</span>`)};for(const s of t){s.start>r&&i(e.slice(r,s.start));const o=`json-${s.type}`;n+=`<span class="${o}">${X0(s.value)}</span>`,r=s.end}return r<e.length&&i(e.slice(r)),n}function X0(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function rC({value:e,displayValue:t,maxLength:n,onCopy:r,keyName:i,path:s}){const[o,a]=(0,g.useState)(null),[l,c]=(0,g.useState)(!1),[u,h]=(0,g.useState)(!1),f=e.length>n,d=f&&!u?`"${e.slice(0,n)}..."`:t,m=(0,g.useCallback)(async(b,w)=>{await uu(b)&&(a(w),r?.(b),setTimeout(()=>a(null),1500))},[r]),v=(0,g.useCallback)(b=>{f&&(b.stopPropagation(),h(w=>!w))},[f]),y=s&&s.length>0?zz(s):null,x=[];return x.push({label:"Copy value",value:e,key:"value"}),i&&x.push({label:"Copy key",value:i,key:"key"}),y&&x.push({label:"Copy path",value:y,key:"path"}),x.length===1?(0,p.jsxs)("span",{className:"relative group/copy",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[(0,p.jsx)("span",{onClick:v,className:G("json-string",f&&!u&&"json-string-truncated"),children:d}),(0,p.jsx)("button",{onClick:b=>{b.stopPropagation(),m(x[0].value,x[0].key)},className:G("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,p.jsx)(hs,{className:"h-3 w-3 text-green-500"}):(0,p.jsx)(ts,{className:"h-3 w-3 text-muted-foreground/60 hover:text-muted-foreground"})})]}):(0,p.jsxs)("span",{className:"relative group/copy",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[(0,p.jsx)("span",{onClick:v,className:G("json-string",f&&!u&&"json-string-truncated"),children:d}),(0,p.jsxs)(Vm,{children:[(0,p.jsx)(zm,{asChild:!0,children:(0,p.jsx)("button",{className:G("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:b=>b.stopPropagation(),children:o?(0,p.jsx)(hs,{className:"h-3 w-3 text-green-500"}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ts,{className:"h-3 w-3 text-muted-foreground/60"}),(0,p.jsx)(Xw,{className:"h-2 w-2 text-muted-foreground/60 -ml-0.5"})]})})}),(0,p.jsx)($m,{align:"start",className:"min-w-[140px]",children:x.map(b=>(0,p.jsxs)(Bl,{onClick:()=>m(b.value,b.key),className:"text-xs",children:[(0,p.jsx)(ts,{className:"h-3 w-3 mr-2"}),b.label]},b.key))})]})]})}function J0(e,t){return t?(0,p.jsx)("span",{className:"json-punctuation",children:t},e):null}function Mh({children:e,value:t,onCopy:n}){const[r,i]=(0,g.useState)(!1),[s,o]=(0,g.useState)(!1),a=(0,g.useCallback)(async l=>{await uu(l)&&(i(!0),n?.(l),setTimeout(()=>i(!1),1500))},[n]);return(0,p.jsxs)("span",{className:"relative group/copy",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[e,(0,p.jsx)("button",{onClick:l=>{l.stopPropagation(),a(t)},className:G("inline-flex items-center justify-center ml-1 p-0.5 rounded","transition-all duration-150","hover:bg-muted",s||r?"opacity-100":"opacity-0"),style:{verticalAlign:"middle"},children:r?(0,p.jsx)(hs,{className:"h-3 w-3 text-green-500"}):(0,p.jsx)(ts,{className:"h-3 w-3 text-muted-foreground/60 hover:text-muted-foreground"})})]})}function Z0(e,t){const n=e[t],r=n==="{"?"}":"]";let i=1,s=t+1,o=!1,a=!1;for(;s<e.length&&i>0;){const l=e[s];a?a=!1:l==="\\"?a=!0:l==='"'?o=!o:o||(l===n?i++:l===r&&i--),s++}return e.slice(t,s)}function $z({content:e,onCopy:t,collapseStringsAfterLength:n}){const r=(0,g.useMemo)(()=>{const i=tC(e),s=[];let o=0,a=null,l=!0;const c=u=>{for(let h=u+1;h<i.length;h++){const f=i[h];if(!(f.type==="punctuation"&&f.value===":"))return f}return null};for(let u=0;u<i.length;u++){const h=i[u];h.start>o&&s.push(J0(`ws-${o}`,e.slice(o,h.start)));const f=`json-${h.type}`;if(h.type==="key"){const v=c(u);v&&v.type==="punctuation"&&(v.value==="{"||v.value==="[")&&(a={start:v.start}),s.push((0,p.jsx)("span",{className:f,children:h.value},`token-${u}`)),o=h.end;continue}if(l&&h.type==="punctuation"&&(h.value==="{"||h.value==="[")){l=!1;const v=Z0(e,h.start);s.push((0,p.jsx)(Mh,{value:v,onCopy:t,children:(0,p.jsx)("span",{className:f,children:h.value})},`token-${u}`)),o=h.end;continue}if(a&&h.type==="punctuation"&&(h.value==="{"||h.value==="[")&&h.start===a.start){const v=Z0(e,h.start);a=null,s.push((0,p.jsx)(Mh,{value:v,onCopy:t,children:(0,p.jsx)("span",{className:f,children:h.value})},`token-${u}`)),o=h.end;continue}const d=h.type==="string"||h.type==="number"||h.type==="boolean"||h.type==="boolean-false"||h.type==="null",m=()=>{if(h.type==="string")try{return JSON.parse(h.value)}catch{return h.value.slice(1,-1)}return h.value};if(h.type==="string"&&n!==void 0){const v=m();s.push((0,p.jsx)(rC,{value:v,displayValue:h.value,maxLength:n,onCopy:t,keyName:h.keyName,path:h.path},`token-${u}`))}else d?s.push((0,p.jsx)(Mh,{value:m(),onCopy:t,children:(0,p.jsx)("span",{className:f,children:h.value})},`token-${u}`)):s.push((0,p.jsx)("span",{className:f,children:h.value},`token-${u}`));o=h.end}return o<e.length&&s.push(J0("ws-end",e.slice(o))),s},[e,t,n]);return(0,p.jsx)(p.Fragment,{children:r})}var ii=20,ey=30,ty=12,cd=80,Hz=2;function Wz(e){const t=e.value,n=e.selectionStart,r=t.substring(0,n).split(`
43
- `);return{line:r.length,column:r[r.length-1].length+1}}function Uz(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 cd;const i=Number.parseFloat(t.paddingLeft)||0,s=Number.parseFloat(t.paddingRight)||0,o=e.clientWidth-i-s;return o<=0?cd:Math.max(1,Math.floor(o/r))}function qz(e,t){const n=e.replace(/\t/g," ".repeat(Hz)).length;return n===0?1:Math.max(1,Math.ceil(n/t))}function Kz(e,t,n){let r=0;return e.map((i,s)=>{const o=t?qz(i,n)*ii:ii,a=t?r:s*ii;return r+=o,{top:a,height:o}})}function Gz(e,t,n,r,i){return(0,g.useMemo)(()=>{if(!r)return{highlightedHtml:"",paddingTop:0,paddingBottom:0};const s=e.split(`
44
- `),o=s.length;if(o===0)return{highlightedHtml:"",paddingTop:0,paddingBottom:0};let a=0,l=o-1;for(;a<=l;){const C=a+l>>>1,A=i[C];!A||A.top+A.height<=t?a=C+1:l=C-1}const c=Math.min(a,o-1),u=t+n;let h=c;for(let C=c;C<o;C++){const A=i[C];if(!A||A.top>=u)break;h=C}const f=Math.max(0,c-ey),d=Math.min(o-1,h+ey),m=s.slice(f,d+1).join(`
45
- `),v=i[f],y=i[d],x=i[o-1],b=x?x.top+x.height:0,w=v?.top??0,S=Math.max(0,b-(y?y.top+y.height:0));return{highlightedHtml:nC(m),paddingTop:w,paddingBottom:S}},[e,t,n,r,i])}function iC({content:e,onChange:t,onCursorChange:n,onUndo:r,onRedo:i,onEscape:s,isValid:o=!0,readOnly:a=!1,className:l,height:c,maxHeight:u,showLineNumbers:h=!0,collapseStringsAfterLength:f,wrapLongLinesInEdit:d=!1,wrapLongLinesInView:m=!1}){const v=(0,g.useRef)(null),y=(0,g.useRef)(null),x=(0,g.useRef)(null),b=(0,g.useRef)(null),w=(0,g.useRef)(null),[S,C]=(0,g.useState)(!1),[A,k]=(0,g.useState)(1),[E,T]=(0,g.useState)(0),[R,P]=(0,g.useState)(0),[M,N]=(0,g.useState)(400),L=(0,g.useRef)(null),I=(0,g.useRef)(null),_=(0,g.useRef)(0),[j,$]=(0,g.useState)(cd),B=a?m:d,D=a&&c==="auto",se=(0,g.useMemo)(()=>e.split(`
46
- `),[e]),ne=(0,g.useMemo)(()=>Kz(se,B,j),[j,B,se]),F=se.length,q=ne[Math.min(Math.max(A-1,0),F-1)],K=q?.top??0,Y=q?.height??ii,H=!a,X=K-E+ty,oe=(0,g.useCallback)(()=>{const J=a?b.current:v.current;if(!B||!J)return;const ge=Uz(J);$(ke=>ke===ge?ke:ge)},[B,a]),pe=Vz({count:F,getScrollElement:()=>a?x.current:y.current,estimateSize:J=>ne[J]?.height??ii,overscan:20}),{highlightedHtml:ae,paddingTop:at}=Gz(e,E,M,H,ne),et=(0,g.useMemo)(()=>a?"":H?ae:nC(e),[e,a,H,ae]),Re=H?at:0,ze=(0,g.useRef)(0);ze.current=Re;const _e=(0,g.useRef)(0);_e.current=K;const _n=(0,g.useCallback)(()=>{if(v.current){const J=v.current.scrollTop,ge=v.current.scrollLeft;y.current&&(y.current.scrollTop=J),L.current&&(L.current.style.transform=`translate(${-ge}px, ${ze.current-J}px)`),I.current&&(I.current.style.transform=`translateY(${_e.current-J+ty}px)`),cancelAnimationFrame(_.current),_.current=requestAnimationFrame(()=>{T(J),P(ge)})}},[]),je=(0,g.useCallback)(()=>{if(v.current&&n){const J=Wz(v.current);n(J),k(J.line)}},[n]),hn=(0,g.useCallback)(J=>{const ge=J.currentTarget,{selectionStart:ke,selectionEnd:js,value:$e}=ge;if((J.ctrlKey||J.metaKey)&&J.key==="z"&&!J.shiftKey){J.preventDefault(),r?.();return}if((J.ctrlKey||J.metaKey)&&J.shiftKey&&J.key==="z"||J.ctrlKey&&J.key==="y"){J.preventDefault(),i?.();return}if(J.key==="Escape"&&s){J.preventDefault(),s();return}if(J.key==="Tab"){J.preventDefault();const Ai=" ";if(J.shiftKey){const gt=$e.lastIndexOf(`
47
- `,ke-1)+1;if($e.substring(gt,ke).startsWith(Ai)){const Ti=$e.substring(0,gt)+$e.substring(gt+2);t?.(Ti),requestAnimationFrame(()=>{ge.selectionStart=ge.selectionEnd=ke-2})}}else{const gt=$e.substring(0,ke)+Ai+$e.substring(js);t?.(gt),requestAnimationFrame(()=>{ge.selectionStart=ge.selectionEnd=ke+2})}return}if(J.key==="Enter"){J.preventDefault();const Ai=$e.lastIndexOf(`
48
- `,ke-1)+1,gt=$e.substring(Ai,ke).match(/^(\s*)/)?.[1]||"",Ti=$e[ke-1],Pe=$e[ke],Bs=Ti==="{"||Ti==="[",Na=Pe==="}"||Pe==="]";let Hr=`
49
- `+gt,Te=Hr.length;Bs&&(Hr=`
50
- `+gt+" ",Te=Hr.length,Na&&(Hr+=`
51
- `+gt));const Bu=$e.substring(0,ke)+Hr+$e.substring(js);t?.(Bu),requestAnimationFrame(()=>{ge.selectionStart=ge.selectionEnd=ke+Te})}},[t,r,i,s]);(0,g.useEffect)(()=>{a||v.current?.focus()},[a]),(0,g.useEffect)(()=>{const J=()=>{w.current&&N(w.current.clientHeight)};return J(),window.addEventListener("resize",J),()=>window.removeEventListener("resize",J)},[]),(0,g.useEffect)(()=>()=>cancelAnimationFrame(_.current),[]),(0,g.useEffect)(()=>{A>F&&k(F)},[A,F]),(0,g.useEffect)(()=>{pe.measure()},[ne,pe]),(0,g.useEffect)(()=>{if(!B)return;oe(),window.addEventListener("resize",oe);let J;const ge=a?b.current:v.current;return window.ResizeObserver&&ge&&(J=new ResizeObserver(()=>oe()),J.observe(ge)),()=>{window.removeEventListener("resize",oe),J?.disconnect()}},[B,a,oe]);const wt={height:c??"auto",maxHeight:u??"none"},tt={fontFamily:"var(--font-code)"};return(0,p.jsxs)("div",{ref:w,className:G("group relative flex w-full overflow-hidden bg-muted/30",!o&&"border-destructive",l),style:wt,children:[h&&!a&&(0,p.jsx)("div",{ref:y,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,p.jsx)("div",{className:"py-3 pr-2 text-xs text-muted-foreground leading-5 relative",style:{...tt,height:`${pe.getTotalSize()}px`},children:pe.getVirtualItems().map(J=>{const ge=J.index+1,ke=ne[J.index]?.height??ii;return(0,p.jsx)("div",{className:G("leading-5 transition-colors duration-150 absolute left-0 right-0 pr-2",ge===A&&S&&"text-foreground font-medium"),style:{transform:`translateY(${J.start}px)`,height:`${ke}px`},children:ge},J.index)})})}),(0,p.jsx)("div",{className:G("relative flex-1 min-w-0",D?"overflow-visible":"h-full overflow-hidden"),children:a?(0,p.jsxs)("div",{ref:x,className:G("relative z-10 flex min-w-0 items-start",D?"h-auto overflow-visible":"h-full min-h-0 overflow-auto overscroll-none"),children:[h&&(0,p.jsx)("div",{ref:y,className:G("flex-shrink-0 border-r border-border/50 bg-muted/50 text-right select-none self-stretch",!D&&"sticky left-0 z-20"),style:{width:"3rem"},children:(0,p.jsx)("div",{className:"py-3 pr-2 text-xs text-muted-foreground leading-5 relative",style:{...tt,height:`${pe.getTotalSize()}px`},children:pe.getVirtualItems().map(J=>{const ge=J.index+1,ke=ne[J.index]?.height??ii;return(0,p.jsx)("div",{className:"leading-5 transition-colors duration-150 absolute left-0 right-0 pr-2",style:{transform:`translateY(${J.start}px)`,height:`${ke}px`},children:ge},J.index)})})}),(0,p.jsx)("div",{className:G("relative self-start overflow-visible",B?"flex-1 min-w-0":"w-max min-w-full"),children:(0,p.jsx)("pre",{ref:b,className:G("p-3 text-xs leading-5 m-0 select-text cursor-text",B?"w-full whitespace-pre-wrap break-words":"w-max min-w-full whitespace-pre"),style:tt,children:(0,p.jsx)($z,{content:e,collapseStringsAfterLength:f})})})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("pre",{ref:b,className:G("absolute inset-0 p-3 text-xs leading-5 overflow-hidden",B?"whitespace-pre-wrap break-words":"whitespace-pre","pointer-events-none m-0","text-muted-foreground"),style:{...tt,scrollbarGutter:"stable"},"aria-hidden":"true",children:(0,p.jsx)("div",{ref:L,style:{transform:`translate(${-R}px, ${Re-E}px)`,willChange:"transform"},children:(0,p.jsx)("div",{dangerouslySetInnerHTML:{__html:et+`
52
- `}})})}),S&&(0,p.jsx)("div",{ref:I,className:"absolute left-0 right-0 bg-foreground/[0.03] pointer-events-none",style:{height:`${Y}px`,transform:`translateY(${X}px)`}}),(0,p.jsx)("textarea",{ref:v,value:e,wrap:B?"soft":"off",onChange:J=>t?.(J.target.value),onScroll:_n,onSelect:je,onClick:je,onKeyDown:hn,onKeyUp:je,onFocus:()=>C(!0),onBlur:()=>C(!1),spellCheck:!1,className:G("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",B?"overflow-auto whitespace-pre-wrap break-words":"overflow-auto whitespace-pre"),style:{...tt,tabSize:2,scrollbarGutter:"stable"}})]})})]})}var ny=100;function Qz(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function sC(e,t){const n=Math.min(t,ny),r=[],i=[{value:e,path:"root",depth:0}];for(;i.length>0;){const s=i.pop();if(typeof s.value!="object"||s.value===null)continue;if(s.depth>=ny){s.depth>=n&&Qz(s.value)&&r.push(s.path);continue}const o=Object.entries(s.value);if(o.length!==0){s.depth>=n&&r.push(s.path);for(const[a,l]of o)i.push({value:l,path:`${s.path}.${a}`,depth:s.depth+1})}}return r}function Yz(e){return sC(e,0)}function Xz({value:e,defaultExpandDepth:t,initialCollapsedPaths:n,onCollapseChange:r}={}){const[i]=(0,g.useState)(()=>n!==void 0||t===void 0?null:new Set(sC(e,t))),[s,o]=(0,g.useState)(()=>i??n??new Set),a=(0,g.useCallback)(f=>s.has(f),[s]),l=(0,g.useCallback)(f=>{o(d=>{const m=new Set(d);return m.has(f)?m.delete(f):m.add(f),r?.(m),m})},[r]),c=(0,g.useCallback)(()=>{o(new Set),r?.(new Set)},[r]),u=(0,g.useCallback)(f=>{const d=Yz(f),m=new Set(d);o(m),r?.(m)},[r]),h=(0,g.useRef)(!1);return(0,g.useEffect)(()=>{h.current||i===null||(h.current=!0,r?.(i))},[i,r]),(0,g.useEffect)(()=>{n!==void 0&&o(n)},[n]),(0,g.useMemo)(()=>({collapsedPaths:s,isCollapsed:a,toggleCollapse:l,expandAll:c,collapseAll:u}),[s,a,l,c,u])}var el=50,Jz=100,Zz=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)},e$=typeof cancelIdleCallback<"u"?cancelIdleCallback:clearTimeout;function oC(e,t){const[n,r]=(0,g.useState)(e.length<=el?e.length:el);return(0,g.useEffect)(()=>{if(!t){r(Math.min(e.length,el));return}r(i=>i>e.length?Math.min(e.length,el):i)},[e.length,t]),(0,g.useEffect)(()=>{if(!t||n>=e.length)return;const i=Zz(()=>{r(s=>Math.min(s+Jz,e.length))},{timeout:100});return()=>e$(i)},[e.length,n,t]),e.slice(0,n)}var Tn=(0,g.memo)(function({children:t,value:n,onCopy:r,alwaysVisible:i=!1}){const[s,o]=(0,g.useState)(!1),[a,l]=(0,g.useState)(!1),c=(0,g.useCallback)(async u=>{u.stopPropagation();let h;try{h=typeof n=="function"?n():n}catch(f){console.error("Failed to serialize value for copy",f);return}await uu(h)&&(o(!0),r?.(h),setTimeout(()=>o(!1),1500))},[n,r]);return(0,p.jsxs)("span",{className:"relative group/copy",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t,(0,p.jsx)("button",{onClick:c,className:G("inline-flex items-center justify-center ml-1 p-0.5 rounded","transition-all duration-150","hover:bg-muted",i||a||s?"opacity-100":"opacity-0"),style:{verticalAlign:"middle"},children:s?(0,p.jsx)(hs,{className:"h-3 w-3 text-green-500"}):(0,p.jsx)(ts,{className:"h-3 w-3 text-muted-foreground/60 hover:text-muted-foreground"})})]})});function t$({value:e,path:t,keyName:n,isLast:r=!0,depth:i=0,isCollapsed:s,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}){const c=i*16,u=s(t),h=oC(e,!u),f=(0,g.useCallback)(()=>JSON.stringify(e,null,2),[e]),d=()=>n===void 0?null:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"json-key",children:['"',n,'"']}),(0,p.jsx)("span",{className:"json-punctuation",children:": "})]}),m=()=>r?null:(0,p.jsx)("span",{className:"json-punctuation",children:","});if(e.length===0)return(0,p.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[d(),(0,p.jsx)(Tn,{value:"[]",onCopy:l,alwaysVisible:!0,children:(0,p.jsx)("span",{className:"json-punctuation",children:"[]"})}),m()]});const v=y=>{y.stopPropagation(),o(t)};return u?(0,p.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,p.jsx)("button",{onClick:v,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,p.jsx)(fs,{className:"h-3 w-3"})}),d(),(0,p.jsxs)(Tn,{value:f,onCopy:l,alwaysVisible:!0,children:[(0,p.jsx)("span",{className:"json-punctuation",children:"["}),(0,p.jsxs)("span",{className:"text-muted-foreground text-xs px-1",children:[e.length," ",e.length===1?"item":"items"]}),(0,p.jsx)("span",{className:"json-punctuation",children:"]"})]}),m()]}):(0,p.jsxs)(g.Fragment,{children:[(0,p.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,p.jsx)("button",{onClick:v,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,p.jsx)(fs,{className:"h-3 w-3"})}),d(),(0,p.jsx)(Tn,{value:f,onCopy:l,alwaysVisible:!0,children:(0,p.jsx)("span",{className:"json-punctuation",children:"["})})]}),h.map((y,x)=>(0,p.jsx)(Wm,{value:y,path:`${t}.${x}`,isLast:x===e.length-1&&h.length===e.length,depth:i+1,isCollapsed:s,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l},`${t}.${x}`)),h.length<e.length&&(0,p.jsxs)("div",{className:"leading-5 text-muted-foreground text-xs",style:{paddingLeft:(i+1)*16},children:["Loading ",e.length-h.length," more items..."]}),(0,p.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,p.jsx)("span",{className:"json-punctuation",children:"]"}),m()]})]})}function n$({value:e,path:t,keyName:n,isLast:r=!0,depth:i=0,isCollapsed:s,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}){const c=i*16,u=s(t),h=Object.entries(e),f=oC(h,!u),d=(0,g.useCallback)(()=>JSON.stringify(e,null,2),[e]),m=()=>n===void 0?null:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"json-key",children:['"',n,'"']}),(0,p.jsx)("span",{className:"json-punctuation",children:": "})]}),v=()=>r?null:(0,p.jsx)("span",{className:"json-punctuation",children:","});if(h.length===0)return(0,p.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[m(),(0,p.jsx)(Tn,{value:"{}",onCopy:l,alwaysVisible:!0,children:(0,p.jsx)("span",{className:"json-punctuation",children:"{}"})}),v()]});const y=x=>{x.stopPropagation(),o(t)};return u?(0,p.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,p.jsx)("button",{onClick:y,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,p.jsx)(fs,{className:"h-3 w-3"})}),m(),(0,p.jsxs)(Tn,{value:d,onCopy:l,alwaysVisible:!0,children:[(0,p.jsx)("span",{className:"json-punctuation",children:"{"}),(0,p.jsxs)("span",{className:"text-muted-foreground text-xs px-1",children:[h.length," ",h.length===1?"key":"keys"]}),(0,p.jsx)("span",{className:"json-punctuation",children:"}"})]}),v()]}):(0,p.jsxs)(g.Fragment,{children:[(0,p.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,p.jsx)("button",{onClick:y,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,p.jsx)(fs,{className:"h-3 w-3"})}),m(),(0,p.jsx)(Tn,{value:d,onCopy:l,alwaysVisible:!0,children:(0,p.jsx)("span",{className:"json-punctuation",children:"{"})})]}),f.map(([x,b],w)=>(0,p.jsx)(Wm,{value:b,path:`${t}.${x}`,keyName:x,isLast:w===h.length-1&&f.length===h.length,depth:i+1,isCollapsed:s,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l},`${t}.${x}`)),f.length<h.length&&(0,p.jsxs)("div",{className:"leading-5 text-muted-foreground text-xs",style:{paddingLeft:(i+1)*16},children:["Loading ",h.length-f.length," more keys..."]}),(0,p.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,p.jsx)("span",{className:"json-punctuation",children:"}"}),v()]})]})}function r$({value:e,path:t,keyName:n,isLast:r=!0,depth:i=0,isCollapsed:s,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}){const c=i*16,u=()=>{if(e===null)return(0,p.jsx)(Tn,{value:"null",onCopy:l,children:(0,p.jsx)("span",{className:"json-null",children:"null"})});if(typeof e=="boolean")return(0,p.jsx)(Tn,{value:String(e),onCopy:l,children:(0,p.jsx)("span",{className:e?"json-boolean":"json-boolean-false",children:String(e)})});if(typeof e=="number")return(0,p.jsx)(Tn,{value:String(e),onCopy:l,children:(0,p.jsx)("span",{className:"json-number",children:String(e)})});if(typeof e=="string"){const d=JSON.stringify(e);return a!==void 0?(0,p.jsx)(rC,{value:e,displayValue:d,maxLength:a,onCopy:l}):(0,p.jsx)(Tn,{value:e,onCopy:l,children:(0,p.jsx)("span",{className:"json-string",children:d})})}return null},h=()=>n===void 0?null:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"json-key",children:['"',n,'"']}),(0,p.jsx)("span",{className:"json-punctuation",children:": "})]}),f=()=>r?null:(0,p.jsx)("span",{className:"json-punctuation",children:","});return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"?(0,p.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[h(),u(),f()]}):Array.isArray(e)?(0,p.jsx)(t$,{value:e,path:t,keyName:n,isLast:r,depth:i,isCollapsed:s,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}):typeof e=="object"?(0,p.jsx)(n$,{value:e,path:t,keyName:n,isLast:r,depth:i,isCollapsed:s,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}):(0,p.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[h(),(0,p.jsx)("span",{className:"text-muted-foreground",children:"undefined"}),f()]})}function i$(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 Wm=(0,g.memo)(r$,i$);function s$({value:e,className:t,height:n,maxHeight:r,defaultExpandDepth:i,collapsedPaths:s,onCollapseChange:o,collapseStringsAfterLength:a,onCopy:l}){const{isCollapsed:c,toggleCollapse:u}=Xz({value:e,defaultExpandDepth:i,initialCollapsedPaths:s,onCollapseChange:o});return(0,p.jsx)("div",{className:G("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,p.jsx)(Wm,{value:e,path:"root",isCollapsed:c,toggleCollapse:u,collapseStringsAfterLength:a,onCopy:l})})}function ud({value:e,className:t,height:n,maxHeight:r,showLineNumbers:i=!0,collapseStringsAfterLength:s,wrapLongLinesInView:o=!0,collapsible:a=!1,defaultExpandDepth:l,collapsedPaths:c,onCollapseChange:u}){const h=(0,g.useMemo)(()=>{if(e==null)return"null";try{return JSON.stringify(e,null,2)}catch{return String(e)}},[e]);return a?(0,p.jsx)(s$,{value:e,className:t,height:n??"100%",maxHeight:r,defaultExpandDepth:l,collapsedPaths:c,onCollapseChange:u,collapseStringsAfterLength:s}):(0,p.jsx)(iC,{content:h,readOnly:!0,className:t,height:n??"100%",maxHeight:r,showLineNumbers:i,collapseStringsAfterLength:s,wrapLongLinesInView:o})}var aC=1024,o$=0,Rh=class{constructor(e,t){this.from=e,this.to=t}},ue=class{constructor(e={}){this.id=o$++,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=Bt.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};ue.closedBy=new ue({deserialize:e=>e.split(" ")});ue.openedBy=new ue({deserialize:e=>e.split(" ")});ue.group=new ue({deserialize:e=>e.split(" ")});ue.isolate=new ue({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});ue.contextHash=new ue({perNode:!0});ue.lookAhead=new ue({perNode:!0});ue.mounted=new ue({perNode:!0});var Eo=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[ue.mounted.id]}},a$=Object.create(null),Bt=class lC{constructor(t,n,r,i=0){this.name=t,this.props=n,this.id=r,this.flags=i}static define(t){let n=t.props&&t.props.length?Object.create(null):a$,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new lC(t.name||"",n,t.id,r);if(t.props){for(let s of t.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}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(ue.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 i of r.split(" "))n[i]=t[r];return r=>{for(let i=r.prop(ue.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}};Bt.none=new Bt("",Object.create(null),0,8);var l$=class cC{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 i=null;for(let s of t){let o=s(r);if(o){i||(i=Object.assign({},r.props));let a=o[1],l=o[0];l.combine&&l.id in i&&(a=l.combine(i[l.id],a)),i[l.id]=a}}n.push(i?new Bt(r.name,i,r.id,r.flags):r)}return new cC(n)}},tl=new WeakMap,ry=new WeakMap,Oe;(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"})(Oe||(Oe={}));var Ze=class hd{constructor(t,n,r,i,s){if(this.type=t,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,a]of s)this.props[typeof o=="number"?o:o.id]=a}}toString(){let t=Eo.get(this);if(t&&!t.overlay)return t.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}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 pd(this.topNode,t)}cursorAt(t,n=0,r=0){let i=tl.get(this)||this.topNode,s=new pd(i);return s.moveTo(t,n),tl.set(this,s._tree),s}get topNode(){return new Dr(this,0,0,null)}resolve(t,n=0){let r=Jo(tl.get(this)||this.topNode,t,n,!1);return tl.set(this,r),r}resolveInner(t,n=0){let r=Jo(ry.get(this)||this.topNode,t,n,!0);return ry.set(this,r),r}resolveStack(t,n=0){return f$(this,t,n)}iterate(t){let{enter:n,leave:r,from:i=0,to:s=this.length}=t,o=t.mode||0,a=(o&Oe.IncludeAnonymous)>0;for(let l=this.cursor(o|Oe.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=i&&(!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:qm(Bt.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new hd(this.type,n,r,i,this.propValues),t.makeTree||((n,r,i)=>new hd(Bt.none,n,r,i)))}static build(t){return d$(t)}};Ze.empty=new Ze(Bt.none,[],[],0);var c$=class uC{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 uC(this.buffer,this.index)}},xs=class hC{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return Bt.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],i=this.set.types[n],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),t+=4,r==t)return s;let o=[];for(;t<r;)o.push(this.childString(t)),t=this.buffer[t+3];return s+"("+o.join(",")+")"}findChild(t,n,r,i,s){let{buffer:o}=this,a=-1;for(let l=t;l!=n&&!(fC(s,i,o[l+1],o[l+2])&&(a=l,r>0));l=o[l+3]);return a}slice(t,n,r){let i=this.buffer,s=new Uint16Array(n-t),o=0;for(let a=t,l=0;a<n;){s[l++]=i[a++],s[l++]=i[a++]-r;let c=s[l++]=i[a++]-r;s[l++]=i[a++]-t,o=Math.max(o,c)}return new hC(s,o,this.set)}};function fC(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 Jo(e,t,n,r){for(var i;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 Dr&&e.index<0?null:e.parent;if(!o)return e;e=o}let s=r?0:Oe.IgnoreOverlays;if(r)for(let o=e,a=o.parent;a;o=a,a=o.parent)o instanceof Dr&&o.index<0&&((i=a.enter(t,n,s))===null||i===void 0?void 0:i.from)!=o.from&&(e=a);for(;;){let o=e.enter(t,n,s);if(!o)return e;e=o}}var dC=class{cursor(e=0){return new pd(this,e)}getChild(e,t=null,n=null){let r=iy(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return iy(this,e,t,n)}resolve(e,t=0){return Jo(this,e,t,!1)}resolveInner(e,t=0){return Jo(this,e,t,!0)}matchContext(e){return fd(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}},Dr=class Vl extends dC{constructor(t,n,r,i){super(),this._tree=t,this.from=n,this.index=r,this._parent=i}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,i,s=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],h=l[t]+o.from,f;if(!(!(s&Oe.EnterBracketed&&u instanceof Ze&&(f=Eo.get(u))&&!f.overlay&&f.bracketed&&r>=h&&r<=h+u.length)&&!fC(i,r,h,h+u.length))){if(u instanceof xs){if(s&Oe.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,n,r-h,i);if(d>-1)return new dd(new u$(o,u,t,h),null,d)}else if(s&Oe.IncludeAnonymous||!u.type.isAnonymous||Um(u)){let d;if(!(s&Oe.IgnoreMounts)&&(d=Eo.get(u))&&!d.overlay)return new Vl(d.tree,h,t,o);let m=new Vl(u,h,t,o);return s&Oe.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(n<0?u.children.length-1:0,n,r,i,s)}}}if(s&Oe.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 i;if(!(r&Oe.IgnoreOverlays)&&(i=Eo.get(this._tree))&&i.overlay){let s=t-this.from,o=r&Oe.EnterBracketed&&i.bracketed;for(let{from:a,to:l}of i.overlay)if((n>0||o?a<=s:a<s)&&(n<0||o?l>=s:l>s))return new Vl(i.tree,i.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 iy(e,t,n,r){let i=e.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(t)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function fd(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 u$=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},dd=class ao extends dC{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:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return s<0?null:new ao(this.context,this,s)}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&Oe.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return s<0?null:new ao(this.context,this,s)}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 ao(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 ao(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];t.push(r.slice(i,s,o)),n.push(0)}return new Ze(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function pC(e){if(!e.length)return null;let t=0,n=e[0];for(let s=1;s<e.length;s++){let o=e[s];(o.from>n.from||o.to<n.to)&&(n=o,t=s)}let r=n instanceof Dr&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new h$(i,n)}var h$=class{constructor(e,t){this.heads=e,this.node=t}get next(){return pC(this.heads)}};function f$(e,t,n){let r=e.resolveInner(t,n),i=null;for(let s=r instanceof Dr?r:r.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(i||(i=[r])).push(o.resolve(t,n)),s=o}else{let o=Eo.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let a=new Dr(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Jo(a,t,n,!1))}}return i?pC(i):r}var pd=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&~Oe.EnterBracketed,e instanceof Dr)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 Dr?(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,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}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&Oe.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Oe.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Oe.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 i=0;i<this.index;i++)if(r.buffer.buffer[i+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 i=t+e,s=e<0?-1:n._tree.children.length;i!=s;i+=e){let o=n._tree.children[i];if(this.mode&Oe.IncludeAnonymous||o instanceof xs||!o.type.isAnonymous||Um(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,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==r){if(r==this.index)return s;t=s,n=i+1;break e}r=this.stack[--i]}for(let r=n;r<this.stack.length;r++)t=new dd(this.buffer,t,this.stack[r]);return this.bufferNode=new dd(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 fd(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return fd(this._tree,e,r);let s=n[t.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[r]&&e[r]!=s.name)return!1;r--}}return!0}};function Um(e){return e.children.some(t=>t instanceof xs||!t.type.isAnonymous||Um(t))}function d$(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=aC,reused:s=[],minRepeatType:o=r.types.length}=e,a=Array.isArray(n)?new c$(n,n.length):n,l=r.types,c=0,u=0;function h(C,A,k,E,T,R){let{id:P,start:M,end:N,size:L}=a,I=u,_=c;if(L<0)if(a.next(),L==-1){let se=s[P];k.push(se),E.push(M-C);return}else if(L==-3){c=P;return}else if(L==-4){u=P;return}else throw new RangeError(`Unrecognized record size: ${L}`);let j=l[P],$,B,D=M-C;if(N-M<=i&&(B=y(a.pos-A,T))){let se=new Uint16Array(B.size-B.skip),ne=a.pos-B.size,F=se.length;for(;a.pos>ne;)F=x(B.start,se,F);$=new xs(se,N-B.start,r),D=B.start-C}else{let se=a.pos-L;a.next();let ne=[],F=[],q=P>=o?P:-1,K=0,Y=N;for(;a.pos>se;)q>=0&&a.id==q&&a.size>=0?(a.end<=Y-i&&(m(ne,F,M,K,a.end,Y,q,I,_),K=ne.length,Y=a.end),a.next()):R>2500?f(M,se,ne,F):h(M,se,ne,F,q,R+1);if(q>=0&&K>0&&K<ne.length&&m(ne,F,M,K,M,Y,q,I,_),ne.reverse(),F.reverse(),q>-1&&K>0){let H=d(j,_);$=qm(j,ne,F,0,ne.length,0,N-M,H,H)}else $=v(j,ne,F,N-M,I-N,_)}k.push($),E.push(D)}function f(C,A,k,E){let T=[],R=0,P=-1;for(;a.pos>A;){let{id:M,start:N,end:L,size:I}=a;if(I>4)a.next();else{if(P>-1&&N<P)break;P<0&&(P=L-i),T.push(M,N,L),R++,a.next()}}if(R){let M=new Uint16Array(R*4),N=T[T.length-2];for(let L=T.length-3,I=0;L>=0;L-=3)M[I++]=T[L],M[I++]=T[L+1]-N,M[I++]=T[L+2]-N,M[I++]=I;k.push(new xs(M,T[2]-N,r)),E.push(N-C)}}function d(C,A){return(k,E,T)=>{let R=0,P=k.length-1,M,N;if(P>=0&&(M=k[P])instanceof Ze){if(!P&&M.type==C&&M.length==T)return M;(N=M.prop(ue.lookAhead))&&(R=E[P]+M.length+N)}return v(C,k,E,T,R,A)}}function m(C,A,k,E,T,R,P,M,N){let L=[],I=[];for(;C.length>E;)L.push(C.pop()),I.push(A.pop()+k-T);C.push(v(r.types[P],L,I,R-T,M-R,N)),A.push(T-k)}function v(C,A,k,E,T,R,P){if(R){let M=[ue.contextHash,R];P=P?[M].concat(P):[M]}if(T>25){let M=[ue.lookAhead,T];P=P?[M].concat(P):[M]}return new Ze(C,A,k,E,P)}function y(C,A){let k=a.fork(),E=0,T=0,R=0,P=k.end-i,M={size:0,start:0,skip:0};e:for(let N=k.pos-C;k.pos>N;){let L=k.size;if(k.id==A&&L>=0){M.size=E,M.start=T,M.skip=R,R+=4,E+=4,k.next();continue}let I=k.pos-L;if(L<0||I<N||k.start<P)break;let _=k.id>=o?4:0,j=k.start;for(k.next();k.pos>I;){if(k.size<0)if(k.size==-3||k.size==-4)_+=4;else break e;else k.id>=o&&(_+=4);k.next()}T=j,E+=L,R+=_}return(A<0||E==C)&&(M.size=E,M.start=T,M.skip=R),M.size>4?M:void 0}function x(C,A,k){let{id:E,start:T,end:R,size:P}=a;if(a.next(),P>=0&&E<o){let M=k;if(P>4){let N=a.pos-(P-4);for(;a.pos>N;)k=x(C,A,k)}A[--k]=M,A[--k]=R-C,A[--k]=T-C,A[--k]=E}else P==-3?c=E:P==-4&&(u=E);return k}let b=[],w=[];for(;a.pos>0;)h(e.start||0,e.bufferStart||0,b,w,-1,0);let S=(t=e.length)!==null&&t!==void 0?t:b.length?w[0]+b[0].length:0;return new Ze(l[e.topID],b.reverse(),w.reverse(),S)}var sy=new WeakMap;function zl(e,t){if(!e.isAnonymous||t instanceof xs||t.type!=e)return 1;let n=sy.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof Ze)){n=1;break}n+=zl(e,r)}sy.set(t,n)}return n}function qm(e,t,n,r,i,s,o,a,l){let c=0;for(let m=r;m<i;m++)c+=zl(e,t[m]);let u=Math.ceil(c*1.5/8),h=[],f=[];function d(m,v,y,x,b){for(let w=y;w<x;){let S=w,C=v[w],A=zl(e,m[w]);for(w++;w<x;w++){let k=zl(e,m[w]);if(A+k>=u)break;A+=k}if(w==S+1){if(A>u){let k=m[S];d(k.children,k.positions,0,k.children.length,v[S]+b);continue}h.push(m[S])}else{let k=v[w-1]+m[w-1].length-C;h.push(qm(e,m,v,S,w,C,k,null,l))}f.push(C+b-s)}}return d(t,n,r,i,0),(a||l)(h,f,o)}var $l=class md{constructor(t,n,r,i,s=!1,o=!1){this.from=t,this.to=n,this.tree=r,this.offset=i,this.open=(s?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 i=[new md(0,t.length,t,0,!1,r)];for(let s of n)s.to>t.length&&i.push(s);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],s=1,o=t.length?t[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<n.length?n[a]:null,h=u?u.fromA:1e9;if(h-l>=r)for(;o&&o.from<h;){let f=o;if(l>=f.from||h<=f.to||c){let d=Math.max(f.from,l)-c,m=Math.min(f.to,h)-c;f=d>=m?null:new md(d,m,f.tree,f.offset+c,a>0,!!u)}if(f&&i.push(f),o.to>h)break;o=s<t.length?t[s++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}},mC=class{startParse(e,t,n){return typeof e=="string"&&(e=new p$(e)),n=n?n.length?n.map(r=>new Rh(r.from,r.to)):[new Rh(0,0)]:[new Rh(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let i=r.advance();if(i)return i}}},p$=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)}},H8=new ue({perNode:!0}),m$=class gd{constructor(t,n,r,i,s,o,a,l,c,u=0,h){this.p=t,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=h}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 i=t.parser.context;return new gd(t,[],n,r,r,0,[],0,i?new oy(i,i.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,i=t&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=s.dynamicPrecedence(i);if(a&&(this.score+=a),r==0){i<s.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(i,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;i<s.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[i])===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 h=l?this.stack[l-1]:0,f=this.bufferBase+this.buffer.length-h;if(i<s.minRepeatTerm||t&131072){let d=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,c,d,f+4,!0)}if(t&262144)this.state=this.stack[l];else{let d=this.stack[l-3];this.state=s.getGoto(d,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,c)}storeNode(t,n,r,i=4,s=!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(!s||this.pos==r)this.buffer.push(t,n,r,i);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,i>4&&(i-=4)}this.buffer[o]=t,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(t,n,r,i){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let s=t,{parser:o}=this.p;this.pos=i;let a=o.stateFlag(s,1);!a&&(i>r||n<=o.maxNode)&&(this.reducePos=i),this.pushState(s,a?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}else this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4)}apply(t,n,r,i){t&65536?this.reduce(t):this.shift(t,n,r,i)}useNode(t,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=t)&&(this.p.reused.push(t),r++);let i=this.pos;this.reducePos=this.pos=i+t.length,this.pushState(n,i),this.buffer.push(r,i,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),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new gd(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,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 g$(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 i=[];for(let s=0,o;s<n.length;s+=2)(o=n[s+1])!=this.state&&this.p.parser.hasAction(o,t)&&i.push(n[s],o);if(this.stack.length<120)for(let s=0;i.length<8&&s<n.length;s+=2){let o=n[s+1];i.some((a,l)=>l&1&&a==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i<n.length&&r.length<4;i+=2){let s=n[i+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[i],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,i=n&65535,s=this.stack.length-r*3;if(s<0||t.getGoto(this.stack[s],i,!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=(i,s)=>{if(!n.includes(i))return n.push(i),t.allActions(i,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;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,s+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 oy(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()}},oy=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},g$=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}},v$=class vd{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 vd(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 vd(this.stack,this.pos,this.index)}};function lo(e,t=Uint16Array){if(typeof e!="string")return e;let n=null;for(let r=0,i=0;r<e.length;){let s=0;for(;;){let o=e.charCodeAt(r++),a=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}n?n[i++]=s:n=new t(s)}return n}var Hl=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},ay=new Hl,y$=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=ay,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,i=this.pos+e;for(;i<n.from;){if(!r)return null;let s=this.ranges[--r];i-=n.from-s.to,n=s}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let s=this.ranges[++r];i+=s.from-n.to,n=s}return i}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 i=this.resolveOffset(e,1);if(i==null)return-1;if(n=i,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let s=this.rangeIndex,o=this.range;for(;o.to<=n;)o=this.ranges[++s];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=ay,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}},rs=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;gC(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};rs.prototype.contextual=rs.prototype.fallback=rs.prototype.extend=!1;var x$=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?lo(e):e}token(e,t){let n=e.pos,r=0;for(;;){let i=e.next<0,s=e.resolveOffset(1,1);if(gC(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(i||r++,s==null)break;e.reset(s,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};x$.prototype.contextual=rs.prototype.fallback=rs.prototype.extend=!1;function gC(e,t,n,r,i,s){let o=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;(a&e[o])!=0;){let c=e[o+1];for(let d=o+3;d<c;d+=2)if((e[d+1]&a)>0){let m=e[d];if(l.allows(m)&&(t.token.value==-1||t.token.value==m||b$(m,t.token.value,i,s))){t.acceptToken(m);break}}let u=t.next,h=0,f=e[o+2];if(t.next<0&&f>h&&e[c+f*3-3]==65535){o=e[c+f*3-1];continue e}for(;h<f;){let d=h+f>>1,m=c+d+(d<<1),v=e[m],y=e[m+1]||65536;if(u<v)f=d;else if(u>=y)h=d+1;else{o=e[m+2],t.advance();continue e}}break}}function ly(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function b$(e,t,n,r){let i=ly(n,r,t);return i<0||ly(n,r,e)<i}var At=typeof process<"u"&&/\bparse\b/.test({}.LOG),Ph=null;function cy(e,t,n){let r=e.cursor(Oe.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 w$=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?cy(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?cy(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 i=n.children[r],s=this.start[t]+n.positions[r];if(s>e)return this.nextStart=s,null;if(i instanceof Ze){if(s==e){if(s<this.safeFrom)return null;let o=s+i.length;if(o<=this.safeTo){let a=i.prop(ue.lookAhead);if(!a||o+a<this.fragment.to)return i}}this.index[t]++,s+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(s),this.index.push(0))}else this.index[t]++,this.nextStart=s+i.length}}},S$=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Hl)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,s=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,a=0;for(let l=0;l<i.length;l++){if((1<<l&s)==0)continue;let c=i[l],u=this.tokens[l];if(!(n&&!c.fallback)&&((c.contextual||u.start!=e.pos||u.mask!=s||u.context!=o)&&(this.updateCachedToken(u,c,e),u.mask=s,u.context=o),u.lookAhead>u.end+25&&(a=Math.max(u.lookAhead,a)),u.value!=0)){let h=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>h))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new Hl,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 Hl,{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:i}=n.p;for(let s=0;s<i.specialized.length;s++)if(i.specialized[s]==e.value){let o=i.specializers[s](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 i=0;i<r;i+=3)if(this.actions[i]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:s}=e.p,{data:o}=s;for(let a=0;a<2;a++)for(let l=s.stateSlot(i,a?2:1);;l+=3){if(o[l]==65535)if(o[l+1]==1)l=Un(o,l+2);else{r==0&&o[l+1]==2&&(r=this.putAction(Un(o,l+2),t,n,r));break}o[l]==t&&(r=this.putAction(Un(o,l+1),t,n,r))}return r}},k$=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 y$(t,r),this.tokens=new S$(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[m$.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new w$(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let o=e[s];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else{if(this.advanceStack(o,n,e))continue;{r||(r=[],i=[]),r.push(o);let a=this.tokens.getMainToken(o);i.push(a.value,a.end)}}break}}if(!n.length){let s=r&&T$(r);if(s)return At&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw At&&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 s=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(s)return At&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(n.length>s)for(n.sort((o,a)=>a.score-o.score);n.length>s;)n.pop();n.some(o=>o.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let s=0;s<n.length-1;s++){let o=n[s];for(let a=s+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(s--,1);continue e}}}n.length>12&&(n.sort((s,o)=>o.score-s.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let s=1;s<n.length;s++)n[s].pos<this.minStackPos&&(this.minStackPos=n[s].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:i}=this,s=At?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 h=this.parser.nodeSet.types[u.type.id]==u.type?i.getGoto(e.state,u.type.id):-1;if(h>-1&&u.length&&(!l||(u.prop(ue.contextHash)||0)==c))return e.useNode(u,h),At&&console.log(s+this.stackID(e)+` (via reuse of ${i.getName(u.type.id)})`),!0;if(!(u instanceof Ze)||u.children.length==0||u.positions[0]>0)break;let f=u.children[0];if(f instanceof Ze&&u.positions[0]==0)u=f;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),At&&console.log(s+this.stackID(e)+` (via always-reduce ${i.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++],h=a[l++],f=l==a.length||!n,d=f?e:e.split(),m=this.tokens.mainToken;if(d.apply(c,u,m?m.start:d.pos,h),At&&console.log(s+this.stackID(d)+` (via ${(c&65536)==0?"shift":`reduce of ${i.getName(c&65535)}`} for ${i.getName(u)} @ ${r}${d==e?"":", split"})`),f)return!0;d.pos>r?t.push(d):n.push(d)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return uy(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let s=0;s<e.length;s++){let o=e[s],a=t[s<<1],l=t[(s<<1)+1],c=At?this.stackID(o)+" -> ":"";if(o.deadEnd&&(i||(i=!0,o.restart(),At&&console.log(c+this.stackID(o)+" (restarted)"),this.advanceFully(o,n))))continue;let u=o.split(),h=c;for(let f=0;f<10&&u.forceReduce()&&(At&&console.log(h+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,n));f++)At&&(h=this.stackID(u)+" -> ");for(let f of o.recoverByInsert(a))At&&console.log(c+this.stackID(f)+" (via recover-insert)"),this.advanceFully(f,n);this.stream.end>o.pos?(l==o.pos&&(l++,a=0),o.recoverByDelete(a,l),At&&console.log(c+this.stackID(o)+` (via recover-delete ${this.parser.getName(a)})`),uy(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),Ze.build({buffer:v$.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=(Ph||(Ph=new WeakMap)).get(e);return t||Ph.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function uy(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 C$=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},A$=class yd extends mC{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]),i=[];for(let a=0;a<n.length;a++)i.push([]);function s(a,l,c){i[a].push([l,l.deserialize(String(c))])}if(t.nodeProps)for(let a of t.nodeProps){let l=a[0];typeof l=="string"&&(l=ue[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)s(u,l,a[c++]);else{let h=a[c+-u];for(let f=-u;f>0;f--)s(a[c++],l,h);c++}}}this.nodeSet=new l$(n.map((a,l)=>Bt.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:i[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=aC;let o=lo(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(hy),this.states=lo(t.states,Uint32Array),this.data=lo(t.stateData),this.goto=lo(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(a=>typeof a=="number"?new rs(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 i=new k$(this,t,n,r);for(let s of this.wrappers)i=s(i,t,n,r);return i}getGoto(t,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],a=o&1,l=i[s++];if(a&&r)return l;for(let c=s+(o>>1);s<c;s++)if(i[s]==t)return l;if(a)return-1}}hasAction(t,n){let r=this.data;for(let i=0;i<2;i++)for(let s=this.stateSlot(t,i?2:1),o;;s+=3){if((o=r[s])==65535)if(r[s+1]==1)o=r[s=Un(r,s+2)];else{if(r[s+1]==2)return Un(r,s+2);break}if(o==n||o==0)return Un(r,s+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),i=r?n(r):void 0;for(let s=this.stateSlot(t,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Un(this.data,s+2);else break;i=n(Un(this.data,s+1))}return i}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=Un(this.data,r+2);else break;if((this.data[r+2]&1)==0){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(t){let n=Object.assign(Object.create(yd.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 i=t.tokenizers.find(s=>s.from==r);return i?i.to:r})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=t.specializers.find(a=>a.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=hy(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 s of t.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;s<n.length;s++)if(!r[s])for(let o=this.dialects[n[s]],a;(a=this.data[o++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[a]=1;return new C$(t,r,i)}static deserialize(t){return new yd(t)}};function Un(e,t){return e[t]|e[t+1]<<16}function T$(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 hy(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}var E$=0,qn=class xd{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=E$++}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 xd&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new xd(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(t){let n=new fy(t);return r=>r.modified.indexOf(n)>-1?r:fy.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}},M$=0,fy=class vC{constructor(t){this.name=t,this.instances=[],this.id=M$++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(a=>a.base==t&&R$(n,a.modified));if(r)return r;let i=[],s=new qn(t.name,i,t,n);for(let a of n)a.instances.push(s);let o=P$(n);for(let a of t.set)if(!a.modified.length)for(let l of o)i.push(vC.get(a,l));return s}};function R$(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function P$(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((n,r)=>r.length-n.length)}function yC(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,a=i;for(let u=0;;){if(a=="..."&&u>0&&u+3==i.length){o=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+i);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),u+=h[0].length,u==i.length)break;let f=i[u++];if(u==i.length&&f=="!"){o=0;break}if(f!="/")throw new RangeError("Invalid path: "+i);a=i.slice(u)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+i);t[c]=new Zo(r,o,l>0?s.slice(0,l):null).sort(t[c])}}return xC.add(t)}var xC=new ue({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth<=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let s=new Zo(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}}),Zo=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}};Zo.empty=new Zo([],2,null);function bC(e,t){let n=Object.create(null);for(let s of e)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let o of s.tag)n[o.id]=s.class;let{scope:r,all:i=null}=t||{};return{style:s=>{let o=i;for(let a of s)for(let l of a.set){let c=n[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:r}}function I$(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function O$(e,t,n,r=0,i=e.length){let s=new D$(r,Array.isArray(t)?t:[t],n);s.highlightRange(e.cursor(),r,i,"",s.highlighters),s.flush(i)}var D$=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,i){let{type:s,from:o,to:a}=e;if(o>=n||a<=t)return;s.isTop&&(i=this.highlighters.filter(f=>!f.scope||f.scope(s)));let l=r,c=N$(e)||Zo.empty,u=I$(i,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 h=e.tree&&e.tree.prop(ue.mounted);if(h&&h.overlay){let f=e.node.enter(h.overlay[0].from+o,1),d=this.highlighters.filter(v=>!v.scope||v.scope(h.tree.type)),m=e.firstChild();for(let v=0,y=o;;v++){let x=v<h.overlay.length?h.overlay[v]:null,b=x?x.from+o:a,w=Math.max(t,y),S=Math.min(n,b);if(w<S&&m)for(;e.from<S&&(this.highlightRange(e,w,S,r,i),this.startSpan(Math.min(S,e.to),l),!(e.to>=b||!e.nextSibling())););if(!x||b>n)break;y=x.to+o,y>t&&(this.highlightRange(f.cursor(),Math.max(t,x.from+o),Math.min(n,y),"",d),this.startSpan(Math.min(n,y),l))}m&&e.parent()}else if(e.firstChild()){h&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),l)}while(e.nextSibling());e.parent()}}};function N$(e){let t=e.type.prop(xC);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var W=qn.define,nl=W(),yr=W(),dy=W(yr),py=W(yr),xr=W(),rl=W(xr),Ih=W(xr),yn=W(),Kr=W(yn),mn=W(),gn=W(),bd=W(),Ks=W(bd),il=W(),V={comment:nl,lineComment:W(nl),blockComment:W(nl),docComment:W(nl),name:yr,variableName:W(yr),typeName:dy,tagName:W(dy),propertyName:py,attributeName:W(py),className:W(yr),labelName:W(yr),namespace:W(yr),macroName:W(yr),literal:xr,string:rl,docString:W(rl),character:W(rl),attributeValue:W(rl),number:Ih,integer:W(Ih),float:W(Ih),bool:W(xr),regexp:W(xr),escape:W(xr),color:W(xr),url:W(xr),keyword:mn,self:W(mn),null:W(mn),atom:W(mn),unit:W(mn),modifier:W(mn),operatorKeyword:W(mn),controlKeyword:W(mn),definitionKeyword:W(mn),moduleKeyword:W(mn),operator:gn,derefOperator:W(gn),arithmeticOperator:W(gn),logicOperator:W(gn),bitwiseOperator:W(gn),compareOperator:W(gn),updateOperator:W(gn),definitionOperator:W(gn),typeOperator:W(gn),controlOperator:W(gn),punctuation:bd,separator:W(bd),bracket:Ks,angleBracket:W(Ks),squareBracket:W(Ks),paren:W(Ks),brace:W(Ks),content:yn,heading:Kr,heading1:W(Kr),heading2:W(Kr),heading3:W(Kr),heading4:W(Kr),heading5:W(Kr),heading6:W(Kr),contentSeparator:W(yn),list:W(yn),quote:W(yn),emphasis:W(yn),strong:W(yn),link:W(yn),monospace:W(yn),strikethrough:W(yn),inserted:W(),deleted:W(),changed:W(),invalid:W(),meta:il,documentMeta:W(il),annotation:W(il),processingInstruction:W(il),definition:qn.defineModifier("definition"),constant:qn.defineModifier("constant"),function:qn.defineModifier("function"),standard:qn.defineModifier("standard"),local:qn.defineModifier("local"),special:qn.defineModifier("special")};for(let e in V){let t=V[e];t instanceof qn&&(t.name=e)}var W8=bC([{tag:V.link,class:"tok-link"},{tag:V.heading,class:"tok-heading"},{tag:V.emphasis,class:"tok-emphasis"},{tag:V.strong,class:"tok-strong"},{tag:V.keyword,class:"tok-keyword"},{tag:V.atom,class:"tok-atom"},{tag:V.bool,class:"tok-bool"},{tag:V.url,class:"tok-url"},{tag:V.labelName,class:"tok-labelName"},{tag:V.inserted,class:"tok-inserted"},{tag:V.deleted,class:"tok-deleted"},{tag:V.literal,class:"tok-literal"},{tag:V.string,class:"tok-string"},{tag:V.number,class:"tok-number"},{tag:[V.regexp,V.escape,V.special(V.string)],class:"tok-string2"},{tag:V.variableName,class:"tok-variableName"},{tag:V.local(V.variableName),class:"tok-variableName tok-local"},{tag:V.definition(V.variableName),class:"tok-variableName tok-definition"},{tag:V.special(V.variableName),class:"tok-variableName2"},{tag:V.definition(V.propertyName),class:"tok-propertyName tok-definition"},{tag:V.typeName,class:"tok-typeName"},{tag:V.namespace,class:"tok-namespace"},{tag:V.className,class:"tok-className"},{tag:V.macroName,class:"tok-macroName"},{tag:V.propertyName,class:"tok-propertyName"},{tag:V.operator,class:"tok-operator"},{tag:V.comment,class:"tok-comment"},{tag:V.meta,class:"tok-meta"},{tag:V.invalid,class:"tok-invalid"},{tag:V.punctuation,class:"tok-punctuation"}]),L$=yC({String:V.string,Number:V.number,"True False":V.bool,PropertyName:V.propertyName,Null:V.null,", :":V.separator,"[ ]":V.squareBracket,"{ }":V.brace}),_$=A$.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:[L$],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}),wd=[],wC=[];(()=>{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?wC:wd).push(n=n+e[t])})();function j$(e){if(e<768)return!1;for(let t=0,n=wd.length;;){let r=t+n>>1;if(e<wd[r])n=r;else if(e>=wC[r])t=r+1;else return!0;if(t==n)return!1}}function my(e){return e>=127462&&e<=127487}var gy=8205;function B$(e,t,n=!0,r=!0){return(n?SC:F$)(e,t,r)}function SC(e,t,n){if(t==e.length)return t;t&&kC(e.charCodeAt(t))&&CC(e.charCodeAt(t-1))&&t--;let r=Oh(e,t);for(t+=vy(r);t<e.length;){let i=Oh(e,t);if(r==gy||i==gy||n&&j$(i))t+=vy(i),r=i;else if(my(i)){let s=0,o=t-2;for(;o>=0&&my(Oh(e,o));)s++,o-=2;if(s%2==0)break;t+=2}else break}return t}function F$(e,t,n){for(;t>0;){let r=SC(e,t-2,n);if(r<t)return r;t--}return 0}function Oh(e,t){let n=e.charCodeAt(t);if(!CC(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return kC(r)?(n-55296<<10)+(r-56320)+65536:n}function kC(e){return e>=56320&&e<57344}function CC(e){return e>=55296&&e<56320}function vy(e){return e<65536?1:2}var me=class AC{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]=bs(this,t,n);let i=[];return this.decompose(0,t,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Wl.from(i,this.length-(n-t)+r.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,n=this.length){[t,n]=bs(this,t,n);let r=[];return this.decompose(t,n,r,0),Wl.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),i=new Mo(this),s=new Mo(t);for(let o=n,a=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(a+=i.value.length,i.done||a>=r)return!0}}iter(t=1){return new Mo(this,t)}iterRange(t,n=this.length){return new TC(this,t,n)}iterLines(t,n){let r;if(t==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(t).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new EC(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]?AC.empty:t.length<=32?new Xt(t):Wl.from(Xt.split(t,[]))}},Xt=class xn extends me{constructor(t,n=V$(t)){super(),this.text=t,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(t,n,r,i){for(let s=0;;s++){let o=this.text[s],a=i+o.length;if((n?r:a)>=t)return new z$(i,a,r,o);i=a+1,r++}}decompose(t,n,r,i){let s=t<=0&&n>=this.length?this:new xn(yy(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let o=r.pop(),a=Ul(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new xn(a,o.length+s.length));else{let l=a.length>>1;r.push(new xn(a.slice(0,l)),new xn(a.slice(l)))}}else r.push(s)}replace(t,n,r){if(!(r instanceof xn))return super.replace(t,n,r);[t,n]=bs(this,t,n);let i=Ul(this.text,Ul(r.text,yy(this.text,0,t)),n),s=this.length+r.length-(n-t);return i.length<=32?new xn(i,s):Wl.from(xn.split(i,[]),s)}sliceString(t,n=this.length,r=`
53
- `){[t,n]=bs(this,t,n);let i="";for(let s=0,o=0;s<=n&&o<this.text.length;o++){let a=this.text[o],l=s+a.length;s>t&&o&&(i+=r),t<l&&n>s&&(i+=a.slice(Math.max(0,t-s),n-s)),s=l+1}return i}flatten(t){for(let n of this.text)t.push(n)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let s of t)r.push(s),i+=s.length+1,r.length==32&&(n.push(new xn(r,i)),r=[],i=-1);return i>-1&&n.push(new xn(r,i)),n}},Wl=class zi extends me{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,i){for(let s=0;;s++){let o=this.children[s],a=i+o.length,l=r+o.lines-1;if((n?l:a)>=t)return o.lineInner(t,n,r,i);i=a+1,r=l+1}}decompose(t,n,r,i){for(let s=0,o=0;o<=n&&s<this.children.length;s++){let a=this.children[s],l=o+a.length;if(t<=l&&n>=o){let c=i&((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]=bs(this,t,n),r.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let o=this.children[i],a=s+o.length;if(t>=s&&n<=a){let l=o.replace(t-s,n-s,r),c=this.lines-o.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[i]=l,new zi(u,this.length-(n-t)+r.length)}return super.replace(s,a,l)}s=a+1}return super.replace(t,n,r)}sliceString(t,n=this.length,r=`
54
- `){[t,n]=bs(this,t,n);let i="";for(let s=0,o=0;s<this.children.length&&o<=n;s++){let a=this.children[s],l=o+a.length;o>t&&s&&(i+=r),t<l&&n>o&&(i+=a.sliceString(t-o,n-o,r)),o=l+1}return i}flatten(t){for(let n of this.children)n.flatten(t)}scanIdentical(t,n){if(!(t instanceof zi))return 0;let r=0,[i,s,o,a]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==a)return r;let l=this.children[i],c=t.children[s];if(l!=c)return r+l.scanIdentical(c,n);r+=l.length+1}}static from(t,n=t.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let d of t)r+=d.lines;if(r<32){let d=[];for(let m of t)m.flatten(d);return new Xt(d,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,a=[],l=0,c=-1,u=[];function h(d){let m;if(d.lines>s&&d instanceof zi)for(let v of d.children)h(v);else d.lines>o&&(l>o||!l)?(f(),a.push(d)):d instanceof Xt&&l&&(m=u[u.length-1])instanceof Xt&&d.lines+m.lines<=32?(l+=d.lines,c+=d.length+1,u[u.length-1]=new Xt(m.text.concat(d.text),m.length+1+d.length)):(l+d.lines>i&&f(),l+=d.lines,c+=d.length+1,u.push(d))}function f(){l!=0&&(a.push(u.length==1?u[0]:zi.from(u,c)),c=-1,l=u.length=0)}for(let d of t)h(d);return f(),a.length==1?a[0]:new zi(a,n)}};me.empty=new Xt([""],0);function V$(e){let t=-1;for(let n of e)t+=n.length+1;return t}function Ul(e,t,n=0,r=1e9){for(let i=0,s=0,o=!0;s<e.length&&i<=r;s++){let a=e[s],l=i+a.length;l>=n&&(l>r&&(a=a.slice(0,r-i)),i<n&&(a=a.slice(n-i)),o?(t[t.length-1]+=a,o=!1):t.push(a)),i=l+1}return t}function yy(e,t,n){return Ul(e,[""],t,n)}var Mo=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 Xt?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],i=this.offsets[n],s=i>>1,o=r instanceof Xt?r.text.length:r.children.length;if(s==(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((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
55
- `,this;e--}else if(r instanceof Xt){let a=r.text[s+(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[s+(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 Xt?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)}},TC=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Mo(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!=""}},EC=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"&&(me.prototype[Symbol.iterator]=function(){return this.iter()},Mo.prototype[Symbol.iterator]=TC.prototype[Symbol.iterator]=EC.prototype[Symbol.iterator]=function(){return this});var z$=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 bs(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function ct(e,t,n=!0,r=!0){return B$(e,t,n,r)}function $$(e){return e>=56320&&e<57344}function H$(e){return e>=55296&&e<56320}function W$(e,t){let n=e.charCodeAt(t);if(!H$(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return $$(r)?(n-55296<<10)+(r-56320)+65536:n}function U$(e){return e<65536?1:2}var Sd=/\r\n?|\n/,Mt=(function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e})(Mt||(Mt={})),is=class ql{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,i=0;n<this.sections.length;){let s=this.sections[n++],o=this.sections[n++];o<0?(t(r,i,s),i+=s):i+=o,r+=s}}iterChangedRanges(t,n=!1){kd(this,t,n)}get invertedDesc(){let t=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];i<0?t.push(r,i):t.push(i,r)}return new ql(t)}composeDesc(t){return this.empty?t:t.empty?this:MC(this,t)}mapDesc(t,n=!1){return t.empty?this:Cd(this,t,n)}mapPos(t,n=-1,r=Mt.Simple){let i=0,s=0;for(let o=0;o<this.sections.length;){let a=this.sections[o++],l=this.sections[o++],c=i+a;if(l<0){if(c>t)return s+(t-i);s+=a}else{if(r!=Mt.Simple&&c>=t&&(r==Mt.TrackDel&&i<t&&c>t||r==Mt.TrackBefore&&i<t||r==Mt.TrackAfter&&c>t))return null;if(c>t||c==t&&n<0&&!a)return t==i||n<0?s:s+l;s+=l}i=c}if(t>i)throw new RangeError(`Position ${t} is out of range for changeset of length ${i}`);return s}touchesRange(t,n=t){for(let r=0,i=0;r<this.sections.length&&i<=n;){let s=this.sections[r++],o=this.sections[r++],a=i+s;if(o>=0&&i<=n&&a>=t)return i<t&&a>n?"cover":!0;i=a}return!1}toString(){let t="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];t+=(t?" ":"")+r+(i>=0?":"+i:"")}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 ql(t)}static create(t){return new ql(t)}},on=class pr extends is{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 kd(this,(n,r,i,s,o)=>t=t.replace(i,i+(r-n),o),!1),t}mapDesc(t,n=!1){return Cd(this,t,n,!0)}invert(t){let n=this.sections.slice(),r=[];for(let i=0,s=0;i<n.length;i+=2){let o=n[i],a=n[i+1];if(a>=0){n[i]=a,n[i+1]=o;let l=i>>1;for(;r.length<l;)r.push(me.empty);r.push(o?t.slice(s,s+o):me.empty)}s+=o}return new pr(n,r)}compose(t){return this.empty?t:t.empty?this:MC(this,t,!0)}map(t,n=!1){return t.empty?this:Cd(this,t,n,!0)}iterChanges(t,n=!1){kd(this,t,n)}get desc(){return is.create(this.sections)}filter(t){let n=[],r=[],i=[],s=new ea(this);e:for(let o=0,a=0;;){let l=o==t.length?1e9:t[o++];for(;a<l||a==l&&s.len==0;){if(s.done)break e;let u=Math.min(s.len,l-a);lt(i,u,-1);let h=s.ins==-1?-1:s.off==0?s.ins:0;lt(n,u,h),h>0&&Ar(r,n,s.text),s.forward(u),a+=u}let c=t[o++];for(;a<c;){if(s.done)break e;let u=Math.min(s.len,c-a);lt(n,u,-1),lt(i,u,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(u),a+=u}}return{changes:new pr(n,r),filtered:is.create(i)}}toJSON(){let t=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],i=this.sections[n+1];i<0?t.push(r):i==0?t.push([r]):t.push([r].concat(this.inserted[n>>1].toJSON()))}return t}static of(t,n,r){let i=[],s=[],o=0,a=null;function l(u=!1){if(!u&&!i.length)return;o<n&&lt(i,n-o,-1);let h=new pr(i,s);a=a?a.compose(h.map(a)):h,i=[],s=[],o=0}function c(u){if(Array.isArray(u))for(let h of u)c(h);else if(u instanceof pr){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:h,to:f=h,insert:d}=u;if(h>f||h<0||f>n)throw new RangeError(`Invalid change range ${h} to ${f} (in doc of length ${n})`);let m=d?typeof d=="string"?me.of(d.split(r||Sd)):d:me.empty,v=m.length;if(h==f&&v==0)return;h<o&&l(),h>o&&lt(i,h-o,-1),lt(i,f-h,v),Ar(s,i,m),o=f}}return c(t),l(!a),a}static empty(t){return new pr(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;i<t.length;i++){let s=t[i];if(typeof s=="number")n.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,a)=>a&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length<i;)r.push(me.empty);r[i]=me.of(s.slice(1)),n.push(s[0],r[i].length)}}}return new pr(n,r)}static createSet(t,n){return new pr(t,n)}};function lt(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function Ar(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(me.empty);e.push(n)}}function kd(e,t,n){let r=e.inserted;for(let i=0,s=0,o=0;o<e.sections.length;){let a=e.sections[o++],l=e.sections[o++];if(l<0)i+=a,s+=a;else{let c=i,u=s,h=me.empty;for(;c+=a,u+=l,l&&r&&(h=h.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)a=e.sections[o++],l=e.sections[o++];t(i,c,s,u,h),i=c,s=u}}}function Cd(e,t,n,r=!1){let i=[],s=r?[]:null,o=new ea(e),a=new ea(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);lt(i,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(lt(i,a.ins,-1);c;){let u=Math.min(o.len,c);o.ins>=0&&l<o.i&&o.len<=u&&(lt(i,0,o.ins),s&&Ar(s,i,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 h=Math.min(u,a.len);c+=h,u-=h,a.forward(h)}else if(a.ins==0&&a.len<u)u-=a.len,a.next();else break;lt(i,c,l<o.i?o.ins:0),s&&l<o.i&&Ar(s,i,o.text),l=o.i,o.forward(o.len-u)}else{if(o.done&&a.done)return s?on.createSet(i,s):is.create(i);throw new Error("Mismatched change set lengths")}}}function MC(e,t,n=!1){let r=[],i=n?[]:null,s=new ea(e),o=new ea(t);for(let a=!1;;){if(s.done&&o.done)return i?on.createSet(r,i):is.create(r);if(s.ins==0)lt(r,s.len,0,a),s.next();else if(o.len==0&&!o.done)lt(r,0,o.ins,a),i&&Ar(i,r,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let l=Math.min(s.len2,o.len),c=r.length;if(s.ins==-1){let u=o.ins==-1?-1:o.off?0:o.ins;lt(r,l,u,a),i&&u&&Ar(i,r,o.text)}else o.ins==-1?(lt(r,s.off?0:s.len,l,a),i&&Ar(i,r,s.textBit(l))):(lt(r,s.off?0:s.len,o.off?0:o.ins,a),i&&!o.off&&Ar(i,r,o.text));a=(s.ins>l||o.ins>=0&&o.len>l)&&(a||r.length>c),s.forward2(l),o.forward(l)}}}}var ea=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?me.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?me.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)}},Gs=class Ad{constructor(t,n,r,i){this.from=t,this.to=n,this.flags=r,this.goalColumn=i}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,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new Ad(r,i,this.flags,this.goalColumn)}extend(t,n=t,r=0){if(t<=this.anchor&&n>=this.anchor)return z.range(t,n,void 0,void 0,r);let i=Math.abs(t-this.anchor)>Math.abs(n-this.anchor)?t:n;return z.range(this.anchor,i,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 z.range(t.anchor,t.head)}static create(t,n,r,i){return new Ad(t,n,r,i)}},z=class Tt{constructor(t,n){this.ranges=t,this.mainIndex=n}map(t,n=-1){return t.empty?this:Tt.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 Tt([this.main],0)}addRange(t,n=!0){return Tt.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,Tt.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 Tt(t.ranges.map(n=>Gs.fromJSON(n)),t.main)}static single(t,n=t){return new Tt([Tt.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,i=0;i<t.length;i++){let s=t[i];if(s.empty?s.from<=r:s.from<r)return Tt.normalized(t.slice(),n);r=s.to}return new Tt(t,n)}static cursor(t,n=0,r,i){return Gs.create(t,t,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r)),i)}static range(t,n,r,i,s){let o=i==null?7:Math.min(6,i);return!s&&t!=n&&(s=n<t?1:-1),s&&(o|=s<0?8:16),n<t?Gs.create(n,t,o|32,r):Gs.create(t,n,o,r)}static undirectionalRange(t,n){return Gs.create(t,n,64,void 0)}static normalized(t,n=0){let r=t[n];t.sort((i,s)=>i.from-s.from),n=t.indexOf(r);for(let i=1;i<t.length;i++){let s=t[i],o=t[i-1];if(s.empty?s.from<=o.to:s.from<o.to){let a=o.from,l=Math.max(s.to,o.to);i<=n&&n--,t.splice(--i,2,s.anchor>s.head?Tt.range(l,a):Tt.range(a,l))}}return new Tt(t,n)}};function RC(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}var Km=0,ee=class PC{constructor(t,n,r,i,s){this.combine=t,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=Km++,this.default=t([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(t={}){return new PC(t.combine||(n=>n),t.compareInput||((n,r)=>n===r),t.compare||(t.combine?(n,r)=>n===r:Gm),!!t.static,t.enables)}of(t){return new Kl([],this,0,t)}compute(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Kl(t,this,1,n)}computeN(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Kl(t,this,2,n)}from(t,n){return n||(n=r=>r),this.compute([t],r=>n(r.field(t)))}};function Gm(e,t){return e==t||e.length==t.length&&e.every((n,r)=>n===t[r])}var Kl=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Km++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,i=this.id,s=e[i]>>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[s]=n(u),1},update(u,h){if(a&&h.docChanged||l&&(h.docChanged||h.selection)||Td(u,c)){let f=n(u);if(o?!xy(f,u.values[s],r):!r(f,u.values[s]))return u.values[s]=f,1}return 0},reconfigure:(u,h)=>{let f,d=h.config.address[i];if(d!=null){let m=Ac(h,d);if(this.dependencies.every(v=>v instanceof ee?h.facet(v)===u.facet(v):v instanceof Ma?h.field(v,!1)==u.field(v,!1):!0)||(o?xy(f=n(u),m,r):r(f=n(u),m)))return u.values[s]=m,0}else f=n(u);return u.values[s]=f,1}}}get extension(){return this}};function xy(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 Td(e,t){let n=!1;for(let r of t)Ro(e,r)&1&&(n=!0);return n}function q$(e,t,n){let r=n.map(l=>e[l.id]),i=n.map(l=>l.type),s=r.filter(l=>!(l&1)),o=e[t.id]>>1;function a(l){let c=[];for(let u=0;u<r.length;u++){let h=Ac(l,r[u]);if(i[u]==2)for(let f of h)c.push(f);else c.push(h)}return t.combine(c)}return{create(l){for(let c of r)Ro(l,c);return l.values[o]=a(l),1},update(l,c){if(!Td(l,s))return 0;let u=a(l);return t.compare(u,l.values[o])?0:(l.values[o]=u,1)},reconfigure(l,c){let u=Td(l,r),h=c.config.facets[t.id],f=c.facet(t);if(h&&!u&&Gm(n,h))return l.values[o]=f,0;let d=a(l);return t.compare(d,f)?(l.values[o]=f,0):(l.values[o]=d,1)}}}var sl=ee.define({static:!0}),Ma=class IC{constructor(t,n,r,i,s){this.id=t,this.createF=n,this.updateF=r,this.compareF=i,this.spec=s,this.provides=void 0}static define(t){let n=new IC(Km++,t.create,t.update,t.compare||((r,i)=>r===i),t);return t.provide&&(n.provides=t.provide(n)),n}create(t){let n=t.facet(sl).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,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let s=r.facet(sl),o=i.facet(sl),a;return(a=s.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(r.values[n]=a.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(t){return[this,sl.of({field:this,create:t})]}get extension(){return this}},ti={lowest:4,low:3,default:2,high:1,highest:0};function Qs(e){return t=>new OC(t,e)}var vu={highest:Qs(ti.highest),high:Qs(ti.high),default:Qs(ti.default),low:Qs(ti.low),lowest:Qs(ti.lowest)},OC=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},DC=class NC{of(t){return new Ed(this,t)}reconfigure(t){return NC.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}},Ed=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},by=class LC{constructor(t,n,r,i,s,o){for(this.base=t,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,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 i=[],s=Object.create(null),o=new Map;for(let f of K$(t,n,o))f instanceof Ma?i.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let a=Object.create(null),l=[],c=[];for(let f of i)a[f.id]=c.length<<1,c.push(d=>f.slot(d));let u=r?.config.facets;for(let f in s){let d=s[f],m=d[0].facet,v=u&&u[f]||[];if(d.every(y=>y.type==0))if(a[m.id]=l.length<<1|1,Gm(v,d))l.push(r.facet(m));else{let y=m.combine(d.map(x=>x.value));l.push(r&&m.compare(y,r.facet(m))?r.facet(m):y)}else{for(let y of d)y.type==0?(a[y.id]=l.length<<1|1,l.push(y.value)):(a[y.id]=c.length<<1,c.push(x=>y.dynamicSlot(x)));a[m.id]=c.length<<1,c.push(y=>q$(y,m,d))}}let h=c.map(f=>f(a));return new LC(t,o,h,a,l,s)}};function K$(e,t,n){let r=[[],[],[],[],[]],i=new Map;function s(o,a){let l=i.get(o);if(l!=null){if(l<=a)return;let c=r[l].indexOf(o);c>-1&&r[l].splice(c,1),o instanceof Ed&&n.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let c of o)s(c,a);else if(o instanceof Ed){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),s(c,a)}else if(o instanceof OC)s(o.inner,o.prec);else if(o instanceof Ma)r[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof Kl)r[a].push(o),o.facet.extensions&&s(o.facet.extensions,ti.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.`);s(c,a)}}return s(e,ti.default),r.reduce((o,a)=>o.concat(a))}function Ro(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 i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Ac(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var _C=ee.define(),Md=ee.define({combine:e=>e.some(t=>t),static:!0}),jC=ee.define({combine:e=>e.length?e[0]:void 0,static:!0}),BC=ee.define(),FC=ee.define(),VC=ee.define(),zC=ee.define({combine:e=>e.length?e[0]:!1}),Ci=class{constructor(e,t){this.type=e,this.value=t}static define(){return new G$}},G$=class{of(e){return new Ci(this,e)}},Q$=class{constructor(e){this.map=e}of(e){return new Ke(this,e)}},Ke=class $C{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 $C(this.type,n)}is(t){return this.type==t}static define(t={}){return new Q$(t.map||(n=>n))}static mapEffects(t,n){if(!t.length)return t;let r=[];for(let i of t){let s=i.map(n);s&&r.push(s)}return r}};Ke.reconfigure=Ke.define();Ke.appendConfig=Ke.define();var nn=class co{constructor(t,n,r,i,s,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&RC(r,n.newLength),s.some(a=>a.type==co.time)||(this.annotations=s.concat(co.time.of(Date.now())))}static create(t,n,r,i,s,o){return new co(t,n,r,i,s,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(co.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]=="."))}};nn.time=Ci.define();nn.userEvent=Ci.define();nn.addToHistory=Ci.define();nn.remote=Ci.define();function Y$(e,t){let n=[];for(let r=0,i=0;;){let s,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))s=e[r++],o=e[r++];else if(i<t.length)s=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function HC(e,t,n){var r;let i,s,o;return n?(i=t.changes,s=on.empty(t.changes.length),o=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),s=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(i)),{changes:o,selection:t.selection?t.selection.map(s):(r=e.selection)===null||r===void 0?void 0:r.map(i),effects:Ke.mapEffects(e.effects,i).concat(Ke.mapEffects(t.effects,s)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function Rd(e,t,n){let r=t.selection,i=ss(t.annotations);return t.userEvent&&(i=i.concat(nn.userEvent.of(t.userEvent))),{changes:t.changes instanceof on?t.changes:on.of(t.changes||[],n,e.facet(jC)),selection:r&&(r instanceof z?r:z.single(r.anchor,r.head)),effects:ss(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function WC(e,t,n){let r=Rd(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let s=1;s<t.length;s++){t[s].filter===!1&&(n=!1);let o=!!t[s].sequential;r=HC(r,Rd(e,t[s],o?r.changes.newLength:e.doc.length),o)}let i=nn.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return J$(n?X$(i):i)}function X$(e){let t=e.startState,n=!0;for(let i of t.facet(BC)){let s=i(e);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:Y$(n,s))}if(n!==!0){let i,s;if(n===!1)s=e.changes.invertedDesc,i=on.empty(t.doc.length);else{let o=e.changes.filter(n);i=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}e=nn.create(t,i,e.selection&&e.selection.map(s),Ke.mapEffects(e.effects,s),e.annotations,e.scrollIntoView)}let r=t.facet(FC);for(let i=r.length-1;i>=0;i--){let s=r[i](e);s instanceof nn?e=s:Array.isArray(s)&&s.length==1&&s[0]instanceof nn?e=s[0]:e=WC(t,ss(s),!1)}return e}function J$(e){let t=e.startState,n=t.facet(VC),r=e;for(let i=n.length-1;i>=0;i--){let s=n[i](e);s&&Object.keys(s).length&&(r=HC(r,Rd(t,s,e.changes.newLength),!0))}return r==e?e:nn.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var Z$=[];function ss(e){return e==null?Z$:Array.isArray(e)?e:[e]}var Zn=(function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e})(Zn||(Zn={})),e5=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Pd;try{Pd=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function t5(e){if(Pd)return Pd.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||e5.test(n)))return!0}return!1}function n5(e){return t=>{if(!/\S/.test(t))return Zn.Space;if(t5(t))return Zn.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return Zn.Word;return Zn.Other}}var Ve=class Ut{constructor(t,n,r,i,s,o){this.config=t,this.doc=n,this.selection=r,this.values=i,this.status=t.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)Ro(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 Ro(this,r),Ac(this,r)}update(...t){return WC(this,t,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let a of t.effects)a.is(DC.reconfigure)?(n&&(i=new Map,n.compartments.forEach((l,c)=>i.set(c,l)),n=null),i.set(a.value.compartment,a.value.extension)):a.is(Ke.reconfigure)?(n=null,r=a.value):a.is(Ke.appendConfig)&&(n=null,r=ss(r).concat(a.value));let s;n?s=t.startState.values.slice():(n=by.resolve(r,i,this),s=new Ut(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,l)=>l.reconfigure(a,this),null).values);let o=t.startState.facet(Md)?t.newSelection:t.newSelection.asSingle();new Ut(n,t.newDoc,o,s,(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:z.cursor(n.from+t.length,-1)}))}changeByRange(t){let n=this.selection,r=t(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=ss(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(i);for(let f=0;f<a;f++)s[f]=s[f].map(u);let h=i.mapDesc(c,!0);s.push(l.range.map(h)),i=i.compose(u),o=Ke.mapEffects(o,u).concat(Ke.mapEffects(ss(l.effects),h))}return{changes:i,selection:z.create(s,n.mainIndex),effects:o}}changes(t=[]){return t instanceof on?t:on.of(t,this.doc.length,this.facet(Ut.lineSeparator))}toText(t){return me.of(t.split(this.facet(Ut.lineSeparator)||Sd))}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:(Ro(this,n),Ac(this,n))}toJSON(t){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let r in t){let i=t[r];i instanceof Ma&&this.config.address[i.id]!=null&&(n[r]=i.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 i=[];if(r){for(let s in r)if(Object.prototype.hasOwnProperty.call(t,s)){let o=r[s],a=t[s];i.push(o.init(l=>o.spec.fromJSON(a,l)))}}return Ut.create({doc:t.doc,selection:z.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=by.resolve(t.extensions||[],new Map),r=t.doc instanceof me?t.doc:me.of((t.doc||"").split(n.staticFacet(Ut.lineSeparator)||Sd)),i=t.selection?t.selection instanceof z?t.selection:z.single(t.selection.anchor,t.selection.head):z.single(0);return RC(i,r.length),n.staticFacet(Md)||(i=i.asSingle()),new Ut(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Ut.tabSize)}get lineBreak(){return this.facet(Ut.lineSeparator)||`
56
- `}get readOnly(){return this.facet(zC)}phrase(t,...n){for(let r of this.facet(Ut.phrases))if(Object.prototype.hasOwnProperty.call(r,t)){t=r[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let s=+(i||1);return!s||s>n.length?r:n[s-1]})),t}languageDataAt(t,n,r=-1){let i=[];for(let s of this.facet(_C))for(let o of s(this,n,r))Object.prototype.hasOwnProperty.call(o,t)&&i.push(o[t]);return i}charCategorizer(t){let n=this.languageDataAt("wordChars",t);return n5(n.length?n[0]:"")}wordAt(t){let{text:n,from:r,length:i}=this.doc.lineAt(t),s=this.charCategorizer(t),o=t-r,a=t-r;for(;o>0;){let l=ct(n,o,!1);if(s(n.slice(l,o))!=Zn.Word)break;o=l}for(;a<i;){let l=ct(n,a);if(s(n.slice(a,l))!=Zn.Word)break;a=l}return o==a?null:z.range(o+r,a+r)}};Ve.allowMultipleSelections=Md;Ve.tabSize=ee.define({combine:e=>e.length?e[0]:4});Ve.lineSeparator=jC;Ve.readOnly=zC;Ve.phrases=ee.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(i=>e[i]==t[i])}});Ve.languageData=_C;Ve.changeFilter=BC;Ve.transactionFilter=FC;Ve.transactionExtender=VC;DC.reconfigure=Ke.define();function Qm(e,t,n={}){let r={};for(let i of e)for(let s of Object.keys(i)){let o=i[s],a=r[s];if(a===void 0)r[s]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(n,s))r[s]=n[s](a,o);else throw new Error("Config merge conflict for field "+s)}for(let i in t)r[i]===void 0&&(r[i]=t[i]);return r}var xi=class{eq(e){return this==e}range(e,t=e){return Id.create(e,t,this)}};xi.prototype.startSide=xi.prototype.endSide=0;xi.prototype.point=!1;xi.prototype.mapMode=Mt.TrackDel;function Ym(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var Id=class UC{constructor(t,n,r){this.from=t,this.to=n,this.value=r}static create(t,n,r){return new UC(t,n,r)}};function Od(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var r5=class qC{constructor(t,n,r,i){this.from=t,this.to=n,this.value=r,this.maxPoint=i}get length(){return $i(this.to)}findIndex(t,n,r,i=0){let s=r?this.to:this.from;for(let o=i,a=s.length;;){if(o==a)return o;let l=o+a>>1,c=s[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,i){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(r,1e9,!1,s);s<o;s++)if(i(this.from[s]+t,this.to[s]+t,this.value[s])===!1)return!1}map(t,n,r,i,s){let o=[],a=[],l=[],c=-1,u=-1;e:for(let h=0;h<this.value.length;h++){let f=this.value[h],d=this.from[h]+t,m=this.to[h]+t,v,y;if(d==m){let x=n.mapPos(d,f.startSide,f.mapMode);if(x==null||(v=y=x,f.startSide!=f.endSide&&(y=n.mapPos(d,f.endSide),y<v)))continue}else if(v=n.mapPos(d,f.startSide),y=n.mapPos(m,f.endSide),v>y||v==y&&f.startSide>0&&f.endSide<=0)continue;if(!((y-v||f.endSide-f.startSide)<0))if(c<0&&(c=v),f.point&&(u=Math.max(u,y-v)),(v-r||f.startSide-i)>=0)o.push(f),a.push(v-c),l.push(y-c),r=y,i=f.endSide;else{if(v==y)for(let x=o.length;x>0;x--){if((v-(l[x-1]+c)||f.startSide-o[x-1].endSide)>=0){o.splice(x,0,f),a.splice(x,0,v-c),l.splice(x,0,y-c);continue e}if((v-(a[x-1]+c)||f.endSide-o[x-1].startSide)>0)break}s(v,y,f)}}return{mapped:o.length?new qC(a,l,o,u):null,pos:c}}},Ae=class $n{constructor(t,n,r,i){this.chunkPos=t,this.chunk=n,this.nextLayer=r,this.maxPoint=i}static create(t,n,r,i){return new $n(t,n,r,i)}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:i=0,filterTo:s=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(Od)),this.isEmpty)return n.length?$n.of(n):this;let a=new GC(this,null,-1).goto(0),l=0,c=[],u=new Gl;for(;a.value||l<n.length;)if(l<n.length&&(a.from-n[l].from||a.startSide-n[l].value.startSide)>=0){let h=n[l++];u.addInner(h.from,h.to,h.value,!1)||c.push(h)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(l==n.length||this.chunkEnd(a.chunkIndex)<n[l].from)&&(!o||i>this.chunkEnd(a.chunkIndex)||s<this.chunkPos[a.chunkIndex])&&u.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!o||i>a.to||s<a.from||o(a.from,a.to,a.value))&&(u.addInner(a.from,a.to,a.value,!1)||c.push(Id.create(a.from,a.to,a.value))),a.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?$n.empty:this.nextLayer.update({add:c,filter:o,filterFrom:i,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let n=[],r=[],i=-1,s,o=(l,c,u)=>{s||(s=new Gl),s.addRange(l,c,u,!1)};for(let l=0;l<this.chunk.length;l++){let c=this.chunkPos[l],u=this.chunk[l],h=t.touchesRange(c,c+u.length);if(h===!1)i=Math.max(i,u.maxPoint),n.push(u),r.push(t.mapPos(c));else if(h===!0){let[f,d]=n.length?[$i(r)+$i(n).length,$i($i(n).value).endSide]:[-1,-1],{mapped:m,pos:v}=u.map(c,t,f,d,o);m&&(i=Math.max(i,m.maxPoint),n.push(m),r.push(v))}}let a=this.nextLayer.map(t);return s&&(a=s.finishInner(a)),n.length==0?a:new $n(r,n,a||$n.empty,i)}between(t,n,r){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let s=this.chunkPos[i],o=this.chunk[i];if(n>=s&&t<=s+o.length&&o.between(s,t-s,n-s,r)===!1)return}this.nextLayer.between(t,n,r)}}iter(t=0){return Dd.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,n=0){return Dd.from(t).goto(n)}static compare(t,n,r,i,s=-1){let o=t.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=s),a=n.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=s),l=wy(o,a,r),c=new Ys(o,l,s),u=new Ys(a,l,s);r.iterGaps((h,f,d)=>Sy(c,h,u,f,d,i)),r.empty&&r.length==0&&Sy(c,0,u,0,0,i)}static eq(t,n,r=0,i){i==null&&(i=999999999);let s=t.filter(u=>!u.isEmpty&&n.indexOf(u)<0),o=n.filter(u=>!u.isEmpty&&t.indexOf(u)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let a=wy(s,o),l=new Ys(s,a,0).goto(r),c=new Ys(o,a,0).goto(r);for(;;){if(l.to!=c.to||!Nd(l.active,c.active)||l.point&&(!c.point||!Ym(l.point,c.point)))return!1;if(l.to>i)return!0;l.next(),c.next()}}static spans(t,n,r,i,s=-1){let o=new Ys(t,null,s).goto(n),a=n,l=o.openStart;for(;;){let c=Math.min(o.to,r);if(o.point){let u=o.activeForPoint(o.to),h=o.pointFrom<n?u.length+1:o.point.startSide<0?u.length:Math.min(u.length,l);i.point(a,c,o.point,u,h,o.pointRank),l=Math.min(o.openEnd(c),u.length)}else c>a&&(i.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 Gl;for(let i of t instanceof Id?[t]:n?i5(t):t)r.add(i.from,i.to,i.value);return r.finish()}static join(t){if(!t.length)return $n.empty;let n=$i(t);for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=$n.empty;i=i.nextLayer)n=new $n(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};Ae.empty=new Ae([],[],null,-1);function $i(e){return e[e.length-1]}function i5(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(Od(t,r)>0)return e.slice().sort(Od);t=r}return e}Ae.empty.nextLayer=Ae.empty;var Gl=class KC{finishChunk(t){this.chunks.push(new r5(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,i){this.addInner(t,n,r,i)||(this.nextLayer||(this.nextLayer=new KC)).addRange(t,n,r,i)}addInner(t,n,r,i){let s=t-this.lastTo||r.startSide-this.last.endSide;if(i&&s<=0&&(t-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<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(Ae.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let n=Ae.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,n}};function wy(e,t,n){let r=new Map;for(let s of e)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&r.set(s.chunk[o],s.chunkPos[o]);let i=new Set;for(let s of t)for(let o=0;o<s.chunk.length;o++){let a=r.get(s.chunk[o]);a!=null&&(n?n.mapPos(a):a)==s.chunkPos[o]&&!n?.touchesRange(a,a+s.chunk[o].length)&&i.add(s.chunk[o])}return i}var GC=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}},Dd=class QC{constructor(t){this.heap=t}static from(t,n=null,r=-1){let i=[];for(let s=0;s<t.length;s++)for(let o=t[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=r&&i.push(new GC(o,n,r,s));return i.length==1?i[0]:new QC(i)}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--)Dh(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--)Dh(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(),Dh(this.heap,0)}}};function Dh(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var Ys=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=Dd.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){ol(this.active,e),ol(this.activeTo,e),ol(this.activeRank,e),this.minActive=ky(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;al(this.active,t,n),al(this.activeTo,t,r),al(this.activeRank,t,i),e&&al(e,t,this.cursor.from),this.minActive=ky(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&&ol(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 i=this.cursor.value;if(!i.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=i,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=i.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 Sy(e,t,n,r,i,s){e.goto(t),n.goto(r);let o=r+i,a=r,l=r-t,c=!!s.boundChange;for(let u=!1;;){let h=e.to+l-n.to,f=h||e.endSide-n.endSide,d=f<0?e.to+l:n.to,m=Math.min(d,o);if(e.point||n.point?(e.point&&n.point&&Ym(e.point,n.point)&&Nd(e.activeForPoint(e.to),n.activeForPoint(n.to))||s.comparePoint(a,m,e.point,n.point),u=!1):(u&&(s.boundChange(a),u=!1),m>a&&!Nd(e.active,n.active)&&s.compareRange(a,m,e.active,n.active),c&&m<o&&(h||e.openEnd(d)!=n.openEnd(d))&&(u=!0)),d>o)break;a=d,f<=0&&e.next(),f>=0&&n.next()}}function Nd(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!Ym(e[n],t[n]))return!1;return!0}function ol(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function al(e,t,n){for(let r=e.length-1;r>=t;r--)e[r+1]=e[r];e[t]=n}function ky(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function yu(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)e.charCodeAt(i)==9?(r+=t-r%t,i++):(r++,i=ct(e,i));return r}function s5(e,t,n,r){for(let i=0,s=0;;){if(s>=t)return i;if(i==e.length)break;s+=e.charCodeAt(i)==9?n-s%n:1,i=ct(e,i)}return r===!0?-1:e.length}var YC="ͼ",Cy=typeof Symbol>"u"?"__ͼ":Symbol.for(YC),Ld=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Ay=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Nr=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function i(s,o,a,l){let c=[],u=/^@(\w+)\b/.exec(s[0]),h=u&&u[1]=="keyframes";if(u&&o==null)return a.push(s[0]+";");for(let f in o){let d=o[f];if(/&/.test(f))i(f.split(/,\s*/).map(m=>s.map(v=>m.replace(/&/,v))).reduce((m,v)=>m.concat(v)),d,a);else if(d&&typeof d=="object"){if(!u)throw new RangeError("The value of a property ("+f+") should be a primitive value.");i(r(f),d,c,h)}else d!=null&&c.push(f.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+d+";")}(c.length||h)&&a.push((n&&!u&&!l?s.map(n):s).join(", ")+" {"+c.join(" ")+"}")}for(let s in e)i(r(s),e[s],this.rules)}getRules(){return this.rules.join(`
57
- `)}static newName(){let e=Ay[Cy]||1;return Ay[Cy]=e+1,YC+e.toString(36)}static mount(e,t,n){let r=e[Ld],i=n&&n.nonce;r?i&&r.setNonce(i):r=new o5(e,i),r.mount(Array.isArray(t)?t:[t],e)}},Ty=new Map,o5=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let i=Ty.get(n);if(i)return e[Ld]=i;this.sheet=new r.CSSStyleSheet,Ty.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Ld]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let s=0;s<e.length;s++){let o=e[s],a=this.modules.indexOf(o);if(a<i&&a>-1&&(this.modules.splice(a,1),i--,a=-1),a==-1){if(this.modules.splice(i++,0,o),n)for(let l=0;l<o.rules.length;l++)n.insertRule(o.rules[l],r++)}else{for(;i<a;)r+=this.modules[i++].rules.length;r+=o.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let s="";for(let a=0;a<this.modules.length;a++)s+=this.modules[a].getRules()+`
58
- `;this.styleTag.textContent=s;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)}},Lr={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:"'"},ta={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},a5=typeof navigator<"u"&&/Mac/.test(navigator.platform),l5=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var rt=0;rt<10;rt++)Lr[48+rt]=Lr[96+rt]=String(rt);for(var rt=1;rt<=24;rt++)Lr[rt+111]="F"+rt;for(var rt=65;rt<=90;rt++)Lr[rt]=String.fromCharCode(rt+32),ta[rt]=String.fromCharCode(rt);for(var Nh in Lr)ta.hasOwnProperty(Nh)||(ta[Nh]=Lr[Nh]);function c5(e){var t=!(a5&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||l5&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified")&&e.key||(e.shiftKey?ta:Lr)[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 ht=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},_d=typeof document<"u"?document:{documentElement:{style:{}}},jd=/Edge\/(\d+)/.exec(ht.userAgent),XC=/MSIE \d/.test(ht.userAgent),Bd=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ht.userAgent),xu=!!(XC||Bd||jd),Ey=!xu&&/gecko\/(\d+)/i.test(ht.userAgent),Lh=!xu&&/Chrome\/(\d+)/.exec(ht.userAgent),My="webkitFontSmoothing"in _d.documentElement.style,Fd=!xu&&/Apple Computer/.test(ht.vendor),Ry=Fd&&(/Mobile\/\w+/.test(ht.userAgent)||ht.maxTouchPoints>2),U={mac:Ry||/Mac/.test(ht.platform),windows:/Win/.test(ht.platform),linux:/Linux|X11/.test(ht.platform),ie:xu,ie_version:XC?_d.documentMode||6:Bd?+Bd[1]:jd?+jd[1]:0,gecko:Ey,gecko_version:Ey?+(/Firefox\/(\d+)/.exec(ht.userAgent)||[0,0])[1]:0,chrome:!!Lh,chrome_version:Lh?+Lh[1]:0,ios:Ry,android:/Android\b/.test(ht.userAgent),webkit:My,webkit_version:My?+(/\bAppleWebKit\/(\d+)/.exec(ht.userAgent)||[0,0])[1]:0,safari:Fd,safari_version:Fd?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ht.userAgent)||[0,0])[1]:0,tabSize:_d.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Xm(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 Tc=Object.create(null);function Jm(e,t,n){if(e==t)return!0;e||(e=Tc),t||(t=Tc);let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let s of r)if(s!=n&&(i.indexOf(s)==-1||e[s]!==t[s]))return!1;return!0}function u5(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 Py(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i=="style"?e.style.cssText="":e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i=="style"?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function h5(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 bu=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){}},ot=(function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e})(ot||(ot={})),Me=class extends xi{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 Zm(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 na(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:i,end:s}=tA(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(s?t?2e8:1:-6e8)+1}return new na(e,n,r,t,e.widget||null,!0)}static line(e){return new eg(e)}static set(e,t=!1){return Ae.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Me.none=Ae.empty;var Zm=class JC extends Me{constructor(t){let{start:n,end:r}=tA(t);super(n?-1:5e8,r?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?Xm(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||Tc}eq(t){return this==t||t instanceof JC&&this.tagName==t.tagName&&Jm(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)}};Zm.prototype.point=!1;var eg=class ZC extends Me{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof ZC&&this.spec.class==t.spec.class&&Jm(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)}};eg.prototype.mapMode=Mt.TrackBefore;eg.prototype.point=!0;var na=class eA extends Me{constructor(t,n,r,i,s,o){super(n,r,s,t),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?Mt.TrackBefore:Mt.TrackAfter:Mt.TrackDel}get type(){return this.startSide!=this.endSide?ot.WidgetRange:this.startSide<=0?ot.WidgetBefore:ot.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof eA&&f5(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)}};na.prototype.point=!0;function tA(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 f5(e,t){return e==t||!!(e&&t&&e.compare(t))}function os(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var Iy=class Vd extends xi{constructor(t,n,r){super(),this.tagName=t,this.attributes=n,this.rank=r}eq(t){return t==this||t instanceof Vd&&this.tagName==t.tagName&&Jm(this.attributes,t.attributes)}static create(t){return new Vd(t.tagName,t.attributes||Tc,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(t,n=!1){return Ae.of(t,n)}};Iy.prototype.startSide=Iy.prototype.endSide=-1;function ra(e){let t;return e.nodeType==11?t=e.getSelection?e:e.ownerDocument:t=e,t.getSelection()}function zd(e,t){return t?e==t||e.contains(t.nodeType!=1?t.parentNode:t):!1}function Po(e,t){if(!t.anchorNode)return!1;try{return zd(e,t.anchorNode)}catch{return!1}}function Ql(e){return e.nodeType==3?ia(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function Io(e,t,n,r){return n?Oy(e,t,n,r,-1)||Oy(e,t,n,r,1):!1}function _r(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function Ec(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function Oy(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:lr(e))){if(e.nodeName=="DIV")return!1;let s=e.parentNode;if(!s||s.nodeType!=1)return!1;t=_r(e)+(i<0?0:1),e=s}else if(e.nodeType==1){if(e=e.childNodes[t+(i<0?-1:0)],e.nodeType==1&&e.contentEditable=="false")return!1;t=i<0?lr(e):0}else return!1}}function lr(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Mc(e,t){let{left:n,right:r}=e;if(n==r)return e;let i=t?n:r;return{left:i,right:i,top:e.top,bottom:e.bottom}}function d5(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 nA(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 p5(e,t,n,r,i,s,o,a){let l=e.ownerDocument,c=l.defaultView||window;for(let u=e,h=!1;u&&!h;)if(u.nodeType==1){let f,d=u==l.body,m=1,v=1;if(d)f=d5(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(h=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let b=u.getBoundingClientRect();({scaleX:m,scaleY:v}=nA(u,b)),f={left:b.left,right:b.left+u.clientWidth*m,top:b.top,bottom:b.top+u.clientHeight*v}}let y=0,x=0;if(i=="nearest")t.top<f.top+o?(x=t.top-(f.top+o),n>0&&t.bottom>f.bottom+x&&(x=t.bottom-f.bottom+o)):t.bottom>f.bottom-o&&(x=t.bottom-f.bottom+o,n<0&&t.top-x<f.top&&(x=t.top-(f.top+o)));else{let b=t.bottom-t.top,w=f.bottom-f.top;x=(i=="center"&&b<=w?t.top+b/2-w/2:i=="start"||i=="center"&&n<0?t.top-o:t.bottom-w+o)-f.top}if(r=="nearest"?t.left<f.left+s?(y=t.left-(f.left+s),n>0&&t.right>f.right+y&&(y=t.right-f.right+s)):t.right>f.right-s&&(y=t.right-f.right+s,n<0&&t.left<f.left+y&&(y=t.left-(f.left+s))):y=(r=="center"?t.left+(t.right-t.left)/2-(f.right-f.left)/2:r=="start"==a?t.left-s:t.right-(f.right-f.left)+s)-f.left,y||x)if(d)c.scrollBy(y,x);else{let b=0,w=0;if(x){let S=u.scrollTop;u.scrollTop+=x/v,w=(u.scrollTop-S)*v}if(y){let S=u.scrollLeft;u.scrollLeft+=y/m,b=(u.scrollLeft-S)*m}t={left:t.left-b,top:t.top-w,right:t.right-b,bottom:t.bottom-w},b&&Math.abs(b-y)<1&&(r="nearest"),w&&Math.abs(w-x)<1&&(i="nearest")}if(d)break;(t.top<f.top||t.bottom>f.bottom||t.left<f.left||t.right>f.right)&&(t={left:Math.max(t.left,f.left),right:Math.min(t.right,f.right),top:Math.max(t.top,f.top),bottom:Math.min(t.bottom,f.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function rA(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let s=e.parentNode;s&&!(s==n.body||(!t||r)&&i);)if(s.nodeType==1)!i&&s.scrollHeight>s.clientHeight&&(i=s),t&&!r&&s.scrollWidth>s.clientWidth&&(r=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:r,y:i}}var m5=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?lr(t):0),n,Math.min(e.focusOffset,n?lr(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}};function iA(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 sA(e,t=!0){for(let{node:n,left:r,top:i}of e)t&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}var ei=null;U.safari&&U.safari_version>=26&&(ei=!1);function oA(e){if(e.setActive)return e.setActive();if(ei)return e.focus(ei);let t=iA(e);e.focus(ei==null?{get preventScroll(){return ei={preventScroll:!0},!0}}:void 0),ei||(ei=!1,sA(t))}var Dy;function ia(e,t,n=t){let r=Dy||(Dy=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function as(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let s=new KeyboardEvent("keydown",i);s.synthetic=!0,e.dispatchEvent(s);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,e.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function g5(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function v5(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,lr(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=lr(n))}else{if(n==e)return!0;r=_r(n),n=n.parentNode}}function aA(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 lA(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=lr(n)}else if(n.parentNode&&!Ec(n))r=_r(n),n=n.parentNode;else return null}}function cA(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&&!Ec(n))r=_r(n)+1,n=n.parentNode;else return null}}var Tr=class $d{constructor(t,n,r=!0){this.node=t,this.offset=n,this.precise=r}static before(t,n){return new $d(t.parentNode,_r(t),n)}static after(t,n){return new $d(t.parentNode,_r(t)+1,n)}},Ee=(function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e})(Ee||(Ee={})),bi=Ee.LTR,tg=Ee.RTL;function uA(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}var y5=uA("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),x5=uA("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Hd=Object.create(null),vn=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);Hd[t]=n,Hd[n]=-t}function hA(e){return e<=247?y5[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?x5[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var b5=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,En=class{get dir(){return this.level%2?tg:bi}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 i=-1;for(let s=0;s<e.length;s++){let o=e[s];if(o.from<=t&&o.to>=t){if(o.level==n)return s;(i<0||(r!=0?r<0?o.from<t:o.to>t:e[i].level>o.level))&&(i=s)}}if(i<0)throw new RangeError("Index out of range");return i}};function fA(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!fA(r.inner,i.inner))return!1}return!0}var be=[];function w5(e,t,n,r,i){for(let s=0;s<=r.length;s++){let o=s?r[s-1].to:t,a=s<r.length?r[s].from:n,l=s?256:i;for(let c=o,u=l,h=l;c<a;c++){let f=hA(e.charCodeAt(c));f==512?f=u:f==8&&h==4&&(f=16),be[c]=f==4?2:f,f&7&&(h=f),u=f}for(let c=o,u=l,h=l;c<a;c++){let f=be[c];if(f==128)c<a-1&&u==be[c+1]&&u&24?f=be[c]=u:be[c]=256;else if(f==64){let d=c+1;for(;d<a&&be[d]==64;)d++;let m=c&&u==8||d<n&&be[d]==8?h==1?1:8:256;for(let v=c;v<d;v++)be[v]=m;c=d-1}else f==8&&h==1&&(be[c]=1);u=f,f&7&&(h=f)}}}function S5(e,t,n,r,i){let s=i==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 h=c,f,d,m;h<u;h++)if(d=Hd[f=e.charCodeAt(h)])if(d<0){for(let v=a-3;v>=0;v-=3)if(vn[v+1]==-d){let y=vn[v+2],x=y&2?i:y&4?y&1?s:i:0;x&&(be[h]=be[vn[v]]=x),a=v;break}}else{if(vn.length==189)break;vn[a++]=h,vn[a++]=f,vn[a++]=l}else if((m=be[h])==2||m==1){let v=m==i;l=v?0:1;for(let y=a-3;y>=0;y-=3){let x=vn[y+2];if(x&2)break;if(v)vn[y+2]|=2;else{if(x&4)break;vn[y+2]|=4}}}}}function k5(e,t,n,r){for(let i=0,s=r;i<=n.length;i++){let o=i?n[i-1].to:e,a=i<n.length?n[i].from:t;for(let l=o;l<a;){let c=be[l];if(c==256){let u=l+1;for(;;)if(u==a){if(i==n.length)break;u=n[i++].to,a=i<n.length?n[i].from:t}else if(be[u]==256)u++;else break;let h=s==1,f=h==((u<t?be[u]:r)==1)?h?1:2:r;for(let d=u,m=i,v=m?n[m-1].to:e;d>l;)d==v&&(d=n[--m].from,v=m?n[m-1].to:e),be[--d]=f;l=u}else s=c,l++}}}function Wd(e,t,n,r,i,s,o){let a=r%2?2:1;if(r%2==i%2)for(let l=t,c=0;l<n;){let u=!0,h=!1;if(c==s.length||l<s[c].from){let v=be[l];v!=a&&(u=!1,h=v==16)}let f=!u&&a==1?[]:null,d=u?r:r+1,m=l;e:for(;;)if(c<s.length&&m==s[c].from){if(h)break e;let v=s[c];if(!u)for(let y=v.to,x=c+1;;){if(y==n)break e;if(x<s.length&&s[x].from==y)y=s[x++].to;else{if(be[y]==a)break e;break}}c++,f?f.push(v):(v.from>l&&o.push(new En(l,v.from,d)),Ud(e,v.direction==bi!=!(d%2)?r+1:r,i,v.inner,v.from,v.to,o),l=v.to),m=v.to}else{if(m==n||(u?be[m]!=a:be[m]==a))break;m++}f?Wd(e,l,m,r+1,i,f,o):l<m&&o.push(new En(l,m,d)),l=m}else for(let l=n,c=s.length;l>t;){let u=!0,h=!1;if(!c||l>s[c-1].to){let v=be[l-1];v!=a&&(u=!1,h=v==16)}let f=!u&&a==1?[]:null,d=u?r:r+1,m=l;e:for(;;)if(c&&m==s[c-1].to){if(h)break e;let v=s[--c];if(!u)for(let y=v.from,x=c;;){if(y==t)break e;if(x&&s[x-1].to==y)y=s[--x].from;else{if(be[y-1]==a)break e;break}}f?f.push(v):(v.to<l&&o.push(new En(v.to,l,d)),Ud(e,v.direction==bi!=!(d%2)?r+1:r,i,v.inner,v.from,v.to,o),l=v.from),m=v.from}else{if(m==t||(u?be[m-1]!=a:be[m-1]==a))break;m--}f?Wd(e,m,l,r+1,i,f,o):m<l&&o.push(new En(m,l,d)),l=m}}function Ud(e,t,n,r,i,s,o){let a=t%2?2:1;w5(e,i,s,r,a),S5(e,i,s,r,a),k5(i,s,r,a),Wd(e,i,s,t,n,r,o)}function C5(e,t,n){if(!e)return[new En(0,0,t==tg?1:0)];if(t==bi&&!n.length&&!b5.test(e))return dA(e.length);if(n.length)for(;e.length>be.length;)be[be.length]=256;let r=[],i=t==bi?0:1;return Ud(e,i,i,n,0,e.length,r),r}function dA(e){return[new En(0,e,0)]}var pA="";function A5(e,t,n,r,i){var s;if(!e.length)return null;let o=r.head-e.from,a;if(r.head==e.from&&r.assoc<0){if(!i)return null;o=t[a=0].side(!1,n)}else if(r.head==e.to&&r.assoc>0){if(i)return null;o=t[a=t.length-1].side(!0,n)}else a=En.find(t,o,(s=r.bidiLevel)!==null&&s!==void 0?s:-1,r.assoc);let l=t[a],c=l.side(i,n);if(o==c){let f=a+=i?1:-1;if(f<0||f>=t.length)return null;l=t[a=f],o=l.side(!i,n),c=l.side(i,n)}let u=ct(e.text,o,l.forward(i,n));(u<l.from||u>l.to)&&(u=c),pA=e.text.slice(Math.min(o,u),Math.max(o,u));let h=a==(i?t.length-1:0)?null:t[a+(i?1:-1)];if(u==c){if(!h)return i?z.cursor(e.to,1):z.cursor(e.from,-1);if(h.level+(i?0:1)<l.level)return z.cursor(h.side(!i,n)+e.from,h.forward(i,n)?1:-1,h.level)}return z.cursor(u+e.from,l.forward(i,n)?-1:1,l.level)}function T5(e,t,n){for(let r=t;r<n;r++){let i=hA(e.charCodeAt(r));if(i==1)return bi;if(i==2||i==4)return tg}return bi}var mA=ee.define(),gA=ee.define(),vA=ee.define(),yA=ee.define(),qd=ee.define(),xA=ee.define(),bA=ee.define(),ng=ee.define(),rg=ee.define(),wA=ee.define({combine:e=>e.some(t=>t)}),SA=ee.define({combine:e=>e.some(t=>t)}),kA=ee.define(),_h=class Kd{constructor(t,n,r,i,s,o=!1){this.range=t,this.y=n,this.x=r,this.yMargin=i,this.xMargin=s,this.isSnapshot=o}map(t){return t.empty?this:new Kd(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 Kd(z.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},ll=Ke.define({map:(e,t)=>e.map(t)}),CA=Ke.define();function Mn(e,t,n){let r=e.facet(yA);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 Qn=ee.define({combine:e=>e.length?e[0]:!0}),E5=0,Qi=ee.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})}}),jr=class Gd{constructor(t,n,r,i,s){this.id=t,this.create=n,this.domEventHandlers=r,this.domEventObservers=i,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(Qi.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(Qi.of({plugin:this,arg:t}))}static define(t,n){const{eventHandlers:r,eventObservers:i,provide:s,decorations:o}=n||{};return new Gd(E5++,t,r,i,a=>{let l=[];return o&&l.push(wu.of(c=>{let u=c.plugin(a);return u?o(u):Me.none})),s&&l.push(s(a)),l})}static fromClass(t,n){return Gd.define((r,i)=>new t(r,i),n)}},jh=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(Mn(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){Mn(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){Mn(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},AA=ee.define(),ig=ee.define(),wu=ee.define(),TA=ee.define(),sg=ee.define(),Ra=ee.define(),EA=ee.define();function Ny(e,t){let n=e.state.facet(EA);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(e):s),i=[];return Ae.spans(r,t.from,t.to,{point(){},span(s,o,a,l){let c=s-t.from,u=o-t.from,h=i;for(let f=a.length-1;f>=0;f--,l--){let d=a[f].spec.bidiIsolate,m;if(d==null&&(d=T5(t.text,c,u)),l>0&&h.length&&(m=h[h.length-1]).to==c&&m.direction==d)m.to=u,h=m.inner;else{let v={from:c,to:u,direction:d,inner:[]};h.push(v),h=v.inner}}}}),i}var MA=ee.define();function RA(e){let t=0,n=0,r=0,i=0;for(let s of e.state.facet(MA)){let o=s(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&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:r,bottom:i}}var uo=ee.define(),er=class Qd{constructor(t,n,r,i){this.fromA=t,this.toA=n,this.fromB=r,this.toB=i}join(t){return new Qd(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 i=t[n-1];if(!(i.fromA>r.toA)){if(i.toA<r.fromA)break;r=r.join(i),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 i=0,s=0,o=0;;){let a=i<t.length?t[i].fromB:1e9,l=s<n.length?n[s]:1e9,c=Math.min(a,l);if(c==1e9)break;let u=c+o,h=c,f=u;for(;;)if(s<n.length&&n[s]<=h){let d=n[s+1];s+=2,h=Math.max(h,d);for(let m=i;m<t.length&&t[m].fromB<=h;m++)o=t[m].toA-t[m].toB;f=Math.max(f,d+o)}else if(i<t.length&&t[i].fromB<=h){let d=t[i++];h=Math.max(h,d.toB),f=Math.max(f,d.toA),o=d.toA-d.toB}else break;r.push(new Qd(u,f,c,h))}return r}},Ly=class PA{constructor(t,n,r){this.view=t,this.state=n,this.transactions=r,this.flags=0,this.startState=t.state,this.changes=on.empty(this.startState.doc.length);for(let s of r)this.changes=this.changes.compose(s.changes);let i=[];this.changes.iterChangedRanges((s,o,a,l)=>i.push(new er(s,o,a,l))),this.changedRanges=i}static create(t,n,r){return new PA(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}},M5=[],Ne=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 M5}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&&u5(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=_r(this.dom),r=this.length?e>0:t>0;return new Tr(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 ku)return e;return null}static get(e){return e.cmTile}},Su=class extends Ne{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,i=e?.node==t?e:null,s=0;for(let o of this.children){if(o.sync(e),s+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=_y(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=_y(r);this.length=s}};function _y(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var ku=class extends Su{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=Ne.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let s=n.children[r++];if(s instanceof hi)t.push(r),n=s,r=0;else{let o=i+s.length,a=e(s,i);if(a!==void 0)return a;i=o+s.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,s=-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)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,s=e-a)}}),!n&&!i)throw new Error("No tile at position "+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:s}}},hi=class IA extends Su{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 IA(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},Rc=class OA extends Su{constructor(t,n){super(t),this.attrs=n}isLine(){return!0}static start(t,n,r){let i=new OA(n||document.createElement("div"),t);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(t,n,r){let i=null,s=-1,o=null,a=-1;function l(u,h){for(let f=0,d=0;f<u.children.length&&d<=h;f++){let m=u.children[f],v=d+m.length;v>=h&&(m.isComposite()?l(m,h-d):(!o||o.isHidden&&(n>0&&!(o.flags&32)||r&&P5(o,m)))&&(v>h||m.flags&32&&n<=1)?(o=m,a=h-d):(d<h||m.flags&16&&!m.isHidden&&n>=-1)&&(i=m,s=h-d)),d=v}}l(this,t);let c=(n<0?i:o)||i||o;return c?{tile:c,offset:c==i?s:a}:null}coordsIn(t,n,r){let i=this.resolveInline(t,n,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),n,r):R5(this)}domIn(t,n){let r=this.resolveInline(t,n);if(r){let{tile:i,offset:s}=r;if(this.dom.contains(i.dom))return i.isText()?new Tr(i.dom,Math.min(i.dom.nodeValue.length,s)):i.domPosFor(s,i.flags&16?1:i.flags&32?-1:n);let o=r.tile.parent,a=!1;for(let l of o.children){if(a)return new Tr(l.dom,0);l==r.tile&&(a=!0)}}return new Tr(this.dom,0)}};function R5(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Ql(t);return n[n.length-1]||null}function P5(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var Nt=class DA extends Su{constructor(t,n){super(t),this.mark=n}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new DA(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},ho=class NA extends Ne{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 i=this.dom.nodeValue.length;t>i&&(t=i);let s=t,o=t,a=0;t==0&&n<0||t==i&&n>=0?U.chrome||U.gecko||(t?(s--,a=1):o<i&&(o++,a=-1)):n<0?s--:o<i&&o++;let l=ia(this.dom,s,o).getClientRects();if(!l.length)return null;let c=l[(a?a<0:n>=0)?0:l.length-1];return U.safari&&!a&&c.width==0&&(c=Array.prototype.find.call(l,u=>u.width)||c),r==null?c:Mc(c,(a?a>0:n<0)==r)}static of(t,n){let r=new NA(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},sa=class LA extends Ne{constructor(t,n,r,i){super(t,n,i),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 i=this.widget.coordsAt(this.dom,t,n);if(i)return i;if(r)return Mc(this.dom.getBoundingClientRect(),this.length?t==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let a=this.flags&16?!0:this.flags&32?!1:t>0;for(let l=a?s.length-1:0;o=s[l],!(t>0?l==0:l==s.length-1||o.top<o.bottom);l+=a?-1:1);return Mc(o,!a)}}get overrideDOMText(){if(!this.length)return me.empty;let{root:t}=this;if(!t)return me.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,i,s){return s||(s=t.toDOM(n),t.editable||(s.contentEditable="false")),new LA(s,r,t,i)}},Pc=class extends Ne{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 me.empty}coordsIn(e,t,n){let r=this.dom.getBoundingClientRect();return n==null?r:Mc(r,t>0==n)}},I5=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:s,parents:o}=this;for(;e||t>0;)if(r.isComposite())if(s){if(!e)break;n&&n.break(),e--,s=!1}else if(i==r.children.length){if(!e&&!o.length)break;n&&n.leave(r),s=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++}else{let a=r.children[i],l=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!n||n.skip(a,0,a.length)!==!1||!a.isComposite)?(s=!!l,i++,e-=a.length):(o.push({tile:r,index:i}),r=a,i=0,n&&a.isComposite()&&n.enter(a))}else{let a=r.length;if(i<a&&e){let l=Math.min(e,a-i);n&&n.skip(r,i,i+l),e-=l,i+=l}if(i==a)s=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++;else if(!e)break}return this.tile=r,this.index=i,this.beforeBreak=s,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},O5=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},D5=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 i;this.flushBuffer();let s=this.ensureMarks(t,n),o=s.lastChild;if(o&&o.isText()&&!(o.flags&8)&&o.length+e.length<512){this.cache.reused.set(o,2);let a=s.children[s.children.length-1]=new ho(o.dom,o.text+e);a.parent=s}else s.append(r||ho.of(e,(i=this.cache.find(ho))===null||i===void 0?void 0:i.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)?Bh(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 Nt&&l.mark.eq(a.mark))l.dom!=a.dom&&l.setDOM(Bh(a.dom)),r=l;else{let{dom:c}=a;this.cache.reused.get(a)&&Ne.get(a.dom)&&(c=Bh(a.dom));let u=Nt.of(a.mark,c);r.append(u),r=u}this.cache.reused.set(a,2)}let i=Ne.get(e.text);i&&this.cache.reused.set(i,2);let s=new ho(e.text,e.text.nodeValue);s.flags|=8,this.pos=e.range.toB,r.append(s)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.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=_A);let r=Rc.start(e,t||((n=this.cache.find(Rc))===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 i=e.length-1;i>=0;i--){let s=e[i],o;if(t>0&&(o=r.lastChild)&&o instanceof Nt&&o.mark.eq(s))r=o,t--;else{let a=Nt.of(s,(n=this.cache.find(Nt,l=>l.mark.eq(s)))===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||!jy(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(U.ios&&jy(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Fh,0,32)||new sa(Fh.toDOM(),0,Fh,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 O5(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 hi&&r.wrapper.eq(n.wrapper))t=r;else{let i=hi.of(n.wrapper,(e=this.cache.find(hi,s=>s.wrapper.eq(n.wrapper)))===null||e===void 0?void 0:e.dom);t.append(i),t=i}}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(Pc,void 0,1);return n&&(n.flags=t),n||new Pc(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},N5=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:i,done:s}=this.cursor.next(this.skipCount);if(this.skipCount=0,s)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 i?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}},Ic=[sa,Rc,ho,Nt,Pc,hi,ku];for(let e=0;e<Ic.length;e++)Ic[e].bucket=e;var L5=class{constructor(e){this.view=e,this.buckets=Ic.map(()=>[]),this.index=Ic.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,i=this.buckets[r],s=this.index[r];for(let o=0;o<i.length;o++){let a=(o+s)%i.length,l=i[a];if((!t||t(l))&&!this.reused.has(l))return i.splice(a,1),a<s&&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 i=0,s=0;;i++){if(i==r.length){if(s)return null;s=1,i=0}let o=r[i];if(!this.reused.has(o)&&(s==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(i,1),i<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 sa(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}},_5=class{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new L5(e),this.text=new N5(e.state.doc),this.builder=new D5(this.cache,new ku(e,e.contentDOM),Ae.iter(n)),this.cache.reused.set(t,2),this.old=new I5(t),this.reuseWalker={skip:(s,o,a)=>{if(this.cache.add(s),s.isComposite())return!1},enter:s=>this.cache.add(s),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,s=0;;){let o=s<e.length?e[s++]:null,a=o?o.fromA:this.old.root.length;if(a>r){let l=a-r;this.preserve(l,!s,!o),r=a,i+=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(i,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(i,o.toB)),i=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=F5(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(s,o,a)=>{if(s.isWidget())if(this.openWidget)this.builder.continueWidget(a-o);else{let l=a>0||o<s.length?sa.of(s.widget,this.view,a-o,s.flags&496,this.cache.maybeReuse(s)):this.cache.reuse(s);l.flags&256?(l.flags&=-2,this.builder.addBlockWidget(l)):(this.builder.ensureLine(null),this.builder.addInlineWidget(l,r,i),i=r.length)}else if(s.isText())this.builder.ensureLine(null),!o&&a==s.length&&!this.cache.reused.has(s)?this.builder.addText(s.text,r,i,this.cache.reuse(s)):(this.cache.add(s),this.builder.addText(s.text.slice(o,a),r,i)),i=r.length;else if(s.isLine())s.flags&=-2,this.cache.reused.set(s,1),this.builder.addLine(s);else if(s instanceof Pc)this.cache.add(s);else if(s instanceof Nt)this.builder.ensureLine(null),this.builder.addMark(s,r,i),this.cache.reused.set(s,1),i=r.length;else return!1;this.openWidget=!1},enter:s=>{s.isLine()?this.builder.addLineStart(s.attrs,this.cache.maybeReuse(s)):(this.cache.add(s),s instanceof Nt&&r.unshift(s.mark)),this.openWidget=!1},leave:s=>{s.isLine()?r.length&&(r.length=i=0):s instanceof Nt&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=-1,s=Ae.spans(this.decorations,e,t,{point:(o,a,l,c,u,h)=>{if(l instanceof na){if(this.disallowBlockEffectsFor[h]){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(i=c.length,u>c.length)r.continueWidget(a-o);else{let f=l.widget||(l.block?ws.block:ws.inline),d=j5(l),m=this.cache.findWidget(f,a-o,d)||sa.of(f,this.view,a-o,d);l.block?(l.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(m)):(r.ensureLine(n),r.addInlineWidget(m,c,u))}n=null}else n=B5(n,l);a>o&&this.text.skip(a-o)},span:(o,a,l,c)=>{for(let u=o;u<a;){let h=this.text.next(Math.min(512,a-u));h==null?(r.addLineStartIfNotCovered(n),r.addBreak(),u++):(r.ensureLine(n),r.addText(h,l,u==o?c:l.length),u+=h.length),n=null}i=l.length}});i>-1&&(this.openWidget=s>i),this.openWidget||r.addLineStartIfNotCovered(n),this.openMarks=s}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 i=Ne.get(r);if(r==this.view.contentDOM)break;i instanceof Nt?t.push(i):i?.isLine()?n=i:i instanceof hi||(r.nodeName=="DIV"&&!n?n=new Rc(r,_A):n||t.push(Nt.of(new Zm({tagName:r.nodeName.toLowerCase(),attributes:h5(r)}),r)))}return n?{line:n,marks:t}:null}};function jy(e,t){let n=r=>{for(let i of r.children)if((t?i.isText():i.length)||n(i))return!0;return!1};return n(e)}function j5(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 _A={class:"cm-line"};function B5(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r||(e||(e={class:"cm-line"}),n&&Xm(n,e),r&&(e.class+=" "+r)),e}function F5(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 Nt&&t.push(r.mark)}return t}function Bh(e){let t=Ne.get(e);return t&&t.setDOM(e.cloneNode()),e}var ws=class extends bu{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}};ws.inline=new ws("span");ws.block=new ws("div");var Fh=new class extends bu{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},By=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Me.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 ku(e,e.contentDOM),this.updateInner([new er(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:!G5(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let i=r>-1?z5(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:u}=this.hasComposition;n=new er(c,u,e.changes.mapPos(c,-1),e.changes.mapPos(u,1)).addToSet(n.slice())}this.hasComposition=i?{from:i.range.fromB,to:i.range.toB}:null,(U.ie||U.chrome)&&!i&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let s=this.decorations,o=this.blockWrappers;this.updateDeco();let a=W5(s,this.decorations,e.changes);a.length&&(n=er.extendWithRanges(n,a));let l=q5(o,this.blockWrappers,e.changes);return l.length&&(n=er.extendWithRanges(n,l)),i&&!n.some(c=>c.fromA<=i.range.fromA&&c.toA>=i.range.toA)&&(n=i.range.addToSet(n.slice())),this.tile.flags&2&&n.length==0?!1:(this.updateInner(n,i),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 s=this.tile,o=new _5(this.view,s,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Ne.get(t.text)&&o.cache.reused.set(Ne.get(t.text),2),this.tile=o.run(e,t),Yd(s,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 i=U.chrome||U.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(i),i&&(i.written||n.selectionRange.focusNode!=i.node||!this.tile.dom.contains(i.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 i of this.tile.children)i.isWidget()&&i.widget instanceof Vh&&r.push(i.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(CA)&&(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,i=r==n,s=!i&&!(this.view.state.facet(Qn)||n.tabIndex>-1)&&Po(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||s))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)),U.gecko&&a.empty&&!this.hasComposition&&V5(l)){let h=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(h,l.node.childNodes[l.offset]||null)),l=c=new Tr(h,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!Io(l.node,l.offset,u.anchorNode,u.anchorOffset)||!Io(c.node,c.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{U.android&&U.chrome&&n.contains(u.focusNode)&&K5(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let h=ra(this.view.root);if(h)if(a.empty){if(U.gecko){let f=$5(l.node,l.offset);if(f&&f!=3){let d=(f==1?lA:cA)(l.node,l.offset);d&&(l=new Tr(d.node,d.offset))}}h.collapse(l.node,l.offset),a.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=a.bidiLevel)}else if(h.extend){h.collapse(l.node,l.offset);try{h.extend(c.node,c.offset)}catch{}}else{let f=document.createRange();a.anchor>a.head&&([l,c]=[c,l]),f.setEnd(c.node,c.offset),f.setStart(l.node,l.offset),h.removeAllRanges(),h.addRange(f)}s&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(l,c)),this.impreciseAnchor=l.precise?null:new Tr(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new Tr(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Io(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=ra(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let s=this.lineAt(t.head,t.assoc);if(!s)return;let o=s.posAtStart;if(t.head==o||t.head==o+s.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,i)}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 i;if(e==n.dom)i=n.dom.childNodes[t];else{let s=lr(e)==0?0:t==0?-1:1;for(;;){let o=e.parentNode;if(o==n.dom)break;s==0&&o.firstChild!=o.lastChild&&(e==o.firstChild?s=-1:s=1),e=o}s<0?i=e:i=e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!Ne.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let s=0,o=r;;s++){let a=n.children[s];if(a.dom==i)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,i=!1,s,o=-1,a=!1;return this.tile.blockTiles((l,c)=>{if(l.isWidget()){if(l.flags&32&&c>=e)return!0;l.flags&16&&(i=!0)}else{let u=c+l.length;if(c<=e&&(n=l,r=e-c,i=u<e),u>=e&&!s&&(s=l,o=e-c,a=c>e),c>e&&s)return!0}}),!n&&!s?this.domAtPos(e,t):(i&&s?n=null:a&&n&&(s=null),n&&t<0||!s?n.domIn(r,t):s.domIn(o,t))}coordsAt(e,t,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof Vh?null:r.coordsInWidget(i,t,!0):r.coordsIn(i,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(i,s){if(i.isComposite())for(let o of i.children){if(o.length>=s){let a=r(o,s);if(a)return a}if(s-=o.length,s<0)break}else if(i.isText()&&s<i.length){let o=ct(i.text,s);if(o==s)return null;let a=ia(i.dom,s,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,i=this.view.contentDOM.clientWidth,s=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,a=this.view.textDirection==Ee.LTR,l=0,c=(u,h,f)=>{for(let d=0;d<u.children.length&&!(h>r);d++){let m=u.children[d],v=h+m.length,y=m.dom.getBoundingClientRect(),{height:x}=y;if(f&&!d&&(l+=y.top-f.top),m instanceof hi)v>n&&c(m,h,y);else if(h>=n&&(l>0&&t.push(-l),t.push(x+l),l=0,s)){let b=m.dom.lastChild,w=b?Ql(b):[];if(w.length){let S=w[w.length-1],C=a?S.right-y.left:y.right-S.left;C>o&&(o=C,this.minWidth=i,this.minWidthFrom=h,this.minWidthTo=v)}}f&&d==u.children.length-1&&(l+=f.bottom-y.bottom),h=v+m.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?Ee.RTL:Ee.LTR}measureTextSize(){let e=this.tile.blockTiles(s=>{if(s.isLine()&&s.children.length&&s.length<=20){let o=0,a;for(let l of s.children){if(!l.isText()||/[^ -~]/.test(l.text))return;let c=Ql(l.dom);if(c.length!=1)return;o+=c[0].width,a=c[0].height}if(o)return{lineHeight:s.dom.getBoundingClientRect().height,charWidth:o/s.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),n,r,i;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 s=Ql(t.firstChild)[0];n=t.getBoundingClientRect().height,r=s&&s.width?s.width/27:7,i=s&&s.height?s.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],s=i?i.from-1:this.view.state.doc.length;if(s>n){let o=(t.lineBlockAt(s).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(Me.replace({widget:new Vh(o),block:!0,inclusive:!0,isBlockGap:!0}).range(n,s))}if(!i)break;n=i.to+1}return Me.set(e)}updateDeco(){let e=1,t=this.view.state.facet(wu).map(i=>(this.dynamicDecorationMap[e++]=typeof i=="function")?i(this.view):i),n=!1,r=this.view.state.facet(sg).map((i,s)=>{let o=typeof i=="function";return o&&(n=!0),o?i(this.view):i});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(Ae.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(TA).map(i=>typeof i=="function"?i(this.view):i)}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(kA))try{if(l(this.view,e.range,e))return!0}catch(c){Mn(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 i=RA(this.view),s={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:a}=this.view.scrollDOM;if(p5(this.view.scrollDOM,s,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==Ee.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=iA(l.dom);l.dom.scrollIntoView({block:"nearest"}),sA(c,!1)}}}lineHasWidget(e){let t=n=>n.isWidget()||n.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Yd(this.tile)}};function Yd(e,t){let n=t?.get(e);if(n!=1){n==null&&e.destroy();for(let r of e.children)Yd(r,t)}}function V5(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 jA(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=lA(n.focusNode,n.focusOffset),i=cA(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let a=Ne.get(i.node);if(!a||a.isText()&&a.text!=i.node.nodeValue)s=i;else if(e.docView.lastCompositionAfterCursor){let l=Ne.get(r.node);!l||l.isText()&&l.text!=r.node.nodeValue||(s=i)}}if(e.docView.lastCompositionAfterCursor=s!=r,!s)return null;let o=t-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function z5(e,t,n){let r=jA(e,n);if(!r)return null;let{node:i,from:s,to:o}=r,a=i.nodeValue;if(/[\n\r]/.test(a)||e.state.doc.sliceString(r.from,r.to)!=a)return null;let l=t.invertedDesc;return{range:new er(l.mapPos(s),l.mapPos(o),s,o),text:i}}function $5(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 H5=class{constructor(){this.changes=[]}compareRange(t,n){os(t,n,this.changes)}comparePoint(t,n){os(t,n,this.changes)}boundChange(t){os(t,t,this.changes)}};function W5(e,t,n){let r=new H5;return Ae.compare(e,t,n,r),r.changes}var U5=class{constructor(){this.changes=[]}compareRange(e,t){os(e,t,this.changes)}comparePoint(){}boundChange(e){os(e,e,this.changes)}};function q5(e,t,n){let r=new U5;return Ae.compare(e,t,n,r),r.changes}function K5(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 G5(e,t){let n=!1;return t&&e.iterChangedRanges((r,i)=>{r<t.to&&i>t.from&&(n=!0)}),n}var Vh=class extends bu{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 Q5(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),s=t-i.from;if(i.length==0)return z.cursor(t);s==0?n=1:s==i.length&&(n=-1);let o=s,a=s;n<0?o=ct(i.text,s,!1):a=ct(i.text,s);let l=r(i.text.slice(o,a));for(;o>0;){let c=ct(i.text,o,!1);if(r(i.text.slice(c,o))!=l)break;o=c}for(;a<i.length;){let c=ct(i.text,a);if(r(i.text.slice(a,c))!=l)break;a=c}return z.undirectionalRange(o+i.from,a+i.from)}function Y5(e,t,n,r,i){let s=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((i-n.top-(e.defaultLineHeight-a)*.5)/a);s+=l*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+s5(o,s,e.state.tabSize)}function Xd(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let i;for(let s of r.type){if(s.from>t)break;if(!(s.to<t)){if(s.from<t&&s.to>t)return s;(!i||s.type==ot.Text&&(i.type!=s.type||(n<0?s.from<t:s.to>t)))&&(i=s)}}return i||r}return r}function X5(e,t,n,r){let i=Xd(e,t.head,t.assoc||-1),s=!r||i.type!=ot.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(s){let o=e.dom.getBoundingClientRect(),a=e.textDirectionAt(i.from),l=e.posAtCoords({x:n==(a==Ee.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(l!=null)return z.cursor(l,n?-1:1)}return z.cursor(n?i.to:i.from,n?-1:1)}function Fy(e,t,n,r){let i=e.state.doc.lineAt(t.head),s=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let a=t,l=null;;){let c=A5(i,s,o,a,n),u=pA;if(!c){if(i.number==(n?e.state.doc.lines:1))return a;u=`
59
- `,i=e.state.doc.line(i.number+(n?1:-1)),s=e.bidiSpans(i),c=n?z.cursor(i.from,-1):z.cursor(i.to,1)}if(l){if(!l(u))return a}else{if(!r)return c;l=r(u)}a=c}}function J5(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return s=>{let o=r(s);return i==Zn.Space&&(i=o),i==o}}function Z5(e,t,n,r){let i=t.head,s=n?1:-1;if(i==(n?e.state.doc.length:0))return z.cursor(i,t.assoc);let o=t.goalColumn,a,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(c)o==null&&(o=c.left-l.left),a=s<0?c.top:c.bottom;else{let m=e.viewState.lineBlockAt(i);o==null&&(o=Math.min(l.right-l.left,e.defaultCharacterWidth*(i-m.from))),a=(s<0?m.top:m.bottom)+u}let h=l.left+o,f=e.viewState.heightOracle.textHeight>>1,d=r??f;for(let m=0;;m+=f){let v=a+(d+m)*s,y=Jd(e,{x:h,y:v},!1,s);if(n?v>l.bottom:v<l.top)return z.cursor(y.pos,y.assoc);let x=e.coordsAtPos(y.pos,y.assoc),b=x?(x.top+x.bottom)/2:0;if(!x||(n?b>a:b<a))return z.cursor(y.pos,y.assoc,void 0,o)}}function Oo(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(s,o,a)=>{if(t>s&&t<o){let l=r||n||(t-s<o-t?-1:1);t=l<0?s:o,r=l}});if(!r)return t}}function BA(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],s=null;if(i.empty){let o=Oo(e,i.from,0);o!=i.from&&(s=z.cursor(o,-1))}else{let o=Oo(e,i.from,-1),a=Oo(e,i.to,1);(o!=i.from||a!=i.to)&&(i.undirectional?s=z.undirectionalRange(i.from,i.to):s=z.range(i.from==i.anchor?o:a,i.from==i.head?o:a))}s&&(n||(n=t.ranges.slice()),n[r]=s)}return n?z.create(n,t.mainIndex):t}function zh(e,t,n){let r=Oo(e.state.facet(Ra).map(i=>i(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:z.cursor(r,r<n.from?1:-1)}var Cn=class{constructor(e,t){this.pos=e,this.assoc=t}};function Jd(e,t,n,r){let i=e.contentDOM.getBoundingClientRect(),s=i.top+e.viewState.paddingTop,{x:o,y:a}=t,l=a-s,c;for(;;){if(l<0)return new Cn(0,1);if(l>e.viewState.docHeight)return new Cn(e.state.doc.length,-1);if(c=e.elementAtHeight(l),r==null)break;if(c.type==ot.Text){if(r<0?c.to<e.viewport.from:c.from>e.viewport.to)break;let f=e.docView.coordsAt(r<0?c.from:c.to,r>0?-1:1);if(f&&(r<0?f.top<=l+s:f.bottom>=l+s))break}let h=e.viewState.heightOracle.textHeight/2;l=r>0?c.bottom+h:c.top-h}if(e.viewport.from>=c.to||e.viewport.to<=c.from){if(n)return null;if(c.type==ot.Text){let h=Y5(e,i,c,o,a);return new Cn(h,h==c.from?1:-1)}}if(c.type!=ot.Text)return l<(c.top+c.bottom)/2?new Cn(c.from,1):new Cn(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 e3(e,o,a,e.textDirectionAt(c.from)).scanTile(u,c.from)}var e3=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[En.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[En.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,i=e.length-1,s=new Set,o=this.bidiIn(e[0],e[i]),a,l,c=-1,u=1e9,h;e:for(;r<i;){let d=i-r,m=r+i>>1;t:if(s.has(m)){for(let x=1;x<d;x++){let b=m+x;if(b>=i&&(b-=d),!s.has(b)){m=b;break t}}break e}s.add(m);let v=t(m),y=0;if(v)for(let x=0;x<v.length;x++){let b=v[x];if(!(b.width==0&&v.length>1))if(b.bottom<this.y)(!a||a.bottom<b.bottom)&&(a=b),y=1;else if(b.top>this.y)(!l||l.top>b.top)&&(l=b),y=-1;else{let w=b.left>this.x?this.x-b.left:b.right<this.x?this.x-b.right:0,S=Math.abs(w);S<u&&(c=m,u=S,h=b),w&&(y=w<0==(this.baseDir==Ee.LTR)?-1:1)}}y==-1&&(!o||this.baseDirAt(e[m],1))?i=m:y==1&&(!o||this.baseDirAt(e[m+1],-1))&&(r=m+1)}if(!h){if(!l&&!a)return{i:0,after:!1};let d=a&&(!l||this.y-a.bottom<l.top-this.y)?a:l;return this.y=(d.top+d.bottom)/2,this.scan(e,t,!0)}if(u&&!n){let{top:d,bottom:m}=h;if(a&&a.bottom>(d+d+m)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(l&&l.top<(d+m+m)/3)return this.y=l.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[c],1):this.baseDir)==Ee.LTR;return{i:c,after:this.x>(h.left+h.right)/2==f}}scanText(e,t){let n=[];for(let i=0;i<e.length;i=ct(e.text,i))n.push(t+i);n.push(t+e.length);let r=this.scan(n,i=>{let s=n[i]-t,o=n[i+1]-t;return ia(e.dom,s,o).getClientRects()});return r.after?new Cn(n[r.i+1],-1):new Cn(n[r.i],1)}scanTile(e,t){if(!e.length)return new Cn(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:ia(a.dom,0,a.length)).getClientRects()}),i=e.children[r.i],s=n[r.i];return i.isText()?this.scanText(i,s):i.isComposite()?this.scanTile(i,s):r.after?new Cn(n[r.i+1],-1):new Cn(s,1)}},Yl="￿",t3=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(Ve.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Yl}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let i=this.text.length;this.readNode(r);let s=Ne.get(r),o=r.nextSibling;if(o==t){s?.breakAfter&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let a=Ne.get(o);(s&&a?s.breakAfter:(s?s.breakAfter:Ec(r))||Ec(o)&&(r.nodeName!="BR"||s?.isWidget())&&this.text.length>i)&&!r3(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 i=-1,s=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,s=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),s>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=s-1);n=i+s}}readNode(e){let t=Ne.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+(n3(e,n.node,n.offset)?t:0))}};function n3(e,t,n){for(;;){if(!t||n<lr(t))return!1;if(t==e)return!0;n=_r(t)+1,t=t.parentNode}}function r3(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let r=Ne.get(e);if(!r?.isWidget())return!1;r&&(n||(n=[])).push(r)}if(n)for(let r of n){let i=r.overrideDOMText;if(i?.length)return!1}return!0}var Vy=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},i3=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:s}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=FA(e.docView.tile,t,n,0))){let a=i||s?[]:o3(e),l=new t3(a,e);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=a3(a,this.bounds.from)}else{let a=e.observer.selectionRange,l=i&&i.node==a.focusNode&&i.offset==a.focusOffset||!zd(e.contentDOM,a.focusNode)?o.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=s&&s.node==a.anchorNode&&s.offset==a.anchorOffset||!zd(e.contentDOM,a.anchorNode)?o.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=e.viewport;if((U.ios||U.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 h=Math.min(l,c),f=Math.max(l,c),d=u.from-h,m=u.to-f;(d==0||d==1||h==0)&&(m==0||m==-1||f==e.state.doc.length)&&(l=0,c=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(z.range(c,l));else if(e.lineWrapping&&c==l&&!(o.main.empty&&o.main.head==l)&&e.inputState.lastTouchTime>Date.now()-100){let h=e.coordsAtPos(l,-1),f=0;h&&(f=e.inputState.lastTouchY<=h.bottom?-1:1),this.newSel=z.create([z.cursor(l,f)])}else this.newSel=z.single(c,l)}}};function FA(e,t,n,r){if(e.isComposite()){let i=-1,s=-1,o=-1,a=-1;for(let l=0,c=r,u=r;l<e.children.length;l++){let h=e.children[l],f=c+h.length;if(c<t&&f>n)return FA(h,t,n,c);if(f>=t&&i==-1&&(i=l,s=c),c>n&&h.dom.parentNode==e.dom){o=l,a=u;break}u=f,c=f+h.breakAfter}return{from:s,to:a<0?r+e.length:a,startDOM:(i?e.children[i-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 VA(e,t){let n,{newSel:r}=t,{state:i}=e,s=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:a,to:l}=t.bounds,c=s.from,u=null;(o===8||U.android&&t.text.length<l-a)&&(c=s.to,u="end");let h=i.doc.sliceString(a,l,Yl),f,d;!s.empty&&s.from>=a&&s.to<=l&&(t.typeOver||h!=t.text)&&h.slice(0,s.from-a)==t.text.slice(0,s.from-a)&&h.slice(s.to-a)==t.text.slice(f=t.text.length-(h.length-(s.to-a)))?n={from:s.from,to:s.to,insert:me.of(t.text.slice(s.from-a,f).split(Yl))}:(d=zA(h,t.text,c-a,u))&&(U.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)=="￿￿"&&d.toB--,n={from:a+d.from,to:a+d.toA,insert:me.of(t.text.slice(d.from,d.toB).split(Yl))})}else r&&(!e.hasFocus&&i.facet(Qn)||Oc(r,s))&&(r=null);if(!n&&!r)return!1;if((U.mac||U.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=z.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:me.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(s.from).to<s.to&&e.docView.lineHasWidget(s.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:s.from,to:s.to,insert:i.toText(e.inputState.insertingText)}:U.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==`
60
- `&&e.lineWrapping&&(r&&(r=z.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:me.of([" "])}),n)return og(e,n,r,o);if(r&&!Oc(r,s)){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=BA(i.facet(Ra).map(c=>c(e)),r))),e.dispatch({selection:r,scrollIntoView:a,userEvent:l}),!0}else return!1}function og(e,t,n,r=-1){if(U.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(U.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&as(e.contentDOM,"Enter",13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>i.head)&&as(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&as(e.contentDOM,"Delete",46)))return!0;let s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,a=()=>o||(o=s3(e,t,n));return e.state.facet(xA).some(l=>l(e,t.from,t.to,s,a))||e.dispatch(a()),!0}function s3(e,t,n){let r,i=e.state,s=i.selection.main,o=-1;if(t.from==t.to&&t.from<s.from||t.from>s.to){let l=t.from<s.from?-1:1,c=l<0?s.from:s.to,u=Oo(i.facet(Ra).map(h=>h(e)),c,l);t.from==u&&(o=u)}if(o>-1)r={changes:t,selection:z.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let l=s.from<t.from?i.sliceDoc(s.from,t.from):"",c=s.to>t.to?i.sliceDoc(t.to,s.to):"";r=i.replaceSelection(e.state.toText(l+t.insert.sliceString(0,void 0,e.state.lineBreak)+c))}else{let l=i.changes(t),c=n&&n.main.to<=l.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=s.to+10&&t.to>=s.to-10){let u=e.state.sliceDoc(t.from,t.to),h,f=n&&jA(e,n.main.head);if(f){let m=t.insert.length-(t.to-t.from);h={from:f.from,to:f.to-m}}else h=e.state.doc.lineAt(s.head);let d=s.to-t.to;r=i.changeByRange(m=>{if(m.from==s.from&&m.to==s.to)return{changes:l,range:c||m.map(l)};let v=m.to-d,y=v-u.length;if(e.state.sliceDoc(y,v)!=u||v>=h.from&&y<=h.to)return{range:m};let x=i.changes({from:y,to:v,insert:t.insert}),b=m.to-s.to;return{changes:x,range:c?z.range(Math.max(0,c.anchor+b),Math.max(0,c.head+b)):m.map(x)}})}else r={changes:l,selection:c&&i.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)),i.update(r,{userEvent:a,scrollIntoView:!0})}function zA(e,t,n,r){let i=Math.min(e.length,t.length),s=0;for(;s<i&&e.charCodeAt(s)==t.charCodeAt(s);)s++;if(s==i&&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,s-Math.min(o,a));n-=o+l-s}if(o<s&&e.length<t.length){let l=n<=s&&n>=o?s-n:0;s-=l,a=s+(a-o),o=s}else if(a<s){let l=n<=s&&n>=a?s-n:0;s-=l,o=s+(o-a),a=s}return{from:s,toA:o,toB:a}}function o3(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=e.observer.selectionRange;return n&&(t.push(new Vy(n,r)),(i!=n||s!=r)&&t.push(new Vy(i,s))),t}function a3(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?z.create([z.cursor(r+t,-1)]):z.single(n+t,r+t)}function Oc(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var l3=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,U.safari&&e.contentDOM.addEventListener("input",()=>null),U.gecko&&C3(e.contentDOM.ownerDocument)}handleEvent(e){!v3(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=u3(e),n=this.handlers,r=this.view.contentDOM;for(let i in t)if(i!="scroll"){let s=!t[i].handlers.length,o=n[i];o&&s!=!o.handlers.length&&(r.removeEventListener(i,this.handleEvent),o=null),o||r.addEventListener(i,this.handleEvent,{passive:s})}for(let i in n)i!="scroll"&&!t[i]&&r.removeEventListener(i,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&&HA.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),U.android&&U.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(U.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&($A.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||h3.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&U.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&c3(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,as(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:U.safari&&!U.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 c3(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function zy(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(i){Mn(n.state,i)}}}function u3(e){let t=Object.create(null);function n(r){return t[r]||(t[r]={observers:[],handlers:[]})}for(let r of e){let i=r.spec,s=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(s)for(let a in s){let l=s[a];l&&n(a).handlers.push(zy(r.value,l))}if(o)for(let a in o){let l=o[a];l&&n(a).observers.push(zy(r.value,l))}}for(let r in an)n(r).handlers.push(an[r]);for(let r in mt)n(r).observers.push(mt[r]);return t}var $A=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],h3="dthko",HA=[16,17,18,20,91,92,224,225],cl=6;function ul(e){return Math.max(0,e)*.7+8}function f3(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var d3=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=rA(e.contentDOM),this.atoms=e.state.facet(Ra).map(s=>s(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Ve.allowMultipleSelections)&&p3(e,t),this.dragging=g3(e,t)&&qA(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&&f3(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,s=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:s}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let a=RA(this.view);e.clientX-a.left<=r+cl?t=-ul(r-e.clientX):e.clientX+a.right>=s-cl&&(t=ul(e.clientX-s)),e.clientY-a.top<=i+cl?n=-ul(i-e.clientY):e.clientY+a.bottom>=o-cl&&(n=ul(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=BA(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 p3(e,t){let n=e.state.facet(mA);return n.length?n[0](t):U.mac?t.metaKey:t.ctrlKey}function m3(e,t){let n=e.state.facet(gA);return n.length?n[0](t):U.mac?!t.altKey:!t.ctrlKey}function g3(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=ra(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s<i.length;s++){let o=i[s];if(o.left<=t.clientX&&o.right>=t.clientX&&o.top<=t.clientY&&o.bottom>=t.clientY)return!0}return!1}function v3(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=Ne.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var an=Object.create(null),mt=Object.create(null),WA=U.ie&&U.ie_version<15||U.ios&&U.webkit_version<604;function y3(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(),UA(e,n.value)},50)}function Cu(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function UA(e,t){t=Cu(e.state,ng,t);let{state:n}=e,r,i=1,s=n.toText(t),o=s.lines==n.selection.ranges.length;if(Zd!=null&&n.selection.ranges.every(a=>a.empty)&&Zd==s.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?s.line(i++).text:t)+n.lineBreak);return{changes:{from:c.from,insert:u},range:z.cursor(l.from+u.length,-1)}})}else o?r=n.changeByRange(a=>{let l=s.line(i++);return{changes:{from:a.from,to:a.to,insert:l.text},range:z.cursor(a.from+l.length,-1)}}):r=n.replaceSelection(s);e.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}mt.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,U.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())};mt.wheel=mt.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()};an.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1);mt.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")};mt.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")};mt.touchend=(e,t)=>{e.inputState.touchActive=!1};an.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(vA))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=b3(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new d3(e,t,n,r)),r&&e.observer.ignore(()=>{oA(e.contentDOM);let s=e.root.activeElement;s&&!s.contains(e.contentDOM)&&s.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin("select.pointer");return!1};function $y(e,t,n,r){if(r==1)return z.cursor(t,n);if(r==2)return Q5(e.state,t,n);{let i=e.docView.lineAt(t,n),s=e.state.doc.lineAt(i?i.posAtEnd:t),o=i?i.posAtStart:s.from,a=i?i.posAtEnd:s.to;return a<e.state.doc.length&&a==s.to&&a++,z.undirectionalRange(o,a)}}var x3=U.ie&&U.ie_version<=11,Hy=null,Wy=0,Uy=0;function qA(e){if(!x3)return e.detail;let t=Hy,n=Uy;return Hy=e,Uy=Date.now(),Wy=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Wy+1)%3:1}function b3(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=qA(t),i=e.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),i=i.map(s.changes))},get(s,o,a){let l=e.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),c,u=$y(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){let h=$y(e,n.pos,n.assoc,r),f=Math.min(h.from,u.from),d=Math.max(h.to,u.to);u=f<u.from?z.range(f,d,u.assoc):z.range(d,f,u.assoc)}return o?i.replaceRange(i.main.extend(u.from,u.to,u.assoc)):a&&r==1&&i.ranges.length>1&&(c=w3(i,l.pos))?c:a?i.addRange(u):z.create([u])}}}function w3(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return z.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}an.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let i=e.docView.tile.nearest(t.target);if(i&&i.isWidget()){let s=i.posAtStart,o=s+i.length;(s>=n.to||o<=n.from)&&(n=z.undirectionalRange(s,o))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",Cu(e.state,rg,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1};an.dragend=e=>(e.inputState.draggedContent=null,!1);function qy(e,t,n,r){if(n=Cu(e.state,ng,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:s}=e.inputState,o=r&&s&&m3(e,t)?{from:s.from,to:s.to}:null,a={from:i,insert:n},l=e.state.changes(o?[o,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),e.inputState.draggedContent=null}an.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),i=0,s=()=>{++i==n.length&&qy(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=s,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(r[o]=a.result),s()},a.readAsText(n[o])}return!0}else{let r=t.dataTransfer.getData("Text");if(r)return qy(e,t,r,!0),!0}return!1};an.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=WA?null:t.clipboardData;return n?(UA(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(y3(e),!1)};function S3(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 k3(e){let t=[],n=[],r=!1;for(let i of e.selection.ranges)i.empty||(t.push(e.sliceDoc(i.from,i.to)),n.push(i));if(!t.length){let i=-1;for(let{from:s}of e.selection.ranges){let o=e.doc.lineAt(s);o.number>i&&(t.push(o.text),n.push({from:o.from,to:Math.min(e.doc.length,o.to+1)})),i=o.number}r=!0}return{text:Cu(e,rg,t.join(e.lineBreak)),ranges:n,linewise:r}}var Zd=null;an.copy=an.cut=(e,t)=>{if(!Po(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=k3(e.state);if(!n&&!i)return!1;Zd=i?n:null,t.type=="cut"&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=WA?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(S3(e,n),!1)};var KA=Ci.define();function GA(e,t){let n=[];for(let r of e.facet(bA)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:KA.of(!0)}):null}function QA(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=GA(e.state,t);n?e.dispatch(n):e.update([])}},10)}mt.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),QA(e)};mt.blur=e=>{e.observer.clearSelectionRange(),QA(e)};mt.compositionstart=mt.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}};mt.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,U.chrome&&U.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))};mt.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()};an.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 s=(n=t.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=t.getTargetRanges();if(s&&o.length){let a=o[0];return og(e,{from:e.posAtDOM(a.startContainer,a.startOffset),to:e.posAtDOM(a.endContainer,a.endOffset),insert:e.state.toText(s)},null),!0}}let i;if(U.chrome&&U.android&&(i=$A.find(s=>s.inputType==t.inputType))&&(e.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((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)>s+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return U.ios&&t.inputType=="deleteContentForward"&&e.observer.flushSoon(),U.safari&&t.inputType=="insertText"&&e.inputState.composing>=0&&setTimeout(()=>mt.compositionend(e,t),20),!1};var Ky=new Set;function C3(e){Ky.has(e)||(Ky.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}var Gy=["pre-wrap","normal","pre-line","break-spaces"],Ss=!1;function Qy(){Ss=!1}var A3=class{constructor(e){this.lineWrapping=e,this.doc=me.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 Gy.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,i,s){let o=Gy.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=i,a){this.heightSamples={};for(let l=0;l<s.length;l++){let c=s[l];c<0?l++:this.heightSamples[Math.floor(c*10)]=!0}}return a}},T3=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},Yn=class YA{constructor(t,n,r,i,s){this.from=t,this.length=n,this.top=r,this.height=i,this._content=s}get type(){return typeof this._content=="number"?ot.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 na?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 YA(this.from,this.length+t.length,this.top,this.height+t.height,n)}},Se=(function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e})(Se||(Se={})),Xl=.001,rn=class Jl{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)>Xl&&(Ss=!0),this.height=t)}replace(t,n,r){return Jl.of(r)}decomposeLeft(t,n){n.push(this)}decomposeRight(t,n){n.push(this)}applyChanges(t,n,r,i){let s=this,o=r.doc;for(let a=i.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:h}=i[a],f=s.lineAt(l,Se.ByPosNoHeight,r.setDoc(n),0,0),d=f.to>=c?f:s.lineAt(c,Se.ByPosNoHeight,r,0,0);for(h+=d.to-c,c=d.to;a>0&&f.from<=i[a-1].toA;)l=i[a-1].fromA,u=i[a-1].fromB,a--,l<f.from&&(f=s.lineAt(l,Se.ByPosNoHeight,r,0,0));u+=f.from-l,l=f.from;let m=P3.build(r.setDoc(o),t,u,h);s=Dc(s,s.replace(l,c,m))}return s.updateHeight(r,0)}static empty(){return new wn(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,i=0,s=0;for(;;)if(n==r)if(i>s*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,i-=a.size}else if(s>i*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,s-=a.size}else break;else if(i<s){let a=t[n++];a&&(i+=a.size)}else{let a=t[--r];a&&(s+=a.size)}let o=!1;return t[n-1]==null?(o=!0,n--):t[n]==null&&(o=!0,r++),new M3(Jl.of(t.slice(0,n)),o,Jl.of(t.slice(r)))}};function Dc(e,t){return e==t?e:(e.constructor!=t.constructor&&(Ss=!0),t)}rn.prototype.size=1;var E3=Me.replace({}),XA=class extends rn{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new Yn(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 Yn(r,0,n,this.spaceAbove,E3):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let s=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(s):s}forEachLine(e,t,n,r,i,s){e<=i+this.length&&t>=i&&s(this.lineAt(0,Se.ByPos,n,r,i))}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})`}},wn=class ep extends XA{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 Yn(n,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof ep||i instanceof ls&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof ls?i=new ep(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):rn.of(r)}updateHeight(t,n=0,r=!1,i){return i&&i.from<=n&&i.more?this.setMeasuredHeight(i):(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:""})`}},ls=class qt extends rn{constructor(t){super(t,0)}heightMetrics(t,n){let r=t.doc.lineAt(n).number,i=t.doc.lineAt(n+this.length).number,s=i-r+1,o,a=0;if(t.lineWrapping){let l=Math.min(this.height,t.lineHeight*s);o=l/s,this.length>s+1&&(a=(this.height-l)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:i,perLine:o,perChar:a}}blockAt(t,n,r,i){let{firstLine:s,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(n,i);if(n.lineWrapping){let c=i+(t<n.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-r)/this.height))*this.length)),u=n.doc.lineAt(c),h=a+u.length*l,f=Math.max(r,t-h/2);return new Yn(u.from,u.length,f,h,0)}else{let c=Math.max(0,Math.min(o-s,Math.floor((t-r)/a))),{from:u,length:h}=n.doc.line(s+c);return new Yn(u,h,r+a*c,a,0)}}lineAt(t,n,r,i,s){if(n==Se.ByHeight)return this.blockAt(t,r,i,s);if(n==Se.ByPosNoHeight){let{from:d,to:m}=r.doc.lineAt(t);return new Yn(d,m-d,0,0,0)}let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(r,s),c=r.doc.lineAt(t),u=a+c.length*l,h=c.number-o,f=i+a*h+l*(c.from-s-h);return new Yn(c.from,c.length,Math.max(i,Math.min(f,i+this.height-u)),u,0)}forEachLine(t,n,r,i,s,o){t=Math.max(t,s),n=Math.min(n,s+this.length);let{firstLine:a,perLine:l,perChar:c}=this.heightMetrics(r,s);for(let u=t,h=i;u<=n;){let f=r.doc.lineAt(u);if(u==t){let m=f.number-a;h+=l*m+c*(t-s-m)}let d=l+c*f.length;o(new Yn(f.from,f.length,h,d,0)),h+=d,u=f.to+1}}replace(t,n,r){let i=this.length-n;if(i>0){let s=r[r.length-1];s instanceof qt?r[r.length-1]=new qt(s.length+i):r.push(null,new qt(i-1))}if(t>0){let s=r[0];s instanceof qt?r[0]=new qt(t+s.length):r.unshift(new qt(t-1),null)}return rn.of(r)}decomposeLeft(t,n){n.push(new qt(t-1),null)}decomposeRight(t,n){n.push(null,new qt(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let s=n+this.length;if(i&&i.from<=n+this.length&&i.more){let o=[],a=Math.max(n,i.from),l=-1;for(i.from>n&&o.push(new qt(i.from-n-1).updateHeight(t,n));a<=s&&i.more;){let u=t.doc.lineAt(a).length;o.length&&o.push(null);let h=i.heights[i.index++],f=0;h<0&&(f=-h,h=i.heights[i.index++]),l==-1?l=h:Math.abs(h-l)>=Xl&&(l=-2);let d=new wn(u,h,f);d.outdated=!1,o.push(d),a+=u+1}a<=s&&o.push(null,new qt(s-a).updateHeight(t,a));let c=rn.of(o);return(l<0||Math.abs(c.height-this.height)>=Xl||Math.abs(l-this.heightMetrics(t,n).perLine)>=Xl)&&(Ss=!0),Dc(this,c)}else(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},M3=class extends rn{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 i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let s=r+this.left.height,o=i+this.left.length+this.break,a=t==Se.ByHeight?e<s:e<o,l=a?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,s,o);if(this.break||(a?l.to<o:l.from>o))return l;let c=t==Se.ByPosNoHeight?Se.ByPosNoHeight:Se.ByPos;return a?l.join(this.right.lineAt(o,c,n,s,o)):this.left.lineAt(o,c,n,r,i).join(l)}forEachLine(e,t,n,r,i,s){let o=r+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,i,s),t>=a&&this.right.forEachLine(e,t,n,o,a,s);else{let l=this.lineAt(a,Se.ByPos,n,r,i);e<l.from&&this.left.forEachLine(e,Math.min(t,l.from-1),n,r,i,s),l.to>=e&&l.from<=t&&s(l),t>l.to&&this.right.forEachLine(Math.max(e,l.to+1),t,n,o,a,s)}}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 i=[];e>0&&this.decomposeLeft(e,i);let s=i.length;for(let o of n)i.push(o);if(e>0&&Yy(i,s-1),t<this.length){let o=i.length;this.decomposeRight(t,i),Yy(i,o)}return rn.of(i)}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?rn.of(this.break?[e,null,t]:[e,t]):(this.left=Dc(this.left,e),this.right=Dc(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:i,right:s}=this,o=t+i.length+this.break,a=null;return r&&r.from<=t+i.length&&r.more?a=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+s.length&&r.more?a=s=s.updateHeight(e,o,n,r):s.updateHeight(e,o,n),a?this.balanced(i,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Yy(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof ls&&(r=e[t+1])instanceof ls&&e.splice(t-1,3,new ls(n.length+1+r.length))}var R3=5,P3=class JA{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),i=this.nodes[this.nodes.length-1];i instanceof wn?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new wn(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 i=r.widget?r.widget.estimatedHeight:0,s=r.widget?r.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let o=n-t;r.block?this.addBlock(new XA(o,i,r)):(o||s||i>=R3)&&this.addLineDeco(i,s,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 wn(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,n){let r=new ls(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 wn)return t;let n=new wn(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 i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,t),i.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 wn)&&!this.isCovered?this.nodes.push(new wn(0,-1,0)):(this.writtenTo<this.pos||n==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let r=t;for(let i of this.nodes)i instanceof wn&&i.updateHeight(this.oracle,r),r+=i?i.length:1;return this.nodes}static build(t,n,r,i){let s=new JA(r,t);return Ae.spans(n,r,i,s,0),s.finish(r)}};function I3(e,t,n){let r=new O3;return Ae.compare(e,t,n,r,0),r.changes}var O3=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&os(e,t,this.changes,5)}};function D3(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,s=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(i.innerHeight,n.bottom);for(let c=e.parentNode;c&&c!=r.body;)if(c.nodeType==1){let u=c,h=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&h.overflow!="visible"){let f=u.getBoundingClientRect();s=Math.max(s,f.left),o=Math.min(o,f.right),a=Math.max(a,f.top),l=Math.min(c==e.parentNode?i.innerHeight:l,f.bottom)}c=h.position=="absolute"||h.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function N3(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 L3(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var $h=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],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return Me.replace({widget:new _3(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},_3=class extends bu{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}},Xy=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=Jy,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Ee.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(ig).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new A3(n),this.stateDeco=Zy(t),this.heightMap=rn.empty().applyChanges(this.stateDeco,me.empty,this.heightOracle.setDoc(t.doc),[new er(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=Me.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:i,to:s})=>r>=i&&r<=s)){let{from:i,to:s}=this.lineBlockAt(r);e.push(new hl(i,s))}}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?Jy:new F3(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(fo(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=Zy(this.state);let r=e.changedRanges,i=er.extendWithRanges(r,I3(n,this.stateDeco,e?e.changes:on.empty(this.state.doc.length))),s=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Qy(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=s||Ss)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=s);let a=i.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(SA)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?Ee.RTL:Ee.LTR;let s=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent==="refresh",o=t.getBoundingClientRect(),a=s||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:S,scaleY:C}=nA(t,o);(S>.005&&Math.abs(this.scaleX-S)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=S,this.scaleY=C,l|=16,s=a=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,h=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=h)&&(this.paddingTop=u,this.paddingBottom=h,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let f=rA(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let d=this.getScrollOffset();this.scrollOffset!=d&&(this.scrollAnchorHeight=-1,this.scrollOffset=d),this.scrolledToBottom=aA(this.scrollParent||e.win);let m=(this.printing?L3:D3)(t,this.paddingTop),v=m.top-this.pixelViewport.top,y=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let x=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(x!=this.inView&&(this.inView=x,x&&(a=!0)),!this.inView&&!this.scrollTarget&&!N3(e.dom))return 0;let b=o.width;if((this.contentDOMWidth!=b||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let S=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(S)&&(s=!0),s||r.lineWrapping&&Math.abs(b-this.contentDOMWidth)>r.charWidth){let{lineHeight:C,charWidth:A,textHeight:k}=e.docView.measureTextSize();s=C>0&&r.refresh(i,C,A,k,Math.max(5,b/A),S),s&&(e.docView.minWidth=0,l|=16)}v>0&&y>0?c=Math.max(v,y):v<0&&y<0&&(c=Math.min(v,y)),Qy();for(let C of this.viewports){let A=C.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(C);this.heightMap=(s?rn.empty().applyChanges(this.stateDeco,me.empty,this.heightOracle,[new er(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,s,new T3(C.from,A))}Ss&&(l|=2)}let w=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return w&&(l&2&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(l&2||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]: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,i=this.heightOracle,{visibleTop:s,visibleBottom:o}=this,a=new hl(r.lineAt(s-n*1e3,Se.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,Se.ByHeight,i,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,Se.ByPos,i,0,0),h;t.y=="center"?h=(u.top+u.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&l<a.from?h=u.top:h=u.bottom-c,a=new hl(r.lineAt(h-500,Se.ByHeight,i,0,0).from,r.lineAt(h+c+500,Se.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new hl(this.heightMap.lineAt(n,Se.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,Se.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,Se.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,Se.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:o}=this;return(e==0||r<=s-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&r>s-2e3&&i<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 $h(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,i=r>>1,s=r<<1;if(this.defaultTextDirection!=Ee.LTR&&!n)return[];let o=[],a=(c,u,h,f)=>{if(u-c<i)return;let d=this.state.selection.main,m=[d.from];d.empty||m.push(d.to);for(let y of m)if(y>c&&y<u){a(c,y-10,h,f),a(y+10,u,h,f);return}let v=B3(e,y=>y.from>=h.from&&y.to<=h.to&&Math.abs(y.from-c)<i&&Math.abs(y.to-u)<i&&!m.some(x=>y.from<x&&y.to>x));if(!v){if(u<h.to&&t&&n&&t.visibleRanges.some(x=>x.from<=u&&x.to>=u)){let x=t.moveToLineBoundary(z.cursor(u),!1,!0).head;x>c&&(u=x)}let y=this.gapSize(h,c,u,f);v=new $h(c,u,y,n||y<2e6?y:2e6)}o.push(v)},l=c=>{if(c.length<s||c.type!=ot.Text)return;let u=j3(c.from,c.to,this.stateDeco);if(u.total<s)return;let h=this.scrollTarget?this.scrollTarget.range.head:null,f,d;if(n){let m=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,v,y;if(h!=null){let x=dl(u,h),b=((this.visibleBottom-this.visibleTop)/2+m)/c.height;v=x-b,y=x+b}else v=(this.visibleTop-c.top-m)/c.height,y=(this.visibleBottom-c.top+m)/c.height;f=fl(u,v),d=fl(u,y)}else{let m=u.total*this.heightOracle.charWidth,v=r*this.heightOracle.charWidth,y=0;if(m>2e6)for(let C of e)C.from>=c.from&&C.from<c.to&&C.size!=C.displaySize&&C.from*this.heightOracle.charWidth+y<this.pixelViewport.left&&(y=C.size-C.displaySize);let x=this.pixelViewport.left+y,b=this.pixelViewport.right+y,w,S;if(h!=null){let C=dl(u,h),A=((b-x)/2+v)/m;w=C-A,S=C+A}else w=(x-v)/m,S=(b+v)/m;f=fl(u,w),d=fl(u,S)}f>c.from&&a(c.from,f,c,u),d<c.to&&a(d,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 i=dl(r,n)-dl(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){$h.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Me.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=[];Ae.spans(t,this.viewport.from,this.viewport.to,{span(i,s){n.push({from:i,to:s})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let i=0;i<n.length&&!(r&8);i++){let s=this.visibleRanges[i],o=n[i];(s.from!=o.from||s.to!=o.to)&&(r|=4,e&&e.mapPos(s.from,-1)==o.from&&e.mapPos(s.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)||fo(this.heightMap.lineAt(e,Se.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)||fo(this.heightMap.lineAt(this.scaler.fromDOM(e),Se.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 fo(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}},hl=class{constructor(e,t){this.from=e,this.to=t}};function j3(e,t,n){let r=[],i=e,s=0;return Ae.spans(n,e,t,{span(){},point(o,a){o>i&&(r.push({from:i,to:o}),s+=o-i),i=a}},20),i<t&&(r.push({from:i,to:t}),s+=t-i),{total:s,ranges:r}}function fl({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 i=0;;i++){let{from:s,to:o}=t[i],a=o-s;if(r<=a)return s+r;r-=a}}function dl(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function B3(e,t){for(let n of e)if(t(n))return n}var Jy={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function Zy(e){let t=e.facet(wu).filter(r=>typeof r!="function"),n=e.facet(sg).filter(r=>typeof r!="function");return n.length&&t.push(Ae.join(n)),t}var F3=class ZA{constructor(t,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:a,to:l})=>{let c=n.lineAt(a,Se.ByPos,t,0,0).top,u=n.lineAt(l,Se.ByPos,t,0,0).bottom;return i+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(t){for(let n=0,r=0,i=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||t<s.top)return i+(t-r)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);r=s.bottom,i=s.domBottom}}fromDOM(t){for(let n=0,r=0,i=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||t<s.domTop)return r+(t-i)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);r=s.bottom,i=s.domBottom}}eq(t){return t instanceof ZA?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 fo(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new Yn(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(i=>fo(i,t)):e._content)}var pl=ee.define({combine:e=>e.join(" ")}),tp=ee.define({combine:e=>e.indexOf(!0)>-1}),np=Nr.newName(),eT=Nr.newName(),tT=Nr.newName(),nT={"&light":"."+eT,"&dark":"."+tT};function rp(e,t,n){return new Nr(t,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return e;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):e+" "+r}})}var V3=rp("."+np,{"&":{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"}},nT),z3={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Hh=U.ie&&U.ie_version<=11,$3=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new m5,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);(U.ie&&U.ie_version<=11||U.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&&U.android&&e.constructor.EDIT_CONTEXT!==!1&&!(U.chrome&&U.chrome_version<126)&&(this.editContext=new W3(e),e.state.facet(Qn)&&(e.contentDOM.editContext=this.editContext.editContext)),Hh&&(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(Qn)?n.root.activeElement!=this.dom:!Po(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(U.ie&&U.ie_version<=11||U.android&&U.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Io(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=ra(e.root);if(!t)return!1;let n=U.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&H3(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=Po(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&v5(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,z3),Hh&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Hh&&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 i=this.delayedAndroidKey;i&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=i.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&i.force&&as(this.dom,i.key,i.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 i of e){let s=this.readMutation(i);s&&(s.typeOver&&(r=!0),t==-1?{from:t,to:n}=s:(t=Math.min(s.from,t),n=Math.max(s.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&Po(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 i=new i3(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}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=VA(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Oc(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=ex(t,e.previousSibling||e.target.previousSibling,-1),r=ex(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(Qn)!=e.state.facet(Qn)&&(e.view.contentDOM.editContext=e.state.facet(Qn)?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 ex(e,t,n){for(;t;){let r=Ne.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i!=e.dom?i:n>0?t.nextSibling:t.previousSibling}return null}function tx(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,s=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return Io(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function H3(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return tx(e,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",r,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",r,!0),n?tx(e,n):null}var W3=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:i,head:s}=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&&i<this.from?o=i:a==this.to&&i>this.to&&(a=i);let c=zA(e.state.sliceDoc(o,a),n.text,(l?r.from:r.to)-o,l?"end":null);if(!c){let h=z.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));Oc(h,r)||e.dispatch({selection:h,userEvent:"select"});return}let u={from:c.from+o,to:c.toA+o,insert:me.of(n.text.slice(c.from,c.toB).split(`
61
- `))};if((U.mac||U.android)&&u.from==s-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:o,to:a,insert:me.of([n.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let h=this.to-this.from+(u.to-u.from+u.insert.length);og(e,u,z.single(this.toEditorPos(n.selectionStart,h),this.toEditorPos(n.selectionEnd,h)))}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=[],i=null;for(let s=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);s<o;s++){let a=e.coordsForChar(s);i=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=n=>{let r=[];for(let i of n.getTextFormats()){let s=i.underlineStyle,o=i.underlineThickness;if(!/none/i.test(s)&&!/none/i.test(o)){let a=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);if(a<l){let c=`text-decoration: underline ${/^[a-z]/.test(s)?s+" ":s=="Dashed"?"dashed ":s=="Squiggle"?"wavy ":""}${/thin/i.test(o)?1:2}px`;r.push(Me.mark({attributes:{style:c}}).range(a,l))}}}e.dispatch({effects:CA.of(Me.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=ra(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((i,s,o,a,l)=>{if(n)return;let c=l.length-(s-i);if(r&&s>=r.to)if(r.from==i&&r.to==s&&r.insert.eq(l)){r=this.pendingContextChange=null,t+=c,this.to+=c;return}else r=null,this.revertPending(e.state);if(i+=t,s+=t,s<=this.from)this.from+=c,this.to+=c;else if(i<this.to){if(i<this.from||s>this.to||this.to-this.from+l.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(s),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])}},ie=class Zl{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&&(i=>i.forEach(s=>r(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=t.root||g5(t.parent)||document,this.viewState=new Xy(this,t.state||Ve.create(t)),t.scrollTo&&t.scrollTo.is(ll)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Qi).map(i=>new jh(i));for(let i of this.plugins)i.update(this);this.observer=new $3(this),this.inputState=new l3(this),this.inputState.ensureHandlers(this.plugins),this.docView=new By(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 nn?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,i,s=this.state;for(let f of t){if(f.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=f.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,a=0,l=null;t.some(f=>f.annotation(KA))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=GA(s,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(s.doc)||!this.state.selection.eq(s.selection))&&(u=null)):this.observer.clear(),s.facet(Ve.phrases)!=this.state.facet(Ve.phrases))return this.setState(s);i=Ly.create(this,s,t),i.flags|=a;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let f of t){if(h&&(h=h.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection,{x:m,y:v}=this.state.facet(Zl.cursorScrollMargin);h=new _h(d.empty?d:z.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",v,m)}for(let d of f.effects)d.is(ll)&&(h=d.value.clip(this.state))}this.viewState.update(i,h),this.bidiCache=rx.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(uo)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(pl)!=i.state.facet(pl)&&(this.viewState.mustMeasureContent=!0),(n||r||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let f of this.state.facet(qd))try{f(i)}catch(d){Mn(this.state,d,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!VA(this,u)&&c.force&&as(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 Xy(this,t),this.plugins=t.facet(Qi).map(r=>new jh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new By(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(Qi),r=t.state.facet(Qi);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new jh(s));else{let a=this.plugins[o];a.mustUpdate=t,i.push(a)}}for(let s of this.plugins)s.mustUpdate!=t&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=t;for(let i=0;i<this.plugins.length;i++)this.plugins[i].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){Mn(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,i=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o,scaleY:a}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0){if(aA(r||this.win))s=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let m=this.viewState.scrollAnchorAt(i);s=m.from,o=m.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 h=u.map(m=>{try{return m.read(this)}catch(v){return Mn(this.state,v),nx}}),f=Ly.create(this,this.state,[]),d=!1;f.flags|=c,n?n.flags|=c:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),d=this.docView.update(f),d&&this.docViewUpdate());for(let m=0;m<u.length;m++)if(h[m]!=nx)try{let v=u[m];v.write&&v.write(h[m],this)}catch(v){Mn(this.state,v)}if(d&&this.docView.updateSelection(!0),!f.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 m=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)/this.viewState.scaleY-o/a;if((m>1||m<-1)&&!(U.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+m,r?s<0?r.scrollTop=r.scrollHeight:r.scrollTop+=m:this.win.scrollBy(0,m),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(qd))l(n)}get themeClasses(){return np+" "+(this.state.facet(tp)?tT:eT)+" "+this.state.facet(pl)}updateAttrs(){let t=ix(this,AA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Qn)?"true":"false",class:"cm-content",style:`${U.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),ix(this,ig,n);let r=this.observer.ignore(()=>{let i=Py(this.contentDOM,this.contentAttrs,n),s=Py(this.dom,this.editorAttrs,t);return i||s});return this.editorAttrs=t,this.contentAttrs=n,r}showAnnouncements(t){let n=!0;for(let r of t)for(let i of r.effects)if(i.is(Zl.announce)){n&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=" "},200),n=!1);let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(uo);let t=this.state.facet(Zl.cspNonce);Nr.mount(this.root,this.styleModules.concat(V3).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 zh(this,t,Fy(this,t,n,r))}moveByGroup(t,n){return zh(this,t,Fy(this,t,n,r=>J5(this,t.head,r)))}visualLineSide(t,n){return n?z.cursor(t.to,1):z.cursor(t.from,-1)}moveToLineBoundary(t,n,r=!0){return X5(this,t,n,r)}moveVertically(t,n,r){return zh(this,t,Z5(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=Jd(this,t,n);return r&&r.pos}posAndSideAtCoords(t,n=!0){return this.readMeasured(),Jd(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let r=this.state.doc.lineAt(t),i=this.bidiSpans(r),s=i[En.find(i,t-r.from,-1,n)];return r.length&&(t==r.from&&n<0||t==r.to&&n>0)&&s.dir!=this.textDirectionAt(r.from)&&(t==r.to?(t=r.from+s.from,n=1):(t=r.from+s.to,n=-1)),this.docView.coordsAt(t,n,s.dir==Ee.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(wA)||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>U3)return dA(t.length);let n=this.textDirectionAt(t.from),r;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==n&&(s.fresh||fA(s.isolates,r=Ny(this,t))))return s.order;r||(r=Ny(this,t));let i=C5(t.text,n,r);return this.bidiCache.push(new rx(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||U.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{oA(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,i,s,o;return ll.of(new _h(typeof t=="number"?z.cursor(t):t,(r=n.y)!==null&&r!==void 0?r:"nearest",(i=n.x)!==null&&i!==void 0?i:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(t);return ll.of(new _h(z.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 jr.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return jr.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=Nr.newName(),i=[pl.of(r),uo.of(rp(`.${r}`,t))];return n&&n.dark&&i.push(tp.of(!0)),i}static baseTheme(t){return vu.lowest(uo.of(rp("."+np,t,nT)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&Ne.get(r)||Ne.get(t);return((n=i?.root)===null||n===void 0?void 0:n.view)||null}};ie.styleModule=uo;ie.inputHandler=xA;ie.clipboardInputFilter=ng;ie.clipboardOutputFilter=rg;ie.scrollHandler=kA;ie.focusChangeEffect=bA;ie.perLineTextDirection=wA;ie.exceptionSink=yA;ie.updateListener=qd;ie.editable=Qn;ie.mouseSelectionStyle=vA;ie.dragMovesSelection=gA;ie.clickAddsSelectionRange=mA;ie.decorations=wu;ie.blockWrappers=TA;ie.outerDecorations=sg;ie.atomicRanges=Ra;ie.bidiIsolatedRanges=EA;ie.cursorScrollMargin=ee.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}}});ie.scrollMargins=MA;ie.darkTheme=tp;ie.cspNonce=ee.define({combine:e=>e.length?e[0]:""});ie.contentAttributes=ig;ie.editorAttributes=AA;ie.lineWrapping=ie.contentAttributes.of({class:"cm-lineWrapping"});ie.announce=Ke.define();var U3=4096,nx={},rx=class rT{constructor(t,n,r,i,s,o){this.from=t,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=o}static update(t,n){if(n.empty&&!t.some(s=>s.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:Ee.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let o=t[s];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new rT(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function ix(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let s=r[i],o=typeof s=="function"?s(e):s;o&&Xm(o,n)}return n}var q3=U.mac?"mac":U.windows?"win":U.linux?"linux":"key";function K3(e,t){const n=e.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,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))i=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))t=="mac"?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(r="Alt-"+r),s&&(r="Ctrl-"+r),a&&(r="Meta-"+r),o&&(r="Shift-"+r),r}function ml(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 G3=vu.default(ie.domEventHandlers({keydown(e,t){return J3(Q3(t.state),e,t,"editor")}})),iT=ee.define({enables:G3}),sx=new WeakMap;function Q3(e){let t=e.facet(iT),n=sx.get(t);return n||sx.set(t,n=X3(t.reduce((r,i)=>r.concat(i),[]))),n}var wr=null,Y3=4e3;function X3(e,t=q3){let n=Object.create(null),r=Object.create(null),i=(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")},s=(o,a,l,c,u)=>{var h,f;let d=n[o]||(n[o]=Object.create(null)),m=a.split(/ (?!$)/).map(x=>K3(x,t));for(let x=1;x<m.length;x++){let b=m.slice(0,x).join(" ");i(b,!0),d[b]||(d[b]={preventDefault:!0,stopPropagation:!1,run:[w=>{let S=wr={view:w,prefix:b,scope:o};return setTimeout(()=>{wr==S&&(wr=null)},Y3),!0}]})}let v=m.join(" ");i(v,!1);let y=d[v]||(d[v]={preventDefault:!1,stopPropagation:!1,run:((f=(h=d._any)===null||h===void 0?void 0:h.run)===null||f===void 0?void 0:f.slice())||[]});l&&y.run.push(l),c&&(y.preventDefault=!0),u&&(y.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:h}=o;for(let f in u)u[f].run.push(d=>h(d,ip))}let l=o[t]||o.key;if(l)for(let c of a)s(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return n}var ip=null;function J3(e,t,n,r){ip=t;let i=c5(t),s=W$(i,0),o=U$(s)==i.length&&i!=" ",a="",l=!1,c=!1,u=!1;wr&&wr.view==n&&wr.scope==r&&(a=wr.prefix+" ",HA.indexOf(t.keyCode)<0&&(c=!0,wr=null));let h=new Set,f=y=>{if(y){for(let x of y.run)if(!h.has(x)&&(h.add(x),x(n)))return y.stopPropagation&&(u=!0),!0;y.preventDefault&&(y.stopPropagation&&(u=!0),c=!0)}return!1},d=e[r],m,v;return d&&(f(d[a+ml(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(U.windows&&t.ctrlKey&&t.altKey)&&!(U.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(m=Lr[t.keyCode])&&m!=i?(f(d[a+ml(m,t,!0)])||t.shiftKey&&(v=ta[t.keyCode])!=i&&v!=m&&f(d[a+ml(v,t,!1)]))&&(l=!0):o&&t.shiftKey&&f(d[a+ml(i,t,!0)])&&(l=!0),!l&&f(d._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),ip=null,l}var Do=class sT{constructor(t,n,r,i,s){this.className=t,this.left=n,this.top=r,this.width=i,this.height=s}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 i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let s=oT(t);return[new sT(n,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return Z3(t,n,r)}};function oT(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Ee.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function ox(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let s=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,a=e.posAtCoords({x:s.left+1,y:o}),l=e.posAtCoords({x:s.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 Z3(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),s=e.textDirection==Ee.LTR,o=e.contentDOM,a=o.getBoundingClientRect(),l=oT(e),c=o.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),h=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=a.right-(u?parseInt(u.paddingRight):0),d=Xd(e,r,1),m=Xd(e,i,-1),v=d.type==ot.Text?d:null,y=m.type==ot.Text?m:null;if(v&&(e.lineWrapping||d.widgetLineBreaks)&&(v=ox(e,r,1,v)),y&&(e.lineWrapping||m.widgetLineBreaks)&&(y=ox(e,i,-1,y)),v&&y&&v.from==y.from&&v.to==y.to)return b(w(n.from,n.to,v));{let C=v?w(n.from,null,v):S(d,!1),A=y?w(null,n.to,y):S(m,!0),k=[];return(v||d).to<(y||m).from-(v&&y?1:0)||d.widgetLineBreaks>1&&C.bottom+e.defaultLineHeight/2<A.top?k.push(x(h,C.bottom,f,A.top)):C.bottom<A.top&&e.elementAtHeight((C.bottom+A.top)/2).type==ot.Text&&(C.bottom=A.top=(C.bottom+A.top)/2),b(C).concat(k).concat(b(A))}function x(C,A,k,E){return new Do(t,C-l.left,A-l.top,Math.max(0,k-C),E-A)}function b({top:C,bottom:A,horizontal:k}){let E=[];for(let T=0;T<k.length;T+=2)E.push(x(k[T],C,k[T+1],A));return E}function w(C,A,k){let E=1e9,T=-1e9,R=[];function P(L,I,_,j,$){let B=e.coordsAtPos(L,L==k.to?-2:2),D=e.coordsAtPos(_,_==k.from?2:-2);!B||!D||(E=Math.min(B.top,D.top,E),T=Math.max(B.bottom,D.bottom,T),$==Ee.LTR?R.push(s&&I?h:B.left,s&&j?f:D.right):R.push(!s&&j?h:D.left,!s&&I?f:B.right))}let M=C??k.from,N=A??k.to;for(let L of e.visibleRanges)if(L.to>M&&L.from<N)for(let I=Math.max(L.from,M),_=Math.min(L.to,N);;){let j=e.state.doc.lineAt(I);for(let $ of e.bidiSpans(j)){let B=$.from+j.from,D=$.to+j.from;if(B>=_)break;D>I&&P(Math.max(B,I),C==null&&B<=M,Math.min(D,_),A==null&&D>=N,$.dir)}if(I=j.to+1,I>=_)break}return R.length==0&&P(M,C==null,N,A==null,e.textDirection),{top:E,bottom:T,horizontal:R}}function S(C,A){let k=a.top+(A?C.top:C.bottom);return{top:k,bottom:k,horizontal:[]}}}function eH(e,t){return e.constructor==t.constructor&&e.eq(t)}var tH=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(ec)!=e.state.facet(ec)&&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(ec);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)=>!eH(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,U.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},ec=ee.define();function aT(e){return[jr.define(t=>new tH(t,e)),ec.of(e)]}var ks=ee.define({combine(e){return Qm(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function nH(e={}){return[ks.of(e),rH,iH,oH,SA.of(!0)]}function lT(e){return e.startState.facet(ks)!=e.state.facet(ks)}var rH=aT({above:!0,markers(e){let{state:t}=e,n=t.facet(ks),r=[];for(let i of t.selection.ranges){let s=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(s&&U.ios&&n.iosSelectionHandles)){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=i.empty?i:z.cursor(i.head,i.assoc);for(let l of Do.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=lT(e);return n&&ax(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){ax(t.state,e)},class:"cm-cursorLayer"});function ax(e,t){t.style.animationDuration=e.facet(ks).cursorBlinkRate+"ms"}var iH=aT({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let i of r)if(!i.empty)for(let s of Do.forRange(e,"cm-selectionBackground",i))t.push(s);if(U.ios&&!n.empty&&e.state.facet(ks).iosSelectionHandles){for(let i of Do.forRange(e,"cm-selectionHandle cm-selectionHandle-start",z.cursor(n.from,1)))t.push(i);for(let i of Do.forRange(e,"cm-selectionHandle cm-selectionHandle-end",z.cursor(n.to,1)))t.push(i)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||lT(e)},class:"cm-selectionLayer"}),sH=U.gecko&&U.gecko_version==153?"#ffffff01":"transparent",oH=vu.highest(ie.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${sH} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),q8=/x/.unicode!=null?"gu":"g";function aH(){return cH}var lH=Me.line({class:"cm-activeLine"}),cH=jr.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 i=e.lineBlockAt(r.head);i.from>t&&(n.push(lH.range(i.from)),t=i.from)}return Me.set(n)}},{decorations:e=>e.decorations}),Br=class extends xi{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Br.prototype.elementClass="";Br.prototype.toDOM=void 0;Br.prototype.mapMode=Mt.TrackBefore;Br.prototype.startSide=Br.prototype.endSide=-1;Br.prototype.point=!0;var tc=ee.define(),uH=ee.define(),nc=ee.define(),sp=ee.define({combine:e=>e.some(t=>t)});function hH(e){let t=[fH];return e&&e.fixed===!1&&t.push(sp.of(!0)),t}var fH=jr.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(nc).map(t=>new cx(e,t)),this.fixed=!e.state.facet(sp);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(sp)!=!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=Ae.iter(this.view.state.facet(tc),this.view.viewport.from),r=[],i=this.gutters.map(s=>new dH(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(s.type)){let o=!0;for(let a of s.type)if(a.type==ot.Text&&o){op(n,r,a.from);for(let l of i)l.line(this.view,a,r);o=!1}else if(a.widget)for(let l of i)l.widget(this.view,a)}else if(s.type==ot.Text){op(n,r,s.from);for(let o of i)o.line(this.view,s,r)}else if(s.widget)for(let o of i)o.widget(this.view,s);for(let s of i)s.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(nc),n=e.state.facet(nc),r=e.docChanged||e.heightChanged||e.viewportChanged||!Ae.eq(e.startState.facet(tc),e.state.facet(tc),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let i of this.gutters)i.update(e)&&(r=!0);else{r=!0;let i=[];for(let s of n){let o=t.indexOf(s);o<0?i.push(new cx(this.view,s)):(this.gutters[o].update(e),i.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),i.indexOf(s)<0&&s.destroy();for(let s of i)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>ie.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,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==Ee.LTR?{left:r,right:i}:{right:r,left:i}})});function lx(e){return Array.isArray(e)?e:[e]}function op(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var dH=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=Ae.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,s=t.height/e.scaleY;if(this.i==r.elements.length){let o=new cT(e,s,i,n);r.elements.push(o),r.dom.appendChild(o.dom)}else r.elements[this.i].update(e,s,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];op(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let s=this.gutter;r.length==0&&!s.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 i of e.state.facet(uH)){let s=i(e,t.widget,t);s&&(r||(r=[])).push(s)}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()}}},cx=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 i=r.target,s;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let a=i.getBoundingClientRect();s=(a.top+a.bottom)/2}else s=r.clientY;let o=e.lineBlockAtHeight(s-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=lx(t.markers(e)),t.initialSpacer&&(this.spacer=new cT(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=lx(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!Ae.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()}},cT=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":""),pH(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let i=0,s=0;;){let o=s,a=i<t.length?t[i++]:null,l=!1;if(a){let c=a.elementClass;c&&(n+=" "+c);for(let u=s;u<this.markers.length;u++)if(this.markers[u].compare(a)){o=u,l=!0;break}}else o=this.markers.length;for(;s<o;){let c=this.markers[s++];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&&s++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function pH(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 mH=ee.define(),gH=ee.define(),Yi=ee.define({combine(e){return Qm(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,n){let r=Object.assign({},t);for(let i in n){let s=r[i],o=n[i];r[i]=s?(a,l,c)=>s(a,l,c)||o(a,l,c):o}return r}})}}),Wh=class extends Br{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Uh(e,t){return e.state.facet(Yi).formatNumber(t,e.state)}var vH=nc.compute([Yi],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(mH)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new Wh(Uh(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(gH)){let s=i(t,n,r);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(Yi)!=t.state.facet(Yi),initialSpacer(t){return new Wh(Uh(t,ux(t.state.doc.lines)))},updateSpacer(t,n){let r=Uh(n.view,ux(n.view.state.doc.lines));return r==t.number?t:new Wh(r)},domEventHandlers:e.facet(Yi).domEventHandlers,side:"before"}));function yH(e={}){return[Yi.of(e),hH(),vH]}function ux(e){let t=9;for(;t<e;)t=t*10+9;return t}var xH=new class extends Br{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},bH=tc.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(xH.range(i)))}return Ae.of(t)});function wH(){return bH}var qh,Xi=new ue;function SH(e){return ee.define({combine:e?t=>t.concat(e):void 0})}var kH=new ue,Jt=class{constructor(e,t,n=[],r=""){this.data=e,this.name=r,Ve.prototype.hasOwnProperty("tree")||Object.defineProperty(Ve.prototype,"tree",{get(){return Nn(this)}}),this.parser=t,this.extension=[Cs.of(this),Ve.languageData.of((i,s,o)=>{let a=hx(i,s,o),l=a.type.prop(Xi);if(!l)return[];let c=i.facet(l),u=a.type.prop(kH);if(u){let h=a.resolve(s-a.from,o);for(let f of u)if(f.test(h,i)){let d=i.facet(f.facet);return f.type=="replace"?d:d.concat(c)}}return c})].concat(n)}isActiveAt(e,t,n=-1){return hx(e,t,n).type.prop(Xi)==this.data}findRegions(e){let t=e.facet(Cs);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(i,s)=>{if(i.prop(Xi)==this.data){n.push({from:s,to:s+i.length});return}let o=i.prop(ue.mounted);if(o){if(o.tree.prop(Xi)==this.data){if(o.overlay)for(let a of o.overlay)n.push({from:a.from+s,to:a.to+s});else n.push({from:s,to:s+i.length});return}else if(o.overlay){let a=n.length;if(r(o.tree,o.overlay[0].from+s),n.length>a)return}}for(let a=0;a<i.children.length;a++){let l=i.children[a];l instanceof Ze&&r(l,i.positions[a]+s)}};return r(Nn(e),0),n}get allowsNesting(){return!0}};Jt.setState=Ke.define();function hx(e,t,n){let r=e.facet(Cs),i=Nn(e).topNode;if(!r||r.allowsNesting)for(let s=i;s;s=s.enter(t,n,Oe.ExcludeBuffers|Oe.EnterBracketed))s.type.isTop&&(i=s);return i}var CH=class ap extends Jt{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=SH(t.languageData);return new ap(n,t.parser.configure({props:[Xi.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new ap(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Nn(e){let t=e.field(Jt.state,!1);return t?t.tree:Ze.empty}var AH=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)}},Xs=null,TH=class lp{constructor(t,n,r=[],i,s,o,a,l){this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new lp(t,n,[],Ze.empty,0,r,[],null)}startParse(){return this.parser.startParse(new AH(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Ze.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let i=Date.now()+t;t=()=>Date.now()>i}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 i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped($l.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,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($l.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=Xs;Xs=this;try{return t()}finally{Xs=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=fx(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((c,u,h,f)=>l.push({fromA:c,toA:u,fromB:h,toB:f})),r=$l.applyChanges(r,l),i=Ze.empty,s=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),h=t.mapPos(c.to,-1);u<h&&a.push({from:u,to:h})}}}return new lp(this.parser,n,r,i,s,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:i,to:s}=this.skipped[r];i<t.to&&s>t.from&&(this.fragments=fx(this.fragments,i,s),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 mC{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=Xs;if(a){for(let l of i)a.tempSkipped.push(l);t&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,t]):t)}return this.parsedPos=o,new Ze(Bt.none,[],[],o-s)},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 Xs}};function fx(e,t,n){return $l.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var cp=class up{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 up(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=TH.create(t.facet(Cs).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new up(r)}};Jt.state=Ma.define({create:cp.init,update(e,t){for(let n of t.effects)if(n.is(Jt.setState))return n.value;return t.startState.facet(Cs)!=t.state.facet(Cs)?cp.init(t.state):e.apply(t)}});var uT=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(uT=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var Kh=typeof navigator<"u"&&(!((qh=navigator.scheduling)===null||qh===void 0)&&qh.isInputPending)?()=>navigator.scheduling.isInputPending():null,EH=jr.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(Jt.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(Jt.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=uT(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:i}}=this.view,s=r.field(Jt.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!Kh?Math.max(25,t.timeRemaining()-5):1e9),a=s.context.treeLen<i&&r.doc.length>i+1e3,l=s.context.work(()=>Kh&&Kh()||Date.now()>o,i+(a?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Jt.setState.of(new cp(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Mn(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()}}}),Cs=ee.define({combine(e){return e.length?e[0]:null},enables:e=>[Jt.state,EH,ie.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),MH=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},RH=ee.define(),ag=ee.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 Nc(e){let t=e.facet(ag);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function oa(e,t){let n="",r=e.tabSize,i=e.facet(ag)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let s=0;s<t;s++)n+=i;return n}function lg(e,t){e instanceof Ve&&(e=new Au(e));for(let r of e.state.facet(RH)){let i=r(e,t);if(i!==void 0)return i}let n=Nn(e.state);return n.length>=t?PH(e,n,t):null}var Au=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Nc(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&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),i=this.countColumn(n,e-r),s=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return s>-1&&(i+=s-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return yu(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let s=i(r);if(s>-1)return s}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},hT=new ue;function PH(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let o=i;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return fT(r,e,n)}function fT(e,t,n){for(let r=e;r;r=r.next){let i=OH(r.node);if(i)return i(NH.create(t,n,r))}return 0}function IH(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function OH(e){let t=e.type.prop(hT);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(ue.closedBy))){let i=e.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>jH(o,!0,1,void 0,s&&!IH(o)?i.from:void 0)}return e.parent==null?DH:null}function DH(){return 0}var NH=class dT extends Au{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 dT(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(LH(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return fT(this.context.next,this.base,this.pos)}};function LH(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function _H(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,s=e.state.doc.lineAt(n.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);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(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+c}}a=l.to}}function jH(e,t,n,r,i){let s=e.textAfter,o=s.match(/^\s*/)[0].length,a=r&&s.slice(o,o+r.length)==r||i==e.pos+o,l=t?_H(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}function dx({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var BH=200;function FH(){return Ve.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,i=n.lineAt(r);if(r>i.from+BH)return e;let s=n.sliceString(i.from,r);if(!t.some(c=>c.test(s)))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 h=lg(o,u.from);if(h==null)continue;let f=/^\s*/.exec(u.text)[0],d=oa(o,h);f!=d&&l.push({from:u.from,to:u.from+f.length,insert:d})}return l.length?[e,{changes:l,sequential:!0}]:e})}var VH=new ue;function zH(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 cg=class pT{constructor(t,n){this.specs=t;let r;function i(a){let l=Nr.newName();return(r||(r=Object.create(null)))["."+l]=a,l}const s=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,o=n.scope;this.scope=o instanceof Jt?a=>a.prop(Xi)==o.data:o?a=>a==o:void 0,this.style=bC(t.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=r?new Nr(r):null,this.themeType=n.themeType}static define(t,n){return new pT(t,n||{})}},hp=ee.define(),mT=ee.define({combine(e){return e.length?[e[0]]:null}});function Gh(e){let t=e.facet(hp);return t.length?t:e.facet(mT)}function $H(e,t){let n=[WH],r;return e instanceof cg&&(e.module&&n.push(ie.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(mT.of(e)):r?n.push(hp.computeN([ie.darkTheme],i=>i.facet(ie.darkTheme)==(r=="dark")?[e]:[])):n.push(hp.of(e)),n}var HH=class{constructor(e){this.markCache=Object.create(null),this.tree=Nn(e.state),this.decorations=this.buildDeco(e,Gh(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Nn(e.state),n=Gh(e.state),r=n!=Gh(e.startState),{viewport:i}=e.view,s=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&s>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return Me.none;let n=new Gl;for(let{from:r,to:i}of e.visibleRanges)O$(this.tree,t,(s,o,a)=>{n.add(s,o,this.markCache[a]||(this.markCache[a]=Me.mark({class:a})))},r,i);return n.finish()}},WH=vu.high(jr.fromClass(HH,{decorations:e=>e.decorations})),G8=cg.define([{tag:V.meta,color:"#404740"},{tag:V.link,textDecoration:"underline"},{tag:V.heading,textDecoration:"underline",fontWeight:"bold"},{tag:V.emphasis,fontStyle:"italic"},{tag:V.strong,fontWeight:"bold"},{tag:V.strikethrough,textDecoration:"line-through"},{tag:V.keyword,color:"#708"},{tag:[V.atom,V.bool,V.url,V.contentSeparator,V.labelName],color:"#219"},{tag:[V.literal,V.inserted],color:"#164"},{tag:[V.string,V.deleted],color:"#a11"},{tag:[V.regexp,V.escape,V.special(V.string)],color:"#e40"},{tag:V.definition(V.variableName),color:"#00f"},{tag:V.local(V.variableName),color:"#30a"},{tag:[V.typeName,V.namespace],color:"#085"},{tag:V.className,color:"#167"},{tag:[V.special(V.variableName),V.macroName],color:"#256"},{tag:V.definition(V.propertyName),color:"#00c"},{tag:V.comment,color:"#940"},{tag:V.invalid,color:"#f00"}]),UH=ie.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),gT=1e4,vT="()[]{}",yT=ee.define({combine(e){return Qm(e,{afterCursor:!0,brackets:vT,maxScanDistance:gT,renderMatch:GH})}}),qH=Me.mark({class:"cm-matchingBracket"}),KH=Me.mark({class:"cm-nonmatchingBracket"});function GH(e){let t=[],n=e.matched?qH:KH;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 px(e){let t=[],n=e.facet(yT);for(let r of e.selection.ranges){if(!r.empty)continue;let i=Rn(e,r.head,-1,n)||r.head>0&&Rn(e,r.head-1,1,n)||n.afterCursor&&(Rn(e,r.head,1,n)||r.head<e.doc.length&&Rn(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return Me.set(t,!0)}var QH=[jr.fromClass(class{constructor(e){this.paused=!1,this.decorations=px(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=px(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),UH];function YH(e={}){return[yT.of(e),QH]}var XH=new ue;function fp(e,t,n){let r=e.prop(t<0?ue.openedBy:ue.closedBy);if(r)return r;if(e.name.length==1){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function dp(e){let t=e.type.prop(XH);return t?t(e.node):e}function Rn(e,t,n,r={}){let i=r.maxScanDistance||gT,s=r.brackets||vT,o=Nn(e),a=o.resolveInner(t,n);for(let l=a;l;l=l.parent){let c=fp(l.type,n,s);if(c&&l.from<l.to){let u=dp(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return JH(e,t,n,l,u,c,s)}}return ZH(e,t,n,o,a.type,i,s)}function JH(e,t,n,r,i,s,o){let a=r.parent,l={from:i.from,to:i.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&&s.indexOf(u.type.name)>-1&&u.from<u.to){let h=dp(u);return{start:l,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(fp(u.type,n,o))c++;else if(fp(u.type,-n,o)){if(c==0){let h=dp(u);return{start:l,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}c--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function ZH(e,t,n,r,i,s,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),h=0;for(let f=0;!u.next().done&&f<=s;){let d=u.value;n<0&&(f+=d.length);let m=t+f*n;for(let v=n>0?0:d.length-1,y=n>0?d.length:-1;v!=y;v+=n){let x=o.indexOf(d[v]);if(!(x<0||r.resolveInner(m+v,1).type!=i))if(x%2==0==n>0)h++;else{if(h==1)return{start:c,end:{from:m+v,to:m+v+1},matched:x>>1==l>>1};h--}}n>0&&(f+=d.length)}return u.done?{start:c,matched:!1}:null}var eW=Object.create(null),mx=[Bt.none],gx=[],vx=Object.create(null),tW=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"]])tW[e]=nW(eW,t);function Qh(e,t){gx.indexOf(e)>-1||(gx.push(e),console.warn(t))}function nW(e,t){let n=[];for(let a of t.split(" ")){let l=[];for(let c of a.split(".")){let u=e[c]||V[c];u?typeof u=="function"?l.length?l=l.map(u):Qh(c,`Modifier ${c} used at start of tag`):l.length?Qh(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:Qh(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(a=>a.id),s=vx[i];if(s)return s.id;let o=vx[i]=Bt.define({id:mx.length,name:r,props:[yC({[r]:n})]});return mx.push(o),o.id}var Q8={rtl:Me.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:Ee.RTL}),ltr:Me.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:Ee.LTR}),auto:Me.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})},rW=CH.define({name:"json",parser:_$.configure({props:[hT.add({Object:dx({except:/^\s*\}/}),Array:dx({except:/^\s*\]/})}),VH.add({"Object Array":zH})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function iW(){return new MH(rW)}var sW=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=hg(e.state,n.from);return r.line?oW(e):r.block?lW(e):!1};function ug(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var oW=ug(hW,0),aW=ug(xT,0),lW=ug((e,t)=>xT(e,t,uW(t)),0);function hg(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var gl=50;function cW(e,{open:t,close:n},r,i){let s=e.sliceDoc(r-gl,r),o=e.sliceDoc(i,i+gl),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,c=s.length-a;if(s.slice(c-t.length,c)==t&&o.slice(l,l+n.length)==n)return{open:{pos:r-a,margin:a&&1},close:{pos:i+l,margin:l&&1}};let u,h;i-r<=100?u=h=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+gl),h=e.sliceDoc(i-gl,i));let f=/^\s*/.exec(u)[0].length,d=/\s*$/.exec(h)[0].length,m=h.length-d-n.length;return u.slice(f,f+t.length)==t&&h.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-d-n.length,margin:/\s/.test(h.charAt(m-1))?1:0}}:null}function uW(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let s=t.length-1;s>=0&&t[s].to>r.from?t[s].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function xT(e,t,n=t.selection.ranges){let r=n.map(s=>hg(t,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>cW(t,r[o],s.from,s.to));if(e!=2&&!i.every(s=>s))return{changes:t.changes(n.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(e!=1&&i.some(s=>s)){let s=[];for(let o=0,a;o<i.length;o++)if(a=i[o]){let l=r[o],{open:c,close:u}=a;s.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:s}}return null}function hW(e,t,n=t.selection.ranges){let r=[],i=-1;e:for(let{from:s,to:o}of n){let a=r.length,l=1e9,c;for(let u=s;u<=o;){let h=t.doc.lineAt(u);if(c==null&&(c=hg(t,h.from).line,!c))continue e;if(h.from>i&&(s==o||o>h.from)){i=h.from;let f=/^\s*/.exec(h.text)[0].length,d=f==h.length,m=h.text.slice(f,f+c.length)==c?f:-1;f<h.text.length&&f<l&&(l=f),r.push({line:h,comment:m,token:c,indent:f,empty:d,single:!1})}u=h.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(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:l,indent:c,empty:u,single:h}of r)(h||!u)&&s.push({from:a.from+c,insert:l+" "});let o=t.changes(s);return{changes:o,selection:t.selection.map(o,1)}}else if(e!=1&&r.some(s=>s.comment>=0)){let s=[];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++,s.push({from:c,to:u})}return{changes:s}}return null}var yx=Ci.define(),fW=ee.define(),aa=class po{constructor(t,n,r,i,s){this.changes=t,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(t){return new po(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(i=>i.toJSON())}}static fromJSON(t){return new po(t.changes&&on.fromJSON(t.changes),[],t.mapped&&is.fromJSON(t.mapped),t.startSelection&&z.fromJSON(t.startSelection),t.selectionsAfter.map(z.fromJSON))}static fromTransaction(t,n){let r=_t;for(let i of t.startState.facet(fW)){let s=i(t);s.length&&(r=r.concat(s))}return!r.length&&t.changes.empty?null:new po(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,_t)}static selection(t){return new po(void 0,_t,void 0,void 0,t)}};function pp(e,t,n,r){let i=t+1>n+20?t-n-1:0,s=e.slice(i,t);return s.push(r),s}function dW(e,t){let n=[],r=!1;return e.iterChangedRanges((i,s)=>n.push(i,s)),t.iterChangedRanges((i,s,o,a)=>{for(let l=0;l<n.length;){let c=n[l++],u=n[l++];a>=c&&o<=u&&(r=!0)}}),r}function pW(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function bT(e,t){return e.length?t.length?e.concat(t):e:t}var _t=[],mW=200;function gW(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-mW));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),pp(e,e.length-1,1e9,n.setSelAfter(r)))}else return[aa.selection([t])]}function vW(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 Yh(e,t){if(!e.length)return e;let n=e.length,r=_t;for(;n;){let i=yW(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=e.slice(0,n);return s[n-1]=i,s}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[aa.selection(r)]:_t}function yW(e,t,n){let r=bT(e.selectionsAfter.length?e.selectionsAfter.map(a=>a.map(t)):_t,n);if(!e.changes)return aa.selection(r);let i=e.changes.map(t),s=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(s):s;return new aa(i,Ke.mapEffects(e.effects,t),o,e.startSelection.map(s),r)}var xW=/^(input\.type|delete)($|\.)/,xx=class mo{constructor(t,n,r=0,i=void 0){this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new mo(this.done,this.undone):this}addChanges(t,n,r,i,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&t.changes&&(!r||xW.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(s,dW(a.changes,t.changes))||r=="input.type.compose")?o=pp(o,o.length-1,i.minDepth,new aa(t.changes.compose(a.changes),bT(Ke.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,_t)):o=pp(o,o.length,i.minDepth,t),new mo(o,_t,n,r)}addSelection(t,n,r,i){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:_t;return s.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&pW(s[s.length-1],t)?this:new mo(gW(this.done,t),this.undone,n,r)}addMapping(t){return new mo(Yh(this.done,t),Yh(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,n,r){let i=t==0?this.done:this.undone;if(i.length==0)return null;let s=i[i.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):n.selection);if(r&&s.selectionsAfter.length)return n.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:yx.of({side:t,rest:vW(i),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=i.length==1?_t:i.slice(0,i.length-1);return s.mapped&&(a=Yh(a,s.mapped)),n.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:yx.of({side:t,rest:a,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};xx.empty=new xx(_t,_t);function Ls(e,t){return z.create(e.ranges.map(t),e.mainIndex)}function cn(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function un({state:e,dispatch:t},n){let r=Ls(e.selection,n);return r.eq(e.selection,!0)?!1:(t(cn(e,r)),!0)}function Tu(e,t){return z.cursor(t?e.to:e.from)}function wT(e,t){return un(e,n=>n.empty?e.moveByChar(n,t):Tu(n,t))}function ut(e){return e.textDirectionAt(e.state.selection.main.head)==Ee.LTR}var ST=e=>wT(e,!ut(e)),kT=e=>wT(e,ut(e));function CT(e,t){return un(e,n=>n.empty?e.moveByGroup(n,t):Tu(n,t))}var bW=e=>CT(e,!ut(e)),wW=e=>CT(e,ut(e)),Y8=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function SW(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 Eu(e,t,n){let r=Nn(e).resolveInner(t.head),i=n?ue.closedBy:ue.openedBy;for(let l=t.head;;){let c=n?r.childAfter(l):r.childBefore(l);if(!c)break;SW(e,c,i)?r=c:l=n?c.to:c.from}let s=r.type.prop(i),o,a;return s&&(o=n?Rn(e,r.from,1):Rn(e,r.to,-1))&&o.matched?a=n?o.end.to:o.end.from:a=n?r.to:r.from,z.cursor(a,n?-1:1)}var kW=e=>un(e,t=>Eu(e.state,t,!ut(e))),CW=e=>un(e,t=>Eu(e.state,t,ut(e)));function AT(e,t){return un(e,n=>{if(!n.empty)return Tu(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}var TT=e=>AT(e,!1),ET=e=>AT(e,!0);function MT(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let s of e.state.facet(ie.scrollMargins)){let o=s(e);o?.top&&(n=Math.max(o?.top,n)),o?.bottom&&(r=Math.max(o?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function RT(e,t){let n=MT(e),{state:r}=e,i=Ls(r.selection,o=>o.empty?e.moveVertically(o,t,n.height):Tu(o,t));if(i.eq(r.selection))return!1;let s;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&&(s=ie.scrollIntoView(i.main.head,{y:"start",yMargin:o.top-l}))}return e.dispatch(cn(r,i),{effects:s}),!0}var bx=e=>RT(e,!1),mp=e=>RT(e,!0);function $r(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let s=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&t.head!=r.from+s&&(i=z.cursor(r.from+s))}return i}var AW=e=>un(e,t=>$r(e,t,!0)),TW=e=>un(e,t=>$r(e,t,!1)),EW=e=>un(e,t=>$r(e,t,!ut(e))),MW=e=>un(e,t=>$r(e,t,ut(e))),RW=e=>un(e,t=>e.moveToLineBoundary(t,!1,!1)),PW=e=>un(e,t=>e.moveToLineBoundary(t,!0,!1));function IW(e,t,n){let r=!1,i=Ls(e.selection,s=>{let o=Rn(e,s.head,-1)||Rn(e,s.head,1)||s.head>0&&Rn(e,s.head-1,1)||s.head<e.doc.length&&Rn(e,s.head+1,-1);if(!o||!o.end)return s;r=!0;let a=o.start.from==s.head?o.end.to:o.end.from;return n?z.range(s.anchor,a):z.cursor(a)});return r?(t(cn(e,i)),!0):!1}var OW=({state:e,dispatch:t})=>IW(e,t,!1);function Vt(e,t,n){let r=Ls(e.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=t&&(i=z.range(i.head,i.anchor));let s=n(i);return z.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return r.eq(e.state.selection)?!1:(e.dispatch(cn(e.state,r)),!0)}function PT(e,t){return Vt(e,t,n=>e.moveByChar(n,t))}var IT=e=>PT(e,!ut(e)),OT=e=>PT(e,ut(e));function DT(e,t){return Vt(e,t,n=>e.moveByGroup(n,t))}var DW=e=>DT(e,!ut(e)),NW=e=>DT(e,ut(e)),LW=e=>{let t=!ut(e);return Vt(e,t,n=>Eu(e.state,n,t))},_W=e=>{let t=ut(e);return Vt(e,t,n=>Eu(e.state,n,t))};function NT(e,t){return Vt(e,t,n=>e.moveVertically(n,t))}var LT=e=>NT(e,!1),_T=e=>NT(e,!0);function jT(e,t){return Vt(e,t,n=>e.moveVertically(n,t,MT(e).height))}var wx=e=>jT(e,!1),Sx=e=>jT(e,!0),jW=e=>Vt(e,!0,t=>$r(e,t,!0)),BW=e=>Vt(e,!1,t=>$r(e,t,!1)),FW=e=>{let t=!ut(e);return Vt(e,t,n=>$r(e,n,t))},VW=e=>{let t=ut(e);return Vt(e,t,n=>$r(e,n,t))},zW=e=>Vt(e,!1,t=>z.cursor(e.lineBlockAt(t.head).from)),$W=e=>Vt(e,!0,t=>z.cursor(e.lineBlockAt(t.head).to)),kx=({state:e,dispatch:t})=>(t(cn(e,{anchor:0})),!0),Cx=({state:e,dispatch:t})=>(t(cn(e,{anchor:e.doc.length})),!0),Ax=({state:e,dispatch:t})=>(t(cn(e,{anchor:e.selection.main.anchor,head:0})),!0),Tx=({state:e,dispatch:t})=>(t(cn(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),HW=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),WW=({state:e,dispatch:t})=>{let n=Mu(e).map(({from:r,to:i})=>z.undirectionalRange(r,Math.min(i+1,e.doc.length)));return t(e.update({selection:z.create(n),userEvent:"select"})),!0},UW=({state:e,dispatch:t})=>{let n=Ls(e.selection,r=>{let i=Nn(e),s=i.resolveStack(r.from,1);if(r.empty){let o=i.resolveStack(r.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;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 z.undirectionalRange(a.from,a.to)}return r});return n.eq(e.selection)?!1:(t(cn(e,n)),!0)};function BT(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(t?o.to<e.state.doc.length:o.from>0)for(let a=s;;){let l=e.moveVertically(a,t);if(l.head<o.from||l.head>o.to){i.some(c=>c.head==l.head)||i.push(l);break}else{if(l.head==a.head)break;a=l}}}return i.length==r.ranges.length?!1:(e.dispatch(cn(n,z.create(i,i.length-1))),!0)}var qW=e=>BT(e,!1),KW=e=>BT(e,!0),GW=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=z.create([n.main]):n.main.empty||(r=z.create([z.cursor(n.main.head)])),r?(t(cn(e,r)),!0):!1};function Pa(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,i=r.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let l=t(s);l<o?(n="delete.backward",l=vl(e,l,!1)):l>o&&(n="delete.forward",l=vl(e,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=vl(e,o,!1),a=vl(e,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:z.cursor(o,o<s.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?ie.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function vl(e,t,n){if(e instanceof ie)for(let r of e.state.facet(ie.atomicRanges).map(i=>i(e)))r.between(t,t,(i,s)=>{i<t&&s>t&&(t=n?s:i)});return t}var FT=(e,t,n)=>Pa(e,r=>{let i=r.from,{state:s}=e,o=s.doc.lineAt(i),a,l;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,i-o.from))){if(a[a.length-1]==" ")return i-1;let c=yu(a,s.tabSize)%Nc(s)||Nc(s);for(let u=0;u<c&&a[a.length-1-u]==" ";u++)i--;l=i}else l=ct(o.text,i-o.from,t,t)+o.from,l==i&&o.number!=(t?s.doc.lines:1)?l+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,i-o.from))&&(l=ct(o.text,l-o.from,!1,!1)+o.from);return l}),gp=e=>FT(e,!1,!0),VT=e=>FT(e,!0,!1),zT=(e,t)=>Pa(e,n=>{let r=n.head,{state:i}=e,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let a=null;;){if(r==(t?s.to:s.from)){r==n.head&&s.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let l=ct(s.text,r-s.from,t)+s.from,c=s.text.slice(Math.min(r,l)-s.from,Math.max(r,l)-s.from),u=o(c);if(a!=null&&u!=a)break;(c!=" "||r!=n.head)&&(a=u),r=l}return r}),$T=e=>zT(e,!1),QW=e=>zT(e,!0),YW=e=>Pa(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),XW=e=>Pa(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),JW=e=>Pa(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),ZW=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:me.of(["",""])},range:z.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},e4=({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 i=r.from,s=e.doc.lineAt(i),o=i==s.from?i-1:ct(s.text,i-s.from,!1)+s.from,a=i==s.to?i+1:ct(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:e.doc.slice(i,a).append(e.doc.slice(o,i))},range:z.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Mu(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),s=e.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=e.doc.lineAt(r.to-1)),n>=i.number){let o=t[t.length-1];o.to=s.to,o.ranges.push(r)}else t.push({from:i.from,to:s.to,ranges:[r]});n=s.number+1}return t}function HT(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let s of Mu(e)){if(n?s.to==e.doc.length:s.from==0)continue;let o=e.doc.lineAt(n?s.to+1:s.from-1),a=o.length+1;if(n){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+e.lineBreak});for(let l of s.ranges)i.push(z.range(Math.min(e.doc.length,l.anchor+a),Math.min(e.doc.length,l.head+a)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:e.lineBreak+o.text});for(let l of s.ranges)i.push(z.range(l.anchor-a,l.head-a))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:z.create(i,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}var t4=({state:e,dispatch:t})=>HT(e,t,!1),n4=({state:e,dispatch:t})=>HT(e,t,!0);function WT(e,t,n){if(e.readOnly)return!1;let r=[];for(let s of Mu(e))n?r.push({from:s.from,insert:e.doc.slice(s.from,s.to)+e.lineBreak}):r.push({from:s.to,insert:e.lineBreak+e.doc.slice(s.from,s.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var r4=({state:e,dispatch:t})=>WT(e,t,!1),i4=({state:e,dispatch:t})=>WT(e,t,!0),s4=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Mu(t).map(({from:i,to:s})=>(i>0?i--:s<t.doc.length&&s++,{from:i,to:s}))),r=Ls(t.selection,i=>{let s;if(e.lineWrapping){let o=e.lineBlockAt(i.head),a=e.coordsAtPos(i.head,i.assoc||1);a&&(s=o.bottom+e.documentTop-a.bottom+e.defaultLineHeight/2)}return e.moveVertically(i,!0,s)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function o4(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Nn(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),s;return r&&i&&r.to<=t&&i.from>=t&&(s=r.type.prop(ue.closedBy))&&s.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Ex=UT(!1),a4=UT(!0);function UT(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(i=>{let{from:s,to:o}=i,a=t.doc.lineAt(s),l=!e&&s==o&&o4(t,s);e&&(s=o=(o<=a.to?a:t.doc.lineAt(o)).to);let c=new Au(t,{simulateBreak:s,simulateDoubleBreak:!!l}),u=lg(c,s);for(u==null&&(u=yu(/^\s*/.exec(t.doc.lineAt(s).text)[0],t.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;l?{from:s,to:o}=l:s>a.from&&s<a.from+100&&!/\S/.test(a.text.slice(0,s))&&(s=a.from);let h=["",oa(t,u)];return l&&h.push(oa(t,c.lineIndent(a.from,-1))),{changes:{from:s,to:o,insert:me.of(h)},range:z.cursor(s+1+h[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function fg(e,t){let n=-1;return e.changeByRange(r=>{let i=[];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,i,r),n=a.number),o=a.to+1}let s=e.changes(i);return{changes:i,range:z.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}var l4=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Au(e,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=fg(e,(s,o,a)=>{let l=lg(r,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let c=/^\s*/.exec(s.text)[0],u=oa(e,l);(c!=u||a.from<s.from+c.length)&&(n[s.from]=l,o.push({from:s.from,to:s.from+c.length,insert:u}))});return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0},qT=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(fg(e,(n,r)=>{r.push({from:n.from,insert:e.facet(ag)})}),{userEvent:"input.indent"})),!0),KT=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(fg(e,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=yu(i,e.tabSize),o=0,a=oa(e,Math.max(0,s-Nc(e)));for(;o<i.length&&o<a.length&&i.charCodeAt(o)==a.charCodeAt(o);)o++;r.push({from:n.from+o,to:n.from+i.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),c4=e=>(e.setTabFocusMode(),!0),u4=[{key:"Ctrl-b",run:ST,shift:IT,preventDefault:!0},{key:"Ctrl-f",run:kT,shift:OT},{key:"Ctrl-p",run:TT,shift:LT},{key:"Ctrl-n",run:ET,shift:_T},{key:"Ctrl-a",run:RW,shift:zW},{key:"Ctrl-e",run:PW,shift:$W},{key:"Ctrl-d",run:VT},{key:"Ctrl-h",run:gp},{key:"Ctrl-k",run:YW},{key:"Ctrl-Alt-h",run:$T},{key:"Ctrl-o",run:ZW},{key:"Ctrl-t",run:e4},{key:"Ctrl-v",run:mp}],h4=[{key:"ArrowLeft",run:ST,shift:IT,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:bW,shift:DW,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:EW,shift:FW,preventDefault:!0},{key:"ArrowRight",run:kT,shift:OT,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:wW,shift:NW,preventDefault:!0},{mac:"Cmd-ArrowRight",run:MW,shift:VW,preventDefault:!0},{key:"ArrowUp",run:TT,shift:LT,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kx,shift:Ax},{mac:"Ctrl-ArrowUp",run:bx,shift:wx},{key:"ArrowDown",run:ET,shift:_T,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cx,shift:Tx},{mac:"Ctrl-ArrowDown",run:mp,shift:Sx},{key:"PageUp",run:bx,shift:wx},{key:"PageDown",run:mp,shift:Sx},{key:"Home",run:TW,shift:BW,preventDefault:!0},{key:"Mod-Home",run:kx,shift:Ax},{key:"End",run:AW,shift:jW,preventDefault:!0},{key:"Mod-End",run:Cx,shift:Tx},{key:"Enter",run:Ex,shift:Ex},{key:"Mod-a",run:HW},{key:"Backspace",run:gp,shift:gp,preventDefault:!0},{key:"Delete",run:VT,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:$T,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:QW,preventDefault:!0},{mac:"Mod-Backspace",run:XW,preventDefault:!0},{mac:"Mod-Delete",run:JW,preventDefault:!0}].concat(u4.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),f4=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:kW,shift:LW},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:CW,shift:_W},{key:"Alt-ArrowUp",run:t4},{key:"Shift-Alt-ArrowUp",run:r4},{key:"Alt-ArrowDown",run:n4},{key:"Shift-Alt-ArrowDown",run:i4},{key:"Mod-Alt-ArrowUp",run:qW},{key:"Mod-Alt-ArrowDown",run:KW},{key:"Escape",run:GW},{key:"Mod-Enter",run:a4},{key:"Alt-l",mac:"Ctrl-l",run:WW},{key:"Mod-i",run:UW,preventDefault:!0},{key:"Mod-[",run:KT},{key:"Mod-]",run:qT},{key:"Mod-Alt-\\",run:l4},{key:"Shift-Mod-k",run:s4},{key:"Shift-Mod-\\",run:OW},{key:"Mod-/",run:sW},{key:"Alt-A",mac:"Ctrl-A",run:aW},{key:"Ctrl-m",mac:"Shift-Alt-m",run:c4}].concat(h4),d4={key:"Tab",run:qT,shift:KT},p4=ie.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)"}}),m4=cg.define([{tag:V.propertyName,color:"var(--json-key)"},{tag:V.string,color:"var(--json-string)"},{tag:V.number,color:"var(--json-number)"},{tag:V.bool,color:"var(--json-boolean)"},{tag:V.null,color:"var(--json-null)"},{tag:V.punctuation,color:"var(--json-punctuation)"},{tag:V.invalid,color:"var(--destructive)"}]);function Mx(e){const t=e.state.selection.main.head,n=e.state.doc.lineAt(t);return{line:n.number,column:t-n.from+1}}function Rx(e,t){return typeof e=="number"?`${e}px`:e??t}function g4({content:e,onChange:t,onCursorChange:n,onUndo:r,onRedo:i,onEscape:s,isValid:o=!0,height:a,maxHeight:l,showLineNumbers:c=!0,wrapLongLines:u=!0,className:h}){const f=(0,g.useRef)(null),d=(0,g.useRef)(null),m=(0,g.useRef)(e),v=(0,g.useRef)({onChange:t,onCursorChange:n,onUndo:r,onRedo:i,onEscape:s});m.current=e,v.current={onChange:t,onCursorChange:n,onUndo:r,onRedo:i,onEscape:s};const y=(0,g.useMemo)(()=>{const x=[p4,$H(m4),iW(),nH(),FH(),YH(),aH(),ie.updateListener.of(b=>{b.docChanged&&v.current.onChange?.(b.state.doc.toString()),(b.docChanged||b.selectionSet||b.focusChanged)&&v.current.onCursorChange?.(Mx(b.view))}),iT.of([{key:"Mod-z",run:()=>(v.current.onUndo?.(),!0)},{key:"Mod-y",run:()=>(v.current.onRedo?.(),!0)},{key:"Shift-Mod-z",run:()=>(v.current.onRedo?.(),!0)},{key:"Escape",run:()=>(v.current.onEscape?.(),!0)},d4,...f4])];return c&&x.push(yH(),wH()),u&&x.push(ie.lineWrapping),x},[c,u]);return(0,g.useEffect)(()=>{if(!f.current)return;const x=new ie({state:Ve.create({doc:m.current,extensions:y}),parent:f.current});return d.current=x,v.current.onCursorChange?.(Mx(x)),()=>{x.destroy(),d.current=null}},[y]),(0,g.useEffect)(()=>{const x=d.current;if(!x||x.state.doc.toString()===e)return;const b=Math.min(x.state.selection.main.head,e.length);x.dispatch({changes:{from:0,to:x.state.doc.length,insert:e},selection:{anchor:b}})},[e]),(0,p.jsx)("div",{className:G("h-full w-full overflow-hidden bg-muted/30",!o&&"border-destructive",h),style:{height:Rx(a,"100%"),maxHeight:Rx(l,"none")},children:(0,p.jsx)("div",{ref:f,className:"h-full w-full"})})}function v4({options:e,value:t,onChange:n,className:r,size:i="sm",disabled:s=!1}){const o=(0,g.useRef)(null),[a,l]=(0,g.useState)({});return(0,g.useEffect)(()=>{const c=o.current;if(!c)return;const u=e.findIndex(f=>f.value===t),h=c.querySelectorAll("button")[u];h&&l({width:h.offsetWidth,transform:`translateX(${h.offsetLeft}px)`})},[t,e,i]),(0,p.jsxs)("div",{ref:o,className:G("relative inline-flex items-center rounded-md bg-muted/50",i==="default"?"p-1":"p-0.5",s&&"opacity-50",r),children:[(0,p.jsx)("div",{className:G("absolute left-0 rounded-md bg-background shadow-sm","transition-all duration-200 ease-out",i==="default"?"top-1 h-[calc(100%-8px)]":"top-0.5 h-[calc(100%-4px)]"),style:a}),e.map(c=>(0,p.jsxs)("button",{type:"button",disabled:s||c.disabled,title:c.title,"aria-pressed":t===c.value,onClick:()=>n(c.value),className:G("relative z-10 flex items-center rounded-md font-medium transition-colors duration-200",i==="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",(s||c.disabled)&&"cursor-not-allowed",c.disabled&&!s&&"opacity-50"),children:[c.icon,c.label]},c.value))]})}var y4=[{value:"view",label:"View",icon:(0,p.jsx)(YD,{className:"h-3 w-3"})},{value:"edit",label:"Edit",icon:(0,p.jsx)(sN,{className:"h-3 w-3"})}];function x4({mode:e,onModeChange:t,showModeToggle:n=!0,readOnly:r=!1,onFormat:i,onCopy:s,onUndo:o,onRedo:a,canUndo:l=!1,canRedo:c=!1,isMaximized:u=!1,onToggleMaximize:h,allowMaximize:f=!1,isValid:d=!0,className:m,leftContent:v,rightContent:y,error:x}){const[b,w]=(0,g.useState)(!1),S=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);const C=async()=>{let A;try{A=await s?.()}catch{return}A!==!1&&(S.current&&clearTimeout(S.current),w(!0),S.current=setTimeout(()=>w(!1),2e3))};return(0,p.jsxs)("div",{className:G("flex items-center justify-between border-b border-border/50 px-3 py-1.5 bg-muted/50",m),children:[(0,p.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[v,n&&!r&&t&&(0,p.jsx)(v4,{options:y4,value:e,onChange:t})]}),x?(0,p.jsxs)(mr,{children:[(0,p.jsx)(gr,{asChild:!0,children:(0,p.jsxs)("div",{className:"mx-3 flex min-w-0 flex-1 cursor-default items-center gap-1.5 text-xs text-destructive",children:[(0,p.jsx)(nu,{className:"h-3 w-3 shrink-0"}),(0,p.jsx)("span",{className:"truncate",children:x})]})}),(0,p.jsx)(vr,{side:"bottom",className:"max-w-[min(40rem,calc(100vw-2rem))] break-words",children:(0,p.jsx)("p",{children:x})})]}):null,(0,p.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[e==="edit"&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(mr,{children:[(0,p.jsx)(gr,{asChild:!0,children:(0,p.jsx)(Ot,{size:"sm",variant:"ghost",onClick:o,disabled:!l,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:(0,p.jsx)(uN,{className:"h-3.5 w-3.5"})})}),(0,p.jsx)(vr,{side:"bottom",children:(0,p.jsx)("p",{children:"Undo (Ctrl+Z)"})})]}),(0,p.jsxs)(mr,{children:[(0,p.jsx)(gr,{asChild:!0,children:(0,p.jsx)(Ot,{size:"sm",variant:"ghost",onClick:a,disabled:!c,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:(0,p.jsx)(aN,{className:"h-3.5 w-3.5"})})}),(0,p.jsx)(vr,{side:"bottom",children:(0,p.jsx)("p",{children:"Redo (Ctrl+Shift+Z)"})})]}),(0,p.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),(0,p.jsxs)(mr,{children:[(0,p.jsx)(gr,{asChild:!0,children:(0,p.jsx)(Ot,{size:"sm",variant:"ghost",onClick:i,disabled:!d,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:(0,p.jsx)(cN,{className:"h-3.5 w-3.5"})})}),(0,p.jsx)(vr,{side:"bottom",children:(0,p.jsx)("p",{children:"Format JSON"})})]})]}),(0,p.jsxs)(mr,{children:[(0,p.jsx)(gr,{asChild:!0,children:(0,p.jsx)(Ot,{size:"sm",variant:"ghost",onClick:C,className:G("h-7 w-7 p-0 transition-all duration-200 hover:scale-105",b&&"bg-success/10"),children:b?(0,p.jsx)(hs,{className:"h-3.5 w-3.5 text-success"}):(0,p.jsx)(ts,{className:"h-3.5 w-3.5"})})}),(0,p.jsx)(vr,{side:"bottom",children:(0,p.jsx)("p",{children:b?"Copied!":"Copy to clipboard"})})]}),f&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),(0,p.jsxs)(mr,{children:[(0,p.jsx)(gr,{asChild:!0,children:(0,p.jsx)(Ot,{size:"sm",variant:"ghost",onClick:h,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:u?(0,p.jsx)(nN,{className:"h-3.5 w-3.5"}):(0,p.jsx)(eN,{className:"h-3.5 w-3.5"})})}),(0,p.jsx)(vr,{side:"bottom",children:(0,p.jsx)("p",{children:u?"Exit fullscreen":"Fullscreen"})})]})]}),y&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),y]})]})]})}function b4({cursorPosition:e,characterCount:t,validationError:n,className:r}){return(0,p.jsxs)("div",{className:G("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,p.jsxs)("div",{className:"flex items-center gap-3",children:[(0,p.jsxs)("span",{className:"transition-colors duration-200",children:["Ln ",e.line,", Col ",e.column]}),(0,p.jsxs)("span",{className:"transition-colors duration-200",children:[t.toLocaleString()," chars"]})]}),n?(0,p.jsxs)(mr,{children:[(0,p.jsx)(gr,{asChild:!0,children:(0,p.jsxs)("div",{className:"flex min-w-0 cursor-default items-center gap-1.5 text-destructive",children:[(0,p.jsx)(nu,{className:"h-3 w-3 shrink-0"}),(0,p.jsx)("span",{className:"truncate",children:n})]})}),(0,p.jsx)(vr,{side:"top",className:"max-w-[min(40rem,calc(100vw-2rem))] break-words",children:(0,p.jsx)("p",{children:n})})]}):null]})}function w4(e){if(e===void 0)return"null";try{return JSON.stringify(e,null,2)??"null"}catch{return"null"}}function vp(){return(0,p.jsxs)("div",{className:"flex items-center justify-center p-4 text-sm text-muted-foreground",children:[(0,p.jsx)(nu,{className:"h-4 w-4 mr-2 text-destructive"}),"Failed to render JSON content"]})}function S4(e){return e.viewOnly&&e.rawContent===void 0?(0,p.jsx)(k4,{...e}):(0,p.jsx)(C4,{...e})}function k4({value:e,expandJsonStrings:t=!1,className:n,height:r,maxHeight:i,collapsible:s=!1,defaultExpandDepth:o,collapsedPaths:a,onCollapseChange:l,showLineNumbers:c=!0,collapseStringsAfterLength:u,wrapLongLinesInView:h=!0}){const f=(0,g.useMemo)(()=>t?ui(e):e,[t,e]);return(0,p.jsx)(Sc,{fallback:(0,p.jsx)(vp,{}),children:(0,p.jsx)(ud,{value:f,className:n,height:r??"100%",maxHeight:i,collapsible:s,defaultExpandDepth:o,collapsedPaths:a,onCollapseChange:l,showLineNumbers:c,collapseStringsAfterLength:u,wrapLongLinesInView:h})})}function C4({value:e,onChange:t,rawContent:n,onRawChange:r,mode:i,onModeChange:s,readOnly:o=!1,showModeToggle:a=!0,showToolbar:l=!0,allowMaximize:c=!1,height:u,maxHeight:h,className:f,onValidationError:d,collapsible:m=!1,defaultExpandDepth:v,collapsedPaths:y,onCollapseChange:x,collapseStringsAfterLength:b,viewOnly:w=!1,expandJsonStrings:S=!1,autoFormatOnEdit:C=!0,wrapLongLinesInEdit:A=!1,editSurface:k="codemirror",wrapLongLinesInView:E=!0,showLineNumbers:T=!0,toolbarLeftContent:R,toolbarRightContent:P,error:M,showValidationErrorInStatusBar:N=!0}){const L=n!==void 0,[I,_]=(0,g.useState)("view"),j=o?"view":i??I,[$,B]=(0,g.useState)(!1),D=Sz({initialValue:L?void 0:e,initialContent:L?n:void 0,onChange:t,onRawChange:L?r:void 0,onValidationError:d,expandJsonStrings:S}),se=L?n??"":D.sourceContent,ne=D.content!==se,F=(0,g.useRef)(j),q=(0,g.useRef)(!1),K=(0,g.useMemo)(()=>L?D.getParsedValue():S?ui(e):e,[D.content,S,L,e]);(0,g.useEffect)(()=>{const ae=F.current,at=!q.current;q.current=!0,F.current=j,!(w||o||!C)&&(!(j==="edit"&&(at||ae!=="edit"))||!D.isValid||D.format())},[j,D.format,D.isValid,C,o,w]);const Y=(0,g.useCallback)(ae=>{if(!o){if(j==="edit"&&ae==="view"&&ne&&!D.isValid){if(!window.confirm("The JSON is invalid. Switching to view mode will lose your changes. Continue?"))return;D.reset()}_(ae),s?.(ae)}},[j,ne,D,s,o]),H=(0,g.useCallback)(async()=>{let ae;return j==="edit"?ae=D.content:L?ae=n??"":ae=w4(e),uu(ae)},[j,D.content,e,L,n]),X=(0,g.useCallback)(()=>{ne&&!window.confirm("You have unsaved changes. Discard them?")||(D.reset(),_("view"),s?.("view"))},[ne,D,s]),oe=(0,g.useCallback)(()=>{B(ae=>!ae)},[]);if(w)return(0,p.jsx)(Sc,{fallback:(0,p.jsx)(vp,{}),children:(0,p.jsx)(ud,{value:K,className:f,height:u??"100%",maxHeight:h,collapsible:m,defaultExpandDepth:v,collapsedPaths:y,onCollapseChange:x,showLineNumbers:T,collapseStringsAfterLength:b,wrapLongLinesInView:E})});const pe=$?{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:50}:{height:u??"100%",maxHeight:h??"none"};return(0,p.jsx)(Sc,{fallback:(0,p.jsx)(vp,{}),children:(0,p.jsxs)("div",{className:G("flex flex-col rounded-lg bg-background overflow-hidden",$&&"rounded-none",f),style:pe,children:[l&&(0,p.jsx)(x4,{mode:j,onModeChange:Y,showModeToggle:a&&!o,readOnly:o,onFormat:D.format,onCopy:H,onUndo:D.undo,onRedo:D.redo,canUndo:D.canUndo,canRedo:D.canRedo,isMaximized:$,onToggleMaximize:oe,allowMaximize:c,isValid:D.isValid,leftContent:R,rightContent:P,error:M}),(0,p.jsx)("div",{className:"flex-1 min-h-0 h-full",children:j==="view"?(0,p.jsx)(ud,{value:K,height:u??"100%",collapsible:m,defaultExpandDepth:v,collapsedPaths:y,onCollapseChange:x,showLineNumbers:T,collapseStringsAfterLength:b,wrapLongLinesInView:E}):k==="codemirror"?(0,p.jsx)(g4,{content:D.content,onChange:D.setContent,onCursorChange:D.setCursorPosition,onUndo:D.undo,onRedo:D.redo,onEscape:X,isValid:D.isValid,height:u??"100%",maxHeight:$?void 0:h,showLineNumbers:T,wrapLongLines:A}):(0,p.jsx)(iC,{content:D.content,onChange:D.setContent,onCursorChange:D.setCursorPosition,onUndo:D.undo,onRedo:D.redo,onEscape:X,isValid:D.isValid,height:u??"100%",maxHeight:$?void 0:h,showLineNumbers:T,wrapLongLinesInEdit:A,wrapLongLinesInView:E})}),j==="edit"&&(0,p.jsx)(b4,{cursorPosition:D.cursorPosition,characterCount:D.content.length,validationError:N?D.validationError:null})]})})}function A4({value:e,className:t,collapsible:n=!1,defaultExpandDepth:r,collapsedPaths:i,onCollapseChange:s,collapseStringsAfterLength:o,expandJsonStrings:a=!1,wrapLongLinesInView:l=!0,showLineNumbers:c=!0,containerClassName:u}){return(0,p.jsx)("div",{className:G("overflow-auto",u),children:(0,p.jsx)(S4,{value:e,className:t,collapsible:n,defaultExpandDepth:r,collapsedPaths:i,onCollapseChange:s,collapseStringsAfterLength:o,expandJsonStrings:a,wrapLongLinesInView:l,showLineNumbers:c,height:"auto",viewOnly:!0,showToolbar:!1})})}var T4=class extends Error{};function X8(e){return typeof e=="string"&&e===e.trim()&&/^[A-Za-z0-9][A-Za-z0-9._~:-]{0,255}$/.test(e)&&!e.startsWith("server-")}function E4(e){const t=()=>new T4("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 i=n?n[1]:"https",s=n?n[2]:r[1],o=n?n[3]:r[2],a=n?n[4]:r[3],l=s.split("@");if(l.length>2||i==="https"&&l.length!==1)throw t();const c=y=>{let x;try{x=decodeURIComponent(y)}catch{throw t()}if(!x||x.length>256||/[\u0000-\u001f\u007f\\]/.test(x))throw t();return x},u=c(l[0]),h=l[1]===void 0?void 0:c(l[1]),f=c(o);if([u,h,f].some(y=>y==="."||y==="..")||a&&/%(?![\da-f]{2})/i.test(a))throw t();const d=new URLSearchParams(a),m=[...d.entries()];if(m.some(([y])=>y!=="path")||m.length>1)throw t();const v=d.get("path")??"/";if(!v.startsWith("/")||v.startsWith("//")||v.length>4096||/[\u0000-\u001f\u007f\\#]/.test(v)||new TextEncoder().encode(v).byteLength>8192)throw t();return{scheme:i,pluginId:u,...h===void 0?{}:{marketplace:h},toolName:f,url:v}}var GT=(0,g.createContext)(null);function J8({value:e,children:t}){return(0,p.jsx)(GT.Provider,{value:e,children:t})}function Px(e){try{return E4(e),!0}catch{return!1}}function yp(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(yp).join(""):(0,g.isValidElement)(e)?yp(e.props.children):""}var M4=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Xh=e=>e.replace(/([\\[\]])/g,"\\$1"),QT="#mcpjam-link-",R4=/(?:codex|chatgpt):\/\/plugins\/[^\s)\]>]+|https:\/\/chatgpt\.com\/plugins\/[^\s)\]>]+/g,P4=/(`[^`\n]*`)|\[((?:\\.|[^\[\]\\])*)\]\(\s*<?([^\s)>]+)>?(?:\s+"[^"]*")?\s*\)|<([a-z][a-z0-9+.-]*:[^>\s]+)>/gi;function I4(e,t,n){const r=[],i=h=>!!t[h]||n&&Px(h),s=(h,f)=>(r.push(f),`[${h}](${QT}${r.length-1})`);if(/^\s*(```|~~~)/.test(e))return{content:e,targets:r};const o=Object.keys(t).filter(h=>e.includes(h)).sort((h,f)=>f.length-h.length),a=o.length?new RegExp(o.map(M4).join("|"),"g"):null,l=h=>{let f=a?h.replace(a,d=>s(Xh(t[d]?.name??d),d)):h;return n&&(f=f.replace(R4,d=>Px(d)?s(Xh(d),d):d)),f};let c="",u=0;for(const h of e.matchAll(P4)){c+=l(e.slice(u,h.index)),u=h.index+h[0].length;const[f,d,m,v,y]=h;d!==void 0?c+=f:v!==void 0?c+=i(v)?s(m,v):f:y!==void 0?c+=i(y)?s(Xh(t[y]?.name??y),y):f:c+=f}return{content:c+l(e.slice(u)),targets:r}}function O4(){const e=pz(),t=(0,g.useContext)(GT),n=(0,g.useCallback)(r=>{const i=I4(r,e,!!t);if(!i.targets.length)return null;const s=AM.a,o=a=>{const l=typeof a.href=="string"?a.href:"",c=l.startsWith(QT)?Number(l.slice(13)):NaN,u=Number.isInteger(c)?i.targets[c]:void 0;if(!u)return(0,p.jsx)(s,{...a});const h=e[u];if(h){const f=yp(a.children).trim();return(0,p.jsx)(J1,{reference:{serverId:h.serverId,resourceUri:u},label:!f||f===u?h.name:a.children})}return(0,p.jsx)("button",{type:"button",className:"text-primary underline underline-offset-2",title:u,onClick:()=>t?.open(u),children:a.children})};return{content:i.content,components:{a:o}}},[e,t]);return Object.keys(e).length||t?n:null}var YT=(0,g.createContext)({linkBase:null,trustLinks:!1});function Z8({base:e,trustLinks:t=!1,children:n}){const r=(0,g.useMemo)(()=>({linkBase:e,trustLinks:t}),[e,t]);return(0,p.jsx)(YT.Provider,{value:r,children:n})}function D4(e){if(!e)return;const t=e.replace(/\/$/,"");return(n,r,i)=>n.startsWith("/")&&!n.startsWith("//")?t+n:CM(n,r,i)}function N4(e){const t=kM.lexer(e);return t.length===0?[e]:t.map(n=>n.raw)}var XT=(0,g.memo)(({content:e})=>{const{linkBase:t,trustLinks:n}=(0,g.useContext)(YT),r=O4(),i=(0,g.useMemo)(()=>D4(t),[t]),s=(0,g.useMemo)(()=>n?{enabled:!1}:void 0,[n]),o=(0,g.useMemo)(()=>r?.(e)??null,[r,e]);return(0,p.jsx)(SM,{linkSafety:s,urlTransform:i,...o?{components:o.components}:{},children:o?o.content:e})},(e,t)=>e.content===t.content);XT.displayName="MemoizedMarkdownBlock";var JT=(0,g.memo)(({content:e,className:t})=>(0,g.useMemo)(()=>N4(e),[e]).map((n,r)=>(0,p.jsx)("div",{className:t,children:(0,p.jsx)(XT,{content:n})},`markdown-block_${r}`)),(e,t)=>!(e.content!==t.content||e.className!==t.className));JT.displayName="MemoizedMarkdown";var ZT="/web/artifact",eE=3e4,L4=15e3,_4=2e3,j4=2e4,B4=new Set([401,403,404,410]),F4=new Set([404,410]),V4=1,z4=6e5;function Ia(e){if(!e)return!1;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&t.pathname.endsWith(ZT)&&t.searchParams.has("t")}catch{return!1}}function Ru(e){if(!Ia(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 i=JSON.parse(atob(r+"=".repeat((4-r.length%4)%4)));if(!i||typeof i!="object")return null;const{s,k:o,e:a}=i;return typeof s=="string"&&typeof o=="string"&&typeof a=="number"?{s,k:o,e:a}:null}catch{return null}}function dg(e,t){return`artifact:${new URL(e).origin}:${t.k}:${t.s}`}function pg(e){const t=Ru(e);return t?dg(e,t):e}var As=new Map,tE=0,la=new Set;function $4(e){for(const[t,n]of As)n.expiresAt<=e&&As.delete(t)}function H4(e){const t=Ru(e);if(!t)return!1;const n=dg(e,t),r=t.e*1e3,i=As.get(n);return i&&i.expiresAt>=r?!1:(As.set(n,{url:e,expiresAt:r}),!0)}function W4(e){let t=!1,n=j4;const r=[e];for(;r.length>0&&n>0;){n-=1;const i=r.pop();if(typeof i=="string")i.includes(ZT)&&H4(i)&&(t=!0);else if(Array.isArray(i))for(const s of i)r.push(s);else if(i&&typeof i=="object")for(const s of Object.values(i))r.push(s)}if(t){As.size>_4&&$4(Date.now()),tE+=1;for(const i of la)i()}}function Lc(e){const t=Ru(e);if(!t)return e;const n=As.get(dg(e,t));return n&&n.expiresAt>t.e*1e3?n.url:e}function U4(e){return la.add(e),()=>{la.delete(e)}}function Ix(){return tE}function q4(e,t){const n=Lc(e);return n!==e?Promise.resolve(n):new Promise(r=>{const i=()=>{const a=Lc(e);a!==e&&(o(),r(a))},s=setTimeout(()=>{o(),r(null)},t),o=()=>{clearTimeout(s),la.delete(i)};la.add(i)})}function mg(e){return(0,g.useSyncExternalStore)(U4,Ix,Ix),typeof e=="string"?Lc(e):e}var xp,bp=Number.NEGATIVE_INFINITY,wp=new Set,_c=new Map;function nE(e){return(_c.get(pg(e))??0)<V4}function rE(e){const t=pg(e);_c.set(t,(_c.get(t)??0)+1)}function Sp(e){_c.delete(pg(e))}function iE(e=Date.now()){if(e-bp<eE)return!1;bp=e,xp=Math.max((xp??0)+1,Math.floor(e/6e4));for(const t of wp)t();return!0}function K4(e){return wp.add(e),()=>{wp.delete(e)}}function Ox(){return xp}function G4(){return(0,g.useSyncExternalStore)(K4,Ox,Ox)}async function Q4(e,t){const n=Lc(e),r=t===void 0?await fetch(n):await fetch(n,t);if(!Ia(n))return r;if(r.ok)return Sp(n),r;if(!B4.has(r.status))return r;const i=F4.has(r.status);if(i&&!nE(n))return r;iE()&&i&&rE(n);const s=await q4(n,L4);if(!s||t?.signal?.aborted)return r;const o=t===void 0?await fetch(s):await fetch(s,t);return o.ok&&Sp(s),o}function sE(e,t=Date.now()){if(!Ia(e))return null;const n=Ru(e),r=n!==null&&n.e*1e3-t<=z4;return!r&&!nE(e)?null:iE(t)?(r||rE(e),0):bp+eE-t}function oE(e){Ia(e)&&Sp(e)}function eK(e,t){const n=G4(),r=t==="skip"||n===void 0?t:{...t,urlEpoch:n},i=V1(e,r);(0,g.useEffect)(()=>{i!==void 0&&W4(i)},[i]);const s=t==="skip"?null:JSON.stringify(t),o=(0,g.useRef)(null);if(s!==null)return i!==void 0?(o.current={argsKey:s,value:i},i):o.current?.argsKey===s?o.current.value:void 0}function aE({src:e,alt:t,onError:n,onLoad:r,...i}){const s=mg(e);return(0,p.jsx)("img",{...i,src:s,alt:t,onError:o=>{sE(s),n?.(o)},onLoad:o=>{oE(s),r?.(o)}})}var Y4="eval-account-selection-enabled";function X4(){return $1(Y4)===!0}var Pu=(0,g.createContext)(null);Pu.displayName="PanelGroupContext";var De={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"},gg=10,fi=g.useLayoutEffect,Dx=g.useId,J4=typeof Dx=="function"?Dx:()=>null,Z4=0;function vg(e=null){const t=J4(),n=(0,g.useRef)(e||t||null);return n.current===null&&(n.current=""+Z4++),e??n.current}function lE({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:o,maxSize:a,minSize:l,onCollapse:c,onExpand:u,onResize:h,order:f,style:d,tagName:m="div",...v}){const y=(0,g.useContext)(Pu);if(y===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:b,getPanelSize:w,getPanelStyle:S,groupId:C,isPanelCollapsed:A,reevaluatePanelConstraints:k,registerPanel:E,resizePanel:T,unregisterPanel:R}=y,P=vg(o),M=(0,g.useRef)({callbacks:{onCollapse:c,onExpand:u,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:a,minSize:l},id:P,idIsFromProps:o!==void 0,order:f});(0,g.useRef)({didLogMissingDefaultSizeWarning:!1}),fi(()=>{const{callbacks:L,constraints:I}=M.current,_={...I};M.current.id=P,M.current.idIsFromProps=o!==void 0,M.current.order=f,L.onCollapse=c,L.onExpand=u,L.onResize=h,I.collapsedSize=n,I.collapsible=r,I.defaultSize=i,I.maxSize=a,I.minSize=l,(_.collapsedSize!==I.collapsedSize||_.collapsible!==I.collapsible||_.maxSize!==I.maxSize||_.minSize!==I.minSize)&&k(M.current,_)}),fi(()=>{const L=M.current;return E(L),()=>{R(L)}},[f,P,E,R]),(0,g.useImperativeHandle)(s,()=>({collapse:()=>{x(M.current)},expand:L=>{b(M.current,L)},getId(){return P},getSize(){return w(M.current)},isCollapsed(){return A(M.current)},isExpanded(){return!A(M.current)},resize:L=>{T(M.current,L)}}),[x,b,w,A,P,T]);const N=S(M.current,i);return(0,g.createElement)(m,{...v,children:e,className:t,id:P,style:{...N,...d},[De.groupId]:C,[De.panel]:"",[De.panelCollapsible]:r||void 0,[De.panelId]:P,[De.panelSize]:parseFloat(""+N.flexGrow).toFixed(1)})}var yg=(0,g.forwardRef)((e,t)=>(0,g.createElement)(lE,{...e,forwardedRef:t}));lE.displayName="Panel";yg.displayName="forwardRef(Panel)";var eU;function tU(){return eU}var kp=null,nU=!0,Nx=null,rc=-1,Kn=null;function rU(e,t,n){const r=(t&dE)!==0,i=(t&pE)!==0,s=(t&mE)!==0,o=(t&gE)!==0;if(Nx)return Nx({exceedsHorizontalMaximum:i,exceedsHorizontalMinimum:r,exceedsVerticalMaximum:o,exceedsVerticalMinimum:s,intersectsHorizontalDragHandle:e==="horizontal"||e==="intersection",intersectsVerticalDragHandle:e==="vertical"||e==="intersection",isPointerDown:n});if(t){if(r)return s?"se-resize":o?"ne-resize":"e-resize";if(i)return s?"sw-resize":o?"nw-resize":"w-resize";if(s)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 iU(){Kn!==null&&(document.head.removeChild(Kn),kp=null,Kn=null,rc=-1)}function Jh(e,t,n){var r,i;if(!nU)return;const s=rU(e,t,n);if(kp!==s){if(kp=s,Kn===null){Kn=document.createElement("style");const a=tU();a&&Kn.setAttribute("nonce",a),document.head.appendChild(Kn)}if(rc>=0){var o;(o=Kn.sheet)===null||o===void 0||o.removeRule(rc)}rc=(r=(i=Kn.sheet)===null||i===void 0?void 0:i.insertRule(`*{cursor: ${s} !important;}`))!==null&&r!==void 0?r:-1}}function cE(e){return e.type==="keydown"}function uE(e){return e.type.startsWith("pointer")}function hE(e){return e.type.startsWith("mouse")}function Iu(e){if(uE(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(hE(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function sU(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function oU(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 aU(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:jx(e),b:jx(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;ce(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:_x(Lx(n.a)),b:_x(Lx(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}var lU=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function cU(e){var t;const n=getComputedStyle((t=fE(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function uU(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||cU(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"||lU.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Lx(e){let t=e.length;for(;t--;){const n=e[t];if(ce(n,"Missing node"),uU(n))return n}return null}function _x(e){return e&&Number(getComputedStyle(e).zIndex)||0}function jx(e){const t=[];for(;e;)t.push(e),e=fE(e);return t}function fE(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}var dE=1,pE=2,mE=4,gE=8,hU=sU()==="coarse",sn=[],ir=!1,Sr=new Map,Ou=new Map,ca=new Set;function fU(e,t,n,r,i){var s;const{ownerDocument:o}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=Sr.get(o))!==null&&s!==void 0?s:0;return Sr.set(o,l+1),ca.add(a),jc(),function(){var u;Ou.delete(e),ca.delete(a);const h=(u=Sr.get(o))!==null&&u!==void 0?u:1;if(Sr.set(o,h-1),jc(),h===1&&Sr.delete(o),sn.includes(a)){const f=sn.indexOf(a);f>=0&&sn.splice(f,1),Du(),i("up",!0,null)}}}function dU(e){const{target:t}=e,{x:n,y:r}=Iu(e);ir=!0,xg({target:t,x:n,y:r}),jc(),sn.length>0&&(Bc("down",e),Du(),e.preventDefault(),vE(t)||e.stopImmediatePropagation())}function Zh(e){const{x:t,y:n}=Iu(e);if(ir&&e.type!=="pointerleave"&&e.buttons===0&&(ir=!1,Bc("up",e)),!ir){const{target:r}=e;xg({target:r,x:t,y:n})}Bc("move",e),Du(),sn.length>0&&e.preventDefault()}function ef(e){const{target:t}=e,{x:n,y:r}=Iu(e);Ou.clear(),ir=!1,sn.length>0&&(e.preventDefault(),vE(t)||e.stopImmediatePropagation()),Bc("up",e),xg({target:t,x:n,y:r}),Du(),jc()}function vE(e){let t=e;for(;t;){if(t.hasAttribute(De.resizeHandle))return!0;t=t.parentElement}return!1}function xg({target:e,x:t,y:n}){sn.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),ca.forEach(i=>{const{element:s,hitAreaMargins:o}=i,a=s.getBoundingClientRect(),{bottom:l,left:c,right:u,top:h}=a,f=hU?o.coarse:o.fine;if(t>=c-f&&t<=u+f&&n>=h-f&&n<=l+f){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&aU(r,s)>0){let d=r,m=!1;for(;d&&!d.contains(s);){if(oU(d.getBoundingClientRect(),a,!0)){m=!0;break}d=d.parentElement}if(m)return}sn.push(i)}})}function tf(e,t){Ou.set(e,t)}function Du(){let e=!1,t=!1;sn.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;Ou.forEach(r=>{n|=r}),e&&t?Jh("intersection",n,ir):e?Jh("horizontal",n,ir):t?Jh("vertical",n,ir):iU()}var nf;function jc(){var e;(e=nf)===null||e===void 0||e.abort(),nf=new AbortController;const t={capture:!0,signal:nf.signal};ca.size&&(ir?(sn.length>0&&Sr.forEach((n,r)=>{const{body:i}=r;n>0&&(i.addEventListener("contextmenu",ef,t),i.addEventListener("pointerleave",Zh,t),i.addEventListener("pointermove",Zh,t))}),Sr.forEach((n,r)=>{const{body:i}=r;i.addEventListener("pointerup",ef,t),i.addEventListener("pointercancel",ef,t)})):Sr.forEach((n,r)=>{const{body:i}=r;n>0&&(i.addEventListener("pointerdown",dU,t),i.addEventListener("pointermove",Zh,t))}))}function Bc(e,t){ca.forEach(n=>{const{setResizeHandlerState:r}=n;r(e,sn.includes(n),t)})}function pU(){const[e,t]=(0,g.useState)(0);return(0,g.useCallback)(()=>t(n=>n+1),[])}function ce(e,t){if(!e)throw console.error(t),Error(t)}function wi(e,t,n=gg){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Xn(e,t,n=gg){return wi(e,t,n)===0}function Et(e,t,n){return wi(e,t,n)===0}function mU(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],s=t[r];if(!Et(i,s,n))return!1}return!0}function Ji({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];ce(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:o=100,minSize:a=0}=r;if(wi(n,a)<0)if(s){const l=(i+a)/2;wi(n,l)<0?n=i:n=a}else n=a;return n=Math.min(o,n),n=parseFloat(n.toFixed(gg)),n}function go({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Et(e,0))return t;const o=[...t],[a,l]=r;ce(a!=null,"Invalid first pivot index"),ce(l!=null,"Invalid second pivot index");let c=0;if(s==="keyboard"){{const u=e<0?l:a,h=n[u];ce(h,`Panel constraints not found for index ${u}`);const{collapsedSize:f=0,collapsible:d,minSize:m=0}=h;if(d){const v=t[u];if(ce(v!=null,`Previous layout not found for panel index ${u}`),Et(v,f)){const y=m-v;wi(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{const u=e<0?a:l,h=n[u];ce(h,`No panel constraints found for index ${u}`);const{collapsedSize:f=0,collapsible:d,minSize:m=0}=h;if(d){const v=t[u];if(ce(v!=null,`Previous layout not found for panel index ${u}`),Et(v,m)){const y=v-f;wi(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}}{const u=e<0?1:-1;let h=e<0?l:a,f=0;for(;;){const m=t[h];ce(m!=null,`Previous layout not found for panel index ${h}`);const v=Ji({panelConstraints:n,panelIndex:h,size:100})-m;if(f+=v,h+=u,h<0||h>=n.length)break}const d=Math.min(Math.abs(e),Math.abs(f));e=e<0?0-d:d}{let u=e<0?a:l;for(;u>=0&&u<n.length;){const h=Math.abs(e)-Math.abs(c),f=t[u];ce(f!=null,`Previous layout not found for panel index ${u}`);const d=f-h,m=Ji({panelConstraints:n,panelIndex:u,size:d});if(!Et(f,m)&&(c+=f-m,o[u]=m,c.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?u--:u++}}if(mU(i,o))return i;{const u=e<0?l:a,h=t[u];ce(h!=null,`Previous layout not found for panel index ${u}`);const f=h+c,d=Ji({panelConstraints:n,panelIndex:u,size:f});if(o[u]=d,!Et(d,f)){let m=f-d,v=e<0?l:a;for(;v>=0&&v<n.length;){const y=o[v];ce(y!=null,`Previous layout not found for panel index ${v}`);const x=y+m,b=Ji({panelConstraints:n,panelIndex:v,size:x});if(Et(y,b)||(m-=b-y,o[v]=b),Et(m,0))break;e>0?v--:v++}}}return Et(o.reduce((u,h)=>h+u,0),100)?o:i}function gU({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,o=0;const a=n[0];return ce(a!=null,"No pivot index found"),t.forEach((l,c)=>{const{constraints:u}=l,{maxSize:h=100,minSize:f=0}=u;c===a?(r=f,i=h):(s+=f,o+=h)}),{valueMax:Math.min(i,100-s),valueMin:Math.max(r,100-o),valueNow:e[a]}}function ua(e,t=document){return Array.from(t.querySelectorAll(`[${De.resizeHandleId}][data-panel-group-id="${e}"]`))}function yE(e,t,n=document){const r=ua(e,n).findIndex(i=>i.getAttribute(De.resizeHandleId)===t);return r??null}function xE(e,t,n){const r=yE(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function vU(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function bE(e,t=document){if(vU(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Nu(e,t=document){const n=t.querySelector(`[${De.resizeHandleId}="${e}"]`);return n||null}function yU(e,t,n,r=document){var i,s,o,a;const l=Nu(t,r),c=ua(e,r),u=l?c.indexOf(l):-1;return[(i=(s=n[u])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null,(o=(a=n[u+1])===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:null]}function xU({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:o}){(0,g.useRef)({didWarnAboutMissingResizeHandle:!1}),fi(()=>{if(!s)return;const a=ua(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:c,valueMin:u,valueNow:h}=gU({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),f=a[l];if(f!=null){const d=i[l];ce(d,`No panel data found for index "${l}"`),f.setAttribute("aria-controls",d.id),f.setAttribute("aria-valuemax",""+Math.round(c)),f.setAttribute("aria-valuemin",""+Math.round(u)),f.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{a.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,i,s]),(0,g.useEffect)(()=>{if(!s)return;const a=t.current;ce(a,"Eager values not found");const{panelDataArray:l}=a;ce(bE(n,s)!=null,`No group found for id "${n}"`);const c=ua(n,s);ce(c,`No resize handles found for group id "${n}"`);const u=c.map(h=>{const f=h.getAttribute(De.resizeHandleId);ce(f,"Resize handle element has no handle id attribute");const[d,m]=yU(n,f,l,s);if(d==null||m==null)return()=>{};const v=y=>{if(!y.defaultPrevented)switch(y.key){case"Enter":{y.preventDefault();const x=l.findIndex(b=>b.id===d);if(x>=0){const b=l[x];ce(b,`No panel data found for index ${x}`);const w=r[x],{collapsedSize:S=0,collapsible:C,minSize:A=0}=b.constraints;if(w!=null&&C){const k=go({delta:Et(w,S)?A-S:S-w,initialLayout:r,panelConstraints:l.map(E=>E.constraints),pivotIndices:xE(n,f,s),prevLayout:r,trigger:"keyboard"});r!==k&&o(k)}}break}}};return h.addEventListener("keydown",v),()=>{h.removeEventListener("keydown",v)}});return()=>{u.forEach(h=>h())}},[s,e,t,n,r,i,o])}function Bx(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 wE(e,t){const n=e==="horizontal",{x:r,y:i}=Iu(t);return n?r:i}function bU(e,t,n,r,i){const s=n==="horizontal",o=Nu(t,i);ce(o,`No resize handle element found for id "${t}"`);const a=o.getAttribute(De.groupId);ce(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=wE(n,e),u=bE(a,i);ce(u,`No group element found for id "${a}"`);const h=u.getBoundingClientRect(),f=s?h.width:h.height;return(c-l)/f*100}function wU(e,t,n,r,i,s){if(cE(e)){const o=n==="horizontal";let a=0;e.shiftKey?a=100:i!=null?a=i: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:bU(e,t,n,r,s)}function SU({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,i=100;for(let s=0;s<e.length;s++){const o=n[s];ce(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;a!=null&&(r++,t[s]=a,i-=a)}for(let s=0;s<e.length;s++){const o=n[s];ce(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;if(a!=null)continue;const l=e.length-r,c=i/l;r++,t[s]=c,i-=c}return t}function _i(e,t,n){t.forEach((r,i)=>{const s=e[i];ce(s,`Panel data not found for index ${i}`);const{callbacks:o,constraints:a,id:l}=s,{collapsedSize:c=0,collapsible:u}=a,h=n[l];if(h==null||r!==h){n[l]=r;const{onCollapse:f,onExpand:d,onResize:m}=o;m&&m(r,h),u&&(f||d)&&(d&&(h==null||Xn(h,c))&&!Xn(r,c)&&d(),f&&(h==null||!Xn(h,c))&&Xn(r,c)&&f())}})}function yl(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 kU({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:s=3}){const o=n[i];let a;return o==null?a=e!=null?e.toFixed(s):"1":r.length===1?a="1":a=o.toFixed(s),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function CU(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function Fx(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 SE(e){return`react-resizable-panels:${e}`}function kE(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:i,order:s}=t;return i?r:s?`${s}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function CE(e,t){try{const n=SE(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function AU(e,t,n){var r,i;return(i=((r=CE(e,n))!==null&&r!==void 0?r:{})[kE(t)])!==null&&i!==void 0?i:null}function TU(e,t,n,r,i){var s;const o=SE(e),a=kE(t),l=(s=CE(e,i))!==null&&s!==void 0?s:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(o,JSON.stringify(l))}catch(c){console.error(c)}}function Vx({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,o)=>s+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!Et(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];ce(o!=null,`No layout data found for index ${s}`);const a=100/r*o;n[s]=a}let i=0;for(let s=0;s<t.length;s++){const o=n[s];ce(o!=null,`No layout data found for index ${s}`);const a=Ji({panelConstraints:t,panelIndex:s,size:o});o!=a&&(i+=o-a,n[s]=a)}if(!Et(i,0))for(let s=0;s<t.length;s++){const o=n[s];ce(o!=null,`No layout data found for index ${s}`);const a=o+i,l=Ji({panelConstraints:t,panelIndex:s,size:a});if(o!==l&&(i-=l-o,n[s]=l,Et(i,0)))break}return n}var EU=100,vo={getItem:e=>(Fx(vo),vo.getItem(e)),setItem:(e,t)=>{Fx(vo),vo.setItem(e,t)}},zx={};function AE({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:o=null,keyboardResizeBy:a=null,storage:l=vo,style:c,tagName:u="div",...h}){const f=vg(s),d=(0,g.useRef)(null),[m,v]=(0,g.useState)(null),[y,x]=(0,g.useState)([]),b=pU(),w=(0,g.useRef)({}),S=(0,g.useRef)(new Map),C=(0,g.useRef)(0),A=(0,g.useRef)({autoSaveId:e,direction:r,dragState:m,id:f,keyboardResizeBy:a,onLayout:o,storage:l}),k=(0,g.useRef)({layout:y,panelDataArray:[],panelDataArrayChanged:!1});(0,g.useRef)({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),(0,g.useImperativeHandle)(i,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:F}=k.current;return F},setLayout:F=>{const{onLayout:q}=A.current,{layout:K,panelDataArray:Y}=k.current,H=Vx({layout:F,panelConstraints:Y.map(X=>X.constraints)});Bx(K,H)||(x(H),k.current.layout=H,q&&q(H),_i(Y,H,w.current))}}),[]),fi(()=>{A.current.autoSaveId=e,A.current.direction=r,A.current.dragState=m,A.current.id=f,A.current.onLayout=o,A.current.storage=l}),xU({committedValuesRef:A,eagerValuesRef:k,groupId:f,layout:y,panelDataArray:k.current.panelDataArray,setLayout:x,panelGroupElement:d.current}),(0,g.useEffect)(()=>{const{panelDataArray:F}=k.current;if(e){if(y.length===0||y.length!==F.length)return;let q=zx[e];q==null&&(q=CU(TU,EU),zx[e]=q);const K=[...F],Y=new Map(S.current);q(e,K,Y,y,l)}},[e,y,l]),(0,g.useEffect)(()=>{});const E=(0,g.useCallback)(F=>{const{onLayout:q}=A.current,{layout:K,panelDataArray:Y}=k.current;if(F.constraints.collapsible){const H=Y.map(ae=>ae.constraints),{collapsedSize:X=0,panelSize:oe,pivotIndices:pe}=Gr(Y,F,K);if(ce(oe!=null,`Panel size not found for panel "${F.id}"`),!Xn(oe,X)){S.current.set(F.id,oe);const ae=go({delta:Hi(Y,F)===Y.length-1?oe-X:X-oe,initialLayout:K,panelConstraints:H,pivotIndices:pe,prevLayout:K,trigger:"imperative-api"});yl(K,ae)||(x(ae),k.current.layout=ae,q&&q(ae),_i(Y,ae,w.current))}}},[]),T=(0,g.useCallback)((F,q)=>{const{onLayout:K}=A.current,{layout:Y,panelDataArray:H}=k.current;if(F.constraints.collapsible){const X=H.map(Re=>Re.constraints),{collapsedSize:oe=0,panelSize:pe=0,minSize:ae=0,pivotIndices:at}=Gr(H,F,Y),et=q??ae;if(Xn(pe,oe)){const Re=S.current.get(F.id),ze=Re!=null&&Re>=et?Re:et,_e=go({delta:Hi(H,F)===H.length-1?pe-ze:ze-pe,initialLayout:Y,panelConstraints:X,pivotIndices:at,prevLayout:Y,trigger:"imperative-api"});yl(Y,_e)||(x(_e),k.current.layout=_e,K&&K(_e),_i(H,_e,w.current))}}},[]),R=(0,g.useCallback)(F=>{const{layout:q,panelDataArray:K}=k.current,{panelSize:Y}=Gr(K,F,q);return ce(Y!=null,`Panel size not found for panel "${F.id}"`),Y},[]),P=(0,g.useCallback)((F,q)=>{const{panelDataArray:K}=k.current,Y=Hi(K,F);return kU({defaultSize:q,dragState:m,layout:y,panelData:K,panelIndex:Y})},[m,y]),M=(0,g.useCallback)(F=>{const{layout:q,panelDataArray:K}=k.current,{collapsedSize:Y=0,collapsible:H,panelSize:X}=Gr(K,F,q);return ce(X!=null,`Panel size not found for panel "${F.id}"`),H===!0&&Xn(X,Y)},[]),N=(0,g.useCallback)(F=>{const{layout:q,panelDataArray:K}=k.current,{collapsedSize:Y=0,collapsible:H,panelSize:X}=Gr(K,F,q);return ce(X!=null,`Panel size not found for panel "${F.id}"`),!H||wi(X,Y)>0},[]),L=(0,g.useCallback)(F=>{const{panelDataArray:q}=k.current;q.push(F),q.sort((K,Y)=>{const H=K.order,X=Y.order;return H==null&&X==null?0:H==null?-1:X==null?1:H-X}),k.current.panelDataArrayChanged=!0,b()},[b]);fi(()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;const{autoSaveId:F,onLayout:q,storage:K}=A.current,{layout:Y,panelDataArray:H}=k.current;let X=null;if(F){const pe=AU(F,H,K);pe&&(S.current=new Map(Object.entries(pe.expandToSizes)),X=pe.layout)}X==null&&(X=SU({panelDataArray:H}));const oe=Vx({layout:X,panelConstraints:H.map(pe=>pe.constraints)});Bx(Y,oe)||(x(oe),k.current.layout=oe,q&&q(oe),_i(H,oe,w.current))}}),fi(()=>{const F=k.current;return()=>{F.layout=[]}},[]);const I=(0,g.useCallback)(F=>{let q=!1;const K=d.current;return K&&window.getComputedStyle(K,null).getPropertyValue("direction")==="rtl"&&(q=!0),function(H){H.preventDefault();const X=d.current;if(!X)return()=>null;const{direction:oe,dragState:pe,id:ae,keyboardResizeBy:at,onLayout:et}=A.current,{layout:Re,panelDataArray:ze}=k.current,{initialLayout:_e}=pe??{},_n=xE(ae,F,X);let je=wU(H,F,oe,pe,at,X);const hn=oe==="horizontal";hn&&q&&(je=-je);const wt=ze.map(ge=>ge.constraints),tt=go({delta:je,initialLayout:_e??Re,panelConstraints:wt,pivotIndices:_n,prevLayout:Re,trigger:cE(H)?"keyboard":"mouse-or-touch"}),J=!yl(Re,tt);(uE(H)||hE(H))&&C.current!=je&&(C.current=je,!J&&je!==0?hn?tf(F,je<0?dE:pE):tf(F,je<0?mE:gE):tf(F,0)),J&&(x(tt),k.current.layout=tt,et&&et(tt),_i(ze,tt,w.current))}},[]),_=(0,g.useCallback)((F,q)=>{const{onLayout:K}=A.current,{layout:Y,panelDataArray:H}=k.current,X=H.map(at=>at.constraints),{panelSize:oe,pivotIndices:pe}=Gr(H,F,Y);ce(oe!=null,`Panel size not found for panel "${F.id}"`);const ae=go({delta:Hi(H,F)===H.length-1?oe-q:q-oe,initialLayout:Y,panelConstraints:X,pivotIndices:pe,prevLayout:Y,trigger:"imperative-api"});yl(Y,ae)||(x(ae),k.current.layout=ae,K&&K(ae),_i(H,ae,w.current))},[]),j=(0,g.useCallback)((F,q)=>{const{layout:K,panelDataArray:Y}=k.current,{collapsedSize:H=0,collapsible:X}=q,{collapsedSize:oe=0,collapsible:pe,maxSize:ae=100,minSize:at=0}=F.constraints,{panelSize:et}=Gr(Y,F,K);et!=null&&(X&&pe&&Xn(et,H)?Xn(H,oe)||_(F,oe):et<at?_(F,at):et>ae&&_(F,ae))},[_]),$=(0,g.useCallback)((F,q)=>{const{direction:K}=A.current,{layout:Y}=k.current;if(!d.current)return;const H=Nu(F,d.current);ce(H,`Drag handle element not found for id "${F}"`);const X=wE(K,q);v({dragHandleId:F,dragHandleRect:H.getBoundingClientRect(),initialCursorPosition:X,initialLayout:Y})},[]),B=(0,g.useCallback)(()=>{v(null)},[]),D=(0,g.useCallback)(F=>{const{panelDataArray:q}=k.current,K=Hi(q,F);K>=0&&(q.splice(K,1),delete w.current[F.id],k.current.panelDataArrayChanged=!0,b())},[b]),se=(0,g.useMemo)(()=>({collapsePanel:E,direction:r,dragState:m,expandPanel:T,getPanelSize:R,getPanelStyle:P,groupId:f,isPanelCollapsed:M,isPanelExpanded:N,reevaluatePanelConstraints:j,registerPanel:L,registerResizeHandle:I,resizePanel:_,startDragging:$,stopDragging:B,unregisterPanel:D,panelGroupElement:d.current}),[E,m,r,T,R,P,f,M,N,j,L,I,_,$,B,D]),ne={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return(0,g.createElement)(Pu.Provider,{value:se},(0,g.createElement)(u,{...h,children:t,className:n,id:s,ref:d,style:{...ne,...c},[De.group]:"",[De.groupDirection]:r,[De.groupId]:f}))}var TE=(0,g.forwardRef)((e,t)=>(0,g.createElement)(AE,{...e,forwardedRef:t}));AE.displayName="PanelGroup";TE.displayName="forwardRef(PanelGroup)";function Hi(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Gr(e,t,n){const r=Hi(e,t),i=r===e.length-1?[r-1,r]:[r,r+1],s=n[r];return{...t.constraints,panelSize:s,pivotIndices:i}}function MU({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){(0,g.useEffect)(()=>{if(e||n==null||r==null)return;const i=Nu(t,r);if(i==null)return;const s=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=i.getAttribute(De.groupId);ce(a,`No group element found for id "${a}"`);const l=ua(a,r),c=yE(a,t,r);ce(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 i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function EE({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onClick:o,onDragging:a,onFocus:l,onPointerDown:c,onPointerUp:u,style:h={},tabIndex:f=0,tagName:d="div",...m}){var v,y;const x=(0,g.useRef)(null),b=(0,g.useRef)({onClick:o,onDragging:a,onPointerDown:c,onPointerUp:u});(0,g.useEffect)(()=>{b.current.onClick=o,b.current.onDragging=a,b.current.onPointerDown=c,b.current.onPointerUp=u});const w=(0,g.useContext)(Pu);if(w===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:S,groupId:C,registerResizeHandle:A,startDragging:k,stopDragging:E,panelGroupElement:T}=w,R=vg(i),[P,M]=(0,g.useState)("inactive"),[N,L]=(0,g.useState)(!1),[I,_]=(0,g.useState)(null),j=(0,g.useRef)({state:P});fi(()=>{j.current.state=P}),(0,g.useEffect)(()=>{if(n)_(null);else{const se=A(R);_(()=>se)}},[n,R,A]);const $=(v=r?.coarse)!==null&&v!==void 0?v:15,B=(y=r?.fine)!==null&&y!==void 0?y:5;(0,g.useEffect)(()=>{if(n||I==null)return;const se=x.current;ce(se,"Element ref not attached");let ne=!1;return fU(R,se,S,{coarse:$,fine:B},(q,K,Y)=>{if(!K){M("inactive");return}switch(q){case"down":{M("drag"),ne=!1,ce(Y,'Expected event to be defined for "down" action'),k(R,Y);const{onDragging:H,onPointerDown:X}=b.current;H?.(!0),X?.();break}case"move":{const{state:H}=j.current;ne=!0,H!=="drag"&&M("hover"),ce(Y,'Expected event to be defined for "move" action'),I(Y);break}case"up":{M("hover"),E();const{onClick:H,onDragging:X,onPointerUp:oe}=b.current;X?.(!1),oe?.(),ne||H?.();break}}})},[$,S,n,B,A,R,I,k,E]),MU({disabled:n,handleId:R,resizeHandler:I,panelGroupElement:T});const D={touchAction:"none",userSelect:"none"};return(0,g.createElement)(d,{...m,children:e,className:t,id:i,onBlur:()=>{L(!1),s?.()},onFocus:()=>{L(!0),l?.()},ref:x,role:"separator",style:{...D,...h},tabIndex:f,[De.groupDirection]:S,[De.groupId]:C,[De.resizeHandle]:"",[De.resizeHandleActive]:P==="drag"?"pointer":N?"keyboard":void 0,[De.resizeHandleEnabled]:!n,[De.resizeHandleId]:R,[De.resizeHandleState]:P})}EE.displayName="PanelResizeHandle";function RU({className:e,...t}){return(0,p.jsx)(TE,{"data-slot":"resizable-panel-group",className:G("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}var Cp=g.forwardRef((e,t)=>(0,p.jsx)(yg,{ref:t,"data-slot":"resizable-panel",...e}));Cp.displayName=yg.displayName;function PU({withHandle:e,className:t,...n}){return(0,p.jsx)(EE,{"data-slot":"resizable-handle",className:G("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,p.jsx)("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:(0,p.jsx)(XD,{className:"size-2.5"})})})}function Fc(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 IU(e){try{const t=JSON.parse(e);if(Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t))return t}catch{}return null}function OU(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function DU(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 Js(e){if(e==null)return null;if(Array.isArray(e))return{kind:"json",value:e};if(typeof e=="string"){const t=OU(e)?IU(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 tK(e){if(e==null)return null;if(typeof e!="object"||Array.isArray(e))return Js(e);const t=e;if(DU(t))return null;if(typeof t.text=="string")return Js(t.text);const n=Fc(t.content);if(n.length>0)return Js(n.join(`
62
-
63
- `));const r=Fc((t.value&&typeof t.value=="object"?t.value:null)?.content);return r.length>0?Js(r.join(`
64
-
65
- `)):Js(t)}function rf(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=Fc(t.content);if(n.length>0)return n.join(`
66
-
67
- `);const r=Fc((t.value&&typeof t.value=="object"?t.value:null)?.content);return r.length>0?r.join(`
68
-
69
- `):null}function NU({className:e,children:t,...n}){return(0,p.jsxs)(kD,{"data-slot":"scroll-area",className:G("relative",e),...n,children:[(0,p.jsx)(CD,{"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,p.jsx)(LU,{}),(0,p.jsx)(AD,{})]})}function LU({className:e,orientation:t="vertical",...n}){return(0,p.jsx)(fD,{"data-slot":"scroll-area-scrollbar",orientation:t,className:G("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,p.jsx)(yD,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}function nK(e){return e==="schedule"?"Schedule owner":e==="api"||e==="sdk"?"Key owner":null}function Ap(e){return e.kind==="xaa"&&e.xaaSubject?.trim()||e.name}function rK(e){const t=[];for(const n of e){const r=Ap(n),i=t.find(s=>s.serverId===n.serverId);i?i.names.includes(r)||i.names.push(r):t.push({serverId:n.serverId,names:[r]})}return t}function ME(e,t){if(e.category!=="tool"||!t?.length)return;if(e.connectionId){const r=t.find(i=>i.connectionId===e.connectionId);return r?Ap(r):void 0}const n=e.serverId?t.filter(r=>r.serverId===e.serverId):[];return n.length===1?Ap(n[0]):void 0}function _U(e,t){const n=new Map;for(const r of e??[]){const i=r.toolCallId?ME(r,t):void 0;r.toolCallId&&i&&n.set(r.toolCallId,i)}return n}var jU=["opened","selected","shown","hidden","closed","call-started","call-completed","call-denied","call-unknown","call-suspended","call-continued","cancel-requested"],BU=["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"],FU=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Zs=(e,t=0)=>Number.isSafeInteger(e)&&e>=t;function xl(e,t){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).every(n=>t.includes(n))}var bl=e=>typeof e=="string"&&FU.test(e);function bg(e){if(!xl(e,["version","runtime","sequence","droppedEvents","activeInstanceId","instances","events"])||e.version!==1&&e.version!==2||!["chatgpt","codex"].includes(e.runtime)||!Zs(e.sequence)||!Zs(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(!xl(r,["instanceId","generation","visible"])||!bl(r.instanceId)||t.has(r.instanceId)||!Zs(r.generation,1)||typeof r.visible!="boolean")throw new Error("PLUGIN_RECORDING_INVALID");t.add(r.instanceId)}if(e.activeInstanceId!==void 0&&(!bl(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(!xl(r,["sequence","kind","instanceId","generation","operationId",...e.version===2?["feature","fidelity","outcome","display"]:[]])||!Zs(r.sequence,1)||r.sequence!==n+1||r.sequence>e.sequence||!jU.includes(r.kind)||!bl(r.instanceId)||!Zs(r.generation,1))throw new Error("PLUGIN_RECORDING_INVALID");const i=r.kind.startsWith("call-")||r.kind==="cancel-requested";if(i?!bl(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&&(!i||!BU.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 s=r.display;if(r.feature!=="app-display"||r.kind!=="call-completed"||!xl(s,["availableDisplayModes","displayMode","interactionCursor"])||!Array.isArray(s.availableDisplayModes)||s.availableDisplayModes.length>2||new Set(s.availableDisplayModes).size!==s.availableDisplayModes.length||!s.availableDisplayModes.every(o=>o==="inline"||o==="fullscreen")||(s.availableDisplayModes.length===0?s.displayMode!==void 0:!s.availableDisplayModes.includes(s.displayMode))||!["pointer","default"].includes(s.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 RE(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
70
- 
71
- `),r=t.startsWith("ÿØÿ");if(!n&&!r)throw new Error("PLUGIN_REPLAY_IMAGE_INVALID");return`data:image/${n?"png":"jpeg"};base64,${e}`}function VU(e,t){e!==void 0&&bg(e);const n=t?RE(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 $x({recording:e,screenshotBase64:t}){let n;try{n=VU(e,t)}catch{return(0,p.jsx)("p",{role:"status",className:"text-xs text-muted-foreground",children:"Unsupported workspace capture."})}return(0,p.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 zU({recording:e,screenshotUrl:t}){const n=mg(t??void 0),[r,i]=(0,g.useState)();let s=!1;try{e!==void 0&&bg(e),s=!0}catch{}return(0,g.useEffect)(()=>{if(!s||!n)return;const o=new AbortController;return(async()=>{try{if(!Ia(n))throw new Error("Owned screenshot link unavailable");const a=await Q4(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:v,value:y}=await l.read();if(v)break;if(u+=y.byteLength,u>1048576)throw new Error("Screenshot too large");c.push(y)}}finally{await l.cancel().catch(()=>{}),l.releaseLock()}const h=new Uint8Array(u);let f=0;for(const v of c)h.set(v,f),f+=v.length;let d="";for(let v=0;v<h.length;v+=8192)d+=String.fromCharCode(...h.subarray(v,v+8192));const m=btoa(d);RE(m),o.signal.aborted||i({url:n,base64:m})}catch{o.signal.aborted||i({url:n,failed:!0})}})(),()=>o.abort()},[n,s]),s?n&&r?.url!==n?(0,p.jsx)("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading captured workspace…"}):(0,p.jsxs)("div",{className:"space-y-2",children:[r?.failed?(0,p.jsx)("p",{role:"status",className:"text-xs text-muted-foreground",children:"Captured image unavailable."}):null,(0,p.jsx)($x,{recording:e,screenshotBase64:n?r?.base64:void 0})]}):(0,p.jsx)($x,{recording:e})}var $U=500,HU={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 PE(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 Ts(e){const t=PE(e.action),n=e.locatorLabel?.trim();return n?`Interact · ${t} ${n}`:`Interact · ${t}`}function Vc(e){return e.assertion?e.assertion.passed?"ok":"error":e.ok===!0?"ok":e.ok===!1?"error":"unknown"}function eo(e){return`${e.toolCallId}:${e.stepIndex}`}function WU(e){if(!e)return[];const t=[];return typeof e.durationMs=="number"&&e.durationMs>0&&t.push({key:"duration",label:UU(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 UU(e){const t=Math.round(e/1e3),n=t%60,r=Math.floor(t/60)%60,i=Math.floor(t/3600),s=String(r).padStart(i>0?2:1,"0");return i>0?`${i}:${s}:${String(n).padStart(2,"0")}`:`${s}:${String(n).padStart(2,"0")}`}function IE(e){return typeof e=="string"&&e.length>0?e:null}function iK(e){return(e.widgetRenderObservations?.length??0)>0||(e.browserInteractionSteps?.length??0)>0||IE(e.videoUrl)!==null}function qU(e){return e==="ok"?"OK":e==="error"?"Failed":"Unknown"}function OE({step:e,leading:t,className:n}){const r=Vc(e),i=e.widgetToolCalls??[],s=e.coordinateX!=null&&e.coordinateY!=null?`(${e.coordinateX}, ${e.coordinateY})`:null;return(0,p.jsxs)("div",{"data-testid":"browser-step-detail",className:G("flex flex-col gap-4",n),children:[(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[t,(0,p.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,p.jsx)("p",{className:"truncate text-sm font-medium text-foreground",children:Ts(e)}),(0,p.jsxs)("p",{className:"text-xs text-muted-foreground",children:["App interaction · ",e.elapsedMs,"ms",s?` · ${s}`:""]})]}),(0,p.jsx)("span",{className:G("inline-flex shrink-0 items-center rounded-full border px-2 py-0.5 text-[11px] font-medium",HU[r]),children:qU(r)})]}),e.assertion&&!e.assertion.passed&&e.assertion.reason?(0,p.jsx)("p",{className:"text-xs text-destructive",children:e.assertion.reason}):null,e.pluginWorkspace?(0,p.jsx)(zU,{recording:e.pluginWorkspace,screenshotUrl:e.screenshotUrl}):e.screenshotUrl?(0,p.jsx)(aE,{src:e.screenshotUrl,alt:Ts(e),className:"max-h-72 w-full rounded-md border border-border/50 object-contain"}):null,i.length>0?(0,p.jsxs)("div",{className:"space-y-1.5",children:[(0,p.jsx)("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Widget tool calls"}),i.map((o,a)=>(0,p.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border/50 px-2.5 py-1.5 text-xs",children:[(0,p.jsx)("span",{className:G("inline-block h-1.5 w-1.5 shrink-0 rounded-full",o.ok?"bg-success":"bg-destructive"),"aria-hidden":!0}),(0,p.jsx)("span",{className:"font-mono text-foreground",children:o.name}),o.error?(0,p.jsx)("span",{className:"truncate text-destructive",children:o.error}):null]},`${o.name}-${a}`))]}):null,e.followUps&&e.followUps.length>0?(0,p.jsxs)("div",{className:"space-y-1.5",children:[(0,p.jsx)("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Sent message to chat"}),e.followUps.map((o,a)=>(0,p.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border/50 px-2.5 py-1.5 text-xs",children:[(0,p.jsx)("span",{"aria-hidden":!0,children:"↳"}),(0,p.jsx)("span",{className:"truncate text-foreground",children:o})]},a))]}):null]})}function KU(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,"0")}`}function GU(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 sK({steps:e,videoUrl:t,videoMeta:n,isRunning:r=!1,className:i}){const s=(0,g.useRef)(null),[o,a]=(0,g.useState)(null),[l,c]=(0,g.useState)(null),u=(0,g.useRef)(null),[h,f]=(0,g.useState)(!1),[d,m]=(0,g.useState)(null),v=mg(IE(t)),y=(0,g.useMemo)(()=>WU(n),[n]),x=(0,g.useMemo)(()=>[...e].sort((T,R)=>(T.videoOffsetMs??Number.POSITIVE_INFINITY)-(R.videoOffsetMs??Number.POSITIVE_INFINITY)||T.promptIndex-R.promptIndex||T.ts-R.ts),[e]),b=o??l??null,w=(0,g.useMemo)(()=>x.find(T=>eo(T)===b)??null,[x,b]),S=v!=null&&!h,C=x.some(T=>T.screenshotUrl),A=(0,g.useCallback)(T=>{a(eo(T));const R=s.current;if(!R||!S||T.videoOffsetMs==null)return;const P=T.videoOffsetMs/1e3;u.current=P,R.currentTime=P},[S]),k=(0,g.useCallback)(()=>{u.current=null},[]),E=(0,g.useCallback)(()=>{const T=s.current;if(!T)return;const R=GU(x,T.currentTime*1e3);if(c(R?eo(R):null),u.current==null){if(o!=null){const P=x.find(M=>eo(M)===o);if(P?.videoOffsetMs!=null){const M=P.videoOffsetMs-T.currentTime*1e3;if(M>0&&M<$U)return}}a(null)}},[x,o]);return(0,g.useEffect)(()=>{f(!1)},[v]),(0,g.useEffect)(()=>{if(!d||d.url!==v)return;const T=setTimeout(()=>{m(null),f(!1)},d.delayMs);return()=>clearTimeout(T)},[d,v]),x.length===0&&!v?(0,p.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,p.jsxs)("section",{className:G("flex min-w-0 flex-col gap-3",i),"data-testid":"browser-step-filmstrip",children:[(0,p.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,p.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:["Replay",(0,p.jsx)("span",{className:"ml-1.5 font-normal normal-case text-muted-foreground/70",children:"screen recording of the app interactions in this run"})]}),v&&!h&&(y.length>0||n?.truncated)?(0,p.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:[y.map(T=>(0,p.jsx)("span",{title:T.title,children:T.label},T.key)),n?.truncated?(0,p.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,v&&!h?(0,p.jsx)("video",{ref:s,src:v,controls:!0,preload:"metadata",onTimeUpdate:E,onSeeked:k,onError:()=>{const T=sE(v);f(!0),m(T!==null&&T>0?{url:v,delayMs:T}:null)},onLoadedMetadata:()=>oE(v),className:"w-full rounded-md border border-border/60 bg-black","data-testid":"browser-replay-video"}):(0,p.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.":h?C?"Recording failed to load — screenshots preserved.":"Recording failed to load, and no screenshots were captured.":C?"Video unavailable — screenshots preserved.":"Partial capture — no recording, and no screenshots survived."})]}),x.length>0?(0,p.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,p.jsx)("div",{className:"flex min-w-0 gap-2 overflow-x-auto pb-1","data-testid":"browser-filmstrip-track",children:x.map(T=>{const R=eo(T),P=Vc(T),M=R===b;return(0,p.jsxs)("button",{type:"button",onClick:()=>A(T),"aria-pressed":M,title:Ts(T),"data-testid":"browser-filmstrip-frame","data-step-key":R,"data-active":M?"true":"false",className:G("flex w-28 shrink-0 flex-col gap-1 rounded-md border p-1 text-left transition-colors",M?"border-primary bg-primary/5":"border-border/50 hover:border-border"),children:[T.pluginWorkspace?(0,p.jsx)("span",{className:"text-xs text-muted-foreground",children:"Workspace capture"}):T.screenshotUrl?(0,p.jsx)(aE,{src:T.screenshotUrl,alt:Ts(T),loading:"lazy",className:"h-16 w-full rounded-sm border border-border/40 bg-background object-cover object-top"}):(0,p.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,p.jsx)("span",{className:"truncate text-[10px] font-medium text-foreground",children:PE(T.action)}),(0,p.jsx)("span",{className:G("truncate text-[10px]",P==="error"?"text-destructive":"text-muted-foreground"),children:T.videoOffsetMs!=null?KU(T.videoOffsetMs):`turn ${T.promptIndex+1}`})]},R)})}),w?(0,p.jsx)(OE,{step:w,className:"rounded-lg bg-muted/5 px-4 py-4"}):(0,p.jsx)("p",{className:"px-1 text-[11px] text-muted-foreground",children:"Select a frame to see the interaction that produced it."})]}):null]})}function QU(e){return typeof e=="string"&&e.length>0&&e.length<=200?e:void 0}var YU={[-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 XU(e){const t=YU[e];return t?`${e} · ${t}`:String(e)}var JU=Mr({id:ve(),parentId:ve().optional(),name:ve(),category:xo(["step","llm","tool","error","connection","discovery"]),startMs:nt(),endMs:nt(),promptIndex:nt().optional(),stepIndex:nt().optional(),authoredStepId:ve().optional(),status:xo(["ok","error"]).optional(),toolCallId:ve().optional(),toolName:ve().optional(),toolOrigin:xo(["mcp","native","builtin","unknown"]).optional(),serverId:ve().optional(),connectionId:ve().optional(),modelId:ve().optional(),inputTokens:nt().optional(),outputTokens:nt().optional(),totalTokens:nt().optional(),cost:yo().transform(kS).optional(),callId:yo().transform(QU).optional(),messageStartIndex:nt().optional(),messageEndIndex:nt().optional(),finishReason:ve().optional(),provider:ve().optional(),responseId:ve().optional(),responseTimestamp:ve().optional(),ttfcMs:nt().optional(),mcpErrorCode:nt().optional(),outputSource:lf([br("narration"),br("evidence"),br("reconstructed")]).optional(),wireCorroborated:Ge().optional(),evidenceRequestId:ve().optional(),evidenceStatus:lf([br("complete"),br("incomplete")]).optional()}),Qr=Mr({toolName:ve(),arguments:Sl(ve(),Jx())}),ZU=Mr({promptIndex:nt(),prompt:ve(),expectedToolCalls:Qt(Qr),actualToolCalls:Qt(Qr),expectedOutput:ve().optional(),passed:Ge(),missing:Qt(Qr),unexpected:Qt(Qr),argumentMismatches:Qt(Mr({expected:Qr,actual:Qr,mismatchedArguments:Qt(ve())})),retries:Qt(Qr.extend({actualIndex:nt().int().nonnegative(),retriedByIndex:nt().int().nonnegative()})).optional()}),eq=Mr({toolCallId:ve(),toolName:ve(),protocol:lf([br("mcp-apps"),br("openai-apps")]),serverId:ve(),resourceUri:ve().optional(),toolMetadata:Sl(ve(),yo()),widgetCsp:Sl(ve(),yo()).nullable().optional(),widgetPermissions:Sl(ve(),yo()).nullable().optional(),widgetPermissive:Ge().optional(),prefersBorder:Ge().optional(),widgetHtmlBlobId:ve().optional(),widgetHtmlUrl:ve().nullable().optional(),injectedOpenAiCompat:Ge().optional(),injectedOpenAiCompatCapabilities:Mr({callTool:Ge().optional(),sendFollowUpMessage:Ge().optional(),setWidgetState:Ge().optional(),requestDisplayMode:xo(["all","fullscreen-only","none"]).optional(),notifyIntrinsicHeight:Ge().optional(),openExternal:Ge().optional(),setOpenInAppUrl:Ge().optional(),requestModal:Ge().optional(),uploadFile:Ge().optional(),selectFiles:Ge().optional(),getFileDownloadUrl:Ge().optional(),requestCheckout:Ge().optional(),requestClose:Ge().optional()}).optional()}),tq=Mr({source:xo(["hosted","widget"]),fps:nt().optional(),durationMs:nt().optional(),distinctFrames:nt().optional(),truncated:Ge().optional()}),oK=Mr({traceVersion:br(1),messages:Qt(Jx()),widgetSnapshots:Qt(eq).optional(),spans:Qt(JU).optional(),prompts:Qt(ZU).optional(),videoBlobId:ve().optional(),videoMeta:tq.optional()});function nq(e,t){const n=[],r=new Map;return t.forEach((i,s)=>{if(i.role==="user"&&n.push(s),!!Array.isArray(i.content))for(const o of i.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(s),r.set(o.toolCallId,a)}}),{userIndices:n,spans:e.map(i=>{const s=n[i.promptIndex??0],o=n[(i.promptIndex??0)+1]??t.length,a=s!==void 0&&i.category==="tool"&&i.toolCallId?r.get(i.toolCallId)?.filter(l=>l>=s&&l<o):void 0;return{...i,messageStartIndex:a?.[0],messageEndIndex:a?.at(-1)}})}}function rq({recording:e}){let t;try{t=bg(e)}catch{return null}return(0,p.jsxs)("section",{"aria-label":"Workspace events",className:"mt-4 space-y-2 text-xs",children:[(0,p.jsx)("p",{className:"font-medium",children:"Workspace events"}),t.droppedEvents>0&&(0,p.jsxs)("p",{className:"text-muted-foreground",children:[t.droppedEvents," earlier events omitted."]}),t.events.map(n=>(0,p.jsxs)("div",{className:"flex gap-2 border-b border-border py-2",children:[(0,p.jsx)("span",{className:"tabular-nums text-muted-foreground",children:n.sequence}),(0,p.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 wg=(0,g.createContext)(void 0);function aK({accounts:e,children:t}){const n=X4();return(0,p.jsx)(wg.Provider,{value:n?e:void 0,children:t})}function DE(){const e=(0,g.useContext)(wg);return(0,g.useCallback)(t=>ME(t,e),[e])}function lK({spans:e,children:t}){const n=(0,g.useContext)(wg),r=(0,g.useMemo)(()=>_U(e,n),[e,n]);return(0,p.jsx)(Z1.Provider,{value:r,children:t})}var iq=1024;function sq(e){const[t,n]=(0,g.useState)(null),[r,i]=(0,g.useState)(!1);return(0,g.useLayoutEffect)(()=>{if(e!=="auto"||!t)return;const s=()=>i(t.getBoundingClientRect().width>=iq);if(s(),typeof ResizeObserver>"u")return;const o=new ResizeObserver(s);return o.observe(t),()=>o.disconnect()},[e,t]),{containerRef:n,direction:e==="auto"&&r?"horizontal":"vertical"}}var oq=["all","connection","discovery","llm","tool","error"];function sf(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 aq({filter:e,onFilterChange:t,isFullyExpanded:n,expandDisabled:r,onToggleExpandAll:i,zoomControls:s,showBottomBorder:o=!0}){return(0,p.jsxs)("div",{className:G("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,p.jsxs)(Vm,{children:[(0,p.jsx)(zm,{asChild:!0,children:(0,p.jsxs)(Ot,{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: ${sf(e)}`,children:[(0,p.jsx)(ZD,{className:"size-3.5 shrink-0 opacity-80","aria-hidden":!0}),sf(e)]})}),(0,p.jsx)($m,{align:"start",className:"min-w-[8rem]",children:(0,p.jsx)(GV,{value:e,onValueChange:a=>t(a),children:oq.map(a=>(0,p.jsx)(QV,{value:a,className:"text-xs",children:sf(a)},a))})})]}),(0,p.jsx)(Ot,{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:i,children:n?(0,p.jsx)(lN,{className:"size-3.5",strokeWidth:2,"aria-hidden":!0}):(0,p.jsx)(QD,{className:"size-3.5",strokeWidth:2,"aria-hidden":!0})}),s?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"bg-border hidden h-3 w-px shrink-0 md:block","aria-hidden":!0}),(0,p.jsx)("div",{className:"flex shrink-0 items-center gap-0.5",children:s})]}):null]})}function NE(e,t=[]){const n=e.filter(r=>r.category==="llm");if(!(!n.some(r=>r.cost)&&t.length===0))return CN([...n.map(r=>r.cost),...t])}function LE(e,t){if(!e||e.kind==="interaction")return;if(e.kind==="span"){const{span:r}=e;if(r.category!=="llm")return;const i=r.cost??t?.find(({id:s})=>s===r.id)?.cost;return i?{kind:"call",cost:i}:void 0}const n=NE((t??[]).filter(r=>(r.promptIndex??0)===e.promptIndex));return n?{kind:"rollup",rollup:n}:void 0}function lq(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 Sg={provider_reported:"Provider-reported",list_price:"Estimated at list price",customer_rate:"Estimated at your rates",runner_reported:"Runner-reported"},_E={partial:"Partial",unavailable:"Cost unavailable"},kg=e=>e==="list_price"||e==="customer_rate",cq={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."},uq={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"},hq={input:"Input",cacheRead:"Cache read",cacheWrite:"Cache write",output:"Output",webSearch:"Web search"};function fq(e){if(e.length<=1)return e[0]&&Sg[e[0]];const t=e.filter(kg).length;return t===e.length?"Estimated":t>0?"Reported and estimated":"Reported"}function dq(e){const t=(e.missing??[]).map(i=>uq[i]),n=e.completeness==="unavailable"?e.reason?cq[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(hq).flatMap(([i,s])=>{const o=e.parts?.[i];return typeof o=="number"?[{label:s,amountUsd:o}]:[]});return{amountUsd:e.amountUsd,estimated:e.source?kg(e.source):!1,sourceLabel:e.source?Sg[e.source]:void 0,completeness:e.completeness,note:n,parts:r}}function pq(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(kg),sourceLabel:fq(e.sources),completeness:e.completeness,coverage:`${t} of ${e.totalCalls} ${n} priced${r}`,parts:[]}}function jE(e){return e.kind==="call"?dq(e.cost):pq(e.rollup)}var mq="trace-cost";function Oa(){return $1(mq)===!0}var BE="evalIterationModelCalls:list",gq=pu(BE),wl=e=>Number.isInteger(e)&&e>=0;function vq(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)&&wl(t.totalCalls)&&wl(t.completeCalls)&&wl(t.partialCalls)&&wl(t.unavailableCalls)&&Array.isArray(r)&&r.every(i=>typeof i=="string"&&Object.hasOwn(Sg,i))?e:void 0}function cK(e,t){const n=vq(e.usage?.costRollup);return{iterationId:e._id,...n?{rollup:n}:{},harness:t?t.startsWith("harness:"):!!eM(e.execution)?.harness}}function yq(e,t){const n=new Set(e.filter(o=>o.category==="llm").map(o=>o.id)),r=new Map,i=[],s=new Set;for(const o of t??[]){if(s.has(o.generationId))continue;s.add(o.generationId);const a=kS(o.cost),l=o.matchedSpanId;l&&n.has(l)&&!r.has(l)?r.set(l,a):i.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:i}}function xq(e){return tM(e,BE)}var FE=[];function Lu(e){const t=Oa();return(0,g.useMemo)(()=>t&&e?jE(e):void 0,[t,e])}function ha({amountUsd:e,estimated:t,slot:n=!1}){return(0,p.jsxs)("span",{className:"whitespace-nowrap tabular-nums",children:[t?(0,p.jsx)("span",{className:"inline-block w-[1ch] text-center",children:"≈"}):n?(0,p.jsx)("span",{"aria-hidden":!0,className:"inline-block w-[1ch]"}):null,lq(e)]})}function VE({view:e}){return(0,p.jsxs)(p.Fragment,{children:[e.sourceLabel?(0,p.jsx)(kc,{variant:"outline",className:"px-1.5 py-0 text-[10px] text-muted-foreground",children:e.sourceLabel}):null,e.completeness!=="complete"?(0,p.jsx)(kc,{variant:"outline",className:G("px-1.5 py-0 text-[10px]",e.completeness==="partial"?"border-warning/50 bg-warning/10 text-foreground":"text-muted-foreground"),children:_E[e.completeness]}):null,e.coverage?(0,p.jsx)("span",{children:e.coverage}):null,e.note?(0,p.jsx)("span",{children:e.note}):null]})}function bq({cost:e}){const t=Lu(e);return t?.amountUsd===void 0?null:(0,p.jsxs)("span",{"data-testid":"trace-cost-inline",children:[" · ",(0,p.jsx)("span",{className:"font-medium text-foreground",children:(0,p.jsx)(ha,{amountUsd:t.amountUsd,estimated:t.estimated})})]})}function wq({cost:e}){const t=Lu(e);return t?(0,p.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,p.jsx)("span",{className:"text-muted-foreground/70",children:"Cost"}),(0,p.jsx)(VE,{view:t})]}):null}function to({label:e,children:t}){return(0,p.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,p.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:e}),(0,p.jsx)("span",{className:"min-w-0 text-right font-medium text-popover-foreground",children:t})]})}function Sq({cost:e}){const t=Lu(e);return t?(0,p.jsxs)("div",{"data-testid":"trace-row-hover-cost",className:"space-y-1.5",children:[(0,p.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-popover-foreground/65",children:"Cost"}),(0,p.jsxs)("div",{className:"space-y-1 text-xs",children:[(0,p.jsx)(to,{label:e?.kind==="rollup"?"Total":"Amount",children:t.amountUsd===void 0?"Unavailable":(0,p.jsx)(ha,{amountUsd:t.amountUsd,estimated:t.estimated,slot:!0})}),t.parts.map(n=>(0,p.jsx)(to,{label:n.label,children:(0,p.jsx)(ha,{amountUsd:n.amountUsd,estimated:t.estimated,slot:!0})},n.label)),t.sourceLabel?(0,p.jsx)(to,{label:"Source",children:t.sourceLabel}):null,t.completeness==="partial"?(0,p.jsx)(to,{label:"Status",children:_E.partial}):null,t.coverage?(0,p.jsx)(to,{label:"Coverage",children:t.coverage}):null,t.note?(0,p.jsx)("p",{className:"text-popover-foreground/70",children:t.note}):null]})]}):null}function kq(e,t){const n=Oa()&&t?.harness?t.iterationId:void 0,[r,i]=(0,g.useState)(),s=r?.iterationId===n?r?.calls:void 0,o=(0,g.useMemo)(()=>s?yq(e??[],s):void 0,[e,s]),a=(0,g.useCallback)(()=>i(void 0),[]),l=n?(0,p.jsx)(Sc,{name:"trace-cost-model-calls",isExpectedError:xq,onError:a,fallback:null,children:(0,p.jsx)(Cq,{iterationId:n,onLoad:i})},n):null;return{spans:o?.spans??e,unmatched:o?.unmatched??FE,loader:l}}function Cq({iterationId:e,onLoad:t}){const n=V1(gq,{iterationId:e});return(0,g.useEffect)(()=>{n&&t({iterationId:e,calls:n})},[n,e,t]),null}function Aq({spans:e,iteration:t,unmatched:n=FE}){const r=Oa(),i=Lu((0,g.useMemo)(()=>{if(!r)return;const s=t?.rollup??NE(e??[],n.map(o=>o.cost));return s&&{kind:"rollup",rollup:s}},[r,e,t?.rollup,n]));return i?(0,p.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,p.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,p.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wide",children:"Trace cost"}),i.amountUsd!==void 0?(0,p.jsx)("span",{className:"text-sm font-semibold text-foreground",children:(0,p.jsx)(ha,{amountUsd:i.amountUsd,estimated:i.estimated})}):null,(0,p.jsx)(VE,{view:i})]}),n.length>0?(0,p.jsx)(Tq,{calls:n}):null]}):null}function Tq({calls:e}){return(0,p.jsxs)("div",{"data-testid":"trace-cost-unmatched-calls",className:"space-y-1",children:[(0,p.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wide",children:"Model calls not matched to a step"}),(0,p.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&&jE({kind:"call",cost:t.cost});return(0,p.jsxs)("li",{className:"flex flex-wrap items-baseline gap-x-2",children:[(0,p.jsx)("span",{className:"min-w-0 truncate font-mono text-foreground",children:t.modelId}),(0,p.jsx)("span",{className:"font-medium text-foreground",children:n?.amountUsd!==void 0?(0,p.jsx)(ha,{amountUsd:n.amountUsd,estimated:n.estimated}):"Cost unavailable"}),n?.sourceLabel?(0,p.jsx)("span",{children:n.sourceLabel}):null]},t.generationId)})})]})}var Hx=[0,25,50,75,100],Eq=54,Mq=120;function Rq(e){if(!Number.isFinite(e))return[0,100];if(e<=0)return[0,100];const t=Math.max(2,Math.floor(e/Eq));return t>=Hx.length?[...Hx]:t<=2?[0,100]:t===3?[0,50,100]:[0,25,75,100]}function Pq(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 Wx(e){return e<=0?ic(0):`${ic(0)}–${ic(e)}`}function Iq(e){const t=e.filter(l=>l.category==="llm");let n=0,r=0,i=0,s=0,o=0,a=0;for(const l of t)typeof l.inputTokens=="number"&&(n+=l.inputTokens,r++),typeof l.outputTokens=="number"&&(i+=l.outputTokens,s++),typeof l.totalTokens=="number"&&(o+=l.totalTokens,a++);return{...r?{inputTokens:n}:{},...s?{outputTokens:i}:{},...a?{totalTokens:o}:{}}}function _u(e,t){return t}function Ux(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 _u(e,9)}}function Oq(e,t){if(e.startMs!==t.startMs)return e.startMs-t.startMs;const n=Ux(e.category)-Ux(t.category);return n!==0?n:e.endMs!==t.endMs?e.endMs-t.endMs:e.name.localeCompare(t.name)}function Dq(e,t){return typeof e!="number"||t<50?null:e/(t/1e3)}function No(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?1:2)}s`:`${Math.round(e)}ms`}function ic(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`}function Jn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function fa(e){const t=e.toolName??e.name;return typeof t=="string"&&t.trim()?t:void 0}function Da(e){return Array.isArray(e.content)?e.content.filter(t=>Jn(t)&&typeof t.type=="string"):typeof e.content=="string"?[{type:"text",text:e.content}]:[]}function zE(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(Jn(e)){const t=Object.keys(e);return t.length>0?`{ ${t.slice(0,4).join(", ")}${t.length>4?", ...":""} }`:"{}"}return String(e)}function Nq(e){const t=Da(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: ${fa(r)??"Tool"}`:r.type==="tool-result"?`Tool result: ${fa(r)??"Tool"}`:typeof r.type=="string"?r.type:"content").join(" | ");return n.length>220?`${n.slice(0,217)}...`:n}function Lq(e){return!Jn(e)||!("type"in e)||!("value"in e)?e:e.value}function _q(e){return e.result!==void 0?e.result:Lq(e.output)}function jq(e){const t=_q(e);if(typeof e.error=="string"&&e.error.trim())return e.error.trim();if(Jn(e.error)&&typeof e.error.message=="string")return e.error.message;if(Jn(e.output)&&e.output.type==="error-text")return typeof e.output.value=="string"?e.output.value:"Tool error";if(Jn(e.result)&&e.result.isError===!0||Jn(e.output)&&Jn(e.output.value)&&e.output.value.isError===!0||e.isError===!0)return rf(t)??"Tool error"}function ju(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 i,s,o;for(const a of e)for(const l of Da(a)){const c=typeof t=="string"&&l.toolCallId===t,u=!t&&typeof n=="string"&&fa(l)===n;if(!(!c&&!u)&&(l.type==="tool-call"&&(i=l.input??l.parameters??l.args),l.type==="tool-result")){s=l.result??(Jn(l.output)&&"value"in l.output?l.output.value:l.output);const h=jq(l);h&&(o=h)}}return{input:i,output:s,errorText:o}}function Zi(e,t,n=!1){return e.category==="error"||e.status==="error"?!0:e.category==="tool"?!!ju(t,e.toolCallId,e.toolName??e.name,n?e:void 0).errorText:!1}function _s(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 Bq(e){return _s(e.messageStartIndex,e.messageEndIndex)}function Fq(e){return _s(e.span.messageStartIndex,e.span.messageEndIndex)}function $E(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 HE(e,t,n){if(t)for(let r=t.startIndex;r<=t.endIndex;r+=1){const i=e[r];if(i&&n(i))return r}}function Cg(e,t,n){if(!e.length)return;const r=_s(t,n);if(!r){const s=e.findIndex(o=>o.role==="user");return s>=0?s:void 0}const i=HE(e,r,s=>s.role==="user");if(typeof i=="number")return i;if(!(r.startIndex>=e.length)&&r.startIndex>0)for(let s=r.startIndex-1;s>=0;s-=1){const o=e[s];if(o){if(o.role==="user")return s;if(o.role==="assistant")break}}}function Vq(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 _u(n,"trace-waterfall-bar-step")}}function zq(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 _u(e,"text-muted-foreground")}}function $q(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 _u(n,"border-l-muted-foreground")}}function Hq(e){const t=new Map;for(const n of e){const r=typeof n.promptIndex=="number"?n.promptIndex:0,i=t.get(r);i?i.push(n):t.set(r,[n])}return[...t.entries()].sort(([n],[r])=>n-r).map(([n,r])=>{const i=new Map;r.forEach(c=>{i.set(c.id,{span:c,children:[]})});const s=[];r.forEach(c=>{const u=i.get(c.id),h=typeof c.parentId=="string"?i.get(c.parentId):void 0;if(h){h.children.push(u);return}s.push(u)});const o=c=>{c.sort((u,h)=>Oq(u.span,h.span)),c.forEach(u=>o(u.children))};o(s);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:s,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 qx(e){const t=new Set;function n(r){for(const i of r)i.span.category==="step"&&i.children.length>0&&t.add(i.span.id),n(i.children)}for(const r of e)n(r.roots);return t}function of(e){return{role:e.role,content:e.content}}function WE(e,t,n){const r=_s(t,n);if(!r)return[];const i=e.slice(r.startIndex,r.endIndex+1);if(i.length===0)return[];let s=-1;for(let a=0;a<i.length;a++)if(i[a].role==="assistant"){s=a;break}if(s<0)return e.slice(0,r.endIndex+1);const o=r.startIndex+s;return o===0?[]:e.slice(0,o)}function Wq(e,t,n){const r=_s(t,n);if(!r)return{input:null,output:null};const i=e.slice(r.startIndex,r.endIndex+1);if(i.length===0)return{input:[],output:null};let s=-1;for(let l=i.length-1;l>=0;l-=1)if(i[l].role==="assistant"){s=l;break}if(s<0)return{input:i.map(of),output:null};const o=WE(e,t,n),a=i[s];return{input:o.length>0?o.map(of):null,output:of(a)}}var Uq=96;function Zt(e,t=Uq){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function da(e){return typeof e.content=="string"?e.content.trim():Da(e).map(t=>t.type==="text"&&typeof t.text=="string"?t.text.trim():"").filter(Boolean).join(" ")}function qq(e){const t=Da(e),n=[];for(const r of t)r.type==="tool-call"&&n.push(fa(r)??"tool");return n}function Kq(e,t){if(!e.length)return;const n=WE(e,t.messageStartIndex,t.messageEndIndex);if(n.length!==0){for(let r=n.length-1;r>=0;r--){const i=n[r];if(i.role==="user"){const s=da(i);if(s)return Zt(s)}}for(const r of n)if(r.role==="system"){const i=da(r);if(i)return Zt(i)}for(let r=n.length-1;r>=0;r--){const i=n[r];if(i.role==="tool"){const s=Nq(i);if(s&&s!=="No content")return Zt(s)}}}}function Gq(e,t){if(!e.length)return;const n=_s(t.messageStartIndex,t.messageEndIndex);if(!n)return;const r=e.slice(n.startIndex,n.endIndex+1);for(let i=r.length-1;i>=0;i--){const s=r[i];if(s.role!=="assistant")continue;const o=da(s);if(o)return{kind:"text",preview:Zt(o)};const a=qq(s);if(a.length>0)return{kind:"tools",preview:Zt(`Calling ${a.join(", ")}`)}}}function Qq(e,t,n){const r=Cg(e,t,n);if(typeof r!="number")return;const i=da(e[r]);return i?Zt(i):void 0}function Yq(e,t,n){const r=Cg(e,t,n);if(typeof r=="number")return da(e[r])||void 0}function Kx(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&&fa(e)===n)}function Xq(e,t,n){if(n)for(let r=n.startIndex;r<=n.endIndex;r+=1){const i=e[r];if(!i)continue;const s=Da(i);if(s.some(o=>o.type==="tool-call"&&Kx(o,t))||s.some(o=>o.type==="tool-result"&&Kx(o,t)))return r}}function Jq(e,t){const n=Cg(t,e.messageStartIndex,e.messageEndIndex);if(typeof n=="number")return{focusSourceIndex:n,highlightSourceIndices:[n]};const r=$E(Bq(e));if(r.length!==0)return{focusSourceIndex:r[0],highlightSourceIndices:r}}function Zq(e,t){const n=Fq(e),r=$E(n);if(r.length===0)return;const i=HE(t,n,s=>s.role==="assistant");return{focusSourceIndex:(e.span.category==="tool"?Xq(t,e.span,n):void 0)??i??r[0],highlightSourceIndices:r}}function e6(e,t,n=!1){const r=ju(e,t.toolCallId,t.toolName??t.name,n?t:void 0);if(r.input==null)return;const i=zE(r.input);if(!(!i||i==="None"))return Zt(i)}function Es({category:e,size:t="sm"}){const n=G(t==="lg"?"h-5 w-5 shrink-0":"h-3.5 w-3.5 shrink-0",zq(e));switch(e){case"prompt":return(0,p.jsx)(fN,{className:n,"aria-hidden":!0});case"llm":return(0,p.jsx)(KD,{className:n,"aria-hidden":!0});case"tool":return(0,p.jsx)(dN,{className:n,"aria-hidden":!0});case"interaction":return(0,p.jsx)(iN,{className:n,"aria-hidden":!0});case"error":return(0,p.jsx)(GD,{className:n,"aria-hidden":!0});case"connection":case"discovery":case"step":return(0,p.jsx)(nv,{className:n,"aria-hidden":!0});default:return(0,p.jsx)(nv,{className:n,"aria-hidden":!0})}}function t6(e,t){const n=t.promptIndex,r=t.stepIndex;if(typeof n!="number"||typeof r!="number")return{};const i=e.find(s=>s.category==="llm"&&s.promptIndex===n&&s.stepIndex===r);return i?{...typeof i.inputTokens=="number"?{inputTokens:i.inputTokens}:{},...typeof i.outputTokens=="number"?{outputTokens:i.outputTokens}:{},...typeof i.totalTokens=="number"?{totalTokens:i.totalTokens}:{}}:{}}function n6(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=t6(t,e.span);return typeof r.inputTokens=="number"||typeof r.outputTokens=="number"||typeof r.totalTokens=="number"?r:n}function af(e){return typeof e=="number"?e.toLocaleString():"—"}function Gx(e){return typeof e=="number"&&Number.isFinite(e)?new Date(e).toLocaleString():"—"}function r6({traceStartedAtMs:e,traceEndedAtMs:t,traceDurationMs:n}){return typeof e=="number"&&Number.isFinite(e)?e:typeof t=="number"&&Number.isFinite(t)?t-n:null}function Tp(e,t,n=!1,r){const{span:i,promptIndex:s}=e,o=i.modelId?.trim()?Zt(i.modelId.trim(),56):void 0,a=i.name?.trim()??"";if(i.category==="step"){const l=typeof i.stepIndex=="number"?i.stepIndex+1:void 0,c=typeof l=="number"?`Step ${l}`:a||"Step",u=typeof l=="number"&&(a===`Step ${l}`||a.toLowerCase()===`step ${l}`),h=a&&!u?Zt(a,64):c,f=Kq(t,i);return f?{title:h,subtitle:f}:o?{title:h,subtitle:o}:{title:h,subtitle:`Prompt ${s+1}`}}if(i.category==="llm"){const l=Gq(t,i),c=!a||/^assistant$/i.test(a)||/^llm$/i.test(a)||/^model$/i.test(a)||a==="Model response"||/·\s*response$/i.test(a)?"Agent":Zt(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(i.category==="tool"){const l=`Tool · ${(i.toolName??i.name).trim()||"tool"}${r?` · ${r}`:""}`,c=e6(t,i,n),u=!c||c==="{}"||c==="None";if(c&&!u)return{title:l,subtitle:c};if(u){const h=ju(t,i.toolCallId,i.toolName??i.name,n?i:void 0);if(h.output!=null){const f=zE(h.output);if(f&&f!=="None"&&f!=="{}")return{title:l,subtitle:Zt(f)}}}return typeof i.stepIndex=="number"?{title:l,subtitle:o?`${o} · step ${i.stepIndex+1}`:`step ${i.stepIndex+1}`}:{title:l,subtitle:o}}return{title:i.name,subtitle:typeof i.stepIndex=="number"?o?`${o} · step ${i.stepIndex+1}`:`step ${i.stepIndex+1}`:o}}function Ep(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 i6({format:e,onFormatChange:t}){return(0,p.jsx)("div",{className:"flex flex-wrap gap-1",children:["plain","markdown"].map(n=>(0,p.jsx)(Ot,{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 Qx({value:e}){const[t,n]=(0,g.useState)("plain");return(0,g.useEffect)(()=>{typeof e=="string"&&n("plain")},[e]),e==null?(0,p.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,p.jsxs)("div",{className:"space-y-2",children:[(0,p.jsx)(i6,{format:t,onFormatChange:n}),t==="markdown"?(0,p.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,p.jsx)(JT,{content:e})}):(0,p.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,p.jsx)(A4,{value:e,containerClassName:"max-h-56 rounded-md border border-border/60 bg-background"})}function s6({row:e}){return(0,p.jsxs)("div",{"data-testid":"trace-detail-pane",className:"min-h-[280px] rounded-lg bg-muted/5 px-5 py-5",children:[(0,p.jsx)(OE,{step:e.step,leading:(0,p.jsx)(Es,{category:"interaction",size:"lg"})}),e.step.pluginWorkspace&&(0,p.jsx)(rq,{recording:e.step.pluginWorkspace})]})}function Yx(e){return e.split(/[-_\s]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function o6(e){return e.engine==="harness"?e.harness?Yx(e.harness):"Harness":e.engine==="emulated"?"Emulated":e.harness?Yx(e.harness):"Unknown"}function a6({row:e,recordedSpans:t,projectedMessages:n,transcriptMessages:r,onRevealInTranscript:i,turnRuntimeByPromptIndex:s}){const o=DE(),a=Oa();if(!e)return(0,p.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,p.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-full border border-border/50 bg-background shadow-sm",children:(0,p.jsx)(JD,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),(0,p.jsxs)("div",{className:"space-y-1",children:[(0,p.jsx)("p",{className:"text-sm font-medium text-foreground",children:"No span selected"}),(0,p.jsx)("p",{className:"text-xs text-muted-foreground",children:"Click a row or use arrow keys"})]})]});if(e.kind==="interaction")return(0,p.jsx)(s6,{row:e});const l=e.kind==="prompt"?Jq(e,r):Zq(e,r),c=e.kind==="span"?ju(r,e.span.toolCallId,e.span.toolName??e.span.name,n?e.span:void 0):{},{durationMs:u}=Ep(e),h=e.kind==="span"?Tp(e,r,n,o(e.span)):null,f=e.kind==="prompt"?e.label:h.title,d=e.kind==="prompt"?e.hasAnyFailure?"error":"ok":Zi(e.span,r,n)?"error":"ok",m=e.kind==="prompt"?"prompt":e.span.category==="tool"&&Zi(e.span,r,n)?"error":e.span.category,v=s?.get(e.promptIndex),y=e.kind==="span"&&(e.span.category==="llm"||e.span.category==="step")?Wq(r,e.span.messageStartIndex,e.span.messageEndIndex):{input:null,output:null},x=e.kind==="span"&&e.span.category==="tool"&&(!!e.span.toolCallId||!!(e.span.toolName?.trim()||e.span.name?.trim())),b=e.kind==="prompt"?null:x?c.input:e.kind==="span"&&(e.span.category==="llm"||e.span.category==="step")?y.input:(e.kind==="span"&&e.span.category==="error",null),w=e.kind==="prompt"?null:x?c.output:e.kind==="span"&&(e.span.category==="llm"||e.span.category==="step")?y.output:e.kind==="span"&&e.span.category==="error"?e.span.name:null,S=e.kind==="prompt"?Yq(r,e.messageStartIndex,e.messageEndIndex):void 0,C=e.kind==="span"&&(typeof e.span.inputTokens=="number"||typeof e.span.outputTokens=="number"||typeof e.span.totalTokens=="number"),A=e.kind==="prompt"&&(typeof e.aggregatedInputTokens=="number"||typeof e.aggregatedOutputTokens=="number"||typeof e.aggregatedTotalTokens=="number"),k=e.kind==="span"&&c.errorText?c.errorText:null,E=!!(l&&i),T=a?LE(e,t):void 0;return(0,p.jsxs)("div",{"data-testid":"trace-detail-pane",className:"space-y-4 bg-background p-4",children:[(0,p.jsxs)("div",{className:G("border-b border-border/40 pb-3",E?"flex flex-col gap-3 min-[400px]:flex-row min-[400px]:items-start":""),children:[(0,p.jsxs)("div",{className:G("flex gap-3",E?"min-w-0 min-[400px]:flex-1":""),children:[(0,p.jsx)("div",{className:"shrink-0 pt-0.5",children:e.kind==="prompt"?(0,p.jsx)(Es,{category:"prompt",size:"lg"}):(0,p.jsx)(Es,{category:m,size:"lg"})}),(0,p.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,p.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[(0,p.jsx)("h3",{className:"text-sm font-bold leading-tight text-foreground",children:f}),v?(0,p.jsxs)(kc,{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:v.engine==="harness"?"This turn ran through the harness adapter.":v.engine==="emulated"?"This turn ran through MCPJam's emulated chat engine.":v.harness?"This turn ran through the harness adapter.":"Runtime engine was not recorded for this turn.",children:["Engine: ",o6(v)]}):null,d==="error"?(0,p.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-destructive",title:"Error","aria-label":"Error"}):null]}),(0,p.jsxs)("div",{className:"text-xs tabular-nums text-muted-foreground",children:[(0,p.jsx)("span",{className:"font-medium text-foreground",children:No(u)}),e.kind==="prompt"&&A?(0,p.jsxs)(p.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"&&C?(0,p.jsxs)(p.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,p.jsx)(bq,{cost:T})]}),(0,p.jsx)(wq,{cost:T}),e.kind==="span"?(()=>{const R=e.span,P=R.category==="llm"?Dq(R.outputTokens,u):null,M=[];return R.provider&&M.push({label:"Provider",value:R.provider}),R.finishReason&&M.push({label:"Finish",value:R.finishReason}),typeof R.ttfcMs=="number"&&M.push({label:"TTFC",value:No(R.ttfcMs)}),P!==null&&M.push({label:"Throughput",value:`${P.toFixed(1)} tok/s`}),R.responseId&&M.push({label:"Response ID",value:R.responseId}),M.length===0?null:(0,p.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:M.map(N=>(0,p.jsxs)("span",{className:"truncate",children:[(0,p.jsxs)("span",{className:"text-muted-foreground/70",children:[N.label,":"," "]}),(0,p.jsx)("span",{className:"font-medium text-foreground",children:N.value})]},N.label))})})():null]})]}),E?(0,p.jsx)("div",{className:"flex min-w-0 min-[400px]:flex-1 min-[400px]:justify-end min-[400px]:pt-0.5",children:(0,p.jsxs)(Ot,{type:"button",size:"sm",variant:"outline",className:"w-full shrink-0 justify-center whitespace-nowrap min-[400px]:w-auto",onClick:()=>{l&&i&&i(l)},children:[(0,p.jsx)(tN,{className:"h-3.5 w-3.5"}),"Reveal in Chat"]})}):null]}),e.kind==="prompt"&&S?(0,p.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:S}):null,n&&e.kind==="span"&&e.span.messageStartIndex===void 0?(0,p.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,p.jsxs)("div",{className:"space-y-4",children:[(0,p.jsxs)("div",{className:"space-y-2",children:[(0,p.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"Input"}),(0,p.jsx)(Qx,{value:b??void 0})]}),(0,p.jsxs)("div",{className:G("space-y-2",e.span.category==="error"||k?"rounded-md border border-destructive/50 bg-destructive/50 p-2":""),children:[(0,p.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"Output"}),(0,p.jsx)(Qx,{value:w??void 0}),k?(0,p.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:k}):null,typeof e.span.mcpErrorCode=="number"?(0,p.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,p.jsx)("span",{className:"text-muted-foreground/70",children:"MCP error: "}),(0,p.jsx)("span",{className:"font-medium text-foreground",children:XU(e.span.mcpErrorCode)})]}):null]})]}):null]})}function uK({recordedSpans:e,projectedMessages:t=!1,interactionSteps:n,estimatedDurationMs:r,transcriptMessageCount:i=0,transcriptMessages:s=[],traceStartedAtMs:o=null,traceEndedAtMs:a=null,onRevealInTranscript:l,hideToolbar:c=!1,timelineFilter:u,onTimelineFilterChange:h,expandedPromptIds:f,onExpandedPromptIdsChange:d,expandedStepIds:m,onExpandedStepIdsChange:v,viewportMaxMs:y,turnRuntimeByPromptIndex:x,fillContent:b=!1,detailPlacement:w="below",iterationCost:S}){const{containerRef:C,direction:A}=sq(w),k=A==="horizontal",E=(0,g.useMemo)(()=>t?nq(e??[],s):void 0,[t,e,s]),T=E?.spans??e,R=kq(T,S),P=R.spans,M=vM(),N=DE(),L=Oa(),I=(0,g.useMemo)(()=>new Set(L?(P??[]).filter(O=>O.cost).map(O=>O.id):[]),[L,P]),_=T&&T.length>0?"recorded":(r??0)>0?"estimated":"none",j=(0,g.useMemo)(()=>T?.length?Hq(T).map(O=>E?{...O,messageStartIndex:E.userIndices[O.promptIndex]??-1,messageEndIndex:E.userIndices[O.promptIndex]??-1}:O):[],[T,E]),$=(0,g.useMemo)(()=>{const O=new Map;for(const le of n??[]){const fe=O.get(le.toolCallId);fe?fe.push(le):O.set(le.toolCallId,[le])}for(const le of O.values())le.sort((fe,Ie)=>fe.stepIndex-Ie.stepIndex);return O},[n]),B=T?.length?T.reduce((O,le)=>Math.max(O,le.endMs),1):Math.max(r??0,1),D=(0,g.useMemo)(()=>T?.map(O=>`${O.id}:${O.startMs}:${O.endMs}`).join("|")??_,[_,T]),[se,ne]=(0,g.useState)(1);(0,g.useEffect)(()=>{y===void 0&&ne(B)},[B,D,y]);const F=Math.max(1,y!==void 0?y:se),q=Math.max(1,Math.round(B/50)),K=(0,g.useMemo)(()=>r6({traceStartedAtMs:o,traceEndedAtMs:a,traceDurationMs:B}),[B,a,o]),[Y,H]=(0,g.useState)("all"),X=u!==void 0?u:Y,oe=h??H,[pe,ae]=(0,g.useState)(new Set),[at,et]=(0,g.useState)(new Set),Re=f!==void 0?f:pe,ze=d??ae,_e=m!==void 0?m:at,_n=v??et,[je,hn]=(0,g.useState)(null),[wt,tt]=(0,g.useState)(null),[J,ge]=(0,g.useState)(null),ke=(0,g.useRef)(null),js=(0,g.useRef)(null),[$e,Ai]=(0,g.useState)(-1);(0,g.useLayoutEffect)(()=>{const O=js.current;if(!O)return;const le=()=>{const Ie=O.getBoundingClientRect().width;Ai(Number.isFinite(Ie)?Ie:0)};if(le(),typeof ResizeObserver>"u")return;const fe=new ResizeObserver(le);return fe.observe(O),()=>fe.disconnect()},[A]);const gt=(0,g.useMemo)(()=>Rq($e),[$e]),Ti=(0,g.useMemo)(()=>gt.length!==2?!1:$e<0||$e===0?!0:$e<Mq,[$e,gt]);(0,g.useEffect)(()=>{c||(ae(new Set(j.map(O=>O.key))),et(qx(j)))},[c,j]);const Pe=(0,g.useMemo)(()=>{if(_!=="recorded")return[];const O=[],le=new Set;function fe(re){return X==="all"?!0:X==="error"?Zi(re,s,t):re.category===X}function Ie(re,zt,fn){const Wr=re.span.category==="step",$t=Wr?fn:fn+1,dn=re.children.map(St=>Ie(St,zt,$t)),Fs=dn.flatMap(St=>St.rows),Vs=dn.some(St=>St.hasVisibleContent);if(Wr)return{hasVisibleContent:Vs||re.children.length>0,rows:Fs};if(re.span.category==="llm"&&!I.has(re.span.id)&&typeof re.span.totalTokens!="number"&&typeof re.span.inputTokens!="number"&&typeof re.span.outputTokens!="number"&&re.span.endMs-re.span.startMs<50)return{hasVisibleContent:!1,rows:[]};const jn=re.span.toolCallId,zs=re.span.category==="tool"&&!!jn&&!le.has(jn);zs&&jn&&le.add(jn);const _a=zs&&jn?($.get(jn)??[]).filter(St=>X==="all"||X==="tool"?!0:X==="error"?Vc(St)==="error":!1).map((St,Vu)=>({kind:"interaction",key:`interaction-${re.span.id}-${St.stepIndex}-${Vu}`,promptIndex:zt,depth:fn+1,step:St,startMs:re.span.startMs,endMs:re.span.endMs,status:Vc(St)})):[];if(!(fe(re.span)||Vs||_a.length>0))return{hasVisibleContent:Vs,rows:Fs};const $s={kind:"span",key:re.span.id,promptIndex:zt,depth:fn,span:re.span,hasChildren:re.children.length>0,isExpanded:_e.has(re.span.id)};return{hasVisibleContent:!0,rows:[$s,...$s.hasChildren&&$s.isExpanded?Fs:[],..._a]}}for(const re of j){const zt=re.roots.map(dn=>Ie(dn,re.promptIndex,0)).flatMap(dn=>dn.rows);if(!(zt.length>0||X==="all"&&re.spans.length>0))continue;const fn=re.spans.some(dn=>Zi(dn,s,t)),Wr=Qq(s,re.messageStartIndex,re.messageEndIndex),$t=Iq(re.spans);O.push({kind:"prompt",key:re.key,promptIndex:re.promptIndex,label:re.label,conversationLabel:Wr?`User: "${Wr}"`:void 0,startMs:re.startMs,endMs:re.endMs,messageStartIndex:re.messageStartIndex,messageEndIndex:re.messageEndIndex,counts:re.counts,hasAnyFailure:fn,isExpanded:Re.has(re.key),aggregatedInputTokens:$t.inputTokens,aggregatedOutputTokens:$t.outputTokens,aggregatedTotalTokens:$t.totalTokens}),Re.has(re.key)&&O.push(...zt)}return O},[Re,_e,X,j,$,_,s,t,I]),Bs=(0,g.useMemo)(()=>qx(j),[j]),Na=(0,g.useMemo)(()=>{if(j.length===0)return!1;for(const O of j)if(!Re.has(O.key))return!1;for(const O of Bs)if(!_e.has(O))return!1;return!0},[j,Re,_e,Bs]);(0,g.useEffect)(()=>{if(Pe.length===0){hn(null);return}(!je||!Pe.some(O=>O.key===je))&&hn(Pe[0].key)},[Pe,je]);const Hr=Pe.find(O=>O.key===je),Te=wt?Pe.find(O=>O.key===wt):void 0,Bu=wt?Pe.findIndex(O=>O.key===wt):-1;(0,g.useEffect)(()=>{wt&&!Pe.some(O=>O.key===wt)&&(tt(null),ge(null),ke.current=null)},[wt,Pe]);const La=(0,g.useCallback)(O=>{const le=(O.querySelector('[data-testid="trace-row-glyph"]')??O).getBoundingClientRect();return{anchorX:le.left+le.width/2,anchorY:le.top,anchorBottom:le.bottom}},[]);(0,g.useEffect)(()=>{if(!wt)return;const O=()=>{const le=ke.current;le&&ge(La(le))};return window.addEventListener("scroll",O,!0),window.addEventListener("resize",O),()=>{window.removeEventListener("scroll",O,!0),window.removeEventListener("resize",O)}},[wt,La]);const Ag=(0,g.useMemo)(()=>{if(!Te)return null;const{startMs:O,endMs:le}=Ep(Te),fe=Te.kind==="span"&&Zi(Te.span,s,t),Ie=Te.kind==="span"?Tp(Te,s,t,N(Te.span)):null,re=Te.kind==="prompt"?Te.conversationLabel??Te.label:Te.kind==="interaction"?Ts(Te.step):Ie.title,zt=n6(Te,T),fn=Te.kind==="prompt"?"prompt":Te.kind==="interaction"?"interaction":Te.span.category==="tool"&&fe?"error":Te.span.category;return{label:re,spanShowsFailure:fe,tokenStats:zt,rowStartTimestamp:K!==null?K+O:null,rowEndTimestamp:K!==null?K+le:null,glyphCategory:fn,cost:L?LE(Te,P):void 0}},[Te,T,P,K,s,t,N,L]),UE=(0,g.useCallback)(O=>{if(Pe.length===0)return;const le=Pe.findIndex(fe=>fe.key===je);if(O.key==="ArrowDown"){O.preventDefault();const fe=le<0?0:Math.min(Pe.length-1,le+1);hn(Pe[fe].key);return}if(O.key==="ArrowUp"){O.preventDefault();const fe=le<=0?0:le-1;hn(Pe[fe].key);return}if(O.key==="Enter"&&le>=0){const fe=Pe[le];if(fe.kind==="prompt"){O.preventDefault();const Ie=new Set(Re);Ie.has(fe.key)?Ie.delete(fe.key):Ie.add(fe.key),ze(Ie);return}if(fe.kind==="span"&&fe.hasChildren){O.preventDefault();const Ie=new Set(_e);Ie.has(fe.key)?Ie.delete(fe.key):Ie.add(fe.key),_n(Ie)}}},[Re,_e,Pe,je,ze,_n]),Fu=(0,p.jsxs)(p.Fragment,{children:[R.loader,(0,p.jsx)(Aq,{spans:P,iteration:S,unmatched:R.unmatched})]});if(_==="none")return(0,p.jsxs)(p.Fragment,{children:[Fu,(0,p.jsx)("div",{className:"text-xs text-muted-foreground",children:"No timing data recorded for this iteration."})]});if(_==="estimated")return(0,p.jsxs)("div",{className:"space-y-3",children:[Fu,(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[(0,p.jsx)(kc,{className:"border-warning/50 bg-warning/50 text-foreground",children:"Estimated total only"}),(0,p.jsx)("span",{className:"text-xs text-muted-foreground",children:No(r??0)})]}),(0,p.jsxs)("div",{className:"space-y-1 text-[11px] text-muted-foreground",children:[(0,p.jsx)("p",{children:"Per-step timing was not recorded for this run."}),i>0?(0,p.jsxs)("p",{children:["Conversation detail is in the Chat tab. Open"," ",(0,p.jsx)("span",{className:"font-medium text-foreground/80",children:"Raw"})," to inspect the stored trace and confirm whether a"," ",(0,p.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 qE=y===void 0?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ot,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7 border-border/50",title:"Zoom in timeline","aria-label":"Zoom in timeline",disabled:se<=q,onClick:()=>ne(O=>Math.max(q,Math.round(O*.8))),children:(0,p.jsx)(oN,{className:"size-3.5","aria-hidden":!0})}),(0,p.jsx)(Ot,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7 border-border/50",title:"Zoom out timeline","aria-label":"Zoom out timeline",disabled:se>=B*4,onClick:()=>ne(O=>Math.min(B*4,Math.round(O*1.25))),children:(0,p.jsx)(rN,{className:"size-3.5","aria-hidden":!0})})]}):null;return(0,p.jsxs)("div",{className:G("space-y-2",b&&"flex min-h-0 flex-1 flex-col"),children:[c?null:(0,p.jsxs)("div",{className:b?"shrink-0":void 0,children:[(0,p.jsx)(aq,{filter:X,onFilterChange:oe,isFullyExpanded:Na,expandDisabled:j.length===0,zoomControls:qE,onToggleExpandAll:()=>{Na?(ze(new Set),_n(new Set)):(ze(new Set(j.map(O=>O.key))),_n(new Set(Bs)))}}),(0,p.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:O,cls:le})=>(0,p.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:G("h-2 w-2.5 rounded-sm",le)}),O]},O))})]}),Fu,(0,p.jsx)("div",{ref:C,className:G("@container/trace-timeline min-w-0",b&&"flex min-h-0 flex-1 flex-col"),children:(0,p.jsxs)(RU,{direction:A,className:G("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,p.jsx)(Cp,{defaultSize:k?62:65,minSize:0,className:"min-h-0 min-w-0 overflow-hidden",children:(0,p.jsx)(NU,{className:G(b?"h-full min-h-0 overflow-hidden":"max-h-[calc(100vh-8rem)] min-h-0"),children:(0,p.jsx)("div",{tabIndex:0,role:"region","aria-label":"Trace timeline. Use arrow keys to change selection, Enter to expand.",onKeyDown:UE,className:"relative min-h-0 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:(0,p.jsxs)("div",{className:"grid pr-4",style:{gridTemplateColumns:"minmax(140px, 260px) minmax(0, 1fr) minmax(5.25rem, max-content)",gridTemplateRows:`auto repeat(${Pe.length}, minmax(48px, auto))`},children:[(0,p.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,p.jsxs)("div",{className:"flex min-h-6 min-w-0 items-center gap-3",children:[(0,p.jsx)("div",{className:"shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground",children:"Trace"}),(0,p.jsx)("div",{className:"min-h-6 min-w-0 flex-1",children:(0,p.jsx)("div",{ref:js,className:"relative h-6 min-w-0",children:Ti?(0,p.jsx)("div",{className:"flex h-full min-w-0 items-center justify-center",children:(0,p.jsx)("span",{className:"min-w-0 max-w-full truncate text-center text-[10px] tabular-nums text-muted-foreground",title:Wx(F),children:Wx(F)})}):gt.map(O=>{const le=O>=100?"100%":`${O}%`;return(0,p.jsx)("div",{className:"pointer-events-none absolute inset-y-0",style:{left:le},children:(0,p.jsx)("div",{className:G("absolute text-[10px] tabular-nums text-muted-foreground",Pq(O)),children:ic(F*O/100)})},O)})})})]})}),(0,p.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,p.jsxs)("div",{className:"flex h-6 w-full min-w-0 items-center justify-start gap-1.5",children:[(0,p.jsx)(tv,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,p.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Latency"})]})}),Pe.length>0?(0,p.jsx)("div",{className:"pointer-events-none relative z-0 bg-transparent",style:{gridColumn:2,gridRow:`2 / ${Pe.length+2}`},children:gt.map(O=>(0,p.jsx)("div",{className:"absolute top-0 bottom-0 w-px bg-border/40",style:{left:O>=100?"100%":`${O}%`}},O))}):null,Pe.map((O,le)=>{const fe=O.key===je,{startMs:Ie,endMs:re,durationMs:zt}=Ep(O),fn=Ie/F*100,Wr=Math.max((re-Ie)/F*100,.45),$t=O.kind==="span"&&Zi(O.span,s,t),dn=O.kind==="prompt"?"prompt":O.kind==="interaction"?"interaction":O.span.category==="tool"&&$t?"error":O.span.category,Fs=O.kind==="interaction"&&O.status==="error",Vs=O.kind==="span"?Tp(O,s,t):null,jn=O.kind==="prompt"?O.conversationLabel??O.label:O.kind==="interaction"?Ts(O.step):Vs.title,zs=No(zt),_a=O.kind==="prompt"?!0:O.kind==="interaction"?!1:O.hasChildren||O.span.category==="llm",$s=le+2,St=$q(O,$t),Vu=Vq(O,$t),Tg=()=>{td("trace_span_clicked",{location:"trace_timeline",span_kind:O.kind}),hn(O.key)},zu=kt=>{kt.stopPropagation(),Tg()},KE=fe?G("bg-transparent",St):"border-l-transparent bg-background group-hover:bg-muted/20 hover:bg-muted/20",Eg=fe?"bg-transparent":"bg-background group-hover:bg-muted/20 hover:bg-muted/20";return(0,p.jsxs)(s1.div,{"data-testid":"trace-row","data-state":fe?"selected":void 0,onClick:Tg,onMouseEnter:kt=>{tt(O.key);const Ct=kt.currentTarget;ke.current=Ct,ge(La(Ct))},onMouseLeave:()=>{tt(kt=>kt===O.key?null:kt),ge(null),ke.current=null},onFocus:kt=>{tt(O.key);const Ct=kt.currentTarget;ke.current=Ct,ge(La(Ct))},onBlur:kt=>{kt.currentTarget.contains(kt.relatedTarget)||(tt(Ct=>Ct===O.key?null:Ct),ge(null),ke.current=null)},initial:M||le>=20?!1:{opacity:0,y:6},animate:{opacity:1,y:0},transition:M||le>=20?{duration:0}:{duration:.15,delay:le*.03+.05,ease:[.16,1,.3,1]},style:{gridColumn:"1 / 4",gridRow:$s,display:"grid",gridTemplateColumns:"subgrid"},className:G("group min-h-0 min-w-0 cursor-pointer items-stretch",fe&&"trace-waterfall-row-selected ring-1 ring-inset ring-ring/40"),children:[(0,p.jsxs)("div",{className:G("flex items-center gap-2 border-b border-border/40 px-4 py-2 transition-all duration-150 border-l-2",KE),children:[(0,p.jsx)("div",{className:"flex shrink-0 items-center",style:{paddingLeft:O.kind==="prompt"?0:O.depth*16},children:_a?(0,p.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:kt=>{if(kt.stopPropagation(),O.kind==="prompt"){const ja=new Set(Re);ja.has(O.key)?ja.delete(O.key):ja.add(O.key),ze(ja);return}const Ct=new Set(_e);Ct.has(O.key)?Ct.delete(O.key):Ct.add(O.key),_n(Ct)},"aria-label":O.kind==="prompt"?`${O.isExpanded?"Collapse":"Expand"} ${O.label}`:`${"isExpanded"in O&&O.isExpanded?"Collapse":"Expand"} ${jn}`,children:"isExpanded"in O&&O.isExpanded?(0,p.jsx)(Xw,{className:"h-3.5 w-3.5"}):(0,p.jsx)(fs,{className:"h-3.5 w-3.5"})}):(0,p.jsx)("span",{className:"mr-1 h-5 w-5"})}),(0,p.jsx)("button",{type:"button","data-testid":"trace-row-label-button",className:"min-w-0 flex-1 text-left",onClick:zu,children:(0,p.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,p.jsx)("span",{"data-testid":"trace-row-glyph",className:"inline-flex shrink-0 items-center",children:O.kind==="prompt"?(0,p.jsx)(Es,{category:"prompt"}):(0,p.jsx)(Es,{category:dn})}),(0,p.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:jn}),(0,p.jsx)(xz,{name:O.kind==="span"?N(O.span):void 0}),O.kind==="prompt"&&O.hasAnyFailure?(0,p.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-destructive",title:"Contains errors","aria-label":"Contains errors"}):null,O.kind==="span"&&$t||Fs?(0,p.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-destructive",title:"Error","aria-label":"Error"}):null]})})]}),(0,p.jsx)("button",{type:"button","data-testid":"trace-row-bar-hit","data-state":fe?"selected":void 0,className:G("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",Eg),"aria-label":`Select on timeline (${No(zt)})`,onClick:zu,children:(0,p.jsx)("div",{"data-testid":O.kind==="span"&&$t?"trace-row-bar-error":"trace-row-bar",className:G("absolute top-1/2 z-[1] h-4 min-w-0 -translate-y-1/2 rounded-[3px] transition-[left,width] duration-150",Vu),style:{left:`${fn}%`,width:`max(${Wr}%, 3px)`}})}),(0,p.jsxs)("button",{type:"button","data-testid":"trace-row-duration-hit","data-state":fe?"selected":void 0,className:G("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",Eg),"aria-label":`Select row duration (${zs})`,onClick:zu,children:[(0,p.jsx)(tv,{className:"size-3 shrink-0 opacity-80","aria-hidden":!0}),zs]})]},O.key)})]})})})}),(0,p.jsx)(PU,{withHandle:!0}),(0,p.jsx)(Cp,{defaultSize:k?38:35,minSize:k?25:20,className:"min-h-0 min-w-0 overflow-hidden",children:(0,p.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,p.jsx)(a6,{projectedMessages:t,row:Hr,recordedSpans:P,transcriptMessages:s,onRevealInTranscript:l,turnRuntimeByPromptIndex:x})})})]},A)}),Te&&Ag&&J?(0,p.jsx)(l6,{hoverPos:J,info:Ag,placement:Bu===0?"bottom":"top",reduceMotion:M??!1,rowKey:Te.key}):null]})}function l6({hoverPos:e,info:t,placement:n,reduceMotion:r,rowKey:i}){if(typeof document>"u")return null;const s=304,o=12,a=8,l=s/2,c=typeof window<"u"?window.innerWidth:e.anchorX+l+o,u=164,h=Math.max(u,c-l-o),f=Math.min(Math.max(e.anchorX,u),h),d={position:"fixed",top:n==="top"?e.anchorY-a:e.anchorBottom+a,left:f,transform:n==="top"?"translate(-50%, -100%)":"translateX(-50%)",zIndex:9999};return(0,pa.createPortal)((0,p.jsx)("div",{className:"pointer-events-none",style:d,children:(0,p.jsx)(s1.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,p.jsxs)("div",{"data-testid":"trace-row-hover-card",className:"space-y-3 p-3",children:[(0,p.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,p.jsx)(Es,{category:t.glyphCategory}),(0,p.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs font-semibold text-popover-foreground",children:t.label})]}),(0,p.jsxs)("div",{className:"space-y-1.5",children:[(0,p.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-popover-foreground/65",children:"Time"}),(0,p.jsxs)("div",{className:"space-y-1 text-xs",children:[(0,p.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,p.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"Start"}),(0,p.jsx)("span",{"data-testid":"trace-row-hover-start",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:Gx(t.rowStartTimestamp)})]}),(0,p.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,p.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"End"}),(0,p.jsx)("span",{"data-testid":"trace-row-hover-end",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:Gx(t.rowEndTimestamp)})]})]})]}),(0,p.jsxs)("div",{className:"space-y-1.5",children:[(0,p.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-popover-foreground/65",children:"Tokens"}),(0,p.jsxs)("div",{className:"space-y-1 text-xs",children:[(0,p.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,p.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"Input"}),(0,p.jsx)("span",{"data-testid":"trace-row-hover-input-tokens",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:af(t.tokenStats.inputTokens)})]}),(0,p.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,p.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"Output"}),(0,p.jsx)("span",{"data-testid":"trace-row-hover-output-tokens",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:af(t.tokenStats.outputTokens)})]}),(0,p.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,p.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"Total"}),(0,p.jsx)("span",{"data-testid":"trace-row-hover-total-tokens",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:af(t.tokenStats.totalTokens)})]})]})]}),(0,p.jsx)(Sq,{cost:t.cost})]})},i)}),document.body)}export{F8 as $,a1 as $n,KD as $r,p8 as $t,RU as A,J6 as An,dN as Ar,R8 as At,JT as B,W6 as Bn,nN as Br,v8 as Bt,rK as C,te as Ci,r8 as Cn,ru as Cr,Bl as Ct,Js as D,Le as Di,Z6 as Dn,x6 as Dr,E8 as Dt,tK as E,PM as Ei,oF as En,AS as Er,QV as Et,W4 as F,$6 as Fn,cN as Fr,k8 as Ft,S4 as G,V6 as Gn,XD as Gr,pt as Gt,X8 as H,UB as Hn,eN as Hr,NV as Ht,eK as I,Q6 as In,oN as Ir,C8 as It,$z as J,FB as Jn,tv as Jr,IF as Jt,v4 as K,F6 as Kn,YD as Kr,pu as Kt,G4 as L,K6 as Ln,sN as Lr,Sc as Lt,aE as M,H6 as Mn,hN as Mr,w8 as Mt,pg as N,q6 as Nn,uN as Nr,S8 as Nt,PU as O,X6 as On,no as Or,M8 as Ot,Q4 as P,z6 as Pn,nu as Pr,$1 as Pt,V8 as Q,C6 as Qn,hs as Qr,du as Qt,mg as R,U6 as Rn,iN as Rr,FV as Rt,Ap as S,Rt as Si,w1 as Sn,we as Sr,$m as St,LU as T,cr as Ti,o8 as Tn,PN as Tr,GV as Tt,E4 as U,ms as Un,ZD as Ur,x8 as Ut,J8 as V,Pm as Vn,tN as Vr,b8 as Vt,A4 as W,zB as Wn,JD as Wr,V1 as Wt,$8 as X,MB as Xn,fs as Xr,E1 as Xt,xz as Y,EB as Yn,GD as Yr,m8 as Yt,z8 as Z,k6 as Zn,Xw as Zr,CF as Zt,PE as _,Je as _i,i8 as _n,s1 as _r,rz as _t,ha as a,yI as ai,u8 as an,NB as ar,vr as at,zU as b,Ln as bi,rF as bn,Kk as br,Vm as bt,_E as c,Qc as ci,c8 as cn,D6 as cr,lz as ct,aq as d,_b as di,A1 as dn,R6 as dr,D8 as dt,Iw as ei,d8 as en,A6 as er,B8 as et,aK as f,Lp as fi,t8 as fn,T6 as fr,O8 as ft,sK as g,rR as gi,n8 as gn,uu as gr,I8 as gt,tq as h,xb as hi,_m as hn,M6 as hr,ys as ht,Rq as i,tw as ii,h8 as in,LB as ir,mr as it,X4 as j,G6 as jn,fN as jr,zm as jt,Cp as k,Y6 as kn,xN as kr,P8 as kt,jE as l,Bb as li,l8 as ln,L6 as lr,_8 as lt,JU as m,oR as mi,S1 as mn,E6 as mr,L8 as mt,Hq as n,OI as ni,yF as nn,O6 as nr,cz as nt,cK as o,nw as oi,td as on,N6 as or,az as ot,lK as p,Mb as pi,b1 as pn,P6 as pr,N8 as pt,Kz as q,B6 as qn,ts as qr,Bm as qt,qx as r,lw as ri,xF as rn,_6 as rr,j8 as rt,Oa as s,$p as si,dF as sn,j6 as sr,gr as st,uK as t,DI as ti,f8 as tn,_B as tr,q0 as tt,LE as u,YR as ui,uF as un,I6 as ur,kc as ut,iK as v,$c as vi,s8 as vn,S6 as vr,W1 as vt,NU as w,Pp as wi,e8 as wn,ov as wr,YV as wt,nK as x,ga as xi,Dm as xn,$L as xr,T8 as xt,IE as y,di as yi,a8 as yn,vj as yr,nz as yt,Z8 as z,jt as zn,rN as zr,y8 as zt};
72
-
73
- //# sourceMappingURL=trace-timeline-mjuETy67.js.map