@mcpjam/inspector 3.11.0 → 3.12.1

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/OAuthDesktopReturnNotice-BeDakGgb.css +2 -0
  2. package/dist/client/assets/OAuthDesktopReturnNotice-DrCSUffX.js +11 -0
  3. package/dist/client/assets/{mermaid-GHXKKRXX-DooOqFNN.js → app-bootstrap-C0wjVteM.js} +1909 -649
  4. package/dist/client/assets/app-bootstrap-CbO9HC35.css +1 -0
  5. package/dist/client/assets/button-DQ9bR46C.js +3 -0
  6. package/dist/client/assets/chunk-YOKDWASO-Cpy4vQY8.js +145 -0
  7. package/dist/client/assets/dead-clicks-autocapture-D3WNuKsf.js +3 -0
  8. package/dist/client/assets/error-reporting-BHW3WviX.js +102 -0
  9. package/dist/client/assets/error-reporting-DmfwQkBP.js +1 -0
  10. package/dist/client/assets/exception-autocapture-D0Qfhhbc.js +5 -0
  11. package/dist/client/assets/failed-request-tracker-DyZB_Nfp.js +3 -0
  12. package/dist/client/assets/highlighted-body-KPVGNVTW-QEEOJH_y.js +3 -0
  13. package/dist/client/assets/index-pxVGER4l.js +4 -0
  14. package/dist/client/assets/jszip.min-DPr4_u5f.js +4 -0
  15. package/dist/client/assets/mermaid-HWGCJPDP-DNAzcUbW.js +1 -0
  16. package/dist/client/assets/posthog-recorder-dQnAa9ak.js +110 -0
  17. package/dist/client/assets/preload-helper-DsxBH8kv.js +3 -0
  18. package/dist/client/assets/rolldown-runtime-DeZZUx0l.js +1 -0
  19. package/dist/client/assets/surveys-CdlQJ0hc.js +3 -0
  20. package/dist/client/assets/trace-timeline-2WCodaTP.js +137 -0
  21. package/dist/client/assets/trace-timeline-Ix3CoQw4.js +1 -0
  22. package/dist/client/assets/web-vitals-DdK10Etm.js +3 -0
  23. package/dist/client/index.html +7 -2
  24. package/dist/client/robots.txt +14 -0
  25. package/dist/server/{chunk-3I6NEQHV.js → chunk-R5EHY55H.js} +2 -2
  26. package/dist/server/harness-install-cli.js +1 -1
  27. package/dist/server/index.js +9213 -6634
  28. package/package.json +51 -50
  29. package/dist/client/assets/dead-clicks-autocapture-ApmbuFvM.js +0 -2
  30. package/dist/client/assets/error-reporting-C8so6E8C.js +0 -92
  31. package/dist/client/assets/exception-autocapture-BqHgtpgn.js +0 -3
  32. package/dist/client/assets/highlighted-body-OFNGDK62-Lg-8-zC8.js +0 -2
  33. package/dist/client/assets/index-BYEarR7W.css +0 -1
  34. package/dist/client/assets/index-BireMI1y.js +0 -11
  35. package/dist/client/assets/jszip.min-DkflbHVD.js +0 -3
  36. package/dist/client/assets/mermaid-GHXKKRXX-zqdNpMJm.css +0 -1
  37. package/dist/client/assets/posthog-recorder-Cqdsd7mu.js +0 -109
  38. package/dist/client/assets/surveys-Bn96AwyI.js +0 -2
  39. package/dist/client/assets/web-vitals-D6VtlfDg.js +0 -2
@@ -0,0 +1,137 @@
1
+ import{a as GC,n as QC,o as gy,r as XC}from"./rolldown-runtime-DeZZUx0l.js";import{a as YC,i as JC,o as ZC}from"./preload-helper-DsxBH8kv.js";import{a as eT,i as tT,l as Ae,o as Xi,r as X,s as nT,t as Nt}from"./button-DQ9bR46C.js";import{An as rh,Cn as xr,En as Va,Gi as rT,Hi as Pn,Ki as iT,On as ve,Sn as ct,Ui as yl,Vi as ih,Wi as Fn,cn as xl,d as sT,fn as vy,jn as Wc,mn as Ue,pn as yn,qi as oT,t as aT,yn as dr,zn as lT}from"./error-reporting-BHW3WviX.js";import{a as cT,n as uT}from"./chunk-YOKDWASO-Cpy4vQY8.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.12.1"};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8770d1c1-a35a-4f4d-8a31-74baacd8af48",e._sentryDebugIdIdentifier="sentry-dbid-8770d1c1-a35a-4f4d-8a31-74baacd8af48")}catch{}})();var m=gy(ZC(),1),_o=gy(YC(),1),g=JC(),hT=Object.defineProperty,fT=(e,t)=>hT(e,"name",{value:t,configurable:!0}),_e=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=Xi(`Primitive.${t}`),r=m.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),(0,g.jsx)(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function hd(e,t){e&&_o.flushSync(()=>e.dispatchEvent(t))}fT(hd,"dispatchDiscreteCustomEvent");var dT=Object.defineProperty,pT=(e,t)=>dT(e,"name",{value:t,configurable:!0}),mT=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"}),gT=m.forwardRef(pT(function(t,n){return(0,g.jsx)(_e.span,{...t,ref:n,style:{...mT,...t.style}})},"VisuallyHidden")),vT=gT,yT=Object.defineProperty,Lt=(e,t)=>yT(e,"name",{value:t,configurable:!0});function xT(e,t){const n=m.createContext(t);n.displayName=e+"Context";const r=Lt(s=>{const{children:o,...a}=s,l=m.useMemo(()=>a,Object.values(a));return(0,g.jsx)(n.Provider,{value:l,children:o})},"Provider");r.displayName=e+"Provider";function i(s,o={}){const{optional:a=!1}=o,l=m.useContext(n);if(l)return l;if(t!==void 0)return t;if(!a)throw new Error(`\`${s}\` must be used within \`${e}\``)}return Lt(i,"useContext"),[r,i]}Lt(xT,"createContext");function rr(e,t=[]){let n=[];function r(s,o){const a=m.createContext(o);a.displayName=s+"Context";const l=n.length;n=[...n,o];const c=Lt(h=>{const{scope:f,children:d,...p}=h,v=f?.[e]?.[l]||a,y=m.useMemo(()=>p,Object.values(p));return(0,g.jsx)(v.Provider,{value:y,children:d})},"Provider");c.displayName=s+"Provider";function u(h,f,d={}){const{optional:p=!1}=d,v=f?.[e]?.[l]||a,y=m.useContext(v);if(y)return y;if(o!==void 0)return o;if(!p)throw new Error(`\`${h}\` must be used within \`${s}\``)}return Lt(u,"useContext"),[c,u]}Lt(r,"createContext");const i=Lt(()=>{const s=n.map(o=>m.createContext(o));return Lt(function(a){const l=a?.[e]||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])},"useScope")},"createScope");return i.scopeName=e,[r,yy(i,...t)]}Lt(rr,"createContextScope");function yy(...e){const t=e[0];if(e.length===1)return t;const n=Lt(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Lt(function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const u=l(s)[`__scope${c}`];return{...a,...u}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Lt(yy,"composeContextScopes");var bT=Object.defineProperty,Ge=(e,t)=>bT(e,"name",{value:t,configurable:!0});function fd(e){const t=e+"CollectionProvider",[n,r]=rr(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Ge(v=>{const{scope:y,children:x}=v,b=m.useRef(null),w=m.useRef(new Map).current;return(0,g.jsx)(i,{scope:y,itemMap:w,collectionRef:b,children:x})},"CollectionProvider");o.displayName=t;const a=e+"CollectionSlot",l=Xi(a),c=m.forwardRef((v,y)=>{const{scope:x,children:b}=v,w=s(a,x),S=Ae(y,w.collectionRef);return(0,g.jsx)(l,{ref:S,children:b})});c.displayName=a;const u=e+"CollectionItemSlot",h="data-radix-collection-item",f=Xi(u),d=m.forwardRef((v,y)=>{const{scope:x,children:b,...w}=v,S=m.useRef(null),C=Ae(y,S),T=s(u,x);return m.useEffect(()=>(T.itemMap.set(S,{ref:S,...w}),()=>{T.itemMap.delete(S)})),(0,g.jsx)(f,{[h]:"",ref:C,children:b})});d.displayName=u;function p(v){const y=s(e+"CollectionConsumer",v);return m.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 Ge(p,"useCollection"),[{Provider:o,Slot:c,ItemSlot:d},p,r]}Ge(fd,"createCollection");var Zp=new WeakMap,qc=class lr extends Map{static{Ge(this,"OrderedDict")}#e;constructor(t){super(t),this.#e=[...super.keys()],Zp.set(this,!0)}set(t,n){return Zp.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=dd(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 p=u[d];u[d]===n&&(p=u[d+1]),i&&this.delete(n),h=this.get(p),this.set(n,r)}else{!f&&u[d-1]===n&&(f=!0);const p=u[f?d:d-1],v=h;h=this.get(p),this.delete(p),this.set(p,v)}return this}with(t,n,r){const i=new lr(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=Fa(this.#e,t);if(n!==void 0)return this.get(n)}entryAt(t){const n=Fa(this.#e,t);if(n!==void 0)return[n,this.get(n)]}indexOf(t){return this.#e.indexOf(t)}keyAt(t){return Fa(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 lr(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 lr(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 lr(n)}toReversed(){const t=new lr;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 lr(n)}slice(t,n){const r=new lr;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 Fa(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=xy(e,t);return n===-1?void 0:e[n]}Ge(Fa,"at");function xy(e,t){const n=e.length,r=dd(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}Ge(xy,"toSafeIndex");function dd(e){return e!==e||e===0?0:Math.trunc(e)}Ge(dd,"toSafeInteger");function wT(e){const t=e+"CollectionProvider",[n,r]=rr(t),[i,s]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new qc,setItemMap:Ge(()=>{},"setItemMap")}),o=Ge(({state:b,...w})=>b?(0,g.jsx)(l,{...w,state:b}):(0,g.jsx)(a,{...w}),"CollectionProvider");o.displayName=t;const a=Ge(b=>{const w=y();return(0,g.jsx)(l,{...b,state:w})},"CollectionInit");a.displayName=t+"Init";const l=Ge(b=>{const{scope:w,children:S,state:C}=b,T=m.useRef(null),[k,A]=m.useState(null),E=Ae(T,A),[R,O]=C;return m.useEffect(()=>{if(!k)return;const M=Sy(()=>{});return M.observe(k,{childList:!0,subtree:!0}),()=>{M.disconnect()}},[k]),(0,g.jsx)(i,{scope:w,itemMap:R,setItemMap:O,collectionRef:E,collectionRefObject:T,collectionElement:k,children:S})},"CollectionProviderImpl");l.displayName=t+"Impl";const c=e+"CollectionSlot",u=Xi(c),h=m.forwardRef((b,w)=>{const{scope:S,children:C}=b,T=s(c,S),k=Ae(w,T.collectionRef);return(0,g.jsx)(u,{ref:k,children:C})});h.displayName=c;const f=e+"CollectionItemSlot",d="data-radix-collection-item",p=Xi(f),v=m.forwardRef((b,w)=>{const{scope:S,children:C,...T}=b,k=m.useRef(null),[A,E]=m.useState(null),R=Ae(w,k,E),{setItemMap:O}=s(f,S),M=m.useRef(T);by(M.current,T)||(M.current=T);const j=M.current;return m.useEffect(()=>{const N=j;return O(P=>A?P.has(A)?P.set(A,{...N,element:A}).toSorted(sh):(P.set(A,{...N,element:A}),P.toSorted(sh)):P),()=>{O(P=>!A||!P.has(A)?P:(P.delete(A),new qc(P)))}},[A,j,O]),(0,g.jsx)(p,{[d]:"",ref:R,children:C})});v.displayName=f;function y(){return m.useState(new qc)}Ge(y,"useInitCollection");function x(b){const{itemMap:w}=s(e+"CollectionConsumer",b);return w}return Ge(x,"useCollection"),[{Provider:o,Slot:h,ItemSlot:v},{createCollectionScope:r,useCollection:x,useInitCollection:y}]}Ge(wT,"createCollection");function by(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}Ge(by,"shallowEqual");function wy(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Ge(wy,"isElementPreceding");function sh(e,t){return!e[1].element||!t[1].element?0:wy(e[1].element,t[1].element)?-1:1}Ge(sh,"sortByDocumentPosition");function Sy(e){return new MutationObserver(t=>{for(const n of t)if(n.type==="childList"){e();return}})}Ge(Sy,"getChildListObserver");var ST=Object.defineProperty,fs=(e,t)=>ST(e,"name",{value:t,configurable:!0}),ky=!!(typeof window<"u"&&window.document&&window.document.createElement);function te(e,t,{checkForDefaultPrevented:n=!0}={}){return fs(function(i){if(e?.(i),n===!1||!i||!i.defaultPrevented)return t?.(i)},"handleEvent")}fs(te,"composeEventHandlers");function kT(e){if(!ky)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}fs(kT,"getOwnerWindow");function oh(e){if(!ky)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}fs(oh,"getOwnerDocument");function Cy(e,t=!1){const{activeElement:n}=oh(e);if(!n?.nodeName)return null;if(Ty(n)&&n.contentDocument)return Cy(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=oh(n).getElementById(r);if(i)return i}}return n}fs(Cy,"getActiveElement");function Ty(e){return e.tagName==="IFRAME"}fs(Ty,"isFrame");var Dt=globalThis?.document?m.useLayoutEffect:()=>{},CT=Object.defineProperty,TT=(e,t)=>CT(e,"name",{value:t,configurable:!0}),em=m[" useEffectEvent ".trim().toString()],tm=m[" useInsertionEffect ".trim().toString()];function Ay(e){if(typeof em=="function")return em(e);const t=m.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof tm=="function"?tm(()=>{t.current=e}):Dt(()=>{t.current=e}),m.useMemo(()=>((...n)=>t.current?.(...n)),[])}TT(Ay,"useEffectEvent");var AT=Object.defineProperty,Bo=(e,t)=>AT(e,"name",{value:t,configurable:!0}),RT=m[" useInsertionEffect ".trim().toString()]||Dt;function Vo({prop:e,defaultProp:t,onChange:n=Bo(()=>{},"onChange"),caller:r}){const[i,s,o]=Ry({defaultProp:t,onChange:n}),a=e!==void 0;return[a?e:i,m.useCallback(c=>{if(a){const u=My(c)?c(e):c;u!==e&&o.current?.(u)}else s(c)},[a,e,s,o])]}Bo(Vo,"useControllableState");function Ry({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),i=m.useRef(n),s=m.useRef(t);return RT(()=>{s.current=t},[t]),m.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}Bo(Ry,"useUncontrolledState");function My(e){return typeof e=="function"}Bo(My,"isFunction");var nm=Symbol("RADIX:SYNC_STATE");function MT(e,t,n,r){const{prop:i,defaultProp:s,onChange:o,caller:a}=t,l=i!==void 0,c=Ay(o),u=[{...n,state:s}];r&&u.push(r);const[h,f]=m.useReducer((y,x)=>{if(x.type===nm)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,p=m.useRef(d);m.useEffect(()=>{p.current!==d&&(p.current=d,l||c(d))},[d,p,l]);const v=m.useMemo(()=>i!==void 0?{...h,state:i}:h,[h,i]);return m.useEffect(()=>{l&&!Object.is(i,h.state)&&f({type:nm,state:i})},[i,h.state,l]),[v,f]}Bo(MT,"useControllableStateReducer");var PT=Object.defineProperty,er=(e,t)=>PT(e,"name",{value:t,configurable:!0});function Py(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}er(Py,"useStateMachine");var Nn=er(e=>{const{present:t,children:n}=e,r=Ey(t),i=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Oy(r.ref,Iy(i));return typeof n=="function"||r.isPresent?m.cloneElement(i,{ref:s}):null},"Presence");function Ey(e){const[t,n]=m.useState(),r=m.useRef(null),i=m.useRef(e),s=m.useRef("none"),o=m.useRef(void 0),[a,l]=Py(e?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{a==="mounted"?(s.current=o.current??Ai(r.current),o.current=void 0):s.current="none"},[a]),Dt(()=>{const c=r.current,u=i.current;if(u!==e){const h=s.current,f=Ai(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]),Dt(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,h=er(d=>{const p=Ai(r.current).includes(CSS.escape(d.animationName));if(d.target===t&&p&&(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=er(d=>{d.target===t&&(s.current=Ai(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:m.useCallback(c=>{if(c){const u=getComputedStyle(c);r.current=u,o.current=Ai(u)}else r.current=null;n(c)},[])}}er(Ey,"usePresence");function ah(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}er(ah,"setRef");function Oy(...e){const t=m.useRef(e);return t.current=e,m.useCallback(n=>{const r=t.current;let i=!1;const s=r.map(o=>{const a=ah(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():ah(r[o],null)}}},[])}er(Oy,"useStableComposedRefs");function Ai(e){return e?.animationName||"none"}er(Ai,"getAnimationName");function Iy(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)}er(Iy,"getElementRef");var ET=Object.defineProperty,OT=(e,t)=>ET(e,"name",{value:t,configurable:!0}),IT=m[" useId ".trim().toString()]||(()=>{}),DT=0;function ni(e){const[t,n]=m.useState(IT());return Dt(()=>{e||n(r=>r??String(DT++))},[e]),e||(t?`radix-${t}`:"")}OT(ni,"useId");var NT=Object.defineProperty,LT=(e,t)=>NT(e,"name",{value:t,configurable:!0}),jT=m.createContext(void 0);function tc(e){const t=m.useContext(jT);return e||t||"ltr"}LT(tc,"useDirection");var _T=Object.defineProperty,BT=(e,t)=>_T(e,"name",{value:t,configurable:!0});function Qe(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>((...n)=>t.current?.(...n)),[])}BT(Qe,"useCallbackRef");var VT=Object.defineProperty,Ke=(e,t)=>VT(e,"name",{value:t,configurable:!0}),lh="dismissableLayer.update",FT="dismissableLayer.pointerDownOutside",zT="dismissableLayer.focusOutside",rm,Dy=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ny=m.forwardRef(Ke(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...u}=t,h=m.useContext(Dy),[f,d]=m.useState(null),p=f?.ownerDocument??globalThis?.document,[,v]=m.useState({}),y=Ae(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,T=S>=w,k=m.useRef(!1),A=Ly(M=>{o?.(M),l?.(M),M.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:h.dismissableSurfaces,shouldHandlePointerDownOutside:m.useCallback(M=>{if(!(M instanceof Node))return!1;const j=[...h.branches].some(N=>N.contains(M));return T&&!j},[h.branches,T])}),E=jy(M=>{if(i&&k.current)return;const j=M.target;[...h.branches].some(N=>N.contains(j))||(a?.(M),l?.(M),M.defaultPrevented||c?.())},p),R=f?S===x.length-1:!1,O=Qe(M=>{M.key==="Escape"&&(s?.(M),!M.defaultPrevented&&c&&(M.preventDefault(),c()))});return m.useEffect(()=>{if(R)return p.addEventListener("keydown",O,{capture:!0}),()=>p.removeEventListener("keydown",O,{capture:!0})},[p,R,O]),m.useEffect(()=>{if(f)return r&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(rm=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),ch(),()=>{r&&(h.layersWithOutsidePointerEventsDisabled.delete(f),h.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=rm))}},[f,p,r,h]),m.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),ch())},[f,h]),m.useEffect(()=>{const M=Ke(()=>v({}),"handleUpdate");return document.addEventListener(lh,M),()=>document.removeEventListener(lh,M)},[]),(0,g.jsx)(_e.div,{...u,ref:y,style:{pointerEvents:C?T?"auto":"none":void 0,...t.style},onFocusCapture:te(t.onFocusCapture,E.onFocusCapture),onBlurCapture:te(t.onBlurCapture,E.onBlurCapture),onPointerDownCapture:te(t.onPointerDownCapture,A.onPointerDownCapture)})},"DismissableLayer"));function $T(){const e=m.useContext(Dy),[t,n]=m.useState(null);return m.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}Ke($T,"useDismissableLayerSurface");var HT=Ke(()=>!0,"IS_TRUE");function Ly(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:s,shouldHandlePointerDownOutside:o=HT}=t,a=Qe(e),l=m.useRef(!1),c=m.useRef(!1),u=m.useRef(new Map),h=m.useRef(()=>{});return m.useEffect(()=>{function f(){c.current=!1,i.current=!1,u.current.clear()}Ke(f,"resetOutsideInteraction");function d(){return Array.from(u.current.values()).some(Boolean)}Ke(d,"isOutsideInteractionIntercepted");function p(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)}Ke(p,"handleInteractionCapture");function v(w){c.current&&u.current.set(w.type,!1)}Ke(v,"handleInteractionBubble");const y=Ke(w=>{if(w.target&&!l.current){let S=function(){n.removeEventListener("click",h.current);const T=d();f(),T||pd(FT,a,C,{discrete:!0})};if(Ke(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,p,!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,p,!0),n.removeEventListener(w,v)}},[n,a,r,i,s,o]),{onPointerDownCapture:Ke(()=>l.current=!0,"onPointerDownCapture")}}Ke(Ly,"usePointerDownOutside");function jy(e,t=globalThis?.document){const n=Qe(e),r=m.useRef(!1);return m.useEffect(()=>{const i=Ke(s=>{s.target&&!r.current&&pd(zT,n,{originalEvent:s},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:Ke(()=>r.current=!0,"onFocusCapture"),onBlurCapture:Ke(()=>r.current=!1,"onBlurCapture")}}Ke(jy,"useFocusOutside");function ch(){const e=new CustomEvent(lh);document.dispatchEvent(e)}Ke(ch,"dispatchUpdate");function pd(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?hd(i,s):i.dispatchEvent(s)}Ke(pd,"handleAndDispatchCustomEvent");var WT=Object.defineProperty,ht=(e,t)=>WT(e,"name",{value:t,configurable:!0}),Uc="focusScope.autoFocusOnMount",Kc="focusScope.autoFocusOnUnmount",im={bubbles:!1,cancelable:!0},qT=m.forwardRef(ht(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:s,onUnmountAutoFocus:o,...a}=t,[l,c]=m.useState(null),u=Qe(s),h=Qe(o),f=m.useRef(null),d=Ae(n,c),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(i){let y=function(S){if(p.paused||!l)return;const C=S.target;l.contains(C)?f.current=C:Vn(f.current,{select:!0})},x=function(S){if(p.paused||!l)return;const C=S.relatedTarget;C!==null&&(l.contains(C)||Vn(f.current,{select:!0}))},b=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Vn(l)};ht(y,"handleFocusIn"),ht(x,"handleFocusOut"),ht(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,p.paused]),m.useEffect(()=>{if(l){sm.add(p);const y=document.activeElement;if(!l.contains(y)){const x=new CustomEvent(Uc,im);l.addEventListener(Uc,u),l.dispatchEvent(x),x.defaultPrevented||(_y($y(md(l)),{select:!0}),document.activeElement===y&&Vn(l))}return()=>{l.removeEventListener(Uc,u),setTimeout(()=>{const x=new CustomEvent(Kc,im);l.addEventListener(Kc,h),l.dispatchEvent(x),x.defaultPrevented||Vn(y??document.body,{select:!0}),l.removeEventListener(Kc,h),sm.remove(p)},0)}}},[l,u,h,p]);const v=m.useCallback(y=>{if(!r&&!i||p.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]=By(w);S&&C?!y.shiftKey&&b===C?(y.preventDefault(),r&&Vn(S,{select:!0})):y.shiftKey&&b===S&&(y.preventDefault(),r&&Vn(C,{select:!0})):b===w&&y.preventDefault()}},[r,i,p.paused]);return(0,g.jsx)(_e.div,{tabIndex:-1,...a,ref:d,onKeyDown:v})},"FocusScope"));function _y(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Vn(r,{select:t}),document.activeElement!==n)return}ht(_y,"focusFirst");function By(e){const t=md(e);return[uh(t,e),uh(t.reverse(),e)]}ht(By,"getTabbableEdges");function md(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:ht(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}ht(md,"getTabbableCandidates");function uh(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Vy(r,{upTo:t})))return r}ht(uh,"findVisible");function Vy(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}ht(Vy,"isHidden");function Fy(e){return e instanceof HTMLInputElement&&"select"in e}ht(Fy,"isSelectableInput");function Vn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Fy(e)&&t&&e.select()}}ht(Vn,"focus");var sm=zy();function zy(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=hh(e,t),e.unshift(t)},remove(t){e=hh(e,t),e[0]?.resume()}}}ht(zy,"createFocusScopesStack");function hh(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}ht(hh,"arrayRemove");function $y(e){return e.filter(t=>t.tagName!=="A")}ht($y,"removeLinks");var UT=Object.defineProperty,KT=(e,t)=>UT(e,"name",{value:t,configurable:!0}),Hy=m.forwardRef(KT(function(t,n){const{container:r,...i}=t,[s,o]=m.useState(!1);Dt(()=>o(!0),[]);const a=r||s&&globalThis?.document?.body;return a?_o.createPortal((0,g.jsx)(_e.div,{...i,ref:n}),a):null},"Portal")),GT=Object.defineProperty,gd=(e,t)=>GT(e,"name",{value:t,configurable:!0}),sa=0,mi=null;function QT(e){return vd(),e.children}gd(QT,"FocusGuards");function vd(){m.useEffect(()=>{mi||(mi={start:fh(),end:fh()});const{start:e,end:t}=mi;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),sa++,()=>{sa===1&&(mi?.start.remove(),mi?.end.remove(),mi=null),sa=Math.max(0,sa-1)}},[])}gd(vd,"useFocusGuards");function fh(){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}gd(fh,"createFocusGuard");var bn=function(){return bn=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},bn.apply(this,arguments)};function Wy(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 XT(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 za="right-scroll-bar-position",$a="width-before-scroll-bar",YT="with-scroll-bars-hidden",JT="--removed-body-scroll-bar-size";function Gc(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function ZT(e,t){var n=(0,m.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 eA=typeof window<"u"?m.useLayoutEffect:m.useEffect,om=new WeakMap;function tA(e,t){var n=ZT(t||null,function(r){return e.forEach(function(i){return Gc(i,r)})});return eA(function(){var r=om.get(n);if(r){var i=new Set(r),s=new Set(e),o=n.current;i.forEach(function(a){s.has(a)||Gc(a,null)}),s.forEach(function(a){i.has(a)||Gc(a,o)})}om.set(n,e)},[e]),n}function nA(e){return e}function rA(e,t){t===void 0&&(t=nA);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 iA(e){e===void 0&&(e={});var t=rA(null);return t.options=bn({async:!0,ssr:!1},e),t}var qy=function(e){var t=e.sideCar,n=Wy(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 m.createElement(r,bn({},n))};qy.isSideCarExport=!0;function sA(e,t){return e.useMedium(t),qy}var Uy=iA(),Qc=function(){},nc=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Qc,onWheelCapture:Qc,onTouchMoveCapture:Qc}),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,p=e.noIsolation,v=e.inert,y=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,w=e.gapMode,S=Wy(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,T=tA([n,t]),k=bn(bn({},S),i);return m.createElement(m.Fragment,null,u&&m.createElement(C,{sideCar:Uy,removeScrollBar:c,shards:h,noRelative:d,noIsolation:p,inert:v,setCallbacks:s,allowPinchZoom:!!y,lockRef:n,gapMode:w}),o?m.cloneElement(m.Children.only(a),bn(bn({},k),{ref:T})):m.createElement(b,bn({},k,{className:l,ref:T}),a))});nc.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};nc.classNames={fullWidth:$a,zeroRight:za};var am,oA=function(){if(am)return am;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function aA(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=oA();return t&&e.setAttribute("nonce",t),e}function lA(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function cA(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}var uA=function(){var e=0,t=null;return{add:function(n){e==0&&(t=aA())&&(lA(t,n),cA(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},hA=function(){var e=uA();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ky=function(){var e=hA(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},fA={left:0,top:0,right:0,gap:0},Xc=function(e){return parseInt(e||"",10)||0},dA=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[Xc(n),Xc(r),Xc(i)]},pA=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return fA;var t=dA(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])}},mA=Ky(),Qs="data-scroll-locked",gA=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(YT,` {
3
+ overflow: hidden `).concat(r,`;
4
+ padding-right: `).concat(a,"px ").concat(r,`;
5
+ }
6
+ body[`).concat(Qs,`] {
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(za,` {
20
+ right: `).concat(a,"px ").concat(r,`;
21
+ }
22
+
23
+ .`).concat($a,` {
24
+ margin-right: `).concat(a,"px ").concat(r,`;
25
+ }
26
+
27
+ .`).concat(za," .").concat(za,` {
28
+ right: 0 `).concat(r,`;
29
+ }
30
+
31
+ .`).concat($a," .").concat($a,` {
32
+ margin-right: 0 `).concat(r,`;
33
+ }
34
+
35
+ body[`).concat(Qs,`] {
36
+ `).concat(JT,": ").concat(a,`px;
37
+ }
38
+ `)},lm=function(){var e=parseInt(document.body.getAttribute("data-scroll-locked")||"0",10);return isFinite(e)?e:0},vA=function(){m.useEffect(function(){return document.body.setAttribute(Qs,(lm()+1).toString()),function(){var e=lm()-1;e<=0?document.body.removeAttribute(Qs):document.body.setAttribute(Qs,e.toString())}},[])},yA=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;vA();var s=m.useMemo(function(){return pA(i)},[i]);return m.createElement(mA,{styles:gA(s,!t,i,n?"":"!important")})},dh=!1;if(typeof window<"u")try{var oa=Object.defineProperty({},"passive",{get:function(){return dh=!0,!0}});window.addEventListener("test",oa,oa),window.removeEventListener("test",oa,oa)}catch{dh=!1}var gi=dh?{passive:!1}:!1,xA=function(e){return e.tagName==="TEXTAREA"},Gy=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!xA(e)&&n[t]==="visible")},bA=function(e){return Gy(e,"overflowY")},wA=function(e){return Gy(e,"overflowX")},cm=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host),Qy(e,r)){var i=Xy(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},SA=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},kA=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Qy=function(e,t){return e==="v"?bA(t):wA(t)},Xy=function(e,t){return e==="v"?SA(t):kA(t)},CA=function(e,t){return e==="h"&&t==="rtl"?-1:1},TA=function(e,t,n,r,i){var s=CA(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=Xy(e,a),p=d[0],v=d[1]-d[2]-s*p;(p||v)&&Qy(e,a)&&(h+=v,f+=p);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},aa=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},um=function(e){return[e.deltaX,e.deltaY]},hm=function(e){return e&&"current"in e?e.current:e},AA=function(e,t){return e[0]===t[0]&&e[1]===t[1]},RA=function(e){return`
39
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
40
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
41
+ `)},MA=0,vi=[];function PA(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),i=m.useState(MA++)[0],s=m.useState(Ky)[0],o=m.useRef(e);m.useEffect(function(){o.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var v=XT([e.lockRef.current],(e.shards||[]).map(hm),!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=m.useCallback(function(v,y){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var x=aa(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,T=v.target,k=Math.abs(w)>Math.abs(S)?"h":"v";if("touches"in v&&k==="h"&&T.type==="range")return!1;var A=window.getSelection(),E=A&&A.anchorNode;if(E&&(E===T||E.contains(T)))return!1;var R=cm(k,T);if(!R)return!0;if(R?C=k:(C=k==="v"?"h":"v",R=cm(k,T)),!R)return!1;if(!r.current&&"changedTouches"in v&&(w||S)&&(r.current=C),!C)return!0;var O=r.current||C;return TA(O,y,v,O==="h"?w:S,!0)},[]),l=m.useCallback(function(v){var y=v;if(!(!vi.length||vi[vi.length-1]!==s)){var x="deltaY"in y?um(y):aa(y),b=t.current.filter(function(S){return S.name===y.type&&(S.target===y.target||y.target===S.shadowParent)&&AA(S.delta,x)})[0];if(b&&b.should){y.cancelable&&y.preventDefault();return}if(!b){var w=(o.current.shards||[]).map(hm).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=m.useCallback(function(v,y,x,b){var w={name:v,delta:y,target:x,should:b,shadowParent:EA(x)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(S){return S!==w})},1)},[]),u=m.useCallback(function(v){n.current=aa(v),r.current=void 0},[]),h=m.useCallback(function(v){c(v.type,um(v),v.target,a(v,e.lockRef.current))},[]),f=m.useCallback(function(v){c(v.type,aa(v),v.target,a(v,e.lockRef.current))},[]);m.useEffect(function(){return vi.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",l,gi),document.addEventListener("touchmove",l,gi),document.addEventListener("touchstart",u,gi),function(){vi=vi.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,gi),document.removeEventListener("touchmove",l,gi),document.removeEventListener("touchstart",u,gi)}},[]);var d=e.removeScrollBar,p=e.inert;return m.createElement(m.Fragment,null,p?m.createElement(s,{styles:RA(i)}):null,d?m.createElement(yA,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function EA(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var OA=sA(Uy,PA),Yy=m.forwardRef(function(e,t){return m.createElement(nc,bn({},e,{ref:t,sideCar:OA}))});Yy.classNames=nc.classNames;var IA=function(e){return typeof document>"u"?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},yi=new WeakMap,la=new WeakMap,ca={},Yc=0,Jy=function(e){return e&&(e.host||Jy(e.parentNode))},DA=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Jy(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})},NA=function(e,t,n,r){var i=DA(t,Array.isArray(e)?e:[e]);ca[n]||(ca[n]=new WeakMap);var s=ca[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),p=d!==null&&d!=="false",v=(yi.get(f)||0)+1,y=(s.get(f)||0)+1;yi.set(f,v),s.set(f,y),o.push(f),v===1&&p&&la.set(f,!0),y===1&&f.setAttribute(n,"true"),p||f.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",f,x)}})};return u(t),a.clear(),Yc++,function(){o.forEach(function(h){var f=yi.get(h)-1,d=s.get(h)-1;yi.set(h,f),s.set(h,d),f||(la.has(h)||h.removeAttribute(r),la.delete(h)),d||h.removeAttribute(n)}),Yc--,Yc||(yi=new WeakMap,yi=new WeakMap,la=new WeakMap,ca={})}},LA=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||IA(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),NA(r,i,n,"aria-hidden")):function(){return null}},jA=Object.defineProperty,_A=(e,t)=>jA(e,"name",{value:t,configurable:!0});function Zy(e){const[t,n]=m.useState(void 0);return Dt(()=>{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}_A(Zy,"useSize");var BA=["top","right","bottom","left"],br=Math.min,Xn=Math.max,bl=Math.round,ua=Math.floor,Yn=e=>({x:e,y:e}),VA={left:"right",right:"left",bottom:"top",top:"bottom"};function ex(e,t,n){return Xn(e,br(t,n))}function tr(e,t){return typeof e=="function"?e(t):e}function wr(e){return e.split("-")[0]}function ds(e){return e.split("-")[1]}function yd(e){return e==="x"?"y":"x"}function xd(e){return e==="y"?"height":"width"}function kn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function bd(e){return yd(kn(e))}function FA(e,t,n){n===void 0&&(n=!1);const r=ds(e),i=bd(e),s=xd(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=wl(o)),[o,wl(o)]}function zA(e){const t=wl(e);return[ph(e),t,ph(t)]}function ph(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var fm=["left","right"],dm=["right","left"],$A=["top","bottom"],HA=["bottom","top"];function WA(e,t,n){switch(e){case"top":case"bottom":return n?t?dm:fm:t?fm:dm;case"left":case"right":return t?$A:HA;default:return[]}}function qA(e,t,n,r){const i=ds(e);let s=WA(wr(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(ph)))),s}function wl(e){const t=wr(e);return VA[t]+e.slice(t.length)}function UA(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 tx(e){return typeof e!="number"?UA(e):{top:e,right:e,bottom:e,left:e}}function Sl(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 pm(e,t,n){let{reference:r,floating:i}=e;const s=kn(t),o=bd(t),a=xd(o),l=wr(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 p=ds(t);return p&&(d[o]+=f*(p==="end"?1:-1)*(n&&c?-1:1)),d}async function KA(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}=tr(t,e),p=tx(d),v=a[f?h==="floating"?"reference":"floating":h],y=Sl(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=Sl(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:b,strategy:l}):x);return{top:(y.top-S.top+p.top)/w.y,bottom:(S.bottom-y.bottom+p.bottom)/w.y,left:(y.left-S.left+p.left)/w.x,right:(S.right-y.right+p.right)/w.x}}var GA=50,QA=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:KA},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}=pm(c,r,l),f=r,d=0;const p={};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:T}=await b({x:u,y:h,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:c,platform:a,elements:{reference:e,floating:t}});u=w??u,h=S??h,p[x]={...p[x],...C},T&&d<GA&&(d++,typeof T=="object"&&(T.placement&&(f=T.placement),T.rects&&(c=T.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):T.rects),{x:u,y:h}=pm(c,f,l)),v=-1)}return{x:u,y:h,placement:f,strategy:i,middlewareData:p}},XA=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}=tr(e,t)||{};if(c==null)return{};const h=tx(u),f={x:n,y:r},d=bd(i),p=xd(d),v=await o.getDimensions(c),y=d==="y",x=y?"top":"left",b=y?"bottom":"right",w=y?"clientHeight":"clientWidth",S=s.reference[p]+s.reference[d]-f[d]-s.floating[p],C=f[d]-s.reference[d],T=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let k=T?T[w]:0;(!k||!await(o.isElement==null?void 0:o.isElement(T)))&&(k=a.floating[w]||s.floating[p]);const A=S/2-C/2,E=k/2-v[p]/2-1,R=br(h[x],E),O=br(h[b],E),M=k-v[p]-O,j=k/2-v[p]/2+A,N=ex(R,j,M),P=!l.arrow&&ds(i)!=null&&j!==N&&s.reference[p]/2-(j<R?R:O)-v[p]/2<0,L=P?j<R?j-R:j-M:0;return{[d]:f[d]+L,data:{[d]:N,centerOffset:j-N-L,...P&&{alignmentOffset:L}},reset:P}}}),YA=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:p="none",flipAlignment:v=!0,...y}=tr(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=wr(i),b=kn(a),w=wr(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=f||(w||!v?[wl(a)]:zA(a)),T=p!=="none";!f&&T&&C.push(...qA(a,v,p,S));const k=[a,...C],A=await l.detectOverflow(t,y),E=[];let R=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&E.push(A[x]),h){const N=FA(i,o,S);E.push(A[N[0]],A[N[1]])}if(R=[...R,{placement:i,overflows:E}],!E.every(N=>N<=0)){var O,M;const N=(((O=s.flip)==null?void 0:O.index)||0)+1,P=k[N];if(P&&(!(h==="alignment"&&b!==kn(P))||R.every(B=>kn(B.placement)===b?B.overflows[0]>0:!0)))return{data:{index:N,overflows:R},reset:{placement:P}};let L=(M=R.filter(B=>B.overflows[0]<=0).sort((B,H)=>B.overflows[1]-H.overflows[1])[0])==null?void 0:M.placement;if(!L)switch(d){case"bestFit":{var j;const B=(j=R.filter(H=>{if(T){const V=kn(H.placement);return V===b||V==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(V=>V>0).reduce((V,I)=>V+I,0)]).sort((H,V)=>H[1]-V[1])[0])==null?void 0:j[0];B&&(L=B);break}case"initialPlacement":L=a}if(i!==L)return{reset:{placement:L}}}return{}}}};function mm(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function gm(e){return BA.some(t=>e[t]>=0)}var JA=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=tr(e,t);switch(i){case"referenceHidden":{const o=mm(await r.detectOverflow(t,{...s,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:gm(o)}}}case"escaped":{const o=mm(await r.detectOverflow(t,{...s,altBoundary:!0}),n.floating);return{data:{escapedOffsets:o,escaped:gm(o)}}}default:return{}}}}},nx=new Set(["left","top"]);async function ZA(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=wr(n),a=ds(n),l=kn(n)==="y",c=nx.has(o)?-1:1,u=s&&l?-1:1,h=tr(t,e);let{mainAxis:f,crossAxis:d,alignmentAxis:p}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof p=="number"&&(d=a==="end"?p*-1:p),l?{x:d*u,y:f*c}:{x:f*c,y:d*u}}var eR=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 ZA(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}}}}},tR=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}=tr(e,t),u={x:n,y:r},h=await s.detectOverflow(t,c),f=kn(i),d=yd(f);let p=u[d],v=u[f];const y=(b,w)=>ex(w+h[b==="y"?"top":"left"],w,w-h[b==="y"?"bottom":"right"]);o&&(p=y(d,p)),a&&(v=y(f,v));const x=l.fn({...t,[d]:p,[f]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[d]:o,[f]:a}}}}}},nR=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}=tr(e,t),f={x:i,y:s},d=kn(o),p=yd(d);let v=f[p],y=f[d];const x=tr(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=p==="y"?"height":"width",T=a.reference[p]-a.floating[C]+b.mainAxis,k=a.reference[p]+a.reference[C]-b.mainAxis;v<T?v=T:v>k&&(v=k)}if(h){var w,S;const C=p==="y"?"width":"height",T=nx.has(wr(o)),k=a.reference[d]-a.floating[C]+(T&&((w=l.offset)==null?void 0:w[d])||0)+(T?0:b.crossAxis),A=a.reference[d]+a.reference[C]+(T?0:((S=l.offset)==null?void 0:S[d])||0)-(T?b.crossAxis:0);y<k?y=k:y>A&&(y=A)}return{[p]:v,[d]:y}}}},rR=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}=tr(e,t),l=await i.detectOverflow(t,a),c=wr(n),u=ds(n),h=kn(n)==="y",{width:f,height:d}=r.floating;let p,v;c==="top"||c==="bottom"?(p=c,v=u===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(v=c,p=u==="end"?"top":"bottom");const y=d-l.top-l.bottom,x=f-l.left-l.right,b=br(d-l[p],y),w=br(f-l[v],x),S=t.middlewareData.shift,C=!S;let T=b,k=w;S!=null&&S.enabled.x&&(k=x),S!=null&&S.enabled.y&&(T=y),C&&!u&&(h?k=f-2*Xn(l.left,l.right):T=d-2*Xn(l.top,l.bottom)),await o({...t,availableWidth:k,availableHeight:T});const A=await i.getDimensions(s.floating);return f!==A.width||d!==A.height?{reset:{rects:!0}}:{}}}};function rc(){return typeof window<"u"}function ps(e){return rx(e)?(e.nodeName||"").toLowerCase():"#document"}function xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ir(e){var t;return(t=(rx(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function rx(e){return rc()?e instanceof Node||e instanceof xt(e).Node:!1}function En(e){return rc()?e instanceof Element||e instanceof xt(e).Element:!1}function Er(e){return rc()?e instanceof HTMLElement||e instanceof xt(e).HTMLElement:!1}function vm(e){return!rc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xt(e).ShadowRoot}function ic(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=On(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function iR(e){return/^(table|td|th)$/.test(ps(e))}function sc(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var sR=/transform|translate|scale|rotate|perspective|filter/,oR=/paint|layout|strict|content/,Lr=e=>!!e&&e!=="none",Jc;function wd(e){const t=En(e)?On(e):e;return Lr(t.transform)||Lr(t.translate)||Lr(t.scale)||Lr(t.rotate)||Lr(t.perspective)||!Sd()&&(Lr(t.backdropFilter)||Lr(t.filter))||sR.test(t.willChange||"")||oR.test(t.contain||"")}function aR(e){let t=ri(e);for(;Er(t)&&!uo(t);){if(wd(t))return t;if(sc(t))return null;t=ri(t)}return null}function Sd(){return Jc==null&&(Jc=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Jc}function uo(e){return/^(html|body|#document)$/.test(ps(e))}function On(e){return xt(e).getComputedStyle(e)}function oc(e){return En(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ri(e){if(ps(e)==="html")return e;const t=e.assignedSlot||e.parentNode||vm(e)&&e.host||ir(e);return vm(t)?t.host:t}function ix(e){const t=ri(e);return uo(t)?(e.ownerDocument||e).body:Er(t)&&ic(t)?t:ix(t)}function ho(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=ix(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=xt(i);if(s){const a=mh(o);return t.concat(o,o.visualViewport||[],ic(i)?i:[],a&&n?ho(a):[])}else return t.concat(i,ho(i,[],n))}function mh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sx(e){const t=On(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Er(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=bl(n)!==s||bl(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function kd(e){return En(e)?e:e.contextElement}function zi(e){const t=kd(e);if(!Er(t))return Yn(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=sx(t);let o=(s?bl(n.width):n.width)/r,a=(s?bl(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}var lR=Yn(0);function ox(e){const t=xt(e);return!Sd()||!t.visualViewport?lR:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function cR(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===xt(e)}function ii(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=kd(e);let o=Yn(1);t&&(r?En(r)&&(o=zi(r)):o=zi(e));const a=cR(s,n,r)?ox(s):Yn(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=xt(s),d=En(r)?xt(r):r;let p=f,v=mh(p);for(;v&&d!==p;){const y=zi(v),x=v.getBoundingClientRect(),b=On(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,p=xt(v),v=mh(p)}}return Sl({width:u,height:h,x:l,y:c})}function ac(e,t){const n=oc(e).scrollLeft;return t?t.left+n:ii(ir(e)).left+n}function ax(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ac(e,n),y:n.top+t.scrollTop}}function uR(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=ir(r),a=t?sc(t.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Yn(1);const u=Yn(0),h=Er(r);if((h||!s)&&((ps(r)!=="body"||ic(o))&&(l=oc(r)),h)){const d=ii(r);c=zi(r),u.x=d.x+r.clientLeft,u.y=d.y+r.clientTop}const f=o&&!h&&!s?ax(o,l):Yn(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 hR(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function fR(e){const t=oc(e),n=e.ownerDocument.body,r=Xn(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Xn(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+ac(e);const o=-t.scrollTop;return On(n).direction==="rtl"&&(s+=Xn(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:s,y:o}}var dR=25;function pR(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=xt(e),s=ir(e),o=i.visualViewport;let a=s.clientWidth,l=s.clientHeight,c=0,u=0;if(o){const h=!Sd()||t==="fixed";r?h||(c=-o.offsetLeft,u=-o.offsetTop):(a=o.width,l=o.height,h&&(c=o.offsetLeft,u=o.offsetTop))}if(ac(s)<=0){const h=s.ownerDocument,f=h.body,d=getComputedStyle(f),p=h.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,v=Math.abs(s.clientWidth-f.clientWidth-p),y=getComputedStyle(s).scrollbarGutter==="stable both-edges"?v/2:v;y<=dR&&(a-=y)}return{width:a,height:l,x:c,y:u}}function mR(e,t){const n=ii(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=zi(e);return{width:e.clientWidth*s.x,height:e.clientHeight*s.y,x:i*s.x,y:r*s.y}}function ym(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=pR(e,n,t);else if(t==="document")r=fR(ir(e));else if(En(t))r=mR(t,n);else{const i=ox(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Sl(r)}function gR(e,t){const n=t.get(e);if(n)return n;let r=ho(e,[],!1).filter(a=>En(a)&&ps(a)!=="body"),i=null;const s=On(e).position==="fixed";let o=s?ri(e):e;for(;En(o)&&!uo(o);){const a=On(o),l=wd(o),c=i?i.position:s?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?r=r.filter(u=>u!==o):i=a,o=ri(o)}return t.set(e,r),r}function vR(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const s=[...n==="clippingAncestors"?sc(t)?[]:gR(t,this._c):[].concat(n),r],o=ym(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=ym(t,s[h],i);a=Xn(f.top,a),l=br(f.right,l),c=br(f.bottom,c),u=Xn(f.left,u)}return{width:l-u,height:c-a,x:u,y:a}}function yR(e){const{width:t,height:n}=sx(e);return{width:t,height:n}}function xR(e,t,n){const r=Er(t),i=ir(t),s=n==="fixed",o=ii(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Yn(0);if((r||!s)&&((ps(t)!=="body"||ic(i))&&(a=oc(t)),r)){const u=ii(t,!0,s,t);l.x=u.x+t.clientLeft,l.y=u.y+t.clientTop}!r&&i&&(l.x=ac(i));const c=i&&!r&&!s?ax(i,a):Yn(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 Zc(e){return On(e).position==="static"}function xm(e,t){if(!Er(e)||On(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ir(e)===n&&(n=n.ownerDocument.body),n}function lx(e,t){const n=xt(e);if(sc(e))return n;if(!Er(e)){let i=ri(e);for(;i&&!uo(i);){if(En(i)&&!Zc(i))return i;i=ri(i)}return n}let r=xm(e,t);for(;r&&iR(r)&&Zc(r);)r=xm(r,t);return r&&uo(r)&&Zc(r)&&!wd(r)?n:r||aR(e)||n}var bR=async function(e){const t=this.getOffsetParent||lx,n=this.getDimensions,r=await n(e.floating);return{reference:xR(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function wR(e){return On(e).direction==="rtl"}var SR={convertOffsetParentRelativeRectToViewportRelativeRect:uR,getDocumentElement:ir,getClippingRect:vR,getOffsetParent:lx,getElementRects:bR,getClientRects:hR,getDimensions:yR,getScale:zi,isElement:En,isRTL:wR};function cx(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function kR(e,t,n){let r=null,i;const s=ir(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:p,width:v,height:y}=f;if(u||t(),!v||!y)return;const x=ua(p),b=ua(s.clientWidth-(d+v)),w=ua(s.clientHeight-(p+y)),S=ua(d),C={rootMargin:-x+"px "+-b+"px "+-w+"px "+-S+"px",threshold:Xn(0,br(1,h))||1};let T=!0;function k(A){const E=A[0].intersectionRatio;if(!cx(f,e.getBoundingClientRect()))return a();if(E!==h){if(!T)return a();E?a(!1,E):i=setTimeout(()=>{a(!1,1e-7)},1e3)}T=!1}try{r=new IntersectionObserver(k,{...C,root:s.ownerDocument})}catch{r=new IntersectionObserver(k,C)}r.observe(e)}const l=xt(e),c=()=>a(n);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),o()}}function CR(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=kd(e),u=i||s?[...c?ho(c):[],...t?ho(t):[]]:[];u.forEach(x=>{i&&x.addEventListener("scroll",n),s&&x.addEventListener("resize",n)});const h=c&&a?kR(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 p,v=l?ii(e):null;l&&y();function y(){const x=ii(e);v&&!cx(v,x)&&n(),v=x,p=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(p)}}var TR=eR,AR=tR,RR=YA,MR=rR,PR=JA,bm=XA,ER=nR,OR=(e,t,n)=>{const r=new Map,i=n??{},s={...SR,...i.platform,_c:r};return QA(e,t,{...i,platform:s})},Ha=typeof document<"u"?m.useLayoutEffect:function(){};function kl(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(!kl(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)&&!kl(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function ux(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function wm(e,t){const n=ux(e);return Math.round(t*n)/n}function eu(e){const t=m.useRef(e);return Ha(()=>{t.current=e}),t}function IR(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]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,d]=m.useState(r);kl(f,r)||d(r);const[p,v]=m.useState(null),[y,x]=m.useState(null),b=m.useCallback(H=>{H!==T.current&&(T.current=H,v(H))},[]),w=m.useCallback(H=>{H!==k.current&&(k.current=H,x(H))},[]),S=s||p,C=o||y,T=m.useRef(null),k=m.useRef(null),A=m.useRef(u),E=l!=null,R=eu(l),O=eu(i),M=eu(c),j=m.useCallback(()=>{if(!T.current||!k.current)return;const H={placement:t,strategy:n,middleware:f};O.current&&(H.platform=O.current),OR(T.current,k.current,H).then(V=>{const I={...V,isPositioned:M.current!==!1};N.current&&!kl(A.current,I)&&(A.current=I,_o.flushSync(()=>{h(I)}))})},[f,t,n,O,M]);Ha(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,h(H=>({...H,isPositioned:!1})))},[c]);const N=m.useRef(!1);Ha(()=>(N.current=!0,()=>{N.current=!1}),[]),Ha(()=>{if(S&&(T.current=S),C&&(k.current=C),S&&C){if(R.current)return R.current(S,C,j);j()}},[S,C,j,R,E]);const P=m.useMemo(()=>({reference:T,floating:k,setReference:b,setFloating:w}),[b,w]),L=m.useMemo(()=>({reference:S,floating:C}),[S,C]),B=m.useMemo(()=>{const H={position:n,left:0,top:0};if(!L.floating)return H;const V=wm(L.floating,u.x),I=wm(L.floating,u.y);return a?{...H,transform:"translate("+V+"px, "+I+"px)",...ux(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:I}},[n,a,L.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:j,refs:P,elements:L,floatingStyles:B}),[u,j,P,L,B])}var DR=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?bm({element:r.current,padding:i}).fn(n):{}:r?bm({element:r,padding:i}).fn(n):{}}}},NR=(e,t)=>{const n=TR(e);return{name:n.name,fn:n.fn,options:[e,t]}},LR=(e,t)=>{const n=AR(e);return{name:n.name,fn:n.fn,options:[e,t]}},jR=(e,t)=>({fn:ER(e).fn,options:[e,t]}),_R=(e,t)=>{const n=RR(e);return{name:n.name,fn:n.fn,options:[e,t]}},BR=(e,t)=>{const n=MR(e);return{name:n.name,fn:n.fn,options:[e,t]}},VR=(e,t)=>{const n=PR(e);return{name:n.name,fn:n.fn,options:[e,t]}},FR=(e,t)=>{const n=DR(e);return{name:n.name,fn:n.fn,options:[e,t]}},zR=Object.defineProperty,$R=(e,t)=>zR(e,"name",{value:t,configurable:!0}),HR=m.forwardRef($R(function(t,n){const{children:r,width:i=10,height:s=5,...o}=t;return(0,g.jsx)(_e.svg,{...o,ref:n,width:i,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:(0,g.jsx)("polygon",{points:"0,0 30,0 15,10"})})},"Arrow")),WR=HR,qR=Object.defineProperty,Jn=(e,t)=>qR(e,"name",{value:t,configurable:!0}),hx="Popper",[fx,lc]=rr(hx),[UR,dx]=fx(hx),KR=Jn(e=>{const{__scopePopper:t,children:n}=e,[r,i]=m.useState(null),[s,o]=m.useState(void 0);return(0,g.jsx)(UR,{scope:t,anchor:r,onAnchorChange:i,placementState:s,setPlacementState:o,children:n})},"Popper"),GR="PopperAnchor",QR=m.forwardRef(Jn(function(t,n){const{__scopePopper:r,virtualRef:i,...s}=t,o=dx(GR,r),a=m.useRef(null),l=o.onAnchorChange,c=m.useCallback(v=>{a.current=v,v&&l(v)},[l]),u=Ae(n,c),h=m.useRef(null);m.useEffect(()=>{if(!i)return;const v=h.current;h.current=i.current,v!==h.current&&l(h.current)});const f=o.placementState&&cc(o.placementState),d=f?.[0],p=f?.[1];return i?null:(0,g.jsx)(_e.div,{"data-radix-popper-side":d,"data-radix-popper-align":p,...s,ref:u})},"PopperAnchor")),px="PopperContent",[XR,YR]=fx(px),JR=m.forwardRef(Jn(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:p="optimized",onPlaced:v,...y}=t,x=dx(px,r),[b,w]=m.useState(null),S=Ae(n,w),[C,T]=m.useState(null),k=Zy(C),A=k?.width??0,E=k?.height??0,R=i+(o!=="center"?"-"+o:""),O=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(u)?u:[u],j=M.length>0,N={padding:O,boundary:M.filter(mx),altBoundary:j},{refs:P,floatingStyles:L,placement:B,isPositioned:H,middlewareData:V}=IR({strategy:"fixed",placement:R,whileElementsMounted:Jn((...ae)=>CR(...ae,{animationFrame:p==="always"}),"whileElementsMounted"),elements:{reference:x.anchor},middleware:[NR({mainAxis:s+E,alignmentAxis:a}),c&&LR({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?jR():void 0,...N}),c&&_R({...N}),BR({...N,apply:Jn(({elements:ae,rects:he,availableWidth:se,availableHeight:Ye})=>{const{width:Le,height:rt}=he.reference,qe=ae.floating.style;qe.setProperty("--radix-popper-available-width",`${se}px`),qe.setProperty("--radix-popper-available-height",`${Ye}px`),qe.setProperty("--radix-popper-anchor-width",`${Le}px`),qe.setProperty("--radix-popper-anchor-height",`${rt}px`)},"apply")}),C&&FR({element:C,padding:l}),nM({arrowWidth:A,arrowHeight:E}),d&&VR({strategy:"referenceHidden",...N,boundary:j?N.boundary:void 0})]}),I=x.setPlacementState;Dt(()=>(I(B),()=>{I(void 0)}),[B,I]);const[ne,re]=cc(B),_=Qe(v);Dt(()=>{H&&_?.()},[H,_]);const U=V.arrow?.x,K=V.arrow?.y,G=V.arrow?.centerOffset!==0,[$,J]=m.useState();return Dt(()=>{b&&J(window.getComputedStyle(b).zIndex)},[b]),(0,g.jsx)("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:H?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[V.transformOrigin?.x,V.transformOrigin?.y].join(" "),...V.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:(0,g.jsx)(XR,{scope:r,placedSide:ne,placedAlign:re,onArrowChange:T,arrowX:U,arrowY:K,shouldHideArrow:G,children:(0,g.jsx)(_e.div,{"data-side":ne,"data-align":re,...y,ref:S,style:{...y.style,animation:H?y.style?.animation:"none"}})})})},"PopperContent")),ZR="PopperArrow",eM={top:"bottom",right:"left",bottom:"top",left:"right"},tM=m.forwardRef(Jn(function(t,n){const{__scopePopper:r,...i}=t,s=YR(ZR,r),o=eM[s.placedSide];return(0,g.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,g.jsx)(WR,{...i,ref:n,style:{...i.style,display:"block"}})})},"PopperArrow"));function mx(e){return e!==null}Jn(mx,"isNotNull");var nM=Jn(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]=cc(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="",p="";return l==="bottom"?(d=s?u:`${h}px`,p=`${-a}px`):l==="top"?(d=s?u:`${h}px`,p=`${r.floating.height+a}px`):l==="right"?(d=`${-a}px`,p=s?u:`${f}px`):l==="left"&&(d=`${r.floating.width+a}px`,p=s?u:`${f}px`),{data:{x:d,y:p}}}}),"transformOrigin");function cc(e){const[t,n="center"]=e.split("-");return[t,n]}Jn(cc,"getSideAndAlignFromPlacement");var Cd=KR,gx=QR,vx=JR,rM=tM,iM=Object.defineProperty,Td=(e,t)=>iM(e,"name",{value:t,configurable:!0}),tu=!1;function yx(){const[e,t]=m.useState(tu);return m.useEffect(()=>{tu||(tu=!0,t(!0))},[]),e}Td(yx,"useIsHydrated");var xx=m[" useSyncExternalStore ".trim().toString()];function bx(){return()=>{}}Td(bx,"subscribe");function wx(){return xx(bx,()=>!0,()=>!1)}Td(wx,"useIsHydratedModern");var sM=typeof xx=="function"?wx:yx,oM=Object.defineProperty,hi=(e,t)=>oM(e,"name",{value:t,configurable:!0}),nu="rovingFocusGroup.onEntryFocus",aM={bubbles:!1,cancelable:!0},uc="RovingFocusGroup",[gh,Sx,lM]=fd(uc),[cM,kx]=rr(uc,[lM]),[uM,hM]=cM(uc),fM=m.forwardRef(hi(function(t,n){return(0,g.jsx)(gh.Provider,{scope:t.__scopeRovingFocusGroup,children:(0,g.jsx)(gh.Slot,{scope:t.__scopeRovingFocusGroup,children:(0,g.jsx)(dM,{...t,ref:n})})})},"RovingFocusGroup")),dM=m.forwardRef(hi(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=m.useRef(null),p=Ae(n,d),v=tc(o),[y,x]=Vo({prop:a,defaultProp:l??null,onChange:c,caller:uc}),[b,w]=m.useState(!1),S=Qe(u),C=Sx(r),T=m.useRef(!1),[k,A]=m.useState(0);return m.useEffect(()=>{const E=d.current;if(E)return E.addEventListener(nu,S),()=>E.removeEventListener(nu,S)},[S]),(0,g.jsx)(uM,{scope:r,orientation:i,dir:v,loop:s,currentTabStopId:y,onItemFocus:m.useCallback(E=>x(E),[x]),onItemShiftTab:m.useCallback(()=>w(!0),[]),onFocusableItemAdd:m.useCallback(()=>A(E=>E+1),[]),onFocusableItemRemove:m.useCallback(()=>A(E=>E-1),[]),children:(0,g.jsx)(_e.div,{tabIndex:b||k===0?-1:0,"data-orientation":i,...f,ref:p,style:{outline:"none",...t.style},onMouseDown:te(t.onMouseDown,()=>{T.current=!0}),onFocus:te(t.onFocus,E=>{const R=!T.current;if(E.target===E.currentTarget&&R&&!b){const O=new CustomEvent(nu,aM);if(E.currentTarget.dispatchEvent(O),!O.defaultPrevented){const M=C().filter(j=>j.focusable);Ad([M.find(j=>j.active),M.find(j=>j.id===y),...M].filter(Boolean).map(j=>j.ref.current),h)}}T.current=!1}),onBlur:te(t.onBlur,()=>w(!1))})})},"RovingFocusGroupImpl")),pM="RovingFocusGroupItem",mM=m.forwardRef(hi(function(t,n){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:s=!1,tabStopId:o,children:a,...l}=t,c=ni(),u=o||c,h=hM(pM,r),f=h.currentTabStopId===u,d=Sx(r),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:y}=h,x=sM();return Dt(()=>{if(!(!x||!i))return p(),()=>v()},[x,i,p,v]),m.useEffect(()=>{if(!(x||!i))return p(),()=>v()},[x,i,p,v]),(0,g.jsx)(gh.ItemSlot,{scope:r,id:u,focusable:i,active:s,children:(0,g.jsx)(_e.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=Tx(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?Ax(S,C+1):S.slice(C+1)}setTimeout(()=>Ad(S))}}),children:typeof a=="function"?a({isCurrentTabStop:f,hasTabStop:y!=null}):a})})},"RovingFocusGroupItem")),gM={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Cx(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}hi(Cx,"getDirectionAwareKey");function Tx(e,t,n){const r=Cx(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return gM[r]}hi(Tx,"getFocusIntent");function Ad(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}hi(Ad,"focusFirst");function Ax(e,t){return e.map((n,r)=>e[(t+r)%e.length])}hi(Ax,"wrapArray");var vM=fM,yM=mM,xM=Object.defineProperty,pe=(e,t)=>xM(e,"name",{value:t,configurable:!0}),vh=["Enter"," "],bM=["ArrowDown","PageUp","Home"],Rx=["ArrowUp","PageDown","End"],wM=[...bM,...Rx],SM={ltr:[...vh,"ArrowRight"],rtl:[...vh,"ArrowLeft"]},kM={ltr:["ArrowLeft"],rtl:["ArrowRight"]},hc="Menu",[fo,CM,TM]=fd(hc),[fi,Mx]=rr(hc,[TM,lc,kx]),fc=lc(),Px=kx(),[Ex,Or]=fi(hc),[AM,Fo]=fi(hc),RM=pe(e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=fc(t),[l,c]=m.useState(null),u=m.useRef(!1),h=Qe(s),f=tc(i);return m.useEffect(()=>{const d=pe(()=>{u.current=!0,document.addEventListener("pointerdown",p,{capture:!0,once:!0}),document.addEventListener("pointermove",p,{capture:!0,once:!0})},"handleKeyDown"),p=pe(()=>u.current=!1,"handlePointer");return document.addEventListener("keydown",d,{capture:!0}),()=>{document.removeEventListener("keydown",d,{capture:!0}),document.removeEventListener("pointerdown",p,{capture:!0}),document.removeEventListener("pointermove",p,{capture:!0})}},[]),m.useEffect(()=>{if(!n)return;const d=pe(()=>h(!1),"handleBlur");return window.addEventListener("blur",d),()=>window.removeEventListener("blur",d)},[n,h]),(0,g.jsx)(Cd,{...a,children:(0,g.jsx)(Ex,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:(0,g.jsx)(AM,{scope:t,onClose:m.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},"Menu"),Ox=m.forwardRef(pe(function(t,n){const{__scopeMenu:r,...i}=t,s=fc(r);return(0,g.jsx)(gx,{...s,...i,ref:n})},"MenuAnchor")),Ix="MenuPortal",[MM,Dx]=fi(Ix,{forceMount:void 0}),PM=pe(e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Or(Ix,t);return(0,g.jsx)(MM,{scope:t,forceMount:n,children:(0,g.jsx)(Nn,{present:n||s.open,children:(0,g.jsx)(Hy,{asChild:!0,container:i,children:r})})})},"MenuPortal"),Jt="MenuContent",[EM,Rd]=fi(Jt),OM=m.forwardRef(pe(function(t,n){const r=Dx(Jt,t.__scopeMenu),{forceMount:i=r.forceMount,...s}=t,o=Or(Jt,t.__scopeMenu),a=Fo(Jt,t.__scopeMenu);return(0,g.jsx)(fo.Provider,{scope:t.__scopeMenu,children:(0,g.jsx)(Nn,{present:i||o.open,children:(0,g.jsx)(fo.Slot,{scope:t.__scopeMenu,children:a.modal?(0,g.jsx)(IM,{...s,ref:n}):(0,g.jsx)(DM,{...s,ref:n})})})})},"MenuContent")),IM=m.forwardRef(pe(function(t,n){const r=Or(Jt,t.__scopeMenu),i=m.useRef(null),s=Ae(n,i);return m.useEffect(()=>{const o=i.current;if(o)return LA(o)},[]),(0,g.jsx)(Md,{...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")),DM=m.forwardRef(pe(function(t,n){const r=Or(Jt,t.__scopeMenu);return(0,g.jsx)(Md,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),NM=Xi("MenuContent.ScrollLock"),Md=m.forwardRef(pe(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:p,disableOutsideScroll:v,...y}=t,x=Or(Jt,r),b=Fo(Jt,r),w=fc(r),S=Px(r),C=CM(r),[T,k]=m.useState(null),A=m.useRef(null),E=Ae(n,A,x.onContentChange),R=m.useRef(0),O=m.useRef(""),M=m.useRef(0),j=m.useRef(null),N=m.useRef("right"),P=m.useRef(0),L=v?Yy:m.Fragment,B=v?{as:NM,allowPinchZoom:!0}:void 0,H=pe(I=>{const ne=O.current+I,re=C().filter($=>!$.disabled),_=document.activeElement,U=re.find($=>$.ref.current===_)?.textValue,K=zx(re.map($=>$.textValue),ne,U),G=re.find($=>$.textValue===K)?.ref.current;pe((function $(J){O.current=J,window.clearTimeout(R.current),J!==""&&(R.current=window.setTimeout(()=>$(""),1e3))}),"updateSearch")(ne),G&&setTimeout(()=>G.focus())},"handleTypeaheadSearch");m.useEffect(()=>()=>window.clearTimeout(R.current),[]),vd();const V=m.useCallback(I=>N.current===j.current?.side&&Hx(I,j.current?.area),[]);return(0,g.jsx)(EM,{scope:r,searchRef:O,onItemEnter:m.useCallback(I=>{V(I)&&I.preventDefault()},[V]),onItemLeave:m.useCallback(I=>{V(I)||(A.current?.focus(),k(null))},[V]),onTriggerLeave:m.useCallback(I=>{V(I)&&I.preventDefault()},[V]),pointerGraceTimerRef:M,onPointerGraceIntentChange:m.useCallback(I=>{j.current=I},[]),children:(0,g.jsx)(L,{...B,children:(0,g.jsx)(qT,{asChild:!0,trapped:s,onMountAutoFocus:te(o,I=>{I.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:(0,g.jsx)(Ny,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:d,onDismiss:p,children:(0,g.jsx)(vM,{asChild:!0,...S,dir:b.dir,orientation:"vertical",loop:i,currentTabStopId:T,onCurrentTabStopIdChange:k,onEntryFocus:te(c,I=>{b.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,g.jsx)(vx,{role:"menu","aria-orientation":"vertical","data-state":Ed(x.open),"data-radix-menu-content":"",dir:b.dir,...w,...y,ref:E,style:{outline:"none",...y.style},onKeyDown:te(y.onKeyDown,I=>{const ne=I.target.closest("[data-radix-menu-content]")===I.currentTarget,re=I.ctrlKey||I.altKey||I.metaKey,_=I.key.length===1;ne&&(I.key==="Tab"&&I.preventDefault(),!re&&_&&H(I.key));const U=A.current;if(I.target!==U||!wM.includes(I.key))return;I.preventDefault();const K=C().filter(G=>!G.disabled).map(G=>G.ref.current);Rx.includes(I.key)&&K.reverse(),Vx(K)}),onBlur:te(t.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(R.current),O.current="")}),onPointerMove:te(t.onPointerMove,Yi(I=>{const ne=I.target,re=P.current!==I.clientX;if(I.currentTarget.contains(ne)&&re){const _=I.clientX>P.current?"right":"left";N.current=_,P.current=I.clientX}}))})})})})})})},"MenuContentImpl")),LM=m.forwardRef(pe(function(t,n){const{__scopeMenu:r,...i}=t;return(0,g.jsx)(_e.div,{role:"group",...i,ref:n})},"MenuGroup")),jM=m.forwardRef(pe(function(t,n){const{__scopeMenu:r,...i}=t;return(0,g.jsx)(_e.div,{...i,ref:n})},"MenuLabel")),yh="MenuItem",Sm="menu.itemSelect",Pd=m.forwardRef(pe(function(t,n){const{disabled:r=!1,onSelect:i,...s}=t,o=m.useRef(null),a=Fo(yh,t.__scopeMenu),l=Rd(yh,t.__scopeMenu),c=Ae(n,o),u=m.useRef(!1),h=pe(()=>{const f=o.current;if(!r&&f){const d=new CustomEvent(Sm,{bubbles:!0,cancelable:!0});f.addEventListener(Sm,p=>i?.(p),{once:!0}),hd(f,d),d.defaultPrevented?u.current=!1:a.onClose()}},"handleSelect");return(0,g.jsx)(Nx,{...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===" "||vh.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})},"MenuItem")),Nx=m.forwardRef(pe(function(t,n){const{__scopeMenu:r,disabled:i=!1,textValue:s,...o}=t,a=Rd(yh,r),l=Px(r),c=m.useRef(null),u=Ae(n,c),[h,f]=m.useState(!1),[d,p]=m.useState("");return m.useEffect(()=>{const v=c.current;v&&p((v.textContent??"").trim())},[o.children]),(0,g.jsx)(fo.ItemSlot,{scope:r,disabled:i,textValue:s??d,children:(0,g.jsx)(yM,{asChild:!0,...l,focusable:!i,children:(0,g.jsx)(_e.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,Yi(v=>{i?a.onItemLeave(v):(a.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:te(t.onPointerLeave,Yi(v=>a.onItemLeave(v))),onFocus:te(t.onFocus,()=>f(!0)),onBlur:te(t.onBlur,()=>f(!1))})})})},"MenuItemImpl")),_M=m.forwardRef(pe(function(t,n){const{checked:r=!1,onCheckedChange:i,...s}=t;return(0,g.jsx)(jx,{scope:t.__scopeMenu,checked:r,children:(0,g.jsx)(Pd,{role:"menuitemcheckbox","aria-checked":po(r)?"mixed":r,...s,ref:n,"data-state":dc(r),onSelect:te(s.onSelect,()=>i?.(po(r)?!0:!r),{checkForDefaultPrevented:!1})})})},"MenuCheckboxItem")),[BM,VM]=fi("MenuRadioGroup",{value:void 0,onValueChange:pe(()=>{},"onValueChange")}),FM=m.forwardRef(pe(function(t,n){const{value:r,onValueChange:i,...s}=t,o=Qe(i);return(0,g.jsx)(BM,{scope:t.__scopeMenu,value:r,onValueChange:o,children:(0,g.jsx)(LM,{...s,ref:n})})},"MenuRadioGroup")),zM="MenuRadioItem",$M=m.forwardRef(pe(function(t,n){const{value:r,...i}=t,s=VM(zM,t.__scopeMenu),o=r===s.value;return(0,g.jsx)(jx,{scope:t.__scopeMenu,checked:o,children:(0,g.jsx)(Pd,{role:"menuitemradio","aria-checked":o,...i,ref:n,"data-state":dc(o),onSelect:te(i.onSelect,()=>s.onValueChange?.(r),{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),Lx="MenuItemIndicator",[jx,HM]=fi(Lx,{checked:!1}),WM=m.forwardRef(pe(function(t,n){const{__scopeMenu:r,forceMount:i,...s}=t,o=HM(Lx,r);return(0,g.jsx)(Nn,{present:i||po(o.checked)||o.checked===!0,children:(0,g.jsx)(_e.span,{...s,ref:n,"data-state":dc(o.checked)})})},"MenuItemIndicator")),qM=m.forwardRef(pe(function(t,n){const{__scopeMenu:r,...i}=t;return(0,g.jsx)(_e.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})},"MenuSeparator")),_x="MenuSub",[UM,Bx]=fi(_x),KM=pe(e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=Or(_x,t),o=fc(t),[a,l]=m.useState(null),[c,u]=m.useState(null),h=Qe(i);return m.useEffect(()=>(s.open===!1&&h(!1),()=>h(!1)),[s.open,h]),(0,g.jsx)(Cd,{...o,children:(0,g.jsx)(Ex,{scope:t,open:r,onOpenChange:h,content:c,onContentChange:u,children:(0,g.jsx)(UM,{scope:t,contentId:ni(),triggerId:ni(),trigger:a,onTriggerChange:l,children:n})})})},"MenuSub"),ha="MenuSubTrigger",GM=m.forwardRef(pe(function(t,n){const r=Or(ha,t.__scopeMenu),i=Fo(ha,t.__scopeMenu),s=Bx(ha,t.__scopeMenu),o=Rd(ha,t.__scopeMenu),a=m.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=o,u={__scopeMenu:t.__scopeMenu},h=m.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);m.useEffect(()=>h,[h]),m.useEffect(()=>{const d=l.current;return()=>{window.clearTimeout(d),c(null)}},[l,c]);const f=Ae(n,s.onTriggerChange);return(0,g.jsx)(Ox,{asChild:!0,...u,children:(0,g.jsx)(Nx,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?s.contentId:void 0,"data-state":Ed(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,Yi(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,Yi(d=>{h();const p=r.content?.getBoundingClientRect();if(p){const v=r.content?.dataset.side,y=v==="right",x=y?-5:5,b=p[y?"left":"right"],w=p[y?"right":"left"];o.onPointerGraceIntentChange({area:[{x:d.clientX+x,y:d.clientY},{x:b,y:p.top},{x:w,y:p.top},{x:w,y:p.bottom},{x:b,y:p.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===" "||SM[i.dir].includes(d.key)&&(r.onOpenChange(!0),r.content?.focus(),d.preventDefault())})})})},"MenuSubTrigger")),QM="MenuSubContent",XM=m.forwardRef(pe(function(t,n){const r=Dx(Jt,t.__scopeMenu),{forceMount:i=r.forceMount,align:s="start",...o}=t,a=Or(Jt,t.__scopeMenu),l=Fo(Jt,t.__scopeMenu),c=Bx(QM,t.__scopeMenu),u=m.useRef(null),h=Ae(n,u);return(0,g.jsx)(fo.Provider,{scope:t.__scopeMenu,children:(0,g.jsx)(Nn,{present:i||a.open,children:(0,g.jsx)(fo.Slot,{scope:t.__scopeMenu,children:(0,g.jsx)(Md,{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),p=kM[l.dir].includes(f.key);d&&p&&(a.onOpenChange(!1),c.trigger?.focus(),f.preventDefault())})})})})})},"MenuSubContent"));function Ed(e){return e?"open":"closed"}pe(Ed,"getOpenState");function po(e){return e==="indeterminate"}pe(po,"isIndeterminate");function dc(e){return po(e)?"indeterminate":e?"checked":"unchecked"}pe(dc,"getCheckedState");function Vx(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}pe(Vx,"focusFirst");function Fx(e,t){return e.map((n,r)=>e[(t+r)%e.length])}pe(Fx,"wrapArray");function zx(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=Fx(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}pe(zx,"getNextMatch");function $x(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}pe($x,"isPointInPolygon");function Hx(e,t){return t?$x({x:e.clientX,y:e.clientY},t):!1}pe(Hx,"isPointerInGraceArea");function Yi(e){return t=>t.pointerType==="mouse"?e(t):void 0}pe(Yi,"whenMouse");var YM=RM,JM=Ox,ZM=PM,eP=OM,tP=jM,nP=Pd,rP=_M,iP=FM,sP=$M,oP=WM,aP=qM,lP=KM,cP=GM,uP=XM,hP=Object.defineProperty,wt=(e,t)=>hP(e,"name",{value:t,configurable:!0}),Od="DropdownMenu",[fP,YH]=rr(Od,[Mx]),St=Mx(),[dP,Wx]=fP(Od),pP=wt(e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=St(t),c=m.useRef(null),[u,h]=Vo({prop:i,defaultProp:s??!1,onChange:o,caller:Od});return(0,g.jsx)(dP,{scope:t,triggerId:ni(),triggerRef:c,contentId:ni(),open:u,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(f=>!f),[h]),modal:a,children:(0,g.jsx)(YM,{...l,open:u,onOpenChange:h,dir:r,modal:a,children:n})})},"DropdownMenu"),mP="DropdownMenuTrigger",gP=m.forwardRef(wt(function(t,n){const{__scopeDropdownMenu:r,disabled:i=!1,...s}=t,o=Wx(mP,r),a=St(r),l=Ae(n,o.triggerRef);return(0,g.jsx)(JM,{asChild:!0,...a,children:(0,g.jsx)(_e.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")),vP=wt(e=>{const{__scopeDropdownMenu:t,...n}=e,r=St(t);return(0,g.jsx)(ZM,{...r,...n})},"DropdownMenuPortal"),yP="DropdownMenuContent",xP=m.forwardRef(wt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=Wx(yP,r),o=St(r),a=m.useRef(!1);return(0,g.jsx)(eP,{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")),bP=m.forwardRef(wt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=St(r);return(0,g.jsx)(tP,{...s,...i,ref:n})},"DropdownMenuLabel")),wP=m.forwardRef(wt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=St(r);return(0,g.jsx)(nP,{...s,...i,ref:n})},"DropdownMenuItem")),SP=m.forwardRef(wt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=St(r);return(0,g.jsx)(rP,{...s,...i,ref:n})},"DropdownMenuCheckboxItem")),kP=m.forwardRef(wt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=St(r);return(0,g.jsx)(iP,{...s,...i,ref:n})},"DropdownMenuRadioGroup")),CP=m.forwardRef(wt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=St(r);return(0,g.jsx)(sP,{...s,...i,ref:n})},"DropdownMenuRadioItem")),TP=m.forwardRef(wt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=St(r);return(0,g.jsx)(oP,{...s,...i,ref:n})},"DropdownMenuItemIndicator")),AP=m.forwardRef(wt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=St(r);return(0,g.jsx)(aP,{...s,...i,ref:n})},"DropdownMenuSeparator")),RP=wt(e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=St(t),[a,l]=Vo({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return(0,g.jsx)(lP,{...o,open:a,onOpenChange:l,children:n})},"DropdownMenuSub"),MP=m.forwardRef(wt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=St(r);return(0,g.jsx)(cP,{...s,...i,ref:n})},"DropdownMenuSubTrigger")),PP=m.forwardRef(wt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=St(r);return(0,g.jsx)(uP,{...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")),EP=pP,OP=gP,IP=vP,DP=xP,NP=bP,LP=wP,jP=SP,_P=kP,BP=CP,qx=TP,VP=AP,FP=RP,zP=MP,$P=PP,HP=Object.defineProperty,WP=(e,t)=>HP(e,"name",{value:t,configurable:!0});function Ux(e,[t,n]){return Math.min(n,Math.max(t,e))}WP(Ux,"clamp");var qP=Object.defineProperty,de=(e,t)=>qP(e,"name",{value:t,configurable:!0});function Kx(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}de(Kx,"useStateMachine");var Gx="ScrollArea",[Qx,JH]=rr(Gx),[UP,zt]=Qx(Gx),KP=m.forwardRef(de(function(t,n){const{__scopeScrollArea:r,type:i="hover",dir:s,scrollHideDelay:o=600,...a}=t,[l,c]=m.useState(null),[u,h]=m.useState(null),[f,d]=m.useState(null),[p,v]=m.useState(null),[y,x]=m.useState(null),[b,w]=m.useState(0),[S,C]=m.useState(0),[T,k]=m.useState(!1),[A,E]=m.useState(!1),R=Ae(n,c),O=tc(s);return(0,g.jsx)(UP,{scope:r,type:i,dir:O,scrollHideDelay:o,scrollArea:l,viewport:u,onViewportChange:h,content:f,onContentChange:d,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:T,onScrollbarXEnabledChange:k,scrollbarY:y,onScrollbarYChange:x,scrollbarYEnabled:A,onScrollbarYEnabledChange:E,onCornerWidthChange:w,onCornerHeightChange:C,children:(0,g.jsx)(_e.div,{dir:O,...a,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":S+"px",...t.style}})})},"ScrollArea")),GP="ScrollAreaViewport",QP=m.forwardRef(de(function(t,n){const{__scopeScrollArea:r,children:i,nonce:s,...o}=t,a=zt(GP,r),l=m.useRef(null),c=Ae(n,l,a.onViewportChange);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(XP,{nonce:s}),(0,g.jsx)(_e.div,{"data-radix-scroll-area-viewport":"",...o,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...t.style},children:(0,g.jsx)("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})},"ScrollAreaViewport")),XP=m.memo(de(function({nonce:t}){return(0,g.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),sr="ScrollAreaScrollbar",YP=m.forwardRef(de(function(t,n){const{forceMount:r,...i}=t,s=zt(sr,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:a}=s,l=t.orientation==="horizontal";return m.useEffect(()=>(l?o(!0):a(!0),()=>{l?o(!1):a(!1)}),[l,o,a]),s.type==="hover"?(0,g.jsx)(JP,{...i,ref:n,forceMount:r}):s.type==="scroll"?(0,g.jsx)(ZP,{...i,ref:n,forceMount:r}):s.type==="auto"?(0,g.jsx)(Xx,{...i,ref:n,forceMount:r}):s.type==="always"?(0,g.jsx)(Id,{...i,ref:n,"data-state":"visible"}):null},"ScrollAreaScrollbar")),JP=m.forwardRef(de(function(t,n){const{forceMount:r,...i}=t,s=zt(sr,t.__scopeScrollArea),[o,a]=m.useState(!1);return m.useEffect(()=>{const l=s.scrollArea;let c=0;if(l){const u=de(()=>{window.clearTimeout(c),a(!0)},"handlePointerEnter"),h=de(()=>{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,g.jsx)(Nn,{present:r||o,children:(0,g.jsx)(Xx,{"data-state":o?"visible":"hidden",...i,ref:n})})},"ScrollAreaScrollbarHover")),ZP=m.forwardRef(de(function(t,n){const{forceMount:r,...i}=t,s=zt(sr,t.__scopeScrollArea),o=t.orientation==="horizontal",a=$o(()=>c("SCROLL_END"),100),[l,c]=Kx("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 m.useEffect(()=>{if(l==="idle"){const u=window.setTimeout(()=>c("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(u)}},[l,s.scrollHideDelay,c]),m.useEffect(()=>{const u=s.viewport,h=o?"scrollLeft":"scrollTop";if(u){let f=u[h];const d=de(()=>{const p=u[h];f!==p&&(c("SCROLL"),a()),f=p},"handleScroll");return u.addEventListener("scroll",d),()=>u.removeEventListener("scroll",d)}},[s.viewport,o,c,a]),(0,g.jsx)(Nn,{present:r||l!=="hidden",children:(0,g.jsx)(Id,{"data-state":l==="hidden"?"hidden":"visible",...i,ref:n,onPointerEnter:te(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:te(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})},"ScrollAreaScrollbarScroll")),Xx=m.forwardRef(de(function(t,n){const r=zt(sr,t.__scopeScrollArea),{forceMount:i,...s}=t,[o,a]=m.useState(!1),l=t.orientation==="horizontal",c=$o(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,h=r.viewport.offsetHeight<r.viewport.scrollHeight;a(l?u:h)}},10);return si(r.viewport,c),si(r.content,c),(0,g.jsx)(Nn,{present:i||o,children:(0,g.jsx)(Id,{"data-state":o?"visible":"hidden",...s,ref:n})})},"ScrollAreaScrollbarAuto")),Id=m.forwardRef(de(function(t,n){const{orientation:r="vertical",...i}=t,s=zt(sr,t.__scopeScrollArea),o=m.useRef(null),a=m.useRef(0),[l,c]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Dd(l.viewport,l.content),h={...i,sizes:l,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:de(d=>o.current=d,"onThumbChange"),onThumbPointerUp:de(()=>a.current=0,"onThumbPointerUp"),onThumbPointerDown:de(d=>a.current=d,"onThumbPointerDown")};function f(d,p){return eb(d,a.current,l,p)}return de(f,"getScrollPosition"),r==="horizontal"?(0,g.jsx)(eE,{...h,ref:n,onThumbPositionChange:()=>{if(s.viewport&&o.current){const d=s.viewport.scrollLeft,p=bh(d,l,s.dir);o.current.style.transform=`translate3d(${p}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,g.jsx)(tE,{...h,ref:n,onThumbPositionChange:()=>{if(s.viewport&&o.current){const d=s.viewport.scrollTop,p=bh(d,l);o.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:d=>{s.viewport&&(s.viewport.scrollTop=d)},onDragScroll:d=>{s.viewport&&(s.viewport.scrollTop=f(d))}}):null},"ScrollAreaScrollbarVisible")),eE=m.forwardRef(de(function(t,n){const{sizes:r,onSizesChange:i,...s}=t,o=zt(sr,t.__scopeScrollArea),[a,l]=m.useState(),c=m.useRef(null),u=Ae(n,c,o.onScrollbarXChange);return m.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,g.jsx)(Jx,{"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":zo(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),Ld(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:mo(a.paddingLeft),paddingEnd:mo(a.paddingRight)}})}})},"ScrollAreaScrollbarX")),tE=m.forwardRef(de(function(t,n){const{sizes:r,onSizesChange:i,...s}=t,o=zt(sr,t.__scopeScrollArea),[a,l]=m.useState(),c=m.useRef(null),u=Ae(n,c,o.onScrollbarYChange);return m.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,g.jsx)(Jx,{"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":zo(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),Ld(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:mo(a.paddingTop),paddingEnd:mo(a.paddingBottom)}})}})},"ScrollAreaScrollbarY")),[nE,Yx]=Qx(sr),Jx=m.forwardRef(de(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,p=zt(sr,r),[v,y]=m.useState(null),x=Ae(n,y),b=m.useRef(null),w=m.useRef(""),S=p.viewport,C=i.content-i.viewport,T=Qe(h),k=Qe(c),A=$o(f,10);function E(R){if(b.current){const O=R.clientX-b.current.left,M=R.clientY-b.current.top;u({x:O,y:M})}}return de(E,"handleDragScroll"),m.useEffect(()=>{const R=de(O=>{const M=O.target;v?.contains(M)&&T(O,C)},"handleWheel");return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,C,T]),m.useEffect(k,[i,k]),si(v,A),si(p.content,A),(0,g.jsx)(nE,{scope:r,scrollbar:v,hasThumb:s,onThumbChange:Qe(o),onThumbPointerUp:Qe(a),onThumbPositionChange:k,onThumbPointerDown:Qe(l),children:(0,g.jsx)(_e.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",p.viewport&&(p.viewport.style.scrollBehavior="auto"),E(R))}),onPointerMove:te(t.onPointerMove,E),onPointerUp:te(t.onPointerUp,R=>{const O=R.target;O.hasPointerCapture(R.pointerId)&&O.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),b.current=null})})})},"ScrollAreaScrollbarImpl")),xh="ScrollAreaThumb",rE=m.forwardRef(de(function(t,n){const{forceMount:r,...i}=t,s=Yx(xh,t.__scopeScrollArea);return(0,g.jsx)(Nn,{present:r||s.hasThumb,children:(0,g.jsx)(iE,{ref:n,...i})})},"ScrollAreaThumb")),iE=m.forwardRef(de(function(t,n){const{__scopeScrollArea:r,style:i,...s}=t,o=zt(xh,r),a=Yx(xh,r),{onThumbPositionChange:l}=a,c=Ae(n,a.onThumbChange),u=m.useRef(void 0),h=$o(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=o.viewport;if(f){const d=de(()=>{if(h(),!u.current){const p=aE(f,l);u.current=p,l()}},"handleScroll");return l(),f.addEventListener("scroll",d),()=>f.removeEventListener("scroll",d)}},[o.viewport,h,l]),(0,g.jsx)(_e.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(),p=f.clientX-d.left,v=f.clientY-d.top;a.onThumbPointerDown({x:p,y:v})}),onPointerUp:te(t.onPointerUp,a.onThumbPointerUp)})},"ScrollAreaThumbImpl")),Zx="ScrollAreaCorner",sE=m.forwardRef(de(function(t,n){const r=zt(Zx,t.__scopeScrollArea),i=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&i?(0,g.jsx)(oE,{...t,ref:n}):null},"ScrollAreaCorner")),oE=m.forwardRef(de(function(t,n){const{__scopeScrollArea:r,...i}=t,s=zt(Zx,r),[o,a]=m.useState(0),[l,c]=m.useState(0),u=!!(o&&l),{onCornerWidthChange:h,onCornerHeightChange:f}=s;return si(s.scrollbarX,()=>{const d=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(d),c(d)}),si(s.scrollbarY,()=>{const d=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(d),a(d)}),m.useEffect(()=>()=>{h(0),f(0)},[h,f]),u?(0,g.jsx)(_e.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 mo(e){return e?parseInt(e,10):0}de(mo,"toInt");function Dd(e,t){const n=e/t;return isNaN(n)?0:n}de(Dd,"getThumbRatio");function zo(e){const t=Dd(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}de(zo,"getThumbSize");function eb(e,t,n,r="ltr"){const i=zo(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 Nd([l,c],h)(e)}de(eb,"getScrollPositionFromPointer");function bh(e,t,n="ltr"){const r=zo(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=Ux(e,l);return Nd([0,o],[0,a])(c)}de(bh,"getThumbOffsetFromScroll");function Nd(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])}}de(Nd,"linearScale");function Ld(e,t){return e>0&&e<t}de(Ld,"isScrollingWithinScrollbarBounds");var aE=de((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return de((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 $o(e,t){const n=Qe(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}de($o,"useDebounceCallback");function si(e,t){const n=Qe(t);Dt(()=>{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])}de(si,"useResizeObserver");var lE=KP,cE=QP,uE=sE,hE=Object.defineProperty,He=(e,t)=>hE(e,"name",{value:t,configurable:!0}),[jd,ZH]=rr("Tooltip",[lc]),pc=lc(),fE="TooltipProvider",dE=700,wh="tooltip.open",[pE,_d]=jd(fE),mE=He(e=>{const{__scopeTooltip:t,delayDuration:n=dE,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=m.useRef(!0),a=m.useRef(!1),l=m.useRef(0);return m.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),(0,g.jsx)(pE,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:m.useCallback(()=>{r<=0||(window.clearTimeout(l.current),o.current=!1)},[r]),onClose:m.useCallback(()=>{r<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:m.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})},"TooltipProvider"),Sh="Tooltip",[gE,Ho]=jd(Sh),vE=He(e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=_d(Sh,e.__scopeTooltip),c=pc(t),[u,h]=m.useState(null),[f,d]=m.useState(void 0),p=ni(),v=m.useRef(0),y=o??l.disableHoverableContent,x=a??l.delayDuration,b=m.useRef(!1),[w,S]=Vo({prop:r,defaultProp:i??!1,onChange:He(R=>{R?(l.onOpen(),document.dispatchEvent(new CustomEvent(wh))):l.onClose(),s?.(R)},"onChange"),caller:Sh}),C=m.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),T=m.useCallback(()=>{window.clearTimeout(v.current),v.current=0,b.current=!1,S(!0)},[S]),k=m.useCallback(()=>{window.clearTimeout(v.current),v.current=0,S(!1)},[S]),A=m.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{b.current=!0,S(!0),v.current=0},x)},[x,S]);m.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]);const E=f??p;return(0,g.jsx)(Cd,{...c,children:(0,g.jsx)(gE,{scope:t,contentId:E,setContentId:d,open:w,stateAttribute:C,trigger:u,onTriggerChange:h,onTriggerEnter:m.useCallback(()=>{l.isOpenDelayedRef.current?A():T()},[l.isOpenDelayedRef,A,T]),onTriggerLeave:m.useCallback(()=>{y?k():(window.clearTimeout(v.current),v.current=0)},[k,y]),onOpen:T,onClose:k,disableHoverableContent:y,children:n})})},"Tooltip"),km="TooltipTrigger",yE=m.forwardRef(He(function(t,n){const{__scopeTooltip:r,...i}=t,s=Ho(km,r),o=_d(km,r),a=pc(r),l=m.useRef(null),c=Ae(n,l,s.onTriggerChange),u=m.useRef(!1),h=m.useRef(!1),f=m.useCallback(()=>u.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),(0,g.jsx)(gx,{asChild:!0,...a,children:(0,g.jsx)(_e.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")),tb="TooltipPortal",[xE,bE]=jd(tb,{forceMount:void 0}),wE=He(e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Ho(tb,t);return(0,g.jsx)(xE,{scope:t,forceMount:n,children:(0,g.jsx)(Nn,{present:n||s.open,children:(0,g.jsx)(Hy,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),go="TooltipContent",SE=m.forwardRef(He(function(t,n){const r=bE(go,t.__scopeTooltip),{forceMount:i=r.forceMount,side:s="top",...o}=t,a=Ho(go,t.__scopeTooltip);return(0,g.jsx)(Nn,{present:i||a.open,children:a.disableHoverableContent?(0,g.jsx)(nb,{side:s,...o,ref:n}):(0,g.jsx)(kE,{side:s,...o,ref:n})})},"TooltipContent")),kE=m.forwardRef(He(function(t,n){const r=Ho(go,t.__scopeTooltip),i=_d(go,t.__scopeTooltip),s=m.useRef(null),o=Ae(n,s),[a,l]=m.useState(null),{trigger:c,onClose:u}=r,h=s.current,{onPointerInTransitChange:f}=i,d=m.useCallback(()=>{l(null),f(!1)},[f]),p=m.useCallback((v,y)=>{const x=v.currentTarget,b={x:v.clientX,y:v.clientY},w=ib(b,rb(b,x.getBoundingClientRect())),S=sb(y.getBoundingClientRect()),C=ab([...w,...S]);l(C),f(!0)},[f]);return m.useEffect(()=>()=>d(),[d]),m.useEffect(()=>{if(c&&h){const v=He(x=>p(x,h),"handleTriggerLeave"),y=He(x=>p(x,c),"handleContentLeave");return c.addEventListener("pointerleave",v),h.addEventListener("pointerleave",y),()=>{c.removeEventListener("pointerleave",v),h.removeEventListener("pointerleave",y)}}},[c,h,p,d]),m.useEffect(()=>{if(a){const v=He(y=>{const x=y.target,b={x:y.clientX,y:y.clientY},w=c?.contains(x)||h?.contains(x),S=!ob(b,a);w?d():S&&(d(),u())},"handleTrackPointerGrace");return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,h,a,u,d]),(0,g.jsx)(nb,{...t,ref:o})},"TooltipContentHoverable")),CE=nT("TooltipContent"),nb=m.forwardRef(He(function(t,n){const{__scopeTooltip:r,children:i,"aria-label":s,id:o,onEscapeKeyDown:a,onPointerDownOutside:l,...c}=t,u=Ho(go,r),h=pc(r),{onClose:f}=u;m.useEffect(()=>(document.addEventListener(wh,f),()=>document.removeEventListener(wh,f)),[f]),m.useEffect(()=>{if(u.trigger){const p=He(v=>{v.target instanceof Node&&v.target.contains(u.trigger)&&f()},"handleScroll");return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[u.trigger,f]);const{setContentId:d}=u;return Dt(()=>(d(o),()=>{d(void 0)}),[o,d]),(0,g.jsx)(Ny,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:p=>p.preventDefault(),onDismiss:f,children:(0,g.jsxs)(vx,{"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,g.jsx)(CE,{children:i}),s?(0,g.jsx)(vT,{id:u.contentId,role:"tooltip",children:s}):null]})})},"TooltipContentImpl")),TE=m.forwardRef(He(function(t,n){const{__scopeTooltip:r,...i}=t,s=pc(r);return(0,g.jsx)(rM,{...s,...i,ref:n})},"TooltipArrow"));function rb(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")}}He(rb,"getExitSideFromRect");function ib(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}He(ib,"getPaddedExitPoints");function sb(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}]}He(sb,"getPointsFromRect");function ob(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}He(ob,"isPointInPolygon");function ab(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),lb(t)}He(ab,"getHull");function lb(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)}He(lb,"getHullPresorted");var AE=mE,RE=vE,ME=yE,PE=wE,EE=SE,OE=TE,Cm="1.46.0",vo=Symbol.for("functionName"),IE=Symbol.for("toReferencePath");function DE(e){return e[IE]??null}function NE(e){return e.startsWith("function://")}function LE(e){let t;if(typeof e=="string")NE(e)?t={functionHandle:e}:t={name:e};else if(e[vo])t={name:e[vo]};else{const n=DE(e);if(!n)throw new Error(`${e} is not a functionReference`);t={reference:n}}return t}function ft(e){const t=LE(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[vo];if(!n)throw new Error(`${e} is not a functionReference`);return n}function Bd(e){return{[vo]:e}}function cb(e=[]){return new Proxy({},{get(t,n){if(typeof n=="string")return cb([...e,n]);if(n===vo){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 eW=cb(),jE=Object.defineProperty,_E=(e,t,n)=>t in e?jE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tm=(e,t,n)=>_E(e,typeof t!="symbol"?t+"":t,n),BE="color:rgb(0, 145, 255)";function ub(e){switch(e){case"query":return"Q";case"mutation":return"M";case"action":return"A";case"any":return"?"}}var hb=class{constructor(e){Tm(this,"_onLogLineFuncs"),Tm(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 fb(e){const t=new hb(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 db(e){return new hb(e)}function Cl(e,t,n,r,i){const s=ub(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}]`,BE,l)}else e.error(`[CONVEX ${s}(${r})] ${i}`)}function VE(e,t){const n=`[CONVEX FATAL ERROR] ${t}`;return e.error(n),new Error(n)}function Ii(e,t,n){return`[CONVEX ${ub(e)}(${t})] ${n.errorMessage}
42
+ Called by client`}function kh(e,t){return t.data=e.errorData,t}function oi(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 Xr(e,t){return JSON.stringify({udfPath:oi(e),args:Pn(t)})}function Am(e,t,n){const{initialNumItems:r,id:i}=n;return JSON.stringify({type:"paginated",udfPath:oi(e),args:Pn(t),options:Pn({initialNumItems:r,id:i})})}var FE=Object.defineProperty,zE=(e,t,n)=>t in e?FE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,un=(e,t,n)=>zE(e,typeof t!="symbol"?t+"":t,n),$E=class{constructor(){un(this,"nextQueryId"),un(this,"querySetVersion"),un(this,"querySet"),un(this,"queryIdToToken"),un(this,"identityVersion"),un(this,"auth"),un(this,"outstandingQueriesOlderThanRestart"),un(this,"outstandingAuthOlderThanRestart"),un(this,"paused"),un(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=oi(e),s=Xr(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:[Pn(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=oi(e),r=Xr(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:[Pn(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]}}}},HE=Object.defineProperty,WE=(e,t,n)=>t in e?HE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fa=(e,t,n)=>WE(e,typeof t!="symbol"?t+"":t,n),qE=class{constructor(e,t){this.logger=e,this.markConnectionStateDirty=t,fa(this,"inflightRequests"),fa(this,"requestsOlderThanRestart"),fa(this,"inflightMutationsCount",0),fa(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)Cl(this.logger,"info",n,r,a);const i=t.status;let s,o;if(e.success)s={success:!0,logLines:e.logLines,value:yl(e.result)},o=()=>i.onResult(s);else{const a=e.result,{errorData:l}=e;Cl(this.logger,"error",n,r,a),s={success:!1,errorMessage:a,errorData:l!==void 0?yl(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}},UE=Object.defineProperty,KE=(e,t,n)=>t in e?UE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tl=(e,t,n)=>KE(e,typeof t!="symbol"?t+"":t,n),Rm=class Ch{constructor(t){Tl(this,"queryResults"),Tl(this,"modifiedQueries"),this.queryResults=t,this.modifiedQueries=[]}getQuery(t,...n){const r=Fn(n[0]),i=ft(t),s=this.queryResults.get(Xr(i,r));if(s!==void 0)return Ch.queryValue(s.result)}getAllQueries(t){const n=[],r=ft(t);for(const i of this.queryResults.values())i.udfPath===oi(r)&&n.push({args:i.args,value:Ch.queryValue(i.result)});return n}setQuery(t,n,r){const i=Fn(n),s=ft(t),o=Xr(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}},GE=class{constructor(){Tl(this,"queryResults"),Tl(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 Rm(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 Rm(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?kh(n,new ih(Ii("query",t.udfPath,n))):new Error(Ii("query",t.udfPath,n))}}hasQueryResult(e){return this.queryResults.get(e)!==void 0}queryLogs(e){return this.queryResults.get(e)?.result?.logLines}},QE=Object.defineProperty,XE=(e,t,n)=>t in e?QE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ru=(e,t,n)=>XE(e,typeof t!="symbol"?t+"":t,n),Wo=class _n{constructor(t,n){ru(this,"low"),ru(this,"high"),ru(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 _n(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?Mm:t>=YE?JE:new _n(t%Xs|0,t/Xs|0)}toString(){return(BigInt(this.high)*BigInt(Xs)+BigInt(this.low)).toString()}equals(t){return _n.isLong(t)||(t=_n.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 _n.isLong(t)||(t=_n.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"?_n.fromNumber(t):new _n(t.low,t.high)}},Mm=new Wo(0,0),Pm=65536,Xs=Pm*Pm,YE=Xs*Xs,JE=new Wo(-1,-1),ZE=Object.defineProperty,eO=(e,t,n)=>t in e?ZE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,da=(e,t,n)=>eO(e,typeof t!="symbol"?t+"":t,n),Em=class{constructor(e,t){da(this,"version"),da(this,"remoteQuerySet"),da(this,"queryPath"),da(this,"logger"),this.version={querySet:0,ts:Wo.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)Cl(this.logger,"info","query",r,s);const i=yl(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)Cl(this.logger,"info","query",r,s);const{errorData:i}=n;this.remoteQuerySet.set(n.queryId,{success:!1,errorMessage:n.errorMessage,errorData:i!==void 0?yl(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 iu(e){const t=oT(e);return Wo.fromBytesLE(Array.from(t))}function tO(e){const t=new Uint8Array(e.toBytesLE());return iT(t)}function Om(e){switch(e.type){case"FatalError":case"AuthError":case"ActionResponse":case"TransitionChunk":case"Ping":return{...e};case"MutationResponse":return e.success?{...e,ts:iu(e.ts)}:{...e};case"Transition":return{...e,startVersion:{...e.startVersion,ts:iu(e.startVersion.ts)},endVersion:{...e.endVersion,ts:iu(e.endVersion.ts)}}}}function nO(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:tO(e.maxObservedTimestamp)}:{...e,maxObservedTimestamp:void 0}}}var rO=Object.defineProperty,iO=(e,t,n)=>t in e?rO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Be=(e,t,n)=>iO(e,typeof t!="symbol"?t+"":t,n),sO=1e3,oO=1001,aO=1005,lO=4040,Wa;function Ri(){return Wa===void 0&&(Wa=Date.now()),typeof performance>"u"||!performance.now?Date.now():Math.round(Wa+performance.now())}function Im(){return`t=${Math.round((Ri()-Wa)/100)/10}s`}var pb={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 cO(e){if(e===void 0)return"Unknown";for(const t of Object.keys(pb))if(e.startsWith(t))return t;return"Unknown"}var uO=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=Om(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:Ri()})),this.lastCloseReason!=="InitialConnect"&&(this.lastCloseReason?this.logger.log("WebSocket reconnected at",Im(),"after disconnect due to",this.lastCloseReason):this.logger.log("WebSocket reconnected at",Im())),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=Om(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!==sO&&t.code!==oO&&t.code!==aO&&t.code!==lO){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=cO(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=nO(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=Ri(),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=Ri()-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:Ri()})):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:pb[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=Ri()-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 hO(){return fO()}function fO(){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 js=class extends Error{};js.prototype.name="InvalidTokenError";function dO(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 pO(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 dO(t)}catch{return atob(t)}}function mb(e,t){if(typeof e!="string")throw new js("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 js(`Invalid token specified: missing part #${n+1}`);let i;try{i=pO(r)}catch(s){throw new js(`Invalid token specified: invalid base64 for part #${n+1} (${s.message})`)}try{return JSON.parse(i)}catch(s){throw new js(`Invalid token specified: invalid json for part #${n+1} (${s.message})`)}}var mO=Object.defineProperty,gO=(e,t,n)=>t in e?mO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yt=(e,t,n)=>gO(e,typeof t!="symbol"?t+"":t,n),vO=1728e6,Dm=2,yO=class{constructor(e,t,n){yt(this,"authState",{state:"noAuth"}),yt(this,"configVersion",0),yt(this,"syncState"),yt(this,"authenticate"),yt(this,"stopSocket"),yt(this,"tryRestartSocket"),yt(this,"pauseSocket"),yt(this,"resumeSocket"),yt(this,"clearAuth"),yt(this,"logger"),yt(this,"refreshTokenLeewaySeconds"),yt(this,"initialAuthTokenReuse"),yt(this,"lastRefreshChange"),yt(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>=Dm){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, ${Dm-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(vO,(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 mb(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}]`)}},xO=["convexClientConstructed","convexWebSocketOpen","convexFirstMessageReceived"];function bO(e,t){const n={sessionId:t};typeof performance>"u"||!performance.mark||performance.mark(e,{detail:n})}function wO(e){let t=e.name.slice(6);return t=t.charAt(0).toLowerCase()+t.slice(1),{name:t,startTime:e.startTime}}function SO(e){if(typeof performance>"u"||!performance.getEntriesByName)return[];const t=[];for(const n of xO){const r=performance.getEntriesByName(n).filter(i=>i.entryType==="mark").filter(i=>i.detail.sessionId===e);t.push(...r)}return t.map(wO)}var kO=Object.defineProperty,CO=(e,t,n)=>t in e?kO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ve=(e,t,n)=>CO(e,typeof t!="symbol"?t+"":t,n),TO=class{constructor(e,t,n){if(Ve(this,"address"),Ve(this,"state"),Ve(this,"requestManager"),Ve(this,"webSocketManager"),Ve(this,"authenticationManager"),Ve(this,"remoteQuerySet"),Ve(this,"optimisticQueryResults"),Ve(this,"_transitionHandlerCounter",0),Ve(this,"_nextRequestId"),Ve(this,"_onTransitionFns",new Map),Ve(this,"_sessionId"),Ve(this,"firstMessageReceived",!1),Ve(this,"debug"),Ve(this,"logger"),Ve(this,"maxObservedTimestamp"),Ve(this,"connectionStateSubscribers",new Map),Ve(this,"nextConnectionStateSubscriberId",0),Ve(this,"_lastPublishedConnectionState"),Ve(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)}})}),Ve(this,"mark",f=>{this.debug&&bO(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&&rT(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?db({verbose:n.verbose??!1}):n.logger!==!0&&n.logger?n.logger:fb({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/${Cm}/sync`;this.state=new $E,this.remoteQuerySet=new Em(f=>this.state.queryPath(f),this.logger),this.requestManager=new qE(this.logger,this.markConnectionStateDirty);const u=()=>{this.webSocketManager.pause(),this.state.pause()};this.authenticationManager=new yO(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 GE,this.addOnTransitionHandler(f=>{t(f.queries.map(d=>d.token))}),this._nextRequestId=0,this._sessionId=hO();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 uO(c,{onOpen:f=>{this.mark("convexWebSocketOpen"),this.webSocketManager.sendMessage({...f,type:"Connect",sessionId:this._sessionId,maxObservedTimestamp:this.maxObservedTimestamp}),this.remoteQuerySet=new Em(v=>this.state.queryPath(v),this.logger);const[d,p]=this.state.restart();p&&this.webSocketManager.sendMessage(p),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 p of this.requestManager.resume())this.webSocketManager.sendMessage(p)},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=VE(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?mb(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=Fn(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=Fn(t),r=Xr(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=Fn(t),r=Xr(e,n);return this.optimisticQueryResults.queryLogs(r)}queryJournal(e,t){const n=Fn(t),r=Xr(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?kh(r,new ih(Ii("mutation",e,r))):new Error(Ii("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=Fn(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:[Pn(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?kh(n,new ih(Ii("action",e,n))):new Error(Ii("action",e,n));return n.value}async actionInternal(e,t,n){const r=Fn(t),i=this.nextRequestId;this._nextRequestId++,this.tryReportLongDisconnect();const s={type:"Action",requestId:i,udfPath:e,componentPath:n,args:[Pn(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=SO(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-${Cm}`},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 su(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 AO=Object.defineProperty,RO=(e,t,n)=>t in e?AO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Nm=(e,t,n)=>RO(e,typeof t!="symbol"?t+"":t,n),MO=class{constructor(e,t){this.client=e,this.onTransition=t,Nm(this,"paginatedQuerySet",new Map),Nm(this,"lastTransitionTs"),this.lastTransitionTs=Wo.fromNumber(0),this.client.addOnTransitionHandler(n=>this.onBaseTransition(n))}subscribe(e,t,n){const r=oi(e),i=Am(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=oi(e),i=Am(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=su(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=su(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=su(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 PO({getCurrentValue:e,subscribe:t}){const[n,r]=(0,m.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,m.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 EO=Object.defineProperty,OO=(e,t,n)=>t in e?EO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jn=(e,t,n)=>OO(e,typeof t!="symbol"?t+"":t,n),IO=5e3;if(typeof m.default>"u")throw new Error("Required dependency 'react' not found");function gb(e,t,n){function r(i){return jO(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 ${ft(e)}`);return gb(e,t,s)},r}function DO(e,t){return function(n){return t.action(e,n)}}var tW=class{constructor(e,t){if(jn(this,"address"),jn(this,"cachedSync"),jn(this,"cachedPaginatedQueryClient"),jn(this,"listeners"),jn(this,"options"),jn(this,"closed",!1),jn(this,"_logger"),jn(this,"adminAuth"),jn(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?db({verbose:t?.verbose??!1}):t?.logger!==!0&&t?.logger?t.logger:fb({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 TO(this.address,()=>{},this.options),this.adminAuth&&this.cachedSync.setAdminAuth(this.adminAuth,this.fakeUserIdentity),this.cachedPaginatedQueryClient=new MO(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=ft(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??IO,n=this.watchQuery(e.query,e.args||{}).onUpdate(()=>{});setTimeout(n,t)}watchPaginatedQuery(e,t,n){const r=ft(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=ft(e);return this.sync.mutation(i,n,r)}action(e,...t){const n=ft(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()}}},mc=m.createContext(void 0);function NO(){return(0,m.useContext)(mc)}var nW=({client:e,children:t})=>m.createElement(mc.Provider,{value:e},t);function LO(e,...t){const n=t[0]==="skip",r=t[0]==="skip"?{}:Fn(t[0]),i=typeof e=="string"?Bd(e):e,s=ft(i),o=(0,m.useMemo)(()=>n?{}:{query:{query:i,args:r}},[JSON.stringify(Pn(r)),s,n]),a=FO(o).query;if(a instanceof Error)throw a;return a}function rW(e){const t=typeof e=="string"?Bd(e):e,n=(0,m.useContext)(mc);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,m.useMemo)(()=>gb(t,n),[n,ft(t)])}function iW(e){const t=(0,m.useContext)(mc),n=typeof e=="string"?Bd(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,m.useMemo)(()=>DO(n,t),[t,ft(n)])}function jO(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 _O=Object.defineProperty,BO=(e,t,n)=>t in e?_O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ou=(e,t,n)=>BO(e,typeof t!="symbol"?t+"":t,n),VO=class{constructor(e){ou(this,"createWatch"),ou(this,"queries"),ou(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(ft(n),this.queries[t]===void 0)this.addQuery(t,n,r,i?{paginationOptions:i}:{});else{const s=this.queries[t];(ft(n)!==ft(s.query)||JSON.stringify(Pn(r))!==JSON.stringify(Pn(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;ft(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 FO(e){const t=NO();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 zO(e,(0,m.useMemo)(()=>(n,r,{journal:i,paginationOptions:s})=>s?t.watchPaginatedQuery(n,r,s):t.watchQuery(n,r,i?{journal:i}:{}),[t]))}function zO(e,t){const[n]=(0,m.useState)(()=>new VO(t));n.createWatch!==t&&n.setCreateWatch(t),(0,m.useEffect)(()=>()=>n.destroy(),[n]);const r=(0,m.useMemo)(()=>({getCurrentValue:()=>n.getLocalResults(e),subscribe:i=>(n.setQueries(e),n.subscribe(i))}),[n,e]);return PO(r)}var $O=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HO=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),Lm=e=>{const t=HO(e);return t.charAt(0).toUpperCase()+t.slice(1)},vb=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),WO=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0},qO={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},UO=(0,m.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...a},l)=>(0,m.createElement)("svg",{ref:l,...qO,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:vb("lucide",i),...!s&&!WO(a)&&{"aria-hidden":"true"},...a},[...o.map(([c,u])=>(0,m.createElement)(c,u)),...Array.isArray(s)?s:[s]])),be=(e,t)=>{const n=(0,m.forwardRef)(({className:r,...i},s)=>(0,m.createElement)(UO,{ref:s,iconNode:t,className:vb(`lucide-${$O(Lm(e))}`,`lucide-${e}`,r),...i}));return n.displayName=Lm(e),n},KO=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],GO=be("align-left",KO),QO=[["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"}]],XO=be("bot",QO),YO=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ji=be("check",YO),JO=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],yb=be("chevron-down",JO),ZO=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Zi=be("chevron-right",ZO),eI=[["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"}]],tI=be("circle-alert",eI),nI=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],rI=be("circle",nI),iI=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],jm=be("clock",iI),sI=[["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"}]],$i=be("copy",sI),oI=[["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"}]],aI=be("expand",oI),lI=[["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"}]],cI=be("eye",lI),uI=[["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"}]],hI=be("grip-vertical",uI),fI=[["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"}]],dI=be("layers",fI),pI=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]],mI=be("list-filter",pI),gI=[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]],_m=be("list-tree",gI),vI=[["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"}]],yI=be("maximize-2",vI),xI=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 12a2 2 0 0 0 2-2V8H8",key:"1jfesj"}],["path",{d:"M14 12a2 2 0 0 0 2-2V8h-2",key:"1dq9mh"}]],bI=be("message-square-quote",xI),wI=[["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"}]],SI=be("minimize-2",wI),kI=[["path",{d:"M5 12h14",key:"1ays0h"}]],CI=be("minus",kI),TI=[["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"}]],AI=be("mouse-pointer-click",TI),RI=[["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"}]],MI=be("pencil",RI),PI=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],EI=be("plus",PI),OI=[["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"}]],II=be("redo-2",OI),DI=[["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"}]],NI=be("shrink",DI),LI=[["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"}]],gc=be("triangle-alert",LI),jI=[["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"}]],_I=be("undo-2",jI),BI=[["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"}]],VI=be("user",BI),FI=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],zI=be("wrench",FI),Bm=class extends m.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),aT(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,g.jsx)("div",{className:"flex items-center justify-center min-h-[400px] p-6",children:(0,g.jsxs)("div",{className:"text-center max-w-md",children:[(0,g.jsx)(gc,{className:"h-12 w-12 text-destructive mx-auto mb-4"}),(0,g.jsx)("h2",{className:"text-xl font-semibold mb-2",children:"Something went wrong"}),(0,g.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:this.state.error?.message||"An unexpected error occurred"}),(0,g.jsx)(Nt,{onClick:this.handleReset,variant:"outline",children:"Try again"})]})}):this.props.children}},$I=["billing_","credit_topup_","plan_limit_","plans_upgrade_confirm_","pricing_"];function HI(e){return $I.some(t=>e.startsWith(t))}function WI(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 qI(e,t={}){const{location:n="unknown",platform:r,environment:i,...s}=t;try{const o=HI(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])=>!WI(u))):s;lT.capture(e,{...c,...sT(n),...o?{organization_id:null,...l?{$groups:{organization:l}}:{}}:{}})}catch(o){console.warn(`[analytics] Failed to capture ${e}`,o)}}function xb({...e}){return(0,g.jsx)(EP,{"data-slot":"dropdown-menu",...e})}function bb({...e}){return(0,g.jsx)(OP,{"data-slot":"dropdown-menu-trigger",...e})}function wb({className:e,sideOffset:t=4,...n}){return(0,g.jsx)(IP,{children:(0,g.jsx)(DP,{"data-slot":"dropdown-menu-content",sideOffset:t,className:X("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 UI({className:e,inset:t,variant:n="default",...r}){return(0,g.jsx)(LP,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:X("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 sW({className:e,children:t,checked:n,...r}){return(0,g.jsxs)(jP,{"data-slot":"dropdown-menu-checkbox-item",className:X("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,g.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,g.jsx)(qx,{children:(0,g.jsx)(Ji,{className:"size-4"})})}),t]})}function KI({...e}){return(0,g.jsx)(_P,{"data-slot":"dropdown-menu-radio-group",...e})}function GI({className:e,children:t,hideIndicator:n=!1,...r}){return(0,g.jsxs)(BP,{"data-slot":"dropdown-menu-radio-item",className:X("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,g.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,g.jsx)(qx,{children:(0,g.jsx)(rI,{className:"size-2 fill-current"})})}),t]})}function oW({className:e,inset:t,...n}){return(0,g.jsx)(NP,{"data-slot":"dropdown-menu-label","data-inset":t,className:X("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...n})}function aW({className:e,...t}){return(0,g.jsx)(VP,{"data-slot":"dropdown-menu-separator",className:X("bg-border -mx-1 my-1 h-px",e),...t})}function lW({...e}){return(0,g.jsx)(FP,{"data-slot":"dropdown-menu-sub",...e})}function cW({className:e,inset:t,children:n,...r}){return(0,g.jsxs)(zP,{"data-slot":"dropdown-menu-sub-trigger","data-inset":t,className:X("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,g.jsx)(Zi,{className:"ml-auto size-4"})]})}function uW({className:e,...t}){return(0,g.jsx)($P,{"data-slot":"dropdown-menu-sub-content",className:X("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",e),...t})}function QI(){return document.activeElement?.closest('[role="dialog"],[role="alertdialog"]')??document.body}async function vc(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",QI().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 XI=tT("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"}},defaultVariants:{variant:"default"}});function Sb({className:e,variant:t,asChild:n=!1,...r}){const i=n?eT:"span";return(0,g.jsx)(i,{"data-slot":"badge",className:X(XI({variant:t}),e),...r})}var kb=(0,m.createContext)({});function YI(e){const t=(0,m.useRef)(null);return t.current===null&&(t.current=e()),t.current}var JI=typeof window<"u",ZI=JI?m.useLayoutEffect:m.useEffect,Vd=(0,m.createContext)(null);function Fd(e,t){e.indexOf(t)===-1&&e.push(t)}function Al(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}var In=(e,t,n)=>n>t?t:n<e?e:n,yc=()=>{},es=()=>{},Sr={},Cb=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Tb(e){return typeof e=="object"&&e!==null}var Ab=e=>/^0[^.\s]+$/u.test(e);function Rb(e){let t;return()=>(t===void 0&&(t=e()),t)}var Vt=e=>e,eD=(e,t)=>n=>t(e(n)),qo=(...e)=>e.reduce(eD),yo=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r},zd=class{constructor(){this.subscriptions=[]}add(e){return Fd(this.subscriptions,e),()=>Al(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}},bt=e=>e*1e3,_t=e=>e/1e3;function Mb(e,t){return t?e*(1e3/t):0}var Pb=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,tD=1e-7,nD=12;function rD(e,t,n,r,i){let s,o,a=0;do o=t+(n-t)/2,s=Pb(o,r,i)-e,s>0?n=o:t=o;while(Math.abs(s)>tD&&++a<nD);return o}function Uo(e,t,n,r){if(e===t&&n===r)return Vt;const i=s=>rD(s,0,1,e,n);return s=>s===0||s===1?s:Pb(i(s),t,r)}var Eb=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Ob=e=>t=>1-e(1-t),Ib=Uo(.33,1.53,.69,.99),$d=Ob(Ib),Db=Eb($d),Nb=e=>e>=1?1:(e*=2)<1?.5*$d(e):.5*(2-Math.pow(2,-10*(e-1))),Hd=e=>1-Math.sin(Math.acos(e)),Lb=Ob(Hd),jb=Eb(Hd),iD=Uo(.42,0,1,1),sD=Uo(0,0,.58,1),_b=Uo(.42,0,.58,1),oD=e=>Array.isArray(e)&&typeof e[0]!="number",Bb=e=>Array.isArray(e)&&typeof e[0]=="number",Vm={linear:Vt,easeIn:iD,easeInOut:_b,easeOut:sD,circIn:Hd,circInOut:jb,circOut:Lb,backIn:$d,backInOut:Db,backOut:Ib,anticipate:Nb},aD=e=>typeof e=="string",Fm=e=>{if(Bb(e)){es(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,r,i]=e;return Uo(t,n,r,i)}else if(aD(e))return es(Vm[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),Vm[e];return e},pa=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],wn={value:null,addProjectionMetrics:null};function lD(e,t){let n=new Set,r=new Set,i=!1,s=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1},l=0;function c(h){o.has(h)&&(u.schedule(h),e()),l++,h(a)}const u={schedule:(h,f=!1,d=!1)=>{const p=d&&i?n:r;return f&&o.add(h),p.add(h),h},cancel:h=>{r.delete(h),o.delete(h)},process:h=>{if(a=h,i){s=!0;return}i=!0;const f=n;n=r,r=f,n.forEach(c),t&&wn.value&&wn.value.frameloop[t].push(l),l=0,n.clear(),i=!1,s&&(s=!1,u.process(h))}};return u}var cD=40;function Vb(e,t){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,o=pa.reduce((w,S)=>(w[S]=lD(s,t?S:void 0),w),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:u,update:h,preRender:f,render:d,postRender:p}=o,v=()=>{const w=Sr.useManualTiming,S=w?i.timestamp:performance.now();n=!1,w||(i.delta=r?1e3/60:Math.max(Math.min(S-i.timestamp,cD),1)),i.timestamp=S,i.isProcessing=!0,a.process(i),l.process(i),c.process(i),u.process(i),h.process(i),f.process(i),d.process(i),p.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(v))},y=()=>{n=!0,r=!0,i.isProcessing||e(v)};return{schedule:pa.reduce((w,S)=>{const C=o[S];return w[S]=(T,k=!1,A=!1)=>(n||y(),C.schedule(T,k,A)),w},{}),cancel:w=>{for(let S=0;S<pa.length;S++)o[pa[S]].cancel(w)},state:i,steps:o}}var{schedule:Se,cancel:kr,state:Je,steps:au}=Vb(typeof requestAnimationFrame<"u"?requestAnimationFrame:Vt,!0),qa;function uD(){qa=void 0}var dt={now:()=>(qa===void 0&&dt.set(Je.isProcessing||Sr.useManualTiming?Je.timestamp:performance.now()),qa),set:e=>{qa=e,queueMicrotask(uD)}},Yr={layout:0,mainThread:0,waapi:0},Fb=e=>t=>typeof t=="string"&&t.startsWith(e),zb=Fb("--"),hD=Fb("var(--"),Wd=e=>hD(e)?fD.test(e.split("/*")[0].trim()):!1,fD=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function zm(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}var ms={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},xo={...ms,transform:e=>In(0,1,e)},ma={...ms,default:1},Ys=e=>Math.round(e*1e5)/1e5,qd=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function dD(e){return e==null}var pD=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ud=(e,t)=>n=>!!(typeof n=="string"&&pD.test(n)&&n.startsWith(e)||t&&!dD(n)&&Object.prototype.hasOwnProperty.call(n,t)),$b=(e,t,n)=>r=>{if(typeof r!="string")return r;const[i,s,o,a]=r.match(qd);return{[e]:parseFloat(i),[t]:parseFloat(s),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},mD=e=>In(0,255,e),lu={...ms,transform:e=>Math.round(mD(e))},Kr={test:Ud("rgb","red"),parse:$b("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+lu.transform(e)+", "+lu.transform(t)+", "+lu.transform(n)+", "+Ys(xo.transform(r))+")"};function gD(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 Th={test:Ud("#"),parse:gD,transform:Kr.transform},Ko=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),cr=Ko("deg"),Mn=Ko("%"),Q=Ko("px"),vD=Ko("vh"),yD=Ko("vw"),$m={...Mn,parse:e=>Mn.parse(e)/100,transform:e=>Mn.transform(e*100)},Di={test:Ud("hsl","hue"),parse:$b("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+Mn.transform(Ys(t))+", "+Mn.transform(Ys(n))+", "+Ys(xo.transform(r))+")"},Fe={test:e=>Kr.test(e)||Th.test(e)||Di.test(e),parse:e=>Kr.test(e)?Kr.parse(e):Di.test(e)?Di.parse(e):Th.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Kr.transform(e):Di.transform(e),getAnimatableNone:e=>{const t=Fe.parse(e);return t.alpha=0,Fe.transform(t)}},xD=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function bD(e){return isNaN(e)&&typeof e=="string"&&(e.match(qd)?.length||0)+(e.match(xD)?.length||0)>0}var Hb="number",Wb="color",wD="var",SD="var(",Hm="${}",kD=/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 ts(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[];let s=0;return{values:n,split:t.replace(kD,o=>(Fe.test(o)?(r.color.push(s),i.push(Wb),n.push(Fe.parse(o))):o.startsWith(SD)?(r.var.push(s),i.push(wD),n.push(o)):(r.number.push(s),i.push(Hb),n.push(parseFloat(o))),++s,Hm)).split(Hm),indexes:r,types:i}}function CD(e){return ts(e).values}function qb({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===Hb?i+=Ys(r[s]):o===Wb?i+=Fe.transform(r[s]):i+=r[s]}return i}}function TD(e){return qb(ts(e))}var AD=e=>typeof e=="number"?0:Fe.test(e)?Fe.getAnimatableNone(e):e,RD=(e,t)=>typeof e=="number"?t?.trim().endsWith("/")?e:0:AD(e);function MD(e){const t=ts(e);return qb(t)(t.values.map((n,r)=>RD(n,t.split[r])))}var Zt={test:bD,parse:CD,createTransformer:TD,getAnimatableNone:MD};function cu(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 PD({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=cu(l,a,e+1/3),s=cu(l,a,e),o=cu(l,a,e-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(o*255),alpha:r}}function Rl(e,t){return n=>n>0?t:e}var Te=(e,t,n)=>e+(t-e)*n,uu=(e,t,n)=>{const r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},ED=[Th,Kr,Di],OD=e=>ED.find(t=>t.test(e));function Wm(e){const t=OD(e);if(yc(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!t)return!1;let n=t.parse(e);return t===Di&&(n=PD(n)),n}var qm=(e,t)=>{const n=Wm(e),r=Wm(t);if(!n||!r)return Rl(e,t);const i={...n};return s=>(i.red=uu(n.red,r.red,s),i.green=uu(n.green,r.green,s),i.blue=uu(n.blue,r.blue,s),i.alpha=Te(n.alpha,r.alpha,s),Kr.transform(i))},Ah=new Set(["none","hidden"]);function ID(e,t){return Ah.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function DD(e,t){return n=>Te(e,t,n)}function Kd(e){return typeof e=="number"?DD:typeof e=="string"?Wd(e)?Rl:Fe.test(e)?qm:jD:Array.isArray(e)?Ub:typeof e=="object"?Fe.test(e)?qm:ND:Rl}function Ub(e,t){const n=[...e],r=n.length,i=e.map((s,o)=>Kd(s)(s,t[o]));return s=>{for(let o=0;o<r;o++)n[o]=i[o](s);return n}}function ND(e,t){const n={...e,...t},r={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Kd(e[i])(e[i],t[i]));return i=>{for(const s in r)n[s]=r[s](i);return n}}function LD(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 jD=(e,t)=>{const n=Zt.createTransformer(t),r=ts(e),i=ts(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?Ah.has(e)&&!i.values.length||Ah.has(t)&&!r.values.length?ID(e,t):qo(Ub(LD(r,i),i.values),n):(yc(!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"),Rl(e,t))};function Kb(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?Te(e,t,n):Kd(e)(e,t)}var _D=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>Se.update(t,n),stop:()=>kr(t),now:()=>Je.isProcessing?Je.timestamp:dt.now()}},Gb=(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)})`},Qb=2e4;function Gd(e){let t=0;const n=50;let r=e.next(t);for(;!r.done&&t<2e4;)t+=n,r=e.next(t);return t>=2e4?1/0:t}function BD(e,t=100,n){const r=n({...e,keyframes:[0,t]}),i=Math.min(Gd(r),Qb);return{type:"keyframes",ease:s=>r.next(i*s).value/t,duration:_t(i)}}var Oe={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Rh(e,t){return e*Math.sqrt(1-t*t)}var VD=12;function FD(e,t,n){let r=n;for(let i=1;i<VD;i++)r=r-e(r)/t(r);return r}var Um=.001;function zD({duration:e=Oe.duration,bounce:t=Oe.bounce,velocity:n=Oe.velocity,mass:r=Oe.mass}){let i,s;yc(e<=bt(Oe.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-t;o=In(Oe.minDamping,Oe.maxDamping,o),e=In(Oe.minDuration,Oe.maxDuration,_t(e)),o<1?(i=c=>{const u=c*o,h=u*e,f=u-n,d=Rh(c,o),p=Math.exp(-h);return Um-f/d*p},s=c=>{const u=c*o*e,h=u*n+n,f=Math.pow(o,2)*Math.pow(c,2)*e,d=Math.exp(-u),p=Rh(Math.pow(c,2),o);return(-i(c)+Um>0?-1:1)*((h-f)*d)/p}):(i=c=>-.001+Math.exp(-c*e)*((c-n)*e+1),s=c=>Math.exp(-c*e)*((n-c)*(e*e)));const a=5/e,l=FD(i,s,a);if(e=bt(e),isNaN(l))return{stiffness:Oe.stiffness,damping:Oe.damping,duration:e};{const c=Math.pow(l,2)*r;return{stiffness:c,damping:o*2*Math.sqrt(r*c),duration:e}}}var $D=["duration","bounce"],HD=["stiffness","damping","mass"];function Km(e,t){return t.some(n=>e[n]!==void 0)}function WD(e){let t={velocity:Oe.velocity,stiffness:Oe.stiffness,damping:Oe.damping,mass:Oe.mass,isResolvedFromDuration:!1,...e};if(!Km(e,HD)&&Km(e,$D))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,s=2*In(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Oe.mass,stiffness:i,damping:s}}else{const n=zD({...e,velocity:0});t={...t,...n,mass:Oe.mass},t.isResolvedFromDuration=!0}return t}function Ml(e=Oe.visualDuration,t=Oe.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:i}=n;const s=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:s},{stiffness:l,damping:c,mass:u,duration:h,velocity:f,isResolvedFromDuration:d}=WD({...n,velocity:-_t(n.velocity||0)}),p=f||0,v=c/(2*Math.sqrt(l*u)),y=o-s,x=_t(Math.sqrt(l/u)),b=Math.abs(y)<5;r||(r=b?Oe.restSpeed.granular:Oe.restSpeed.default),i||(i=b?Oe.restDelta.granular:Oe.restDelta.default);let w,S,C,T,k,A;if(v<1)C=Rh(x,v),T=(p+v*x*y)/C,w=R=>{const O=Math.exp(-v*x*R);return o-O*(T*Math.sin(C*R)+y*Math.cos(C*R))},k=v*x*T+y*C,A=v*x*y-T*C,S=R=>Math.exp(-v*x*R)*(k*Math.sin(C*R)+A*Math.cos(C*R));else if(v===1){w=O=>o-Math.exp(-x*O)*(y+(p+x*y)*O);const R=p+x*y;S=O=>Math.exp(-x*O)*(x*R*O-p)}else{const R=x*Math.sqrt(v*v-1);w=N=>{const P=Math.exp(-v*x*N),L=Math.min(R*N,300);return o-P*((p+v*x*y)*Math.sinh(L)+R*y*Math.cosh(L))/R};const O=(p+v*x*y)/R,M=v*x*O-y*R,j=v*x*y-O*R;S=N=>{const P=Math.exp(-v*x*N),L=Math.min(R*N,300);return P*(M*Math.sinh(L)+j*Math.cosh(L))}}const E={calculatedDuration:d&&h||null,velocity:R=>bt(S(R)),next:R=>{if(!d&&v<1){const M=Math.exp(-v*x*R),j=Math.sin(C*R),N=Math.cos(C*R),P=o-M*(T*j+y*N),L=bt(M*(k*j+A*N));return a.done=Math.abs(L)<=r&&Math.abs(o-P)<=i,a.value=a.done?o:P,a}const O=w(R);if(d)a.done=R>=h;else{const M=bt(S(R));a.done=Math.abs(M)<=r&&Math.abs(o-O)<=i}return a.value=a.done?o:O,a},toString:()=>{const R=Math.min(Gd(E),Qb),O=Gb(M=>E.next(R*M).value,R,30);return R+"ms "+O},toTransition:()=>{}};return E}Ml.applyToOptions=e=>{const t=BD(e,100,Ml);return e.ease=t.ease,e.duration=bt(t.duration),e.type="keyframes",e};var qD=5;function Xb(e,t,n){const r=Math.max(t-qD,0);return Mb(n-e(r),t-r)}function Mh({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=A=>a!==void 0&&A<a||l!==void 0&&A>l,p=A=>a===void 0?l:l===void 0||Math.abs(a-A)<Math.abs(l-A)?a:l;let v=n*t;const y=h+v,x=o===void 0?y:o(y);x!==y&&(v=x-h);const b=A=>-v*Math.exp(-A/r),w=A=>x+b(A),S=A=>{const E=b(A),R=w(A);f.done=Math.abs(E)<=c,f.value=f.done?x:R};let C,T;const k=A=>{d(f.value)&&(C=A,T=Ml({keyframes:[f.value,p(f.value)],velocity:Xb(w,A,f.value),damping:i,stiffness:s,restDelta:c,restSpeed:u}))};return k(0),{calculatedDuration:null,next:A=>{let E=!1;return!T&&C===void 0&&(E=!0,S(A),k(A)),C!==void 0&&A>=C?T.next(A-C):(!E&&S(A),f)}}}function UD(e,t,n){const r=[],i=n||Sr.mix||Kb,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]||Vt:t;a=qo(l,a)}r.push(a)}return r}function KD(e,t,{clamp:n=!0,ease:r,mixer:i}={}){const s=e.length;if(es(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=UD(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=yo(e[h],e[h+1],u);return a[h](f)};return n?u=>c(In(e[0],e[s-1],u)):c}function GD(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const i=yo(0,t,r);e.push(Te(n,1,i))}}function QD(e){const t=[0];return GD(t,e.length-1),t}function XD(e,t){return e.map(n=>n*t)}function YD(e,t){return e.map(()=>t||_b).splice(0,e.length-1)}function Js({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const i=oD(r)?r.map(Fm):Fm(r),s={done:!1,value:t[0]},o=XD(n&&n.length===t.length?n:QD(t),e),a=KD(o,t,{ease:Array.isArray(i)?i:YD(t,i)});return{calculatedDuration:e,next:l=>(s.value=a(l),s.done=l>=e,s)}}var JD=e=>e!==null;function xc(e,{repeat:t,repeatType:n="loop"},r,i=1){const s=e.filter(JD),o=i<0||t&&n!=="loop"&&t%2===1?0:s.length-1;return!o||r===void 0?s[o]:r}var ZD={decay:Mh,inertia:Mh,tween:Js,keyframes:Js,spring:Ml};function Yb(e){typeof e.type=="string"&&(e.type=ZD[e.type])}var Qd=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},e2=e=>e/100,Pl=class extends Qd{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!==dt.now()&&this.tick(dt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},Yr.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;Yb(e);const{type:t=Js,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:s=0}=e;let{keyframes:o}=e;const a=t||Js;a!==Js&&typeof o[0]!="number"&&(this.mixKeyframes=qo(e2,Kb(o[0],o[1])),o=[0,100]);const l=a({...e,keyframes:o});i==="mirror"&&(this.mirroredGenerator=a({...e,keyframes:[...o].reverse(),velocity:-s})),l.calculatedDuration===null&&(l.calculatedDuration=Gd(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:p,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 A=Math.floor(k),E=k%1;!E&&k>=1&&(E=1),E===1&&A--,A=Math.min(A,u+1),A%2&&(h==="reverse"?(E=1-E,f&&(E-=f/o)):h==="mirror"&&(w=s)),b=In(0,1,E)*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 T=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&C);return T&&d!==Mh&&(S.value=xc(c,this.options,v,this.speed)),p&&p(S.value),T&&this.finish(),S}then(e,t){return this.finished.then(e,t)}get duration(){return _t(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+_t(e)}get time(){return _t(this.currentTime)}set time(e){e=bt(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(){const e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);const t=this.generator.next(e).value;return Xb(n=>this.generator.next(n).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){const t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(dt.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=_t(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=_D,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(dt.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,Yr.mainThread--}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)}};function t2(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var Gr=e=>e*180/Math.PI,Ph=e=>{const t=Gr(Math.atan2(e[1],e[0]));return Eh(t)},n2={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Ph,rotateZ:Ph,skewX:e=>Gr(Math.atan(e[1])),skewY:e=>Gr(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Eh=e=>(e=e%360,e<0&&(e+=360),e),Gm=Ph,Qm=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Xm=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),r2={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Qm,scaleY:Xm,scale:e=>(Qm(e)+Xm(e))/2,rotateX:e=>Eh(Gr(Math.atan2(e[6],e[5]))),rotateY:e=>Eh(Gr(Math.atan2(-e[2],e[0]))),rotateZ:Gm,rotate:Gm,skewX:e=>Gr(Math.atan(e[4])),skewY:e=>Gr(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Oh(e){return e.includes("scale")?1:0}function Ih(e,t){if(!e||e==="none")return Oh(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=r2,i=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=n2,i=a}if(!i)return Oh(t);const s=r[t],o=i[1].split(",").map(s2);return typeof s=="function"?s(o):o[s]}var i2=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Ih(n,t)};function s2(e){return parseFloat(e.trim())}var gs=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],vs=new Set(gs),Ym=e=>e===ms||e===Q,o2=new Set(["x","y","z"]),a2=gs.filter(e=>!o2.has(e));function l2(e){const t=[];return a2.forEach(n=>{const r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}var gr={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:r})=>{const i=e.max-e.min;return r==="border-box"?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:r})=>{const i=e.max-e.min;return r==="border-box"?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Ih(t,"x"),y:(e,{transform:t})=>Ih(t,"y")};gr.translateX=gr.x;gr.translateY=gr.y;var Jr=new Set,Dh=!1,Nh=!1,Lh=!1;function Jb(){if(Nh){const e=Array.from(Jr).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{const i=l2(r);i.length&&(n.set(r,i),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const i=n.get(r);i&&i.forEach(([s,o])=>{r.getValue(s)?.set(o)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}Nh=!1,Dh=!1,Jr.forEach(e=>e.complete(Lh)),Jr.clear()}function Zb(){Jr.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Nh=!0)})}function c2(){Lh=!0,Zb(),Jb(),Lh=!1}var Xd=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?(Jr.add(this),Dh||(Dh=!0,Se.read(Zb),Se.resolveKeyframes(Jb))):(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=n.readValue(t,s);o!=null&&(e[0]=o)}e[0]===void 0&&(e[0]=s),r&&i===void 0&&r.set(e[0])}t2(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Jr.delete(this)}cancel(){this.state==="scheduled"&&(Jr.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}},u2=e=>e.startsWith("--");function ew(e,t,n){u2(t)?e.style.setProperty(t,n):e.style[t]=n}var h2={};function tw(e,t){const n=Rb(e);return()=>h2[t]??n()}var f2=tw(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),nw=tw(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),_s=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Jm={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:_s([0,.65,.55,1]),circOut:_s([.55,0,1,.45]),backIn:_s([.31,.01,.66,-.59]),backOut:_s([.33,1.53,.69,.99])};function rw(e,t){if(e)return typeof e=="function"?nw()?Gb(e,t):"ease-out":Bb(e)?_s(e):Array.isArray(e)?e.map(n=>rw(n,t)||Jm.easeOut):Jm[e]}function d2(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=rw(a,i);Array.isArray(h)&&(u.easing=h),wn.value&&Yr.waapi++;const f={delay:r,duration:i,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:s+1,direction:o==="reverse"?"alternate":"normal"};c&&(f.pseudoElement=c);const d=e.animate(u,f);return wn.value&&d.finished.finally(()=>{Yr.waapi--}),d}function iw(e){return typeof e=="function"&&"applyToOptions"in e}function p2({type:e,...t}){return iw(e)&&nw()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}var sw=class extends Qd{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,es(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const l=p2(e);this.animation=d2(t,n,r,l,i),l.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){const c=xc(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(c),ew(t,n,c),this.animation.cancel()}a?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;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 _t(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+_t(e)}get time(){return _t(Number(this.animation.currentTime)||0)}set time(e){const t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=bt(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,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&f2()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),Vt):r(this)}},ow={anticipate:Nb,backInOut:Db,circInOut:jb};function m2(e){return e in ow}function g2(e){typeof e.ease=="string"&&m2(e.ease)&&(e.ease=ow[e.ease])}var hu=10,v2=class extends sw{constructor(e){g2(e),Yb(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 Pl({...s,autoplay:!1}),a=Math.max(hu,dt.now()-this.startTime),l=In(0,hu,a-hu),c=o.sample(a).value,{name:u}=this.options;i&&u&&ew(i,u,c),t.setWithVelocity(o.sample(Math.max(0,a-l)).value,c,l),o.stop()}},Zm=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Zt.test(e)||e==="0")&&!e.startsWith("url("));function y2(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 x2(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=Zm(i,t),a=Zm(s,t);return yc(o===a,`You are trying to animate ${t} from "${i}" to "${s}". "${o?s:i}" is not an animatable value.`,"value-not-animatable"),!o||!a?!1:y2(e)||(n==="spring"||iw(n))&&r}function jh(e){e.duration=0,e.type="keyframes"}var aw=new Set(["opacity","clipPath","filter","transform"]),b2=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function w2(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&b2.test(e[t]))return!0;return!1}var S2=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),k2=Rb(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function C2(e){const{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:s,type:o,keyframes:a}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:c}=t.owner.getProps();return k2()&&n&&(aw.has(n)||S2.has(n)&&w2(a))&&(n!=="transform"||!c)&&!l&&!r&&i!=="mirror"&&s!==0&&o!=="inertia"}var T2=40,A2=class extends Qd{constructor({autoplay:e=!0,delay:t=0,type:n="keyframes",repeat:r=0,repeatDelay:i=0,repeatType:s="loop",keyframes:o,name:a,motionValue:l,element:c,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=dt.now();const h={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:s,name:a,motionValue:l,element:c,...u},f=c?.KeyframeResolver||Xd;this.keyframeResolver=new f(o,(d,p,v)=>this.onKeyframesResolved(d,p,h,!v),a,l,c),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=dt.now();let u=!0;x2(e,i,s,o)||(u=!1,(Sr.instantAnimations||!a)&&c?.(xc(e,n,t)),e[0]=e[e.length-1],jh(n),n.repeat=0);const h={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>T2?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!l&&C2(h),d=h.motionValue?.owner?.current;let p;if(f)try{p=new v2({...h,element:d})}catch{p=new Pl(h)}else p=new Pl(h);p.finished.then(()=>{this.notifyFinished()}).catch(Vt),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),c2()),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 lw(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 R2=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function M2(e){const t=R2.exec(e);if(!t)return[,];const[,n,r,i]=t;return[`--${n??r}`,i]}var P2=4;function cw(e,t,n=1){es(n<=P2,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,i]=M2(e);if(!r)return;const s=window.getComputedStyle(t).getPropertyValue(r);if(s){const o=s.trim();return Cb(o)?parseFloat(o):o}return Wd(i)?cw(i,t,n+1):i}var E2={type:"spring",stiffness:500,damping:25,restSpeed:10},O2=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),I2={type:"keyframes",duration:.8},D2={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},N2=(e,{keyframes:t})=>t.length>2?I2:vs.has(e)?e.startsWith("scale")?O2(t[1]):E2:D2;function uw(e,t){if(e?.inherit&&t){const{inherit:n,...r}=e;return{...t,...r}}return e}function Yd(e,t){const n=e?.[t]??e?.default??e;return n!==e?uw(n,e):n}var L2=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function j2(e){for(const t in e)if(!L2.has(t))return!0;return!1}var Jd=(e,t,n,r={},i,s)=>o=>{const a=Yd(r,e)||{},l=a.delay||r.delay||0;let{elapsed:c=0}=r;c=c-bt(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};j2(a)||Object.assign(u,N2(e,u)),u.duration&&(u.duration=bt(u.duration)),u.repeatDelay&&(u.repeatDelay=bt(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let h=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(jh(u),u.delay===0&&(h=!0)),(Sr.instantAnimations||Sr.skipAnimations||i?.shouldSkipAnimations)&&(h=!0,jh(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,h&&!s&&t.get()!==void 0){const f=xc(u.keyframes,a);if(f!==void 0){Se.update(()=>{u.onUpdate(f),u.onComplete()});return}}return a.isSync?new Pl(u):new A2(u)};function eg(e){const t=[{},{}];return e?.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function Zd(e,t,n,r){if(typeof t=="function"){const[i,s]=eg(r);t=t(n!==void 0?n:e.custom,i,s)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,s]=eg(r);t=t(n!==void 0?n:e.custom,i,s)}return t}function Zr(e,t,n){const r=e.getProps();return Zd(r,t,n!==void 0?n:r.custom,e)}var hw=new Set(["width","height","top","left","right","bottom",...gs]),tg=30,_2=e=>!isNaN(parseFloat(e)),ng={current:void 0},B2=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{const r=dt.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&(this.events.change?.notify(this.current),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=dt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=_2(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new zd);const n=this.events[e].add(t);return e==="change"?()=>{n(),Se.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){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.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return ng.current&&ng.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const e=dt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>tg)return 0;const t=Math.min(this.updatedAt-this.prevUpdatedAt,tg);return Mb(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function ns(e,t){return new B2(e,t)}var _h=e=>Array.isArray(e);function V2(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,ns(n))}function F2(e){return _h(e)?e[e.length-1]||0:e}function z2(e,t){let{transitionEnd:n={},transition:r={},...i}=Zr(e,t)||{};i={...i,...n};for(const s in i)V2(e,s,F2(i[s]))}var et=e=>!!(e&&e.getVelocity);function $2(e){return!!(et(e)&&e.add)}function Bh(e,t){const n=e.getValue("willChange");if($2(n))return n.add(t);if(!n&&Sr.WillChange){const r=new Sr.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function ep(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var H2="framerAppearId",fw="data-"+ep(H2);function dw(e){return e.props[fw]}function W2({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function pw(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:s,transitionEnd:o,...a}=t;const l=e.getDefaultTransition();s=s?uw(s,l):l;const c=s?.reduceMotion;r&&(s=r);const u=[],h=i&&e.animationState&&e.animationState.getState()[i];for(const f in a){const d=e.getValue(f,e.latestValues[f]??null),p=a[f];if(p===void 0||h&&W2(h,f))continue;const v={delay:n,...Yd(s||{},f)},y=d.get();if(y!==void 0&&!d.isAnimating()&&!Array.isArray(p)&&p===y&&!v.velocity){Se.update(()=>d.set(p));continue}let x=!1;if(window.MotionHandoffAnimation){const S=dw(e);if(S){const C=window.MotionHandoffAnimation(S,f,Se);C!==null&&(v.startTime=C,x=!0)}}Bh(e,f);const b=c??e.shouldReduceMotion;d.start(Jd(f,d,p,b&&hw.has(f)?{type:!1}:v,e,x));const w=d.animation;w&&u.push(w)}if(o){const f=()=>Se.update(()=>{o&&z2(e,o)});u.length?Promise.all(u).then(f):f()}return u}function Vh(e,t,n={}){const r=Zr(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);const s=r?()=>Promise.all(pw(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:c=0,staggerChildren:u,staggerDirection:h}=i;return q2(e,t,l,c,u,h,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,c]=a==="beforeChildren"?[s,o]:[o,s];return l().then(()=>c())}else return Promise.all([s(),o(n.delay)])}function q2(e,t,n=0,r=0,i=0,s=1,o){const a=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),a.push(Vh(l,t,{...o,delay:n+(typeof r=="function"?0:r)+lw(e.variantChildren,l,r,i,s)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function U2(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const i=t.map(s=>Vh(e,s,n));r=Promise.all(i)}else if(typeof t=="string")r=Vh(e,t,n);else{const i=typeof t=="function"?Zr(e,t,n.custom):t;r=Promise.all(pw(e,i,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}var K2={test:e=>e==="auto",parse:e=>e},mw=e=>t=>t.test(e),gw=[ms,Q,Mn,cr,yD,vD,K2],rg=e=>gw.find(mw(e));function G2(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Ab(e):!0}var Q2=new Set(["brightness","contrast","saturate","opacity"]);function X2(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(qd)||[];if(!r)return e;const i=n.replace(r,"");let s=Q2.has(t)?1:0;return r!==n&&(s*=100),t+"("+s+i+")"}var Y2=/\b([a-z-]*)\(.*?\)/gu,Fh={...Zt,getAnimatableNone:e=>{const t=e.match(Y2);return t?t.map(X2).join(" "):e}},zh={...Zt,getAnimatableNone:e=>{const t=Zt.parse(e);return Zt.createTransformer(e)(t.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},ig={...ms,transform:Math.round},J2={rotate:cr,rotateX:cr,rotateY:cr,rotateZ:cr,scale:ma,scaleX:ma,scaleY:ma,scaleZ:ma,skew:cr,skewX:cr,skewY:cr,distance:Q,translateX:Q,translateY:Q,translateZ:Q,x:Q,y:Q,z:Q,perspective:Q,transformPerspective:Q,opacity:xo,originX:$m,originY:$m,originZ:Q},tp={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:ig,fillOpacity:xo,strokeOpacity:xo,numOctaves:ig},Z2={...tp,color:Fe,backgroundColor:Fe,outlineColor:Fe,fill:Fe,stroke:Fe,borderColor:Fe,borderTopColor:Fe,borderRightColor:Fe,borderBottomColor:Fe,borderLeftColor:Fe,filter:Fh,WebkitFilter:Fh,mask:zh,WebkitMask:zh},vw=e=>Z2[e],eN=new Set([Fh,zh]);function yw(e,t){let n=vw(e);return eN.has(n)||(n=Zt),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var tN=new Set(["auto","none","0"]);function nN(e,t,n){let r=0,i;for(;r<e.length&&!i;){const s=e[r];typeof s=="string"&&!tN.has(s)&&ts(s).values.length&&(i=e[r]),r++}if(i&&n)for(const s of t)e[s]=yw(n,i)}var rN=class extends Xd{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(),Wd(l))){const c=cw(l,t.current);c!==void 0&&(e[a]=c),a===e.length-1&&(this.finalKeyframe=l)}}if(this.resolveNoneKeyframes(),!hw.has(n)||e.length!==2)return;const[r,i]=e,s=rg(r),o=rg(i);if(zm(r)!==zm(i)&&gr[n]){this.needsMeasurement=!0;return}if(s!==o)if(Ym(s)&&Ym(o))for(let a=0;a<e.length;a++){const l=e[a];typeof l=="string"&&(e[a]=parseFloat(l))}else gr[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:t}=this,n=[];for(let r=0;r<e.length;r++)(e[r]===null||G2(e[r]))&&n.push(r);n.length&&nN(e,n,t)}measureInitialState(){const{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=gr[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;const r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){const{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;const r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);const i=n.length-1,s=n[i];n[i]=gr[t](e.measureViewportBox(),window.getComputedStyle(e.current)),s!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=s),this.removedTransforms?.length&&this.removedTransforms.forEach(([o,a])=>{e.getValue(o).set(a)}),this.resolveNoneKeyframes()}};function xw(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 bw=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function iN(e){return Tb(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}var{schedule:np,cancel:hW}=Vb(queueMicrotask,!1),Ut={x:!1,y:!1};function ww(){return Ut.x||Ut.y}function sN(e){return e==="x"||e==="y"?Ut[e]?null:(Ut[e]=!0,()=>{Ut[e]=!1}):Ut.x||Ut.y?null:(Ut.x=Ut.y=!0,()=>{Ut.x=Ut.y=!1})}function Sw(e,t){const n=xw(e),r=new AbortController,i={passive:!0,...t,signal:r.signal};return[n,i,()=>r.abort()]}function oN(e){return!(e.pointerType==="touch"||ww())}function aN(e,t,n={}){const[r,i,s]=Sw(e,n);return r.forEach(o=>{let a=!1,l=!1,c;const u=()=>{o.removeEventListener("pointerleave",p)},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)},p=y=>{if(y.pointerType!=="touch"){if(a){l=!0;return}h(y)}},v=y=>{if(!oN(y))return;l=!1;const x=t(o,y);typeof x=="function"&&(c=x,o.addEventListener("pointerleave",p,i))};o.addEventListener("pointerenter",v,i),o.addEventListener("pointerdown",d,i)}),s}var kw=(e,t)=>t?e===t?!0:kw(e,t.parentElement):!1,rp=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,lN=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function cN(e){return lN.has(e.tagName)||e.isContentEditable===!0}var uN=new Set(["INPUT","SELECT","TEXTAREA"]);function hN(e){return uN.has(e.tagName)||e.isContentEditable===!0}var Ua=new WeakSet;function sg(e){return t=>{t.key==="Enter"&&e(t)}}function fu(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}var fN=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=sg(()=>{if(Ua.has(n))return;fu(n,"down");const i=sg(()=>{fu(n,"up")}),s=()=>fu(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 og(e){return rp(e)&&!ww()}var ag=new WeakSet;function dN(e,t,n={}){const[r,i,s]=Sw(e,n),o=a=>{const l=a.currentTarget;if(!og(a)||ag.has(a))return;Ua.add(l),n.stopPropagation&&ag.add(a);const c=t(l,a),u=(d,p)=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",f),Ua.has(l)&&Ua.delete(l),og(d)&&typeof c=="function"&&c(d,{success:p})},h=d=>{u(d,l===window||l===document||n.useGlobalTarget||kw(l,d.target))},f=d=>{u(d,!1)};window.addEventListener("pointerup",h,i),window.addEventListener("pointercancel",f,i)};return r.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),iN(a)&&(a.addEventListener("focus",l=>fN(l,i)),!cN(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),s}function ip(e){return Tb(e)&&"ownerSVGElement"in e}var Ka=new WeakMap,Ga,Cw=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+"Size"]:ip(r)&&"getBBox"in r?r.getBBox()[t]:r[n],pN=Cw("inline","width","offsetWidth"),mN=Cw("block","height","offsetHeight");function gN({target:e,borderBoxSize:t}){Ka.get(e)?.forEach(n=>{n(e,{get width(){return pN(e,t)},get height(){return mN(e,t)}})})}function vN(e){e.forEach(gN)}function yN(){typeof ResizeObserver>"u"||(Ga=new ResizeObserver(vN))}function xN(e,t){Ga||yN();const n=xw(e);return n.forEach(r=>{let i=Ka.get(r);i||(i=new Set,Ka.set(r,i)),i.add(t),Ga?.observe(r)}),()=>{n.forEach(r=>{const i=Ka.get(r);i?.delete(t),i?.size||Ga?.unobserve(r)})}}var Qa=new Set,Ni;function bN(){Ni=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Qa.forEach(t=>t(e))},window.addEventListener("resize",Ni)}function wN(e){return Qa.add(e),Ni||bN(),()=>{Qa.delete(e),!Qa.size&&typeof Ni=="function"&&(window.removeEventListener("resize",Ni),Ni=void 0)}}function lg(e,t){return typeof e=="function"?wN(e):xN(e,t)}function SN(e){return ip(e)&&e.tagName==="svg"}var kN=[...gw,Fe,Zt],CN=e=>kN.find(mw(e)),cg=()=>({translate:0,scale:1,origin:0,originPoint:0}),Li=()=>({x:cg(),y:cg()}),ug=()=>({min:0,max:0}),$e=()=>({x:ug(),y:ug()}),TN=new WeakMap;function bc(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function bo(e){return typeof e=="string"||Array.isArray(e)}var sp=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],op=["initial",...sp];function wc(e){return bc(e.animate)||op.some(t=>bo(e[t]))}function Tw(e){return!!(wc(e)||e.variants)}function AN(e,t,n){for(const r in t){const i=t[r],s=n[r];if(et(i))e.addValue(r,i);else if(et(s))e.addValue(r,ns(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,ns(o!==void 0?o:i,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}var El={current:null},ap={current:!1},RN=typeof window<"u";function Aw(){if(ap.current=!0,!!RN)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>El.current=e.matches;e.addEventListener("change",t),t()}else El.current=!1}var hg=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],Ol={};function Rw(e){Ol=e}function MN(){return Ol}var PN=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=Xd,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=dt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,Se.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=wc(t),this.isVariantNode=Tw(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&&et(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];this.current=e,TN.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((t,n)=>this.bindToMotionValue(n,t)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(ap.current||Aw(),this.shouldReduceMotion=El.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(),kr(this.notifyUpdate),kr(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&&aw.has(e)&&this.current instanceof HTMLElement){const{factory:s,keyframes:o,times:a,ease:l,duration:c}=t.accelerate,u=new sw({element:this.current,name:e,keyframes:o,times:a,ease:l,duration:bt(c)}),h=s(u);this.valueSubscriptions.set(e,()=>{h(),u.cancel()});return}const n=vs.has(e);n&&this.onBindTransform&&this.onBindTransform();const r=t.on("change",s=>{this.latestValues[e]=s,this.props.onUpdate&&Se.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(),t.owner&&t.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Ol){const t=Ol[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):$e()}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<hg.length;n++){const r=hg[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=AN(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){const n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);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=ns(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n=="string"&&(Cb(n)||Ab(n))?n=parseFloat(n):!CN(n)&&Zt.test(t)&&(n=yw(e,t)),this.setBaseTarget(e,et(n)?n.get():n)),et(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){const{initial:t}=this.props;let n;if(typeof t=="string"||typeof t=="object"){const i=Zd(this.props,t,this.presenceContext?.custom);i&&(n=i[e])}if(t&&n!==void 0)return n;const r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!et(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new zd),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){np.render(this.render)}},Mw=class extends PN{constructor(){super(...arguments),this.KeyframeResolver=rN}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;et(e)&&(this.childSubscription=e.on("change",t=>{this.current&&(this.current.textContent=`${t}`)}))}},Ir=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Pw({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function EN({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function ON(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 du(e){return e===void 0||e===1}function $h({scale:e,scaleX:t,scaleY:n}){return!du(e)||!du(t)||!du(n)}function Vr(e){return $h(e)||Ew(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ew(e){return fg(e.x)||fg(e.y)}function fg(e){return e&&e!=="0%"}function Il(e,t,n){return n+t*(e-n)}function dg(e,t,n,r,i){return i!==void 0&&(e=Il(e,i,r)),Il(e,n,r)+t}function Hh(e,t=0,n=1,r,i){e.min=dg(e.min,t,n,r,i),e.max=dg(e.max,t,n,r,i)}function Ow(e,{x:t,y:n}){Hh(e.x,t.translate,t.scale,t.originPoint),Hh(e.y,n.translate,n.scale,n.originPoint)}var pg=.999999999999,mg=1.0000000000001;function IN(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&&(xn(e.x,-s.scroll.offset.x),xn(e.y,-s.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Ow(e,o)),r&&Vr(s.latestValues)&&Xa(e,s.latestValues,s.layout?.layoutBox))}t.x<mg&&t.x>pg&&(t.x=1),t.y<mg&&t.y>pg&&(t.y=1)}function xn(e,t){e.min+=t,e.max+=t}function gg(e,t,n,r,i=.5){Hh(e,t,n,Te(e.min,e.max,i),r)}function vg(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Xa(e,t,n){const r=n??e;gg(e.x,vg(t.x,r.x),t.scaleX,t.scale,t.originX),gg(e.y,vg(t.y,r.y),t.scaleY,t.scale,t.originY)}function Iw(e,t){return Pw(ON(e.getBoundingClientRect(),t))}function DN(e,t,n){const r=Iw(e,n),{scroll:i}=t;return i&&(xn(r.x,i.offset.x),xn(r.y,i.offset.y)),r}var NN={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},LN=gs.length;function jN(e,t,n){let r="",i=!0;for(let s=0;s<LN;s++){const o=gs[s],a=e[o];if(a===void 0)continue;let l=!0;if(typeof a=="number")l=a===(o.startsWith("scale")?1:0);else{const c=parseFloat(a);l=o.startsWith("scale")?c===1:c===0}if(!l||n){const c=bw(a,tp[o]);if(!l){i=!1;const u=NN[o]||o;r+=`${u}(${c}) `}n&&(t[o]=c)}}return r=r.trim(),n?r=n(t,i?"":r):i&&(r="none"),r}function lp(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(vs.has(l)){o=!0;continue}else if(zb(l)){i[l]=c;continue}else{const u=bw(c,tp[l]);l.startsWith("origin")?(a=!0,s[l]=u):r[l]=u}}if(t.transform||(o||n?r.transform=jN(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}`}}function Dw(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])}function yg(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var As={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Q.test(e))e=parseFloat(e);else return e;return`${yg(e,t.target.x)}% ${yg(e,t.target.y)}%`}},_N={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,i=Zt.parse(e);if(i.length>5)return r;const s=Zt.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=Te(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=c),typeof i[3+o]=="number"&&(i[3+o]/=c),s(i)}},Wh={borderRadius:{...As,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:As,borderTopRightRadius:As,borderBottomLeftRadius:As,borderBottomRightRadius:As,boxShadow:_N};function Nw(e,{layout:t,layoutId:n}){return vs.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Wh[e]||e==="opacity")}function cp(e,t,n){const r=e.style,i=t?.style,s={};if(!r)return s;for(const o in r)(et(r[o])||i&&et(i[o])||Nw(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(s[o]=r[o]);return s}function BN(e){return window.getComputedStyle(e)}var VN=class extends Mw{constructor(){super(...arguments),this.type="html",this.renderInstance=Dw}readValueFromInstance(e,t){if(vs.has(t))return this.projection?.isProjecting?Oh(t):i2(e,t);{const n=BN(e),r=(zb(t)?n.getPropertyValue(t):n[t])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Iw(e,t)}build(e,t,n){lp(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return cp(e,t,n)}},FN={offset:"stroke-dashoffset",array:"stroke-dasharray"},zN={offset:"strokeDashoffset",array:"strokeDasharray"};function $N(e,t,n=1,r=0,i=!0){e.pathLength=1;const s=i?FN:zN;e[s.offset]=`${-r}`,e[s.array]=`${t} ${n}`}var HN=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Lw(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:s=1,pathOffset:o=0,...a},l,c,u){if(lp(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;h.transform&&(f.transform=h.transform,delete h.transform),(f.transform||h.transformOrigin)&&(f.transformOrigin=h.transformOrigin??"50% 50%",delete h.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??"fill-box",delete h.transformBox);for(const d of HN)h[d]!==void 0&&(f[d]=h[d],delete h[d]);t!==void 0&&(h.x=t),n!==void 0&&(h.y=n),r!==void 0&&(h.scale=r),i!==void 0&&$N(h,i,s,o,!1)}var jw=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"]),_w=e=>typeof e=="string"&&e.toLowerCase()==="svg";function WN(e,t,n,r){Dw(e,t,void 0,r);for(const i in t.attrs)e.setAttribute(jw.has(i)?i:ep(i),t.attrs[i])}function Bw(e,t,n){const r=cp(e,t,n);for(const i in e)if(et(e[i])||et(t[i])){const s=gs.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[s]=e[i]}return r}var qN=class extends Mw{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=$e}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(vs.has(t)){const n=vw(t);return n&&n.default||0}return t=jw.has(t)?t:ep(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Bw(e,t,n)}build(e,t,n){Lw(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){WN(e,t,n,r)}mount(e){this.isSVGTag=_w(e.tagName),super.mount(e)}},UN=op.length;function Vw(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Vw(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<UN;n++){const r=op[n],i=e.props[r];(bo(i)||i===!1)&&(t[r]=i)}return t}function Fw(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 KN=[...sp].reverse(),GN=sp.length;function QN(e){return t=>Promise.all(t.map(({animation:n,options:r})=>U2(e,n,r)))}function XN(e){let t=QN(e),n=xg(),r=!0,i=!1;const s=c=>(u,h)=>{const f=Zr(e,h,c==="exit"?e.presenceContext?.custom:void 0);if(f){const{transition:d,transitionEnd:p,...v}=f;u={...u,...v,...p}}return u};function o(c){t=c(e)}function a(c){const{props:u}=e,h=Vw(e.parent)||{},f=[],d=new Set;let p={},v=1/0;for(let x=0;x<GN;x++){const b=KN[x],w=n[b],S=u[b]!==void 0?u[b]:h[b],C=bo(S),T=b===c?w.isActive:null;T===!1&&(v=x);let k=S===h[b]&&S!==u[b]&&C;if(k&&(r||i)&&e.manuallyAnimateOnMount&&(k=!1),w.protectedKeys={...p},!w.isActive&&T===null||!S&&!w.prevProp||bc(S)||typeof S=="boolean")continue;if(b==="exit"&&w.isActive&&T!==!0){w.prevResolvedValues&&(p={...p,...w.prevResolvedValues});continue}const A=YN(w.prevProp,S);let E=A||b===c&&w.isActive&&!k&&C||x>v&&C,R=!1;const O=Array.isArray(S)?S:[S];let M=O.reduce(s(b),{});T===!1&&(M={});const{prevResolvedValues:j={}}=w,N={...j,...M},P=B=>{E=!0,d.has(B)&&(R=!0,d.delete(B)),w.needsAnimating[B]=!0;const H=e.getValue(B);H&&(H.liveStyle=!1)};for(const B in N){const H=M[B],V=j[B];if(p.hasOwnProperty(B))continue;let I=!1;_h(H)&&_h(V)?I=!Fw(H,V):I=H!==V,I?H!=null?P(B):d.add(B):H!==void 0&&d.has(B)?P(B):w.protectedKeys[B]=!0}w.prevProp=S,w.prevResolvedValues=M,w.isActive&&(p={...p,...M}),(r||i)&&e.blockInitialAnimation&&(E=!1);const L=k&&A;E&&(!L||R)&&f.push(...O.map(B=>{const H={type:b};if(typeof B=="string"&&(r||i)&&!L&&e.manuallyAnimateOnMount&&e.parent){const{parent:V}=e,I=Zr(V,B);if(V.enteringChildren&&I){const{delayChildren:ne}=I.transition||{};H.delay=lw(V.enteringChildren,e,ne)}}return{animation:B,options:H}}))}if(d.size){const x={};if(typeof u.initial!="boolean"){const b=Zr(e,Array.isArray(u.initial)?u.initial[0]:u.initial);b&&b.transition&&(x.transition=b.transition)}d.forEach(b=>{const w=e.getBaseTarget(b),S=e.getValue(b);S&&(S.liveStyle=!0),x[b]=w??null}),f.push({animation:x})}let y=!!f.length;return r&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(y=!1),r=!1,i=!1,y?t(f):Promise.resolve()}function l(c,u){if(n[c].isActive===u)return Promise.resolve();e.variantChildren?.forEach(f=>f.animationState?.setActive(c,u)),n[c].isActive=u;const h=a(c);for(const f in n)n[f].protectedKeys={};return h}return{animateChanges:a,setActive:l,setAnimateFunction:o,getState:()=>n,reset:()=>{n=xg(),i=!0}}}function YN(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Fw(t,e):!1}function jr(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function xg(){return{animate:jr(!0),whileInView:jr(),whileHover:jr(),whileTap:jr(),whileDrag:jr(),whileFocus:jr(),exit:jr()}}function qh(e,t){e.min=t.min,e.max=t.max}function Ht(e,t){qh(e.x,t.x),qh(e.y,t.y)}function bg(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var JN=.9999,ZN=1.0001,eL=-.01,tL=.01;function pt(e){return e.max-e.min}function nL(e,t,n){return Math.abs(e-t)<=n}function wg(e,t,n,r=.5){e.origin=r,e.originPoint=Te(t.min,t.max,e.origin),e.scale=pt(n)/pt(t),e.translate=Te(n.min,n.max,e.origin)-e.originPoint,(e.scale>=JN&&e.scale<=ZN||isNaN(e.scale))&&(e.scale=1),(e.translate>=eL&&e.translate<=tL||isNaN(e.translate))&&(e.translate=0)}function Zs(e,t,n,r){wg(e.x,t.x,n.x,r?r.originX:void 0),wg(e.y,t.y,n.y,r?r.originY:void 0)}function Sg(e,t,n,r=0){e.min=(r?Te(n.min,n.max,r):n.min)+t.min,e.max=e.min+pt(t)}function rL(e,t,n,r){Sg(e.x,t.x,n.x,r?.x),Sg(e.y,t.y,n.y,r?.y)}function kg(e,t,n,r=0){const i=r?Te(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+pt(t)}function Dl(e,t,n,r){kg(e.x,t.x,n.x,r?.x),kg(e.y,t.y,n.y,r?.y)}function Cg(e,t,n,r,i){return e-=t,e=Il(e,1/n,r),i!==void 0&&(e=Il(e,1/i,r)),e}function iL(e,t=0,n=1,r=.5,i,s=e,o=e){if(Mn.test(t)&&(t=parseFloat(t),t=Te(o.min,o.max,t/100)-o.min),typeof t!="number")return;let a=Te(s.min,s.max,r);e===s&&(a-=t),e.min=Cg(e.min,t,n,a,i),e.max=Cg(e.max,t,n,a,i)}function Tg(e,t,[n,r,i],s,o){iL(e,t[n],t[r],t[i],t.scale,s,o)}var sL=["x","scaleX","originX"],oL=["y","scaleY","originY"];function Ag(e,t,n,r){Tg(e.x,t,sL,n?n.x:void 0,r?r.x:void 0),Tg(e.y,t,oL,n?n.y:void 0,r?r.y:void 0)}function Rg(e){return e.translate===0&&e.scale===1}function zw(e){return Rg(e.x)&&Rg(e.y)}function Mg(e,t){return e.min===t.min&&e.max===t.max}function aL(e,t){return Mg(e.x,t.x)&&Mg(e.y,t.y)}function Pg(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function $w(e,t){return Pg(e.x,t.x)&&Pg(e.y,t.y)}function Eg(e){return pt(e.x)/pt(e.y)}function Og(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function gn(e){return[e("x"),e("y")]}function lL(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,rotateX:h,rotateY:f,skewX:d,skewY:p}=n;c&&(r=`perspective(${c}px) ${r}`),u&&(r+=`rotate(${u}deg) `),h&&(r+=`rotateX(${h}deg) `),f&&(r+=`rotateY(${f}deg) `),d&&(r+=`skewX(${d}deg) `),p&&(r+=`skewY(${p}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 Hw=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],cL=Hw.length,Ig=e=>typeof e=="string"?parseFloat(e):e,Dg=e=>typeof e=="number"||Q.test(e);function uL(e,t,n,r,i,s){i?(e.opacity=Te(0,n.opacity??1,hL(r)),e.opacityExit=Te(t.opacity??1,0,fL(r))):s&&(e.opacity=Te(t.opacity??1,n.opacity??1,r));for(let o=0;o<cL;o++){const a=Hw[o];let l=Ng(t,a),c=Ng(n,a);l===void 0&&c===void 0||(l||(l=0),c||(c=0),l===0||c===0||Dg(l)===Dg(c)?(e[a]=Math.max(Te(Ig(l),Ig(c),r),0),(Mn.test(c)||Mn.test(l))&&(e[a]+="%")):e[a]=c)}(t.rotate||n.rotate)&&(e.rotate=Te(t.rotate||0,n.rotate||0,r))}function Ng(e,t){return e[t]!==void 0?e[t]:e.borderRadius}var hL=Ww(0,.5,Lb),fL=Ww(.5,.95,Vt);function Ww(e,t,n){return r=>r<e?0:r>t?1:n(yo(e,t,r))}function dL(e,t,n){const r=et(e)?e:ns(e);return r.start(Jd("",r,t,n)),r.animation}function wo(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var pL=(e,t)=>e.depth-t.depth,mL=class{constructor(){this.children=[],this.isDirty=!1}add(e){Fd(this.children,e),this.isDirty=!0}remove(e){Al(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(pL),this.isDirty=!1,this.children.forEach(e)}};function gL(e,t){const n=dt.now(),r=({timestamp:i})=>{const s=i-n;s>=t&&(kr(r),e(s-t))};return Se.setup(r,!0),()=>kr(r)}function Ya(e){return et(e)?e.get():e}var vL=class{constructor(){this.members=[]}add(e){Fd(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&&(Al(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Al(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)}},Ja={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Fr={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},pu=["","X","Y","Z"],yL=1e3,xL=0;function mu(e,t,n,r){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function qw(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=dw(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:s}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Se,!(i||s))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&qw(r)}function Uw({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(o={},a=t?.()){this.id=xL++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,wn.value&&(Fr.nodes=Fr.calculatedTargetDeltas=Fr.calculatedProjections=0),this.nodes.forEach(SL),this.nodes.forEach(ML),this.nodes.forEach(PL),this.nodes.forEach(kL),wn.addProjectionMetrics&&wn.addProjectionMetrics(Fr)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=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 mL)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new zd),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=ip(o)&&!SN(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;Se.read(()=>{h=window.innerWidth}),e(o,()=>{const d=window.innerWidth;d!==h&&(h=d,this.root.updateBlockedByResize=!0,u&&u(),u=gL(f,250),Ja.hasAnimatedSinceResize&&(Ja.hasAnimatedSinceResize=!1,this.nodes.forEach(_g)))})}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 p=this.options.transition||c.getDefaultTransition()||NL,{onLayoutAnimationStart:v,onLayoutAnimationComplete:y}=c.getProps(),x=!this.targetLayout||!$w(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={...Yd(p,"layout"),onPlay:v,onComplete:y};(c.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(u,b)}else h||_g(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(),kr(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(EL),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&&qw(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(TL),this.nodes.forEach(Lg);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(jg);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(AL),this.nodes.forEach(RL),this.nodes.forEach(bL),this.nodes.forEach(wL)):this.nodes.forEach(jg),this.clearAllSnapshots();const o=dt.now();Je.delta=In(0,1e3/60,o-Je.timestamp),Je.timestamp=o,Je.isProcessing=!0,au.update.process(Je),au.preRender.process(Je),au.render.process(Je),Je.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,np.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(CL),this.sharedNodes.forEach(OL)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Se.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Se.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!pt(this.snapshot.measuredBox.x)&&!pt(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.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=$e()),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&&!zw(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;o&&this.instance&&(a||Vr(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)),LL(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return $e();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(jL))){const{scroll:l}=this.root;l&&(xn(a.x,l.offset.x),xn(a.y,l.offset.y))}return a}removeElementScroll(o){const a=$e();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),xn(a.x,u.offset.x),xn(a.y,u.offset.y))}return a}applyTransform(o,a=!1,l){const c=l||$e();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&&(xn(c.x,-h.scroll.offset.x),xn(c.y,-h.scroll.offset.y)),Vr(h.latestValues)&&Xa(c,h.latestValues,h.layout?.layoutBox)}return Vr(this.latestValues)&&Xa(c,this.latestValues,this.layout?.layoutBox),c}removeTransform(o){const a=$e();Ht(a,o);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!Vr(c.latestValues))continue;let u;c.instance&&($h(c.latestValues)&&c.updateSnapshot(),u=$e(),Ht(u,c.measurePageBox())),Ag(a,c.latestValues,c.snapshot?.layoutBox,u)}return Vr(this.latestValues)&&Ag(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!==Je.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=Je.timestamp;const h=this.getClosestProjectingParent();h&&this.linkedParentVersion!==h.layoutVersion&&!h.options.layoutRoot&&this.removeRelativeTarget(),!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=$e(),this.targetWithTransforms=$e()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),rL(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),Ow(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),wn.value&&Fr.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||$h(this.parent.latestValues)||Ew(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.linkedParentVersion=o.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=$e(),this.relativeTargetOrigin=$e(),Dl(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===Je.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;IN(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=$e());const{target:d}=o;if(!d){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(bg(this.prevProjectionDelta.x,this.projectionDelta.x),bg(this.prevProjectionDelta.y,this.projectionDelta.y)),Zs(this.projectionDelta,this.layoutCorrected,d,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==f||!Og(this.projectionDelta.x,this.prevProjectionDelta.x)||!Og(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",d)),wn.value&&Fr.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=Li(),this.projectionDelta=Li(),this.projectionDeltaWithTransform=Li()}setAnimationOrigin(o,a=!1){const l=this.snapshot,c=l?l.latestValues:{},u={...this.latestValues},h=Li();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=$e(),d=(l?l.source:void 0)!==(this.layout?this.layout.source:void 0),p=this.getStack(),v=!p||p.members.length<=1,y=!!(d&&!v&&this.options.crossfade===!0&&!this.path.some(DL));this.animationProgress=0;let x;this.mixTargetDelta=b=>{const w=b/1e3;Bg(h.x,o.x,w),Bg(h.y,o.y,w),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Dl(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),IL(this.relativeTarget,this.relativeTargetOrigin,f,w),x&&aL(this.relativeTarget,x)&&(this.isProjectionDirty=!1),x||(x=$e()),Ht(x,this.relativeTarget)),d&&(this.animationValues=u,uL(u,c,this.latestValues,w,y,v)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=w},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(kr(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Se.update(()=>{Ja.hasAnimatedSinceResize=!0,Yr.layout++,this.motionValue||(this.motionValue=ns(0)),this.motionValue.jump(0,!1),this.currentAnimation=dL(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{Yr.layout--},onComplete:()=>{Yr.layout--,o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);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(yL),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:c,latestValues:u}=o;if(!(!a||!l||!c)){if(this!==o&&this.layout&&c&&Kw(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||$e();const h=pt(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+h;const f=pt(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}Ht(a,l),Xa(a,u),Zs(this.projectionDeltaWithTransform,this.layoutCorrected,a,u)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new vL),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&&mu("z",o,c,this.animationValues);for(let u=0;u<pu.length;u++)mu(`rotate${pu[u]}`,o,c,this.animationValues),mu(`skew${pu[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=Ya(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=Ya(a?.pointerEvents)||""),this.hasProjected&&!Vr(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let h=lL(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 p in Wh){if(u[p]===void 0)continue;const{correct:v,applyTo:y,isCSSVariable:x}=Wh[p],b=h==="none"?u[p]:v(u[p],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[p]=b:o[p]=b}this.options.layoutId&&(o.pointerEvents=c===this?Ya(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(Lg),this.root.sharedNodes.clear()}}}function bL(e){e.updateLayout()}function wL(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")gn(u=>{const h=s?t.measuredBox[u]:t.layoutBox[u],f=pt(h);h.min=n[u].min,h.max=h.min+f});else if(i==="x"||i==="y"){const u=i==="x"?"y":"x";qh(s?t.measuredBox[u]:t.layoutBox[u],n[u])}else Kw(i,t.layoutBox,n)&&gn(u=>{const h=s?t.measuredBox[u]:t.layoutBox[u],f=pt(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=Li();Zs(o,n,t.layoutBox);const a=Li();s?Zs(a,e.applyTransform(r,!0),t.measuredBox):Zs(a,n,t.layoutBox);const l=!zw(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,p=$e();Dl(p,t.layoutBox,h.layoutBox,d);const v=$e();Dl(v,n,f.layoutBox,d),$w(p,v)||(c=!0),u.options.layoutRoot&&(e.relativeTarget=v,e.relativeTargetOrigin=p,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 SL(e){wn.value&&Fr.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 kL(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function CL(e){e.clearSnapshot()}function Lg(e){e.clearMeasurements()}function TL(e){e.isLayoutDirty=!0,e.updateLayout()}function jg(e){e.isLayoutDirty=!1}function AL(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function RL(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function _g(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function ML(e){e.resolveTargetDelta()}function PL(e){e.calcProjection()}function EL(e){e.resetSkewAndRotation()}function OL(e){e.removeLeadSnapshot()}function Bg(e,t,n){e.translate=Te(t.translate,0,n),e.scale=Te(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Vg(e,t,n,r){e.min=Te(t.min,n.min,r),e.max=Te(t.max,n.max,r)}function IL(e,t,n,r){Vg(e.x,t.x,n.x,r),Vg(e.y,t.y,n.y,r)}function DL(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var NL={duration:.45,ease:[.4,0,.1,1]},Fg=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),zg=Fg("applewebkit/")&&!Fg("chrome/")?Math.round:Vt;function $g(e){e.min=zg(e.min),e.max=zg(e.max)}function LL(e){$g(e.x),$g(e.y)}function Kw(e,t,n){return e==="position"||e==="preserve-aspect"&&!nL(Eg(t),Eg(n),.2)}function jL(e){return e!==e.root&&e.scroll?.wasRoot}var _L=Uw({attachResizeListener:(e,t)=>wo(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),gu={current:void 0},Gw=Uw({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!gu.current){const e=new _L({});e.mount(window),e.setOptions({layoutScroll:!0}),gu.current=e}return gu.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Qw=(0,m.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function BL(e=!0){const t=(0,m.useContext)(Vd);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:i}=t,s=(0,m.useId)();(0,m.useEffect)(()=>{if(e)return i(s)},[e]);const o=(0,m.useCallback)(()=>e&&r&&r(s),[s,r,e]);return!n&&r?[!1,o]:[!0]}var Xw=(0,m.createContext)({strict:!1}),Hg={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"]},Wg=!1;function VL(){if(Wg)return;const e={};for(const t in Hg)e[t]={isEnabled:n=>Hg[t].some(r=>!!n[r])};Rw(e),Wg=!0}function Yw(){return VL(),MN()}function FL(e){const t=Yw();for(const n in e)t[n]={...t[n],...e[n]};Rw(t)}var zL=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Nl(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||zL.has(e)}var $L=XC({default:()=>Jw}),Jw,HL=QC((()=>{throw Jw={},new Error('Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?')})),Zw=e=>!Nl(e);function WL(e){typeof e=="function"&&(Zw=t=>t.startsWith("on")?!Nl(t):e(t))}try{WL((HL(),GC($L)).default)}catch{}function qL(e,t,n){const r={};for(const i in e)i==="values"&&typeof e.values=="object"||et(e[i])||(Zw(i)||n===!0&&Nl(i)||!t&&!Nl(i)||e.draggable&&i.startsWith("onDrag"))&&(r[i]=e[i]);return r}var Sc=(0,m.createContext)({});function UL(e,t){if(wc(e)){const{initial:n,animate:r}=e;return{initial:n===!1||bo(n)?n:void 0,animate:bo(r)?r:void 0}}return e.inherit!==!1?t:{}}function KL(e){const{initial:t,animate:n}=UL(e,(0,m.useContext)(Sc));return(0,m.useMemo)(()=>({initial:t,animate:n}),[qg(t),qg(n)])}function qg(e){return Array.isArray(e)?e.join(" "):e}var up=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function eS(e,t,n){for(const r in t)!et(t[r])&&!Nw(r,n)&&(e[r]=t[r])}function GL({transformTemplate:e},t){return(0,m.useMemo)(()=>{const n=up();return lp(n,t,e),Object.assign({},n.vars,n.style)},[t])}function QL(e,t){const n=e.style||{},r={};return eS(r,n,e),Object.assign(r,GL(e,t)),r}function XL(e,t){const n={},r=QL(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 tS=()=>({...up(),attrs:{}});function YL(e,t,n,r){const i=(0,m.useMemo)(()=>{const s=tS();return Lw(s,t,_w(r),e.transformTemplate,e.style),{...s.attrs,style:{...s.style}}},[t]);if(e.style){const s={};eS(s,e.style,e),i.style={...s,...i.style}}return i}var JL=["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 hp(e){return typeof e!="string"||e.includes("-")?!1:!!(JL.indexOf(e)>-1||/[A-Z]/u.test(e))}function ZL(e,t,n,{latestValues:r},i,s=!1,o){const a=(o??hp(e)?YL:XL)(t,r,i,e),l=qL(t,typeof e=="string",s),c=e!==m.Fragment?{...l,...a,ref:n}:{},{children:u}=t,h=(0,m.useMemo)(()=>et(u)?u.get():u,[u]);return(0,m.createElement)(e,{...c,children:h})}function ej({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:tj(n,r,i,e),renderState:t()}}function tj(e,t,n,r){const i={},s=r(e,{});for(const f in s)i[f]=Ya(s[f]);let{initial:o,animate:a}=e;const l=wc(e),c=Tw(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"&&!bc(h)){const f=Array.isArray(h)?h:[h];for(let d=0;d<f.length;d++){const p=Zd(e,f[d]);if(p){const{transitionEnd:v,transition:y,...x}=p;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 nS=e=>(t,n)=>{const r=(0,m.useContext)(Sc),i=(0,m.useContext)(Vd),s=()=>ej(e,t,r,i);return n?s():YI(s)},nj=nS({scrapeMotionValuesFromProps:cp,createRenderState:up}),rj=nS({scrapeMotionValuesFromProps:Bw,createRenderState:tS}),ij=Symbol.for("motionComponentSymbol");function sj(e,t,n){const r=(0,m.useRef)(n);(0,m.useInsertionEffect)(()=>{r.current=n});const i=(0,m.useRef)(null);return(0,m.useCallback)(s=>{s&&e.onMount?.(s);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&&(s?t.mount(s):t.unmount())},[t])}var rS=(0,m.createContext)({});function Mi(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function oj(e,t,n,r,i,s){const{visualElement:o}=(0,m.useContext)(Sc),a=(0,m.useContext)(Xw),l=(0,m.useContext)(Vd),c=(0,m.useContext)(Qw),u=c.reducedMotion,h=c.skipAnimations,f=(0,m.useRef)(null),d=(0,m.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 p=f.current,v=(0,m.useContext)(rS);p&&!p.projection&&i&&(p.type==="html"||p.type==="svg")&&aj(f.current,n,i,v);const y=(0,m.useRef)(!1);(0,m.useInsertionEffect)(()=>{p&&y.current&&p.update(n,l)});const x=n[fw],b=(0,m.useRef)(!!x&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(x)&&window.MotionHasOptimisedAnimation?.(x));return ZI(()=>{d.current=!0,p&&(y.current=!0,window.MotionIsMounted=!0,p.updateFeatures(),p.scheduleRenderMicrotask(),b.current&&p.animationState&&p.animationState.animateChanges())}),(0,m.useEffect)(()=>{p&&(!b.current&&p.animationState&&p.animationState.animateChanges(),b.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(x)}),b.current=!1),p.enteringChildren=void 0)}),p}function aj(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:iS(e.parent)),e.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!o||a&&Mi(a),visualElement:e,animationType:typeof s=="string"?s:"both",initialPromotionConfig:r,crossfade:h,layoutScroll:l,layoutRoot:c,layoutAnchor:u})}function iS(e){if(e)return e.options.allowProjection!==!1?e.projection:iS(e.parent)}function vu(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&FL(r);const s=n?n==="svg":hp(e),o=s?rj:nj;function a(c,u){let h;const f={...(0,m.useContext)(Qw),...c,layoutId:lj(c)},{isStatic:d}=f,p=KL(c),v=o(c,d);if(!d&&typeof window<"u"){cj(f,r);const y=uj(f);h=y.MeasureLayout,p.visualElement=oj(e,v,f,i,y.ProjectionNode,s)}return(0,g.jsxs)(Sc.Provider,{value:p,children:[h&&p.visualElement?(0,g.jsx)(h,{visualElement:p.visualElement,...f}):null,ZL(e,c,sj(v,p.visualElement,u),v,d,t,s)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const l=(0,m.forwardRef)(a);return l[ij]=e,l}function lj({layoutId:e}){const t=(0,m.useContext)(kb).id;return t&&e!==void 0?t+"-"+e:e}function cj(e,t){(0,m.useContext)(Xw).strict}function uj(e){const{drag:t,layout:n}=Yw();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 vu;const n=new Map,r=(s,o)=>vu(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,vu(o,void 0,e,t)),n.get(o))})}var fj=(e,t)=>t.isSVG??hp(e)?new qN(t):new VN(t,{allowProjection:e!==m.Fragment}),dj=class extends Ir{constructor(e){super(e),e.animationState||(e.animationState=XN(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();bc(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?.()}},pj=0,mj=class extends Ir{constructor(){super(...arguments),this.id=pj++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){const{initial:i,custom:s}=this.node.getProps();if(typeof i=="string"){const o=Zr(this.node,i,s);if(o){const{transition:a,transitionEnd:l,...c}=o;for(const u in c)this.node.getValue(u)?.jump(c[u])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(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:dj},exit:{Feature:mj}};function Go(e){return{point:{x:e.pageX,y:e.pageY}}}var vj=e=>t=>rp(t)&&e(t,Go(t));function eo(e,t,n,r){return wo(e,t,vj(n),r)}var sS=({current:e})=>e?e.ownerDocument.defaultView:null,Ug=(e,t)=>Math.abs(e-t);function yj(e,t){const n=Ug(e.x,t.x),r=Ug(e.y,t.y);return Math.sqrt(n**2+r**2)}var Kg=new Set(["auto","scroll"]),oS=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=h=>{this.handleScroll(h.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=ga(this.lastRawMoveEventInfo,this.transformPagePoint));const h=yu(this.lastMoveEventInfo,this.history),f=this.startEvent!==null,d=yj(h.offset,{x:0,y:0})>=this.distanceThreshold;if(!f&&!d)return;const{point:p}=h,{timestamp:v}=Je;this.history.push({...p,timestamp:v});const{onStart:y,onMove:x}=this.handlers;f||(y&&y(this.lastMoveEvent,h),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,h)},this.handlePointerMove=(h,f)=>{this.lastMoveEvent=h,this.lastRawMoveEventInfo=f,this.lastMoveEventInfo=ga(f,this.transformPagePoint),Se.update(this.updatePoint,!0)},this.handlePointerUp=(h,f)=>{this.end();const{onEnd:d,onSessionEnd:p,resumeAnimation:v}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&v&&v(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=yu(h.type==="pointercancel"?this.lastMoveEventInfo:ga(f,this.transformPagePoint),this.history);this.startEvent&&d&&d(h,y),p&&p(h,y)},!rp(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=s,this.contextWindow=r||window;const a=ga(Go(e),this.transformPagePoint),{point:l}=a,{timestamp:c}=Je;this.history=[{...l,timestamp:c}];const{onSessionStart:u}=t;u&&u(e,yu(a,this.history)),this.removeListeners=qo(eo(this.contextWindow,"pointermove",this.handlePointerMove),eo(this.contextWindow,"pointerup",this.handlePointerUp),eo(this.contextWindow,"pointercancel",this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){const n=getComputedStyle(t);(Kg.has(n.overflowX)||Kg.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),Se.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),kr(this.updatePoint)}};function ga(e,t){return t?{point:t(e.point)}:e}function Gg(e,t){return{x:e.x-t.x,y:e.y-t.y}}function yu({point:e},t){return{point:e,delta:Gg(e,aS(t)),offset:Gg(e,xj(t)),velocity:bj(t,.1)}}function xj(e){return e[0]}function aS(e){return e[e.length-1]}function bj(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const i=aS(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>bt(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>bt(t)*2&&(r=e[1]);const s=_t(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 wj(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?Te(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?Te(n,e,r.max):Math.min(e,n)),e}function Qg(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 Sj(e,{top:t,left:n,bottom:r,right:i}){return{x:Qg(e.x,n,i),y:Qg(e.y,t,r)}}function Xg(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 kj(e,t){return{x:Xg(e.x,t.x),y:Xg(e.y,t.y)}}function Cj(e,t){let n=.5;const r=pt(e),i=pt(t);return i>r?n=yo(t.min,t.max-r,e.min):r>i&&(n=yo(e.min,e.max-i,t.min)),In(0,1,n)}function Tj(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 Uh=.35;function Aj(e=Uh){return e===!1?e=0:e===!0&&(e=Uh),{x:Yg(e,"left","right"),y:Yg(e,"top","bottom")}}function Yg(e,t,n){return{min:Jg(e,t),max:Jg(e,n)}}function Jg(e,t){return typeof e=="number"?e:e[t]||0}var Rj=new WeakMap,Mj=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=$e(),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(Go(u).point),this.stopAnimation()},s=(u,h)=>{const{drag:f,dragPropagation:d,onDragStart:p}=this.getProps();if(f&&!d&&(this.openDragLock&&this.openDragLock(),this.openDragLock=sN(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),gn(y=>{let x=this.getAxisMotionValue(y).get()||0;if(Mn.test(x)){const{projection:b}=this.visualElement;if(b&&b.layout){const w=b.layout.layoutBox[y];w&&(x=pt(w)*(parseFloat(x)/100))}}this.originPoint[y]=x}),p&&Se.update(()=>p(u,h),!1,!0),Bh(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:p,onDrag:v}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:y}=h;if(d&&this.currentDirection===null){this.currentDirection=Ej(y),this.currentDirection!==null&&p&&p(this.currentDirection);return}this.updateAxis("x",h.point,y),this.updateAxis("y",h.point,y),this.visualElement.render(),v&&Se.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 oS(e,{onSessionStart:i,onStart:s,onMove:o,onSessionEnd:a,resumeAnimation:l},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:n,contextWindow:sS(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&&Se.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||!va(e,r,this.currentDirection))return;const i=this.getAxisMotionValue(e);let s=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(s=wj(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&&Mi(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&n?this.constraints=Sj(n.layoutBox,e):this.constraints=!1,this.elastic=Aj(t),r!==this.constraints&&!Mi(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&gn(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=Tj(n.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Mi(e))return!1;const n=e.current;es(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;const i=DN(n,r.root,this.visualElement.getTransformPagePoint());let s=kj(r.layout.layoutBox,i);if(t){const o=t(EN(s));this.hasMutatedConstraints=!!o,o&&(s=Pw(o))}return s}startAnimation(e){const{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:s,onDragTransitionEnd:o}=this.getProps(),a=this.constraints||{},l=gn(c=>{if(!va(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 Bh(this.visualElement,e),n.start(Jd(e,n,0,t,this.visualElement,!1))}stopAnimation(){gn(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps(),r=n[t];return r||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){gn(t=>{const{drag:n}=this.getProps();if(!va(t,n,this.currentDirection))return;const{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){const{min:s,max:o}=r.layout.layoutBox[t],a=i.get()||0;i.set(e[t]-Te(s,o,.5)+a)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Mi(t)||!n||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};gn(s=>{const o=this.getAxisMotionValue(s);if(o&&this.constraints!==!1){const a=o.get();r[s]=Cj({min:a,max:a},this.constraints[s])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),gn(s=>{if(!va(s,e,null))return;const o=this.getAxisMotionValue(s),{min:a,max:l}=this.constraints[s];o.set(Te(a,l,r[s]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Rj.set(this.visualElement,this);const e=this.visualElement.current,t=eo(e,"pointerdown",l=>{const{drag:c,dragListener:u=!0}=this.getProps(),h=l.target,f=h!==e&&hN(h);c&&u&&!f&&this.start(l)});let n;const r=()=>{const{dragConstraints:l}=this.getProps();Mi(l)&&l.current&&(this.constraints=this.resolveRefConstraints(),n||(n=Pj(e,l.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,s=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Se.read(r);const o=wo(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(gn(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=Uh,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:s,dragMomentum:o}}};function Zg(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Pj(e,t,n){const r=lg(e,Zg(n)),i=lg(t,Zg(n));return()=>{r(),i()}}function va(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Ej(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}var Oj=class extends Ir{constructor(e){super(e),this.removeGroupControls=Vt,this.removeListeners=Vt,this.controls=new Mj(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Vt}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()}},xu=e=>(t,n)=>{e&&Se.update(()=>e(t,n),!1,!0)},Ij=class extends Ir{constructor(){super(...arguments),this.removePointerDownListener=Vt}onPointerDown(e){this.session=new oS(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:sS(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:xu(e),onStart:xu(t),onMove:xu(n),onEnd:(i,s)=>{delete this.session,r&&Se.postRender(()=>r(i,s))}}}mount(){this.removePointerDownListener=eo(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},bu=!1,Dj=class extends m.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),bu&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Ja.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}),bu=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?s.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?s.promote():s.relegate()||Se.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(),np.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;bu=!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 lS(e){const[t,n]=BL(),r=(0,m.useContext)(kb);return(0,g.jsx)(Dj,{...e,layoutGroup:r,switchLayoutGroup:(0,m.useContext)(rS),isPresent:t,safeToRemove:n})}var Nj={pan:{Feature:Ij},drag:{Feature:Oj,ProjectionNode:Gw,MeasureLayout:lS}};function e0(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i=r["onHover"+n];i&&Se.postRender(()=>i(t,Go(t)))}var Lj=class extends Ir{mount(){const{current:e}=this.node;e&&(this.unmount=aN(e,(t,n)=>(e0(this.node,n,"Start"),r=>e0(this.node,r,"End"))))}unmount(){}},jj=class extends Ir{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=qo(wo(this.node.current,"focus",()=>this.onFocus()),wo(this.node.current,"blur",()=>this.onBlur()))}unmount(){}};function t0(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&&Se.postRender(()=>i(t,Go(t)))}var _j=class extends Ir{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=dN(e,(r,i)=>(t0(this.node,i,"Start"),(s,{success:o})=>t0(this.node,s,o?"End":"Cancel")),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},Kh=new WeakMap,wu=new WeakMap,Bj=e=>{const t=Kh.get(e.target);t&&t(e)},Vj=e=>{e.forEach(Bj)};function Fj({root:e,...t}){const n=e||document;wu.has(n)||wu.set(n,{});const r=wu.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Vj,{root:e,...t})),r[i]}function zj(e,t,n){const r=Fj(t);return Kh.set(e,n),r.observe(e),()=>{Kh.delete(e),r.unobserve(e)}}var $j={some:0,all:1},Hj=class extends Ir{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:$j[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=zj(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(Wj(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function Wj({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var qj={inView:{Feature:Hj},tap:{Feature:_j},focus:{Feature:jj},hover:{Feature:Lj}},Uj={layout:{ProjectionNode:Gw,MeasureLayout:lS}},Kj={...gj,...qj,...Nj,...Uj},cS=hj(Kj,fj);function Gj(){!ap.current&&Aw();const[e]=(0,m.useState)(El.current);return e}function Qj({delayDuration:e=0,...t}){return(0,g.jsx)(AE,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function zr({...e}){return(0,g.jsx)(Qj,{children:(0,g.jsx)(RE,{"data-slot":"tooltip",...e})})}function $r({...e}){return(0,g.jsx)(ME,{"data-slot":"tooltip-trigger",...e})}function Hr({className:e,sideOffset:t=0,children:n,variant:r="default",...i}){const s=r==="muted";return(0,g.jsx)(PE,{children:(0,g.jsxs)(EE,{"data-slot":"tooltip-content",sideOffset:t,className:X("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) rounded-md px-3 py-1.5 text-xs text-balance",s?"border border-border bg-popover text-popover-foreground shadow-md":"bg-primary text-primary-foreground",e),...i,children:[n,(0,g.jsx)(OE,{className:X("z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]",s?"fill-popover":"bg-primary fill-primary")})]})})}var Xj=50,Su="null";function xi(){return{line:1,column:1}}function Yj(e){if(e===void 0)return Su;try{return JSON.stringify(e,null,2)??Su}catch{return Su}}function bi(e){try{return{value:JSON.parse(e),error:null}}catch(t){return{value:void 0,error:t instanceof Error?t.message:"Invalid JSON"}}}function wi(e){try{return JSON.stringify(e)}catch{return null}}function Hi(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null)return Hi(t)}catch{}return e}if(Array.isArray(e))return e.map(Hi);if(typeof e=="object"&&e!==null){const t={};for(const[n,r]of Object.entries(e))t[n]=Hi(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 ya(e,t,n){return e!==void 0?e:Yj(n?Hi(t):t)}function Jj({initialValue:e,initialContent:t,onChange:n,onRawChange:r,onValidationError:i,expandJsonStrings:s=!1}){const o=(0,m.useRef)(null);if(o.current===null){const P=ya(t,e,s),L=bi(P);let B;L.error!==null?B=null:s?B=wi(to(L.value,e)):B=wi(L.value),o.current={content:P,lastEmitted:B,error:L.error}}const[a,l]=(0,m.useState)(o.current.content),c=(0,m.useRef)(e),u=(0,m.useRef)(o.current.content),h=(0,m.useRef)(o.current.content),f=(0,m.useRef)(o.current.lastEmitted),[d,p]=(0,m.useState)(o.current.error),[v,y]=(0,m.useState)(xi),x=(0,m.useRef)([{content:o.current.content,cursorPosition:xi()}]),b=(0,m.useRef)(0),w=(0,m.useCallback)(P=>{const L=bi(P);return p(L.error),i?.(L.error),L},[i]);(0,m.useEffect)(()=>{u.current=a},[a]);const S=(0,m.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 P=wi(e);P!==null&&P===f.current?(c.current=e,h.current=u.current):(c.current=e,h.current=ya(void 0,e,!0))}else c.current=e,h.current=ya(t,e,s);(0,m.useEffect)(()=>{const P=h.current;if(P===u.current)return;u.current=P,l(P),y(xi()),x.current=[{content:P,cursorPosition:xi()}],b.current=0,w(P);const L=bi(P);if(L.error===null&&s){const B=to(L.value,e);f.current=wi(B)}else f.current=L.error===null?wi(L.value):null},[e,t,w,s]);const C=(0,m.useCallback)((P,L,B)=>{r?.(P);const H=V=>{const I=s?to(V,c.current):V,ne=wi(I);if(ne===null){n?.(I);return}ne!==f.current&&(f.current=ne,n?.(I))};if(B===void 0){const V=bi(P);V.error===null&&H(V.value);return}B===null&&H(L)},[n,r,s]),T=(0,m.useCallback)(P=>{if(P===u.current)return;u.current=P,l(P);const{value:L,error:B}=w(P),H=b.current;let V=x.current;H<V.length-1&&(V=V.slice(0,H+1));const I=V[V.length-1];(!I||I.content!==P)&&(V=[...V,{content:P,cursorPosition:v}]),V.length>Xj&&(V=V.slice(-50)),x.current=V,b.current=V.length-1,C(P,L,B)},[v,C,w]),k=(0,m.useCallback)(P=>{u.current=P.content,l(P.content),y(P.cursorPosition);const{value:L,error:B}=w(P.content);C(P.content,L,B)},[C,w]),A=(0,m.useCallback)(()=>{const P=x.current,L=b.current;if(L>0){b.current=L-1;const B=P[L-1];k(B)}},[k]),E=(0,m.useCallback)(()=>{const P=x.current,L=b.current;if(L<P.length-1){b.current=L+1;const B=P[L+1];k(B)}},[k]),R=(0,m.useCallback)(()=>{const{value:P,error:L}=bi(a);if(L===null){const B=s?Hi(P):P,H=JSON.stringify(B,null,2);T(H)}},[a,T,s]),O=(0,m.useCallback)(()=>{c.current=e;const P=ya(t,e,s);h.current=P,u.current=P,l(P),y(xi()),x.current=[{content:P,cursorPosition:xi()}],b.current=0;const{value:L,error:B}=w(P);C(P,L,B)},[e,t,w,C,s]),M=(0,m.useCallback)(()=>{const{value:P,error:L}=bi(a);return L===null?P:void 0},[a]),j=b.current>0,N=b.current<x.current.length-1;return{content:a,setContent:T,isValid:d===null,validationError:d,cursorPosition:v,setCursorPosition:y,undo:A,redo:E,canUndo:j,canRedo:N,format:R,reset:O,getParsedValue:M,sourceContent:h.current}}function Zj(e){return typeof e=="object"?e.key:e}function e_(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 Si(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 n0(e,t){if(e===void 0)throw new Error(`Unexpected undefined${t?`: ${t}`:""}`);return e}var r0=(e,t)=>Math.abs(e-t)<1.01,t_=(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)}})},Rs,ku=()=>{if(Rs!==void 0)return Rs;if(typeof navigator>"u")return Rs=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Rs=!0;const e=navigator.maxTouchPoints;return Rs=navigator.platform==="MacIntel"&&e!==void 0&&e>0},i0=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},n_=e=>e,r_=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},i_=(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(i0(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(i0(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},Ll={passive:!0},s_=typeof window>"u"?!0:"onscrollend"in window,o_=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const i=e.targetWindow;if(!i)return;const s=e.options.useScrollendEvent&&s_;let o=0;const a=s?null:t_(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,Ll),s&&r.addEventListener("scrollend",u,Ll),()=>{r.removeEventListener("scroll",c),s&&r.removeEventListener("scrollend",u),a?.cancel()}},a_=(e,t)=>o_(e,t,n=>{const{horizontal:r,isRtl:i}=e.options;return r?n.scrollLeft*(i&&-1||1):n.scrollTop}),l_=(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"]},c_=(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})},u_=c_;function h_(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 f_=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:n_,rangeExtractor:r_,onChange:()=>{},measureElement:l_,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,p=x=>Zj(d[x]),v=u>0?p(0):null,y=u>0?p(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||h_(u,h,p,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:p}=this.options;let v=0;for(;v<d&&p(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=Si(()=>(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,!(!ku()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};s.addEventListener("touchstart",o,Ll),s.addEventListener("touchend",a,Ll),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&&(ku()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):((n=this.scrollState)==null?void 0:n.behavior)==="smooth"&&!r0(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=Si(()=>[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=Si(()=>[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 T=new Float64Array(x);b&&f>0&&T.set(b.subarray(0,f*2)),b=T}const w=f===0?new Array(t):this._singleLaneMeasurements.items.slice();let S;if(f===0)S=n+r;else{const T=f-1;S=b[T*2]+b[T*2+1]+l}for(let T=f;T<t;T++){const k=i(T);w[T]=k;const A=h.get(k),E=typeof A=="number"?A:this.options.estimateSize(T);b[T*2]=S,b[T*2+1]=E,S+=E+l}this._singleLaneMeasurements={flat:b,items:w};const C=e_(w,b);return this.measurementsCache=C,C}const d=this.measurementsCache.slice(0,f),p=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&&(p[b.lane]===void 0&&y++,p[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 T=a==="estimate"||h.has(b);if(w!==void 0&&this.options.lanes>1){S=w;const R=p[S],O=R!==void 0?d[R]:void 0;C=O?O.end+l:n+r}else if(y===o){let R=0,O=v[0],M=p[0];for(let j=1;j<o;j++){const N=v[j];(N<O||N===O&&p[j]<M)&&(R=j,O=N,M=p[j])}S=R,C=O+l,T&&this.laneAssignments.set(x,S)}else S=x%this.options.lanes,C=n+r,T&&this.laneAssignments.set(x,S);const k=h.get(b),A=typeof k=="number"?k:this.options.estimateSize(x),E=C+A;d[x]={index:x,start:C,size:A,end:E,key:b,lane:S},p[S]===void 0&&y++,p[S]=x,v[S]=E}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Si(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,n,r,i)=>t.length===0||n===0?(this.range=null,null):(this.range=p_(t,n,r,i,i===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Si(()=>{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,p=this.getScrollOffset()+this.scrollAdjustments,v=this.itemSizeCache.has(l)?a+u<=p&&this.scrollDirection!=="backward":a<p,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=Si(()=>[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=uS(0,r.length-1,s?a=>i[a*2]:a=>n0(r[a]).start,t);return n0(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(ku()&&(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&&r0(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()}},uS=(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 d_(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 p_(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=d_(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=uS(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 Cu=typeof document<"u"?m.useLayoutEffect:m.useEffect;function m_({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...r}){const i=m.useReducer(h=>h+1,0)[1],s=m.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});s.current.enabled=t,s.current.mode=n;const o=m.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 p=h.options.horizontal?"width":"height";f.container.style[p]=`${d}px`}},l=h=>{const f=s.current;if(!f.enabled||!f.container)return;a(h);const d=!!h.options.horizontal,p=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),p?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 p=s.current;let v=!0;if(p.enabled){l(h);const y=h.range,x=p.prevRange;v=!x||x.isScrolling!==h.isScrolling||x.startIndex!==y?.startIndex||x.endIndex!==y?.endIndex,v&&(p.prevRange=y?{startIndex:y.startIndex,endIndex:y.endIndex,isScrolling:h.isScrolling}:null)}v&&(e&&f&&!o.current?(0,_o.flushSync)(i):i()),(d=r.onChange)==null||d.call(r,h,f)}},[u]=m.useState(()=>{const h=new f_(c),f=h.measureElement;return h.measureElement=d=>{o.current=!0;try{f(d)}finally{o.current=!1}},Object.assign(h,{containerRef:d=>{const p=s.current;if(p.container=d,p.lastSize=null,d&&p.enabled){const v=h.getTotalSize();p.lastSize=v;const y=h.options.horizontal?"width":"height";d.style[y]=`${v}px`}}})});return u.setOptions(c),Cu(()=>u._didMount(),[]),Cu(()=>(a(u),u._willUpdate())),Cu(()=>{l(u)}),u}function g_(e){return m_({observeElementRect:i_,observeElementOffset:a_,scrollToFn:u_,...e})}function v_(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}function hS(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 p;try{p=JSON.parse(d)}catch{p=d.slice(1,-1)}u=p,t.push({type:"key",value:d,start:f,end:n,path:[...c,p],keyName:p})}else{const p=u!==null?[...c,u]:[...c];t.push({type:"string",value:d,start:f,end:n,path:p,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(),p=u!==null?[...c,u]:[...c];t.push({type:"number",value:d,start:f,end:n,path:p,keyName:u??void 0}),u=null,l=!1;break}case"t":case"f":{const d=o(),p=u!==null?[...c,u]:[...c];d==="true"?t.push({type:"boolean",value:d,start:f,end:n,path:p,keyName:u??void 0}):d==="false"&&t.push({type:"boolean-false",value:d,start:f,end:n,path:p,keyName:u??void 0}),u=null,l=!1;break}case"n":{const d=o();if(d==="null"){const p=u!==null?[...c,u]:[...c];t.push({type:"null",value:d,start:f,end:n,path:p,keyName:u??void 0}),u=null}l=!1;break}default:n++}}return t}function fS(e){const t=hS(e);let n="",r=0;const i=s=>{s&&(n+=`<span class="json-punctuation">${s0(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}">${s0(s.value)}</span>`,r=s.end}return r<e.length&&i(e.slice(r)),n}function s0(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function dS({value:e,displayValue:t,maxLength:n,onCopy:r,keyName:i,path:s}){const[o,a]=(0,m.useState)(null),[l,c]=(0,m.useState)(!1),[u,h]=(0,m.useState)(!1),f=e.length>n,d=f&&!u?`"${e.slice(0,n)}..."`:t,p=(0,m.useCallback)(async(b,w)=>{await vc(b)&&(a(w),r?.(b),setTimeout(()=>a(null),1500))},[r]),v=(0,m.useCallback)(b=>{f&&(b.stopPropagation(),h(w=>!w))},[f]),y=s&&s.length>0?v_(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,g.jsxs)("span",{className:"relative group/copy",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[(0,g.jsx)("span",{onClick:v,className:X("json-string",f&&!u&&"json-string-truncated"),children:d}),(0,g.jsx)("button",{onClick:b=>{b.stopPropagation(),p(x[0].value,x[0].key)},className:X("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,g.jsx)(Ji,{className:"h-3 w-3 text-green-500"}):(0,g.jsx)($i,{className:"h-3 w-3 text-muted-foreground/60 hover:text-muted-foreground"})})]}):(0,g.jsxs)("span",{className:"relative group/copy",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[(0,g.jsx)("span",{onClick:v,className:X("json-string",f&&!u&&"json-string-truncated"),children:d}),(0,g.jsxs)(xb,{children:[(0,g.jsx)(bb,{asChild:!0,children:(0,g.jsx)("button",{className:X("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,g.jsx)(Ji,{className:"h-3 w-3 text-green-500"}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)($i,{className:"h-3 w-3 text-muted-foreground/60"}),(0,g.jsx)(yb,{className:"h-2 w-2 text-muted-foreground/60 -ml-0.5"})]})})}),(0,g.jsx)(wb,{align:"start",className:"min-w-[140px]",children:x.map(b=>(0,g.jsxs)(UI,{onClick:()=>p(b.value,b.key),className:"text-xs",children:[(0,g.jsx)($i,{className:"h-3 w-3 mr-2"}),b.label]},b.key))})]})]})}function o0(e,t){return t?(0,g.jsx)("span",{className:"json-punctuation",children:t},e):null}function Tu({children:e,value:t,onCopy:n}){const[r,i]=(0,m.useState)(!1),[s,o]=(0,m.useState)(!1),a=(0,m.useCallback)(async l=>{await vc(l)&&(i(!0),n?.(l),setTimeout(()=>i(!1),1500))},[n]);return(0,g.jsxs)("span",{className:"relative group/copy",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[e,(0,g.jsx)("button",{onClick:l=>{l.stopPropagation(),a(t)},className:X("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,g.jsx)(Ji,{className:"h-3 w-3 text-green-500"}):(0,g.jsx)($i,{className:"h-3 w-3 text-muted-foreground/60 hover:text-muted-foreground"})})]})}function a0(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 y_({content:e,onCopy:t,collapseStringsAfterLength:n}){const r=(0,m.useMemo)(()=>{const i=hS(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(o0(`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,g.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=a0(e,h.start);s.push((0,g.jsx)(Tu,{value:v,onCopy:t,children:(0,g.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=a0(e,h.start);a=null,s.push((0,g.jsx)(Tu,{value:v,onCopy:t,children:(0,g.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",p=()=>{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=p();s.push((0,g.jsx)(dS,{value:v,displayValue:h.value,maxLength:n,onCopy:t,keyName:h.keyName,path:h.path},`token-${u}`))}else d?s.push((0,g.jsx)(Tu,{value:p(),onCopy:t,children:(0,g.jsx)("span",{className:f,children:h.value})},`token-${u}`)):s.push((0,g.jsx)("span",{className:f,children:h.value},`token-${u}`));o=h.end}return o<e.length&&s.push(o0("ws-end",e.slice(o))),s},[e,t,n]);return(0,g.jsx)(g.Fragment,{children:r})}var Qr=20,l0=30,c0=12,Gh=80,x_=2;function b_(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 w_(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 Gh;const i=Number.parseFloat(t.paddingLeft)||0,s=Number.parseFloat(t.paddingRight)||0,o=e.clientWidth-i-s;return o<=0?Gh:Math.max(1,Math.floor(o/r))}function S_(e,t){const n=e.replace(/\t/g," ".repeat(x_)).length;return n===0?1:Math.max(1,Math.ceil(n/t))}function k_(e,t,n){let r=0;return e.map((i,s)=>{const o=t?S_(i,n)*Qr:Qr,a=t?r:s*Qr;return r+=o,{top:a,height:o}})}function C_(e,t,n,r,i){return(0,m.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,T=i[C];!T||T.top+T.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 T=i[C];if(!T||T.top>=u)break;h=C}const f=Math.max(0,c-l0),d=Math.min(o-1,h+l0),p=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:fS(p),paddingTop:w,paddingBottom:S}},[e,t,n,r,i])}function pS({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:p=!1}){const v=(0,m.useRef)(null),y=(0,m.useRef)(null),x=(0,m.useRef)(null),b=(0,m.useRef)(null),w=(0,m.useRef)(null),[S,C]=(0,m.useState)(!1),[T,k]=(0,m.useState)(1),[A,E]=(0,m.useState)(0),[R,O]=(0,m.useState)(0),[M,j]=(0,m.useState)(400),N=(0,m.useRef)(null),P=(0,m.useRef)(null),L=(0,m.useRef)(0),[B,H]=(0,m.useState)(Gh),V=a?p:d,I=a&&c==="auto",ne=(0,m.useMemo)(()=>e.split(`
46
+ `),[e]),re=(0,m.useMemo)(()=>k_(ne,V,B),[B,V,ne]),_=ne.length,U=re[Math.min(Math.max(T-1,0),_-1)],K=U?.top??0,G=U?.height??Qr,$=!a,J=K-A+c0,ae=(0,m.useCallback)(()=>{const Y=a?b.current:v.current;if(!V||!Y)return;const ye=w_(Y);H(je=>je===ye?je:ye)},[V,a]),he=g_({count:_,getScrollElement:()=>a?x.current:y.current,estimateSize:Y=>re[Y]?.height??Qr,overscan:20}),{highlightedHtml:se,paddingTop:Ye}=C_(e,A,M,$,re),Le=(0,m.useMemo)(()=>a?"":$?se:fS(e),[e,a,$,se]),rt=$?Ye:0,qe=(0,m.useRef)(0);qe.current=rt;const gt=(0,m.useRef)(0);gt.current=K;const Me=(0,m.useCallback)(()=>{if(v.current){const Y=v.current.scrollTop,ye=v.current.scrollLeft;y.current&&(y.current.scrollTop=Y),N.current&&(N.current.style.transform=`translate(${-ye}px, ${qe.current-Y}px)`),P.current&&(P.current.style.transform=`translateY(${gt.current-Y+c0}px)`),cancelAnimationFrame(L.current),L.current=requestAnimationFrame(()=>{E(Y),O(ye)})}},[]),it=(0,m.useCallback)(()=>{if(v.current&&n){const Y=b_(v.current);n(Y),k(Y.line)}},[n]),Nr=(0,m.useCallback)(Y=>{const ye=Y.currentTarget,{selectionStart:je,selectionEnd:na,value:vt}=ye;if((Y.ctrlKey||Y.metaKey)&&Y.key==="z"&&!Y.shiftKey){Y.preventDefault(),r?.();return}if((Y.ctrlKey||Y.metaKey)&&Y.shiftKey&&Y.key==="z"||Y.ctrlKey&&Y.key==="y"){Y.preventDefault(),i?.();return}if(Y.key==="Escape"&&s){Y.preventDefault(),s();return}if(Y.key==="Tab"){Y.preventDefault();const D=" ";if(Y.shiftKey){const ee=vt.lastIndexOf(`
47
+ `,je-1)+1;if(vt.substring(ee,je).startsWith(D)){const ce=vt.substring(0,ee)+vt.substring(ee+2);t?.(ce),requestAnimationFrame(()=>{ye.selectionStart=ye.selectionEnd=je-2})}}else{const ee=vt.substring(0,je)+D+vt.substring(na);t?.(ee),requestAnimationFrame(()=>{ye.selectionStart=ye.selectionEnd=je+2})}return}if(Y.key==="Enter"){Y.preventDefault();const D=vt.lastIndexOf(`
48
+ `,je-1)+1,ee=vt.substring(D,je).match(/^(\s*)/)?.[1]||"",ce=vt[je-1],Ce=vt[je],ie=ce==="{"||ce==="[",kt=Ce==="}"||Ce==="]";let st=`
49
+ `+ee,ln=st.length;ie&&(st=`
50
+ `+ee+" ",ln=st.length,kt&&(st+=`
51
+ `+ee));const Ct=vt.substring(0,je)+st+vt.substring(na);t?.(Ct),requestAnimationFrame(()=>{ye.selectionStart=ye.selectionEnd=je+ln})}},[t,r,i,s]);(0,m.useEffect)(()=>{a||v.current?.focus()},[a]),(0,m.useEffect)(()=>{const Y=()=>{w.current&&j(w.current.clientHeight)};return Y(),window.addEventListener("resize",Y),()=>window.removeEventListener("resize",Y)},[]),(0,m.useEffect)(()=>()=>cancelAnimationFrame(L.current),[]),(0,m.useEffect)(()=>{T>_&&k(_)},[T,_]),(0,m.useEffect)(()=>{he.measure()},[re,he]),(0,m.useEffect)(()=>{if(!V)return;ae(),window.addEventListener("resize",ae);let Y;const ye=a?b.current:v.current;return window.ResizeObserver&&ye&&(Y=new ResizeObserver(()=>ae()),Y.observe(ye)),()=>{window.removeEventListener("resize",ae),Y?.disconnect()}},[V,a,ae]);const ws={height:c??"auto",maxHeight:u??"none"},me={fontFamily:"var(--font-code)"};return(0,g.jsxs)("div",{ref:w,className:X("group relative flex w-full overflow-hidden bg-muted/30",!o&&"border-destructive",l),style:ws,children:[h&&!a&&(0,g.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,g.jsx)("div",{className:"py-3 pr-2 text-xs text-muted-foreground leading-5 relative",style:{...me,height:`${he.getTotalSize()}px`},children:he.getVirtualItems().map(Y=>{const ye=Y.index+1,je=re[Y.index]?.height??Qr;return(0,g.jsx)("div",{className:X("leading-5 transition-colors duration-150 absolute left-0 right-0 pr-2",ye===T&&S&&"text-foreground font-medium"),style:{transform:`translateY(${Y.start}px)`,height:`${je}px`},children:ye},Y.index)})})}),(0,g.jsx)("div",{className:X("relative flex-1 min-w-0",I?"overflow-visible":"h-full overflow-hidden"),children:a?(0,g.jsxs)("div",{ref:x,className:X("relative z-10 flex min-w-0 items-start",I?"h-auto overflow-visible":"h-full min-h-0 overflow-auto overscroll-none"),children:[h&&(0,g.jsx)("div",{ref:y,className:X("flex-shrink-0 border-r border-border/50 bg-muted/50 text-right select-none self-stretch",!I&&"sticky left-0 z-20"),style:{width:"3rem"},children:(0,g.jsx)("div",{className:"py-3 pr-2 text-xs text-muted-foreground leading-5 relative",style:{...me,height:`${he.getTotalSize()}px`},children:he.getVirtualItems().map(Y=>{const ye=Y.index+1,je=re[Y.index]?.height??Qr;return(0,g.jsx)("div",{className:"leading-5 transition-colors duration-150 absolute left-0 right-0 pr-2",style:{transform:`translateY(${Y.start}px)`,height:`${je}px`},children:ye},Y.index)})})}),(0,g.jsx)("div",{className:X("relative self-start overflow-visible",V?"flex-1 min-w-0":"w-max min-w-full"),children:(0,g.jsx)("pre",{ref:b,className:X("p-3 text-xs leading-5 m-0 select-text cursor-text",V?"w-full whitespace-pre-wrap break-words":"w-max min-w-full whitespace-pre"),style:me,children:(0,g.jsx)(y_,{content:e,collapseStringsAfterLength:f})})})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("pre",{ref:b,className:X("absolute inset-0 p-3 text-xs leading-5 overflow-hidden",V?"whitespace-pre-wrap break-words":"whitespace-pre","pointer-events-none m-0","text-muted-foreground"),style:{...me,scrollbarGutter:"stable"},"aria-hidden":"true",children:(0,g.jsx)("div",{ref:N,style:{transform:`translate(${-R}px, ${rt-A}px)`,willChange:"transform"},children:(0,g.jsx)("div",{dangerouslySetInnerHTML:{__html:Le+`
52
+ `}})})}),S&&(0,g.jsx)("div",{ref:P,className:"absolute left-0 right-0 bg-foreground/[0.03] pointer-events-none",style:{height:`${G}px`,transform:`translateY(${J}px)`}}),(0,g.jsx)("textarea",{ref:v,value:e,wrap:V?"soft":"off",onChange:Y=>t?.(Y.target.value),onScroll:Me,onSelect:it,onClick:it,onKeyDown:Nr,onKeyUp:it,onFocus:()=>C(!0),onBlur:()=>C(!1),spellCheck:!1,className:X("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",V?"overflow-auto whitespace-pre-wrap break-words":"overflow-auto whitespace-pre"),style:{...me,tabSize:2,scrollbarGutter:"stable"}})]})})]})}var u0=100;function T_(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function mS(e,t){const n=Math.min(t,u0),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>=u0){s.depth>=n&&T_(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 A_(e){return mS(e,0)}function R_({value:e,defaultExpandDepth:t,initialCollapsedPaths:n,onCollapseChange:r}={}){const[i]=(0,m.useState)(()=>n!==void 0||t===void 0?null:new Set(mS(e,t))),[s,o]=(0,m.useState)(()=>i??n??new Set),a=(0,m.useCallback)(f=>s.has(f),[s]),l=(0,m.useCallback)(f=>{o(d=>{const p=new Set(d);return p.has(f)?p.delete(f):p.add(f),r?.(p),p})},[r]),c=(0,m.useCallback)(()=>{o(new Set),r?.(new Set)},[r]),u=(0,m.useCallback)(f=>{const d=A_(f),p=new Set(d);o(p),r?.(p)},[r]),h=(0,m.useRef)(!1);return(0,m.useEffect)(()=>{h.current||i===null||(h.current=!0,r?.(i))},[i,r]),(0,m.useEffect)(()=>{n!==void 0&&o(n)},[n]),(0,m.useMemo)(()=>({collapsedPaths:s,isCollapsed:a,toggleCollapse:l,expandAll:c,collapseAll:u}),[s,a,l,c,u])}var xa=50,M_=100,P_=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 gS(e,t){const[n,r]=(0,m.useState)(e.length<=xa?e.length:xa);return(0,m.useEffect)(()=>{if(!t){r(Math.min(e.length,xa));return}r(i=>i>e.length?Math.min(e.length,xa):i)},[e.length,t]),(0,m.useEffect)(()=>{if(!t||n>=e.length)return;const i=P_(()=>{r(s=>Math.min(s+M_,e.length))},{timeout:100});return()=>E_(i)},[e.length,n,t]),e.slice(0,n)}var Cn=(0,m.memo)(function({children:t,value:n,onCopy:r,alwaysVisible:i=!1}){const[s,o]=(0,m.useState)(!1),[a,l]=(0,m.useState)(!1),c=(0,m.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 vc(h)&&(o(!0),r?.(h),setTimeout(()=>o(!1),1500))},[n,r]);return(0,g.jsxs)("span",{className:"relative group/copy",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t,(0,g.jsx)("button",{onClick:c,className:X("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,g.jsx)(Ji,{className:"h-3 w-3 text-green-500"}):(0,g.jsx)($i,{className:"h-3 w-3 text-muted-foreground/60 hover:text-muted-foreground"})})]})});function O_({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=gS(e,!u),f=(0,m.useCallback)(()=>JSON.stringify(e,null,2),[e]),d=()=>n===void 0?null:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("span",{className:"json-key",children:['"',n,'"']}),(0,g.jsx)("span",{className:"json-punctuation",children:": "})]}),p=()=>r?null:(0,g.jsx)("span",{className:"json-punctuation",children:","});if(e.length===0)return(0,g.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[d(),(0,g.jsx)(Cn,{value:"[]",onCopy:l,alwaysVisible:!0,children:(0,g.jsx)("span",{className:"json-punctuation",children:"[]"})}),p()]});const v=y=>{y.stopPropagation(),o(t)};return u?(0,g.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,g.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,g.jsx)(Zi,{className:"h-3 w-3"})}),d(),(0,g.jsxs)(Cn,{value:f,onCopy:l,alwaysVisible:!0,children:[(0,g.jsx)("span",{className:"json-punctuation",children:"["}),(0,g.jsxs)("span",{className:"text-muted-foreground text-xs px-1",children:[e.length," ",e.length===1?"item":"items"]}),(0,g.jsx)("span",{className:"json-punctuation",children:"]"})]}),p()]}):(0,g.jsxs)(m.Fragment,{children:[(0,g.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,g.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,g.jsx)(Zi,{className:"h-3 w-3"})}),d(),(0,g.jsx)(Cn,{value:f,onCopy:l,alwaysVisible:!0,children:(0,g.jsx)("span",{className:"json-punctuation",children:"["})})]}),h.map((y,x)=>(0,g.jsx)(fp,{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,g.jsxs)("div",{className:"leading-5 text-muted-foreground text-xs",style:{paddingLeft:(i+1)*16},children:["Loading ",e.length-h.length," more items..."]}),(0,g.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,g.jsx)("span",{className:"json-punctuation",children:"]"}),p()]})]})}function I_({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=gS(h,!u),d=(0,m.useCallback)(()=>JSON.stringify(e,null,2),[e]),p=()=>n===void 0?null:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("span",{className:"json-key",children:['"',n,'"']}),(0,g.jsx)("span",{className:"json-punctuation",children:": "})]}),v=()=>r?null:(0,g.jsx)("span",{className:"json-punctuation",children:","});if(h.length===0)return(0,g.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[p(),(0,g.jsx)(Cn,{value:"{}",onCopy:l,alwaysVisible:!0,children:(0,g.jsx)("span",{className:"json-punctuation",children:"{}"})}),v()]});const y=x=>{x.stopPropagation(),o(t)};return u?(0,g.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,g.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,g.jsx)(Zi,{className:"h-3 w-3"})}),p(),(0,g.jsxs)(Cn,{value:d,onCopy:l,alwaysVisible:!0,children:[(0,g.jsx)("span",{className:"json-punctuation",children:"{"}),(0,g.jsxs)("span",{className:"text-muted-foreground text-xs px-1",children:[h.length," ",h.length===1?"key":"keys"]}),(0,g.jsx)("span",{className:"json-punctuation",children:"}"})]}),v()]}):(0,g.jsxs)(m.Fragment,{children:[(0,g.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,g.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,g.jsx)(Zi,{className:"h-3 w-3"})}),p(),(0,g.jsx)(Cn,{value:d,onCopy:l,alwaysVisible:!0,children:(0,g.jsx)("span",{className:"json-punctuation",children:"{"})})]}),f.map(([x,b],w)=>(0,g.jsx)(fp,{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,g.jsxs)("div",{className:"leading-5 text-muted-foreground text-xs",style:{paddingLeft:(i+1)*16},children:["Loading ",h.length-f.length," more keys..."]}),(0,g.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[(0,g.jsx)("span",{className:"json-punctuation",children:"}"}),v()]})]})}function D_({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,g.jsx)(Cn,{value:"null",onCopy:l,children:(0,g.jsx)("span",{className:"json-null",children:"null"})});if(typeof e=="boolean")return(0,g.jsx)(Cn,{value:String(e),onCopy:l,children:(0,g.jsx)("span",{className:e?"json-boolean":"json-boolean-false",children:String(e)})});if(typeof e=="number")return(0,g.jsx)(Cn,{value:String(e),onCopy:l,children:(0,g.jsx)("span",{className:"json-number",children:String(e)})});if(typeof e=="string"){const d=JSON.stringify(e);return a!==void 0?(0,g.jsx)(dS,{value:e,displayValue:d,maxLength:a,onCopy:l}):(0,g.jsx)(Cn,{value:e,onCopy:l,children:(0,g.jsx)("span",{className:"json-string",children:d})})}return null},h=()=>n===void 0?null:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("span",{className:"json-key",children:['"',n,'"']}),(0,g.jsx)("span",{className:"json-punctuation",children:": "})]}),f=()=>r?null:(0,g.jsx)("span",{className:"json-punctuation",children:","});return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"?(0,g.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[h(),u(),f()]}):Array.isArray(e)?(0,g.jsx)(O_,{value:e,path:t,keyName:n,isLast:r,depth:i,isCollapsed:s,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}):typeof e=="object"?(0,g.jsx)(I_,{value:e,path:t,keyName:n,isLast:r,depth:i,isCollapsed:s,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}):(0,g.jsxs)("div",{className:"leading-5",style:{paddingLeft:c},children:[h(),(0,g.jsx)("span",{className:"text-muted-foreground",children:"undefined"}),f()]})}function N_(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 fp=(0,m.memo)(D_,N_);function L_({value:e,className:t,height:n,maxHeight:r,defaultExpandDepth:i,collapsedPaths:s,onCollapseChange:o,collapseStringsAfterLength:a,onCopy:l}){const{isCollapsed:c,toggleCollapse:u}=R_({value:e,defaultExpandDepth:i,initialCollapsedPaths:s,onCollapseChange:o});return(0,g.jsx)("div",{className:X("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,g.jsx)(fp,{value:e,path:"root",isCollapsed:c,toggleCollapse:u,collapseStringsAfterLength:a,onCopy:l})})}function h0({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,m.useMemo)(()=>{if(e==null)return"null";try{return JSON.stringify(e,null,2)}catch{return String(e)}},[e]);return a?(0,g.jsx)(L_,{value:e,className:t,height:n??"100%",maxHeight:r,defaultExpandDepth:l,collapsedPaths:c,onCollapseChange:u,collapseStringsAfterLength:s}):(0,g.jsx)(pS,{content:h,readOnly:!0,className:t,height:n??"100%",maxHeight:r,showLineNumbers:i,collapseStringsAfterLength:s,wrapLongLinesInView:o})}var vS=1024,j_=0,Au=class{constructor(e,t){this.from=e,this.to=t}},fe=class{constructor(e={}){this.id=j_++,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=Ft.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};fe.closedBy=new fe({deserialize:e=>e.split(" ")});fe.openedBy=new fe({deserialize:e=>e.split(" ")});fe.group=new fe({deserialize:e=>e.split(" ")});fe.isolate=new fe({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});fe.contextHash=new fe({perNode:!0});fe.lookAhead=new fe({perNode:!0});fe.mounted=new fe({perNode:!0});var no=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[fe.mounted.id]}},__=Object.create(null),Ft=class yS{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):__,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new yS(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(fe.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(fe.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}};Ft.none=new Ft("",Object.create(null),0,8);var B_=class xS{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 Ft(r.name,i,r.id,r.flags):r)}return new xS(n)}},ba=new WeakMap,f0=new WeakMap,Ie;(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"})(Ie||(Ie={}));var Xe=class Qh{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=no.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 Jh(this.topNode,t)}cursorAt(t,n=0,r=0){let i=ba.get(this)||this.topNode,s=new Jh(i);return s.moveTo(t,n),ba.set(this,s._tree),s}get topNode(){return new Cr(this,0,0,null)}resolve(t,n=0){let r=So(ba.get(this)||this.topNode,t,n,!1);return ba.set(this,r),r}resolveInner(t,n=0){let r=So(f0.get(this)||this.topNode,t,n,!0);return f0.set(this,r),r}resolveStack(t,n=0){return $_(this,t,n)}iterate(t){let{enter:n,leave:r,from:i=0,to:s=this.length}=t,o=t.mode||0,a=(o&Ie.IncludeAnonymous)>0;for(let l=this.cursor(o|Ie.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:pp(Ft.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Qh(this.type,n,r,i,this.propValues),t.makeTree||((n,r,i)=>new Qh(Ft.none,n,r,i)))}static build(t){return H_(t)}};Xe.empty=new Xe(Ft.none,[],[],0);var V_=class bS{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 bS(this.buffer,this.index)}},rs=class wS{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return Ft.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&&!(SS(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 wS(s,o,this.set)}};function SS(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 So(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 Cr&&e.index<0?null:e.parent;if(!o)return e;e=o}let s=r?0:Ie.IgnoreOverlays;if(r)for(let o=e,a=o.parent;a;o=a,a=o.parent)o instanceof Cr&&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 kS=class{cursor(e=0){return new Jh(this,e)}getChild(e,t=null,n=null){let r=d0(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return d0(this,e,t,n)}resolve(e,t=0){return So(this,e,t,!1)}resolveInner(e,t=0){return So(this,e,t,!0)}matchContext(e){return Xh(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}},Cr=class Za extends kS{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&Ie.EnterBracketed&&u instanceof Xe&&(f=no.get(u))&&!f.overlay&&f.bracketed&&r>=h&&r<=h+u.length)&&!SS(i,r,h,h+u.length))){if(u instanceof rs){if(s&Ie.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,n,r-h,i);if(d>-1)return new Yh(new F_(o,u,t,h),null,d)}else if(s&Ie.IncludeAnonymous||!u.type.isAnonymous||dp(u)){let d;if(!(s&Ie.IgnoreMounts)&&(d=no.get(u))&&!d.overlay)return new Za(d.tree,h,t,o);let p=new Za(u,h,t,o);return s&Ie.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?u.children.length-1:0,n,r,i,s)}}}if(s&Ie.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&Ie.IgnoreOverlays)&&(i=no.get(this._tree))&&i.overlay){let s=t-this.from,o=r&Ie.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 Za(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 d0(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 Xh(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 F_=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},Yh=class Bs extends kS{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 Bs(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&Ie.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 Bs(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 Bs(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 Bs(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 Xe(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function CS(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 Cr&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new z_(i,n)}var z_=class{constructor(e,t){this.heads=e,this.node=t}get next(){return CS(this.heads)}};function $_(e,t,n){let r=e.resolveInner(t,n),i=null;for(let s=r instanceof Cr?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=no.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let a=new Cr(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(So(a,t,n,!1))}}return i?CS(i):r}var Jh=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&~Ie.EnterBracketed,e instanceof Cr)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 Cr?(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&Ie.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ie.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Ie.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&Ie.IncludeAnonymous||o instanceof rs||!o.type.isAnonymous||dp(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 Yh(this.buffer,t,this.stack[r]);return this.bufferNode=new Yh(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 Xh(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 Xh(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 dp(e){return e.children.some(t=>t instanceof rs||!t.type.isAnonymous||dp(t))}function H_(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=vS,reused:s=[],minRepeatType:o=r.types.length}=e,a=Array.isArray(n)?new V_(n,n.length):n,l=r.types,c=0,u=0;function h(C,T,k,A,E,R){let{id:O,start:M,end:j,size:N}=a,P=u,L=c;if(N<0)if(a.next(),N==-1){let ne=s[O];k.push(ne),A.push(M-C);return}else if(N==-3){c=O;return}else if(N==-4){u=O;return}else throw new RangeError(`Unrecognized record size: ${N}`);let B=l[O],H,V,I=M-C;if(j-M<=i&&(V=y(a.pos-T,E))){let ne=new Uint16Array(V.size-V.skip),re=a.pos-V.size,_=ne.length;for(;a.pos>re;)_=x(V.start,ne,_);H=new rs(ne,j-V.start,r),I=V.start-C}else{let ne=a.pos-N;a.next();let re=[],_=[],U=O>=o?O:-1,K=0,G=j;for(;a.pos>ne;)U>=0&&a.id==U&&a.size>=0?(a.end<=G-i&&(p(re,_,M,K,a.end,G,U,P,L),K=re.length,G=a.end),a.next()):R>2500?f(M,ne,re,_):h(M,ne,re,_,U,R+1);if(U>=0&&K>0&&K<re.length&&p(re,_,M,K,M,G,U,P,L),re.reverse(),_.reverse(),U>-1&&K>0){let $=d(B,L);H=pp(B,re,_,0,re.length,0,j-M,$,$)}else H=v(B,re,_,j-M,P-j,L)}k.push(H),A.push(I)}function f(C,T,k,A){let E=[],R=0,O=-1;for(;a.pos>T;){let{id:M,start:j,end:N,size:P}=a;if(P>4)a.next();else{if(O>-1&&j<O)break;O<0&&(O=N-i),E.push(M,j,N),R++,a.next()}}if(R){let M=new Uint16Array(R*4),j=E[E.length-2];for(let N=E.length-3,P=0;N>=0;N-=3)M[P++]=E[N],M[P++]=E[N+1]-j,M[P++]=E[N+2]-j,M[P++]=P;k.push(new rs(M,E[2]-j,r)),A.push(j-C)}}function d(C,T){return(k,A,E)=>{let R=0,O=k.length-1,M,j;if(O>=0&&(M=k[O])instanceof Xe){if(!O&&M.type==C&&M.length==E)return M;(j=M.prop(fe.lookAhead))&&(R=A[O]+M.length+j)}return v(C,k,A,E,R,T)}}function p(C,T,k,A,E,R,O,M,j){let N=[],P=[];for(;C.length>A;)N.push(C.pop()),P.push(T.pop()+k-E);C.push(v(r.types[O],N,P,R-E,M-R,j)),T.push(E-k)}function v(C,T,k,A,E,R,O){if(R){let M=[fe.contextHash,R];O=O?[M].concat(O):[M]}if(E>25){let M=[fe.lookAhead,E];O=O?[M].concat(O):[M]}return new Xe(C,T,k,A,O)}function y(C,T){let k=a.fork(),A=0,E=0,R=0,O=k.end-i,M={size:0,start:0,skip:0};e:for(let j=k.pos-C;k.pos>j;){let N=k.size;if(k.id==T&&N>=0){M.size=A,M.start=E,M.skip=R,R+=4,A+=4,k.next();continue}let P=k.pos-N;if(N<0||P<j||k.start<O)break;let L=k.id>=o?4:0,B=k.start;for(k.next();k.pos>P;){if(k.size<0)if(k.size==-3||k.size==-4)L+=4;else break e;else k.id>=o&&(L+=4);k.next()}E=B,A+=N,R+=L}return(T<0||A==C)&&(M.size=A,M.start=E,M.skip=R),M.size>4?M:void 0}function x(C,T,k){let{id:A,start:E,end:R,size:O}=a;if(a.next(),O>=0&&A<o){let M=k;if(O>4){let j=a.pos-(O-4);for(;a.pos>j;)k=x(C,T,k)}T[--k]=M,T[--k]=R-C,T[--k]=E-C,T[--k]=A}else O==-3?c=A:O==-4&&(u=A);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 Xe(l[e.topID],b.reverse(),w.reverse(),S)}var p0=new WeakMap;function el(e,t){if(!e.isAnonymous||t instanceof rs||t.type!=e)return 1;let n=p0.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof Xe)){n=1;break}n+=el(e,r)}p0.set(t,n)}return n}function pp(e,t,n,r,i,s,o,a,l){let c=0;for(let p=r;p<i;p++)c+=el(e,t[p]);let u=Math.ceil(c*1.5/8),h=[],f=[];function d(p,v,y,x,b){for(let w=y;w<x;){let S=w,C=v[w],T=el(e,p[w]);for(w++;w<x;w++){let k=el(e,p[w]);if(T+k>=u)break;T+=k}if(w==S+1){if(T>u){let k=p[S];d(k.children,k.positions,0,k.children.length,v[S]+b);continue}h.push(p[S])}else{let k=v[w-1]+p[w-1].length-C;h.push(pp(e,p,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 tl=class Zh{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 Zh(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,p=Math.min(f.to,h)-c;f=d>=p?null:new Zh(d,p,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}},TS=class{startParse(e,t,n){return typeof e=="string"&&(e=new W_(e)),n=n?n.length?n.map(r=>new Au(r.from,r.to)):[new Au(0,0)]:[new Au(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}}},W_=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)}},dW=new fe({perNode:!0}),q_=class ef{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 ef(t,[],n,r,r,0,[],0,i?new m0(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 ef(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 U_(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 m0(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()}},m0=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},U_=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}},K_=class tf{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 tf(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 tf(this.stack,this.pos,this.index)}};function Vs(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 nl=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},g0=new nl,G_=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=g0,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=g0,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}},Wi=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;AS(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};Wi.prototype.contextual=Wi.prototype.fallback=Wi.prototype.extend=!1;var Q_=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?Vs(e):e}token(e,t){let n=e.pos,r=0;for(;;){let i=e.next<0,s=e.resolveOffset(1,1);if(AS(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))}};Q_.prototype.contextual=Wi.prototype.fallback=Wi.prototype.extend=!1;function AS(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 p=e[d];if(l.allows(p)&&(t.token.value==-1||t.token.value==p||X_(p,t.token.value,i,s))){t.acceptToken(p);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,p=c+d+(d<<1),v=e[p],y=e[p+1]||65536;if(u<v)f=d;else if(u>=y)h=d+1;else{o=e[p+2],t.advance();continue e}}break}}function v0(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function X_(e,t,n,r){let i=v0(n,r,t);return i<0||v0(n,r,e)<i}var Mt=typeof process<"u"&&/\bparse\b/.test({}.LOG),Ru=null;function y0(e,t,n){let r=e.cursor(Ie.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 Y_=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?y0(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?y0(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 Xe){if(s==e){if(s<this.safeFrom)return null;let o=s+i.length;if(o<=this.safeTo){let a=i.prop(fe.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}}},J_=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new nl)}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 nl,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 nl,{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=zn(o,l+2);else{r==0&&o[l+1]==2&&(r=this.putAction(zn(o,l+2),t,n,r));break}o[l]==t&&(r=this.putAction(zn(o,l+1),t,n,r))}return r}},Z_=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 G_(t,r),this.tokens=new J_(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[q_.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new Y_(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&&nB(r);if(s)return Mt&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw Mt&&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 Mt&&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=Mt?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(fe.contextHash)||0)==c))return e.useNode(u,h),Mt&&console.log(s+this.stackID(e)+` (via reuse of ${i.getName(u.type.id)})`),!0;if(!(u instanceof Xe)||u.children.length==0||u.positions[0]>0)break;let f=u.children[0];if(f instanceof Xe&&u.positions[0]==0)u=f;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),Mt&&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(),p=this.tokens.mainToken;if(d.apply(c,u,p?p.start:d.pos,h),Mt&&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 x0(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=Mt?this.stackID(o)+" -> ":"";if(o.deadEnd&&(i||(i=!0,o.restart(),Mt&&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()&&(Mt&&console.log(h+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,n));f++)Mt&&(h=this.stackID(u)+" -> ");for(let f of o.recoverByInsert(a))Mt&&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),Mt&&console.log(c+this.stackID(o)+` (via recover-delete ${this.parser.getName(a)})`),x0(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),Xe.build({buffer:K_.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=(Ru||(Ru=new WeakMap)).get(e);return t||Ru.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function x0(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 eB=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},tB=class nf extends TS{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=fe[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 B_(n.map((a,l)=>Ft.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=vS;let o=Vs(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(b0),this.states=Vs(t.states,Uint32Array),this.data=Vs(t.stateData),this.goto=Vs(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(a=>typeof a=="number"?new Wi(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 Z_(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=zn(r,s+2)];else{if(r[s+1]==2)return zn(r,s+2);break}if(o==n||o==0)return zn(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=zn(this.data,s+2);else break;i=n(zn(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=zn(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(nf.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]=b0(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 eB(t,r,i)}static deserialize(t){return new nf(t)}};function zn(e,t){return e[t]|e[t+1]<<16}function nB(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 b0(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}var rB=0,$n=class rf{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=rB++}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 rf&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new rf(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 w0(t);return r=>r.modified.indexOf(n)>-1?r:w0.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}},iB=0,w0=class RS{constructor(t){this.name=t,this.instances=[],this.id=iB++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(a=>a.base==t&&sB(n,a.modified));if(r)return r;let i=[],s=new $n(t.name,i,t,n);for(let a of n)a.instances.push(s);let o=oB(n);for(let a of t.set)if(!a.modified.length)for(let l of o)i.push(RS.get(a,l));return s}};function sB(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function oB(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 MS(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 ko(r,o,l>0?s.slice(0,l):null).sort(t[c])}}return PS.add(t)}var PS=new fe({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 ko(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}}),ko=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}};ko.empty=new ko([],2,null);function ES(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 aB(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function lB(e,t,n,r=0,i=e.length){let s=new cB(r,Array.isArray(t)?t:[t],n);s.highlightRange(e.cursor(),r,i,"",s.highlighters),s.flush(i)}var cB=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=uB(e)||ko.empty,u=aB(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(fe.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)),p=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&&p)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))}p&&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 uB(e){let t=e.type.prop(PS);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var W=$n.define,wa=W(),hr=W(),S0=W(hr),k0=W(hr),fr=W(),Sa=W(fr),Mu=W(fr),pn=W(),_r=W(pn),hn=W(),fn=W(),sf=W(),Ms=W(sf),ka=W(),F={comment:wa,lineComment:W(wa),blockComment:W(wa),docComment:W(wa),name:hr,variableName:W(hr),typeName:S0,tagName:W(S0),propertyName:k0,attributeName:W(k0),className:W(hr),labelName:W(hr),namespace:W(hr),macroName:W(hr),literal:fr,string:Sa,docString:W(Sa),character:W(Sa),attributeValue:W(Sa),number:Mu,integer:W(Mu),float:W(Mu),bool:W(fr),regexp:W(fr),escape:W(fr),color:W(fr),url:W(fr),keyword:hn,self:W(hn),null:W(hn),atom:W(hn),unit:W(hn),modifier:W(hn),operatorKeyword:W(hn),controlKeyword:W(hn),definitionKeyword:W(hn),moduleKeyword:W(hn),operator:fn,derefOperator:W(fn),arithmeticOperator:W(fn),logicOperator:W(fn),bitwiseOperator:W(fn),compareOperator:W(fn),updateOperator:W(fn),definitionOperator:W(fn),typeOperator:W(fn),controlOperator:W(fn),punctuation:sf,separator:W(sf),bracket:Ms,angleBracket:W(Ms),squareBracket:W(Ms),paren:W(Ms),brace:W(Ms),content:pn,heading:_r,heading1:W(_r),heading2:W(_r),heading3:W(_r),heading4:W(_r),heading5:W(_r),heading6:W(_r),contentSeparator:W(pn),list:W(pn),quote:W(pn),emphasis:W(pn),strong:W(pn),link:W(pn),monospace:W(pn),strikethrough:W(pn),inserted:W(),deleted:W(),changed:W(),invalid:W(),meta:ka,documentMeta:W(ka),annotation:W(ka),processingInstruction:W(ka),definition:$n.defineModifier("definition"),constant:$n.defineModifier("constant"),function:$n.defineModifier("function"),standard:$n.defineModifier("standard"),local:$n.defineModifier("local"),special:$n.defineModifier("special")};for(let e in F){let t=F[e];t instanceof $n&&(t.name=e)}var pW=ES([{tag:F.link,class:"tok-link"},{tag:F.heading,class:"tok-heading"},{tag:F.emphasis,class:"tok-emphasis"},{tag:F.strong,class:"tok-strong"},{tag:F.keyword,class:"tok-keyword"},{tag:F.atom,class:"tok-atom"},{tag:F.bool,class:"tok-bool"},{tag:F.url,class:"tok-url"},{tag:F.labelName,class:"tok-labelName"},{tag:F.inserted,class:"tok-inserted"},{tag:F.deleted,class:"tok-deleted"},{tag:F.literal,class:"tok-literal"},{tag:F.string,class:"tok-string"},{tag:F.number,class:"tok-number"},{tag:[F.regexp,F.escape,F.special(F.string)],class:"tok-string2"},{tag:F.variableName,class:"tok-variableName"},{tag:F.local(F.variableName),class:"tok-variableName tok-local"},{tag:F.definition(F.variableName),class:"tok-variableName tok-definition"},{tag:F.special(F.variableName),class:"tok-variableName2"},{tag:F.definition(F.propertyName),class:"tok-propertyName tok-definition"},{tag:F.typeName,class:"tok-typeName"},{tag:F.namespace,class:"tok-namespace"},{tag:F.className,class:"tok-className"},{tag:F.macroName,class:"tok-macroName"},{tag:F.propertyName,class:"tok-propertyName"},{tag:F.operator,class:"tok-operator"},{tag:F.comment,class:"tok-comment"},{tag:F.meta,class:"tok-meta"},{tag:F.invalid,class:"tok-invalid"},{tag:F.punctuation,class:"tok-punctuation"}]),hB=MS({String:F.string,Number:F.number,"True False":F.bool,PropertyName:F.propertyName,Null:F.null,", :":F.separator,"[ ]":F.squareBracket,"{ }":F.brace}),fB=tB.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:[hB],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}),of=[],OS=[];(()=>{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?OS:of).push(n=n+e[t])})();function dB(e){if(e<768)return!1;for(let t=0,n=of.length;;){let r=t+n>>1;if(e<of[r])n=r;else if(e>=OS[r])t=r+1;else return!0;if(t==n)return!1}}function C0(e){return e>=127462&&e<=127487}var T0=8205;function pB(e,t,n=!0,r=!0){return(n?IS:mB)(e,t,r)}function IS(e,t,n){if(t==e.length)return t;t&&DS(e.charCodeAt(t))&&NS(e.charCodeAt(t-1))&&t--;let r=Pu(e,t);for(t+=A0(r);t<e.length;){let i=Pu(e,t);if(r==T0||i==T0||n&&dB(i))t+=A0(i),r=i;else if(C0(i)){let s=0,o=t-2;for(;o>=0&&C0(Pu(e,o));)s++,o-=2;if(s%2==0)break;t+=2}else break}return t}function mB(e,t,n){for(;t>0;){let r=IS(e,t-2,n);if(r<t)return r;t--}return 0}function Pu(e,t){let n=e.charCodeAt(t);if(!NS(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return DS(r)?(n-55296<<10)+(r-56320)+65536:n}function DS(e){return e>=56320&&e<57344}function NS(e){return e>=55296&&e<56320}function A0(e){return e<65536?1:2}var ge=class LS{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]=is(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),rl.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]=is(this,t,n);let r=[];return this.decompose(t,n,r,0),rl.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 ro(this),s=new ro(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 ro(this,t)}iterRange(t,n=this.length){return new jS(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 _S(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]?LS.empty:t.length<=32?new Qt(t):rl.from(Qt.split(t,[]))}},Qt=class mn extends ge{constructor(t,n=gB(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 vB(i,a,r,o);i=a+1,r++}}decompose(t,n,r,i){let s=t<=0&&n>=this.length?this:new mn(R0(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let o=r.pop(),a=il(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new mn(a,o.length+s.length));else{let l=a.length>>1;r.push(new mn(a.slice(0,l)),new mn(a.slice(l)))}}else r.push(s)}replace(t,n,r){if(!(r instanceof mn))return super.replace(t,n,r);[t,n]=is(this,t,n);let i=il(this.text,il(r.text,R0(this.text,0,t)),n),s=this.length+r.length-(n-t);return i.length<=32?new mn(i,s):rl.from(mn.split(i,[]),s)}sliceString(t,n=this.length,r=`
53
+ `){[t,n]=is(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 mn(r,i)),r=[],i=-1);return i>-1&&n.push(new mn(r,i)),n}},rl=class Pi extends ge{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]=is(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 Pi(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]=is(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 Pi))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 p of t)p.flatten(d);return new Qt(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 p;if(d.lines>s&&d instanceof Pi)for(let v of d.children)h(v);else d.lines>o&&(l>o||!l)?(f(),a.push(d)):d instanceof Qt&&l&&(p=u[u.length-1])instanceof Qt&&d.lines+p.lines<=32?(l+=d.lines,c+=d.length+1,u[u.length-1]=new Qt(p.text.concat(d.text),p.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]:Pi.from(u,c)),c=-1,l=u.length=0)}for(let d of t)h(d);return f(),a.length==1?a[0]:new Pi(a,n)}};ge.empty=new Qt([""],0);function gB(e){let t=-1;for(let n of e)t+=n.length+1;return t}function il(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 R0(e,t,n){return il(e,[""],t,n)}var ro=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 Qt?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 Qt?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 Qt){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 Qt?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)}},jS=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new ro(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!=""}},_S=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"&&(ge.prototype[Symbol.iterator]=function(){return this.iter()},ro.prototype[Symbol.iterator]=jS.prototype[Symbol.iterator]=_S.prototype[Symbol.iterator]=function(){return this});var vB=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 is(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function at(e,t,n=!0,r=!0){return pB(e,t,n,r)}function yB(e){return e>=56320&&e<57344}function xB(e){return e>=55296&&e<56320}function bB(e,t){let n=e.charCodeAt(t);if(!xB(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return yB(r)?(n-55296<<10)+(r-56320)+65536:n}function wB(e){return e<65536?1:2}var af=/\r\n?|\n/,It=(function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e})(It||(It={})),qi=class sl{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){lf(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 sl(t)}composeDesc(t){return this.empty?t:t.empty?this:BS(this,t)}mapDesc(t,n=!1){return t.empty?this:cf(this,t,n)}mapPos(t,n=-1,r=It.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!=It.Simple&&c>=t&&(r==It.TrackDel&&i<t&&c>t||r==It.TrackBefore&&i<t||r==It.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 sl(t)}static create(t){return new sl(t)}},rn=class ur extends qi{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 lf(this,(n,r,i,s,o)=>t=t.replace(i,i+(r-n),o),!1),t}mapDesc(t,n=!1){return cf(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(ge.empty);r.push(o?t.slice(s,s+o):ge.empty)}s+=o}return new ur(n,r)}compose(t){return this.empty?t:t.empty?this:BS(this,t,!0)}map(t,n=!1){return t.empty?this:cf(this,t,n,!0)}iterChanges(t,n=!1){lf(this,t,n)}get desc(){return qi.create(this.sections)}filter(t){let n=[],r=[],i=[],s=new Co(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);ot(i,u,-1);let h=s.ins==-1?-1:s.off==0?s.ins:0;ot(n,u,h),h>0&&vr(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);ot(n,u,-1),ot(i,u,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(u),a+=u}}return{changes:new ur(n,r),filtered:qi.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&&ot(i,n-o,-1);let h=new ur(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 ur){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 p=d?typeof d=="string"?ge.of(d.split(r||af)):d:ge.empty,v=p.length;if(h==f&&v==0)return;h<o&&l(),h>o&&ot(i,h-o,-1),ot(i,f-h,v),vr(s,i,p),o=f}}return c(t),l(!a),a}static empty(t){return new ur(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(ge.empty);r[i]=ge.of(s.slice(1)),n.push(s[0],r[i].length)}}}return new ur(n,r)}static createSet(t,n){return new ur(t,n)}};function ot(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 vr(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(ge.empty);e.push(n)}}function lf(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=ge.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 cf(e,t,n,r=!1){let i=[],s=r?[]:null,o=new Co(e),a=new Co(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);ot(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(ot(i,a.ins,-1);c;){let u=Math.min(o.len,c);o.ins>=0&&l<o.i&&o.len<=u&&(ot(i,0,o.ins),s&&vr(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;ot(i,c,l<o.i?o.ins:0),s&&l<o.i&&vr(s,i,o.text),l=o.i,o.forward(o.len-u)}else{if(o.done&&a.done)return s?rn.createSet(i,s):qi.create(i);throw new Error("Mismatched change set lengths")}}}function BS(e,t,n=!1){let r=[],i=n?[]:null,s=new Co(e),o=new Co(t);for(let a=!1;;){if(s.done&&o.done)return i?rn.createSet(r,i):qi.create(r);if(s.ins==0)ot(r,s.len,0,a),s.next();else if(o.len==0&&!o.done)ot(r,0,o.ins,a),i&&vr(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;ot(r,l,u,a),i&&u&&vr(i,r,o.text)}else o.ins==-1?(ot(r,s.off?0:s.len,l,a),i&&vr(i,r,s.textBit(l))):(ot(r,s.off?0:s.len,o.off?0:o.ins,a),i&&!o.off&&vr(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 Co=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?ge.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?ge.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)}},Ps=class uf{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 uf(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 uf(t,n,r,i)}},z=class Pt{constructor(t,n){this.ranges=t,this.mainIndex=n}map(t,n=-1){return t.empty?this:Pt.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 Pt([this.main],0)}addRange(t,n=!0){return Pt.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,Pt.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 Pt(t.ranges.map(n=>Ps.fromJSON(n)),t.main)}static single(t,n=t){return new Pt([Pt.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 Pt.normalized(t.slice(),n);r=s.to}return new Pt(t,n)}static cursor(t,n=0,r,i){return Ps.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?Ps.create(n,t,o|32,r):Ps.create(t,n,o,r)}static undirectionalRange(t,n){return Ps.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?Pt.range(l,a):Pt.range(a,l))}}return new Pt(t,n)}};function VS(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}var mp=0,Z=class FS{constructor(t,n,r,i,s){this.combine=t,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=mp++,this.default=t([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(t={}){return new FS(t.combine||(n=>n),t.compareInput||((n,r)=>n===r),t.compare||(t.combine?(n,r)=>n===r:gp),!!t.static,t.enables)}of(t){return new ol([],this,0,t)}compute(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new ol(t,this,1,n)}computeN(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new ol(t,this,2,n)}from(t,n){return n||(n=r=>r),this.compute([t],r=>n(r.field(t)))}};function gp(e,t){return e==t||e.length==t.length&&e.every((n,r)=>n===t[r])}var ol=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=mp++}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)||hf(u,c)){let f=n(u);if(o?!M0(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 p=jl(h,d);if(this.dependencies.every(v=>v instanceof Z?h.facet(v)===u.facet(v):v instanceof Qo?h.field(v,!1)==u.field(v,!1):!0)||(o?M0(f=n(u),p,r):r(f=n(u),p)))return u.values[s]=p,0}else f=n(u);return u.values[s]=f,1}}}get extension(){return this}};function M0(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 hf(e,t){let n=!1;for(let r of t)io(e,r)&1&&(n=!0);return n}function SB(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=jl(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)io(l,c);return l.values[o]=a(l),1},update(l,c){if(!hf(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=hf(l,r),h=c.config.facets[t.id],f=c.facet(t);if(h&&!u&&gp(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 Ca=Z.define({static:!0}),Qo=class zS{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 zS(mp++,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(Ca).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(Ca),o=i.facet(Ca),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,Ca.of({field:this,create:t})]}get extension(){return this}},qr={lowest:4,low:3,default:2,high:1,highest:0};function Es(e){return t=>new $S(t,e)}var kc={highest:Es(qr.highest),high:Es(qr.high),default:Es(qr.default),low:Es(qr.low),lowest:Es(qr.lowest)},$S=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},HS=class WS{of(t){return new ff(this,t)}reconfigure(t){return WS.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}},ff=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},P0=class qS{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 kB(t,n,o))f instanceof Qo?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],p=d[0].facet,v=u&&u[f]||[];if(d.every(y=>y.type==0))if(a[p.id]=l.length<<1|1,gp(v,d))l.push(r.facet(p));else{let y=p.combine(d.map(x=>x.value));l.push(r&&p.compare(y,r.facet(p))?r.facet(p):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[p.id]=c.length<<1,c.push(y=>SB(y,p,d))}}let h=c.map(f=>f(a));return new qS(t,o,h,a,l,s)}};function kB(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 ff&&n.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let c of o)s(c,a);else if(o instanceof ff){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 $S)s(o.inner,o.prec);else if(o instanceof Qo)r[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof ol)r[a].push(o),o.facet.extensions&&s(o.facet.extensions,qr.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,qr.default),r.reduce((o,a)=>o.concat(a))}function io(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 jl(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var US=Z.define(),df=Z.define({combine:e=>e.some(t=>t),static:!0}),KS=Z.define({combine:e=>e.length?e[0]:void 0,static:!0}),GS=Z.define(),QS=Z.define(),XS=Z.define(),YS=Z.define({combine:e=>e.length?e[0]:!1}),di=class{constructor(e,t){this.type=e,this.value=t}static define(){return new CB}},CB=class{of(e){return new di(this,e)}},TB=class{constructor(e){this.map=e}of(e){return new We(this,e)}},We=class JS{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 JS(this.type,n)}is(t){return this.type==t}static define(t={}){return new TB(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}};We.reconfigure=We.define();We.appendConfig=We.define();var en=class Fs{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&&VS(r,n.newLength),s.some(a=>a.type==Fs.time)||(this.annotations=s.concat(Fs.time.of(Date.now())))}static create(t,n,r,i,s,o){return new Fs(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(Fs.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]=="."))}};en.time=di.define();en.userEvent=di.define();en.addToHistory=di.define();en.remote=di.define();function AB(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 ZS(e,t,n){var r;let i,s,o;return n?(i=t.changes,s=rn.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:We.mapEffects(e.effects,i).concat(We.mapEffects(t.effects,s)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function pf(e,t,n){let r=t.selection,i=Ui(t.annotations);return t.userEvent&&(i=i.concat(en.userEvent.of(t.userEvent))),{changes:t.changes instanceof rn?t.changes:rn.of(t.changes||[],n,e.facet(KS)),selection:r&&(r instanceof z?r:z.single(r.anchor,r.head)),effects:Ui(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function ek(e,t,n){let r=pf(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=ZS(r,pf(e,t[s],o?r.changes.newLength:e.doc.length),o)}let i=en.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return MB(n?RB(i):i)}function RB(e){let t=e.startState,n=!0;for(let i of t.facet(GS)){let s=i(e);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:AB(n,s))}if(n!==!0){let i,s;if(n===!1)s=e.changes.invertedDesc,i=rn.empty(t.doc.length);else{let o=e.changes.filter(n);i=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}e=en.create(t,i,e.selection&&e.selection.map(s),We.mapEffects(e.effects,s),e.annotations,e.scrollIntoView)}let r=t.facet(QS);for(let i=r.length-1;i>=0;i--){let s=r[i](e);s instanceof en?e=s:Array.isArray(s)&&s.length==1&&s[0]instanceof en?e=s[0]:e=ek(t,Ui(s),!1)}return e}function MB(e){let t=e.startState,n=t.facet(XS),r=e;for(let i=n.length-1;i>=0;i--){let s=n[i](e);s&&Object.keys(s).length&&(r=ZS(r,pf(t,s,e.changes.newLength),!0))}return r==e?e:en.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var PB=[];function Ui(e){return e==null?PB:Array.isArray(e)?e:[e]}var Gn=(function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e})(Gn||(Gn={})),EB=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,mf;try{mf=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function OB(e){if(mf)return mf.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||EB.test(n)))return!0}return!1}function IB(e){return t=>{if(!/\S/.test(t))return Gn.Space;if(OB(t))return Gn.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return Gn.Word;return Gn.Other}}var ze=class Wt{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++)io(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 io(this,r),jl(this,r)}update(...t){return ek(this,t,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let a of t.effects)a.is(HS.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(We.reconfigure)?(n=null,r=a.value):a.is(We.appendConfig)&&(n=null,r=Ui(r).concat(a.value));let s;n?s=t.startState.values.slice():(n=P0.resolve(r,i,this),s=new Wt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,l)=>l.reconfigure(a,this),null).values);let o=t.startState.facet(df)?t.newSelection:t.newSelection.asSingle();new Wt(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=Ui(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=We.mapEffects(o,u).concat(We.mapEffects(Ui(l.effects),h))}return{changes:i,selection:z.create(s,n.mainIndex),effects:o}}changes(t=[]){return t instanceof rn?t:rn.of(t,this.doc.length,this.facet(Wt.lineSeparator))}toText(t){return ge.of(t.split(this.facet(Wt.lineSeparator)||af))}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:(io(this,n),jl(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 Qo&&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 Wt.create({doc:t.doc,selection:z.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=P0.resolve(t.extensions||[],new Map),r=t.doc instanceof ge?t.doc:ge.of((t.doc||"").split(n.staticFacet(Wt.lineSeparator)||af)),i=t.selection?t.selection instanceof z?t.selection:z.single(t.selection.anchor,t.selection.head):z.single(0);return VS(i,r.length),n.staticFacet(df)||(i=i.asSingle()),new Wt(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Wt.tabSize)}get lineBreak(){return this.facet(Wt.lineSeparator)||`
56
+ `}get readOnly(){return this.facet(YS)}phrase(t,...n){for(let r of this.facet(Wt.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(US))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 IB(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=at(n,o,!1);if(s(n.slice(l,o))!=Gn.Word)break;o=l}for(;a<i;){let l=at(n,a);if(s(n.slice(a,l))!=Gn.Word)break;a=l}return o==a?null:z.range(o+r,a+r)}};ze.allowMultipleSelections=df;ze.tabSize=Z.define({combine:e=>e.length?e[0]:4});ze.lineSeparator=KS;ze.readOnly=YS;ze.phrases=Z.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])}});ze.languageData=US;ze.changeFilter=GS;ze.transactionFilter=QS;ze.transactionExtender=XS;HS.reconfigure=We.define();function vp(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 ai=class{eq(e){return this==e}range(e,t=e){return gf.create(e,t,this)}};ai.prototype.startSide=ai.prototype.endSide=0;ai.prototype.point=!1;ai.prototype.mapMode=It.TrackDel;function yp(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var gf=class tk{constructor(t,n,r){this.from=t,this.to=n,this.value=r}static create(t,n,r){return new tk(t,n,r)}};function vf(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var DB=class nk{constructor(t,n,r,i){this.from=t,this.to=n,this.value=r,this.maxPoint=i}get length(){return Ei(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,p=this.to[h]+t,v,y;if(d==p){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(p,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 nk(a,l,o,u):null,pos:c}}},Re=class Bn{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 Bn(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(vf)),this.isEmpty)return n.length?Bn.of(n):this;let a=new ik(this,null,-1).goto(0),l=0,c=[],u=new al;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(gf.create(a.from,a.to,a.value))),a.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?Bn.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 al),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?[Ei(r)+Ei(n).length,Ei(Ei(n).value).endSide]:[-1,-1],{mapped:p,pos:v}=u.map(c,t,f,d,o);p&&(i=Math.max(i,p.maxPoint),n.push(p),r.push(v))}}let a=this.nextLayer.map(t);return s&&(a=s.finishInner(a)),n.length==0?a:new Bn(r,n,a||Bn.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 yf.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,n=0){return yf.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=E0(o,a,r),c=new Os(o,l,s),u=new Os(a,l,s);r.iterGaps((h,f,d)=>O0(c,h,u,f,d,i)),r.empty&&r.length==0&&O0(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=E0(s,o),l=new Os(s,a,0).goto(r),c=new Os(o,a,0).goto(r);for(;;){if(l.to!=c.to||!xf(l.active,c.active)||l.point&&(!c.point||!yp(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 Os(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 al;for(let i of t instanceof gf?[t]:n?NB(t):t)r.add(i.from,i.to,i.value);return r.finish()}static join(t){if(!t.length)return Bn.empty;let n=Ei(t);for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=Bn.empty;i=i.nextLayer)n=new Bn(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};Re.empty=new Re([],[],null,-1);function Ei(e){return e[e.length-1]}function NB(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(vf(t,r)>0)return e.slice().sort(vf);t=r}return e}Re.empty.nextLayer=Re.empty;var al=class rk{finishChunk(t){this.chunks.push(new DB(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 rk)).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(Re.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let n=Re.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,n}};function E0(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 ik=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}},yf=class sk{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 ik(o,n,r,s));return i.length==1?i[0]:new sk(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--)Eu(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--)Eu(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(),Eu(this.heap,0)}}};function Eu(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 Os=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=yf.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){Ta(this.active,e),Ta(this.activeTo,e),Ta(this.activeRank,e),this.minActive=I0(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++;Aa(this.active,t,n),Aa(this.activeTo,t,r),Aa(this.activeRank,t,i),e&&Aa(e,t,this.cursor.from),this.minActive=I0(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&&Ta(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 O0(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,p=Math.min(d,o);if(e.point||n.point?(e.point&&n.point&&yp(e.point,n.point)&&xf(e.activeForPoint(e.to),n.activeForPoint(n.to))||s.comparePoint(a,p,e.point,n.point),u=!1):(u&&(s.boundChange(a),u=!1),p>a&&!xf(e.active,n.active)&&s.compareRange(a,p,e.active,n.active),c&&p<o&&(h||e.openEnd(d)!=n.openEnd(d))&&(u=!0)),d>o)break;a=d,f<=0&&e.next(),f>=0&&n.next()}}function xf(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!yp(e[n],t[n]))return!1;return!0}function Ta(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function Aa(e,t,n){for(let r=e.length-1;r>=t;r--)e[r+1]=e[r];e[t]=n}function I0(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 Cc(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=at(e,i));return r}function LB(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=at(e,i)}return r===!0?-1:e.length}var ok="ͼ",D0=typeof Symbol>"u"?"__ͼ":Symbol.for(ok),bf=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),N0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Tr=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(p=>s.map(v=>p.replace(/&/,v))).reduce((p,v)=>p.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,p=>"-"+p.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=N0[D0]||1;return N0[D0]=e+1,ok+e.toString(36)}static mount(e,t,n){let r=e[bf],i=n&&n.nonce;r?i&&r.setNonce(i):r=new jB(e,i),r.mount(Array.isArray(t)?t:[t],e)}},L0=new Map,jB=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let i=L0.get(n);if(i)return e[bf]=i;this.sheet=new r.CSSStyleSheet,L0.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[bf]=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)}},Ar={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:"'"},To={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},_B=typeof navigator<"u"&&/Mac/.test(navigator.platform),BB=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ze=0;Ze<10;Ze++)Ar[48+Ze]=Ar[96+Ze]=String(Ze);for(var Ze=1;Ze<=24;Ze++)Ar[Ze+111]="F"+Ze;for(var Ze=65;Ze<=90;Ze++)Ar[Ze]=String.fromCharCode(Ze+32),To[Ze]=String.fromCharCode(Ze);for(var Ou in Ar)To.hasOwnProperty(Ou)||(To[Ou]=Ar[Ou]);function VB(e){var t=!(_B&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||BB&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified")&&e.key||(e.shiftKey?To:Ar)[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 ut=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},wf=typeof document<"u"?document:{documentElement:{style:{}}},Sf=/Edge\/(\d+)/.exec(ut.userAgent),ak=/MSIE \d/.test(ut.userAgent),kf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ut.userAgent),Tc=!!(ak||kf||Sf),j0=!Tc&&/gecko\/(\d+)/i.test(ut.userAgent),Iu=!Tc&&/Chrome\/(\d+)/.exec(ut.userAgent),_0="webkitFontSmoothing"in wf.documentElement.style,Cf=!Tc&&/Apple Computer/.test(ut.vendor),B0=Cf&&(/Mobile\/\w+/.test(ut.userAgent)||ut.maxTouchPoints>2),q={mac:B0||/Mac/.test(ut.platform),windows:/Win/.test(ut.platform),linux:/Linux|X11/.test(ut.platform),ie:Tc,ie_version:ak?wf.documentMode||6:kf?+kf[1]:Sf?+Sf[1]:0,gecko:j0,gecko_version:j0?+(/Firefox\/(\d+)/.exec(ut.userAgent)||[0,0])[1]:0,chrome:!!Iu,chrome_version:Iu?+Iu[1]:0,ios:B0,android:/Android\b/.test(ut.userAgent),webkit:_0,webkit_version:_0?+(/\bAppleWebKit\/(\d+)/.exec(ut.userAgent)||[0,0])[1]:0,safari:Cf,safari_version:Cf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ut.userAgent)||[0,0])[1]:0,tabSize:wf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function xp(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 _l=Object.create(null);function bp(e,t,n){if(e==t)return!0;e||(e=_l),t||(t=_l);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 FB(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 V0(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 zB(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 Ac=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){}},nt=(function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e})(nt||(nt={})),Ee=class extends ai{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 wp(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 Ao(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}=hk(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(s?t?2e8:1:-6e8)+1}return new Ao(e,n,r,t,e.widget||null,!0)}static line(e){return new Sp(e)}static set(e,t=!1){return Re.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Ee.none=Re.empty;var wp=class lk extends Ee{constructor(t){let{start:n,end:r}=hk(t);super(n?-1:5e8,r?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?xp(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||_l}eq(t){return this==t||t instanceof lk&&this.tagName==t.tagName&&bp(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)}};wp.prototype.point=!1;var Sp=class ck extends Ee{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof ck&&this.spec.class==t.spec.class&&bp(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)}};Sp.prototype.mapMode=It.TrackBefore;Sp.prototype.point=!0;var Ao=class uk extends Ee{constructor(t,n,r,i,s,o){super(n,r,s,t),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?It.TrackBefore:It.TrackAfter:It.TrackDel}get type(){return this.startSide!=this.endSide?nt.WidgetRange:this.startSide<=0?nt.WidgetBefore:nt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof uk&&$B(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)}};Ao.prototype.point=!0;function hk(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 $B(e,t){return e==t||!!(e&&t&&e.compare(t))}function Ki(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 F0=class Tf extends ai{constructor(t,n,r){super(),this.tagName=t,this.attributes=n,this.rank=r}eq(t){return t==this||t instanceof Tf&&this.tagName==t.tagName&&bp(this.attributes,t.attributes)}static create(t){return new Tf(t.tagName,t.attributes||_l,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(t,n=!1){return Re.of(t,n)}};F0.prototype.startSide=F0.prototype.endSide=-1;function Ro(e){let t;return e.nodeType==11?t=e.getSelection?e:e.ownerDocument:t=e,t.getSelection()}function Af(e,t){return t?e==t||e.contains(t.nodeType!=1?t.parentNode:t):!1}function so(e,t){if(!t.anchorNode)return!1;try{return Af(e,t.anchorNode)}catch{return!1}}function ll(e){return e.nodeType==3?Mo(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function oo(e,t,n,r){return n?z0(e,t,n,r,-1)||z0(e,t,n,r,1):!1}function Rr(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function Bl(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function z0(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:nr(e))){if(e.nodeName=="DIV")return!1;let s=e.parentNode;if(!s||s.nodeType!=1)return!1;t=Rr(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?nr(e):0}else return!1}}function nr(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Vl(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 HB(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 fk(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 WB(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,p=1,v=1;if(d)f=HB(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:p,scaleY:v}=fk(u,b)),f={left:b.left,right:b.left+u.clientWidth*p,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/p,b=(u.scrollLeft-S)*p}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 dk(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 qB=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?nr(t):0),n,Math.min(e.focusOffset,n?nr(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}};function pk(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 mk(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 Wr=null;q.safari&&q.safari_version>=26&&(Wr=!1);function gk(e){if(e.setActive)return e.setActive();if(Wr)return e.focus(Wr);let t=pk(e);e.focus(Wr==null?{get preventScroll(){return Wr={preventScroll:!0},!0}}:void 0),Wr||(Wr=!1,mk(t))}var $0;function Mo(e,t,n=t){let r=$0||($0=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function Gi(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 UB(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function KB(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,nr(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=nr(n))}else{if(n==e)return!0;r=Rr(n),n=n.parentNode}}function vk(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 yk(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=nr(n)}else if(n.parentNode&&!Bl(n))r=Rr(n),n=n.parentNode;else return null}}function xk(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&&!Bl(n))r=Rr(n)+1,n=n.parentNode;else return null}}var yr=class Rf{constructor(t,n,r=!0){this.node=t,this.offset=n,this.precise=r}static before(t,n){return new Rf(t.parentNode,Rr(t),n)}static after(t,n){return new Rf(t.parentNode,Rr(t)+1,n)}},Pe=(function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e})(Pe||(Pe={})),li=Pe.LTR,kp=Pe.RTL;function bk(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}var GB=bk("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),QB=bk("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Mf=Object.create(null),dn=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);Mf[t]=n,Mf[n]=-t}function wk(e){return e<=247?GB[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?QB[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var XB=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Tn=class{get dir(){return this.level%2?kp:li}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 Sk(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||!Sk(r.inner,i.inner))return!1}return!0}var we=[];function YB(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=wk(e.charCodeAt(c));f==512?f=u:f==8&&h==4&&(f=16),we[c]=f==4?2:f,f&7&&(h=f),u=f}for(let c=o,u=l,h=l;c<a;c++){let f=we[c];if(f==128)c<a-1&&u==we[c+1]&&u&24?f=we[c]=u:we[c]=256;else if(f==64){let d=c+1;for(;d<a&&we[d]==64;)d++;let p=c&&u==8||d<n&&we[d]==8?h==1?1:8:256;for(let v=c;v<d;v++)we[v]=p;c=d-1}else f==8&&h==1&&(we[c]=1);u=f,f&7&&(h=f)}}}function JB(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,p;h<u;h++)if(d=Mf[f=e.charCodeAt(h)])if(d<0){for(let v=a-3;v>=0;v-=3)if(dn[v+1]==-d){let y=dn[v+2],x=y&2?i:y&4?y&1?s:i:0;x&&(we[h]=we[dn[v]]=x),a=v;break}}else{if(dn.length==189)break;dn[a++]=h,dn[a++]=f,dn[a++]=l}else if((p=we[h])==2||p==1){let v=p==i;l=v?0:1;for(let y=a-3;y>=0;y-=3){let x=dn[y+2];if(x&2)break;if(v)dn[y+2]|=2;else{if(x&4)break;dn[y+2]|=4}}}}}function ZB(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=we[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(we[u]==256)u++;else break;let h=s==1,f=h==((u<t?we[u]:r)==1)?h?1:2:r;for(let d=u,p=i,v=p?n[p-1].to:e;d>l;)d==v&&(d=n[--p].from,v=p?n[p-1].to:e),we[--d]=f;l=u}else s=c,l++}}}function Pf(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=we[l];v!=a&&(u=!1,h=v==16)}let f=!u&&a==1?[]:null,d=u?r:r+1,p=l;e:for(;;)if(c<s.length&&p==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(we[y]==a)break e;break}}c++,f?f.push(v):(v.from>l&&o.push(new Tn(l,v.from,d)),Ef(e,v.direction==li!=!(d%2)?r+1:r,i,v.inner,v.from,v.to,o),l=v.to),p=v.to}else{if(p==n||(u?we[p]!=a:we[p]==a))break;p++}f?Pf(e,l,p,r+1,i,f,o):l<p&&o.push(new Tn(l,p,d)),l=p}else for(let l=n,c=s.length;l>t;){let u=!0,h=!1;if(!c||l>s[c-1].to){let v=we[l-1];v!=a&&(u=!1,h=v==16)}let f=!u&&a==1?[]:null,d=u?r:r+1,p=l;e:for(;;)if(c&&p==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(we[y-1]==a)break e;break}}f?f.push(v):(v.to<l&&o.push(new Tn(v.to,l,d)),Ef(e,v.direction==li!=!(d%2)?r+1:r,i,v.inner,v.from,v.to,o),l=v.from),p=v.from}else{if(p==t||(u?we[p-1]!=a:we[p-1]==a))break;p--}f?Pf(e,p,l,r+1,i,f,o):p<l&&o.push(new Tn(p,l,d)),l=p}}function Ef(e,t,n,r,i,s,o){let a=t%2?2:1;YB(e,i,s,r,a),JB(e,i,s,r,a),ZB(i,s,r,a),Pf(e,i,s,t,n,r,o)}function eV(e,t,n){if(!e)return[new Tn(0,0,t==kp?1:0)];if(t==li&&!n.length&&!XB.test(e))return kk(e.length);if(n.length)for(;e.length>we.length;)we[we.length]=256;let r=[],i=t==li?0:1;return Ef(e,i,i,n,0,e.length,r),r}function kk(e){return[new Tn(0,e,0)]}var Ck="";function tV(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=Tn.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=at(e.text,o,l.forward(i,n));(u<l.from||u>l.to)&&(u=c),Ck=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 nV(e,t,n){for(let r=t;r<n;r++){let i=wk(e.charCodeAt(r));if(i==1)return li;if(i==2||i==4)return kp}return li}var Tk=Z.define(),Ak=Z.define(),Rk=Z.define(),Mk=Z.define(),Of=Z.define(),Pk=Z.define(),Ek=Z.define(),Cp=Z.define(),Tp=Z.define(),Ok=Z.define({combine:e=>e.some(t=>t)}),Ik=Z.define({combine:e=>e.some(t=>t)}),Dk=Z.define(),Du=class If{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 If(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 If(z.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Ra=We.define({map:(e,t)=>e.map(t)}),Nk=We.define();function An(e,t,n){let r=e.facet(Mk);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 Wn=Z.define({combine:e=>e.length?e[0]:!0}),rV=0,ji=Z.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})}}),Mr=class Df{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(ji.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(ji.of({plugin:this,arg:t}))}static define(t,n){const{eventHandlers:r,eventObservers:i,provide:s,decorations:o}=n||{};return new Df(rV++,t,r,i,a=>{let l=[];return o&&l.push(Rc.of(c=>{let u=c.plugin(a);return u?o(u):Ee.none})),s&&l.push(s(a)),l})}static fromClass(t,n){return Df.define((r,i)=>new t(r,i),n)}},Nu=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(An(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){An(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){An(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},Lk=Z.define(),Ap=Z.define(),Rc=Z.define(),jk=Z.define(),Rp=Z.define(),Xo=Z.define(),_k=Z.define();function H0(e,t){let n=e.state.facet(_k);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(e):s),i=[];return Re.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,p;if(d==null&&(d=nV(t.text,c,u)),l>0&&h.length&&(p=h[h.length-1]).to==c&&p.direction==d)p.to=u,h=p.inner;else{let v={from:c,to:u,direction:d,inner:[]};h.push(v),h=v.inner}}}}),i}var Bk=Z.define();function Vk(e){let t=0,n=0,r=0,i=0;for(let s of e.state.facet(Bk)){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 zs=Z.define(),Qn=class Nf{constructor(t,n,r,i){this.fromA=t,this.toA=n,this.fromB=r,this.toB=i}join(t){return new Nf(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 p=i;p<t.length&&t[p].fromB<=h;p++)o=t[p].toA-t[p].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 Nf(u,f,c,h))}return r}},W0=class Fk{constructor(t,n,r){this.view=t,this.state=n,this.transactions=r,this.flags=0,this.startState=t.state,this.changes=rn.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 Qn(s,o,a,l))),this.changedRanges=i}static create(t,n,r){return new Fk(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}},iV=[],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 iV}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&&FB(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=Rr(this.dom),r=this.length?e>0:t>0;return new yr(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 Pc)return e;return null}static get(e){return e.cmTile}},Mc=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=q0(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=q0(r);this.length=s}};function q0(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var Pc=class extends Mc{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 ei)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}}},ei=class zk extends Mc{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 zk(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},Fl=class $k extends Mc{constructor(t,n){super(t),this.attrs=n}isLine(){return!0}static start(t,n,r){let i=new $k(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 p=u.children[f],v=d+p.length;v>=h&&(p.isComposite()?l(p,h-d):(!o||o.isHidden&&(n>0&&!(o.flags&32)||r&&oV(o,p)))&&(v>h||p.flags&32&&n<=1)?(o=p,a=h-d):(d<h||p.flags&16&&!p.isHidden&&n>=-1)&&(i=p,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):sV(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 yr(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 yr(l.dom,0);l==r.tile&&(a=!0)}}return new yr(this.dom,0)}};function sV(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=ll(t);return n[n.length-1]||null}function oV(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var jt=class Hk extends Mc{constructor(t,n){super(t),this.mark=n}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new Hk(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},$s=class Wk 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?q.chrome||q.gecko||(t?(s--,a=1):o<i&&(o++,a=-1)):n<0?s--:o<i&&o++;let l=Mo(this.dom,s,o).getClientRects();if(!l.length)return null;let c=l[(a?a<0:n>=0)?0:l.length-1];return q.safari&&!a&&c.width==0&&(c=Array.prototype.find.call(l,u=>u.width)||c),r==null?c:Vl(c,(a?a>0:n<0)==r)}static of(t,n){let r=new Wk(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},Po=class qk 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 Vl(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 Vl(o,!a)}}get overrideDOMText(){if(!this.length)return ge.empty;let{root:t}=this;if(!t)return ge.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 qk(s,r,t,i)}},zl=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 ge.empty}coordsIn(e,t,n){let r=this.dom.getBoundingClientRect();return n==null?r:Vl(r,t>0==n)}},aV=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}},lV=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},cV=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 $s(o.dom,o.text+e);a.parent=s}else s.append(r||$s.of(e,(i=this.cache.find($s))===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)?Lu(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 jt&&l.mark.eq(a.mark))l.dom!=a.dom&&l.setDOM(Lu(a.dom)),r=l;else{let{dom:c}=a;this.cache.reused.get(a)&&Ne.get(a.dom)&&(c=Lu(a.dom));let u=jt.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 $s(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=Uk);let r=Fl.start(e,t||((n=this.cache.find(Fl))===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 jt&&o.mark.eq(s))r=o,t--;else{let a=jt.of(s,(n=this.cache.find(jt,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||!U0(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(q.ios&&U0(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(ju,0,32)||new Po(ju.toDOM(),0,ju,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 lV(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 ei&&r.wrapper.eq(n.wrapper))t=r;else{let i=ei.of(n.wrapper,(e=this.cache.find(ei,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(zl,void 0,1);return n&&(n.flags=t),n||new zl(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},uV=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}},$l=[Po,Fl,$s,jt,zl,ei,Pc];for(let e=0;e<$l.length;e++)$l[e].bucket=e;var hV=class{constructor(e){this.view=e,this.buckets=$l.map(()=>[]),this.index=$l.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 Po(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}},fV=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 hV(e),this.text=new uV(e.state.doc),this.builder=new cV(this.cache,new Pc(e,e.contentDOM),Re.iter(n)),this.cache.reused.set(t,2),this.old=new aV(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=mV(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?Po.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 zl)this.cache.add(s);else if(s instanceof jt)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 jt&&r.unshift(s.mark)),this.openWidget=!1},leave:s=>{s.isLine()?r.length&&(r.length=i=0):s instanceof jt&&(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=Re.spans(this.decorations,e,t,{point:(o,a,l,c,u,h)=>{if(l instanceof Ao){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?ss.block:ss.inline),d=dV(l),p=this.cache.findWidget(f,a-o,d)||Po.of(f,this.view,a-o,d);l.block?(l.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(p)):(r.ensureLine(n),r.addInlineWidget(p,c,u))}n=null}else n=pV(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 jt?t.push(i):i?.isLine()?n=i:i instanceof ei||(r.nodeName=="DIV"&&!n?n=new Fl(r,Uk):n||t.push(jt.of(new wp({tagName:r.nodeName.toLowerCase(),attributes:zB(r)}),r)))}return n?{line:n,marks:t}:null}};function U0(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 dV(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 Uk={class:"cm-line"};function pV(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r||(e||(e={class:"cm-line"}),n&&xp(n,e),r&&(e.class+=" "+r)),e}function mV(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 jt&&t.push(r.mark)}return t}function Lu(e){let t=Ne.get(e);return t&&t.setDOM(e.cloneNode()),e}var ss=class extends Ac{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}};ss.inline=new ss("span");ss.block=new ss("div");var ju=new class extends Ac{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},K0=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Ee.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 Pc(e,e.contentDOM),this.updateInner([new Qn(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:!CV(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let i=r>-1?vV(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:u}=this.hasComposition;n=new Qn(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,(q.ie||q.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=bV(s,this.decorations,e.changes);a.length&&(n=Qn.extendWithRanges(n,a));let l=SV(o,this.blockWrappers,e.changes);return l.length&&(n=Qn.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 fV(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),Lf(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=q.chrome||q.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 _u&&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(Nk)&&(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(Wn)||n.tabIndex>-1)&&so(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)),q.gecko&&a.empty&&!this.hasComposition&&gV(l)){let h=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(h,l.node.childNodes[l.offset]||null)),l=c=new yr(h,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!oo(l.node,l.offset,u.anchorNode,u.anchorOffset)||!oo(c.node,c.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{q.android&&q.chrome&&n.contains(u.focusNode)&&kV(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let h=Ro(this.view.root);if(h)if(a.empty){if(q.gecko){let f=yV(l.node,l.offset);if(f&&f!=3){let d=(f==1?yk:xk)(l.node,l.offset);d&&(l=new yr(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 yr(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new yr(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&oo(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=Ro(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=nr(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 _u?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=at(i.text,s);if(o==s)return null;let a=Mo(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==Pe.LTR,l=0,c=(u,h,f)=>{for(let d=0;d<u.children.length&&!(h>r);d++){let p=u.children[d],v=h+p.length,y=p.dom.getBoundingClientRect(),{height:x}=y;if(f&&!d&&(l+=y.top-f.top),p instanceof ei)v>n&&c(p,h,y);else if(h>=n&&(l>0&&t.push(-l),t.push(x+l),l=0,s)){let b=p.dom.lastChild,w=b?ll(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+p.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?Pe.RTL:Pe.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=ll(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=ll(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(Ee.replace({widget:new _u(o),block:!0,inclusive:!0,isBlockGap:!0}).range(n,s))}if(!i)break;n=i.to+1}return Ee.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Rc).map(i=>(this.dynamicDecorationMap[e++]=typeof i=="function")?i(this.view):i),n=!1,r=this.view.state.facet(Rp).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(Re.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(jk).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(Dk))try{if(l(this.view,e.range,e))return!0}catch(c){An(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=Vk(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(WB(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==Pe.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=pk(l.dom);l.dom.scrollIntoView({block:"nearest"}),mk(c,!1)}}}lineHasWidget(e){let t=n=>n.isWidget()||n.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Lf(this.tile)}};function Lf(e,t){let n=t?.get(e);if(n!=1){n==null&&e.destroy();for(let r of e.children)Lf(r,t)}}function gV(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 Kk(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=yk(n.focusNode,n.focusOffset),i=xk(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 vV(e,t,n){let r=Kk(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 Qn(l.mapPos(s),l.mapPos(o),s,o),text:i}}function yV(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 xV=class{constructor(){this.changes=[]}compareRange(t,n){Ki(t,n,this.changes)}comparePoint(t,n){Ki(t,n,this.changes)}boundChange(t){Ki(t,t,this.changes)}};function bV(e,t,n){let r=new xV;return Re.compare(e,t,n,r),r.changes}var wV=class{constructor(){this.changes=[]}compareRange(e,t){Ki(e,t,this.changes)}comparePoint(){}boundChange(e){Ki(e,e,this.changes)}};function SV(e,t,n){let r=new wV;return Re.compare(e,t,n,r),r.changes}function kV(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 CV(e,t){let n=!1;return t&&e.iterChangedRanges((r,i)=>{r<t.to&&i>t.from&&(n=!0)}),n}var _u=class extends Ac{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 TV(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=at(i.text,s,!1):a=at(i.text,s);let l=r(i.text.slice(o,a));for(;o>0;){let c=at(i.text,o,!1);if(r(i.text.slice(c,o))!=l)break;o=c}for(;a<i.length;){let c=at(i.text,a);if(r(i.text.slice(a,c))!=l)break;a=c}return z.undirectionalRange(o+i.from,a+i.from)}function AV(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+LB(o,s,e.state.tabSize)}function jf(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==nt.Text&&(i.type!=s.type||(n<0?s.from<t:s.to>t)))&&(i=s)}}return i||r}return r}function RV(e,t,n,r){let i=jf(e,t.head,t.assoc||-1),s=!r||i.type!=nt.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==Pe.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 G0(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=tV(i,s,o,a,n),u=Ck;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 MV(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return s=>{let o=r(s);return i==Gn.Space&&(i=o),i==o}}function PV(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 p=e.viewState.lineBlockAt(i);o==null&&(o=Math.min(l.right-l.left,e.defaultCharacterWidth*(i-p.from))),a=(s<0?p.top:p.bottom)+u}let h=l.left+o,f=e.viewState.heightOracle.textHeight>>1,d=r??f;for(let p=0;;p+=f){let v=a+(d+p)*s,y=_f(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 ao(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 Gk(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=ao(e,i.from,0);o!=i.from&&(s=z.cursor(o,-1))}else{let o=ao(e,i.from,-1),a=ao(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 Bu(e,t,n){let r=ao(e.state.facet(Xo).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 Sn=class{constructor(e,t){this.pos=e,this.assoc=t}};function _f(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 Sn(0,1);if(l>e.viewState.docHeight)return new Sn(e.state.doc.length,-1);if(c=e.elementAtHeight(l),r==null)break;if(c.type==nt.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==nt.Text){let h=AV(e,i,c,o,a);return new Sn(h,h==c.from?1:-1)}}if(c.type!=nt.Text)return l<(c.top+c.bottom)/2?new Sn(c.from,1):new Sn(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 EV(e,o,a,e.textDirectionAt(c.from)).scanTile(u,c.from)}var EV=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[Tn.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[Tn.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,p=r+i>>1;t:if(s.has(p)){for(let x=1;x<d;x++){let b=p+x;if(b>=i&&(b-=d),!s.has(b)){p=b;break t}}break e}s.add(p);let v=t(p),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=p,u=S,h=b),w&&(y=w<0==(this.baseDir==Pe.LTR)?-1:1)}}y==-1&&(!o||this.baseDirAt(e[p],1))?i=p:y==1&&(!o||this.baseDirAt(e[p+1],-1))&&(r=p+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:p}=h;if(a&&a.bottom>(d+d+p)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(l&&l.top<(d+p+p)/3)return this.y=l.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[c],1):this.baseDir)==Pe.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=at(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 Mo(e.dom,s,o).getClientRects()});return r.after?new Sn(n[r.i+1],-1):new Sn(n[r.i],1)}scanTile(e,t){if(!e.length)return new Sn(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:Mo(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 Sn(n[r.i+1],-1):new Sn(s,1)}},cl="￿",OV=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(ze.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=cl}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:Bl(r))||Bl(o)&&(r.nodeName!="BR"||s?.isWidget())&&this.text.length>i)&&!DV(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+(IV(e,n.node,n.offset)?t:0))}};function IV(e,t,n){for(;;){if(!t||n<nr(t))return!1;if(t==e)return!0;n=Rr(t)+1,t=t.parentNode}}function DV(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 Q0=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},NV=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=Qk(e.docView.tile,t,n,0))){let a=i||s?[]:jV(e),l=new OV(a,e);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=_V(a,this.bounds.from)}else{let a=e.observer.selectionRange,l=i&&i.node==a.focusNode&&i.offset==a.focusOffset||!Af(e.contentDOM,a.focusNode)?o.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=s&&s.node==a.anchorNode&&s.offset==a.anchorOffset||!Af(e.contentDOM,a.anchorNode)?o.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=e.viewport;if((q.ios||q.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,p=u.to-f;(d==0||d==1||h==0)&&(p==0||p==-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 Qk(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 Qk(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 Xk(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||q.android&&t.text.length<l-a)&&(c=s.to,u="end");let h=i.doc.sliceString(a,l,cl),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:ge.of(t.text.slice(s.from-a,f).split(cl))}:(d=Yk(h,t.text,c-a,u))&&(q.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:ge.of(t.text.slice(d.from,d.toB).split(cl))})}else r&&(!e.hasFocus&&i.facet(Wn)||Hl(r,s))&&(r=null);if(!n&&!r)return!1;if((q.mac||q.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:ge.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)}:q.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:ge.of([" "])}),n)return Mp(e,n,r,o);if(r&&!Hl(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=Gk(i.facet(Xo).map(c=>c(e)),r))),e.dispatch({selection:r,scrollIntoView:a,userEvent:l}),!0}else return!1}function Mp(e,t,n,r=-1){if(q.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(q.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&&Gi(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)&&Gi(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&Gi(e.contentDOM,"Delete",46)))return!0;let s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,a=()=>o||(o=LV(e,t,n));return e.state.facet(Pk).some(l=>l(e,t.from,t.to,s,a))||e.dispatch(a()),!0}function LV(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=ao(i.facet(Xo).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&&Kk(e,n.main.head);if(f){let p=t.insert.length-(t.to-t.from);h={from:f.from,to:f.to-p}}else h=e.state.doc.lineAt(s.head);let d=s.to-t.to;r=i.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:l,range:c||p.map(l)};let v=p.to-d,y=v-u.length;if(e.state.sliceDoc(y,v)!=u||v>=h.from&&y<=h.to)return{range:p};let x=i.changes({from:y,to:v,insert:t.insert}),b=p.to-s.to;return{changes:x,range:c?z.range(Math.max(0,c.anchor+b),Math.max(0,c.head+b)):p.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 Yk(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 jV(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 Q0(n,r)),(i!=n||s!=r)&&t.push(new Q0(i,s))),t}function _V(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 Hl(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var BV=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,q.safari&&e.contentDOM.addEventListener("input",()=>null),q.gecko&&eF(e.contentDOM.ownerDocument)}handleEvent(e){!KV(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=FV(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&&Zk.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),q.android&&q.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(q.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Jk.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||zV.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&q.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&VV(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,Gi(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:q.safari&&!q.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 VV(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function X0(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(i){An(n.state,i)}}}function FV(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(X0(r.value,l))}if(o)for(let a in o){let l=o[a];l&&n(a).observers.push(X0(r.value,l))}}for(let r in sn)n(r).handlers.push(sn[r]);for(let r in mt)n(r).observers.push(mt[r]);return t}var Jk=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],zV="dthko",Zk=[16,17,18,20,91,92,224,225],Ma=6;function Pa(e){return Math.max(0,e)*.7+8}function $V(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var HV=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=dk(e.contentDOM),this.atoms=e.state.facet(Xo).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(ze.allowMultipleSelections)&&WV(e,t),this.dragging=UV(e,t)&&n1(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&&$V(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=Vk(this.view);e.clientX-a.left<=r+Ma?t=-Pa(r-e.clientX):e.clientX+a.right>=s-Ma&&(t=Pa(e.clientX-s)),e.clientY-a.top<=i+Ma?n=-Pa(i-e.clientY):e.clientY+a.bottom>=o-Ma&&(n=Pa(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=Gk(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 WV(e,t){let n=e.state.facet(Tk);return n.length?n[0](t):q.mac?t.metaKey:t.ctrlKey}function qV(e,t){let n=e.state.facet(Ak);return n.length?n[0](t):q.mac?!t.altKey:!t.ctrlKey}function UV(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=Ro(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 KV(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 sn=Object.create(null),mt=Object.create(null),e1=q.ie&&q.ie_version<15||q.ios&&q.webkit_version<604;function GV(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(),t1(e,n.value)},50)}function Ec(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function t1(e,t){t=Ec(e.state,Cp,t);let{state:n}=e,r,i=1,s=n.toText(t),o=s.lines==n.selection.ranges.length;if(Bf!=null&&n.selection.ranges.every(a=>a.empty)&&Bf==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,q.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())};mt.wheel=mt.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()};sn.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};sn.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(Rk))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=XV(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new HV(e,t,n,r)),r&&e.observer.ignore(()=>{gk(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 Y0(e,t,n,r){if(r==1)return z.cursor(t,n);if(r==2)return TV(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 QV=q.ie&&q.ie_version<=11,J0=null,Z0=0,ev=0;function n1(e){if(!QV)return e.detail;let t=J0,n=ev;return J0=e,ev=Date.now(),Z0=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Z0+1)%3:1}function XV(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=n1(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=Y0(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){let h=Y0(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=YV(i,l.pos))?c:a?i.addRange(u):z.create([u])}}}function YV(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}sn.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",Ec(e.state,Tp,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1};sn.dragend=e=>(e.inputState.draggedContent=null,!1);function tv(e,t,n,r){if(n=Ec(e.state,Cp,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:s}=e.inputState,o=r&&s&&qV(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}sn.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&&tv(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 tv(e,t,r,!0),!0}return!1};sn.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=e1?null:t.clipboardData;return n?(t1(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(GV(e),!1)};function JV(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 ZV(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:Ec(e,Tp,t.join(e.lineBreak)),ranges:n,linewise:r}}var Bf=null;sn.copy=sn.cut=(e,t)=>{if(!so(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=ZV(e.state);if(!n&&!i)return!1;Bf=i?n:null,t.type=="cut"&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=e1?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(JV(e,n),!1)};var r1=di.define();function i1(e,t){let n=[];for(let r of e.facet(Ek)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:r1.of(!0)}):null}function s1(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=i1(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),s1(e)};mt.blur=e=>{e.observer.clearSelectionRange(),s1(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,q.chrome&&q.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()};sn.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 Mp(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(q.chrome&&q.android&&(i=Jk.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 q.ios&&t.inputType=="deleteContentForward"&&e.observer.flushSoon(),q.safari&&t.inputType=="insertText"&&e.inputState.composing>=0&&setTimeout(()=>mt.compositionend(e,t),20),!1};var nv=new Set;function eF(e){nv.has(e)||(nv.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}var rv=["pre-wrap","normal","pre-line","break-spaces"],os=!1;function iv(){os=!1}var tF=class{constructor(e){this.lineWrapping=e,this.doc=ge.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 rv.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=rv.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}},nF=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},qn=class o1{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"?nt.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 Ao?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 o1(this.from,this.length+t.length,this.top,this.height+t.height,n)}},ke=(function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e})(ke||(ke={})),ul=.001,tn=class hl{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)>ul&&(os=!0),this.height=t)}replace(t,n,r){return hl.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,ke.ByPosNoHeight,r.setDoc(n),0,0),d=f.to>=c?f:s.lineAt(c,ke.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,ke.ByPosNoHeight,r,0,0));u+=f.from-l,l=f.from;let p=oF.build(r.setDoc(o),t,u,h);s=Wl(s,s.replace(l,c,p))}return s.updateHeight(r,0)}static empty(){return new vn(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 iF(hl.of(t.slice(0,n)),o,hl.of(t.slice(r)))}};function Wl(e,t){return e==t?e:(e.constructor!=t.constructor&&(os=!0),t)}tn.prototype.size=1;var rF=Ee.replace({}),a1=class extends tn{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new qn(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 qn(r,0,n,this.spaceAbove,rF):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,ke.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})`}},vn=class Vf extends a1{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 qn(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 Vf||i instanceof Qi&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Qi?i=new Vf(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):tn.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:""})`}},Qi=class qt extends tn{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 qn(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 qn(u,h,r+a*c,a,0)}}lineAt(t,n,r,i,s){if(n==ke.ByHeight)return this.blockAt(t,r,i,s);if(n==ke.ByPosNoHeight){let{from:d,to:p}=r.doc.lineAt(t);return new qn(d,p-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 qn(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 p=f.number-a;h+=l*p+c*(t-s-p)}let d=l+c*f.length;o(new qn(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 tn.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)>=ul&&(l=-2);let d=new vn(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=tn.of(o);return(l<0||Math.abs(c.height-this.height)>=ul||Math.abs(l-this.heightMetrics(t,n).perLine)>=ul)&&(os=!0),Wl(this,c)}else(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},iF=class extends tn{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==ke.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==ke.ByPosNoHeight?ke.ByPosNoHeight:ke.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,ke.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&&sv(i,s-1),t<this.length){let o=i.length;this.decomposeRight(t,i),sv(i,o)}return tn.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?tn.of(this.break?[e,null,t]:[e,t]):(this.left=Wl(this.left,e),this.right=Wl(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 sv(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof Qi&&(r=e[t+1])instanceof Qi&&e.splice(t-1,3,new Qi(n.length+1+r.length))}var sF=5,oF=class l1{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 vn?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new vn(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 a1(o,i,r)):(o||s||i>=sF)&&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 vn(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,n){let r=new Qi(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 vn)return t;let n=new vn(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 vn)&&!this.isCovered?this.nodes.push(new vn(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 vn&&i.updateHeight(this.oracle,r),r+=i?i.length:1;return this.nodes}static build(t,n,r,i){let s=new l1(r,t);return Re.spans(n,r,i,s,0),s.finish(r)}};function aF(e,t,n){let r=new lF;return Re.compare(e,t,n,r,0),r.changes}var lF=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&Ki(e,t,this.changes,5)}};function cF(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 uF(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 hF(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var Vu=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 Ee.replace({widget:new fF(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},fF=class extends Ac{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}},ov=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=av,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Pe.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(Ap).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new tF(n),this.stateDeco=lv(t),this.heightMap=tn.empty().applyChanges(this.stateDeco,ge.empty,this.heightOracle.setDoc(t.doc),[new Qn(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=Ee.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 Ea(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?av:new mF(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(Hs(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=lv(this.state);let r=e.changedRanges,i=Qn.extendWithRanges(r,aF(n,this.stateDeco,e?e.changes:rn.empty(this.state.doc.length))),s=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);iv(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=s||os)&&(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(Ik)&&(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"?Pe.RTL:Pe.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}=fk(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=dk(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=vk(this.scrollParent||e.win);let p=(this.printing?hF:cF)(t,this.paddingTop),v=p.top-this.pixelViewport.top,y=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;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&&!uF(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:T,textHeight:k}=e.docView.measureTextSize();s=C>0&&r.refresh(i,C,T,k,Math.max(5,b/T),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)),iv();for(let C of this.viewports){let T=C.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(C);this.heightMap=(s?tn.empty().applyChanges(this.stateDeco,ge.empty,this.heightOracle,[new Qn(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,s,new nF(C.from,T))}os&&(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 Ea(r.lineAt(s-n*1e3,ke.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,ke.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,ke.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 Ea(r.lineAt(h-500,ke.ByHeight,i,0,0).from,r.lineAt(h+c+500,ke.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 Ea(this.heightMap.lineAt(n,ke.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ke.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,ke.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,ke.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 Vu(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!=Pe.LTR&&!n)return[];let o=[],a=(c,u,h,f)=>{if(u-c<i)return;let d=this.state.selection.main,p=[d.from];d.empty||p.push(d.to);for(let y of p)if(y>c&&y<u){a(c,y-10,h,f),a(y+10,u,h,f);return}let v=pF(e,y=>y.from>=h.from&&y.to<=h.to&&Math.abs(y.from-c)<i&&Math.abs(y.to-u)<i&&!p.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 Vu(c,u,y,n||y<2e6?y:2e6)}o.push(v)},l=c=>{if(c.length<s||c.type!=nt.Text)return;let u=dF(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 p=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,v,y;if(h!=null){let x=Ia(u,h),b=((this.visibleBottom-this.visibleTop)/2+p)/c.height;v=x-b,y=x+b}else v=(this.visibleTop-c.top-p)/c.height,y=(this.visibleBottom-c.top+p)/c.height;f=Oa(u,v),d=Oa(u,y)}else{let p=u.total*this.heightOracle.charWidth,v=r*this.heightOracle.charWidth,y=0;if(p>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=Ia(u,h),T=((b-x)/2+v)/p;w=C-T,S=C+T}else w=(x-v)/p,S=(b+v)/p;f=Oa(u,w),d=Oa(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=Ia(r,n)-Ia(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){Vu.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Ee.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=[];Re.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)||Hs(this.heightMap.lineAt(e,ke.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)||Hs(this.heightMap.lineAt(this.scaler.fromDOM(e),ke.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 Hs(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}},Ea=class{constructor(e,t){this.from=e,this.to=t}};function dF(e,t,n){let r=[],i=e,s=0;return Re.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 Oa({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 Ia(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 pF(e,t){for(let n of e)if(t(n))return n}var av={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function lv(e){let t=e.facet(Rc).filter(r=>typeof r!="function"),n=e.facet(Rp).filter(r=>typeof r!="function");return n.length&&t.push(Re.join(n)),t}var mF=class c1{constructor(t,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:a,to:l})=>{let c=n.lineAt(a,ke.ByPos,t,0,0).top,u=n.lineAt(l,ke.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 c1?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 Hs(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new qn(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(i=>Hs(i,t)):e._content)}var Da=Z.define({combine:e=>e.join(" ")}),Ff=Z.define({combine:e=>e.indexOf(!0)>-1}),zf=Tr.newName(),u1=Tr.newName(),h1=Tr.newName(),f1={"&light":"."+u1,"&dark":"."+h1};function $f(e,t,n){return new Tr(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 gF=$f("."+zf,{"&":{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"}},f1),vF={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Fu=q.ie&&q.ie_version<=11,yF=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new qB,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);(q.ie&&q.ie_version<=11||q.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&&q.android&&e.constructor.EDIT_CONTEXT!==!1&&!(q.chrome&&q.chrome_version<126)&&(this.editContext=new bF(e),e.state.facet(Wn)&&(e.contentDOM.editContext=this.editContext.editContext)),Fu&&(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(Wn)?n.root.activeElement!=this.dom:!so(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}(q.ie&&q.ie_version<=11||q.android&&q.chrome)&&!n.state.selection.main.empty&&r.focusNode&&oo(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Ro(e.root);if(!t)return!1;let n=q.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&xF(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=so(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&KB(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,vF),Fu&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Fu&&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&&Gi(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&&so(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 NV(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=Xk(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Hl(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=cv(t,e.previousSibling||e.target.previousSibling,-1),r=cv(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(Wn)!=e.state.facet(Wn)&&(e.view.contentDOM.editContext=e.state.facet(Wn)?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 cv(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 uv(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 oo(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function xF(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return uv(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?uv(e,n):null}var bF=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=Yk(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));Hl(h,r)||e.dispatch({selection:h,userEvent:"select"});return}let u={from:c.from+o,to:c.toA+o,insert:ge.of(n.text.slice(c.from,c.toB).split(`
61
+ `))};if((q.mac||q.android)&&u.from==s-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:o,to:a,insert:ge.of([n.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let h=this.to-this.from+(u.to-u.from+u.insert.length);Mp(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(Ee.mark({attributes:{style:c}}).range(a,l))}}}e.dispatch({effects:Nk.of(Ee.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=Ro(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])}},oe=class fl{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||UB(t.parent)||document,this.viewState=new ov(this,t.state||ze.create(t)),t.scrollTo&&t.scrollTo.is(Ra)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ji).map(i=>new Nu(i));for(let i of this.plugins)i.update(this);this.observer=new yF(this),this.inputState=new BV(this),this.inputState.ensureHandlers(this.plugins),this.docView=new K0(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 en?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(r1))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=i1(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(ze.phrases)!=this.state.facet(ze.phrases))return this.setState(s);i=W0.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:p,y:v}=this.state.facet(fl.cursorScrollMargin);h=new Du(d.empty?d:z.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",v,p)}for(let d of f.effects)d.is(Ra)&&(h=d.value.clip(this.state))}this.viewState.update(i,h),this.bidiCache=fv.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(zs)!=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(Da)!=i.state.facet(Da)&&(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(Of))try{f(i)}catch(d){An(this.state,d,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!Xk(this,u)&&c.force&&Gi(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 ov(this,t),this.plugins=t.facet(ji).map(r=>new Nu(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new K0(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(ji),r=t.state.facet(ji);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new Nu(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){An(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(vk(r||this.win))s=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let p=this.viewState.scrollAnchorAt(i);s=p.from,o=p.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(p=>{try{return p.read(this)}catch(v){return An(this.state,v),hv}}),f=W0.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 p=0;p<u.length;p++)if(h[p]!=hv)try{let v=u[p];v.write&&v.write(h[p],this)}catch(v){An(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 p=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)/this.viewState.scaleY-o/a;if((p>1||p<-1)&&!(q.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+p,r?s<0?r.scrollTop=r.scrollHeight:r.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(Of))l(n)}get themeClasses(){return zf+" "+(this.state.facet(Ff)?h1:u1)+" "+this.state.facet(Da)}updateAttrs(){let t=dv(this,Lk,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Wn)?"true":"false",class:"cm-content",style:`${q.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),dv(this,Ap,n);let r=this.observer.ignore(()=>{let i=V0(this.contentDOM,this.contentAttrs,n),s=V0(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(fl.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(zs);let t=this.state.facet(fl.cspNonce);Tr.mount(this.root,this.styleModules.concat(gF).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 Bu(this,t,G0(this,t,n,r))}moveByGroup(t,n){return Bu(this,t,G0(this,t,n,r=>MV(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 RV(this,t,n,r)}moveVertically(t,n,r){return Bu(this,t,PV(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=_f(this,t,n);return r&&r.pos}posAndSideAtCoords(t,n=!0){return this.readMeasured(),_f(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let r=this.state.doc.lineAt(t),i=this.bidiSpans(r),s=i[Tn.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==Pe.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(Ok)||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>wF)return kk(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||Sk(s.isolates,r=H0(this,t))))return s.order;r||(r=H0(this,t));let i=eV(t.text,n,r);return this.bidiCache.push(new fv(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||q.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{gk(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 Ra.of(new Du(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 Ra.of(new Du(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 Mr.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Mr.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=Tr.newName(),i=[Da.of(r),zs.of($f(`.${r}`,t))];return n&&n.dark&&i.push(Ff.of(!0)),i}static baseTheme(t){return kc.lowest(zs.of($f("."+zf,t,f1)))}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}};oe.styleModule=zs;oe.inputHandler=Pk;oe.clipboardInputFilter=Cp;oe.clipboardOutputFilter=Tp;oe.scrollHandler=Dk;oe.focusChangeEffect=Ek;oe.perLineTextDirection=Ok;oe.exceptionSink=Mk;oe.updateListener=Of;oe.editable=Wn;oe.mouseSelectionStyle=Rk;oe.dragMovesSelection=Ak;oe.clickAddsSelectionRange=Tk;oe.decorations=Rc;oe.blockWrappers=jk;oe.outerDecorations=Rp;oe.atomicRanges=Xo;oe.bidiIsolatedRanges=_k;oe.cursorScrollMargin=Z.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}}});oe.scrollMargins=Bk;oe.darkTheme=Ff;oe.cspNonce=Z.define({combine:e=>e.length?e[0]:""});oe.contentAttributes=Ap;oe.editorAttributes=Lk;oe.lineWrapping=oe.contentAttributes.of({class:"cm-lineWrapping"});oe.announce=We.define();var wF=4096,hv={},fv=class d1{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:Pe.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 d1(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function dv(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&&xp(o,n)}return n}var SF=q.mac?"mac":q.windows?"win":q.linux?"linux":"key";function kF(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 Na(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 CF=kc.default(oe.domEventHandlers({keydown(e,t){return MF(TF(t.state),e,t,"editor")}})),p1=Z.define({enables:CF}),pv=new WeakMap;function TF(e){let t=e.facet(p1),n=pv.get(t);return n||pv.set(t,n=RF(t.reduce((r,i)=>r.concat(i),[]))),n}var pr=null,AF=4e3;function RF(e,t=SF){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)),p=a.split(/ (?!$)/).map(x=>kF(x,t));for(let x=1;x<p.length;x++){let b=p.slice(0,x).join(" ");i(b,!0),d[b]||(d[b]={preventDefault:!0,stopPropagation:!1,run:[w=>{let S=pr={view:w,prefix:b,scope:o};return setTimeout(()=>{pr==S&&(pr=null)},AF),!0}]})}let v=p.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,Hf))}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 Hf=null;function MF(e,t,n,r){Hf=t;let i=VB(t),s=bB(i,0),o=wB(s)==i.length&&i!=" ",a="",l=!1,c=!1,u=!1;pr&&pr.view==n&&pr.scope==r&&(a=pr.prefix+" ",Zk.indexOf(t.keyCode)<0&&(c=!0,pr=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],p,v;return d&&(f(d[a+Na(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(q.windows&&t.ctrlKey&&t.altKey)&&!(q.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=Ar[t.keyCode])&&p!=i?(f(d[a+Na(p,t,!0)])||t.shiftKey&&(v=To[t.keyCode])!=i&&v!=p&&f(d[a+Na(v,t,!1)]))&&(l=!0):o&&t.shiftKey&&f(d[a+Na(i,t,!0)])&&(l=!0),!l&&f(d._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),Hf=null,l}var lo=class m1{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=g1(t);return[new m1(n,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return PF(t,n,r)}};function g1(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Pe.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function mv(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 PF(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==Pe.LTR,o=e.contentDOM,a=o.getBoundingClientRect(),l=g1(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=jf(e,r,1),p=jf(e,i,-1),v=d.type==nt.Text?d:null,y=p.type==nt.Text?p:null;if(v&&(e.lineWrapping||d.widgetLineBreaks)&&(v=mv(e,r,1,v)),y&&(e.lineWrapping||p.widgetLineBreaks)&&(y=mv(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),T=y?w(null,n.to,y):S(p,!0),k=[];return(v||d).to<(y||p).from-(v&&y?1:0)||d.widgetLineBreaks>1&&C.bottom+e.defaultLineHeight/2<T.top?k.push(x(h,C.bottom,f,T.top)):C.bottom<T.top&&e.elementAtHeight((C.bottom+T.top)/2).type==nt.Text&&(C.bottom=T.top=(C.bottom+T.top)/2),b(C).concat(k).concat(b(T))}function x(C,T,k,A){return new lo(t,C-l.left,T-l.top,Math.max(0,k-C),A-T)}function b({top:C,bottom:T,horizontal:k}){let A=[];for(let E=0;E<k.length;E+=2)A.push(x(k[E],C,k[E+1],T));return A}function w(C,T,k){let A=1e9,E=-1e9,R=[];function O(N,P,L,B,H){let V=e.coordsAtPos(N,N==k.to?-2:2),I=e.coordsAtPos(L,L==k.from?2:-2);!V||!I||(A=Math.min(V.top,I.top,A),E=Math.max(V.bottom,I.bottom,E),H==Pe.LTR?R.push(s&&P?h:V.left,s&&B?f:I.right):R.push(!s&&B?h:I.left,!s&&P?f:V.right))}let M=C??k.from,j=T??k.to;for(let N of e.visibleRanges)if(N.to>M&&N.from<j)for(let P=Math.max(N.from,M),L=Math.min(N.to,j);;){let B=e.state.doc.lineAt(P);for(let H of e.bidiSpans(B)){let V=H.from+B.from,I=H.to+B.from;if(V>=L)break;I>P&&O(Math.max(V,P),C==null&&V<=M,Math.min(I,L),T==null&&I>=j,H.dir)}if(P=B.to+1,P>=L)break}return R.length==0&&O(M,C==null,j,T==null,e.textDirection),{top:A,bottom:E,horizontal:R}}function S(C,T){let k=a.top+(T?C.top:C.bottom);return{top:k,bottom:k,horizontal:[]}}}function EF(e,t){return e.constructor==t.constructor&&e.eq(t)}var OF=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(dl)!=e.state.facet(dl)&&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(dl);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)=>!EF(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,q.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},dl=Z.define();function v1(e){return[Mr.define(t=>new OF(t,e)),dl.of(e)]}var as=Z.define({combine(e){return vp(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function IF(e={}){return[as.of(e),DF,NF,jF,Ik.of(!0)]}function y1(e){return e.startState.facet(as)!=e.state.facet(as)}var DF=v1({above:!0,markers(e){let{state:t}=e,n=t.facet(as),r=[];for(let i of t.selection.ranges){let s=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(s&&q.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 lo.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=y1(e);return n&&gv(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){gv(t.state,e)},class:"cm-cursorLayer"});function gv(e,t){t.style.animationDuration=e.facet(as).cursorBlinkRate+"ms"}var NF=v1({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 lo.forRange(e,"cm-selectionBackground",i))t.push(s);if(q.ios&&!n.empty&&e.state.facet(as).iosSelectionHandles){for(let i of lo.forRange(e,"cm-selectionHandle cm-selectionHandle-start",z.cursor(n.from,1)))t.push(i);for(let i of lo.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||y1(e)},class:"cm-selectionLayer"}),LF=q.gecko&&q.gecko_version==153?"#ffffff01":"transparent",jF=kc.highest(oe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${LF} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),gW=/x/.unicode!=null?"gu":"g";function _F(){return VF}var BF=Ee.line({class:"cm-activeLine"}),VF=Mr.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(BF.range(i.from)),t=i.from)}return Ee.set(n)}},{decorations:e=>e.decorations}),Pr=class extends ai{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Pr.prototype.elementClass="";Pr.prototype.toDOM=void 0;Pr.prototype.mapMode=It.TrackBefore;Pr.prototype.startSide=Pr.prototype.endSide=-1;Pr.prototype.point=!0;var pl=Z.define(),FF=Z.define(),ml=Z.define(),Wf=Z.define({combine:e=>e.some(t=>t)});function zF(e){let t=[$F];return e&&e.fixed===!1&&t.push(Wf.of(!0)),t}var $F=Mr.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(ml).map(t=>new yv(e,t)),this.fixed=!e.state.facet(Wf);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(Wf)!=!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=Re.iter(this.view.state.facet(pl),this.view.viewport.from),r=[],i=this.gutters.map(s=>new HF(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==nt.Text&&o){qf(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==nt.Text){qf(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(ml),n=e.state.facet(ml),r=e.docChanged||e.heightChanged||e.viewportChanged||!Re.eq(e.startState.facet(pl),e.state.facet(pl),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 yv(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=>oe.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==Pe.LTR?{left:r,right:i}:{right:r,left:i}})});function vv(e){return Array.isArray(e)?e:[e]}function qf(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var HF=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=Re.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 x1(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=[];qf(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(FF)){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()}}},yv=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=vv(t.markers(e)),t.initialSpacer&&(this.spacer=new x1(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=vv(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!Re.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()}},x1=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":""),WF(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 WF(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 qF=Z.define(),UF=Z.define(),_i=Z.define({combine(e){return vp(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}})}}),zu=class extends Pr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function $u(e,t){return e.state.facet(_i).formatNumber(t,e.state)}var KF=ml.compute([_i],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(qF)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new zu($u(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(UF)){let s=i(t,n,r);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(_i)!=t.state.facet(_i),initialSpacer(t){return new zu($u(t,xv(t.state.doc.lines)))},updateSpacer(t,n){let r=$u(n.view,xv(n.view.state.doc.lines));return r==t.number?t:new zu(r)},domEventHandlers:e.facet(_i).domEventHandlers,side:"before"}));function GF(e={}){return[_i.of(e),zF(),KF]}function xv(e){let t=9;for(;t<e;)t=t*10+9;return t}var QF=new class extends Pr{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},XF=pl.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(QF.range(i)))}return Re.of(t)});function YF(){return XF}var Hu,Bi=new fe;function JF(e){return Z.define({combine:e?t=>t.concat(e):void 0})}var ZF=new fe,Xt=class{constructor(e,t,n=[],r=""){this.data=e,this.name=r,ze.prototype.hasOwnProperty("tree")||Object.defineProperty(ze.prototype,"tree",{get(){return Dn(this)}}),this.parser=t,this.extension=[ls.of(this),ze.languageData.of((i,s,o)=>{let a=bv(i,s,o),l=a.type.prop(Bi);if(!l)return[];let c=i.facet(l),u=a.type.prop(ZF);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 bv(e,t,n).type.prop(Bi)==this.data}findRegions(e){let t=e.facet(ls);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(Bi)==this.data){n.push({from:s,to:s+i.length});return}let o=i.prop(fe.mounted);if(o){if(o.tree.prop(Bi)==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 Xe&&r(l,i.positions[a]+s)}};return r(Dn(e),0),n}get allowsNesting(){return!0}};Xt.setState=We.define();function bv(e,t,n){let r=e.facet(ls),i=Dn(e).topNode;if(!r||r.allowsNesting)for(let s=i;s;s=s.enter(t,n,Ie.ExcludeBuffers|Ie.EnterBracketed))s.type.isTop&&(i=s);return i}var ez=class Uf extends Xt{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=JF(t.languageData);return new Uf(n,t.parser.configure({props:[Bi.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new Uf(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Dn(e){let t=e.field(Xt.state,!1);return t?t.tree:Xe.empty}var tz=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)}},Is=null,nz=class Kf{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 Kf(t,n,[],Xe.empty,0,r,[],null)}startParse(){return this.parser.startParse(new tz(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Xe.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(tl.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(tl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=Is;Is=this;try{return t()}finally{Is=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=wv(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=tl.applyChanges(r,l),i=Xe.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 Kf(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=wv(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 TS{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=Is;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 Xe(Ft.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 Is}};function wv(e,t,n){return tl.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var Gf=class Qf{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 Qf(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=nz.create(t.facet(ls).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Qf(r)}};Xt.state=Qo.define({create:Gf.init,update(e,t){for(let n of t.effects)if(n.is(Xt.setState))return n.value;return t.startState.facet(ls)!=t.state.facet(ls)?Gf.init(t.state):e.apply(t)}});var b1=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(b1=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var Wu=typeof navigator<"u"&&(!((Hu=navigator.scheduling)===null||Hu===void 0)&&Hu.isInputPending)?()=>navigator.scheduling.isInputPending():null,rz=Mr.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(Xt.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(Xt.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=b1(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(Xt.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!Wu?Math.max(25,t.timeRemaining()-5):1e9),a=s.context.treeLen<i&&r.doc.length>i+1e3,l=s.context.work(()=>Wu&&Wu()||Date.now()>o,i+(a?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Xt.setState.of(new Gf(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=>An(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()}}}),ls=Z.define({combine(e){return e.length?e[0]:null},enables:e=>[Xt.state,rz,oe.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),iz=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},sz=Z.define(),Pp=Z.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 ql(e){let t=e.facet(Pp);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Eo(e,t){let n="",r=e.tabSize,i=e.facet(Pp)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let s=0;s<t;s++)n+=i;return n}function Ep(e,t){e instanceof ze&&(e=new Oc(e));for(let r of e.state.facet(sz)){let i=r(e,t);if(i!==void 0)return i}let n=Dn(e.state);return n.length>=t?oz(e,n,t):null}var Oc=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=ql(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 Cc(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}},w1=new fe;function oz(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 S1(r,e,n)}function S1(e,t,n){for(let r=e;r;r=r.next){let i=lz(r.node);if(i)return i(uz.create(t,n,r))}return 0}function az(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function lz(e){let t=e.type.prop(w1);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(fe.closedBy))){let i=e.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>dz(o,!0,1,void 0,s&&!az(o)?i.from:void 0)}return e.parent==null?cz:null}function cz(){return 0}var uz=class k1 extends Oc{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 k1(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(hz(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return S1(this.context.next,this.base,this.pos)}};function hz(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function fz(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 dz(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?fz(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}function Sv({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var pz=200;function mz(){return ze.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+pz)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=Ep(o,u.from);if(h==null)continue;let f=/^\s*/.exec(u.text)[0],d=Eo(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 gz=new fe;function vz(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 Op=class C1{constructor(t,n){this.specs=t;let r;function i(a){let l=Tr.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 Xt?a=>a.prop(Bi)==o.data:o?a=>a==o:void 0,this.style=ES(t.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=r?new Tr(r):null,this.themeType=n.themeType}static define(t,n){return new C1(t,n||{})}},Xf=Z.define(),T1=Z.define({combine(e){return e.length?[e[0]]:null}});function qu(e){let t=e.facet(Xf);return t.length?t:e.facet(T1)}function yz(e,t){let n=[bz],r;return e instanceof Op&&(e.module&&n.push(oe.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(T1.of(e)):r?n.push(Xf.computeN([oe.darkTheme],i=>i.facet(oe.darkTheme)==(r=="dark")?[e]:[])):n.push(Xf.of(e)),n}var xz=class{constructor(e){this.markCache=Object.create(null),this.tree=Dn(e.state),this.decorations=this.buildDeco(e,qu(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Dn(e.state),n=qu(e.state),r=n!=qu(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 Ee.none;let n=new al;for(let{from:r,to:i}of e.visibleRanges)lB(this.tree,t,(s,o,a)=>{n.add(s,o,this.markCache[a]||(this.markCache[a]=Ee.mark({class:a})))},r,i);return n.finish()}},bz=kc.high(Mr.fromClass(xz,{decorations:e=>e.decorations})),yW=Op.define([{tag:F.meta,color:"#404740"},{tag:F.link,textDecoration:"underline"},{tag:F.heading,textDecoration:"underline",fontWeight:"bold"},{tag:F.emphasis,fontStyle:"italic"},{tag:F.strong,fontWeight:"bold"},{tag:F.strikethrough,textDecoration:"line-through"},{tag:F.keyword,color:"#708"},{tag:[F.atom,F.bool,F.url,F.contentSeparator,F.labelName],color:"#219"},{tag:[F.literal,F.inserted],color:"#164"},{tag:[F.string,F.deleted],color:"#a11"},{tag:[F.regexp,F.escape,F.special(F.string)],color:"#e40"},{tag:F.definition(F.variableName),color:"#00f"},{tag:F.local(F.variableName),color:"#30a"},{tag:[F.typeName,F.namespace],color:"#085"},{tag:F.className,color:"#167"},{tag:[F.special(F.variableName),F.macroName],color:"#256"},{tag:F.definition(F.propertyName),color:"#00c"},{tag:F.comment,color:"#940"},{tag:F.invalid,color:"#f00"}]),wz=oe.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),A1=1e4,R1="()[]{}",M1=Z.define({combine(e){return vp(e,{afterCursor:!0,brackets:R1,maxScanDistance:A1,renderMatch:Cz})}}),Sz=Ee.mark({class:"cm-matchingBracket"}),kz=Ee.mark({class:"cm-nonmatchingBracket"});function Cz(e){let t=[],n=e.matched?Sz:kz;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 kv(e){let t=[],n=e.facet(M1);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 Ee.set(t,!0)}var Tz=[Mr.fromClass(class{constructor(e){this.paused=!1,this.decorations=kv(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=kv(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),wz];function Az(e={}){return[M1.of(e),Tz]}var Rz=new fe;function Yf(e,t,n){let r=e.prop(t<0?fe.openedBy:fe.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 Jf(e){let t=e.type.prop(Rz);return t?t(e.node):e}function Rn(e,t,n,r={}){let i=r.maxScanDistance||A1,s=r.brackets||R1,o=Dn(e),a=o.resolveInner(t,n);for(let l=a;l;l=l.parent){let c=Yf(l.type,n,s);if(c&&l.from<l.to){let u=Jf(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return Mz(e,t,n,l,u,c,s)}}return Pz(e,t,n,o,a.type,i,s)}function Mz(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=Jf(u);return{start:l,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(Yf(u.type,n,o))c++;else if(Yf(u.type,-n,o)){if(c==0){let h=Jf(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 Pz(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 p=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(p+v,1).type!=i))if(x%2==0==n>0)h++;else{if(h==1)return{start:c,end:{from:p+v,to:p+v+1},matched:x>>1==l>>1};h--}}n>0&&(f+=d.length)}return u.done?{start:c,matched:!1}:null}var Ez=Object.create(null),Cv=[Ft.none],Tv=[],Av=Object.create(null),Oz=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"]])Oz[e]=Iz(Ez,t);function Uu(e,t){Tv.indexOf(e)>-1||(Tv.push(e),console.warn(t))}function Iz(e,t){let n=[];for(let a of t.split(" ")){let l=[];for(let c of a.split(".")){let u=e[c]||F[c];u?typeof u=="function"?l.length?l=l.map(u):Uu(c,`Modifier ${c} used at start of tag`):l.length?Uu(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:Uu(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=Av[i];if(s)return s.id;let o=Av[i]=Ft.define({id:Cv.length,name:r,props:[MS({[r]:n})]});return Cv.push(o),o.id}var xW={rtl:Ee.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:Pe.RTL}),ltr:Ee.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:Pe.LTR}),auto:Ee.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})},Dz=ez.define({name:"json",parser:fB.configure({props:[w1.add({Object:Sv({except:/^\s*\}/}),Array:Sv({except:/^\s*\]/})}),gz.add({"Object Array":vz})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function Nz(){return new iz(Dz)}var Lz=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Dp(e.state,n.from);return r.line?jz(e):r.block?Bz(e):!1};function Ip(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 jz=Ip(zz,0),_z=Ip(P1,0),Bz=Ip((e,t)=>P1(e,t,Fz(t)),0);function Dp(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var La=50;function Vz(e,{open:t,close:n},r,i){let s=e.sliceDoc(r-La,r),o=e.sliceDoc(i,i+La),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+La),h=e.sliceDoc(i-La,i));let f=/^\s*/.exec(u)[0].length,d=/\s*$/.exec(h)[0].length,p=h.length-d-n.length;return u.slice(f,f+t.length)==t&&h.slice(p,p+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(p-1))?1:0}}:null}function Fz(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 P1(e,t,n=t.selection.ranges){let r=n.map(s=>Dp(t,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>Vz(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 zz(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=Dp(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,p=h.text.slice(f,f+c.length)==c?f:-1;f<h.text.length&&f<l&&(l=f),r.push({line:h,comment:p,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 Rv=di.define(),$z=Z.define(),Oo=class Ws{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 Ws(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 Ws(t.changes&&rn.fromJSON(t.changes),[],t.mapped&&qi.fromJSON(t.mapped),t.startSelection&&z.fromJSON(t.startSelection),t.selectionsAfter.map(z.fromJSON))}static fromTransaction(t,n){let r=Bt;for(let i of t.startState.facet($z)){let s=i(t);s.length&&(r=r.concat(s))}return!r.length&&t.changes.empty?null:new Ws(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,Bt)}static selection(t){return new Ws(void 0,Bt,void 0,void 0,t)}};function Zf(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 Hz(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 Wz(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function E1(e,t){return e.length?t.length?e.concat(t):e:t}var Bt=[],qz=200;function Uz(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-qz));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),Zf(e,e.length-1,1e9,n.setSelAfter(r)))}else return[Oo.selection([t])]}function Kz(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 Ku(e,t){if(!e.length)return e;let n=e.length,r=Bt;for(;n;){let i=Gz(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?[Oo.selection(r)]:Bt}function Gz(e,t,n){let r=E1(e.selectionsAfter.length?e.selectionsAfter.map(a=>a.map(t)):Bt,n);if(!e.changes)return Oo.selection(r);let i=e.changes.map(t),s=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(s):s;return new Oo(i,We.mapEffects(e.effects,t),o,e.startSelection.map(s),r)}var Qz=/^(input\.type|delete)($|\.)/,Mv=class qs{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 qs(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||Qz.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(s,Hz(a.changes,t.changes))||r=="input.type.compose")?o=Zf(o,o.length-1,i.minDepth,new Oo(t.changes.compose(a.changes),E1(We.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,Bt)):o=Zf(o,o.length,i.minDepth,t),new qs(o,Bt,n,r)}addSelection(t,n,r,i){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Bt;return s.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Wz(s[s.length-1],t)?this:new qs(Uz(this.done,t),this.undone,n,r)}addMapping(t){return new qs(Ku(this.done,t),Ku(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:Rv.of({side:t,rest:Kz(i),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=i.length==1?Bt:i.slice(0,i.length-1);return s.mapped&&(a=Ku(a,s.mapped)),n.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Rv.of({side:t,rest:a,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};Mv.empty=new Mv(Bt,Bt);function ys(e,t){return z.create(e.ranges.map(t),e.mainIndex)}function on(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function an({state:e,dispatch:t},n){let r=ys(e.selection,n);return r.eq(e.selection,!0)?!1:(t(on(e,r)),!0)}function Ic(e,t){return z.cursor(t?e.to:e.from)}function O1(e,t){return an(e,n=>n.empty?e.moveByChar(n,t):Ic(n,t))}function lt(e){return e.textDirectionAt(e.state.selection.main.head)==Pe.LTR}var I1=e=>O1(e,!lt(e)),D1=e=>O1(e,lt(e));function N1(e,t){return an(e,n=>n.empty?e.moveByGroup(n,t):Ic(n,t))}var Xz=e=>N1(e,!lt(e)),Yz=e=>N1(e,lt(e)),bW=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Jz(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 Dc(e,t,n){let r=Dn(e).resolveInner(t.head),i=n?fe.closedBy:fe.openedBy;for(let l=t.head;;){let c=n?r.childAfter(l):r.childBefore(l);if(!c)break;Jz(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 Zz=e=>an(e,t=>Dc(e.state,t,!lt(e))),e$=e=>an(e,t=>Dc(e.state,t,lt(e)));function L1(e,t){return an(e,n=>{if(!n.empty)return Ic(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}var j1=e=>L1(e,!1),_1=e=>L1(e,!0);function B1(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let s of e.state.facet(oe.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 V1(e,t){let n=B1(e),{state:r}=e,i=ys(r.selection,o=>o.empty?e.moveVertically(o,t,n.height):Ic(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=oe.scrollIntoView(i.main.head,{y:"start",yMargin:o.top-l}))}return e.dispatch(on(r,i),{effects:s}),!0}var Pv=e=>V1(e,!1),ed=e=>V1(e,!0);function Dr(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 t$=e=>an(e,t=>Dr(e,t,!0)),n$=e=>an(e,t=>Dr(e,t,!1)),r$=e=>an(e,t=>Dr(e,t,!lt(e))),i$=e=>an(e,t=>Dr(e,t,lt(e))),s$=e=>an(e,t=>e.moveToLineBoundary(t,!1,!1)),o$=e=>an(e,t=>e.moveToLineBoundary(t,!0,!1));function a$(e,t,n){let r=!1,i=ys(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(on(e,i)),!0):!1}var l$=({state:e,dispatch:t})=>a$(e,t,!1);function $t(e,t,n){let r=ys(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(on(e.state,r)),!0)}function F1(e,t){return $t(e,t,n=>e.moveByChar(n,t))}var z1=e=>F1(e,!lt(e)),$1=e=>F1(e,lt(e));function H1(e,t){return $t(e,t,n=>e.moveByGroup(n,t))}var c$=e=>H1(e,!lt(e)),u$=e=>H1(e,lt(e)),h$=e=>{let t=!lt(e);return $t(e,t,n=>Dc(e.state,n,t))},f$=e=>{let t=lt(e);return $t(e,t,n=>Dc(e.state,n,t))};function W1(e,t){return $t(e,t,n=>e.moveVertically(n,t))}var q1=e=>W1(e,!1),U1=e=>W1(e,!0);function K1(e,t){return $t(e,t,n=>e.moveVertically(n,t,B1(e).height))}var Ev=e=>K1(e,!1),Ov=e=>K1(e,!0),d$=e=>$t(e,!0,t=>Dr(e,t,!0)),p$=e=>$t(e,!1,t=>Dr(e,t,!1)),m$=e=>{let t=!lt(e);return $t(e,t,n=>Dr(e,n,t))},g$=e=>{let t=lt(e);return $t(e,t,n=>Dr(e,n,t))},v$=e=>$t(e,!1,t=>z.cursor(e.lineBlockAt(t.head).from)),y$=e=>$t(e,!0,t=>z.cursor(e.lineBlockAt(t.head).to)),Iv=({state:e,dispatch:t})=>(t(on(e,{anchor:0})),!0),Dv=({state:e,dispatch:t})=>(t(on(e,{anchor:e.doc.length})),!0),Nv=({state:e,dispatch:t})=>(t(on(e,{anchor:e.selection.main.anchor,head:0})),!0),Lv=({state:e,dispatch:t})=>(t(on(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),x$=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),b$=({state:e,dispatch:t})=>{let n=Nc(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},w$=({state:e,dispatch:t})=>{let n=ys(e.selection,r=>{let i=Dn(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(on(e,n)),!0)};function G1(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(on(n,z.create(i,i.length-1))),!0)}var S$=e=>G1(e,!1),k$=e=>G1(e,!0),C$=({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(on(e,r)),!0):!1};function Yo(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=ja(e,l,!1)):l>o&&(n="delete.forward",l=ja(e,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=ja(e,o,!1),a=ja(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"?oe.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function ja(e,t,n){if(e instanceof oe)for(let r of e.state.facet(oe.atomicRanges).map(i=>i(e)))r.between(t,t,(i,s)=>{i<t&&s>t&&(t=n?s:i)});return t}var Q1=(e,t,n)=>Yo(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=Cc(a,s.tabSize)%ql(s)||ql(s);for(let u=0;u<c&&a[a.length-1-u]==" ";u++)i--;l=i}else l=at(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=at(o.text,l-o.from,!1,!1)+o.from);return l}),td=e=>Q1(e,!1,!0),X1=e=>Q1(e,!0,!1),Y1=(e,t)=>Yo(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=at(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}),J1=e=>Y1(e,!1),T$=e=>Y1(e,!0),A$=e=>Yo(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),R$=e=>Yo(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),M$=e=>Yo(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),P$=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:ge.of(["",""])},range:z.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},E$=({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:at(s.text,i-s.from,!1)+s.from,a=i==s.to?i+1:at(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 Nc(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 Z1(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let s of Nc(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 O$=({state:e,dispatch:t})=>Z1(e,t,!1),I$=({state:e,dispatch:t})=>Z1(e,t,!0);function eC(e,t,n){if(e.readOnly)return!1;let r=[];for(let s of Nc(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 D$=({state:e,dispatch:t})=>eC(e,t,!1),N$=({state:e,dispatch:t})=>eC(e,t,!0),L$=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Nc(t).map(({from:i,to:s})=>(i>0?i--:s<t.doc.length&&s++,{from:i,to:s}))),r=ys(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 j$(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Dn(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(fe.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 jv=tC(!1),_$=tC(!0);function tC(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&&j$(t,s);e&&(s=o=(o<=a.to?a:t.doc.lineAt(o)).to);let c=new Oc(t,{simulateBreak:s,simulateDoubleBreak:!!l}),u=Ep(c,s);for(u==null&&(u=Cc(/^\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=["",Eo(t,u)];return l&&h.push(Eo(t,c.lineIndent(a.from,-1))),{changes:{from:s,to:o,insert:ge.of(h)},range:z.cursor(s+1+h[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Np(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 B$=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Oc(e,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=Np(e,(s,o,a)=>{let l=Ep(r,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let c=/^\s*/.exec(s.text)[0],u=Eo(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},nC=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Np(e,(n,r)=>{r.push({from:n.from,insert:e.facet(Pp)})}),{userEvent:"input.indent"})),!0),rC=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Np(e,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=Cc(i,e.tabSize),o=0,a=Eo(e,Math.max(0,s-ql(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),V$=e=>(e.setTabFocusMode(),!0),F$=[{key:"Ctrl-b",run:I1,shift:z1,preventDefault:!0},{key:"Ctrl-f",run:D1,shift:$1},{key:"Ctrl-p",run:j1,shift:q1},{key:"Ctrl-n",run:_1,shift:U1},{key:"Ctrl-a",run:s$,shift:v$},{key:"Ctrl-e",run:o$,shift:y$},{key:"Ctrl-d",run:X1},{key:"Ctrl-h",run:td},{key:"Ctrl-k",run:A$},{key:"Ctrl-Alt-h",run:J1},{key:"Ctrl-o",run:P$},{key:"Ctrl-t",run:E$},{key:"Ctrl-v",run:ed}],z$=[{key:"ArrowLeft",run:I1,shift:z1,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Xz,shift:c$,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:r$,shift:m$,preventDefault:!0},{key:"ArrowRight",run:D1,shift:$1,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Yz,shift:u$,preventDefault:!0},{mac:"Cmd-ArrowRight",run:i$,shift:g$,preventDefault:!0},{key:"ArrowUp",run:j1,shift:q1,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Iv,shift:Nv},{mac:"Ctrl-ArrowUp",run:Pv,shift:Ev},{key:"ArrowDown",run:_1,shift:U1,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Dv,shift:Lv},{mac:"Ctrl-ArrowDown",run:ed,shift:Ov},{key:"PageUp",run:Pv,shift:Ev},{key:"PageDown",run:ed,shift:Ov},{key:"Home",run:n$,shift:p$,preventDefault:!0},{key:"Mod-Home",run:Iv,shift:Nv},{key:"End",run:t$,shift:d$,preventDefault:!0},{key:"Mod-End",run:Dv,shift:Lv},{key:"Enter",run:jv,shift:jv},{key:"Mod-a",run:x$},{key:"Backspace",run:td,shift:td,preventDefault:!0},{key:"Delete",run:X1,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:J1,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:T$,preventDefault:!0},{mac:"Mod-Backspace",run:R$,preventDefault:!0},{mac:"Mod-Delete",run:M$,preventDefault:!0}].concat(F$.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),$$=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Zz,shift:h$},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e$,shift:f$},{key:"Alt-ArrowUp",run:O$},{key:"Shift-Alt-ArrowUp",run:D$},{key:"Alt-ArrowDown",run:I$},{key:"Shift-Alt-ArrowDown",run:N$},{key:"Mod-Alt-ArrowUp",run:S$},{key:"Mod-Alt-ArrowDown",run:k$},{key:"Escape",run:C$},{key:"Mod-Enter",run:_$},{key:"Alt-l",mac:"Ctrl-l",run:b$},{key:"Mod-i",run:w$,preventDefault:!0},{key:"Mod-[",run:rC},{key:"Mod-]",run:nC},{key:"Mod-Alt-\\",run:B$},{key:"Shift-Mod-k",run:L$},{key:"Shift-Mod-\\",run:l$},{key:"Mod-/",run:Lz},{key:"Alt-A",mac:"Ctrl-A",run:_z},{key:"Ctrl-m",mac:"Shift-Alt-m",run:V$}].concat(z$),H$={key:"Tab",run:nC,shift:rC},W$=oe.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)"}}),q$=Op.define([{tag:F.propertyName,color:"var(--json-key)"},{tag:F.string,color:"var(--json-string)"},{tag:F.number,color:"var(--json-number)"},{tag:F.bool,color:"var(--json-boolean)"},{tag:F.null,color:"var(--json-null)"},{tag:F.punctuation,color:"var(--json-punctuation)"},{tag:F.invalid,color:"var(--destructive)"}]);function _v(e){const t=e.state.selection.main.head,n=e.state.doc.lineAt(t);return{line:n.number,column:t-n.from+1}}function Bv(e,t){return typeof e=="number"?`${e}px`:e??t}function U$({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,m.useRef)(null),d=(0,m.useRef)(null),p=(0,m.useRef)(e),v=(0,m.useRef)({onChange:t,onCursorChange:n,onUndo:r,onRedo:i,onEscape:s});p.current=e,v.current={onChange:t,onCursorChange:n,onUndo:r,onRedo:i,onEscape:s};const y=(0,m.useMemo)(()=>{const x=[W$,yz(q$),Nz(),IF(),mz(),Az(),_F(),oe.updateListener.of(b=>{b.docChanged&&v.current.onChange?.(b.state.doc.toString()),(b.docChanged||b.selectionSet||b.focusChanged)&&v.current.onCursorChange?.(_v(b.view))}),p1.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)},H$,...$$])];return c&&x.push(GF(),YF()),u&&x.push(oe.lineWrapping),x},[c,u]);return(0,m.useEffect)(()=>{if(!f.current)return;const x=new oe({state:ze.create({doc:p.current,extensions:y}),parent:f.current});return d.current=x,v.current.onCursorChange?.(_v(x)),()=>{x.destroy(),d.current=null}},[y]),(0,m.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,g.jsx)("div",{className:X("h-full w-full overflow-hidden bg-muted/30",!o&&"border-destructive",h),style:{height:Bv(a,"100%"),maxHeight:Bv(l,"none")},children:(0,g.jsx)("div",{ref:f,className:"h-full w-full"})})}function K$({options:e,value:t,onChange:n,className:r,size:i="sm",disabled:s=!1}){const o=(0,m.useRef)(null),[a,l]=(0,m.useState)({});return(0,m.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,g.jsxs)("div",{ref:o,className:X("relative inline-flex items-center rounded-md bg-muted/50",i==="default"?"p-1":"p-0.5",s&&"opacity-50",r),children:[(0,g.jsx)("div",{className:X("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,g.jsxs)("button",{type:"button",disabled:s,title:c.title,"aria-pressed":t===c.value,onClick:()=>n(c.value),className:X("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&&"cursor-not-allowed"),children:[c.icon,c.label]},c.value))]})}var G$=[{value:"view",label:"View",icon:(0,g.jsx)(cI,{className:"h-3 w-3"})},{value:"edit",label:"Edit",icon:(0,g.jsx)(MI,{className:"h-3 w-3"})}];function Q$({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:p,leftContent:v,rightContent:y,error:x}){const[b,w]=(0,m.useState)(!1),S=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);const C=async()=>{let T;try{T=await s?.()}catch{return}T!==!1&&(S.current&&clearTimeout(S.current),w(!0),S.current=setTimeout(()=>w(!1),2e3))};return(0,g.jsxs)("div",{className:X("flex items-center justify-between border-b border-border/50 px-3 py-1.5 bg-muted/50",p),children:[(0,g.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[v,n&&!r&&t&&(0,g.jsx)(K$,{options:G$,value:e,onChange:t})]}),x?(0,g.jsxs)(zr,{children:[(0,g.jsx)($r,{asChild:!0,children:(0,g.jsxs)("div",{className:"mx-3 flex min-w-0 flex-1 cursor-default items-center gap-1.5 text-xs text-destructive",children:[(0,g.jsx)(gc,{className:"h-3 w-3 shrink-0"}),(0,g.jsx)("span",{className:"truncate",children:x})]})}),(0,g.jsx)(Hr,{side:"bottom",className:"max-w-[min(40rem,calc(100vw-2rem))] break-words",children:(0,g.jsx)("p",{children:x})})]}):null,(0,g.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[e==="edit"&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(zr,{children:[(0,g.jsx)($r,{asChild:!0,children:(0,g.jsx)(Nt,{size:"sm",variant:"ghost",onClick:o,disabled:!l,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:(0,g.jsx)(_I,{className:"h-3.5 w-3.5"})})}),(0,g.jsx)(Hr,{side:"bottom",children:(0,g.jsx)("p",{children:"Undo (Ctrl+Z)"})})]}),(0,g.jsxs)(zr,{children:[(0,g.jsx)($r,{asChild:!0,children:(0,g.jsx)(Nt,{size:"sm",variant:"ghost",onClick:a,disabled:!c,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:(0,g.jsx)(II,{className:"h-3.5 w-3.5"})})}),(0,g.jsx)(Hr,{side:"bottom",children:(0,g.jsx)("p",{children:"Redo (Ctrl+Shift+Z)"})})]}),(0,g.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),(0,g.jsxs)(zr,{children:[(0,g.jsx)($r,{asChild:!0,children:(0,g.jsx)(Nt,{size:"sm",variant:"ghost",onClick:i,disabled:!d,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:(0,g.jsx)(GO,{className:"h-3.5 w-3.5"})})}),(0,g.jsx)(Hr,{side:"bottom",children:(0,g.jsx)("p",{children:"Format JSON"})})]})]}),(0,g.jsxs)(zr,{children:[(0,g.jsx)($r,{asChild:!0,children:(0,g.jsx)(Nt,{size:"sm",variant:"ghost",onClick:C,className:X("h-7 w-7 p-0 transition-all duration-200 hover:scale-105",b&&"bg-success/10"),children:b?(0,g.jsx)(Ji,{className:"h-3.5 w-3.5 text-success"}):(0,g.jsx)($i,{className:"h-3.5 w-3.5"})})}),(0,g.jsx)(Hr,{side:"bottom",children:(0,g.jsx)("p",{children:b?"Copied!":"Copy to clipboard"})})]}),f&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),(0,g.jsxs)(zr,{children:[(0,g.jsx)($r,{asChild:!0,children:(0,g.jsx)(Nt,{size:"sm",variant:"ghost",onClick:h,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:u?(0,g.jsx)(SI,{className:"h-3.5 w-3.5"}):(0,g.jsx)(yI,{className:"h-3.5 w-3.5"})})}),(0,g.jsx)(Hr,{side:"bottom",children:(0,g.jsx)("p",{children:u?"Exit fullscreen":"Fullscreen"})})]})]}),y&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),y]})]})]})}function X$({cursorPosition:e,characterCount:t,validationError:n,className:r}){return(0,g.jsxs)("div",{className:X("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,g.jsxs)("div",{className:"flex items-center gap-3",children:[(0,g.jsxs)("span",{className:"transition-colors duration-200",children:["Ln ",e.line,", Col ",e.column]}),(0,g.jsxs)("span",{className:"transition-colors duration-200",children:[t.toLocaleString()," chars"]})]}),n?(0,g.jsxs)(zr,{children:[(0,g.jsx)($r,{asChild:!0,children:(0,g.jsxs)("div",{className:"flex min-w-0 cursor-default items-center gap-1.5 text-destructive",children:[(0,g.jsx)(gc,{className:"h-3 w-3 shrink-0"}),(0,g.jsx)("span",{className:"truncate",children:n})]})}),(0,g.jsx)(Hr,{side:"top",className:"max-w-[min(40rem,calc(100vw-2rem))] break-words",children:(0,g.jsx)("p",{children:n})})]}):null]})}function Y$(e){if(e===void 0)return"null";try{return JSON.stringify(e,null,2)??"null"}catch{return"null"}}function Vv(){return(0,g.jsxs)("div",{className:"flex items-center justify-center p-4 text-sm text-muted-foreground",children:[(0,g.jsx)(gc,{className:"h-4 w-4 mr-2 text-destructive"}),"Failed to render JSON content"]})}function J$({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:p=!1,defaultExpandDepth:v,collapsedPaths:y,onCollapseChange:x,collapseStringsAfterLength:b,viewOnly:w=!1,expandJsonStrings:S=!1,autoFormatOnEdit:C=!0,wrapLongLinesInEdit:T=!1,editSurface:k="codemirror",wrapLongLinesInView:A=!0,showLineNumbers:E=!0,toolbarLeftContent:R,toolbarRightContent:O,error:M,showValidationErrorInStatusBar:j=!0}){const N=n!==void 0,[P,L]=(0,m.useState)("view"),B=o?"view":i??P,[H,V]=(0,m.useState)(!1),I=Jj({initialValue:N?void 0:e,initialContent:N?n:void 0,onChange:t,onRawChange:N?r:void 0,onValidationError:d,expandJsonStrings:S}),ne=N?n??"":I.sourceContent,re=I.content!==ne,_=(0,m.useRef)(B),U=(0,m.useRef)(!1),K=(0,m.useMemo)(()=>N?I.getParsedValue():S?Hi(e):e,[I.content,S,N,e]);(0,m.useEffect)(()=>{const se=_.current,Ye=!U.current;U.current=!0,_.current=B,!(w||o||!C)&&(!(B==="edit"&&(Ye||se!=="edit"))||!I.isValid||I.format())},[B,I.format,I.isValid,C,o,w]);const G=(0,m.useCallback)(se=>{if(!o){if(B==="edit"&&se==="view"&&re&&!I.isValid){if(!window.confirm("The JSON is invalid. Switching to view mode will lose your changes. Continue?"))return;I.reset()}L(se),s?.(se)}},[B,re,I,s,o]),$=(0,m.useCallback)(async()=>{let se;return B==="edit"?se=I.content:N?se=n??"":se=Y$(e),vc(se)},[B,I.content,e,N,n]),J=(0,m.useCallback)(()=>{re&&!window.confirm("You have unsaved changes. Discard them?")||(I.reset(),L("view"),s?.("view"))},[re,I,s]),ae=(0,m.useCallback)(()=>{V(se=>!se)},[]);if(w)return(0,g.jsx)(Bm,{fallback:(0,g.jsx)(Vv,{}),children:(0,g.jsx)(h0,{value:K,className:f,height:u??"100%",maxHeight:h,collapsible:p,defaultExpandDepth:v,collapsedPaths:y,onCollapseChange:x,showLineNumbers:E,collapseStringsAfterLength:b,wrapLongLinesInView:A})});const he=H?{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:50}:{height:u??"100%",maxHeight:h??"none"};return(0,g.jsx)(Bm,{fallback:(0,g.jsx)(Vv,{}),children:(0,g.jsxs)("div",{className:X("flex flex-col rounded-lg bg-background overflow-hidden",H&&"rounded-none",f),style:he,children:[l&&(0,g.jsx)(Q$,{mode:B,onModeChange:G,showModeToggle:a&&!o,readOnly:o,onFormat:I.format,onCopy:$,onUndo:I.undo,onRedo:I.redo,canUndo:I.canUndo,canRedo:I.canRedo,isMaximized:H,onToggleMaximize:ae,allowMaximize:c,isValid:I.isValid,leftContent:R,rightContent:O,error:M}),(0,g.jsx)("div",{className:"flex-1 min-h-0 h-full",children:B==="view"?(0,g.jsx)(h0,{value:K,height:u??"100%",collapsible:p,defaultExpandDepth:v,collapsedPaths:y,onCollapseChange:x,showLineNumbers:E,collapseStringsAfterLength:b,wrapLongLinesInView:A}):k==="codemirror"?(0,g.jsx)(U$,{content:I.content,onChange:I.setContent,onCursorChange:I.setCursorPosition,onUndo:I.undo,onRedo:I.redo,onEscape:J,isValid:I.isValid,height:u??"100%",maxHeight:H?void 0:h,showLineNumbers:E,wrapLongLines:T}):(0,g.jsx)(pS,{content:I.content,onChange:I.setContent,onCursorChange:I.setCursorPosition,onUndo:I.undo,onRedo:I.redo,onEscape:J,isValid:I.isValid,height:u??"100%",maxHeight:H?void 0:h,showLineNumbers:E,wrapLongLinesInEdit:T,wrapLongLinesInView:A})}),B==="edit"&&(0,g.jsx)(X$,{cursorPosition:I.cursorPosition,characterCount:I.content.length,validationError:j?I.validationError:null})]})})}function Z$({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,g.jsx)("div",{className:X("overflow-auto",u),children:(0,g.jsx)(J$,{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})})}function Lp(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var pi=Lp();function iC(e){pi=e}var Ur={exec:()=>null};function ki(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function le(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(tt.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,t)};return r}var e3=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),tt={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:ki(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:ki(e=>new RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:ki(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:ki(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:ki(e=>new RegExp(`^ {0,${e}}(?:</?(?:${Zo})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`,"i")),blockquoteBeginRegex:ki(e=>new RegExp(`^ {0,${e}}>`))},t3=/^(?:[ \t]*(?:\n|$))+/,n3=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,r3=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Jo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,i3=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,jp=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,sC=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,oC=le(sC).replace(/bull/g,jp).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),s3=le(sC).replace(/bull/g,jp).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),_p=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,o3=/^[^\n]+/,Bp=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,a3=le(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Bp).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),l3=le(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,jp).getRegex(),Zo="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Vp=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,c3=le("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Vp).replace("tag",Zo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),aC=e=>le(_p).replace("hr",Jo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Zo).getRegex(),u3=aC(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),h3=aC(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Fp={blockquote:le(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",h3).getRegex(),code:n3,def:a3,fences:r3,heading:i3,hr:Jo,html:c3,lheading:oC,list:l3,newline:t3,paragraph:u3,table:Ur,text:o3},Fv=le("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Jo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Zo).getRegex(),f3={...Fp,lheading:s3,table:Fv,paragraph:le(_p).replace("hr",Jo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Fv).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Zo).getRegex()},d3={...Fp,html:le(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Vp).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ur,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:le(_p).replace("hr",Jo).replace("heading",` *#{1,6} *[^
62
+ ]`).replace("lheading",oC).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},p3=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,m3=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,lC=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,g3=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,or=/[\p{P}\p{S}]/u,xs=/[\s\p{P}\p{S}]/u,ea=/[^\s\p{P}\p{S}]/u,v3=le(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,xs).getRegex(),y3=/[\p{Pi}\p{Ps}"']/u,cC=/(?!~)[\p{P}\p{S}]/u,x3=/(?!~)[\s\p{P}\p{S}]/u,b3=/(?:[^\s\p{P}\p{S}]|~)/u,w3=le(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",e3?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),uC=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,S3=le(uC,"u").replace(/punct/g,or).getRegex(),k3=le(uC,"u").replace(/punct/g,cC).getRegex(),C3=le(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,"u").replace(/openQuote/g,y3).replace(/punct/g,or).getRegex(),hC="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",T3=le(hC,"gu").replace(/notPunctSpace/g,ea).replace(/punctSpace/g,xs).replace(/punct/g,or).getRegex(),A3=le(hC,"gu").replace(/notPunctSpace/g,b3).replace(/punctSpace/g,x3).replace(/punct/g,cC).getRegex(),R3=le("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,ea).replace(/punctSpace/g,xs).replace(/punct/g,or).getRegex(),M3=le("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ea).replace(/punctSpace/g,xs).replace(/punct/g,or).getRegex(),P3=le("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,ea).replace(/punctSpace/g,xs).replace(/punct/g,or).getRegex(),E3=le(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,or).getRegex(),O3=le("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,ea).replace(/punctSpace/g,xs).replace(/punct/g,or).getRegex(),I3=le(/\\(punct)/,"gu").replace(/punct/g,or).getRegex(),D3=le(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),N3=le(Vp).replace("(?:-->|$)","-->").getRegex(),L3=le("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",N3).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),fC=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,Ul=le(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets",fC).getRegex(),j3=le(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Ul).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),_3=le(/^!?\[(label)\]\[(ref)\]/).replace("label",Ul).replace("ref",Bp).getRegex(),B3=le(/^!?\[(ref)\](?:\[\])?/).replace("ref",Bp).getRegex(),zv=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,V3=le(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets",fC).getRegex(),F3=le("reflink|nolink(?!\\()","g").replace("reflink",le(/^!?\[(label)\]\[(ref)\]/).replace("label",V3).replace("ref",zv).getRegex()).replace("nolink",le(/^!?\[(ref)\](?:\[\])?/).replace("ref",zv).getRegex()).getRegex(),$v=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,z3=le(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),zp={_backpedal:Ur,anyPunctuation:I3,autolink:D3,blockSkip:w3,br:lC,code:m3,del:Ur,delLDelim:Ur,delRDelim:Ur,emStrongLDelim:S3,emStrongRDelimAst:T3,emStrongRDelimUnd:M3,escape:p3,link:j3,nolink:B3,punctuation:v3,reflink:_3,reflinkSearch:F3,tag:L3,text:g3,url:Ur},$3={...zp,emStrongLDelim:C3,emStrongRDelimAst:R3,emStrongRDelimUnd:P3,link:le(/^!?\[(label)\]\((.*?)\)/).replace("label",Ul).getRegex(),reflink:le(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ul).getRegex()},nd={...zp,emStrongRDelimAst:A3,emStrongLDelim:k3,delLDelim:E3,delRDelim:O3,url:le(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol",z3).replace("protocol",$v).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:le(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol",$v).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},H3={...nd,br:le(lC).replace("{2,}","*").getRegex(),text:le(nd.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},_a={normal:Fp,gfm:f3,pedantic:d3},Ds={normal:zp,gfm:nd,breaks:H3,pedantic:$3},W3={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Hv=e=>W3[e];function Et(e,t){if(t){if(tt.escapeTest.test(e))return e.replace(tt.escapeReplace,Hv)}else if(tt.escapeTestNoEncode.test(e))return e.replace(tt.escapeReplaceNoEncode,Hv);return e}function q3(e){return e.replace(tt.numericCharacterReference,(t,n,r)=>{let i=n===void 0?Number.parseInt(r,16):Number.parseInt(n,10);return i===0||i>1114111||i>=55296&&i<=57343?"�":String.fromCodePoint(i)})}function Wv(e){try{e=encodeURI(e).replace(tt.percentDecode,"%")}catch{return null}return e}function qv(e,t){let n=e.replace(tt.findPipe,(i,s,o)=>{let a=!1,l=s;for(;--l>=0&&o[l]==="\\";)a=!a;return a?"|":" |"}).split(tt.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(tt.slashPipe,"|");return n}function ar(e,t,n){let r=e.length;if(r===0)return"";let i=0;for(;i<r;){let s=e.charAt(r-i-1);if(s===t&&!n)i++;else if(s!==t&&n)i++;else break}return e.slice(0,r-i)}function Uv(e){let t=e.split(`
63
+ `),n=t.length-1;for(;n>=0&&tt.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
64
+ `)}function Kl(e){return e.trim().toLowerCase().toUpperCase().toLowerCase()}function U3(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Kv(e,t=0){let n=t,r="";for(let i of e)if(i===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=i,n++;return r}function Gv(e,t,n,r,i){let s=t.href,o=t.title||null,a=e[1].replace(i.other.outputLinkReplace,"$1"),l=e[0].charAt(0)==="!";r.state.inLink=!0;let c=r.state.linkEmitted,u=r.state.inRawBlock;r.state.linkEmitted=!1;let h=r.inlineTokens(a),f=r.state.linkEmitted;if(r.state.linkEmitted=c,r.state.inLink=!1,!l){if(f){r.state.inRawBlock=u;return}r.state.linkEmitted=!0}return{type:l?"image":"link",raw:n,href:s,title:o,text:a,tokens:h}}function K3(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
65
+ `).map(s=>{let o=s.match(n.other.beginningSpace);if(o===null)return s;let[a]=o;return s.slice(Math.min(a.length,i.length))}).join(`
66
+ `)}function Qv(e,t,n,r){if(!t.includes("<"))return!1;for(let i=0;i<t.length;i++){if(t[i]==="\\"){i++;continue}if(t[i]==="`"){let a=r.inline.code.exec(t.slice(i));if(a){i+=a[0].length-1;continue}}if(t[i]!=="<")continue;let s=e.slice(n+i),o=r.inline.tag.exec(s)||r.inline.autolink.exec(s);if(o){if(o[0].length>t.length-i)return!0;i+=o[0].length-1}}return!1}var Gl=class{options;rules;lexer;constructor(e){this.options=e||pi}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:Uv(t[0]);return{type:"code",raw:n,codeBlockStyle:"indented",text:n.replace(this.rules.other.codeRemoveIndent,"")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=K3(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=ar(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceTabChar.test(r))&&(n=r.trim())}return{type:"heading",raw:ar(t[0],`
67
+ `),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ar(t[0],`
68
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=ar(t[0],`
69
+ `).split(`
70
+ `),r="",i="",s=[];for(;n.length>0;){let o=!1,a=[],l=0;for(;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=!0;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
71
+ `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
72
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
73
+ ${c}`:c,i=i?`${i}
74
+ ${u}`:u;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,s,!0),this.lexer.state.top=h,n.length===0)break;let f=s.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let d=f,p=n.join(`
75
+ `),v=d.raw+`
76
+ `+p.replace(this.rules.other.blockquoteSetextReplace2,""),y=this.blockquote(v);s[s.length-1]=y;let x=v.substring(y.raw.length).replace(/^\n/,""),b=x?x.split(`
77
+ `).length:0,w=b?n.slice(0,-b):n;w.length>0&&(r=`${r}
78
+ ${w.join(`
79
+ `)}`),i=i.substring(0,i.length-d.text.length)+y.text;break}else if(f?.type==="list"){let d=f,p=d.raw+`
80
+ `+n.join(`
81
+ `),v=this.list(p);s[s.length-1]=v,r=r.substring(0,r.length-f.raw.length)+v.raw,i=i.substring(0,i.length-d.raw.length)+v.raw,n=p.substring(s.at(-1).raw.length).split(`
82
+ `);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),o=!1;for(;e;){let l=!1,c="",u="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let h=t[2].split(`
83
+ `,1)[0],f=t[1].length,d=this.options.pedantic?Kv(h,f):h.replace(this.rules.other.leadingSpaceTab,x=>Kv(x,f)),p=e.split(`
84
+ `,1)[0],v=!d.trim(),y=0;if(this.options.pedantic?(y=2,u=d.trimStart()):v?y=f+1:(y=d.search(this.rules.other.nonSpaceChar),y=y>4?1:y,u=d.slice(y),y+=f),v&&this.rules.other.blankLine.test(p)&&(c+=p+`
85
+ `,e=e.substring(p.length+1),l=!0),!l){let x=this.rules.other.nextBulletRegex(y),b=this.rules.other.hrRegex(y),w=this.rules.other.fencesBeginRegex(y),S=this.rules.other.headingBeginRegex(y),C=this.rules.other.htmlBeginRegex(y),T=this.rules.other.blockquoteBeginRegex(y);for(;e;){let k=e.split(`
86
+ `,1)[0],A;if(p=k,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),A=p):A=p.replace(this.rules.other.leadingSpaceTab,E=>E.replace(this.rules.other.tabCharGlobal," ")),w.test(p)||S.test(p)||C.test(p)||T.test(p)||x.test(p)||b.test(p))break;if(A.search(this.rules.other.nonSpaceChar)>=y||!p.trim())u+=`
87
+ `+A.slice(y);else{if(v||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||w.test(d)||S.test(d)||b.test(d))break;u+=`
88
+ `+p}v=!p.trim(),c+=k+`
89
+ `,e=e.substring(k.length+1),d=A.slice(y)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0)),i.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),i.raw+=c}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.items)if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),!i.loose){let c=l.tokens.filter(u=>u.type==="space");i.loose=c.length>0&&c.some(u=>this.rules.other.anyLine.test(u.raw))}for(let l of i.items){let c=l.tokens[0];if(l.task&&(c?.type==="text"||c?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let h={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};l.checked=h.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}else l.task&&(l.task=!1)}if(i.loose)for(let l of i.items){l.loose=!0;for(let c of l.tokens)c.type==="text"&&(c.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=Uv(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=Kl(t[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:ar(t[0],`
90
+ `),href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=qv(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
91
+ `):[],s={type:"table",raw:ar(t[0],`
92
+ `),header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<n.length;o++)s.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:s.align[o]});for(let o of i)s.rows.push(qv(o,s.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:s.align[l]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:ar(t[0],`
93
+ `),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
94
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&Qv(e,t[1],n,this.rules))return;let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let o=ar(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{let o=U3(t[2],"()");if(o===-2)return;if(o>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(i);o&&(i=o[1],s=o[3])}else s=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i=i.slice(1):i=i.slice(1,-1)),Gv(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=n[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&Qv(e,n[1],r,this.rules))return;let i=t[Kl((n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "))];if(!i){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return Gv(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,s,o,a=i,l=0,c=r[0][0],u=n===c,h=c==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,t=t.slice(-1*e.length+i);(r=h.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if(r[5]||r[6]){if(i%3&&!((i+o)%3)){l+=o;continue}if(u)break}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let f=[...r[0]][0].length,d=e.slice(0,i+r.index+f+o);if(Math.min(i,o)%2){let v=d.slice(1,-1);return{type:"em",raw:d,text:v,tokens:this.lexer.inlineTokens(v)}}let p=d.slice(2,-2);return{type:"strong",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,s,o,a=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,t=t.slice(-1*e.length+i);(r=l.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let c=[...r[0]][0].length,u=e.slice(0,i+r.index+c+o),h=u.slice(i,-i);return{type:"del",raw:u,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,autolink:!0,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:n,href:r,autolink:!0,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:n?t[0]:q3(t[0]),escaped:n}}}},Kt=class rd{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||pi,this.options.tokenizer=this.options.tokenizer||new Gl,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let n={other:tt,block:_a.normal,inline:Ds.normal};this.options.pedantic?(n.block=_a.pedantic,n.inline=Ds.pedantic):this.options.gfm&&(n.block=_a.gfm,this.options.breaks?n.inline=Ds.breaks:n.inline=Ds.gfm),this.tokenizer.rules=n}static get rules(){return{block:_a,inline:Ds}}static lex(t,n){return new rd(n).lex(t)}static lexInline(t,n){return new rd(n).inlineTokens(t)}lex(t){t=t.replace(tt.carriageReturn,`
95
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(tt.tabCharGlobal," ").replace(tt.spaceLine,""));let i=1/0;for(;t;){if(t.length<i)i=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let s;if(this.options.extensions?.block?.some(a=>(s=a.call({lexer:this},t,n))?(t=t.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.space(t)){t=t.substring(s.raw.length);let a=n.at(-1);s.raw.length===1&&a!==void 0?a.raw+=`
96
+ `:n.push(s);continue}if(s=this.tokenizer.code(t)){t=t.substring(s.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
97
+ `)?"":`
98
+ `)+s.raw,a.text+=`
99
+ `+s.text,this.inlineQueue.at(-1).src=a.text):n.push(s);continue}if(s=this.tokenizer.fences(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.heading(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.hr(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.blockquote(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.list(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.html(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.def(t)){t=t.substring(s.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
100
+ `)?"":`
101
+ `)+s.raw,a.text+=`
102
+ `+s.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},n.push(s));continue}if(s=this.tokenizer.table(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.lheading(t)){t=t.substring(s.raw.length),n.push(s);continue}let o=t;if(this.options.extensions?.startBlock){let a=1/0,l=t.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},l),typeof c=="number"&&c>=0&&(a=Math.min(a,c))}),a<1/0&&a>=0&&(o=t.substring(0,a+1))}if(this.state.top&&(s=this.tokenizer.paragraph(o))){let a=n.at(-1);r&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
103
+ `)?"":`
104
+ `)+s.raw,a.text+=`
105
+ `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(s),r=o.length!==t.length,t=t.substring(s.raw.length);continue}if(s=this.tokenizer.text(t)){t=t.substring(s.raw.length);let a=n.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
106
+ `)?"":`
107
+ `)+s.raw,a.text+=`
108
+ `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(s);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}linkInText(t){if(!t.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let r of t.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(r[0])&&t.charAt(r.index-1)!=="!")return!0;for(let r of t.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let i=r[0],s=i.lastIndexOf("[");if(!(i.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,Kl(i.slice(s+1,-1))))&&!(s>1&&this.linkInText(i.slice(1,s-1))))return!0}return!1}inlineTokens(t,n=[]){this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let a=this.tokenizer.rules.inline.reflinkSearch,l=c=>{let u=c.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,Kl(c.slice(u+1,-1))))return c;if(u>1&&c.charAt(0)!=="!"){let h=c.slice(1,u-1);if(this.linkInText(h))return"["+h.replace(a,l)+"]["+"a".repeat(c.length-u-2)+"]"}return"["+"a".repeat(c.length-2)+"]"};r=r.replace(a,l)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,a=>"+".repeat(a.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(a,l,c)=>{let u=c?c.length:0;return a.slice(0,u)+"["+"a".repeat(a.length-u-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,s="",o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}i||(s=""),i=!1;let a;if(this.options.extensions?.inline?.some(c=>(a=c.call({lexer:this},t,n))?(t=t.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.escape(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.tag(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.link(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(a.raw.length);let c=n.at(-1);a.type==="text"&&c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(a=this.tokenizer.emStrong(t,r,s)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.codespan(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.br(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.del(t,r,s)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.autolink(t)){t=t.substring(a.raw.length),n.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(t))){t=t.substring(a.raw.length),n.push(a);continue}let l=t;if(this.options.extensions?.startInline){let c=1/0,u=t.slice(1),h;this.options.extensions.startInline.forEach(f=>{h=f.call({lexer:this},u),typeof h=="number"&&h>=0&&(c=Math.min(c,h))}),c<1/0&&c>=0&&(l=t.substring(0,c+1))}if(a=this.tokenizer.inlineText(l)){t=t.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(s=a.raw.slice(-1)),i=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},Ql=class{options;parser;constructor(e){this.options=e||pi}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(tt.notSpaceStart)?.[0],i=e?e.replace(tt.endingNewline,"")+`
109
+ `:"";return r?'<pre><code class="language-'+Et(r)+'">'+(n?i:Et(i,!0))+`</code></pre>
110
+ `:"<pre><code>"+(n?i:Et(i,!0))+`</code></pre>
111
+ `}blockquote({tokens:e}){return`<blockquote>
112
+ ${this.parser.parse(e)}</blockquote>
113
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
114
+ `}hr(e){return`<hr>
115
+ `}list(e){let t=e.ordered,n=e.start,r="";for(let o=0;o<e.items.length;o++){let a=e.items[o];r+=this.listitem(a)}let i=t?"ol":"ul",s=t&&n!==1?' start="'+n+'"':"";return"<"+i+s+`>
116
+ `+r+"</"+i+`>
117
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
118
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
119
+ `}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let s=e.rows[i];n="";for(let o=0;o<s.length;o++)n+=this.tablecell(s[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
120
+ <thead>
121
+ `+t+`</thead>
122
+ `+r+`</table>
123
+ `}tablerow({text:e}){return`<tr>
124
+ ${e}</tr>
125
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
126
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Et(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let s=i?Et(n,!0):this.parser.parseInline(r),o=Wv(e);if(o===null)return s;e=Et(o,i);let a='<a href="'+e+'"';return t&&(a+=' title="'+Et(t)+'"'),a+=">"+s+"</a>",a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Wv(e);if(i===null)return Et(n);e=i;let s=`<img src="${Et(e)}" alt="${Et(n)}"`;return t&&(s+=` title="${Et(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Et(e.text)}},$p=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Gt=class id{options;renderer;textRenderer;constructor(t){this.options=t||pi,this.options.renderer=this.options.renderer||new Ql,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new $p}static parse(t,n){return new id(n).parse(t)}static parseInline(t,n){return new id(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let r=0;r<t.length;r++){let i=t[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(o.type)){n+=a||"";continue}}let s=i;switch(s.type){case"space":n+=this.renderer.space(s);break;case"hr":n+=this.renderer.hr(s);break;case"heading":n+=this.renderer.heading(s);break;case"code":n+=this.renderer.code(s);break;case"table":n+=this.renderer.table(s);break;case"blockquote":n+=this.renderer.blockquote(s);break;case"list":n+=this.renderer.list(s);break;case"checkbox":n+=this.renderer.checkbox(s);break;case"html":n+=this.renderer.html(s);break;case"def":n+=this.renderer.def(s);break;case"paragraph":n+=this.renderer.paragraph(s);break;case"text":n+=this.renderer.text(s);break;default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<t.length;i++){let s=t[i];if(this.options.extensions?.renderers?.[s.type]){let a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(s.type)){r+=a||"";continue}}let o=s;switch(o.type){case"escape":r+=n.text(o);break;case"html":r+=n.html(o);break;case"link":r+=n.link(o);break;case"image":r+=n.image(o);break;case"checkbox":r+=n.checkbox(o);break;case"strong":r+=n.strong(o);break;case"em":r+=n.em(o);break;case"codespan":r+=n.codespan(o);break;case"br":r+=n.br(o);break;case"del":r+=n.del(o);break;case"text":r+=n.text(o);break;default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},Us=class{options;block;constructor(e){this.options=e||pi}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Kt.lex:Kt.lexInline}provideParser(e=this.block){return e?Gt.parse:Gt.parseInline}},G3=class{defaults=Lp();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Gt;Renderer=Ql;TextRenderer=$p;Lexer=Kt;Tokenizer=Gl;Hooks=Us;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of i.rows)for(let o of s)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let o=i[s].flat(1/0);n=n.concat(this.walkTokens(o,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new Ql(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=n.renderer[o],l=i[o];i[o]=(...c)=>{let u=a.apply(i,c);return u===!1&&(u=l.apply(i,c)),u||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new Gl(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=n.tokenizer[o],l=i[o];i[o]=(...c)=>{let u=a.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Us;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=n.hooks[o],l=i[o];Us.passThroughHooks.has(s)?i[o]=c=>{if(this.defaults.async&&Us.passThroughHooksRespectAsync.has(s))return(async()=>{let h=await a.call(i,c);return l.call(i,h)})();let u=a.call(i,c);return l.call(i,u)}:i[o]=(...c)=>{if(this.defaults.async)return(async()=>{let h=await a.apply(i,c);return h===!1&&(h=await l.apply(i,c)),h})();let u=a.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Kt.lex(e,t??this.defaults)}parser(e,t){return Gt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,a=await(i.hooks?await i.hooks.provideLexer(e):e?Kt.lex:Kt.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let c=await(i.hooks?await i.hooks.provideParser(e):e?Gt.parse:Gt.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(c):c})().catch(s);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer(e):e?Kt.lex:Kt.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser(e):e?Gt.parse:Gt.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(e,t){return n=>{if(n.message+=`
127
+ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+Et(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},ci=new G3;function xe(e,t){return ci.parse(e,t)}xe.options=xe.setOptions=function(e){return ci.setOptions(e),xe.defaults=ci.defaults,iC(xe.defaults),xe};xe.getDefaults=Lp;xe.defaults=pi;function Q3(...e){return ci.use(...e),xe.defaults=ci.defaults,iC(xe.defaults),xe}xe.use=Q3;xe.walkTokens=function(e,t){return ci.walkTokens(e,t)};xe.parseInline=ci.parseInline;xe.Parser=Gt;xe.parser=Gt.parse;xe.Renderer=Ql;xe.TextRenderer=$p;xe.Lexer=Kt;xe.lexer=Kt.lex;xe.Tokenizer=Gl;xe.Hooks=Us;xe.parse=xe;var wW=xe.options,SW=xe.setOptions,kW=xe.walkTokens,CW=xe.parseInline,TW=Gt.parse,AW=Kt.lex,dC=(0,m.createContext)({linkBase:null,trustLinks:!1});function RW({base:e,trustLinks:t=!1,children:n}){const r=(0,m.useMemo)(()=>({linkBase:e,trustLinks:t}),[e,t]);return(0,g.jsx)(dC.Provider,{value:r,children:n})}function X3(e){if(!e)return;const t=e.replace(/\/$/,"");return(n,r,i)=>n.startsWith("/")&&!n.startsWith("//")?t+n:uT(n,r,i)}function Y3(e){const t=xe.lexer(e);return t.length===0?[e]:t.map(n=>n.raw)}var pC=(0,m.memo)(({content:e})=>{const{linkBase:t,trustLinks:n}=(0,m.useContext)(dC),r=(0,m.useMemo)(()=>X3(t),[t]),i=(0,m.useMemo)(()=>n?{enabled:!1}:void 0,[n]);return(0,g.jsx)(cT,{linkSafety:i,urlTransform:r,children:e})},(e,t)=>e.content===t.content);pC.displayName="MemoizedMarkdownBlock";var mC=(0,m.memo)(({content:e,className:t})=>(0,m.useMemo)(()=>Y3(e),[e]).map((n,r)=>(0,g.jsx)("div",{className:t,children:(0,g.jsx)(pC,{content:n})},`markdown-block_${r}`)),(e,t)=>!(e.content!==t.content||e.className!==t.className));mC.displayName="MemoizedMarkdown";var gC="/web/artifact",J3=3e4,Z3=15e3,e5=2e3,t5=2e4;function Hp(e){if(!e)return!1;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&t.pathname.endsWith(gC)&&t.searchParams.has("t")}catch{return!1}}function Wp(e){if(!Hp(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 qp(e,t){return`artifact:${new URL(e).origin}:${t.k}:${t.s}`}function MW(e){const t=Wp(e);return t?qp(e,t):e}var cs=new Map,vC=0,Io=new Set;function n5(e){for(const[t,n]of cs)n.expiresAt<=e&&cs.delete(t)}function r5(e){const t=Wp(e);if(!t)return!1;const n=qp(e,t),r=t.e*1e3,i=cs.get(n);return i&&i.expiresAt>=r?!1:(cs.set(n,{url:e,expiresAt:r}),!0)}function i5(e){let t=!1,n=t5;const r=[e];for(;r.length>0&&n>0;){n-=1;const i=r.pop();if(typeof i=="string")i.includes(gC)&&r5(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){cs.size>e5&&n5(Date.now()),vC+=1;for(const i of Io)i()}}function Xl(e){const t=Wp(e);if(!t)return e;const n=cs.get(qp(e,t));return n&&n.expiresAt>t.e*1e3?n.url:e}function s5(e){return Io.add(e),()=>{Io.delete(e)}}function Xv(){return vC}function o5(e,t){const n=Xl(e);return n!==e?Promise.resolve(n):new Promise(r=>{const i=()=>{const a=Xl(e);a!==e&&(o(),r(a))},s=setTimeout(()=>{o(),r(null)},t),o=()=>{clearTimeout(s),Io.delete(i)};Io.add(i)})}function a5(e){return(0,m.useSyncExternalStore)(s5,Xv,Xv),typeof e=="string"?Xl(e):e}var sd,Yv=Number.NEGATIVE_INFINITY,od=new Set;function yC(e=Date.now()){if(e-Yv<J3)return!1;Yv=e,sd=Math.max((sd??0)+1,Math.floor(e/6e4));for(const t of od)t();return!0}function l5(e){return od.add(e),()=>{od.delete(e)}}function Jv(){return sd}function c5(){return(0,m.useSyncExternalStore)(l5,Jv,Jv)}async function PW(e,t){const n=Xl(e),r=t===void 0?await fetch(n):await fetch(n,t);if(r.status!==401&&r.status!==403||!Hp(n))return r;yC();const i=await o5(n,Z3);return!i||t?.signal?.aborted?r:t===void 0?await fetch(i):await fetch(i,t)}function u5(e){Hp(e)&&yC()}function EW(e,t){const n=c5(),r=t==="skip"||n===void 0?t:{...t,urlEpoch:n},i=LO(e,r);(0,m.useEffect)(()=>{i!==void 0&&i5(i)},[i]);const s=t==="skip"?null:JSON.stringify(t),o=(0,m.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 xC({src:e,alt:t,onError:n,...r}){const i=a5(e);return(0,g.jsx)("img",{...r,src:i,alt:t,onError:s=>{u5(i),n?.(s)}})}var Lc=(0,m.createContext)(null);Lc.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"},Up=10,ti=m.useLayoutEffect,Zv=m.useId,h5=typeof Zv=="function"?Zv:()=>null,f5=0;function Kp(e=null){const t=h5(),n=(0,m.useRef)(e||t||null);return n.current===null&&(n.current=""+f5++),e??n.current}function bC({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:p="div",...v}){const y=(0,m.useContext)(Lc);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:T,reevaluatePanelConstraints:k,registerPanel:A,resizePanel:E,unregisterPanel:R}=y,O=Kp(o),M=(0,m.useRef)({callbacks:{onCollapse:c,onExpand:u,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:a,minSize:l},id:O,idIsFromProps:o!==void 0,order:f});(0,m.useRef)({didLogMissingDefaultSizeWarning:!1}),ti(()=>{const{callbacks:N,constraints:P}=M.current,L={...P};M.current.id=O,M.current.idIsFromProps=o!==void 0,M.current.order=f,N.onCollapse=c,N.onExpand=u,N.onResize=h,P.collapsedSize=n,P.collapsible=r,P.defaultSize=i,P.maxSize=a,P.minSize=l,(L.collapsedSize!==P.collapsedSize||L.collapsible!==P.collapsible||L.maxSize!==P.maxSize||L.minSize!==P.minSize)&&k(M.current,L)}),ti(()=>{const N=M.current;return A(N),()=>{R(N)}},[f,O,A,R]),(0,m.useImperativeHandle)(s,()=>({collapse:()=>{x(M.current)},expand:N=>{b(M.current,N)},getId(){return O},getSize(){return w(M.current)},isCollapsed(){return T(M.current)},isExpanded(){return!T(M.current)},resize:N=>{E(M.current,N)}}),[x,b,w,T,O,E]);const j=S(M.current,i);return(0,m.createElement)(p,{...v,children:e,className:t,id:O,style:{...j,...d},[De.groupId]:C,[De.panel]:"",[De.panelCollapsible]:r||void 0,[De.panelId]:O,[De.panelSize]:parseFloat(""+j.flexGrow).toFixed(1)})}var Gp=(0,m.forwardRef)((e,t)=>(0,m.createElement)(bC,{...e,forwardedRef:t}));bC.displayName="Panel";Gp.displayName="forwardRef(Panel)";var d5;function p5(){return d5}var ad=null,m5=!0,ey=null,gl=-1,Hn=null;function g5(e,t,n){const r=(t&TC)!==0,i=(t&AC)!==0,s=(t&RC)!==0,o=(t&MC)!==0;if(ey)return ey({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 v5(){Hn!==null&&(document.head.removeChild(Hn),ad=null,Hn=null,gl=-1)}function Gu(e,t,n){var r,i;if(!m5)return;const s=g5(e,t,n);if(ad!==s){if(ad=s,Hn===null){Hn=document.createElement("style");const a=p5();a&&Hn.setAttribute("nonce",a),document.head.appendChild(Hn)}if(gl>=0){var o;(o=Hn.sheet)===null||o===void 0||o.removeRule(gl)}gl=(r=(i=Hn.sheet)===null||i===void 0?void 0:i.insertRule(`*{cursor: ${s} !important;}`))!==null&&r!==void 0?r:-1}}function wC(e){return e.type==="keydown"}function SC(e){return e.type.startsWith("pointer")}function kC(e){return e.type.startsWith("mouse")}function jc(e){if(SC(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(kC(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function y5(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function x5(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 b5(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:ry(e),b:ry(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;ue(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:ny(ty(n.a)),b:ny(ty(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 w5=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function S5(e){var t;const n=getComputedStyle((t=CC(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function k5(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||S5(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"||w5.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function ty(e){let t=e.length;for(;t--;){const n=e[t];if(ue(n,"Missing node"),k5(n))return n}return null}function ny(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ry(e){const t=[];for(;e;)t.push(e),e=CC(e);return t}function CC(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}var TC=1,AC=2,RC=4,MC=8,C5=y5()==="coarse",nn=[],Zn=!1,mr=new Map,_c=new Map,Do=new Set;function T5(e,t,n,r,i){var s;const{ownerDocument:o}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=mr.get(o))!==null&&s!==void 0?s:0;return mr.set(o,l+1),Do.add(a),Yl(),function(){var u;_c.delete(e),Do.delete(a);const h=(u=mr.get(o))!==null&&u!==void 0?u:1;if(mr.set(o,h-1),Yl(),h===1&&mr.delete(o),nn.includes(a)){const f=nn.indexOf(a);f>=0&&nn.splice(f,1),Bc(),i("up",!0,null)}}}function A5(e){const{target:t}=e,{x:n,y:r}=jc(e);Zn=!0,Qp({target:t,x:n,y:r}),Yl(),nn.length>0&&(Jl("down",e),Bc(),e.preventDefault(),PC(t)||e.stopImmediatePropagation())}function Qu(e){const{x:t,y:n}=jc(e);if(Zn&&e.type!=="pointerleave"&&e.buttons===0&&(Zn=!1,Jl("up",e)),!Zn){const{target:r}=e;Qp({target:r,x:t,y:n})}Jl("move",e),Bc(),nn.length>0&&e.preventDefault()}function Xu(e){const{target:t}=e,{x:n,y:r}=jc(e);_c.clear(),Zn=!1,nn.length>0&&(e.preventDefault(),PC(t)||e.stopImmediatePropagation()),Jl("up",e),Qp({target:t,x:n,y:r}),Bc(),Yl()}function PC(e){let t=e;for(;t;){if(t.hasAttribute(De.resizeHandle))return!0;t=t.parentElement}return!1}function Qp({target:e,x:t,y:n}){nn.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Do.forEach(i=>{const{element:s,hitAreaMargins:o}=i,a=s.getBoundingClientRect(),{bottom:l,left:c,right:u,top:h}=a,f=C5?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)&&b5(r,s)>0){let d=r,p=!1;for(;d&&!d.contains(s);){if(x5(d.getBoundingClientRect(),a,!0)){p=!0;break}d=d.parentElement}if(p)return}nn.push(i)}})}function Yu(e,t){_c.set(e,t)}function Bc(){let e=!1,t=!1;nn.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;_c.forEach(r=>{n|=r}),e&&t?Gu("intersection",n,Zn):e?Gu("horizontal",n,Zn):t?Gu("vertical",n,Zn):v5()}var Ju;function Yl(){var e;(e=Ju)===null||e===void 0||e.abort(),Ju=new AbortController;const t={capture:!0,signal:Ju.signal};Do.size&&(Zn?(nn.length>0&&mr.forEach((n,r)=>{const{body:i}=r;n>0&&(i.addEventListener("contextmenu",Xu,t),i.addEventListener("pointerleave",Qu,t),i.addEventListener("pointermove",Qu,t))}),mr.forEach((n,r)=>{const{body:i}=r;i.addEventListener("pointerup",Xu,t),i.addEventListener("pointercancel",Xu,t)})):mr.forEach((n,r)=>{const{body:i}=r;n>0&&(i.addEventListener("pointerdown",A5,t),i.addEventListener("pointermove",Qu,t))}))}function Jl(e,t){Do.forEach(n=>{const{setResizeHandlerState:r}=n;r(e,nn.includes(n),t)})}function R5(){const[e,t]=(0,m.useState)(0);return(0,m.useCallback)(()=>t(n=>n+1),[])}function ue(e,t){if(!e)throw console.error(t),Error(t)}function ui(e,t,n=Up){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Un(e,t,n=Up){return ui(e,t,n)===0}function Ot(e,t,n){return ui(e,t,n)===0}function M5(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(!Ot(i,s,n))return!1}return!0}function Vi({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];ue(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:o=100,minSize:a=0}=r;if(ui(n,a)<0)if(s){const l=(i+a)/2;ui(n,l)<0?n=i:n=a}else n=a;return n=Math.min(o,n),n=parseFloat(n.toFixed(Up)),n}function Ks({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Ot(e,0))return t;const o=[...t],[a,l]=r;ue(a!=null,"Invalid first pivot index"),ue(l!=null,"Invalid second pivot index");let c=0;if(s==="keyboard"){{const u=e<0?l:a,h=n[u];ue(h,`Panel constraints not found for index ${u}`);const{collapsedSize:f=0,collapsible:d,minSize:p=0}=h;if(d){const v=t[u];if(ue(v!=null,`Previous layout not found for panel index ${u}`),Ot(v,f)){const y=p-v;ui(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{const u=e<0?a:l,h=n[u];ue(h,`No panel constraints found for index ${u}`);const{collapsedSize:f=0,collapsible:d,minSize:p=0}=h;if(d){const v=t[u];if(ue(v!=null,`Previous layout not found for panel index ${u}`),Ot(v,p)){const y=v-f;ui(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 p=t[h];ue(p!=null,`Previous layout not found for panel index ${h}`);const v=Vi({panelConstraints:n,panelIndex:h,size:100})-p;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];ue(f!=null,`Previous layout not found for panel index ${u}`);const d=f-h,p=Vi({panelConstraints:n,panelIndex:u,size:d});if(!Ot(f,p)&&(c+=f-p,o[u]=p,c.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?u--:u++}}if(M5(i,o))return i;{const u=e<0?l:a,h=t[u];ue(h!=null,`Previous layout not found for panel index ${u}`);const f=h+c,d=Vi({panelConstraints:n,panelIndex:u,size:f});if(o[u]=d,!Ot(d,f)){let p=f-d,v=e<0?l:a;for(;v>=0&&v<n.length;){const y=o[v];ue(y!=null,`Previous layout not found for panel index ${v}`);const x=y+p,b=Vi({panelConstraints:n,panelIndex:v,size:x});if(Ot(y,b)||(p-=b-y,o[v]=b),Ot(p,0))break;e>0?v--:v++}}}return Ot(o.reduce((u,h)=>h+u,0),100)?o:i}function P5({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,o=0;const a=n[0];return ue(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 No(e,t=document){return Array.from(t.querySelectorAll(`[${De.resizeHandleId}][data-panel-group-id="${e}"]`))}function EC(e,t,n=document){const r=No(e,n).findIndex(i=>i.getAttribute(De.resizeHandleId)===t);return r??null}function OC(e,t,n){const r=EC(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function E5(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function IC(e,t=document){if(E5(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Vc(e,t=document){const n=t.querySelector(`[${De.resizeHandleId}="${e}"]`);return n||null}function O5(e,t,n,r=document){var i,s,o,a;const l=Vc(t,r),c=No(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 I5({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:o}){(0,m.useRef)({didWarnAboutMissingResizeHandle:!1}),ti(()=>{if(!s)return;const a=No(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:c,valueMin:u,valueNow:h}=P5({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),f=a[l];if(f!=null){const d=i[l];ue(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,m.useEffect)(()=>{if(!s)return;const a=t.current;ue(a,"Eager values not found");const{panelDataArray:l}=a;ue(IC(n,s)!=null,`No group found for id "${n}"`);const c=No(n,s);ue(c,`No resize handles found for group id "${n}"`);const u=c.map(h=>{const f=h.getAttribute(De.resizeHandleId);ue(f,"Resize handle element has no handle id attribute");const[d,p]=O5(n,f,l,s);if(d==null||p==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];ue(b,`No panel data found for index ${x}`);const w=r[x],{collapsedSize:S=0,collapsible:C,minSize:T=0}=b.constraints;if(w!=null&&C){const k=Ks({delta:Ot(w,S)?T-S:S-w,initialLayout:r,panelConstraints:l.map(A=>A.constraints),pivotIndices:OC(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 iy(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 DC(e,t){const n=e==="horizontal",{x:r,y:i}=jc(t);return n?r:i}function D5(e,t,n,r,i){const s=n==="horizontal",o=Vc(t,i);ue(o,`No resize handle element found for id "${t}"`);const a=o.getAttribute(De.groupId);ue(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=DC(n,e),u=IC(a,i);ue(u,`No group element found for id "${a}"`);const h=u.getBoundingClientRect(),f=s?h.width:h.height;return(c-l)/f*100}function N5(e,t,n,r,i,s){if(wC(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:D5(e,t,n,r,s)}function L5({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];ue(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];ue(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 Ci(e,t,n){t.forEach((r,i)=>{const s=e[i];ue(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:p}=o;p&&p(r,h),u&&(f||d)&&(d&&(h==null||Un(h,c))&&!Un(r,c)&&d(),f&&(h==null||!Un(h,c))&&Un(r,c)&&f())}})}function Ba(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 j5({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 _5(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function sy(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 NC(e){return`react-resizable-panels:${e}`}function LC(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 jC(e,t){try{const n=NC(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function B5(e,t,n){var r,i;return(i=((r=jC(e,n))!==null&&r!==void 0?r:{})[LC(t)])!==null&&i!==void 0?i:null}function V5(e,t,n,r,i){var s;const o=NC(e),a=LC(t),l=(s=jC(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 oy({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(!Ot(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];ue(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];ue(o!=null,`No layout data found for index ${s}`);const a=Vi({panelConstraints:t,panelIndex:s,size:o});o!=a&&(i+=o-a,n[s]=a)}if(!Ot(i,0))for(let s=0;s<t.length;s++){const o=n[s];ue(o!=null,`No layout data found for index ${s}`);const a=o+i,l=Vi({panelConstraints:t,panelIndex:s,size:a});if(o!==l&&(i-=l-o,n[s]=l,Ot(i,0)))break}return n}var F5=100,Gs={getItem:e=>(sy(Gs),Gs.getItem(e)),setItem:(e,t)=>{sy(Gs),Gs.setItem(e,t)}},ay={};function _C({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:o=null,keyboardResizeBy:a=null,storage:l=Gs,style:c,tagName:u="div",...h}){const f=Kp(s),d=(0,m.useRef)(null),[p,v]=(0,m.useState)(null),[y,x]=(0,m.useState)([]),b=R5(),w=(0,m.useRef)({}),S=(0,m.useRef)(new Map),C=(0,m.useRef)(0),T=(0,m.useRef)({autoSaveId:e,direction:r,dragState:p,id:f,keyboardResizeBy:a,onLayout:o,storage:l}),k=(0,m.useRef)({layout:y,panelDataArray:[],panelDataArrayChanged:!1});(0,m.useRef)({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),(0,m.useImperativeHandle)(i,()=>({getId:()=>T.current.id,getLayout:()=>{const{layout:_}=k.current;return _},setLayout:_=>{const{onLayout:U}=T.current,{layout:K,panelDataArray:G}=k.current,$=oy({layout:_,panelConstraints:G.map(J=>J.constraints)});iy(K,$)||(x($),k.current.layout=$,U&&U($),Ci(G,$,w.current))}}),[]),ti(()=>{T.current.autoSaveId=e,T.current.direction=r,T.current.dragState=p,T.current.id=f,T.current.onLayout=o,T.current.storage=l}),I5({committedValuesRef:T,eagerValuesRef:k,groupId:f,layout:y,panelDataArray:k.current.panelDataArray,setLayout:x,panelGroupElement:d.current}),(0,m.useEffect)(()=>{const{panelDataArray:_}=k.current;if(e){if(y.length===0||y.length!==_.length)return;let U=ay[e];U==null&&(U=_5(V5,F5),ay[e]=U);const K=[..._],G=new Map(S.current);U(e,K,G,y,l)}},[e,y,l]),(0,m.useEffect)(()=>{});const A=(0,m.useCallback)(_=>{const{onLayout:U}=T.current,{layout:K,panelDataArray:G}=k.current;if(_.constraints.collapsible){const $=G.map(se=>se.constraints),{collapsedSize:J=0,panelSize:ae,pivotIndices:he}=Br(G,_,K);if(ue(ae!=null,`Panel size not found for panel "${_.id}"`),!Un(ae,J)){S.current.set(_.id,ae);const se=Ks({delta:Oi(G,_)===G.length-1?ae-J:J-ae,initialLayout:K,panelConstraints:$,pivotIndices:he,prevLayout:K,trigger:"imperative-api"});Ba(K,se)||(x(se),k.current.layout=se,U&&U(se),Ci(G,se,w.current))}}},[]),E=(0,m.useCallback)((_,U)=>{const{onLayout:K}=T.current,{layout:G,panelDataArray:$}=k.current;if(_.constraints.collapsible){const J=$.map(rt=>rt.constraints),{collapsedSize:ae=0,panelSize:he=0,minSize:se=0,pivotIndices:Ye}=Br($,_,G),Le=U??se;if(Un(he,ae)){const rt=S.current.get(_.id),qe=rt!=null&&rt>=Le?rt:Le,gt=Ks({delta:Oi($,_)===$.length-1?he-qe:qe-he,initialLayout:G,panelConstraints:J,pivotIndices:Ye,prevLayout:G,trigger:"imperative-api"});Ba(G,gt)||(x(gt),k.current.layout=gt,K&&K(gt),Ci($,gt,w.current))}}},[]),R=(0,m.useCallback)(_=>{const{layout:U,panelDataArray:K}=k.current,{panelSize:G}=Br(K,_,U);return ue(G!=null,`Panel size not found for panel "${_.id}"`),G},[]),O=(0,m.useCallback)((_,U)=>{const{panelDataArray:K}=k.current,G=Oi(K,_);return j5({defaultSize:U,dragState:p,layout:y,panelData:K,panelIndex:G})},[p,y]),M=(0,m.useCallback)(_=>{const{layout:U,panelDataArray:K}=k.current,{collapsedSize:G=0,collapsible:$,panelSize:J}=Br(K,_,U);return ue(J!=null,`Panel size not found for panel "${_.id}"`),$===!0&&Un(J,G)},[]),j=(0,m.useCallback)(_=>{const{layout:U,panelDataArray:K}=k.current,{collapsedSize:G=0,collapsible:$,panelSize:J}=Br(K,_,U);return ue(J!=null,`Panel size not found for panel "${_.id}"`),!$||ui(J,G)>0},[]),N=(0,m.useCallback)(_=>{const{panelDataArray:U}=k.current;U.push(_),U.sort((K,G)=>{const $=K.order,J=G.order;return $==null&&J==null?0:$==null?-1:J==null?1:$-J}),k.current.panelDataArrayChanged=!0,b()},[b]);ti(()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;const{autoSaveId:_,onLayout:U,storage:K}=T.current,{layout:G,panelDataArray:$}=k.current;let J=null;if(_){const he=B5(_,$,K);he&&(S.current=new Map(Object.entries(he.expandToSizes)),J=he.layout)}J==null&&(J=L5({panelDataArray:$}));const ae=oy({layout:J,panelConstraints:$.map(he=>he.constraints)});iy(G,ae)||(x(ae),k.current.layout=ae,U&&U(ae),Ci($,ae,w.current))}}),ti(()=>{const _=k.current;return()=>{_.layout=[]}},[]);const P=(0,m.useCallback)(_=>{let U=!1;const K=d.current;return K&&window.getComputedStyle(K,null).getPropertyValue("direction")==="rtl"&&(U=!0),function($){$.preventDefault();const J=d.current;if(!J)return()=>null;const{direction:ae,dragState:he,id:se,keyboardResizeBy:Ye,onLayout:Le}=T.current,{layout:rt,panelDataArray:qe}=k.current,{initialLayout:gt}=he??{},Me=OC(se,_,J);let it=N5($,_,ae,he,Ye,J);const Nr=ae==="horizontal";Nr&&U&&(it=-it);const ws=qe.map(ye=>ye.constraints),me=Ks({delta:it,initialLayout:gt??rt,panelConstraints:ws,pivotIndices:Me,prevLayout:rt,trigger:wC($)?"keyboard":"mouse-or-touch"}),Y=!Ba(rt,me);(SC($)||kC($))&&C.current!=it&&(C.current=it,!Y&&it!==0?Nr?Yu(_,it<0?TC:AC):Yu(_,it<0?RC:MC):Yu(_,0)),Y&&(x(me),k.current.layout=me,Le&&Le(me),Ci(qe,me,w.current))}},[]),L=(0,m.useCallback)((_,U)=>{const{onLayout:K}=T.current,{layout:G,panelDataArray:$}=k.current,J=$.map(Ye=>Ye.constraints),{panelSize:ae,pivotIndices:he}=Br($,_,G);ue(ae!=null,`Panel size not found for panel "${_.id}"`);const se=Ks({delta:Oi($,_)===$.length-1?ae-U:U-ae,initialLayout:G,panelConstraints:J,pivotIndices:he,prevLayout:G,trigger:"imperative-api"});Ba(G,se)||(x(se),k.current.layout=se,K&&K(se),Ci($,se,w.current))},[]),B=(0,m.useCallback)((_,U)=>{const{layout:K,panelDataArray:G}=k.current,{collapsedSize:$=0,collapsible:J}=U,{collapsedSize:ae=0,collapsible:he,maxSize:se=100,minSize:Ye=0}=_.constraints,{panelSize:Le}=Br(G,_,K);Le!=null&&(J&&he&&Un(Le,$)?Un($,ae)||L(_,ae):Le<Ye?L(_,Ye):Le>se&&L(_,se))},[L]),H=(0,m.useCallback)((_,U)=>{const{direction:K}=T.current,{layout:G}=k.current;if(!d.current)return;const $=Vc(_,d.current);ue($,`Drag handle element not found for id "${_}"`);const J=DC(K,U);v({dragHandleId:_,dragHandleRect:$.getBoundingClientRect(),initialCursorPosition:J,initialLayout:G})},[]),V=(0,m.useCallback)(()=>{v(null)},[]),I=(0,m.useCallback)(_=>{const{panelDataArray:U}=k.current,K=Oi(U,_);K>=0&&(U.splice(K,1),delete w.current[_.id],k.current.panelDataArrayChanged=!0,b())},[b]),ne=(0,m.useMemo)(()=>({collapsePanel:A,direction:r,dragState:p,expandPanel:E,getPanelSize:R,getPanelStyle:O,groupId:f,isPanelCollapsed:M,isPanelExpanded:j,reevaluatePanelConstraints:B,registerPanel:N,registerResizeHandle:P,resizePanel:L,startDragging:H,stopDragging:V,unregisterPanel:I,panelGroupElement:d.current}),[A,p,r,E,R,O,f,M,j,B,N,P,L,H,V,I]),re={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return(0,m.createElement)(Lc.Provider,{value:ne},(0,m.createElement)(u,{...h,children:t,className:n,id:s,ref:d,style:{...re,...c},[De.group]:"",[De.groupDirection]:r,[De.groupId]:f}))}var BC=(0,m.forwardRef)((e,t)=>(0,m.createElement)(_C,{...e,forwardedRef:t}));_C.displayName="PanelGroup";BC.displayName="forwardRef(PanelGroup)";function Oi(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Br(e,t,n){const r=Oi(e,t),i=r===e.length-1?[r-1,r]:[r,r+1],s=n[r];return{...t.constraints,panelSize:s,pivotIndices:i}}function z5({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){(0,m.useEffect)(()=>{if(e||n==null||r==null)return;const i=Vc(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);ue(a,`No group element found for id "${a}"`);const l=No(a,r),c=EC(a,t,r);ue(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 VC({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",...p}){var v,y;const x=(0,m.useRef)(null),b=(0,m.useRef)({onClick:o,onDragging:a,onPointerDown:c,onPointerUp:u});(0,m.useEffect)(()=>{b.current.onClick=o,b.current.onDragging=a,b.current.onPointerDown=c,b.current.onPointerUp=u});const w=(0,m.useContext)(Lc);if(w===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:S,groupId:C,registerResizeHandle:T,startDragging:k,stopDragging:A,panelGroupElement:E}=w,R=Kp(i),[O,M]=(0,m.useState)("inactive"),[j,N]=(0,m.useState)(!1),[P,L]=(0,m.useState)(null),B=(0,m.useRef)({state:O});ti(()=>{B.current.state=O}),(0,m.useEffect)(()=>{if(n)L(null);else{const ne=T(R);L(()=>ne)}},[n,R,T]);const H=(v=r?.coarse)!==null&&v!==void 0?v:15,V=(y=r?.fine)!==null&&y!==void 0?y:5;(0,m.useEffect)(()=>{if(n||P==null)return;const ne=x.current;ue(ne,"Element ref not attached");let re=!1;return T5(R,ne,S,{coarse:H,fine:V},(U,K,G)=>{if(!K){M("inactive");return}switch(U){case"down":{M("drag"),re=!1,ue(G,'Expected event to be defined for "down" action'),k(R,G);const{onDragging:$,onPointerDown:J}=b.current;$?.(!0),J?.();break}case"move":{const{state:$}=B.current;re=!0,$!=="drag"&&M("hover"),ue(G,'Expected event to be defined for "move" action'),P(G);break}case"up":{M("hover"),A();const{onClick:$,onDragging:J,onPointerUp:ae}=b.current;J?.(!1),ae?.(),re||$?.();break}}})},[H,S,n,V,T,R,P,k,A]),z5({disabled:n,handleId:R,resizeHandler:P,panelGroupElement:E});const I={touchAction:"none",userSelect:"none"};return(0,m.createElement)(d,{...p,children:e,className:t,id:i,onBlur:()=>{N(!1),s?.()},onFocus:()=>{N(!0),l?.()},ref:x,role:"separator",style:{...I,...h},tabIndex:f,[De.groupDirection]:S,[De.groupId]:C,[De.resizeHandle]:"",[De.resizeHandleActive]:O==="drag"?"pointer":j?"keyboard":void 0,[De.resizeHandleEnabled]:!n,[De.resizeHandleId]:R,[De.resizeHandleState]:O})}VC.displayName="PanelResizeHandle";function $5({className:e,...t}){return(0,g.jsx)(BC,{"data-slot":"resizable-panel-group",className:X("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}var ld=m.forwardRef((e,t)=>(0,g.jsx)(Gp,{ref:t,"data-slot":"resizable-panel",...e}));ld.displayName=Gp.displayName;function H5({withHandle:e,className:t,...n}){return(0,g.jsx)(VC,{"data-slot":"resizable-handle",className:X("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,g.jsx)("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:(0,g.jsx)(hI,{className:"size-2.5"})})})}function Zl(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 W5(e){try{const t=JSON.parse(e);if(Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t))return t}catch{}return null}function q5(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function U5(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 Ns(e){if(e==null)return null;if(Array.isArray(e))return{kind:"json",value:e};if(typeof e=="string"){const t=q5(e)?W5(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 OW(e){if(e==null)return null;if(typeof e!="object"||Array.isArray(e))return Ns(e);const t=e;if(U5(t))return null;if(typeof t.text=="string")return Ns(t.text);const n=Zl(t.content);if(n.length>0)return Ns(n.join(`
128
+
129
+ `));const r=Zl((t.value&&typeof t.value=="object"?t.value:null)?.content);return r.length>0?Ns(r.join(`
130
+
131
+ `)):Ns(t)}function Zu(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=Zl(t.content);if(n.length>0)return n.join(`
132
+
133
+ `);const r=Zl((t.value&&typeof t.value=="object"?t.value:null)?.content);return r.length>0?r.join(`
134
+
135
+ `):null}function K5({className:e,children:t,...n}){return(0,g.jsxs)(lE,{"data-slot":"scroll-area",className:X("relative",e),...n,children:[(0,g.jsx)(cE,{"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,g.jsx)(G5,{}),(0,g.jsx)(uE,{})]})}function G5({className:e,orientation:t="vertical",...n}){return(0,g.jsx)(YP,{"data-slot":"scroll-area-scrollbar",orientation:t,className:X("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,g.jsx)(rE,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}var Q5=500,X5={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 FC(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 us(e){const t=FC(e.action),n=e.locatorLabel?.trim();return n?`Interact · ${t} ${n}`:`Interact · ${t}`}function ec(e){return e.assertion?e.assertion.passed?"ok":"error":e.ok===!0?"ok":e.ok===!1?"error":"unknown"}function Ls(e){return`${e.toolCallId}:${e.stepIndex}`}function Y5(e){if(!e)return[];const t=[];return typeof e.durationMs=="number"&&e.durationMs>0&&t.push({key:"duration",label:J5(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 J5(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 zC(e){return typeof e=="string"&&e.length>0?e:null}function IW(e){return(e.widgetRenderObservations?.length??0)>0||(e.browserInteractionSteps?.length??0)>0||zC(e.videoUrl)!==null}function Z5(e){return e==="ok"?"OK":e==="error"?"Failed":"Unknown"}function $C({step:e,leading:t,className:n}){const r=ec(e),i=e.widgetToolCalls??[],s=e.coordinateX!=null&&e.coordinateY!=null?`(${e.coordinateX}, ${e.coordinateY})`:null;return(0,g.jsxs)("div",{"data-testid":"browser-step-detail",className:X("flex flex-col gap-4",n),children:[(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[t,(0,g.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,g.jsx)("p",{className:"truncate text-sm font-medium text-foreground",children:us(e)}),(0,g.jsxs)("p",{className:"text-xs text-muted-foreground",children:["App interaction · ",e.elapsedMs,"ms",s?` · ${s}`:""]})]}),(0,g.jsx)("span",{className:X("inline-flex shrink-0 items-center rounded-full border px-2 py-0.5 text-[11px] font-medium",X5[r]),children:Z5(r)})]}),e.assertion&&!e.assertion.passed&&e.assertion.reason?(0,g.jsx)("p",{className:"text-xs text-destructive",children:e.assertion.reason}):null,e.screenshotUrl?(0,g.jsx)(xC,{src:e.screenshotUrl,alt:us(e),className:"max-h-72 w-full rounded-md border border-border/50 object-contain"}):null,i.length>0?(0,g.jsxs)("div",{className:"space-y-1.5",children:[(0,g.jsx)("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Widget tool calls"}),i.map((o,a)=>(0,g.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border/50 px-2.5 py-1.5 text-xs",children:[(0,g.jsx)("span",{className:X("inline-block h-1.5 w-1.5 shrink-0 rounded-full",o.ok?"bg-success":"bg-destructive"),"aria-hidden":!0}),(0,g.jsx)("span",{className:"font-mono text-foreground",children:o.name}),o.error?(0,g.jsx)("span",{className:"truncate text-destructive",children:o.error}):null]},`${o.name}-${a}`))]}):null,e.followUps&&e.followUps.length>0?(0,g.jsxs)("div",{className:"space-y-1.5",children:[(0,g.jsx)("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Sent message to chat"}),e.followUps.map((o,a)=>(0,g.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border/50 px-2.5 py-1.5 text-xs",children:[(0,g.jsx)("span",{"aria-hidden":!0,children:"↳"}),(0,g.jsx)("span",{className:"truncate text-foreground",children:o})]},a))]}):null]})}function eH(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,"0")}`}function tH(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 DW({steps:e,videoUrl:t,videoMeta:n,isRunning:r=!1,className:i}){const s=(0,m.useRef)(null),[o,a]=(0,m.useState)(null),[l,c]=(0,m.useState)(null),u=(0,m.useRef)(null),[h,f]=(0,m.useState)(!1),d=zC(t),p=(0,m.useMemo)(()=>Y5(n),[n]),v=(0,m.useMemo)(()=>[...e].sort((k,A)=>(k.videoOffsetMs??Number.POSITIVE_INFINITY)-(A.videoOffsetMs??Number.POSITIVE_INFINITY)||k.promptIndex-A.promptIndex||k.ts-A.ts),[e]),y=o??l??null,x=(0,m.useMemo)(()=>v.find(k=>Ls(k)===y)??null,[v,y]),b=d!=null&&!h,w=v.some(k=>k.screenshotUrl),S=(0,m.useCallback)(k=>{a(Ls(k));const A=s.current;if(!A||!b||k.videoOffsetMs==null)return;const E=k.videoOffsetMs/1e3;u.current=E,A.currentTime=E},[b]),C=(0,m.useCallback)(()=>{u.current=null},[]),T=(0,m.useCallback)(()=>{const k=s.current;if(!k)return;const A=tH(v,k.currentTime*1e3);if(c(A?Ls(A):null),u.current==null){if(o!=null){const E=v.find(R=>Ls(R)===o);if(E?.videoOffsetMs!=null){const R=E.videoOffsetMs-k.currentTime*1e3;if(R>0&&R<Q5)return}}a(null)}},[v,o]);return(0,m.useEffect)(()=>{f(!1)},[t]),v.length===0&&!d?(0,g.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,g.jsxs)("section",{className:X("flex min-w-0 flex-col gap-3",i),"data-testid":"browser-step-filmstrip",children:[(0,g.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,g.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:["Replay",(0,g.jsx)("span",{className:"ml-1.5 font-normal normal-case text-muted-foreground/70",children:"screen recording of the app interactions in this run"})]}),d&&!h&&(p.length>0||n?.truncated)?(0,g.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:[p.map(k=>(0,g.jsx)("span",{title:k.title,children:k.label},k.key)),n?.truncated?(0,g.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,d&&!h?(0,g.jsx)("video",{ref:s,src:d,controls:!0,preload:"metadata",onTimeUpdate:T,onSeeked:C,onError:()=>f(!0),className:"w-full rounded-md border border-border/60 bg-black","data-testid":"browser-replay-video"}):(0,g.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?w?"Recording failed to load — screenshots preserved.":"Recording failed to load, and no screenshots were captured.":w?"Video unavailable — screenshots preserved.":"Partial capture — no recording, and no screenshots survived."})]}),v.length>0?(0,g.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,g.jsx)("div",{className:"flex min-w-0 gap-2 overflow-x-auto pb-1","data-testid":"browser-filmstrip-track",children:v.map(k=>{const A=Ls(k),E=ec(k),R=A===y;return(0,g.jsxs)("button",{type:"button",onClick:()=>S(k),"aria-pressed":R,title:us(k),"data-testid":"browser-filmstrip-frame","data-step-key":A,"data-active":R?"true":"false",className:X("flex w-28 shrink-0 flex-col gap-1 rounded-md border p-1 text-left transition-colors",R?"border-primary bg-primary/5":"border-border/50 hover:border-border"),children:[k.screenshotUrl?(0,g.jsx)(xC,{src:k.screenshotUrl,alt:us(k),loading:"lazy",className:"h-16 w-full rounded-sm border border-border/40 bg-background object-cover object-top"}):(0,g.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,g.jsx)("span",{className:"truncate text-[10px] font-medium text-foreground",children:FC(k.action)}),(0,g.jsx)("span",{className:X("truncate text-[10px]",E==="error"?"text-destructive":"text-muted-foreground"),children:k.videoOffsetMs!=null?eH(k.videoOffsetMs):`turn ${k.promptIndex+1}`})]},A)})}),x?(0,g.jsx)($C,{step:x,className:"rounded-lg bg-muted/5 px-4 py-4"}):(0,g.jsx)("p",{className:"px-1 text-[11px] text-muted-foreground",children:"Select a frame to see the interaction that produced it."})]}):null]})}var nH={[-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 rH(e){const t=nH[e];return t?`${e} · ${t}`:String(e)}var iH=xr({id:ve(),parentId:ve().optional(),name:ve(),category:xl(["step","llm","tool","error","connection","discovery"]),startMs:ct(),endMs:ct(),promptIndex:ct().optional(),stepIndex:ct().optional(),authoredStepId:ve().optional(),status:xl(["ok","error"]).optional(),toolCallId:ve().optional(),toolName:ve().optional(),serverId:ve().optional(),connectionId:ve().optional(),modelId:ve().optional(),inputTokens:ct().optional(),outputTokens:ct().optional(),totalTokens:ct().optional(),messageStartIndex:ct().optional(),messageEndIndex:ct().optional(),finishReason:ve().optional(),provider:ve().optional(),responseId:ve().optional(),responseTimestamp:ve().optional(),ttfcMs:ct().optional(),mcpErrorCode:ct().optional(),outputSource:rh([dr("narration"),dr("evidence"),dr("reconstructed")]).optional(),wireCorroborated:Ue().optional(),evidenceRequestId:ve().optional(),evidenceStatus:rh([dr("complete"),dr("incomplete")]).optional()}),Ti=xr({toolName:ve(),arguments:Va(ve(),vy())}),sH=xr({promptIndex:ct(),prompt:ve(),expectedToolCalls:yn(Ti),actualToolCalls:yn(Ti),expectedOutput:ve().optional(),passed:Ue(),missing:yn(Ti),unexpected:yn(Ti),argumentMismatches:yn(xr({expected:Ti,actual:Ti,mismatchedArguments:yn(ve())}))}),oH=xr({toolCallId:ve(),toolName:ve(),protocol:rh([dr("mcp-apps"),dr("openai-apps")]),serverId:ve(),resourceUri:ve().optional(),toolMetadata:Va(ve(),Wc()),widgetCsp:Va(ve(),Wc()).nullable().optional(),widgetPermissions:Va(ve(),Wc()).nullable().optional(),widgetPermissive:Ue().optional(),prefersBorder:Ue().optional(),widgetHtmlBlobId:ve().optional(),widgetHtmlUrl:ve().nullable().optional(),injectedOpenAiCompat:Ue().optional(),injectedOpenAiCompatCapabilities:xr({callTool:Ue().optional(),sendFollowUpMessage:Ue().optional(),setWidgetState:Ue().optional(),requestDisplayMode:xl(["all","fullscreen-only","none"]).optional(),notifyIntrinsicHeight:Ue().optional(),openExternal:Ue().optional(),setOpenInAppUrl:Ue().optional(),requestModal:Ue().optional(),uploadFile:Ue().optional(),selectFiles:Ue().optional(),getFileDownloadUrl:Ue().optional(),requestCheckout:Ue().optional(),requestClose:Ue().optional()}).optional()}),aH=xr({source:xl(["hosted","widget"]),fps:ct().optional(),durationMs:ct().optional(),distinctFrames:ct().optional(),truncated:Ue().optional()}),NW=xr({traceVersion:dr(1),messages:yn(vy()),widgetSnapshots:yn(oH).optional(),spans:yn(iH).optional(),prompts:yn(sH).optional(),videoBlobId:ve().optional(),videoMeta:aH.optional()}),lH=["all","connection","discovery","llm","tool","error"];function eh(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 cH({filter:e,onFilterChange:t,isFullyExpanded:n,expandDisabled:r,onToggleExpandAll:i,zoomControls:s,showBottomBorder:o=!0}){return(0,g.jsxs)("div",{className:X("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,g.jsxs)(xb,{children:[(0,g.jsx)(bb,{asChild:!0,children:(0,g.jsxs)(Nt,{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: ${eh(e)}`,children:[(0,g.jsx)(mI,{className:"size-3.5 shrink-0 opacity-80","aria-hidden":!0}),eh(e)]})}),(0,g.jsx)(wb,{align:"start",className:"min-w-[8rem]",children:(0,g.jsx)(KI,{value:e,onValueChange:a=>t(a),children:lH.map(a=>(0,g.jsx)(GI,{value:a,className:"text-xs",children:eh(a)},a))})})]}),(0,g.jsx)(Nt,{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,g.jsx)(NI,{className:"size-3.5",strokeWidth:2,"aria-hidden":!0}):(0,g.jsx)(aI,{className:"size-3.5",strokeWidth:2,"aria-hidden":!0})}),s?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{className:"bg-border hidden h-3 w-px shrink-0 md:block","aria-hidden":!0}),(0,g.jsx)("div",{className:"flex shrink-0 items-center gap-0.5",children:s})]}):null]})}var ly=[0,25,50,75,100],uH=54,hH=120;function fH(e){if(!Number.isFinite(e))return[0,100];if(e<=0)return[0,100];const t=Math.max(2,Math.floor(e/uH));return t>=ly.length?[...ly]:t<=2?[0,100]:t===3?[0,50,100]:[0,25,75,100]}function dH(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 cy(e){return e<=0?vl(0):`${vl(0)}–${vl(e)}`}function pH(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 Fc(e,t){return t}function uy(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 Fc(e,9)}}function mH(e,t){if(e.startMs!==t.startMs)return e.startMs-t.startMs;const n=uy(e.category)-uy(t.category);return n!==0?n:e.endMs!==t.endMs?e.endMs-t.endMs:e.name.localeCompare(t.name)}function gH(e,t){return typeof e!="number"||t<50?null:e/(t/1e3)}function co(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?1:2)}s`:`${Math.round(e)}ms`}function vl(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`}function Kn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Lo(e){const t=e.toolName??e.name;return typeof t=="string"&&t.trim()?t:void 0}function ta(e){return Array.isArray(e.content)?e.content.filter(t=>Kn(t)&&typeof t.type=="string"):typeof e.content=="string"?[{type:"text",text:e.content}]:[]}function HC(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(Kn(e)){const t=Object.keys(e);return t.length>0?`{ ${t.slice(0,4).join(", ")}${t.length>4?", ...":""} }`:"{}"}return String(e)}function vH(e){const t=ta(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: ${Lo(r)??"Tool"}`:r.type==="tool-result"?`Tool result: ${Lo(r)??"Tool"}`:typeof r.type=="string"?r.type:"content").join(" | ");return n.length>220?`${n.slice(0,217)}...`:n}function yH(e){return!Kn(e)||!("type"in e)||!("value"in e)?e:e.value}function xH(e){return e.result!==void 0?e.result:yH(e.output)}function bH(e){const t=xH(e);if(typeof e.error=="string"&&e.error.trim())return e.error.trim();if(Kn(e.error)&&typeof e.error.message=="string")return e.error.message;if(Kn(e.output)&&e.output.type==="error-text")return typeof e.output.value=="string"?e.output.value:"Tool error";if(Kn(e.result)&&e.result.isError===!0||Kn(e.output)&&Kn(e.output.value)&&e.output.value.isError===!0||e.isError===!0)return Zu(t)??"Tool error"}function zc(e,t,n){if(!t&&!n)return{};let r,i,s;for(const o of e)for(const a of ta(o)){const l=typeof t=="string"&&a.toolCallId===t,c=!l&&typeof n=="string"&&Lo(a)===n;if(!(!l&&!c)&&(a.type==="tool-call"&&(r=a.input??a.parameters??a.args),a.type==="tool-result")){i=a.result??(Kn(a.output)&&"value"in a.output?a.output.value:a.output);const u=bH(a);u&&(s=u)}}return{input:r,output:i,errorText:s}}function Fi(e,t){return e.category==="error"||e.status==="error"?!0:e.category==="tool"?!!zc(t,e.toolCallId,e.toolName??e.name).errorText:!1}function bs(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 wH(e){return bs(e.messageStartIndex,e.messageEndIndex)}function SH(e){return bs(e.span.messageStartIndex,e.span.messageEndIndex)}function WC(e){if(!e)return[];const t=[];for(let n=e.startIndex;n<=e.endIndex;n+=1)t.push(n);return t}function qC(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 Xp(e,t,n){if(!e.length)return;const r=bs(t,n);if(!r){const s=e.findIndex(o=>o.role==="user");return s>=0?s:void 0}const i=qC(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 kH(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 Fc(n,"trace-waterfall-bar-step")}}function CH(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 Fc(e,"text-muted-foreground")}}function TH(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 Fc(n,"border-l-muted-foreground")}}function AH(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)=>mH(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 hy(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 th(e){return{role:e.role,content:e.content}}function UC(e,t,n){const r=bs(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 RH(e,t,n){const r=bs(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(th),output:null};const o=UC(e,t,n),a=i[s];return{input:o.length>0?o.map(th):null,output:th(a)}}var MH=96;function Yt(e,t=MH){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function jo(e){return typeof e.content=="string"?e.content.trim():ta(e).map(t=>t.type==="text"&&typeof t.text=="string"?t.text.trim():"").filter(Boolean).join(" ")}function PH(e){const t=ta(e),n=[];for(const r of t)r.type==="tool-call"&&n.push(Lo(r)??"tool");return n}function EH(e,t){if(!e.length)return;const n=UC(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=jo(i);if(s)return Yt(s)}}for(const r of n)if(r.role==="system"){const i=jo(r);if(i)return Yt(i)}for(let r=n.length-1;r>=0;r--){const i=n[r];if(i.role==="tool"){const s=vH(i);if(s&&s!=="No content")return Yt(s)}}}}function OH(e,t){if(!e.length)return;const n=bs(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=jo(s);if(o)return{kind:"text",preview:Yt(o)};const a=PH(s);if(a.length>0)return{kind:"tools",preview:Yt(`Calling ${a.join(", ")}`)}}}function IH(e,t,n){const r=Xp(e,t,n);if(typeof r!="number")return;const i=jo(e[r]);return i?Yt(i):void 0}function DH(e,t,n){const r=Xp(e,t,n);if(typeof r=="number")return jo(e[r])||void 0}function fy(e,t){if(typeof t.toolCallId=="string"&&e.toolCallId===t.toolCallId)return!0;const n=t.toolName?.trim()||t.name?.trim();return!!(n&&Lo(e)===n)}function NH(e,t,n){if(n)for(let r=n.startIndex;r<=n.endIndex;r+=1){const i=e[r];if(!i)continue;const s=ta(i);if(s.some(o=>o.type==="tool-call"&&fy(o,t))||s.some(o=>o.type==="tool-result"&&fy(o,t)))return r}}function LH(e,t){const n=Xp(t,e.messageStartIndex,e.messageEndIndex);if(typeof n=="number")return{focusSourceIndex:n,highlightSourceIndices:[n]};const r=WC(wH(e));if(r.length!==0)return{focusSourceIndex:r[0],highlightSourceIndices:r}}function jH(e,t){const n=SH(e),r=WC(n);if(r.length===0)return;const i=qC(t,n,s=>s.role==="assistant");return{focusSourceIndex:(e.span.category==="tool"?NH(t,e.span,n):void 0)??i??r[0],highlightSourceIndices:r}}function _H(e,t){const n=zc(e,t.toolCallId,t.toolName??t.name);if(n.input==null)return;const r=HC(n.input);if(!(!r||r==="None"))return Yt(r)}function hs({category:e,size:t="sm"}){const n=X(t==="lg"?"h-5 w-5 shrink-0":"h-3.5 w-3.5 shrink-0",CH(e));switch(e){case"prompt":return(0,g.jsx)(VI,{className:n,"aria-hidden":!0});case"llm":return(0,g.jsx)(XO,{className:n,"aria-hidden":!0});case"tool":return(0,g.jsx)(zI,{className:n,"aria-hidden":!0});case"interaction":return(0,g.jsx)(AI,{className:n,"aria-hidden":!0});case"error":return(0,g.jsx)(tI,{className:n,"aria-hidden":!0});case"connection":case"discovery":case"step":return(0,g.jsx)(_m,{className:n,"aria-hidden":!0});default:return(0,g.jsx)(_m,{className:n,"aria-hidden":!0})}}function BH(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 VH(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=BH(t,e.span);return typeof r.inputTokens=="number"||typeof r.outputTokens=="number"||typeof r.totalTokens=="number"?r:n}function nh(e){return typeof e=="number"?e.toLocaleString():"—"}function dy(e){return typeof e=="number"&&Number.isFinite(e)?new Date(e).toLocaleString():"—"}function FH({traceStartedAtMs:e,traceEndedAtMs:t,traceDurationMs:n}){return typeof e=="number"&&Number.isFinite(e)?e:typeof t=="number"&&Number.isFinite(t)?t-n:null}function cd(e,t){const{span:n,promptIndex:r}=e,i=n.modelId?.trim()?Yt(n.modelId.trim(),56):void 0,s=n.name?.trim()??"";if(n.category==="step"){const o=typeof n.stepIndex=="number"?n.stepIndex+1:void 0,a=typeof o=="number"?`Step ${o}`:s||"Step",l=typeof o=="number"&&(s===`Step ${o}`||s.toLowerCase()===`step ${o}`),c=s&&!l?Yt(s,64):a,u=EH(t,n);return u?{title:c,subtitle:u}:i?{title:c,subtitle:i}:{title:c,subtitle:`Prompt ${r+1}`}}if(n.category==="llm"){const o=OH(t,n),a=!s||/^assistant$/i.test(s)||/^llm$/i.test(s)||/^model$/i.test(s)||s==="Model response"||/·\s*response$/i.test(s)?"Agent":Yt(s,64);return o?.kind==="text"?{title:`${a}: "${o.preview}"`,subtitle:i}:o?.kind==="tools"?{title:`${a} · ${o.preview}`,subtitle:i}:{title:a,subtitle:i}}if(n.category==="tool"){const o=`Tool · ${(n.toolName??n.name).trim()||"tool"}`,a=_H(t,n),l=!a||a==="{}"||a==="None";if(a&&!l)return{title:o,subtitle:a};if(l){const c=zc(t,n.toolCallId,n.toolName??n.name);if(c.output!=null){const u=HC(c.output);if(u&&u!=="None"&&u!=="{}")return{title:o,subtitle:Yt(u)}}}return typeof n.stepIndex=="number"?{title:o,subtitle:i?`${i} · step ${n.stepIndex+1}`:`step ${n.stepIndex+1}`}:{title:o,subtitle:i}}return{title:n.name,subtitle:typeof n.stepIndex=="number"?i?`${i} · step ${n.stepIndex+1}`:`step ${n.stepIndex+1}`:i}}function ud(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 zH({format:e,onFormatChange:t}){return(0,g.jsx)("div",{className:"flex flex-wrap gap-1",children:["plain","markdown"].map(n=>(0,g.jsx)(Nt,{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 py({value:e}){const[t,n]=(0,m.useState)("plain");return(0,m.useEffect)(()=>{typeof e=="string"&&n("plain")},[e]),e==null?(0,g.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,g.jsxs)("div",{className:"space-y-2",children:[(0,g.jsx)(zH,{format:t,onFormatChange:n}),t==="markdown"?(0,g.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,g.jsx)(mC,{content:e})}):(0,g.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,g.jsx)(Z$,{value:e,containerClassName:"max-h-56 rounded-md border border-border/60 bg-background"})}function $H({row:e}){return(0,g.jsx)("div",{"data-testid":"trace-detail-pane",className:"min-h-[280px] rounded-lg bg-muted/5 px-5 py-5",children:(0,g.jsx)($C,{step:e.step,leading:(0,g.jsx)(hs,{category:"interaction",size:"lg"})})})}function my(e){return e.split(/[-_\s]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function HH(e){return e.engine==="harness"?e.harness?my(e.harness):"Harness":e.engine==="emulated"?"Emulated":e.harness?my(e.harness):"Unknown"}function WH({row:e,transcriptMessages:t,onRevealInTranscript:n,turnRuntimeByPromptIndex:r}){if(!e)return(0,g.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,g.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-full border border-border/50 bg-background shadow-sm",children:(0,g.jsx)(dI,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),(0,g.jsxs)("div",{className:"space-y-1",children:[(0,g.jsx)("p",{className:"text-sm font-medium text-foreground",children:"No span selected"}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Click a row or use arrow keys"})]})]});if(e.kind==="interaction")return(0,g.jsx)($H,{row:e});const i=e.kind==="prompt"?LH(e,t):jH(e,t),s=e.kind==="span"?zc(t,e.span.toolCallId,e.span.toolName??e.span.name):{},{durationMs:o}=ud(e),a=e.kind==="span"?cd(e,t):null,l=e.kind==="prompt"?e.label:a.title,c=e.kind==="prompt"?e.hasAnyFailure?"error":"ok":Fi(e.span,t)?"error":"ok",u=e.kind==="prompt"?"prompt":e.span.category==="tool"&&Fi(e.span,t)?"error":e.span.category,h=r?.get(e.promptIndex),f=e.kind==="span"&&(e.span.category==="llm"||e.span.category==="step")?RH(t,e.span.messageStartIndex,e.span.messageEndIndex):{input:null,output:null},d=e.kind==="span"&&e.span.category==="tool"&&(!!e.span.toolCallId||!!(e.span.toolName?.trim()||e.span.name?.trim())),p=e.kind==="prompt"?null:d?s.input:e.kind==="span"&&(e.span.category==="llm"||e.span.category==="step")?f.input:(e.kind==="span"&&e.span.category==="error",null),v=e.kind==="prompt"?null:d?s.output:e.kind==="span"&&(e.span.category==="llm"||e.span.category==="step")?f.output:e.kind==="span"&&e.span.category==="error"?e.span.name:null,y=e.kind==="prompt"?DH(t,e.messageStartIndex,e.messageEndIndex):void 0,x=e.kind==="span"&&(typeof e.span.inputTokens=="number"||typeof e.span.outputTokens=="number"||typeof e.span.totalTokens=="number"),b=e.kind==="prompt"&&(typeof e.aggregatedInputTokens=="number"||typeof e.aggregatedOutputTokens=="number"||typeof e.aggregatedTotalTokens=="number"),w=e.kind==="span"&&s.errorText?s.errorText:null,S=!!(i&&n);return(0,g.jsxs)("div",{"data-testid":"trace-detail-pane",className:"space-y-4 bg-background p-4",children:[(0,g.jsxs)("div",{className:X("border-b border-border/40 pb-3",S?"flex flex-col gap-3 min-[400px]:flex-row min-[400px]:items-start":""),children:[(0,g.jsxs)("div",{className:X("flex gap-3",S?"min-w-0 min-[400px]:flex-1":""),children:[(0,g.jsx)("div",{className:"shrink-0 pt-0.5",children:e.kind==="prompt"?(0,g.jsx)(hs,{category:"prompt",size:"lg"}):(0,g.jsx)(hs,{category:u,size:"lg"})}),(0,g.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,g.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[(0,g.jsx)("h3",{className:"text-sm font-bold leading-tight text-foreground",children:l}),h?(0,g.jsxs)(Sb,{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:h.engine==="harness"?"This turn ran through the harness adapter.":h.engine==="emulated"?"This turn ran through MCPJam's emulated chat engine.":h.harness?"This turn ran through the harness adapter.":"Runtime engine was not recorded for this turn.",children:["Engine: ",HH(h)]}):null,c==="error"?(0,g.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-destructive",title:"Error","aria-label":"Error"}):null]}),(0,g.jsxs)("div",{className:"text-xs tabular-nums text-muted-foreground",children:[(0,g.jsx)("span",{className:"font-medium text-foreground",children:co(o)}),e.kind==="prompt"&&b?(0,g.jsxs)(g.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"&&x?(0,g.jsxs)(g.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]}),e.kind==="span"?(()=>{const C=e.span,T=C.category==="llm"?gH(C.outputTokens,o):null,k=[];return C.provider&&k.push({label:"Provider",value:C.provider}),C.finishReason&&k.push({label:"Finish",value:C.finishReason}),typeof C.ttfcMs=="number"&&k.push({label:"TTFC",value:co(C.ttfcMs)}),T!==null&&k.push({label:"Throughput",value:`${T.toFixed(1)} tok/s`}),C.responseId&&k.push({label:"Response ID",value:C.responseId}),k.length===0?null:(0,g.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:k.map(A=>(0,g.jsxs)("span",{className:"truncate",children:[(0,g.jsxs)("span",{className:"text-muted-foreground/70",children:[A.label,":"," "]}),(0,g.jsx)("span",{className:"font-medium text-foreground",children:A.value})]},A.label))})})():null]})]}),S?(0,g.jsx)("div",{className:"flex min-w-0 min-[400px]:flex-1 min-[400px]:justify-end min-[400px]:pt-0.5",children:(0,g.jsxs)(Nt,{type:"button",size:"sm",variant:"outline",className:"w-full shrink-0 justify-center whitespace-nowrap min-[400px]:w-auto",onClick:()=>{i&&n&&n(i)},children:[(0,g.jsx)(bI,{className:"h-3.5 w-3.5"}),"Reveal in Chat"]})}):null]}),e.kind==="prompt"&&y?(0,g.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:y}):null,e.kind==="span"?(0,g.jsxs)("div",{className:"space-y-4",children:[(0,g.jsxs)("div",{className:"space-y-2",children:[(0,g.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"Input"}),(0,g.jsx)(py,{value:p??void 0})]}),(0,g.jsxs)("div",{className:X("space-y-2",e.span.category==="error"||w?"rounded-md border border-destructive/50 bg-destructive/50 p-2":""),children:[(0,g.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"Output"}),(0,g.jsx)(py,{value:v??void 0}),w?(0,g.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:w}):null,typeof e.span.mcpErrorCode=="number"?(0,g.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,g.jsx)("span",{className:"text-muted-foreground/70",children:"MCP error: "}),(0,g.jsx)("span",{className:"font-medium text-foreground",children:rH(e.span.mcpErrorCode)})]}):null]})]}):null]})}function LW({recordedSpans:e,interactionSteps:t,estimatedDurationMs:n,transcriptMessageCount:r=0,transcriptMessages:i=[],traceStartedAtMs:s=null,traceEndedAtMs:o=null,onRevealInTranscript:a,hideToolbar:l=!1,timelineFilter:c,onTimelineFilterChange:u,expandedPromptIds:h,onExpandedPromptIdsChange:f,expandedStepIds:d,onExpandedStepIdsChange:p,viewportMaxMs:v,turnRuntimeByPromptIndex:y,fillContent:x=!1}){const b=Gj(),w=e&&e.length>0?"recorded":(n??0)>0?"estimated":"none",S=(0,m.useMemo)(()=>e?.length?AH(e):[],[e]),C=(0,m.useMemo)(()=>{const D=new Map;for(const ee of t??[]){const ce=D.get(ee.toolCallId);ce?ce.push(ee):D.set(ee.toolCallId,[ee])}for(const ee of D.values())ee.sort((ce,Ce)=>ce.stepIndex-Ce.stepIndex);return D},[t]),T=e?.length?e.reduce((D,ee)=>Math.max(D,ee.endMs),1):Math.max(n??0,1),k=(0,m.useMemo)(()=>e?.map(D=>`${D.id}:${D.startMs}:${D.endMs}`).join("|")??w,[w,e]),[A,E]=(0,m.useState)(1);(0,m.useEffect)(()=>{v===void 0&&E(T)},[T,k,v]);const R=Math.max(1,v!==void 0?v:A),O=Math.max(1,Math.round(T/50)),M=(0,m.useMemo)(()=>FH({traceStartedAtMs:s,traceEndedAtMs:o,traceDurationMs:T}),[T,o,s]),[j,N]=(0,m.useState)("all"),P=c!==void 0?c:j,L=u??N,[B,H]=(0,m.useState)(new Set),[V,I]=(0,m.useState)(new Set),ne=h!==void 0?h:B,re=f??H,_=d!==void 0?d:V,U=p??I,[K,G]=(0,m.useState)(null),[$,J]=(0,m.useState)(null),[ae,he]=(0,m.useState)(null),se=(0,m.useRef)(null),Ye=(0,m.useRef)(null),[Le,rt]=(0,m.useState)(-1);(0,m.useLayoutEffect)(()=>{const D=Ye.current;if(!D)return;const ee=()=>{const Ce=D.getBoundingClientRect().width;rt(Number.isFinite(Ce)?Ce:0)};if(ee(),typeof ResizeObserver>"u")return;const ce=new ResizeObserver(ee);return ce.observe(D),()=>ce.disconnect()},[]);const qe=(0,m.useMemo)(()=>fH(Le),[Le]),gt=(0,m.useMemo)(()=>qe.length!==2?!1:Le<0||Le===0?!0:Le<hH,[Le,qe]);(0,m.useEffect)(()=>{l||(H(new Set(S.map(D=>D.key))),I(hy(S)))},[l,S]);const Me=(0,m.useMemo)(()=>{if(w!=="recorded")return[];const D=[],ee=new Set;function ce(ie){return P==="all"?!0:P==="error"?Fi(ie,i):ie.category===P}function Ce(ie,kt,st){const ln=ie.span.category==="step",Ct=ln?st:st+1,cn=ie.children.map(Tt=>Ce(Tt,kt,Ct)),Ss=cn.flatMap(Tt=>Tt.rows),ks=cn.some(Tt=>Tt.hasVisibleContent);if(ln)return{hasVisibleContent:ks||ie.children.length>0,rows:Ss};if(ie.span.category==="llm"&&typeof ie.span.totalTokens!="number"&&typeof ie.span.inputTokens!="number"&&typeof ie.span.outputTokens!="number"&&ie.span.endMs-ie.span.startMs<50)return{hasVisibleContent:!1,rows:[]};const Ln=ie.span.toolCallId,Cs=ie.span.category==="tool"&&!!Ln&&!ee.has(Ln);Cs&&Ln&&ee.add(Ln);const ra=Cs&&Ln?(C.get(Ln)??[]).filter(Tt=>P==="all"||P==="tool"?!0:P==="error"?ec(Tt)==="error":!1).map((Tt,$c)=>({kind:"interaction",key:`interaction-${ie.span.id}-${Tt.stepIndex}-${$c}`,promptIndex:kt,depth:st+1,step:Tt,startMs:ie.span.startMs,endMs:ie.span.endMs,status:ec(Tt)})):[];if(!(ce(ie.span)||ks||ra.length>0))return{hasVisibleContent:ks,rows:Ss};const Ts={kind:"span",key:ie.span.id,promptIndex:kt,depth:st,span:ie.span,hasChildren:ie.children.length>0,isExpanded:_.has(ie.span.id)};return{hasVisibleContent:!0,rows:[Ts,...Ts.hasChildren&&Ts.isExpanded?Ss:[],...ra]}}for(const ie of S){const kt=ie.roots.map(cn=>Ce(cn,ie.promptIndex,0)).flatMap(cn=>cn.rows);if(!(kt.length>0||P==="all"&&ie.spans.length>0))continue;const st=ie.spans.some(cn=>Fi(cn,i)),ln=IH(i,ie.messageStartIndex,ie.messageEndIndex),Ct=pH(ie.spans);D.push({kind:"prompt",key:ie.key,promptIndex:ie.promptIndex,label:ie.label,conversationLabel:ln?`User: "${ln}"`:void 0,startMs:ie.startMs,endMs:ie.endMs,messageStartIndex:ie.messageStartIndex,messageEndIndex:ie.messageEndIndex,counts:ie.counts,hasAnyFailure:st,isExpanded:ne.has(ie.key),aggregatedInputTokens:Ct.inputTokens,aggregatedOutputTokens:Ct.outputTokens,aggregatedTotalTokens:Ct.totalTokens}),ne.has(ie.key)&&D.push(...kt)}return D},[ne,_,P,S,C,w,i]),it=(0,m.useMemo)(()=>hy(S),[S]),Nr=(0,m.useMemo)(()=>{if(S.length===0)return!1;for(const D of S)if(!ne.has(D.key))return!1;for(const D of it)if(!_.has(D))return!1;return!0},[S,ne,_,it]);(0,m.useEffect)(()=>{if(Me.length===0){G(null);return}(!K||!Me.some(D=>D.key===K))&&G(Me[0].key)},[Me,K]);const ws=Me.find(D=>D.key===K),me=$?Me.find(D=>D.key===$):void 0,Y=$?Me.findIndex(D=>D.key===$):-1;(0,m.useEffect)(()=>{$&&!Me.some(D=>D.key===$)&&(J(null),he(null),se.current=null)},[$,Me]);const ye=(0,m.useCallback)(D=>{const ee=(D.querySelector('[data-testid="trace-row-glyph"]')??D).getBoundingClientRect();return{anchorX:ee.left+ee.width/2,anchorY:ee.top,anchorBottom:ee.bottom}},[]);(0,m.useEffect)(()=>{if(!$)return;const D=()=>{const ee=se.current;ee&&he(ye(ee))};return window.addEventListener("scroll",D,!0),window.addEventListener("resize",D),()=>{window.removeEventListener("scroll",D,!0),window.removeEventListener("resize",D)}},[$,ye]);const je=(0,m.useMemo)(()=>{if(!me)return null;const{startMs:D,endMs:ee}=ud(me),ce=me.kind==="span"&&Fi(me.span,i),Ce=me.kind==="span"?cd(me,i):null,ie=me.kind==="prompt"?me.conversationLabel??me.label:me.kind==="interaction"?us(me.step):Ce.title,kt=VH(me,e),st=me.kind==="prompt"?"prompt":me.kind==="interaction"?"interaction":me.span.category==="tool"&&ce?"error":me.span.category;return{label:ie,spanShowsFailure:ce,tokenStats:kt,rowStartTimestamp:M!==null?M+D:null,rowEndTimestamp:M!==null?M+ee:null,glyphCategory:st}},[me,e,M,i]),na=(0,m.useCallback)(D=>{if(Me.length===0)return;const ee=Me.findIndex(ce=>ce.key===K);if(D.key==="ArrowDown"){D.preventDefault();const ce=ee<0?0:Math.min(Me.length-1,ee+1);G(Me[ce].key);return}if(D.key==="ArrowUp"){D.preventDefault();const ce=ee<=0?0:ee-1;G(Me[ce].key);return}if(D.key==="Enter"&&ee>=0){const ce=Me[ee];if(ce.kind==="prompt"){D.preventDefault();const Ce=new Set(ne);Ce.has(ce.key)?Ce.delete(ce.key):Ce.add(ce.key),re(Ce);return}if(ce.kind==="span"&&ce.hasChildren){D.preventDefault();const Ce=new Set(_);Ce.has(ce.key)?Ce.delete(ce.key):Ce.add(ce.key),U(Ce)}}},[ne,_,Me,K,re,U]);if(w==="none")return(0,g.jsx)("div",{className:"text-xs text-muted-foreground",children:"No timing data recorded for this iteration."});if(w==="estimated")return(0,g.jsxs)("div",{className:"space-y-3",children:[(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)(Sb,{className:"border-warning/50 bg-warning/50 text-foreground",children:"Estimated total only"}),(0,g.jsx)("span",{className:"text-xs text-muted-foreground",children:co(n??0)})]}),(0,g.jsxs)("div",{className:"space-y-1 text-[11px] text-muted-foreground",children:[(0,g.jsx)("p",{children:"Per-step timing was not recorded for this run."}),r>0?(0,g.jsxs)("p",{children:["Conversation detail is in the Chat tab. Open"," ",(0,g.jsx)("span",{className:"font-medium text-foreground/80",children:"Raw"})," to inspect the stored trace and confirm whether a"," ",(0,g.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 vt=v===void 0?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Nt,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7 border-border/50",title:"Zoom in timeline","aria-label":"Zoom in timeline",disabled:A<=O,onClick:()=>E(D=>Math.max(O,Math.round(D*.8))),children:(0,g.jsx)(EI,{className:"size-3.5","aria-hidden":!0})}),(0,g.jsx)(Nt,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7 border-border/50",title:"Zoom out timeline","aria-label":"Zoom out timeline",disabled:A>=T*4,onClick:()=>E(D=>Math.min(T*4,Math.round(D*1.25))),children:(0,g.jsx)(CI,{className:"size-3.5","aria-hidden":!0})})]}):null;return(0,g.jsxs)("div",{className:X("space-y-2",x&&"flex min-h-0 flex-1 flex-col"),children:[l?null:(0,g.jsxs)("div",{className:x?"shrink-0":void 0,children:[(0,g.jsx)(cH,{filter:P,onFilterChange:L,isFullyExpanded:Nr,expandDisabled:S.length===0,zoomControls:vt,onToggleExpandAll:()=>{Nr?(re(new Set),U(new Set)):(re(new Set(S.map(D=>D.key))),U(new Set(it)))}}),(0,g.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:D,cls:ee})=>(0,g.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,g.jsx)("span",{className:X("h-2 w-2.5 rounded-sm",ee)}),D]},D))})]}),(0,g.jsx)("div",{className:X("@container/trace-timeline min-w-0",x&&"flex min-h-0 flex-1 flex-col"),children:(0,g.jsxs)($5,{direction:"vertical",className:X("rounded-lg border border-border/50 bg-background",x?"min-h-0 flex-1 overflow-hidden":"min-h-[min(25rem,calc(100dvh-8rem))]"),style:x?void 0:{height:"auto"},children:[(0,g.jsx)(ld,{defaultSize:65,minSize:0,className:"min-h-0 min-w-0 overflow-hidden",children:(0,g.jsx)(K5,{className:X(x?"h-full min-h-0 overflow-hidden":"max-h-[calc(100vh-8rem)] min-h-0"),children:(0,g.jsx)("div",{tabIndex:0,role:"region","aria-label":"Trace timeline. Use arrow keys to change selection, Enter to expand.",onKeyDown:na,className:"relative min-h-0 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:(0,g.jsxs)("div",{className:"grid pr-4",style:{gridTemplateColumns:"minmax(140px, 260px) minmax(0, 1fr) minmax(5.25rem, max-content)",gridTemplateRows:`auto repeat(${Me.length}, minmax(48px, auto))`},children:[(0,g.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,g.jsxs)("div",{className:"flex min-h-6 min-w-0 items-center gap-3",children:[(0,g.jsx)("div",{className:"shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground",children:"Trace"}),(0,g.jsx)("div",{className:"min-h-6 min-w-0 flex-1",children:(0,g.jsx)("div",{ref:Ye,className:"relative h-6 min-w-0",children:gt?(0,g.jsx)("div",{className:"flex h-full min-w-0 items-center justify-center",children:(0,g.jsx)("span",{className:"min-w-0 max-w-full truncate text-center text-[10px] tabular-nums text-muted-foreground",title:cy(R),children:cy(R)})}):qe.map(D=>{const ee=D>=100?"100%":`${D}%`;return(0,g.jsx)("div",{className:"pointer-events-none absolute inset-y-0",style:{left:ee},children:(0,g.jsx)("div",{className:X("absolute text-[10px] tabular-nums text-muted-foreground",dH(D)),children:vl(R*D/100)})},D)})})})]})}),(0,g.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,g.jsxs)("div",{className:"flex h-6 w-full min-w-0 items-center justify-start gap-1.5",children:[(0,g.jsx)(jm,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,g.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Latency"})]})}),Me.length>0?(0,g.jsx)("div",{className:"pointer-events-none relative z-0 bg-transparent",style:{gridColumn:2,gridRow:`2 / ${Me.length+2}`},children:qe.map(D=>(0,g.jsx)("div",{className:"absolute top-0 bottom-0 w-px bg-border/40",style:{left:D>=100?"100%":`${D}%`}},D))}):null,Me.map((D,ee)=>{const ce=D.key===K,{startMs:Ce,endMs:ie,durationMs:kt}=ud(D),st=Ce/R*100,ln=Math.max((ie-Ce)/R*100,.45),Ct=D.kind==="span"&&Fi(D.span,i),cn=D.kind==="prompt"?"prompt":D.kind==="interaction"?"interaction":D.span.category==="tool"&&Ct?"error":D.span.category,Ss=D.kind==="interaction"&&D.status==="error",ks=D.kind==="span"?cd(D,i):null,Ln=D.kind==="prompt"?D.conversationLabel??D.label:D.kind==="interaction"?us(D.step):ks.title,Cs=co(kt),ra=D.kind==="prompt"?!0:D.kind==="interaction"?!1:D.hasChildren||D.span.category==="llm",Ts=ee+2,Tt=TH(D,Ct),$c=kH(D,Ct),Yp=()=>{qI("trace_span_clicked",{location:"trace_timeline",span_kind:D.kind}),G(D.key)},Hc=At=>{At.stopPropagation(),Yp()},KC=ce?X("bg-transparent",Tt):"border-l-transparent bg-background group-hover:bg-muted/20 hover:bg-muted/20",Jp=ce?"bg-transparent":"bg-background group-hover:bg-muted/20 hover:bg-muted/20";return(0,g.jsxs)(cS.div,{"data-testid":"trace-row","data-state":ce?"selected":void 0,onClick:Yp,onMouseEnter:At=>{J(D.key);const Rt=At.currentTarget;se.current=Rt,he(ye(Rt))},onMouseLeave:()=>{J(At=>At===D.key?null:At),he(null),se.current=null},onFocus:At=>{J(D.key);const Rt=At.currentTarget;se.current=Rt,he(ye(Rt))},onBlur:At=>{At.currentTarget.contains(At.relatedTarget)||(J(Rt=>Rt===D.key?null:Rt),he(null),se.current=null)},initial:b||ee>=20?!1:{opacity:0,y:6},animate:{opacity:1,y:0},transition:b||ee>=20?{duration:0}:{duration:.15,delay:ee*.03+.05,ease:[.16,1,.3,1]},style:{gridColumn:"1 / 4",gridRow:Ts,display:"grid",gridTemplateColumns:"subgrid"},className:X("group min-h-0 min-w-0 cursor-pointer items-stretch",ce&&"trace-waterfall-row-selected ring-1 ring-inset ring-ring/40"),children:[(0,g.jsxs)("div",{className:X("flex items-center gap-2 border-b border-border/40 px-4 py-2 transition-all duration-150 border-l-2",KC),children:[(0,g.jsx)("div",{className:"flex shrink-0 items-center",style:{paddingLeft:D.kind==="prompt"?0:D.depth*16},children:ra?(0,g.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:At=>{if(At.stopPropagation(),D.kind==="prompt"){const ia=new Set(ne);ia.has(D.key)?ia.delete(D.key):ia.add(D.key),re(ia);return}const Rt=new Set(_);Rt.has(D.key)?Rt.delete(D.key):Rt.add(D.key),U(Rt)},"aria-label":D.kind==="prompt"?`${D.isExpanded?"Collapse":"Expand"} ${D.label}`:`${"isExpanded"in D&&D.isExpanded?"Collapse":"Expand"} ${Ln}`,children:"isExpanded"in D&&D.isExpanded?(0,g.jsx)(yb,{className:"h-3.5 w-3.5"}):(0,g.jsx)(Zi,{className:"h-3.5 w-3.5"})}):(0,g.jsx)("span",{className:"mr-1 h-5 w-5"})}),(0,g.jsx)("button",{type:"button","data-testid":"trace-row-label-button",className:"min-w-0 flex-1 text-left",onClick:Hc,children:(0,g.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,g.jsx)("span",{"data-testid":"trace-row-glyph",className:"inline-flex shrink-0 items-center",children:D.kind==="prompt"?(0,g.jsx)(hs,{category:"prompt"}):(0,g.jsx)(hs,{category:cn})}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:Ln}),D.kind==="prompt"&&D.hasAnyFailure?(0,g.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-destructive",title:"Contains errors","aria-label":"Contains errors"}):null,D.kind==="span"&&Ct||Ss?(0,g.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-destructive",title:"Error","aria-label":"Error"}):null]})})]}),(0,g.jsx)("button",{type:"button","data-testid":"trace-row-bar-hit","data-state":ce?"selected":void 0,className:X("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",Jp),"aria-label":`Select on timeline (${co(kt)})`,onClick:Hc,children:(0,g.jsx)("div",{"data-testid":D.kind==="span"&&Ct?"trace-row-bar-error":"trace-row-bar",className:X("absolute top-1/2 z-[1] h-4 min-w-0 -translate-y-1/2 rounded-[3px] transition-[left,width] duration-150",$c),style:{left:`${st}%`,width:`max(${ln}%, 3px)`}})}),(0,g.jsxs)("button",{type:"button","data-testid":"trace-row-duration-hit","data-state":ce?"selected":void 0,className:X("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",Jp),"aria-label":`Select row duration (${Cs})`,onClick:Hc,children:[(0,g.jsx)(jm,{className:"size-3 shrink-0 opacity-80","aria-hidden":!0}),Cs]})]},D.key)})]})})})}),(0,g.jsx)(H5,{withHandle:!0}),(0,g.jsx)(ld,{defaultSize:35,minSize:20,className:"min-h-0 min-w-0 overflow-hidden",children:(0,g.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,g.jsx)(WH,{row:ws,transcriptMessages:i,onRevealInTranscript:a,turnRuntimeByPromptIndex:y})})})]})}),me&&je&&ae?(0,g.jsx)(qH,{hoverPos:ae,info:je,placement:Y===0?"bottom":"top",reduceMotion:b??!1,rowKey:me.key}):null]})}function qH({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,_o.createPortal)((0,g.jsx)("div",{className:"pointer-events-none",style:d,children:(0,g.jsx)(cS.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,g.jsxs)("div",{"data-testid":"trace-row-hover-card",className:"space-y-3 p-3",children:[(0,g.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,g.jsx)(hs,{category:t.glyphCategory}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs font-semibold text-popover-foreground",children:t.label})]}),(0,g.jsxs)("div",{className:"space-y-1.5",children:[(0,g.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-popover-foreground/65",children:"Time"}),(0,g.jsxs)("div",{className:"space-y-1 text-xs",children:[(0,g.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,g.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"Start"}),(0,g.jsx)("span",{"data-testid":"trace-row-hover-start",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:dy(t.rowStartTimestamp)})]}),(0,g.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,g.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"End"}),(0,g.jsx)("span",{"data-testid":"trace-row-hover-end",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:dy(t.rowEndTimestamp)})]})]})]}),(0,g.jsxs)("div",{className:"space-y-1.5",children:[(0,g.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-popover-foreground/65",children:"Tokens"}),(0,g.jsxs)("div",{className:"space-y-1 text-xs",children:[(0,g.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,g.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"Input"}),(0,g.jsx)("span",{"data-testid":"trace-row-hover-input-tokens",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:nh(t.tokenStats.inputTokens)})]}),(0,g.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,g.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"Output"}),(0,g.jsx)("span",{"data-testid":"trace-row-hover-output-tokens",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:nh(t.tokenStats.outputTokens)})]}),(0,g.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,g.jsx)("span",{className:"shrink-0 text-popover-foreground/70",children:"Total"}),(0,g.jsx)("span",{"data-testid":"trace-row-hover-total-tokens",className:"min-w-0 text-right font-medium text-popover-foreground tabular-nums",children:nh(t.tokenStats.totalTokens)})]})]})]})]})},i)}),document.body)}export{GI as $,qT as $t,y_ as A,be as At,Se as B,Ux as Bt,c5 as C,rI as Ct,J$ as D,Ji as Dt,Z$ as E,yb as Et,Gj as F,NO as Ft,Sb as G,vx as Gt,ZI as H,vM as Ht,cS as I,rW as It,sW as J,Zy as Jt,vc as K,Cd as Kt,BL as L,LO as Lt,Hr as M,nW as Mt,Qj as N,tW as Nt,K$ as O,XO as Ot,$r as P,iW as Pt,KI as Q,Hy as Qt,Qw as R,ft as Rt,EW as S,jm as St,mC as T,Zi as Tt,YI as U,kx as Ut,Vd as V,yM as Vt,kb as W,gx as Wt,UI as X,Yy as Xt,wb as Y,LA as Yt,oW as Z,vd as Zt,$5 as _,mI as _t,cH as a,Nn as an,qI as at,PW as b,cI as bt,DW as c,te as cn,VI as ct,K5 as d,mT as dn,EI as dt,Ny as en,aW as et,G5 as f,_e as fn,MI as ft,ld as g,yI as gt,H5 as h,SI as ht,fH as i,ni as in,bb as it,zr as j,FO as jt,k_ as k,GO as kt,IW as l,fd as ln,_I as lt,Ns as m,CI as mt,AH as n,Qe as nn,uW as nt,iH as o,Vo as on,Bm as ot,OW as p,AI as pt,xb as q,lc as qt,hy as r,tc as rn,cW as rt,aH as s,Dt as sn,zI as st,LW as t,$T as tn,lW as tt,zC as u,rr as un,gc as ut,xC as v,dI as vt,RW as w,tI as wt,i5 as x,$i as xt,MW as y,hI as yt,iN as z,Bd as zt};
136
+
137
+ //# sourceMappingURL=trace-timeline-2WCodaTP.js.map