@mcpjam/inspector 3.12.9 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/bin/start.js +32 -6
  2. package/dist/client/assets/OAuthDesktopReturnNotice-BZEaGzn6.css +2 -0
  3. package/dist/client/assets/{OAuthDesktopReturnNotice-DlTJhJwy.js → OAuthDesktopReturnNotice-D5tJNqny.js} +2 -2
  4. package/dist/client/assets/{app-bootstrap-BtbHLWDU.js → app-bootstrap-baadQQNk.js} +351 -368
  5. package/dist/client/assets/{button-12hqsTUk.js → button-DHPqnOj6.js} +2 -2
  6. package/dist/client/assets/chunk-D32TOXHM-BPB6AqSK.js +160 -0
  7. package/dist/client/assets/dead-clicks-autocapture-Cbczl2El.js +3 -0
  8. package/dist/client/assets/{error-reporting-D3byeSLw.js → error-reporting-B4hGM_ob.js} +1 -1
  9. package/dist/client/assets/error-reporting-CORfsjyM.js +120 -0
  10. package/dist/client/assets/{exception-autocapture-CzpTtsxv.js → exception-autocapture-CMOUrnel.js} +4 -4
  11. package/dist/client/assets/{failed-request-tracker-CmHxaDPF.js → failed-request-tracker-DoQRXuIy.js} +2 -2
  12. package/dist/client/assets/highlighted-body-KQOG7T2V-_ljE4u1k.js +3 -0
  13. package/dist/client/assets/{index-C0SfPmai.js → index-BBr8TZVx.js} +3 -3
  14. package/dist/client/assets/{jszip.min-BmAHHtmZ.js → jszip.min-C-vIQbxH.js} +2 -2
  15. package/dist/client/assets/mermaid-MCJ5UELQ-DTJaEEBm.js +1 -0
  16. package/dist/client/assets/posthog-recorder-Dby9Z8HR.js +110 -0
  17. package/dist/client/assets/{preload-helper-B22rzauv.js → preload-helper-Dvt1a6xa.js} +2 -2
  18. package/dist/client/assets/{react-BzkNdoI5.js → react-CD7Pk4KS.js} +2 -2
  19. package/dist/client/assets/{rolldown-runtime-BNuWddGb.js → rolldown-runtime-mzU9SaVm.js} +1 -1
  20. package/dist/client/assets/surveys-DYqpu8xl.js +3 -0
  21. package/dist/client/assets/trace-timeline-PnE1ouRj.js +71 -0
  22. package/dist/client/assets/{trace-timeline-Bg58ukyI.js → trace-timeline-WXINST5z.js} +1 -1
  23. package/dist/client/assets/{web-vitals-D4bU8W1t.js → web-vitals-BLq6M5vx.js} +2 -2
  24. package/dist/client/index.html +8 -8
  25. package/dist/server/{chunk-DGAFFBDM.js → chunk-2FVSBJQF.js} +1470 -890
  26. package/dist/server/chunk-I7ZVTBZP.js +3100 -0
  27. package/dist/server/{chunk-SH24KJBI.js → chunk-MBS3EZ3U.js} +13 -2
  28. package/dist/server/{chunk-4PYR7GMQ.js → chunk-QHYREDE3.js} +4 -4
  29. package/dist/server/{consent-lifetime-M7PS6RUU.js → consent-lifetime-TYLDY64H.js} +3 -3
  30. package/dist/server/harness-install-cli.js +23 -6
  31. package/dist/server/index.js +21146 -18727
  32. package/dist/server/{local-turn-ZWMMQGV3.js → local-turn-VQDSTY6T.js} +4 -4
  33. package/package.json +38 -38
  34. package/dist/client/assets/OAuthDesktopReturnNotice-FnFv52Ym.css +0 -2
  35. package/dist/client/assets/chunk-YOKDWASO--Bd-6XAf.js +0 -145
  36. package/dist/client/assets/dead-clicks-autocapture-RCao2exY.js +0 -3
  37. package/dist/client/assets/error-reporting-StyhxjHz.js +0 -102
  38. package/dist/client/assets/highlighted-body-KPVGNVTW-BweERQbm.js +0 -3
  39. package/dist/client/assets/mermaid-HWGCJPDP-C6s_jIuz.js +0 -1
  40. package/dist/client/assets/posthog-recorder-wc41pimR.js +0 -110
  41. package/dist/client/assets/surveys-D-NcCeqw.js +0 -3
  42. package/dist/client/assets/trace-timeline-CxoCCEiW.js +0 -137
  43. package/dist/server/chunk-WZVZ6LQX.js +0 -2876
@@ -0,0 +1,71 @@
1
+ import{o as Fv}from"./rolldown-runtime-mzU9SaVm.js";import{t as _C}from"./react-CD7Pk4KS.js";import{a as BC,i as VC}from"./preload-helper-Dvt1a6xa.js";import{a as FC,i as zC,l as Ce,o as Fi,r as X,s as $C,t as Ot}from"./button-DHPqnOj6.js";import{Ci as Za,Di as zv,Gi as $u,Ki as Mc,Li as at,Oi as fn,Pi as sr,Pn as WC,Ri as hr,Ui as ge,Vi as ba,_n as HC,dn as Wu,fn as Sn,gn as qC,hn as UC,ki as He,kn as KC,mn as Dn,pn as el,t as GC}from"./error-reporting-CORfsjyM.js";import{a as QC,n as XC,s as YC}from"./chunk-D32TOXHM-BPB6AqSK.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.13.0"};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="79438cbb-b4a7-4eac-9555-13f3858a274a",e._sentryDebugIdIdentifier="sentry-dbid-79438cbb-b4a7-4eac-9555-13f3858a274a")}catch{}})();var m=Fv(_C(),1),ko=Fv(BC(),1),g=VC(),JC=Object.defineProperty,ZC=(e,t)=>JC(e,"name",{value:t,configurable:!0}),Ne=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=Fi(`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 Zf(e,t){e&&ko.flushSync(()=>e.dispatchEvent(t))}ZC(Zf,"dispatchDiscreteCustomEvent");var eT=Object.defineProperty,tT=(e,t)=>eT(e,"name",{value:t,configurable:!0}),nT=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"}),rT=m.forwardRef(tT(function(t,n){return(0,g.jsx)(Ne.span,{...t,ref:n,style:{...nT,...t.style}})},"VisuallyHidden")),iT=rT,sT=Object.defineProperty,It=(e,t)=>sT(e,"name",{value:t,configurable:!0});function oT(e,t){const n=m.createContext(t);n.displayName=e+"Context";const r=It(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 It(i,"useContext"),[r,i]}It(oT,"createContext");function Yn(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=It(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 It(u,"useContext"),[c,u]}It(r,"createContext");const i=It(()=>{const s=n.map(o=>m.createContext(o));return It(function(a){const l=a?.[e]||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])},"useScope")},"createScope");return i.scopeName=e,[r,$v(i,...t)]}It(Yn,"createContextScope");function $v(...e){const t=e[0];if(e.length===1)return t;const n=It(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return It(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}It($v,"composeContextScopes");var aT=Object.defineProperty,Ue=(e,t)=>aT(e,"name",{value:t,configurable:!0});function ed(e){const t=e+"CollectionProvider",[n,r]=Yn(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Ue(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=Fi(a),c=m.forwardRef((v,y)=>{const{scope:x,children:b}=v,w=s(a,x),S=Ce(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=Fi(u),d=m.forwardRef((v,y)=>{const{scope:x,children:b,...w}=v,S=m.useRef(null),C=Ce(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 Ue(p,"useCollection"),[{Provider:o,Slot:c,ItemSlot:d},p,r]}Ue(ed,"createCollection");var Lp=new WeakMap,Rc=class tr extends Map{static{Ue(this,"OrderedDict")}#e;constructor(t){super(t),this.#e=[...super.keys()],Lp.set(this,!0)}set(t,n){return Lp.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=td(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 tr(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=wa(this.#e,t);if(n!==void 0)return this.get(n)}entryAt(t){const n=wa(this.#e,t);if(n!==void 0)return[n,this.get(n)]}indexOf(t){return this.#e.indexOf(t)}keyAt(t){return wa(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 tr(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 tr(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 tr(n)}toReversed(){const t=new tr;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 tr(n)}slice(t,n){const r=new tr;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 wa(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=Wv(e,t);return n===-1?void 0:e[n]}Ue(wa,"at");function Wv(e,t){const n=e.length,r=td(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}Ue(Wv,"toSafeIndex");function td(e){return e!==e||e===0?0:Math.trunc(e)}Ue(td,"toSafeInteger");function lT(e){const t=e+"CollectionProvider",[n,r]=Yn(t),[i,s]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Rc,setItemMap:Ue(()=>{},"setItemMap")}),o=Ue(({state:b,...w})=>b?(0,g.jsx)(l,{...w,state:b}):(0,g.jsx)(a,{...w}),"CollectionProvider");o.displayName=t;const a=Ue(b=>{const w=y();return(0,g.jsx)(l,{...b,state:w})},"CollectionInit");a.displayName=t+"Init";const l=Ue(b=>{const{scope:w,children:S,state:C}=b,T=m.useRef(null),[k,A]=m.useState(null),M=Ce(T,A),[E,O]=C;return m.useEffect(()=>{if(!k)return;const R=Uv(()=>{});return R.observe(k,{childList:!0,subtree:!0}),()=>{R.disconnect()}},[k]),(0,g.jsx)(i,{scope:w,itemMap:E,setItemMap:O,collectionRef:M,collectionRefObject:T,collectionElement:k,children:S})},"CollectionProviderImpl");l.displayName=t+"Impl";const c=e+"CollectionSlot",u=Fi(c),h=m.forwardRef((b,w)=>{const{scope:S,children:C}=b,T=s(c,S),k=Ce(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=Fi(f),v=m.forwardRef((b,w)=>{const{scope:S,children:C,...T}=b,k=m.useRef(null),[A,M]=m.useState(null),E=Ce(w,k,M),{setItemMap:O}=s(f,S),R=m.useRef(T);Hv(R.current,T)||(R.current=T);const L=R.current;return m.useEffect(()=>{const N=L;return O(P=>A?P.has(A)?P.set(A,{...N,element:A}).toSorted(Hu):(P.set(A,{...N,element:A}),P.toSorted(Hu)):P),()=>{O(P=>!A||!P.has(A)?P:(P.delete(A),new Rc(P)))}},[A,L,O]),(0,g.jsx)(p,{[d]:"",ref:E,children:C})});v.displayName=f;function y(){return m.useState(new Rc)}Ue(y,"useInitCollection");function x(b){const{itemMap:w}=s(e+"CollectionConsumer",b);return w}return Ue(x,"useCollection"),[{Provider:o,Slot:h,ItemSlot:v},{createCollectionScope:r,useCollection:x,useInitCollection:y}]}Ue(lT,"createCollection");function Hv(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}Ue(Hv,"shallowEqual");function qv(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Ue(qv,"isElementPreceding");function Hu(e,t){return!e[1].element||!t[1].element?0:qv(e[1].element,t[1].element)?-1:1}Ue(Hu,"sortByDocumentPosition");function Uv(e){return new MutationObserver(t=>{for(const n of t)if(n.type==="childList"){e();return}})}Ue(Uv,"getChildListObserver");var cT=Object.defineProperty,es=(e,t)=>cT(e,"name",{value:t,configurable:!0}),Kv=!!(typeof window<"u"&&window.document&&window.document.createElement);function ne(e,t,{checkForDefaultPrevented:n=!0}={}){return es(function(i){if(e?.(i),n===!1||!i||!i.defaultPrevented)return t?.(i)},"handleEvent")}es(ne,"composeEventHandlers");function uT(e){if(!Kv)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}es(uT,"getOwnerWindow");function qu(e){if(!Kv)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}es(qu,"getOwnerDocument");function Gv(e,t=!1){const{activeElement:n}=qu(e);if(!n?.nodeName)return null;if(Qv(n)&&n.contentDocument)return Gv(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=qu(n).getElementById(r);if(i)return i}}return n}es(Gv,"getActiveElement");function Qv(e){return e.tagName==="IFRAME"}es(Qv,"isFrame");var Rt=globalThis?.document?m.useLayoutEffect:()=>{},hT=Object.defineProperty,fT=(e,t)=>hT(e,"name",{value:t,configurable:!0}),jp=m[" useEffectEvent ".trim().toString()],_p=m[" useInsertionEffect ".trim().toString()];function Xv(e){if(typeof jp=="function")return jp(e);const t=m.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof _p=="function"?_p(()=>{t.current=e}):Rt(()=>{t.current=e}),m.useMemo(()=>((...n)=>t.current?.(...n)),[])}fT(Xv,"useEffectEvent");var dT=Object.defineProperty,Co=(e,t)=>dT(e,"name",{value:t,configurable:!0}),pT=m[" useInsertionEffect ".trim().toString()]||Rt;function To({prop:e,defaultProp:t,onChange:n=Co(()=>{},"onChange"),caller:r}){const[i,s,o]=Yv({defaultProp:t,onChange:n}),a=e!==void 0;return[a?e:i,m.useCallback(c=>{if(a){const u=Jv(c)?c(e):c;u!==e&&o.current?.(u)}else s(c)},[a,e,s,o])]}Co(To,"useControllableState");function Yv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),i=m.useRef(n),s=m.useRef(t);return pT(()=>{s.current=t},[t]),m.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}Co(Yv,"useUncontrolledState");function Jv(e){return typeof e=="function"}Co(Jv,"isFunction");var Bp=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=Xv(o),u=[{...n,state:s}];r&&u.push(r);const[h,f]=m.useReducer((y,x)=>{if(x.type===Bp)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:Bp,state:i})},[i,h.state,l]),[v,f]}Co(mT,"useControllableStateReducer");var gT=Object.defineProperty,Kn=(e,t)=>gT(e,"name",{value:t,configurable:!0});function Zv(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}Kn(Zv,"useStateMachine");var An=Kn(e=>{const{present:t,children:n}=e,r=ey(t),i=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=ty(r.ref,ny(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]=Zv(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??mi(r.current),o.current=void 0):s.current="none"},[a]),Rt(()=>{const c=r.current,u=i.current;if(u!==e){const h=s.current,f=mi(c);e?(o.current=f,l("MOUNT")):f==="none"||c?.display==="none"?l("UNMOUNT"):l(u&&h!==f?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),Rt(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,h=Kn(d=>{const p=mi(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=Kn(d=>{d.target===t&&(s.current=mi(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=mi(u)}else r.current=null;n(c)},[])}}Kn(ey,"usePresence");function Uu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Kn(Uu,"setRef");function ty(...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=Uu(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():Uu(r[o],null)}}},[])}Kn(ty,"useStableComposedRefs");function mi(e){return e?.animationName||"none"}Kn(mi,"getAnimationName");function ny(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)}Kn(ny,"getElementRef");var vT=Object.defineProperty,yT=(e,t)=>vT(e,"name",{value:t,configurable:!0}),xT=m[" useId ".trim().toString()]||(()=>{}),bT=0;function Kr(e){const[t,n]=m.useState(xT());return Rt(()=>{e||n(r=>r??String(bT++))},[e]),e||(t?`radix-${t}`:"")}yT(Kr,"useId");var wT=Object.defineProperty,ST=(e,t)=>wT(e,"name",{value:t,configurable:!0}),kT=m.createContext(void 0);function Ll(e){const t=m.useContext(kT);return e||t||"ltr"}ST(Ll,"useDirection");var CT=Object.defineProperty,TT=(e,t)=>CT(e,"name",{value:t,configurable:!0});function Ge(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>((...n)=>t.current?.(...n)),[])}TT(Ge,"useCallbackRef");var AT=Object.defineProperty,qe=(e,t)=>AT(e,"name",{value:t,configurable:!0}),Ku="dismissableLayer.update",MT="dismissableLayer.pointerDownOutside",RT="dismissableLayer.focusOutside",Vp,ry=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),iy=m.forwardRef(qe(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...u}=t,h=m.useContext(ry),[f,d]=m.useState(null),p=f?.ownerDocument??globalThis?.document,[,v]=m.useState({}),y=Ce(n,d),x=Array.from(h.layers),[b]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),w=b?x.indexOf(b):-1,S=f?x.indexOf(f):-1,C=h.layersWithOutsidePointerEventsDisabled.size>0,T=S>=w,k=m.useRef(!1),A=sy(R=>{o?.(R),l?.(R),R.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:h.dismissableSurfaces,shouldHandlePointerDownOutside:m.useCallback(R=>{if(!(R instanceof Node))return!1;const L=[...h.branches].some(N=>N.contains(R));return T&&!L},[h.branches,T])}),M=oy(R=>{if(i&&k.current)return;const L=R.target;[...h.branches].some(N=>N.contains(L))||(a?.(R),l?.(R),R.defaultPrevented||c?.())},p),E=f?S===x.length-1:!1,O=Ge(R=>{R.key==="Escape"&&(s?.(R),!R.defaultPrevented&&c&&(R.preventDefault(),c()))});return m.useEffect(()=>{if(E)return p.addEventListener("keydown",O,{capture:!0}),()=>p.removeEventListener("keydown",O,{capture:!0})},[p,E,O]),m.useEffect(()=>{if(f)return r&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(Vp=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),Gu(),()=>{r&&(h.layersWithOutsidePointerEventsDisabled.delete(f),h.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=Vp))}},[f,p,r,h]),m.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),Gu())},[f,h]),m.useEffect(()=>{const R=qe(()=>v({}),"handleUpdate");return document.addEventListener(Ku,R),()=>document.removeEventListener(Ku,R)},[]),(0,g.jsx)(Ne.div,{...u,ref:y,style:{pointerEvents:C?T?"auto":"none":void 0,...t.style},onFocusCapture:ne(t.onFocusCapture,M.onFocusCapture),onBlurCapture:ne(t.onBlurCapture,M.onBlurCapture),onPointerDownCapture:ne(t.onPointerDownCapture,A.onPointerDownCapture)})},"DismissableLayer"));function ET(){const e=m.useContext(ry),[t,n]=m.useState(null);return m.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}qe(ET,"useDismissableLayerSurface");var PT=qe(()=>!0,"IS_TRUE");function sy(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:s,shouldHandlePointerDownOutside:o=PT}=t,a=Ge(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()}qe(f,"resetOutsideInteraction");function d(){return Array.from(u.current.values()).some(Boolean)}qe(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)}qe(p,"handleInteractionCapture");function v(w){c.current&&u.current.set(w.type,!1)}qe(v,"handleInteractionBubble");const y=qe(w=>{if(w.target&&!l.current){let S=function(){n.removeEventListener("click",h.current);const T=d();f(),T||nd(MT,a,C,{discrete:!0})};if(qe(S,"handleAndDispatchPointerDownOutsideEvent"),!o(w.target)){n.removeEventListener("click",h.current),f(),l.current=!1;return}const C={originalEvent:w};c.current=!0,i.current=r&&w.button===0,u.current.clear(),!r||w.button!==0?S():(n.removeEventListener("click",h.current),h.current=S,n.addEventListener("click",h.current,{once:!0}))}else n.removeEventListener("click",h.current),f();l.current=!1},"handlePointerDown"),x=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const w of x)n.addEventListener(w,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:qe(()=>l.current=!0,"onPointerDownCapture")}}qe(sy,"usePointerDownOutside");function oy(e,t=globalThis?.document){const n=Ge(e),r=m.useRef(!1);return m.useEffect(()=>{const i=qe(s=>{s.target&&!r.current&&nd(RT,n,{originalEvent:s},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:qe(()=>r.current=!0,"onFocusCapture"),onBlurCapture:qe(()=>r.current=!1,"onBlurCapture")}}qe(oy,"useFocusOutside");function Gu(){const e=new CustomEvent(Ku);document.dispatchEvent(e)}qe(Gu,"dispatchUpdate");function nd(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?Zf(i,s):i.dispatchEvent(s)}qe(nd,"handleAndDispatchCustomEvent");var OT=Object.defineProperty,ct=(e,t)=>OT(e,"name",{value:t,configurable:!0}),Ec="focusScope.autoFocusOnMount",Pc="focusScope.autoFocusOnUnmount",Fp={bubbles:!1,cancelable:!0},IT=m.forwardRef(ct(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:s,onUnmountAutoFocus:o,...a}=t,[l,c]=m.useState(null),u=Ge(s),h=Ge(o),f=m.useRef(null),d=Ce(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:In(f.current,{select:!0})},x=function(S){if(p.paused||!l)return;const C=S.relatedTarget;C!==null&&(l.contains(C)||In(f.current,{select:!0}))},b=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&In(l)};ct(y,"handleFocusIn"),ct(x,"handleFocusOut"),ct(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){zp.add(p);const y=document.activeElement;if(!l.contains(y)){const x=new CustomEvent(Ec,Fp);l.addEventListener(Ec,u),l.dispatchEvent(x),x.defaultPrevented||(ay(fy(rd(l)),{select:!0}),document.activeElement===y&&In(l))}return()=>{l.removeEventListener(Ec,u),setTimeout(()=>{const x=new CustomEvent(Pc,Fp);l.addEventListener(Pc,h),l.dispatchEvent(x),x.defaultPrevented||In(y??document.body,{select:!0}),l.removeEventListener(Pc,h),zp.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]=ly(w);S&&C?!y.shiftKey&&b===C?(y.preventDefault(),r&&In(S,{select:!0})):y.shiftKey&&b===S&&(y.preventDefault(),r&&In(C,{select:!0})):b===w&&y.preventDefault()}},[r,i,p.paused]);return(0,g.jsx)(Ne.div,{tabIndex:-1,...a,ref:d,onKeyDown:v})},"FocusScope"));function ay(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(In(r,{select:t}),document.activeElement!==n)return}ct(ay,"focusFirst");function ly(e){const t=rd(e);return[Qu(t,e),Qu(t.reverse(),e)]}ct(ly,"getTabbableEdges");function rd(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:ct(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}ct(rd,"getTabbableCandidates");function Qu(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):cy(r,{upTo:t})))return r}ct(Qu,"findVisible");function cy(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}ct(cy,"isHidden");function uy(e){return e instanceof HTMLInputElement&&"select"in e}ct(uy,"isSelectableInput");function In(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&uy(e)&&t&&e.select()}}ct(In,"focus");var zp=hy();function hy(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Xu(e,t),e.unshift(t)},remove(t){e=Xu(e,t),e[0]?.resume()}}}ct(hy,"createFocusScopesStack");function Xu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}ct(Xu,"arrayRemove");function fy(e){return e.filter(t=>t.tagName!=="A")}ct(fy,"removeLinks");var DT=Object.defineProperty,NT=(e,t)=>DT(e,"name",{value:t,configurable:!0}),dy=m.forwardRef(NT(function(t,n){const{container:r,...i}=t,[s,o]=m.useState(!1);Rt(()=>o(!0),[]);const a=r||s&&globalThis?.document?.body;return a?ko.createPortal((0,g.jsx)(Ne.div,{...i,ref:n}),a):null},"Portal")),LT=Object.defineProperty,id=(e,t)=>LT(e,"name",{value:t,configurable:!0}),zo=0,si=null;function jT(e){return sd(),e.children}id(jT,"FocusGuards");function sd(){m.useEffect(()=>{si||(si={start:Yu(),end:Yu()});const{start:e,end:t}=si;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),zo++,()=>{zo===1&&(si?.start.remove(),si?.end.remove(),si=null),zo=Math.max(0,zo-1)}},[])}id(sd,"useFocusGuards");function Yu(){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}id(Yu,"createFocusGuard");var pn=function(){return pn=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},pn.apply(this,arguments)};function py(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 _T(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 Sa="right-scroll-bar-position",ka="width-before-scroll-bar",BT="with-scroll-bars-hidden",VT="--removed-body-scroll-bar-size";function Oc(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function FT(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 zT=typeof window<"u"?m.useLayoutEffect:m.useEffect,$p=new WeakMap;function $T(e,t){var n=FT(t||null,function(r){return e.forEach(function(i){return Oc(i,r)})});return zT(function(){var r=$p.get(n);if(r){var i=new Set(r),s=new Set(e),o=n.current;i.forEach(function(a){s.has(a)||Oc(a,null)}),s.forEach(function(a){i.has(a)||Oc(a,o)})}$p.set(n,e)},[e]),n}function WT(e){return e}function HT(e,t){t===void 0&&(t=WT);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 qT(e){e===void 0&&(e={});var t=HT(null);return t.options=pn({async:!0,ssr:!1},e),t}var my=function(e){var t=e.sideCar,n=py(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,pn({},n))};my.isSideCarExport=!0;function UT(e,t){return e.useMedium(t),my}var gy=qT(),Ic=function(){},jl=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Ic,onWheelCapture:Ic,onTouchMoveCapture:Ic}),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=py(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,T=$T([n,t]),k=pn(pn({},S),i);return m.createElement(m.Fragment,null,u&&m.createElement(C,{sideCar:gy,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),pn(pn({},k),{ref:T})):m.createElement(b,pn({},k,{className:l,ref:T}),a))});jl.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};jl.classNames={fullWidth:ka,zeroRight:Sa};var Wp,KT=function(){if(Wp)return Wp;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function GT(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=KT();return t&&e.setAttribute("nonce",t),e}function QT(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function XT(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}var YT=function(){var e=0,t=null;return{add:function(n){e==0&&(t=GT())&&(QT(t,n),XT(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},JT=function(){var e=YT();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},vy=function(){var e=JT(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},ZT={left:0,top:0,right:0,gap:0},Dc=function(e){return parseInt(e||"",10)||0},eA=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[Dc(n),Dc(r),Dc(i)]},tA=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ZT;var t=eA(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])}},nA=vy(),Ds="data-scroll-locked",rA=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(BT,` {
3
+ overflow: hidden `).concat(r,`;
4
+ padding-right: `).concat(a,"px ").concat(r,`;
5
+ }
6
+ body[`).concat(Ds,`] {
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(Sa,` {
20
+ right: `).concat(a,"px ").concat(r,`;
21
+ }
22
+
23
+ .`).concat(ka,` {
24
+ margin-right: `).concat(a,"px ").concat(r,`;
25
+ }
26
+
27
+ .`).concat(Sa," .").concat(Sa,` {
28
+ right: 0 `).concat(r,`;
29
+ }
30
+
31
+ .`).concat(ka," .").concat(ka,` {
32
+ margin-right: 0 `).concat(r,`;
33
+ }
34
+
35
+ body[`).concat(Ds,`] {
36
+ `).concat(VT,": ").concat(a,`px;
37
+ }
38
+ `)},Hp=function(){var e=parseInt(document.body.getAttribute("data-scroll-locked")||"0",10);return isFinite(e)?e:0},iA=function(){m.useEffect(function(){return document.body.setAttribute(Ds,(Hp()+1).toString()),function(){var e=Hp()-1;e<=0?document.body.removeAttribute(Ds):document.body.setAttribute(Ds,e.toString())}},[])},sA=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;iA();var s=m.useMemo(function(){return tA(i)},[i]);return m.createElement(nA,{styles:rA(s,!t,i,n?"":"!important")})},Ju=!1;if(typeof window<"u")try{var $o=Object.defineProperty({},"passive",{get:function(){return Ju=!0,!0}});window.addEventListener("test",$o,$o),window.removeEventListener("test",$o,$o)}catch{Ju=!1}var oi=Ju?{passive:!1}:!1,oA=function(e){return e.tagName==="TEXTAREA"},yy=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!oA(e)&&n[t]==="visible")},aA=function(e){return yy(e,"overflowY")},lA=function(e){return yy(e,"overflowX")},qp=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host),xy(e,r)){var i=by(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},cA=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},uA=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},xy=function(e,t){return e==="v"?aA(t):lA(t)},by=function(e,t){return e==="v"?cA(t):uA(t)},hA=function(e,t){return e==="h"&&t==="rtl"?-1:1},fA=function(e,t,n,r,i){var s=hA(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=by(e,a),p=d[0],v=d[1]-d[2]-s*p;(p||v)&&xy(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},Wo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Up=function(e){return[e.deltaX,e.deltaY]},Kp=function(e){return e&&"current"in e?e.current:e},dA=function(e,t){return e[0]===t[0]&&e[1]===t[1]},pA=function(e){return`
39
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
40
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
41
+ `)},mA=0,ai=[];function gA(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),i=m.useState(mA++)[0],s=m.useState(vy)[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=_T([e.lockRef.current],(e.shards||[]).map(Kp),!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=Wo(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(),M=A&&A.anchorNode;if(M&&(M===T||M.contains(T)))return!1;var E=qp(k,T);if(!E)return!0;if(E?C=k:(C=k==="v"?"h":"v",E=qp(k,T)),!E)return!1;if(!r.current&&"changedTouches"in v&&(w||S)&&(r.current=C),!C)return!0;var O=r.current||C;return fA(O,y,v,O==="h"?w:S,!0)},[]),l=m.useCallback(function(v){var y=v;if(!(!ai.length||ai[ai.length-1]!==s)){var x="deltaY"in y?Up(y):Wo(y),b=t.current.filter(function(S){return S.name===y.type&&(S.target===y.target||y.target===S.shadowParent)&&dA(S.delta,x)})[0];if(b&&b.should){y.cancelable&&y.preventDefault();return}if(!b){var w=(o.current.shards||[]).map(Kp).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:vA(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=Wo(v),r.current=void 0},[]),h=m.useCallback(function(v){c(v.type,Up(v),v.target,a(v,e.lockRef.current))},[]),f=m.useCallback(function(v){c(v.type,Wo(v),v.target,a(v,e.lockRef.current))},[]);m.useEffect(function(){return ai.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",l,oi),document.addEventListener("touchmove",l,oi),document.addEventListener("touchstart",u,oi),function(){ai=ai.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,oi),document.removeEventListener("touchmove",l,oi),document.removeEventListener("touchstart",u,oi)}},[]);var d=e.removeScrollBar,p=e.inert;return m.createElement(m.Fragment,null,p?m.createElement(s,{styles:pA(i)}):null,d?m.createElement(sA,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function vA(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var yA=UT(gy,gA),wy=m.forwardRef(function(e,t){return m.createElement(jl,pn({},e,{ref:t,sideCar:yA}))});wy.classNames=jl.classNames;var xA=function(e){return typeof document>"u"?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},li=new WeakMap,Ho=new WeakMap,qo={},Nc=0,Sy=function(e){return e&&(e.host||Sy(e.parentNode))},bA=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Sy(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})},wA=function(e,t,n,r){var i=bA(t,Array.isArray(e)?e:[e]);qo[n]||(qo[n]=new WeakMap);var s=qo[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=(li.get(f)||0)+1,y=(s.get(f)||0)+1;li.set(f,v),s.set(f,y),o.push(f),v===1&&p&&Ho.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(),Nc++,function(){o.forEach(function(h){var f=li.get(h)-1,d=s.get(h)-1;li.set(h,f),s.set(h,d),f||(Ho.has(h)||h.removeAttribute(r),Ho.delete(h)),d||h.removeAttribute(n)}),Nc--,Nc||(li=new WeakMap,li=new WeakMap,Ho=new WeakMap,qo={})}},SA=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||xA(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),wA(r,i,n,"aria-hidden")):function(){return null}},kA=Object.defineProperty,CA=(e,t)=>kA(e,"name",{value:t,configurable:!0});function ky(e){const[t,n]=m.useState(void 0);return Rt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=e.offsetWidth,a=e.offsetHeight;n({width:o,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}CA(ky,"useSize");var TA=["top","right","bottom","left"],fr=Math.min,Wn=Math.max,tl=Math.round,Uo=Math.floor,Hn=e=>({x:e,y:e}),AA={left:"right",right:"left",bottom:"top",top:"bottom"};function Cy(e,t,n){return Wn(e,fr(t,n))}function Gn(e,t){return typeof e=="function"?e(t):e}function dr(e){return e.split("-")[0]}function ts(e){return e.split("-")[1]}function od(e){return e==="x"?"y":"x"}function ad(e){return e==="y"?"height":"width"}function gn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ld(e){return od(gn(e))}function MA(e,t,n){n===void 0&&(n=!1);const r=ts(e),i=ld(e),s=ad(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=nl(o)),[o,nl(o)]}function RA(e){const t=nl(e);return[Zu(e),t,Zu(t)]}function Zu(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var Gp=["left","right"],Qp=["right","left"],EA=["top","bottom"],PA=["bottom","top"];function OA(e,t,n){switch(e){case"top":case"bottom":return n?t?Qp:Gp:t?Gp:Qp;case"left":case"right":return t?EA:PA;default:return[]}}function IA(e,t,n,r){const i=ts(e);let s=OA(dr(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(Zu)))),s}function nl(e){const t=dr(e);return AA[t]+e.slice(t.length)}function DA(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 Ty(e){return typeof e!="number"?DA(e):{top:e,right:e,bottom:e,left:e}}function rl(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 Xp(e,t,n){let{reference:r,floating:i}=e;const s=gn(t),o=ld(t),a=ad(o),l=dr(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=ts(t);return p&&(d[o]+=f*(p==="end"?1:-1)*(n&&c?-1:1)),d}async function NA(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}=Gn(t,e),p=Ty(d),v=a[f?h==="floating"?"reference":"floating":h],y=rl(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=rl(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 LA=50,jA=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:NA},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}=Xp(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<LA&&(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}=Xp(c,f,l)),v=-1)}return{x:u,y:h,placement:f,strategy:i,middlewareData:p}},_A=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}=Gn(e,t)||{};if(c==null)return{};const h=Ty(u),f={x:n,y:r},d=ld(i),p=ad(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,M=k/2-v[p]/2-1,E=fr(h[x],M),O=fr(h[b],M),R=k-v[p]-O,L=k/2-v[p]/2+A,N=Cy(E,L,R),P=!l.arrow&&ts(i)!=null&&L!==N&&s.reference[p]/2-(L<E?E:O)-v[p]/2<0,j=P?L<E?L-E:L-R:0;return{[d]:f[d]+j,data:{[d]:N,centerOffset:L-N-j,...P&&{alignmentOffset:j}},reset:P}}}),BA=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}=Gn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=dr(i),b=gn(a),w=dr(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=f||(w||!v?[nl(a)]:RA(a)),T=p!=="none";!f&&T&&C.push(...IA(a,v,p,S));const k=[a,...C],A=await l.detectOverflow(t,y),M=[];let E=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&M.push(A[x]),h){const N=MA(i,o,S);M.push(A[N[0]],A[N[1]])}if(E=[...E,{placement:i,overflows:M}],!M.every(N=>N<=0)){var O,R;const N=(((O=s.flip)==null?void 0:O.index)||0)+1,P=k[N];if(P&&(!(h==="alignment"&&b!==gn(P))||E.every(V=>gn(V.placement)===b?V.overflows[0]>0:!0)))return{data:{index:N,overflows:E},reset:{placement:P}};let j=(R=E.filter(V=>V.overflows[0]<=0).sort((V,W)=>V.overflows[1]-W.overflows[1])[0])==null?void 0:R.placement;if(!j)switch(d){case"bestFit":{var L;const V=(L=E.filter(W=>{if(T){const B=gn(W.placement);return B===b||B==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(B=>B>0).reduce((B,D)=>B+D,0)]).sort((W,B)=>W[1]-B[1])[0])==null?void 0:L[0];V&&(j=V);break}case"initialPlacement":j=a}if(i!==j)return{reset:{placement:j}}}return{}}}};function Yp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Jp(e){return TA.some(t=>e[t]>=0)}var VA=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=Gn(e,t);switch(i){case"referenceHidden":{const o=Yp(await r.detectOverflow(t,{...s,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Jp(o)}}}case"escaped":{const o=Yp(await r.detectOverflow(t,{...s,altBoundary:!0}),n.floating);return{data:{escapedOffsets:o,escaped:Jp(o)}}}default:return{}}}}},Ay=new Set(["left","top"]);async function FA(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=dr(n),a=ts(n),l=gn(n)==="y",c=Ay.has(o)?-1:1,u=s&&l?-1:1,h=Gn(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 zA=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 FA(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}}}}},$A=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}=Gn(e,t),u={x:n,y:r},h=await s.detectOverflow(t,c),f=gn(i),d=od(f);let p=u[d],v=u[f];const y=(b,w)=>Cy(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}}}}}},WA=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}=Gn(e,t),f={x:i,y:s},d=gn(o),p=od(d);let v=f[p],y=f[d];const x=Gn(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=Ay.has(dr(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}}}},HA=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}=Gn(e,t),l=await i.detectOverflow(t,a),c=dr(n),u=ts(n),h=gn(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=fr(d-l[p],y),w=fr(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*Wn(l.left,l.right):T=d-2*Wn(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 _l(){return typeof window<"u"}function ns(e){return My(e)?(e.nodeName||"").toLowerCase():"#document"}function gt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Jn(e){var t;return(t=(My(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function My(e){return _l()?e instanceof Node||e instanceof gt(e).Node:!1}function kn(e){return _l()?e instanceof Element||e instanceof gt(e).Element:!1}function wr(e){return _l()?e instanceof HTMLElement||e instanceof gt(e).HTMLElement:!1}function Zp(e){return!_l()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof gt(e).ShadowRoot}function Bl(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Cn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function qA(e){return/^(table|td|th)$/.test(ns(e))}function Vl(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var UA=/transform|translate|scale|rotate|perspective|filter/,KA=/paint|layout|strict|content/,Ar=e=>!!e&&e!=="none",Lc;function cd(e){const t=kn(e)?Cn(e):e;return Ar(t.transform)||Ar(t.translate)||Ar(t.scale)||Ar(t.rotate)||Ar(t.perspective)||!ud()&&(Ar(t.backdropFilter)||Ar(t.filter))||UA.test(t.willChange||"")||KA.test(t.contain||"")}function GA(e){let t=Gr(e);for(;wr(t)&&!Ks(t);){if(cd(t))return t;if(Vl(t))return null;t=Gr(t)}return null}function ud(){return Lc==null&&(Lc=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Lc}function Ks(e){return/^(html|body|#document)$/.test(ns(e))}function Cn(e){return gt(e).getComputedStyle(e)}function Fl(e){return kn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Gr(e){if(ns(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Zp(e)&&e.host||Jn(e);return Zp(t)?t.host:t}function Ry(e){const t=Gr(e);return Ks(t)?(e.ownerDocument||e).body:wr(t)&&Bl(t)?t:Ry(t)}function Gs(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=Ry(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=gt(i);if(s){const a=eh(o);return t.concat(o,o.visualViewport||[],Bl(i)?i:[],a&&n?Gs(a):[])}else return t.concat(i,Gs(i,[],n))}function eh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ey(e){const t=Cn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=wr(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=tl(n)!==s||tl(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function hd(e){return kn(e)?e:e.contextElement}function Oi(e){const t=hd(e);if(!wr(t))return Hn(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=Ey(t);let o=(s?tl(n.width):n.width)/r,a=(s?tl(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}var QA=Hn(0);function Py(e){const t=gt(e);return!ud()||!t.visualViewport?QA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function XA(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===gt(e)}function Qr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=hd(e);let o=Hn(1);t&&(r?kn(r)&&(o=Oi(r)):o=Oi(e));const a=XA(s,n,r)?Py(s):Hn(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=gt(s),d=kn(r)?gt(r):r;let p=f,v=eh(p);for(;v&&d!==p;){const y=Oi(v),x=v.getBoundingClientRect(),b=Cn(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=gt(v),v=eh(p)}}return rl({width:u,height:h,x:l,y:c})}function zl(e,t){const n=Fl(e).scrollLeft;return t?t.left+n:Qr(Jn(e)).left+n}function Oy(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-zl(e,n),y:n.top+t.scrollTop}}function YA(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=Jn(r),a=t?Vl(t.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Hn(1);const u=Hn(0),h=wr(r);if((h||!s)&&((ns(r)!=="body"||Bl(o))&&(l=Fl(r)),h)){const d=Qr(r);c=Oi(r),u.x=d.x+r.clientLeft,u.y=d.y+r.clientTop}const f=o&&!h&&!s?Oy(o,l):Hn(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 JA(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function ZA(e){const t=Fl(e),n=e.ownerDocument.body,r=Wn(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Wn(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+zl(e);const o=-t.scrollTop;return Cn(n).direction==="rtl"&&(s+=Wn(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:s,y:o}}var eM=25;function tM(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=gt(e),s=Jn(e),o=i.visualViewport;let a=s.clientWidth,l=s.clientHeight,c=0,u=0;if(o){const h=!ud()||t==="fixed";r?h||(c=-o.offsetLeft,u=-o.offsetTop):(a=o.width,l=o.height,h&&(c=o.offsetLeft,u=o.offsetTop))}if(zl(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<=eM&&(a-=y)}return{width:a,height:l,x:c,y:u}}function nM(e,t){const n=Qr(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Oi(e);return{width:e.clientWidth*s.x,height:e.clientHeight*s.y,x:i*s.x,y:r*s.y}}function em(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=tM(e,n,t);else if(t==="document")r=ZA(Jn(e));else if(kn(t))r=nM(t,n);else{const i=Py(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return rl(r)}function rM(e,t){const n=t.get(e);if(n)return n;let r=Gs(e,[],!1).filter(a=>kn(a)&&ns(a)!=="body"),i=null;const s=Cn(e).position==="fixed";let o=s?Gr(e):e;for(;kn(o)&&!Ks(o);){const a=Cn(o),l=cd(o),c=i?i.position:s?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?r=r.filter(u=>u!==o):i=a,o=Gr(o)}return t.set(e,r),r}function iM(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const s=[...n==="clippingAncestors"?Vl(t)?[]:rM(t,this._c):[].concat(n),r],o=em(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=em(t,s[h],i);a=Wn(f.top,a),l=fr(f.right,l),c=fr(f.bottom,c),u=Wn(f.left,u)}return{width:l-u,height:c-a,x:u,y:a}}function sM(e){const{width:t,height:n}=Ey(e);return{width:t,height:n}}function oM(e,t,n){const r=wr(t),i=Jn(t),s=n==="fixed",o=Qr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Hn(0);if((r||!s)&&((ns(t)!=="body"||Bl(i))&&(a=Fl(t)),r)){const u=Qr(t,!0,s,t);l.x=u.x+t.clientLeft,l.y=u.y+t.clientTop}!r&&i&&(l.x=zl(i));const c=i&&!r&&!s?Oy(i,a):Hn(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 jc(e){return Cn(e).position==="static"}function tm(e,t){if(!wr(e)||Cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Jn(e)===n&&(n=n.ownerDocument.body),n}function Iy(e,t){const n=gt(e);if(Vl(e))return n;if(!wr(e)){let i=Gr(e);for(;i&&!Ks(i);){if(kn(i)&&!jc(i))return i;i=Gr(i)}return n}let r=tm(e,t);for(;r&&qA(r)&&jc(r);)r=tm(r,t);return r&&Ks(r)&&jc(r)&&!cd(r)?n:r||GA(e)||n}var aM=async function(e){const t=this.getOffsetParent||Iy,n=this.getDimensions,r=await n(e.floating);return{reference:oM(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function lM(e){return Cn(e).direction==="rtl"}var cM={convertOffsetParentRelativeRectToViewportRelativeRect:YA,getDocumentElement:Jn,getClippingRect:iM,getOffsetParent:Iy,getElementRects:aM,getClientRects:JA,getDimensions:sM,getScale:Oi,isElement:kn,isRTL:lM};function Dy(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function uM(e,t,n){let r=null,i;const s=Jn(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=Uo(p),b=Uo(s.clientWidth-(d+v)),w=Uo(s.clientHeight-(p+y)),S=Uo(d),C={rootMargin:-x+"px "+-b+"px "+-w+"px "+-S+"px",threshold:Wn(0,fr(1,h))||1};let T=!0;function k(A){const M=A[0].intersectionRatio;if(!Dy(f,e.getBoundingClientRect()))return a();if(M!==h){if(!T)return a();M?a(!1,M):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=gt(e),c=()=>a(n);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),o()}}function hM(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=hd(e),u=i||s?[...c?Gs(c):[],...t?Gs(t):[]]:[];u.forEach(x=>{i&&x.addEventListener("scroll",n),s&&x.addEventListener("resize",n)});const h=c&&a?uM(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?Qr(e):null;l&&y();function y(){const x=Qr(e);v&&!Dy(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 fM=zA,dM=$A,pM=BA,mM=HA,gM=VA,nm=_A,vM=WA,yM=(e,t,n)=>{const r=new Map,i=n??{},s={...cM,...i.platform,_c:r};return jA(e,t,{...i,platform:s})},Ca=typeof document<"u"?m.useLayoutEffect:function(){};function il(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(!il(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)&&!il(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ny(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function rm(e,t){const n=Ny(e);return Math.round(t*n)/n}function _c(e){const t=m.useRef(e);return Ca(()=>{t.current=e}),t}function xM(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);il(f,r)||d(r);const[p,v]=m.useState(null),[y,x]=m.useState(null),b=m.useCallback(W=>{W!==T.current&&(T.current=W,v(W))},[]),w=m.useCallback(W=>{W!==k.current&&(k.current=W,x(W))},[]),S=s||p,C=o||y,T=m.useRef(null),k=m.useRef(null),A=m.useRef(u),M=l!=null,E=_c(l),O=_c(i),R=_c(c),L=m.useCallback(()=>{if(!T.current||!k.current)return;const W={placement:t,strategy:n,middleware:f};O.current&&(W.platform=O.current),yM(T.current,k.current,W).then(B=>{const D={...B,isPositioned:R.current!==!1};N.current&&!il(A.current,D)&&(A.current=D,ko.flushSync(()=>{h(D)}))})},[f,t,n,O,R]);Ca(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,h(W=>({...W,isPositioned:!1})))},[c]);const N=m.useRef(!1);Ca(()=>(N.current=!0,()=>{N.current=!1}),[]),Ca(()=>{if(S&&(T.current=S),C&&(k.current=C),S&&C){if(E.current)return E.current(S,C,L);L()}},[S,C,L,E,M]);const P=m.useMemo(()=>({reference:T,floating:k,setReference:b,setFloating:w}),[b,w]),j=m.useMemo(()=>({reference:S,floating:C}),[S,C]),V=m.useMemo(()=>{const W={position:n,left:0,top:0};if(!j.floating)return W;const B=rm(j.floating,u.x),D=rm(j.floating,u.y);return a?{...W,transform:"translate("+B+"px, "+D+"px)",...Ny(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:B,top:D}},[n,a,j.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:L,refs:P,elements:j,floatingStyles:V}),[u,L,P,j,V])}var bM=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?nm({element:r.current,padding:i}).fn(n):{}:r?nm({element:r,padding:i}).fn(n):{}}}},wM=(e,t)=>{const n=fM(e);return{name:n.name,fn:n.fn,options:[e,t]}},SM=(e,t)=>{const n=dM(e);return{name:n.name,fn:n.fn,options:[e,t]}},kM=(e,t)=>({fn:vM(e).fn,options:[e,t]}),CM=(e,t)=>{const n=pM(e);return{name:n.name,fn:n.fn,options:[e,t]}},TM=(e,t)=>{const n=mM(e);return{name:n.name,fn:n.fn,options:[e,t]}},AM=(e,t)=>{const n=gM(e);return{name:n.name,fn:n.fn,options:[e,t]}},MM=(e,t)=>{const n=bM(e);return{name:n.name,fn:n.fn,options:[e,t]}},RM=Object.defineProperty,EM=(e,t)=>RM(e,"name",{value:t,configurable:!0}),PM=m.forwardRef(EM(function(t,n){const{children:r,width:i=10,height:s=5,...o}=t;return(0,g.jsx)(Ne.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")),OM=PM,IM=Object.defineProperty,qn=(e,t)=>IM(e,"name",{value:t,configurable:!0}),Ly="Popper",[jy,$l]=Yn(Ly),[DM,_y]=jy(Ly),NM=qn(e=>{const{__scopePopper:t,children:n}=e,[r,i]=m.useState(null),[s,o]=m.useState(void 0);return(0,g.jsx)(DM,{scope:t,anchor:r,onAnchorChange:i,placementState:s,setPlacementState:o,children:n})},"Popper"),LM="PopperAnchor",jM=m.forwardRef(qn(function(t,n){const{__scopePopper:r,virtualRef:i,...s}=t,o=_y(LM,r),a=m.useRef(null),l=o.onAnchorChange,c=m.useCallback(v=>{a.current=v,v&&l(v)},[l]),u=Ce(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&&Wl(o.placementState),d=f?.[0],p=f?.[1];return i?null:(0,g.jsx)(Ne.div,{"data-radix-popper-side":d,"data-radix-popper-align":p,...s,ref:u})},"PopperAnchor")),By="PopperContent",[_M,BM]=jy(By),VM=m.forwardRef(qn(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=_y(By,r),[b,w]=m.useState(null),S=Ce(n,w),[C,T]=m.useState(null),k=ky(C),A=k?.width??0,M=k?.height??0,E=i+(o!=="center"?"-"+o:""),O=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},R=Array.isArray(u)?u:[u],L=R.length>0,N={padding:O,boundary:R.filter(Vy),altBoundary:L},{refs:P,floatingStyles:j,placement:V,isPositioned:W,middlewareData:B}=xM({strategy:"fixed",placement:E,whileElementsMounted:qn((...ae)=>hM(...ae,{animationFrame:p==="always"}),"whileElementsMounted"),elements:{reference:x.anchor},middleware:[wM({mainAxis:s+M,alignmentAxis:a}),c&&SM({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?kM():void 0,...N}),c&&CM({...N}),TM({...N,apply:qn(({elements:ae,rects:ue,availableWidth:se,availableHeight:Xe})=>{const{width:Ie,height:tt}=ue.reference,We=ae.floating.style;We.setProperty("--radix-popper-available-width",`${se}px`),We.setProperty("--radix-popper-available-height",`${Xe}px`),We.setProperty("--radix-popper-anchor-width",`${Ie}px`),We.setProperty("--radix-popper-anchor-height",`${tt}px`)},"apply")}),C&&MM({element:C,padding:l}),WM({arrowWidth:A,arrowHeight:M}),d&&AM({strategy:"referenceHidden",...N,boundary:L?N.boundary:void 0})]}),D=x.setPlacementState;Rt(()=>(D(V),()=>{D(void 0)}),[V,D]);const[te,re]=Wl(V),_=Ge(v);Rt(()=>{W&&_?.()},[W,_]);const U=B.arrow?.x,K=B.arrow?.y,G=B.arrow?.centerOffset!==0,[$,J]=m.useState();return Rt(()=>{b&&J(window.getComputedStyle(b).zIndex)},[b]),(0,g.jsx)("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...j,transform:W?j.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[B.transformOrigin?.x,B.transformOrigin?.y].join(" "),...B.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:(0,g.jsx)(_M,{scope:r,placedSide:te,placedAlign:re,onArrowChange:T,arrowX:U,arrowY:K,shouldHideArrow:G,children:(0,g.jsx)(Ne.div,{"data-side":te,"data-align":re,...y,ref:S,style:{...y.style,animation:W?y.style?.animation:"none"}})})})},"PopperContent")),FM="PopperArrow",zM={top:"bottom",right:"left",bottom:"top",left:"right"},$M=m.forwardRef(qn(function(t,n){const{__scopePopper:r,...i}=t,s=BM(FM,r),o=zM[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)(OM,{...i,ref:n,style:{...i.style,display:"block"}})})},"PopperArrow"));function Vy(e){return e!==null}qn(Vy,"isNotNull");var WM=qn(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]=Wl(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 Wl(e){const[t,n="center"]=e.split("-");return[t,n]}qn(Wl,"getSideAndAlignFromPlacement");var fd=NM,Fy=jM,zy=VM,HM=$M,qM=Object.defineProperty,dd=(e,t)=>qM(e,"name",{value:t,configurable:!0}),Bc=!1;function $y(){const[e,t]=m.useState(Bc);return m.useEffect(()=>{Bc||(Bc=!0,t(!0))},[]),e}dd($y,"useIsHydrated");var Wy=m[" useSyncExternalStore ".trim().toString()];function Hy(){return()=>{}}dd(Hy,"subscribe");function qy(){return Wy(Hy,()=>!0,()=>!1)}dd(qy,"useIsHydratedModern");var UM=typeof Wy=="function"?qy:$y,KM=Object.defineProperty,ni=(e,t)=>KM(e,"name",{value:t,configurable:!0}),Vc="rovingFocusGroup.onEntryFocus",GM={bubbles:!1,cancelable:!0},Hl="RovingFocusGroup",[th,Uy,QM]=ed(Hl),[XM,Ky]=Yn(Hl,[QM]),[YM,JM]=XM(Hl),ZM=m.forwardRef(ni(function(t,n){return(0,g.jsx)(th.Provider,{scope:t.__scopeRovingFocusGroup,children:(0,g.jsx)(th.Slot,{scope:t.__scopeRovingFocusGroup,children:(0,g.jsx)(eR,{...t,ref:n})})})},"RovingFocusGroup")),eR=m.forwardRef(ni(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=Ce(n,d),v=Ll(o),[y,x]=To({prop:a,defaultProp:l??null,onChange:c,caller:Hl}),[b,w]=m.useState(!1),S=Ge(u),C=Uy(r),T=m.useRef(!1),[k,A]=m.useState(0);return m.useEffect(()=>{const M=d.current;if(M)return M.addEventListener(Vc,S),()=>M.removeEventListener(Vc,S)},[S]),(0,g.jsx)(YM,{scope:r,orientation:i,dir:v,loop:s,currentTabStopId:y,onItemFocus:m.useCallback(M=>x(M),[x]),onItemShiftTab:m.useCallback(()=>w(!0),[]),onFocusableItemAdd:m.useCallback(()=>A(M=>M+1),[]),onFocusableItemRemove:m.useCallback(()=>A(M=>M-1),[]),children:(0,g.jsx)(Ne.div,{tabIndex:b||k===0?-1:0,"data-orientation":i,...f,ref:p,style:{outline:"none",...t.style},onMouseDown:ne(t.onMouseDown,()=>{T.current=!0}),onFocus:ne(t.onFocus,M=>{const E=!T.current;if(M.target===M.currentTarget&&E&&!b){const O=new CustomEvent(Vc,GM);if(M.currentTarget.dispatchEvent(O),!O.defaultPrevented){const R=C().filter(L=>L.focusable);pd([R.find(L=>L.active),R.find(L=>L.id===y),...R].filter(Boolean).map(L=>L.ref.current),h)}}T.current=!1}),onBlur:ne(t.onBlur,()=>w(!1))})})},"RovingFocusGroupImpl")),tR="RovingFocusGroupItem",nR=m.forwardRef(ni(function(t,n){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:s=!1,tabStopId:o,children:a,...l}=t,c=Kr(),u=o||c,h=JM(tR,r),f=h.currentTabStopId===u,d=Uy(r),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:y}=h,x=UM();return Rt(()=>{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)(th.ItemSlot,{scope:r,id:u,focusable:i,active:s,children:(0,g.jsx)(Ne.span,{tabIndex:f?0:-1,"data-orientation":h.orientation,...l,ref:n,onMouseDown:ne(t.onMouseDown,b=>{i?h.onItemFocus(u):b.preventDefault()}),onFocus:ne(t.onFocus,()=>h.onItemFocus(u)),onKeyDown:ne(t.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){h.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const w=Qy(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?Xy(S,C+1):S.slice(C+1)}setTimeout(()=>pd(S))}}),children:typeof a=="function"?a({isCurrentTabStop:f,hasTabStop:y!=null}):a})})},"RovingFocusGroupItem")),rR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Gy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}ni(Gy,"getDirectionAwareKey");function Qy(e,t,n){const r=Gy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return rR[r]}ni(Qy,"getFocusIntent");function pd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}ni(pd,"focusFirst");function Xy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}ni(Xy,"wrapArray");var iR=ZM,sR=nR,oR=Object.defineProperty,de=(e,t)=>oR(e,"name",{value:t,configurable:!0}),nh=["Enter"," "],aR=["ArrowDown","PageUp","Home"],Yy=["ArrowUp","PageDown","End"],lR=[...aR,...Yy],cR={ltr:[...nh,"ArrowRight"],rtl:[...nh,"ArrowLeft"]},uR={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ql="Menu",[Qs,hR,fR]=ed(ql),[ri,Jy]=Yn(ql,[fR,$l,Ky]),Ul=$l(),Zy=Ky(),[ex,Sr]=ri(ql),[dR,Ao]=ri(ql),pR=de(e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Ul(t),[l,c]=m.useState(null),u=m.useRef(!1),h=Ge(s),f=Ll(i);return m.useEffect(()=>{const d=de(()=>{u.current=!0,document.addEventListener("pointerdown",p,{capture:!0,once:!0}),document.addEventListener("pointermove",p,{capture:!0,once:!0})},"handleKeyDown"),p=de(()=>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=de(()=>h(!1),"handleBlur");return window.addEventListener("blur",d),()=>window.removeEventListener("blur",d)},[n,h]),(0,g.jsx)(fd,{...a,children:(0,g.jsx)(ex,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:(0,g.jsx)(dR,{scope:t,onClose:m.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},"Menu"),tx=m.forwardRef(de(function(t,n){const{__scopeMenu:r,...i}=t,s=Ul(r);return(0,g.jsx)(Fy,{...s,...i,ref:n})},"MenuAnchor")),nx="MenuPortal",[mR,rx]=ri(nx,{forceMount:void 0}),gR=de(e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Sr(nx,t);return(0,g.jsx)(mR,{scope:t,forceMount:n,children:(0,g.jsx)(An,{present:n||s.open,children:(0,g.jsx)(dy,{asChild:!0,container:i,children:r})})})},"MenuPortal"),Ut="MenuContent",[vR,md]=ri(Ut),yR=m.forwardRef(de(function(t,n){const r=rx(Ut,t.__scopeMenu),{forceMount:i=r.forceMount,...s}=t,o=Sr(Ut,t.__scopeMenu),a=Ao(Ut,t.__scopeMenu);return(0,g.jsx)(Qs.Provider,{scope:t.__scopeMenu,children:(0,g.jsx)(An,{present:i||o.open,children:(0,g.jsx)(Qs.Slot,{scope:t.__scopeMenu,children:a.modal?(0,g.jsx)(xR,{...s,ref:n}):(0,g.jsx)(bR,{...s,ref:n})})})})},"MenuContent")),xR=m.forwardRef(de(function(t,n){const r=Sr(Ut,t.__scopeMenu),i=m.useRef(null),s=Ce(n,i);return m.useEffect(()=>{const o=i.current;if(o)return SA(o)},[]),(0,g.jsx)(gd,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:ne(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),bR=m.forwardRef(de(function(t,n){const r=Sr(Ut,t.__scopeMenu);return(0,g.jsx)(gd,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),wR=Fi("MenuContent.ScrollLock"),gd=m.forwardRef(de(function(t,n){const{__scopeMenu:r,loop:i=!1,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:d,onDismiss:p,disableOutsideScroll:v,...y}=t,x=Sr(Ut,r),b=Ao(Ut,r),w=Ul(r),S=Zy(r),C=hR(r),[T,k]=m.useState(null),A=m.useRef(null),M=Ce(n,A,x.onContentChange),E=m.useRef(0),O=m.useRef(""),R=m.useRef(0),L=m.useRef(null),N=m.useRef("right"),P=m.useRef(0),j=v?wy:m.Fragment,V=v?{as:wR,allowPinchZoom:!0}:void 0,W=de(D=>{const te=O.current+D,re=C().filter($=>!$.disabled),_=document.activeElement,U=re.find($=>$.ref.current===_)?.textValue,K=hx(re.map($=>$.textValue),te,U),G=re.find($=>$.textValue===K)?.ref.current;de((function $(J){O.current=J,window.clearTimeout(E.current),J!==""&&(E.current=window.setTimeout(()=>$(""),1e3))}),"updateSearch")(te),G&&setTimeout(()=>G.focus())},"handleTypeaheadSearch");m.useEffect(()=>()=>window.clearTimeout(E.current),[]),sd();const B=m.useCallback(D=>N.current===L.current?.side&&dx(D,L.current?.area),[]);return(0,g.jsx)(vR,{scope:r,searchRef:O,onItemEnter:m.useCallback(D=>{B(D)&&D.preventDefault()},[B]),onItemLeave:m.useCallback(D=>{B(D)||(A.current?.focus(),k(null))},[B]),onTriggerLeave:m.useCallback(D=>{B(D)&&D.preventDefault()},[B]),pointerGraceTimerRef:R,onPointerGraceIntentChange:m.useCallback(D=>{L.current=D},[]),children:(0,g.jsx)(j,{...V,children:(0,g.jsx)(IT,{asChild:!0,trapped:s,onMountAutoFocus:ne(o,D=>{D.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:(0,g.jsx)(iy,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:d,onDismiss:p,children:(0,g.jsx)(iR,{asChild:!0,...S,dir:b.dir,orientation:"vertical",loop:i,currentTabStopId:T,onCurrentTabStopIdChange:k,onEntryFocus:ne(c,D=>{b.isUsingKeyboardRef.current||D.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,g.jsx)(zy,{role:"menu","aria-orientation":"vertical","data-state":yd(x.open),"data-radix-menu-content":"",dir:b.dir,...w,...y,ref:M,style:{outline:"none",...y.style},onKeyDown:ne(y.onKeyDown,D=>{const te=D.target.closest("[data-radix-menu-content]")===D.currentTarget,re=D.ctrlKey||D.altKey||D.metaKey,_=D.key.length===1;te&&(D.key==="Tab"&&D.preventDefault(),!re&&_&&W(D.key));const U=A.current;if(D.target!==U||!lR.includes(D.key))return;D.preventDefault();const K=C().filter(G=>!G.disabled).map(G=>G.ref.current);Yy.includes(D.key)&&K.reverse(),cx(K)}),onBlur:ne(t.onBlur,D=>{D.currentTarget.contains(D.target)||(window.clearTimeout(E.current),O.current="")}),onPointerMove:ne(t.onPointerMove,zi(D=>{const te=D.target,re=P.current!==D.clientX;if(D.currentTarget.contains(te)&&re){const _=D.clientX>P.current?"right":"left";N.current=_,P.current=D.clientX}}))})})})})})})},"MenuContentImpl")),SR=m.forwardRef(de(function(t,n){const{__scopeMenu:r,...i}=t;return(0,g.jsx)(Ne.div,{role:"group",...i,ref:n})},"MenuGroup")),kR=m.forwardRef(de(function(t,n){const{__scopeMenu:r,...i}=t;return(0,g.jsx)(Ne.div,{...i,ref:n})},"MenuLabel")),rh="MenuItem",im="menu.itemSelect",vd=m.forwardRef(de(function(t,n){const{disabled:r=!1,onSelect:i,...s}=t,o=m.useRef(null),a=Ao(rh,t.__scopeMenu),l=md(rh,t.__scopeMenu),c=Ce(n,o),u=m.useRef(!1),h=de(()=>{const f=o.current;if(!r&&f){const d=new CustomEvent(im,{bubbles:!0,cancelable:!0});f.addEventListener(im,p=>i?.(p),{once:!0}),Zf(f,d),d.defaultPrevented?u.current=!1:a.onClose()}},"handleSelect");return(0,g.jsx)(ix,{...s,ref:c,disabled:r,onClick:ne(t.onClick,h),onPointerDown:f=>{t.onPointerDown?.(f),u.current=!0},onPointerUp:ne(t.onPointerUp,f=>{u.current||f.currentTarget?.click()}),onKeyDown:ne(t.onKeyDown,f=>{r||f.target!==f.currentTarget||l.searchRef.current!==""&&f.key===" "||nh.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})},"MenuItem")),ix=m.forwardRef(de(function(t,n){const{__scopeMenu:r,disabled:i=!1,textValue:s,...o}=t,a=md(rh,r),l=Zy(r),c=m.useRef(null),u=Ce(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)(Qs.ItemSlot,{scope:r,disabled:i,textValue:s??d,children:(0,g.jsx)(sR,{asChild:!0,...l,focusable:!i,children:(0,g.jsx)(Ne.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...o,ref:u,onPointerMove:ne(t.onPointerMove,zi(v=>{i?a.onItemLeave(v):(a.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ne(t.onPointerLeave,zi(v=>a.onItemLeave(v))),onFocus:ne(t.onFocus,()=>f(!0)),onBlur:ne(t.onBlur,()=>f(!1))})})})},"MenuItemImpl")),CR=m.forwardRef(de(function(t,n){const{checked:r=!1,onCheckedChange:i,...s}=t;return(0,g.jsx)(ox,{scope:t.__scopeMenu,checked:r,children:(0,g.jsx)(vd,{role:"menuitemcheckbox","aria-checked":Xs(r)?"mixed":r,...s,ref:n,"data-state":Kl(r),onSelect:ne(s.onSelect,()=>i?.(Xs(r)?!0:!r),{checkForDefaultPrevented:!1})})})},"MenuCheckboxItem")),[TR,AR]=ri("MenuRadioGroup",{value:void 0,onValueChange:de(()=>{},"onValueChange")}),MR=m.forwardRef(de(function(t,n){const{value:r,onValueChange:i,...s}=t,o=Ge(i);return(0,g.jsx)(TR,{scope:t.__scopeMenu,value:r,onValueChange:o,children:(0,g.jsx)(SR,{...s,ref:n})})},"MenuRadioGroup")),RR="MenuRadioItem",ER=m.forwardRef(de(function(t,n){const{value:r,...i}=t,s=AR(RR,t.__scopeMenu),o=r===s.value;return(0,g.jsx)(ox,{scope:t.__scopeMenu,checked:o,children:(0,g.jsx)(vd,{role:"menuitemradio","aria-checked":o,...i,ref:n,"data-state":Kl(o),onSelect:ne(i.onSelect,()=>s.onValueChange?.(r),{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),sx="MenuItemIndicator",[ox,PR]=ri(sx,{checked:!1}),OR=m.forwardRef(de(function(t,n){const{__scopeMenu:r,forceMount:i,...s}=t,o=PR(sx,r);return(0,g.jsx)(An,{present:i||Xs(o.checked)||o.checked===!0,children:(0,g.jsx)(Ne.span,{...s,ref:n,"data-state":Kl(o.checked)})})},"MenuItemIndicator")),IR=m.forwardRef(de(function(t,n){const{__scopeMenu:r,...i}=t;return(0,g.jsx)(Ne.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})},"MenuSeparator")),ax="MenuSub",[DR,lx]=ri(ax),NR=de(e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=Sr(ax,t),o=Ul(t),[a,l]=m.useState(null),[c,u]=m.useState(null),h=Ge(i);return m.useEffect(()=>(s.open===!1&&h(!1),()=>h(!1)),[s.open,h]),(0,g.jsx)(fd,{...o,children:(0,g.jsx)(ex,{scope:t,open:r,onOpenChange:h,content:c,onContentChange:u,children:(0,g.jsx)(DR,{scope:t,contentId:Kr(),triggerId:Kr(),trigger:a,onTriggerChange:l,children:n})})})},"MenuSub"),Ko="MenuSubTrigger",LR=m.forwardRef(de(function(t,n){const r=Sr(Ko,t.__scopeMenu),i=Ao(Ko,t.__scopeMenu),s=lx(Ko,t.__scopeMenu),o=md(Ko,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=Ce(n,s.onTriggerChange);return(0,g.jsx)(tx,{asChild:!0,...u,children:(0,g.jsx)(ix,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?s.contentId:void 0,"data-state":yd(r.open),...t,ref:f,onClick:d=>{t.onClick?.(d),!(t.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:ne(t.onPointerMove,zi(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:ne(t.onPointerLeave,zi(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:ne(t.onKeyDown,d=>{t.disabled||d.target!==d.currentTarget||o.searchRef.current!==""&&d.key===" "||cR[i.dir].includes(d.key)&&(r.onOpenChange(!0),r.content?.focus(),d.preventDefault())})})})},"MenuSubTrigger")),jR="MenuSubContent",_R=m.forwardRef(de(function(t,n){const r=rx(Ut,t.__scopeMenu),{forceMount:i=r.forceMount,align:s="start",...o}=t,a=Sr(Ut,t.__scopeMenu),l=Ao(Ut,t.__scopeMenu),c=lx(jR,t.__scopeMenu),u=m.useRef(null),h=Ce(n,u);return(0,g.jsx)(Qs.Provider,{scope:t.__scopeMenu,children:(0,g.jsx)(An,{present:i||a.open,children:(0,g.jsx)(Qs.Slot,{scope:t.__scopeMenu,children:(0,g.jsx)(gd,{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:ne(t.onFocusOutside,f=>{f.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:ne(t.onEscapeKeyDown,f=>{l.onClose(),f.preventDefault()}),onKeyDown:ne(t.onKeyDown,f=>{const d=f.currentTarget.contains(f.target),p=uR[l.dir].includes(f.key);d&&p&&(a.onOpenChange(!1),c.trigger?.focus(),f.preventDefault())})})})})})},"MenuSubContent"));function yd(e){return e?"open":"closed"}de(yd,"getOpenState");function Xs(e){return e==="indeterminate"}de(Xs,"isIndeterminate");function Kl(e){return Xs(e)?"indeterminate":e?"checked":"unchecked"}de(Kl,"getCheckedState");function cx(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}de(cx,"focusFirst");function ux(e,t){return e.map((n,r)=>e[(t+r)%e.length])}de(ux,"wrapArray");function hx(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=ux(e,Math.max(i,0));r.length===1&&(s=s.filter(a=>a!==n));const o=s.find(a=>a.toLowerCase().startsWith(r.toLowerCase()));return o!==n?o:void 0}de(hx,"getNextMatch");function fx(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,h=l.x,f=l.y;u>r!=f>r&&n<(h-c)*(r-u)/(f-u)+c&&(i=!i)}return i}de(fx,"isPointInPolygon");function dx(e,t){return t?fx({x:e.clientX,y:e.clientY},t):!1}de(dx,"isPointerInGraceArea");function zi(e){return t=>t.pointerType==="mouse"?e(t):void 0}de(zi,"whenMouse");var BR=pR,VR=tx,FR=gR,zR=yR,$R=kR,WR=vd,HR=CR,qR=MR,UR=ER,KR=OR,GR=IR,QR=NR,XR=LR,YR=_R,JR=Object.defineProperty,vt=(e,t)=>JR(e,"name",{value:t,configurable:!0}),xd="DropdownMenu",[ZR,S3]=Yn(xd,[Jy]),yt=Jy(),[eE,px]=ZR(xd),tE=vt(e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=yt(t),c=m.useRef(null),[u,h]=To({prop:i,defaultProp:s??!1,onChange:o,caller:xd});return(0,g.jsx)(eE,{scope:t,triggerId:Kr(),triggerRef:c,contentId:Kr(),open:u,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(f=>!f),[h]),modal:a,children:(0,g.jsx)(BR,{...l,open:u,onOpenChange:h,dir:r,modal:a,children:n})})},"DropdownMenu"),nE="DropdownMenuTrigger",rE=m.forwardRef(vt(function(t,n){const{__scopeDropdownMenu:r,disabled:i=!1,...s}=t,o=px(nE,r),a=yt(r),l=Ce(n,o.triggerRef);return(0,g.jsx)(VR,{asChild:!0,...a,children:(0,g.jsx)(Ne.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:ne(t.onPointerDown,c=>{!i&&c.button===0&&c.ctrlKey===!1&&(o.onOpenToggle(),o.open||c.preventDefault())}),onKeyDown:ne(t.onKeyDown,c=>{i||(["Enter"," "].includes(c.key)&&o.onOpenToggle(),c.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})},"DropdownMenuTrigger")),iE=vt(e=>{const{__scopeDropdownMenu:t,...n}=e,r=yt(t);return(0,g.jsx)(FR,{...r,...n})},"DropdownMenuPortal"),sE="DropdownMenuContent",oE=m.forwardRef(vt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=px(sE,r),o=yt(r),a=m.useRef(!1);return(0,g.jsx)(zR,{id:s.contentId,"aria-labelledby":s.triggerId,...o,...i,ref:n,onCloseAutoFocus:ne(t.onCloseAutoFocus,l=>{a.current||s.triggerRef.current?.focus(),a.current=!1,l.preventDefault()}),onInteractOutside:ne(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")),aE=m.forwardRef(vt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=yt(r);return(0,g.jsx)($R,{...s,...i,ref:n})},"DropdownMenuLabel")),lE=m.forwardRef(vt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=yt(r);return(0,g.jsx)(WR,{...s,...i,ref:n})},"DropdownMenuItem")),cE=m.forwardRef(vt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=yt(r);return(0,g.jsx)(HR,{...s,...i,ref:n})},"DropdownMenuCheckboxItem")),uE=m.forwardRef(vt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=yt(r);return(0,g.jsx)(qR,{...s,...i,ref:n})},"DropdownMenuRadioGroup")),hE=m.forwardRef(vt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=yt(r);return(0,g.jsx)(UR,{...s,...i,ref:n})},"DropdownMenuRadioItem")),fE=m.forwardRef(vt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=yt(r);return(0,g.jsx)(KR,{...s,...i,ref:n})},"DropdownMenuItemIndicator")),dE=m.forwardRef(vt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=yt(r);return(0,g.jsx)(GR,{...s,...i,ref:n})},"DropdownMenuSeparator")),pE=vt(e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=yt(t),[a,l]=To({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return(0,g.jsx)(QR,{...o,open:a,onOpenChange:l,children:n})},"DropdownMenuSub"),mE=m.forwardRef(vt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=yt(r);return(0,g.jsx)(XR,{...s,...i,ref:n})},"DropdownMenuSubTrigger")),gE=m.forwardRef(vt(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=yt(r);return(0,g.jsx)(YR,{...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")),vE=tE,yE=rE,xE=iE,bE=oE,wE=aE,SE=lE,kE=cE,CE=uE,TE=hE,mx=fE,AE=dE,ME=pE,RE=mE,EE=gE,PE=Object.defineProperty,OE=(e,t)=>PE(e,"name",{value:t,configurable:!0});function gx(e,[t,n]){return Math.min(n,Math.max(t,e))}OE(gx,"clamp");var IE=Object.defineProperty,fe=(e,t)=>IE(e,"name",{value:t,configurable:!0});function vx(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}fe(vx,"useStateMachine");var yx="ScrollArea",[xx,k3]=Yn(yx),[DE,_t]=xx(yx),NE=m.forwardRef(fe(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,M]=m.useState(!1),E=Ce(n,c),O=Ll(s);return(0,g.jsx)(DE,{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:M,onCornerWidthChange:w,onCornerHeightChange:C,children:(0,g.jsx)(Ne.div,{dir:O,...a,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":S+"px",...t.style}})})},"ScrollArea")),LE="ScrollAreaViewport",jE=m.forwardRef(fe(function(t,n){const{__scopeScrollArea:r,children:i,nonce:s,...o}=t,a=_t(LE,r),l=m.useRef(null),c=Ce(n,l,a.onViewportChange);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(_E,{nonce:s}),(0,g.jsx)(Ne.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")),_E=m.memo(fe(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),Zn="ScrollAreaScrollbar",BE=m.forwardRef(fe(function(t,n){const{forceMount:r,...i}=t,s=_t(Zn,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)(VE,{...i,ref:n,forceMount:r}):s.type==="scroll"?(0,g.jsx)(FE,{...i,ref:n,forceMount:r}):s.type==="auto"?(0,g.jsx)(bx,{...i,ref:n,forceMount:r}):s.type==="always"?(0,g.jsx)(bd,{...i,ref:n,"data-state":"visible"}):null},"ScrollAreaScrollbar")),VE=m.forwardRef(fe(function(t,n){const{forceMount:r,...i}=t,s=_t(Zn,t.__scopeScrollArea),[o,a]=m.useState(!1);return m.useEffect(()=>{const l=s.scrollArea;let c=0;if(l){const u=fe(()=>{window.clearTimeout(c),a(!0)},"handlePointerEnter"),h=fe(()=>{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)(An,{present:r||o,children:(0,g.jsx)(bx,{"data-state":o?"visible":"hidden",...i,ref:n})})},"ScrollAreaScrollbarHover")),FE=m.forwardRef(fe(function(t,n){const{forceMount:r,...i}=t,s=_t(Zn,t.__scopeScrollArea),o=t.orientation==="horizontal",a=Ro(()=>c("SCROLL_END"),100),[l,c]=vx("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=fe(()=>{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)(An,{present:r||l!=="hidden",children:(0,g.jsx)(bd,{"data-state":l==="hidden"?"hidden":"visible",...i,ref:n,onPointerEnter:ne(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:ne(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})},"ScrollAreaScrollbarScroll")),bx=m.forwardRef(fe(function(t,n){const r=_t(Zn,t.__scopeScrollArea),{forceMount:i,...s}=t,[o,a]=m.useState(!1),l=t.orientation==="horizontal",c=Ro(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,h=r.viewport.offsetHeight<r.viewport.scrollHeight;a(l?u:h)}},10);return Xr(r.viewport,c),Xr(r.content,c),(0,g.jsx)(An,{present:i||o,children:(0,g.jsx)(bd,{"data-state":o?"visible":"hidden",...s,ref:n})})},"ScrollAreaScrollbarAuto")),bd=m.forwardRef(fe(function(t,n){const{orientation:r="vertical",...i}=t,s=_t(Zn,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=wd(l.viewport,l.content),h={...i,sizes:l,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:fe(d=>o.current=d,"onThumbChange"),onThumbPointerUp:fe(()=>a.current=0,"onThumbPointerUp"),onThumbPointerDown:fe(d=>a.current=d,"onThumbPointerDown")};function f(d,p){return Cx(d,a.current,l,p)}return fe(f,"getScrollPosition"),r==="horizontal"?(0,g.jsx)(zE,{...h,ref:n,onThumbPositionChange:()=>{if(s.viewport&&o.current){const d=s.viewport.scrollLeft,p=sh(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)($E,{...h,ref:n,onThumbPositionChange:()=>{if(s.viewport&&o.current){const d=s.viewport.scrollTop,p=sh(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")),zE=m.forwardRef(fe(function(t,n){const{sizes:r,onSizesChange:i,...s}=t,o=_t(Zn,t.__scopeScrollArea),[a,l]=m.useState(),c=m.useRef(null),u=Ce(n,c,o.onScrollbarXChange);return m.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,g.jsx)(Sx,{"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":Mo(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),kd(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:Ys(a.paddingLeft),paddingEnd:Ys(a.paddingRight)}})}})},"ScrollAreaScrollbarX")),$E=m.forwardRef(fe(function(t,n){const{sizes:r,onSizesChange:i,...s}=t,o=_t(Zn,t.__scopeScrollArea),[a,l]=m.useState(),c=m.useRef(null),u=Ce(n,c,o.onScrollbarYChange);return m.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,g.jsx)(Sx,{"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":Mo(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),kd(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:Ys(a.paddingTop),paddingEnd:Ys(a.paddingBottom)}})}})},"ScrollAreaScrollbarY")),[WE,wx]=xx(Zn),Sx=m.forwardRef(fe(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=_t(Zn,r),[v,y]=m.useState(null),x=Ce(n,y),b=m.useRef(null),w=m.useRef(""),S=p.viewport,C=i.content-i.viewport,T=Ge(h),k=Ge(c),A=Ro(f,10);function M(E){if(b.current){const O=E.clientX-b.current.left,R=E.clientY-b.current.top;u({x:O,y:R})}}return fe(M,"handleDragScroll"),m.useEffect(()=>{const E=fe(O=>{const R=O.target;v?.contains(R)&&T(O,C)},"handleWheel");return document.addEventListener("wheel",E,{passive:!1}),()=>document.removeEventListener("wheel",E,{passive:!1})},[S,v,C,T]),m.useEffect(k,[i,k]),Xr(v,A),Xr(p.content,A),(0,g.jsx)(WE,{scope:r,scrollbar:v,hasThumb:s,onThumbChange:Ge(o),onThumbPointerUp:Ge(a),onThumbPositionChange:k,onThumbPointerDown:Ge(l),children:(0,g.jsx)(Ne.div,{...d,ref:x,style:{position:"absolute",...d.style},onPointerDown:ne(t.onPointerDown,E=>{E.button===0&&(E.target.setPointerCapture(E.pointerId),b.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),M(E))}),onPointerMove:ne(t.onPointerMove,M),onPointerUp:ne(t.onPointerUp,E=>{const O=E.target;O.hasPointerCapture(E.pointerId)&&O.releasePointerCapture(E.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),b.current=null})})})},"ScrollAreaScrollbarImpl")),ih="ScrollAreaThumb",HE=m.forwardRef(fe(function(t,n){const{forceMount:r,...i}=t,s=wx(ih,t.__scopeScrollArea);return(0,g.jsx)(An,{present:r||s.hasThumb,children:(0,g.jsx)(qE,{ref:n,...i})})},"ScrollAreaThumb")),qE=m.forwardRef(fe(function(t,n){const{__scopeScrollArea:r,style:i,...s}=t,o=_t(ih,r),a=wx(ih,r),{onThumbPositionChange:l}=a,c=Ce(n,a.onThumbChange),u=m.useRef(void 0),h=Ro(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=o.viewport;if(f){const d=fe(()=>{if(h(),!u.current){const p=GE(f,l);u.current=p,l()}},"handleScroll");return l(),f.addEventListener("scroll",d),()=>f.removeEventListener("scroll",d)}},[o.viewport,h,l]),(0,g.jsx)(Ne.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:ne(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:ne(t.onPointerUp,a.onThumbPointerUp)})},"ScrollAreaThumbImpl")),kx="ScrollAreaCorner",UE=m.forwardRef(fe(function(t,n){const r=_t(kx,t.__scopeScrollArea),i=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&i?(0,g.jsx)(KE,{...t,ref:n}):null},"ScrollAreaCorner")),KE=m.forwardRef(fe(function(t,n){const{__scopeScrollArea:r,...i}=t,s=_t(kx,r),[o,a]=m.useState(0),[l,c]=m.useState(0),u=!!(o&&l),{onCornerWidthChange:h,onCornerHeightChange:f}=s;return Xr(s.scrollbarX,()=>{const d=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(d),c(d)}),Xr(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)(Ne.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 Ys(e){return e?parseInt(e,10):0}fe(Ys,"toInt");function wd(e,t){const n=e/t;return isNaN(n)?0:n}fe(wd,"getThumbRatio");function Mo(e){const t=wd(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}fe(Mo,"getThumbSize");function Cx(e,t,n,r="ltr"){const i=Mo(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 Sd([l,c],h)(e)}fe(Cx,"getScrollPositionFromPointer");function sh(e,t,n="ltr"){const r=Mo(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=gx(e,l);return Sd([0,o],[0,a])(c)}fe(sh,"getThumbOffsetFromScroll");function Sd(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])}}fe(Sd,"linearScale");function kd(e,t){return e>0&&e<t}fe(kd,"isScrollingWithinScrollbarBounds");var GE=fe((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return fe((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 Ro(e,t){const n=Ge(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])}fe(Ro,"useDebounceCallback");function Xr(e,t){const n=Ge(t);Rt(()=>{let r=0;if(e){const i=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return i.observe(e),()=>{window.cancelAnimationFrame(r),i.unobserve(e)}}},[e,n])}fe(Xr,"useResizeObserver");var QE=NE,XE=jE,YE=UE,JE=Object.defineProperty,ze=(e,t)=>JE(e,"name",{value:t,configurable:!0}),[Cd,C3]=Yn("Tooltip",[$l]),Gl=$l(),ZE="TooltipProvider",eP=700,oh="tooltip.open",[tP,Td]=Cd(ZE),nP=ze(e=>{const{__scopeTooltip:t,delayDuration:n=eP,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)(tP,{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"),ah="Tooltip",[rP,Eo]=Cd(ah),iP=ze(e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=Td(ah,e.__scopeTooltip),c=Gl(t),[u,h]=m.useState(null),[f,d]=m.useState(void 0),p=Kr(),v=m.useRef(0),y=o??l.disableHoverableContent,x=a??l.delayDuration,b=m.useRef(!1),[w,S]=To({prop:r,defaultProp:i??!1,onChange:ze(E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(oh))):l.onClose(),s?.(E)},"onChange"),caller:ah}),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 M=f??p;return(0,g.jsx)(fd,{...c,children:(0,g.jsx)(rP,{scope:t,contentId:M,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"),sm="TooltipTrigger",sP=m.forwardRef(ze(function(t,n){const{__scopeTooltip:r,...i}=t,s=Eo(sm,r),o=Td(sm,r),a=Gl(r),l=m.useRef(null),c=Ce(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)(Fy,{asChild:!0,...a,children:(0,g.jsx)(Ne.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...i,ref:c,onPointerMove:ne(t.onPointerMove,d=>{d.pointerType!=="touch"&&!h.current&&!o.isPointerInTransitRef.current&&(s.onTriggerEnter(),h.current=!0)}),onPointerLeave:ne(t.onPointerLeave,()=>{s.onTriggerLeave(),h.current=!1}),onPointerDown:ne(t.onPointerDown,()=>{s.open&&s.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ne(t.onFocus,()=>{u.current||s.onOpen()}),onBlur:ne(t.onBlur,s.onClose),onClick:ne(t.onClick,s.onClose)})})},"TooltipTrigger")),Tx="TooltipPortal",[oP,aP]=Cd(Tx,{forceMount:void 0}),lP=ze(e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Eo(Tx,t);return(0,g.jsx)(oP,{scope:t,forceMount:n,children:(0,g.jsx)(An,{present:n||s.open,children:(0,g.jsx)(dy,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),Js="TooltipContent",cP=m.forwardRef(ze(function(t,n){const r=aP(Js,t.__scopeTooltip),{forceMount:i=r.forceMount,side:s="top",...o}=t,a=Eo(Js,t.__scopeTooltip);return(0,g.jsx)(An,{present:i||a.open,children:a.disableHoverableContent?(0,g.jsx)(Ax,{side:s,...o,ref:n}):(0,g.jsx)(uP,{side:s,...o,ref:n})})},"TooltipContent")),uP=m.forwardRef(ze(function(t,n){const r=Eo(Js,t.__scopeTooltip),i=Td(Js,t.__scopeTooltip),s=m.useRef(null),o=Ce(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=Rx(b,Mx(b,x.getBoundingClientRect())),S=Ex(y.getBoundingClientRect()),C=Ox([...w,...S]);l(C),f(!0)},[f]);return m.useEffect(()=>()=>d(),[d]),m.useEffect(()=>{if(c&&h){const v=ze(x=>p(x,h),"handleTriggerLeave"),y=ze(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=ze(y=>{const x=y.target,b={x:y.clientX,y:y.clientY},w=c?.contains(x)||h?.contains(x),S=!Px(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)(Ax,{...t,ref:o})},"TooltipContentHoverable")),hP=$C("TooltipContent"),Ax=m.forwardRef(ze(function(t,n){const{__scopeTooltip:r,children:i,"aria-label":s,id:o,onEscapeKeyDown:a,onPointerDownOutside:l,...c}=t,u=Eo(Js,r),h=Gl(r),{onClose:f}=u;m.useEffect(()=>(document.addEventListener(oh,f),()=>document.removeEventListener(oh,f)),[f]),m.useEffect(()=>{if(u.trigger){const p=ze(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 Rt(()=>(d(o),()=>{d(void 0)}),[o,d]),(0,g.jsx)(iy,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:p=>p.preventDefault(),onDismiss:f,children:(0,g.jsxs)(zy,{"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)(hP,{children:i}),s?(0,g.jsx)(iT,{id:u.contentId,role:"tooltip",children:s}):null]})})},"TooltipContentImpl")),fP=m.forwardRef(ze(function(t,n){const{__scopeTooltip:r,...i}=t,s=Gl(r);return(0,g.jsx)(HM,{...s,...i,ref:n})},"TooltipArrow"));function Mx(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")}}ze(Mx,"getExitSideFromRect");function Rx(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}ze(Rx,"getPaddedExitPoints");function Ex(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}]}ze(Ex,"getPointsFromRect");function Px(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}ze(Px,"isPointInPolygon");function Ox(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),Ix(t)}ze(Ox,"getHull");function Ix(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)}ze(Ix,"getHullPresorted");var dP=nP,pP=iP,mP=sP,gP=lP,vP=cP,yP=fP;function xP(){return document.activeElement?.closest('[role="dialog"],[role="alertdialog"]')??document.body}async function Ql(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",xP().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 bP=["billing_","credit_topup_","plan_limit_","plans_upgrade_confirm_","pricing_"];function wP(e){return bP.some(t=>e.startsWith(t))}function SP(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 kP(e,t={}){const{location:n="unknown",platform:r,environment:i,...s}=t;try{const o=wP(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])=>!SP(u))):s;WC.capture(e,{...c,...KC(n),...o?{organization_id:null,...l?{$groups:{organization:l}}:{}}:{}})}catch(o){console.warn(`[analytics] Failed to capture ${e}`,o)}}var CP=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function TP(e,t,n=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:CP(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var AP=e=>{let t="",n=!1;for(const r of e){if(r==="-"||r==="_"||r<=" "){n=t.length>0;continue}t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1}return t},MP=e=>{const t=AP(e);return t.charAt(0).toUpperCase()+t.slice(1)},lh=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),Mr={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function Fc(e){return e!=null}function RP(e,t={}){const n=t.attributeNames??{},r=h=>n[h]??h,i=e.size??e.width??Mr.width,s=e.size??e.height??Mr.height,o=e.aliases?.filter(h=>typeof h=="string"&&h.trim()!=="").map(h=>`lucide-${h}`)??[],a=[...e.name?[`lucide-${e.name}`]:[],...o],l=t.className?.split(" ").filter(Boolean)??[],c=t.includeDefaultClasses===!1?lh(...l):lh("lucide",...a,...l),u=t.absoluteStrokeWidth?Number(t.strokeWidth??Mr["stroke-width"])*Number(e.size??e.width??Mr.width)/Number(t.size??t.width??Mr.width):t.strokeWidth??Mr["stroke-width"];return["svg",{...Object.entries(Mr).reduce((h,[f,d])=>(h[r(f)]=d,h),{}),..."color"in t&&t.color&&{[r("stroke")]:t.color},..."size"in t&&Fc(t.size)&&{[r("width")]:t.size,[r("height")]:t.size},..."width"in t&&Fc(t.width)&&{[r("width")]:t.width},..."height"in t&&Fc(t.height)&&{[r("height")]:t.height},[r("stroke-width")]:u,...c&&{[r("class")]:c},[r("viewBox")]:`0 0 ${i} ${s}`,...t.hasA11yProp===!1?{[r("aria-hidden")]:"true"}:{},..."attributes"in t&&t.attributes},e.node.map(h=>{const[f,d,p]=h,v=t.nonScalingStroke?{[r("vector-effect")]:"non-scaling-stroke",...d}:d;return p?[f,v,p]:[f,v]})]}function EP(e,t={}){return RP(e,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var PP=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},OP=(0,m.createContext)({}),IP=()=>(0,m.useContext)(OP),DP=(0,m.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:s,nonScalingStroke:o,className:a="",children:l,iconNode:c=[],icon:u={node:c,aliases:[],size:24},...h},f)=>{const{size:d=24,strokeWidth:p=2,absoluteStrokeWidth:v=!1,nonScalingStroke:y=!1,color:x="currentColor",className:b=""}=IP()??{},w=!!l||PP(h),[S,C,T=[]]=EP(u,{color:e??x,width:n??t??d,height:r??t??d,strokeWidth:i??p,absoluteStrokeWidth:s??v,nonScalingStroke:o??y,className:lh(b,a),hasA11yProp:w,attributes:h});return(0,m.createElement)(S,{ref:f,...C},[...T.map(([k,A])=>(0,m.createElement)(k,A)),...Array.isArray(l)?l:[l]])});function xe(e,t=[],n=[]){const r=typeof e=="string"?TP(e,t,n):e,i=(0,m.forwardRef)(({className:s,...o},a)=>(0,m.createElement)(DP,{ref:a,icon:r,className:s,...o}));return r.name&&(i.displayName=MP(r.name)),i}var Dx={name:"bot",size:24,node:[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]};Dx.node;var NP=xe(Dx),Nx={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};Nx.node;var $i=xe(Nx),Lx={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};Lx.node;var jx=xe(Lx),_x={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};_x.node;var Wi=xe(_x),Bx={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};Bx.node;var LP=xe(Bx),Vx={name:"circle",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]};Vx.node;var jP=xe(Vx),Fx={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};Fx.node;var om=xe(Fx),zx={name:"copy",size:24,node:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};zx.node;var Ii=xe(zx),$x={name:"expand",size:24,node:[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}],["path",{d:"M3 16v5h5",key:"1t08am"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 8V3h5",key:"1ln10m"}],["path",{d:"M9 9 3 3",key:"v551iv"}]]};$x.node;var _P=xe($x),Wx={name:"eye",size:24,node:[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]};Wx.node;var BP=xe(Wx),Hx={name:"grip-vertical",size:24,node:[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]};Hx.node;var VP=xe(Hx),qx={name:"layers",size:24,node:[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],aliases:["layers-3"]};qx.node;var FP=xe(qx),Ux={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]};Ux.node;var zP=xe(Ux),Kx={name:"list-tree",size:24,node:[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]};Kx.node;var am=xe(Kx),Gx={name:"maximize-2",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]};Gx.node;var $P=xe(Gx),Qx={name:"message-square-quote",size:24,node:[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]]};Qx.node;var WP=xe(Qx),Xx={name:"minimize-2",size:24,node:[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]};Xx.node;var HP=xe(Xx),Yx={name:"minus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}]]};Yx.node;var qP=xe(Yx),Jx={name:"mouse-pointer-click",size:24,node:[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]};Jx.node;var UP=xe(Jx),Zx={name:"pencil",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};Zx.node;var KP=xe(Zx),eb={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};eb.node;var GP=xe(eb),tb={name:"redo-2",size:24,node:[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]};tb.node;var QP=xe(tb),nb={name:"shrink",size:24,node:[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]};nb.node;var XP=xe(nb),rb={name:"text-align-start",size:24,node:[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],aliases:["text","align-left"]};rb.node;var YP=xe(rb),ib={name:"triangle-alert",size:24,node:[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["alert-triangle"]};ib.node;var Xl=xe(ib),sb={name:"undo-2",size:24,node:[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]};sb.node;var JP=xe(sb),ob={name:"user",size:24,node:[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]};ob.node;var ZP=xe(ob),ab={name:"wrench",size:24,node:[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]};ab.node;var eO=xe(ab),lb=(0,m.createContext)({});function tO(e){const t=(0,m.useRef)(null);return t.current===null&&(t.current=e()),t.current}var nO=typeof window<"u",lm=nO?m.useLayoutEffect:m.useEffect,Ad=(0,m.createContext)(null);function Md(e,t){e.indexOf(t)===-1&&e.push(t)}function sl(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}var er=(e,t,n)=>n>t?t:n<e?e:n,Yl=()=>{},Yr=()=>{},Qn={},Rd=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),cb=e=>typeof e=="object"&&e!==null,Ed=e=>/^0[^.\s]+$/u.test(e);function ub(e){let t;return()=>(t===void 0&&(t=e()),t)}var Kt=e=>e,Po=(...e)=>e.reduce((t,n)=>r=>n(t(r))),Zs=(e,t,n)=>{const r=t-e;return r?(n-e)/r:1},ol=class{constructor(){this.subscriptions=[]}add(e){return Md(this.subscriptions,e),()=>this.remove(e)}remove(e){sl(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}},Et=e=>e*1e3,Nt=e=>e/1e3,hb=(e,t)=>t?e*(1e3/t):0,fb=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,rO=1e-7,iO=12;function sO(e,t,n,r,i){let s,o,a=0;do o=t+(n-t)/2,s=fb(o,r,i)-e,s>0?n=o:t=o;while(Math.abs(s)>rO&&++a<iO);return o}function Oo(e,t,n,r){if(e===t&&n===r)return Kt;const i=s=>sO(s,0,1,e,n);return s=>s===0||s===1?s:fb(i(s),t,r)}var db=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,pb=e=>t=>1-e(1-t),mb=Oo(.33,1.53,.69,.99),Pd=pb(mb),gb=db(Pd),vb=e=>e>=1?1:(e*=2)<1?.5*Pd(e):.5*(2-Math.pow(2,-10*(e-1))),Od=e=>1-Math.sin(Math.acos(e)),yb=pb(Od),xb=db(Od),oO=Oo(.42,0,1,1),aO=Oo(0,0,.58,1),Id=Oo(.42,0,.58,1),lO=e=>Array.isArray(e)&&typeof e[0]!="number",bb=e=>Array.isArray(e)&&typeof e[0]=="number",cm={linear:Kt,easeIn:oO,easeInOut:Id,easeOut:aO,circIn:Od,circInOut:xb,circOut:yb,backIn:Pd,backInOut:gb,backOut:mb,anticipate:vb},cO=e=>typeof e=="string",um=e=>{if(bb(e)){Yr(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,r,i]=e;return Oo(t,n,r,i)}else if(cO(e))return Yr(cm[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),cm[e];return e},Ve={delta:0,timestamp:0,isProcessing:!1},Ta;function uO(){Ta=void 0}var Je={now:()=>(Ta===void 0&&Je.set(Ve.isProcessing||Qn.useManualTiming?Ve.timestamp:performance.now()),Ta),set:e=>{Ta=e,queueMicrotask(uO)}},Di=e=>Math.round(e*1e5)/1e5,wb=e=>t=>typeof t=="string"&&t.startsWith(e),Sb=wb("--"),hO=wb("var(--"),Dd=e=>hO(e)?fO.test(e.split("/*")[0].trim()):!1,fO=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function hm(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}var rs={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},eo={...rs,transform:e=>er(0,1,e)},Go={...rs,default:1},Nd=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function dO(e){return e==null}var pO=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ld=(e,t)=>n=>!!(typeof n=="string"&&pO.test(n)&&n.startsWith(e)||t&&!dO(n)&&Object.prototype.hasOwnProperty.call(n,t)),kb=(e,t,n)=>r=>{if(typeof r!="string")return r;const[i,s,o,a]=r.match(Nd);return{[e]:parseFloat(i),[t]:parseFloat(s),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},mO=e=>er(0,255,e),zc={...rs,transform:e=>Math.round(mO(e))},_r={test:Ld("rgb","red"),parse:kb("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+zc.transform(e)+", "+zc.transform(t)+", "+zc.transform(n)+", "+Di(eo.transform(r))+")"};function gO(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 ch={test:Ld("#"),parse:gO,transform:_r.transform},Io=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),En=Io("deg"),wn=Io("%"),Q=Io("px"),vO=Io("vh"),yO=Io("vw"),fm={...wn,parse:e=>wn.parse(e)/100,transform:e=>wn.transform(e*100)},Si={test:Ld("hsl","hue"),parse:kb("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+wn.transform(Di(t))+", "+wn.transform(Di(n))+", "+Di(eo.transform(r))+")"},Fe={test:e=>_r.test(e)||ch.test(e)||Si.test(e),parse:e=>_r.test(e)?_r.parse(e):Si.test(e)?Si.parse(e):ch.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?_r.transform(e):Si.transform(e),getAnimatableNone:e=>{const t=Fe.parse(e);return t.alpha=0,Fe.transform(t)}},xO=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,Cb=new RegExp(Nd.source),Tb=new RegExp(xO.source,"i");function bO(e){return isNaN(e)&&typeof e=="string"&&(Cb.test(e)||Tb.test(e))}var Ab="number",Mb="color",wO="var",SO="var(",dm="${}",kO=/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 CO(e){const t=e.toString();return Cb.test(t)||Tb.test(t)}function to(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[];let s=0;return{values:n,split:t.replace(kO,o=>(Fe.test(o)?(r.color.push(s),i.push(Mb),n.push(Fe.parse(o))):o.startsWith(SO)?(r.var.push(s),i.push(wO),n.push(o)):(r.number.push(s),i.push(Ab),n.push(parseFloat(o))),++s,dm)).split(dm),indexes:r,types:i}}function TO(e){return to(e).values}function Rb({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===Ab?i+=Di(r[s]):o===Mb?i+=Fe.transform(r[s]):i+=r[s]}return i}}function AO(e){return Rb(to(e))}var MO=e=>typeof e=="number"?0:Fe.test(e)?Fe.getAnimatableNone(e):e,RO=(e,t)=>typeof e=="number"?t?.trim().endsWith("/")?e:0:MO(e);function EO(e){const t=to(e);return Rb(t)(t.values.map((n,r)=>RO(n,t.split[r])))}var Pt={test:bO,parse:TO,createTransformer:AO,getAnimatableNone:EO};function $c(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 PO({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=$c(l,a,e+1/3),s=$c(l,a,e),o=$c(l,a,e-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(o*255),alpha:r}}function al(e,t){return n=>n>0?t:e}var ye=(e,t,n)=>e+(t-e)*n,Wc=(e,t,n)=>{const r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},OO=[ch,_r,Si],IO=e=>OO.find(t=>t.test(e));function pm(e){const t=IO(e);if(!t)return Yl(!1,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!1;let n=t.parse(e);return t===Si&&(n=PO(n)),n}var mm=(e,t)=>{const n=pm(e),r=pm(t);if(!n||!r)return al(e,t);const i={...n};return s=>(i.red=Wc(n.red,r.red,s),i.green=Wc(n.green,r.green,s),i.blue=Wc(n.blue,r.blue,s),i.alpha=ye(n.alpha,r.alpha,s),_r.transform(i))},uh=new Set(["none","hidden"]);function DO(e,t){return uh.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function NO(e,t){return n=>ye(e,t,n)}function jd(e){return typeof e=="number"?NO:typeof e=="string"?Dd(e)?al:Fe.test(e)?mm:_O:Array.isArray(e)?Eb:typeof e=="object"?Fe.test(e)?mm:LO:al}function Eb(e,t){const n=[...e],r=n.length,i=e.map((s,o)=>jd(s)(s,t[o]));return s=>{for(let o=0;o<r;o++)n[o]=i[o](s);return n}}function LO(e,t){const n={...e,...t},r={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=jd(e[i])(e[i],t[i]));return i=>{for(const s in r)n[s]=r[s](i);return n}}function jO(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 _O=(e,t)=>{const n=Pt.createTransformer(t),r=to(e),i=to(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?uh.has(e)&&!i.values.length||uh.has(t)&&!r.values.length?DO(e,t):Po(Eb(jO(r,i),i.values),n):(Yl(!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"),al(e,t))},gm=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function BO(e,t){const n=gm.exec(e);if(!n)return;const r=gm.exec(t);if(!r||n[2]!==r[2])return;const i=n[2],s=parseFloat(n[1]),o=parseFloat(r[1]);return a=>Di(ye(s,o,a))+i}function _d(e,t,n){if(typeof e=="number"&&typeof t=="number"&&typeof n=="number")return ye(e,t,n);if(typeof e=="string"&&typeof t=="string"){const r=BO(e,t);if(r)return r}return jd(e)(e,t)}var Qo=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function VO(e){let t=new Set,n=new Set,r=!1,i=!1;const s=new Set;let o={delta:0,timestamp:0,isProcessing:!1};function a(c){s.has(c)&&(n.add(c),e()),c(o)}const l={schedule:(c,u=!1,h=!1)=>{const f=h&&r?t:n;return u&&s.add(c),f.add(c),c},cancel:c=>{n.delete(c),s.delete(c)},process:c=>{if(o=c,r){i=!0;return}r=!0;const u=t;t=n,n=u,t.forEach(a),t.clear(),r=!1,i&&(i=!1,l.process(c))}};return l}var FO=40;function Pb(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0;const s=()=>r=!0,o=Qo.reduce((w,S)=>(w[S]=VO(s),w),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:u,update:h,preRender:f,render:d,postRender:p}=o,v=()=>{const w=Qn.useManualTiming,S=w?n.timestamp:performance.now();r=!1,w||(n.delta=i?1e3/60:Math.max(Math.min(S-n.timestamp,FO),1)),n.timestamp=S,n.isProcessing=!0,a.process(n),l.process(n),c.process(n),u.process(n),h.process(n),f.process(n),d.process(n),p.process(n),n.isProcessing=!1,r&&t&&(i=!1,e(v))},y=()=>{r=!0,i=!0,n.isProcessing||e(v)};return{schedule:Qo.reduce((w,S)=>{const C=o[S];return w[S]=(T,k=!1,A=!1)=>(r||y(),C.schedule(T,k,A)),w},{}),cancel:w=>{for(let S=0;S<Qo.length;S++)o[Qo[S]].cancel(w)},state:n,steps:o}}var{schedule:we,cancel:pr,steps:Hc}=Pb(typeof requestAnimationFrame<"u"?requestAnimationFrame:Kt,!0,Ve),zO=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>we.update(t,n),stop:()=>pr(t),now:()=>Ve.isProcessing?Ve.timestamp:Je.now()}},Ob=(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)})`},Bd=2e4;function Vd(e,t=50,n=Bd,r){let i=0,s=e.next(i);for(r?.push(s.value);!s.done&&i<n;)i+=t,s=e.next(i),r?.push(s.value);return i>=n?1/0:i}function $O(e,t=100,n){const r=n({...e,keyframes:[0,t]}),i=Math.min(Vd(r),Bd);return{type:"keyframes",ease:s=>r.next(i*s).value/t,duration:Nt(i)}}var Ke={stiffness:100,damping:10,mass:1,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05},Ib=e=>e<0?1/Math.max(1+e,Ke.minDamping):Math.max(1-e,Ke.minDamping);function Db(e,t){if(!(e>1))return 1;const n=Math.sqrt(e*e-1),r=e-n,i=e+n,s=2*n*Math.exp(-t)*(1+t);return Nb(o=>i*Math.exp(-r*o)-r*Math.exp(-i*o)-s,o=>Math.exp(-i*o)-Math.exp(-r*o),t)/t}function hh(e,t){return e*Math.sqrt(1-t*t)}var WO=12;function Nb(e,t,n){let r=n;for(let i=1;i<WO;i++)r=r-e(r)/t(r);return r}var vm=.001;function HO({duration:e=Ke.duration,bounce:t=Ke.bounce}){let n,r;Yl(e<=Et(Ke.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");const i=Ib(t);e=er(Ke.minDuration,Ke.maxDuration,Nt(e)),i<1?(n=c=>{const u=c*i,h=u*e,f=hh(c,i),d=Math.exp(-h);return vm-u/f*d},r=c=>{const u=c*i*e,h=i*i*c*c*e,f=Math.exp(-u),d=hh(c*c,i);return(-n(c)+vm>0?-1:1)*-h*f/d}):(n=c=>-.001+Math.exp(-c*e)*(c*e+1),r=c=>Math.exp(-c*e)*(-c*(e*e)));const s=5/e,o=Nb(n,r,s),a=o*Db(i,o*e),l=a*a;return{stiffness:l,damping:i*2*Math.sqrt(l),duration:Et(e)}}var fh=(e,t)=>(t?e>=0:e>0)&&e<1/0;function qc(e,t){if(fh(e,t))return e}function qO(e){const t=qc(e.stiffness),n=qc(e.damping,!0),r=qc(e.mass),i={...e,stiffness:t??Ke.stiffness,damping:n??Ke.damping,mass:r??Ke.mass,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(i.isTimeDefined){if(e.visualDuration){const s=Ib(e.bounce||0),o=2*Math.PI/(e.visualDuration*1.2)*Db(s,2*Math.PI/1.2);i.stiffness=o*o,i.damping=2*s*Math.sqrt(i.stiffness)}else Object.assign(i,HO(i)),i.isResolvedFromDuration=!0;(!fh(i.stiffness)||!fh(i.damping,!0))&&(i.stiffness=Ke.stiffness,i.damping=Ke.damping)}return i}function ll(e=Ke.visualDuration,t=Ke.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e,r=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],s={done:!1,value:r},{stiffness:o,damping:a,mass:l,duration:c,isResolvedFromDuration:u,isTimeDefined:h}=qO({...n}),f=k=>h?0:-Nt(k),d=a/(2*Math.sqrt(o*l)),p=Nt(Math.sqrt(o/l)),v=d*p,y={target:i,delta:i-r,velocity:f(n.velocity||0)||0,restSpeed:0,restDelta:0},x=()=>{const k=Math.abs(y.delta)<5;y.restSpeed=n.restSpeed||(k?Ke.restSpeed.granular:Ke.restSpeed.default),y.restDelta=n.restDelta||(k?Ke.restDelta.granular:Ke.restDelta.default)};x();let b,w,S;if(d<1){const k=hh(p,d),A={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};S=()=>{A.A=(y.velocity+v*y.delta)/k,A.sinC=v*A.A+y.delta*k,A.cosC=v*y.delta-A.A*k};const M=E=>{E!==A.t&&(A.t=E,A.env=Math.exp(-v*E),A.sin=Math.sin(k*E),A.cos=Math.cos(k*E))};b=E=>(M(E),y.target-A.env*(A.A*A.sin+y.delta*A.cos)),w=E=>(M(E),A.env*(A.sinC*A.sin+A.cosC*A.cos))}else if(d===1){b=A=>y.target-Math.exp(-p*A)*(y.delta+(y.velocity+p*y.delta)*A);const k={C:0};S=()=>{k.C=y.velocity+p*y.delta},w=A=>Math.exp(-p*A)*(p*k.C*A-y.velocity)}else{const k=p*Math.sqrt(d*d-1),A=v-k,M=v+k,E=h?1/0:300/k,O=(L,N)=>Math.exp(N>E?-L*E-v*(N-E):-L*N),R={S:0,F:0};S=()=>{const L=(y.velocity+v*y.delta)/k;R.S=(y.delta+L)/2,R.F=(y.delta-L)/2},b=L=>y.target-R.S*O(A,L)-R.F*O(M,L),w=L=>A*R.S*O(A,L)+M*R.F*O(M,L)}S();const C=u&&c||null,T={calculatedDuration:C,retarget:(k,A)=>{y.target=k[k.length-1],y.delta=y.target-k[0],y.velocity=f(A),n.restSpeed&&n.restDelta||x(),T.calculatedDuration=C,s.done=!1,S()},velocity:k=>Et(w(k)),next:k=>{const A=b(k);if(u)s.done=k>=c;else{const M=Et(w(k));s.done=Math.abs(M)<=y.restSpeed&&Math.abs(y.target-A)<=y.restDelta}return s.value=s.done?y.target:A,s},toString:()=>{const k=Math.min(Vd(T),Bd),A=Ob(M=>T.next(k*M).value,k,30);return k+"ms "+A},toTransition:()=>{}};return T}ll.applyToOptions=e=>{const t=$O(e,100,ll);return e.ease=t.ease,e.duration=Et(t.duration),e.type="keyframes",e};function dh({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:s=500,modifyTarget:o,min:a,max:l,restDelta:c=.5,restSpeed:u}){const h=e[0],f={done:!1,value:h},d=k=>k<a||k>l,p=k=>a===void 0?l:l===void 0||Math.abs(a-k)<Math.abs(l-k)?a:l;let v=n*t;const y=h+v,x=o===void 0?y:o(y);x!==y&&(v=x-h);const b=k=>-v*Math.exp(-k/r),w=k=>{const A=b(k);f.done=Math.abs(A)<=c,f.value=f.done?x:x+A};let S,C;const T=k=>{d(f.value)&&(S=k,C=ll({keyframes:[f.value,p(f.value)],velocity:-b(k)/r*1e3,damping:i,stiffness:s,restDelta:c,restSpeed:u}))};return T(0),{calculatedDuration:null,next:k=>{let A=!1;return!C&&S===void 0&&(A=!0,w(k),T(k)),S!==void 0&&k>=S?C.next(k-S):(!A&&w(k),f)}}}function UO(e,t,n){const r=[],i=n||Qn.mix||_d,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]||Kt:t;a=Po(l,a)}r.push(a)}return r}function KO(e,t,{clamp:n=!0,ease:r,mixer:i}={}){const s=e.length;if(Yr(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=UO(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=Zs(e[h],e[h+1],u);return a[h](f)};return n?u=>c(er(e[0],e[s-1],u)):c}function GO(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const i=Zs(0,t,r);e.push(ye(n,1,i))}}function QO(e){const t=[0];return GO(t,e.length-1),t}function XO(e,t){return e.map(n=>n*t)}function YO(e,t){return e.map(()=>t||Id).splice(0,e.length-1)}function Ns({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const i=lO(r)?r.map(um):um(r)||Id,s={done:!1,value:t[0]};if(t.length===2&&!Array.isArray(i)&&(!n||n.length!==2||n[0]===0&&n[1]===1)){const[l,c]=t,u=l===c?void 0:(Qn.mix||_d)(l,c);return{calculatedDuration:e,next:h=>(s.value=u?u(i(e>0?er(0,1,h/e):1)):c,s.done=h>=e,s)}}const o=XO(n&&n.length===t.length?n:QO(t),e),a=KO(o,t,{ease:Array.isArray(i)?i:YO(t,i)});return{calculatedDuration:e,next:l=>(s.value=a(l),s.done=l>=e,s)}}var JO=5;function ZO(e,t,n){const r=Math.max(t-JO,0);return hb(n-e(r),t-r)}function eI(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):ZO(r=>e.next(r).value,t,e.next(t).value)}var tI=e=>e!==null;function Jl(e,{repeat:t,repeatType:n="loop"},r,i=1){const s=e.filter(tI),o=i<0||t&&n!=="loop"&&t%2===1?0:s.length-1;return!o||r===void 0?s[o]:r}var nI={decay:dh,inertia:dh,tween:Ns,keyframes:Ns,spring:ll};function Lb(e){typeof e.type=="string"&&(e.type=nI[e.type])}function jb(e,t){return{kind:e,animation:t,timestamp:Je.now(),frameTimestamp:Ve.timestamp,frameIsProcessing:Ve.isProcessing}}function _b(e,t,n){const r=globalThis.__MOTION_INSPECT__;if(r)try{r({...jb("animation-start",e),options:n?{...t,...n}:t})}catch{}}function rI(e,t){const n=globalThis.__MOTION_INSPECT__;if(n)try{n({...jb("layout-animation-start",e),node:t})}catch{}}var Fd=class{constructor(){this.isResolved=!1}get finished(){return this._finished||(this._finished=this.isResolved?Promise.resolve():new Promise(e=>{this._resolve=e})),this._finished}updateFinished(){this._finished=this._resolve=void 0,this.isResolved=!1}notifyFinished(){this.isResolved=!0,this._resolve?.()}then(e,t){return this.finished.then(e,t)}},iI=e=>e/100,cl=class extends Fd{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!==Je.now()&&this.tick(Je.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),_b(this,this.options)}initAnimation(){const{options:e}=this;Lb(e);const{type:t=Ns,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:s=0}=e;let{keyframes:o}=e;const a=t||Ns;a!==Ns&&typeof o[0]!="number"&&(this.mixKeyframes=Po(iI,_d(o[0],o[1])),o=[0,100]);const l=a(o===e.keyframes?e:{...e,keyframes:o});i==="mirror"&&(this.mirroredGenerator=a({...e,keyframes:[...o].reverse(),velocity:-s})),l.calculatedDuration===null&&(l.calculatedDuration=Vd(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),M=k%1;!M&&k>=1&&(M=1),M===1&&A--,A=Math.min(A,u+1),A%2&&(h==="reverse"?(M=1-M,f&&(M-=f/o)):h==="mirror"&&(w=s)),b=er(0,1,M)*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!==dh&&(S.value=Jl(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 Nt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Nt(e)}get time(){return Nt(this.currentTime)}set time(e){e=Et(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=e,this.tick(e))}getGeneratorVelocity(){return eI(this.generator,this.currentTime,this.options.velocity)}get speed(){return this.playbackSpeed}set speed(e){const t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Je.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Nt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=zO,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(Je.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}},sI=new Set(["brightness","contrast","saturate","opacity"]);function oI(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(Nd)||[];if(!r)return e;const i=n.replace(r,"");let s=sI.has(t)?1:0;return r!==n&&(s*=100),t+"("+s+i+")"}var aI=/\b([a-z-]*)\(.*?\)/gu,ph={...Pt,getAnimatableNone:e=>{const t=e.match(aI);return t?t.map(oI).join(" "):e}},mh={...Pt,getAnimatableNone:e=>{const t=Pt.parse(e);return Pt.createTransformer(e)(t.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},ym={...rs,transform:Math.round},lI={rotate:En,pathRotation:En,rotateX:En,rotateY:En,rotateZ:En,scale:Go,scaleX:Go,scaleY:Go,scaleZ:Go,skew:En,skewX:En,skewY:En,distance:Q,translateX:Q,translateY:Q,translateZ:Q,x:Q,y:Q,z:Q,perspective:Q,transformPerspective:Q,opacity:eo,originX:fm,originY:fm,originZ:Q},ul={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,...lI,zIndex:ym,fillOpacity:eo,strokeOpacity:eo,numOctaves:ym},cI={...ul,color:Fe,backgroundColor:Fe,outlineColor:Fe,fill:Fe,stroke:Fe,borderColor:Fe,borderTopColor:Fe,borderRightColor:Fe,borderBottomColor:Fe,borderLeftColor:Fe,filter:ph,WebkitFilter:ph,mask:mh,WebkitMask:mh},Bb=e=>cI[e],uI=new Set([ph,mh]);function zd(e,t){let n=Bb(e);return uI.has(n)||(n=Pt),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function hI(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var Br=e=>e*180/Math.PI,gh=e=>{const t=Br(Math.atan2(e[1],e[0]));return vh(t)},fI={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:gh,rotateZ:gh,skewX:e=>Br(Math.atan(e[1])),skewY:e=>Br(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},vh=e=>(e=e%360,e<0&&(e+=360),e),xm=gh,bm=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),wm=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),dI={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:bm,scaleY:wm,scale:e=>(bm(e)+wm(e))/2,rotateX:e=>vh(Br(Math.atan2(e[6],e[5]))),rotateY:e=>vh(Br(Math.atan2(-e[2],e[0]))),rotateZ:xm,rotate:xm,skewX:e=>Br(Math.atan(e[4])),skewY:e=>Br(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function no(e){return e.includes("scale")?1:0}function yh(e,t){if(!e||e==="none")return no(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=dI,i=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=fI,i=a}if(!i)return no(t);const s=r[t],o=i[1].split(",").map(mI);return typeof s=="function"?s(o):o[s]}var pI=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return yh(n,t)};function mI(e){return parseFloat(e.trim())}var is=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ur=new Set([...is,"pathRotation"]),Sm=e=>e===rs||e===Q,gI=new Set(["x","y","z"]),vI=is.filter(e=>!gI.has(e));function yI(e){const t=[];return vI.forEach(n=>{const r=e.getValue(n);if(r!==void 0){const i=r.get(),s=n.startsWith("scale")?1:0;if(i===s)return;t.push([n,i]),r.set(s)}}),t}var xI=new Set(["bottom","right"]);function km(e,t,n,r,i,s){const o=parseFloat(e);if(!isNaN(o))return o;const{min:a,max:l}=t()[n],c=l-a;return s==="border-box"?c:c-parseFloat(r)-parseFloat(i)}var Fr={width:({width:e,paddingLeft:t="0",paddingRight:n="0",boxSizing:r},i)=>km(e,i,"x",t,n,r),height:({height:e,paddingTop:t="0",paddingBottom:n="0",boxSizing:r},i)=>km(e,i,"y",t,n,r),top:({top:e})=>parseFloat(e),left:({left:e})=>parseFloat(e),bottom:({top:e},t)=>{const{y:n}=t();return parseFloat(e)+(n.max-n.min)},right:({left:e},t)=>{const{x:n}=t();return parseFloat(e)+(n.max-n.min)},x:({transform:e})=>yh(e,"x"),y:({transform:e})=>yh(e,"y")};Fr.translateX=Fr.x;Fr.translateY=Fr.y;var zr=new Set,xh=!1,bh=!1,wh=!1;function Vb(){if(bh){const e=[],t=new Set,n=new Set;zr.forEach(i=>{i.needsMeasurement&&(e.push(i),t.add(i.element),xI.has(i.name)&&n.add(i.element))});const r=new Map;n.forEach(i=>{const s=yI(i);s.length&&(r.set(i,s),i.render())}),e.forEach(i=>i.measureInitialState()),t.forEach(i=>{i.render();const s=r.get(i);s&&s.forEach(([o,a])=>{i.getValue(o)?.set(a)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}bh=!1,xh=!1,zr.forEach(e=>e.complete(wh)),zr.clear()}function Fb(){zr.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(bh=!0)})}function bI(){wh=!0,Fb(),Vb(),wh=!1}function wI(e,t,n){if(typeof e=="string"){if(Rd(e)||Ed(e))return parseFloat(e);if(!Pt.test(e)&&Pt.test(n))return zd(t,n)}return e??void 0}var $d=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?(zr.add(this),xh||(xh=!0,we.read(Fb),we.resolveKeyframes(Vb))):(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=wI(n.readValue(t,s),t,s);o!==void 0&&(e[0]=o)}e[0]===void 0&&(e[0]=s),r&&i===void 0&&r.set(e[0])}hI(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),zr.delete(this)}cancel(){this.state==="scheduled"&&(zr.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}},SI=e=>e.startsWith("--");function zb(e,t,n){SI(t)?e.style.setProperty(t,n):e.style[t]=n}var kI={};function $b(e,t){const n=ub(e);return()=>kI[t]??n()}var CI=$b(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),Wb=$b(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),ws=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Cm={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:ws([0,.65,.55,1]),circOut:ws([.55,0,1,.45]),backIn:ws([.31,.01,.66,-.59]),backOut:ws([.33,1.53,.69,.99])};function Hb(e,t){if(e)return typeof e=="function"?Wb()?Ob(e,t):"ease-out":bb(e)?ws(e):Array.isArray(e)?e.map(n=>Hb(n,t)||Cm.easeOut):Cm[e]}function TI(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=Hb(a,i);Array.isArray(h)&&(u.easing=h);const f={delay:r,duration:i,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:s+1,direction:o==="reverse"?"alternate":"normal"};return c&&(f.pseudoElement=c),e.animate(u,f)}function qb(e){return typeof e=="function"&&"applyToOptions"in e}function AI({type:e,...t}){return qb(e)&&Wb()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}var Ub=class extends Fd{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,Yr(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const l=AI(e);this.animation=TI(t,n,r,l,i),l.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){const c=Jl(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(c),zb(t,n,c),this.animation.cancel()}a?.(),this.notifyFinished()},_b(this,e,l)}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return Nt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Nt(e)}get time(){return Nt(Number(this.animation.currentTime)||0)}set time(e){const t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Et(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,onAttach:t,observe:n,...r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&CI()?(this.animation.timeline=e,Object.assign(this.animation,r),t?.(this.animation),Kt):n(this)}},Kb={anticipate:vb,backInOut:gb,circInOut:xb};function MI(e){return e in Kb}function RI(e){typeof e.ease=="string"&&MI(e.ease)&&(e.ease=Kb[e.ease])}var Uc=10,EI=class extends Ub{constructor(e){RI(e),Lb(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 cl({...s,autoplay:!1}),a=Math.max(Uc,Je.now()-this.startTime),l=er(0,Uc,a-Uc),c=o.sample(a).value,{name:u}=this.options;i&&u&&zb(i,u,c),t.setWithVelocity(o.sample(Math.max(0,a-l)).value,c,l),o.stop()}},Tm=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Pt.test(e)||e==="0")&&!e.startsWith("url("));function PI(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 OI(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=Tm(i,t),a=Tm(s,t);return!o||!a?(o!==a&&Yl(!1,`You are trying to animate ${t} from "${i}" to "${s}". "${o?s:i}" is not an animatable value.`,"value-not-animatable"),!1):PI(e)||(n==="spring"||qb(n))&&r}function Sh(e){e.duration=0,e.type="keyframes"}var kh=new Set(["opacity","clipPath","filter","transform","backgroundColor"]),II=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function DI(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&II.test(e[t]))return!0;return!1}var Am=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),NI=ub(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function LI(e){const{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:s,type:o,keyframes:a}=e;if(!n||!(kh.has(n)||Am.has(n)))return!1;const l=t?.owner?.current;if(!(l instanceof HTMLElement)&&!(l instanceof SVGElement))return!1;const{onUpdate:c,transformTemplate:u}=t.owner.getProps();return NI()&&(kh.has(n)||Am.has(n)&&DI(a))&&(n!=="transform"||!u)&&!c&&!r&&i!=="mirror"&&s!==0&&o!=="inertia"}var jI=40,_I=class extends Fd{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Je.now();const{keyframes:t,name:n,motionValue:r,element:i}=e,s=e;s.autoplay??(s.autoplay=!0),s.delay??(s.delay=0),s.type??(s.type="keyframes"),s.repeat??(s.repeat=0),s.repeatDelay??(s.repeatDelay=0),s.repeatType??(s.repeatType="loop");const o=i?.KeyframeResolver||$d;this.keyframeResolver=new o(t,(a,l,c)=>this.onKeyframesResolved(a,l,s,!c),n,r,i),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;const{name:i,type:s,velocity:o,delay:a,isHandoff:l,onUpdate:c}=n;this.resolvedAt=Je.now();let u=!0;OI(e,i,s,o)||(u=!1,(Qn.instantAnimations||!a)&&c?.(Jl(e,n,t)),e[0]=e[e.length-1],Sh(n),n.repeat=0);const h=r?this.resolvedAt?this.resolvedAt-this.createdAt>jI?this.resolvedAt:this.createdAt:this.createdAt:void 0,{onComplete:f}=n;n.startTime??(n.startTime=h),n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{f?.(),this.notifyFinished()};const d=u&&!l&&LI(n);let p;if(d){n.element=n.motionValue?.owner?.current;try{p=new EI(n)}catch{p=new cl(n)}}else p=new cl(n);this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this._animation.finished:super.finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),bI()),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 Gb(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 Mm=30,BI=e=>!isNaN(parseFloat(e)),Rm={current:void 0},VI=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{const r=Je.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&(this.notifyChange(),this.dependents))for(const i of this.dependents)i.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Je.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=BI(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,t){var n;return e==="change"?this.onChangeSubscribe(t):((n=this.events)[e]||(n[e]=new ol)).add(t)}onChangeSubscribe(e){const{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new ol,t.change.add(this.changeSubscriber),this.changeSubscriber=void 0),t.change.add(e)),()=>{this.changeSubscriber===e?this.changeSubscriber=void 0:t.change?.remove(e),this.stopIfUnobserved()}}stopIfUnobserved(){we.read(()=>{!this.changeSubscriber&&!this.events.change?.getSize()&&this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(const e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.notifyChange()}notifyChange(){const{current:e,changeSubscriber:t}=this;t?t(e):this.events.change?.notify(e)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return Rm.current&&Rm.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const e=Je.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Mm)return 0;const t=Math.min(this.updatedAt-this.prevUpdatedAt,Mm);return hb(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0;let n=!1,r;r=e(()=>{n=!0,this.events.animationComplete?.notify(),this.animation===r&&this.clearAnimation(),t()}),n||(this.animation=r),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){this.animation=void 0}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Hi(e,t){return new VI(e,t)}function Qb(e,t){if(e?.inherit&&t){const{inherit:n,...r}=e;return{...t,...r}}return e}function Wd(e,t){const n=e?.[t]??e?.default??e;return n!==e?Qb(n,e):n}var FI={type:"spring",stiffness:500,damping:25,restSpeed:10},zI=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),$I={type:"keyframes",duration:.8},WI={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},HI=(e,{keyframes:t})=>t.length>2?$I:ur.has(e)?e.startsWith("scale")?zI(t[1]):FI:WI,qI=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function UI(e){for(const t in e)if(!qI.has(t))return!0;return!1}var Hd=(e,t,n,r={},i,s)=>o=>{const a=Wd(r,e)||{},l=a.delay||r.delay||0;let{elapsed:c=0}=r;c=c-Et(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};UI(a)||Object.assign(u,HI(e,u)),u.duration&&(u.duration=Et(u.duration)),u.repeatDelay&&(u.repeatDelay=Et(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let h=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Sh(u),u.delay===0&&(h=!0)),(Qn.instantAnimations||Qn.skipAnimations||i?.shouldSkipAnimations||a.skipAnimations)&&(h=!0,Sh(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,h&&!s&&t.get()!==void 0){const f=Jl(u.keyframes,a);if(f!==void 0){we.update(()=>{u.onUpdate(f),u.onComplete()});return}}return a.isSync?new cl(u):new _I(u)},KI=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function GI(e){const t=KI.exec(e);if(!t)return[,];const[,n,r,i]=t;return[`--${n??r}`,i]}var QI=4;function Xb(e,t,n=1){Yr(n<=QI,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,i]=GI(e);if(!r)return;const s=window.getComputedStyle(t).getPropertyValue(r);if(s){const o=s.trim();return Rd(o)?parseFloat(o):o}return Dd(i)?Xb(i,t,n+1):i}function XI(e){const t=[{},{}];return e?.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function Yb(e,t,n,r){const i=s=>typeof s=="function"?s(n!==void 0?n:e.custom,...XI(r)):s;return t=i(t),typeof t=="string"&&(t=e.variants&&e.variants[t]),i(t)}function $r(e,t,n){return Yb(e.getProps(),t,n,e)}var Jb=(e,t)=>t==="exit"?e.presenceContext?.custom:void 0,Zb=new Set(["width","height","top","left","right","bottom",...is]),YI=e=>Array.isArray(e);function JI(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Hi(n))}function ZI(e){return YI(e)?e[e.length-1]||0:e}function eD(e,t){let{transitionEnd:n={},transition:r={},...i}=$r(e,t)||{};i={...i,...n};for(const s in i)JI(e,s,ZI(i[s]))}var Ze=e=>!!(e&&e.getVelocity);function tD(e){return!!(Ze(e)&&e.add)}function Ch(e,t){const n=e.getValue("willChange");if(tD(n))return n.add(t);if(!n&&Qn.WillChange){const r=new Qn.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function qd(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var nD="framerAppearId",ew="data-"+qd(nD);function tw(e){return e.props[ew]}var rD=typeof window<"u";function iD({protectedKeys:e,needsAnimating:t},n){const r=n in e&&!t[n];return t[n]=!1,r}function nw(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:s,transitionEnd:o,...a}=t;const l=e.getDefaultTransition();s=s?Qb(s,l):l;const c=s?.reduceMotion,u=s?.skipAnimations;r&&(s=r);const h=[],f=i&&e.animationState?.getState()[i],d=s?.path;d&&d.animateVisualElement(e,a,s,n,h);for(const p in a){const v=e.getValue(p,e.latestValues[p]??null),y=a[p];if(y===void 0||f&&iD(f,p))continue;const x={delay:n,...Wd(s||{},p)};u&&(x.skipAnimations=!0);const b=v.get();if(b!==void 0&&!v.isAnimating()&&!Array.isArray(y)&&y===b&&!x.velocity){we.update(()=>v.set(y));continue}let w=!1;if(rD&&window.MotionHandoffAnimation){const T=tw(e);if(T){const k=window.MotionHandoffAnimation(T,p,we);k!==null&&(x.startTime=k,w=!0)}}Ch(e,p);const S=c??e.shouldReduceMotion;v.start(Hd(p,v,y,S&&Zb.has(p)?{type:!1}:x,e,w));const C=v.animation;C&&h.push(C)}if(o){const p=()=>we.update(()=>{o&&eD(e,o)});h.length?Promise.all(h).then(p):p()}return h}function Th(e,t,n={}){const r=$r(e,t,Jb(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),s=()=>Promise.all(r?nw(e,r,n):[]),o=(l=0)=>{const{variantChildren:c}=e,{delayChildren:u=0,staggerChildren:h,staggerDirection:f}=i,d=[];return c?.forEach(p=>{p.notify("AnimationStart",t),d.push(Th(p,t,{...n,delay:l+(typeof u=="function"?0:u)+Gb(c,p,u,h,f)}).then(()=>p.notify("AnimationComplete",t)))}),Promise.all(d)},{when:a}=i;return a?a==="beforeChildren"?s().then(()=>o()):o().then(s):Promise.all([s(),o(n.delay)])}function sD(e,t,n={}){return e.notify("AnimationStart",t),(Array.isArray(t)?Promise.all(t.map(r=>Th(e,r,n))):typeof t=="string"?Th(e,t,n):Promise.all(nw(e,$r(e,t,n.custom),n))).then(()=>{e.notify("AnimationComplete",t)})}var oD={test:e=>e==="auto",parse:e=>e},aD=e=>t=>t.test(e),lD=[rs,Q,wn,En,yO,vO,oD],Em=e=>lD.find(aD(e));function cD(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Ed(e):!0}var uD=new Set(["auto","none","0"]);function hD(e,t,n){let r=0,i;for(;r<e.length&&!i;){const s=e[r];typeof s=="string"&&!uD.has(s)&&CO(s)&&(i=e[r]),r++}if(i&&n)for(const s of t)e[s]!==i&&(e[s]=zd(n,i))}var fD=class extends $d{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(),Dd(l))){const c=Xb(l,t.current);c!==void 0&&(e[a]=c),a===e.length-1&&(this.finalKeyframe=l)}}if(this.resolveNoneKeyframes(),!Zb.has(n)||e.length!==2)return;const[r,i]=e;if(typeof r=="number"&&typeof i=="number")return;const s=Em(r),o=Em(i);if(hm(r)!==hm(i)&&Fr[n]){this.needsMeasurement=!0;return}if(s!==o)if(Sm(s)&&Sm(o))for(let a=0;a<e.length;a++){const l=e[a];typeof l=="string"&&(e[a]=parseFloat(l))}else Fr[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:t}=this,n=[];for(let r=0;r<e.length;r++)(e[r]===null||cD(e[r]))&&n.push(r);n.length&&hD(e,n,t)}measure(){const{element:e,name:t}=this;return Fr[t](window.getComputedStyle(e.current),()=>e.measureViewportBox())}measureInitialState(){const{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=this.measure(),t[0]=this.measuredOrigin;const r=t[t.length-1];r!==void 0&&this.motionValue?.jump(r,!1)}measureEndState(){const{element:e,unresolvedKeyframes:t}=this;if(!e||!e.current)return;this.motionValue?.jump(this.measuredOrigin,!1);const n=t.length-1,r=t[n];t[n]=this.measure(),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([i,s])=>{e.getValue(i).set(s)}),this.resolveNoneKeyframes()}},Ud=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"];function dD(e){return cb(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}function Kd(e){return cb(e)&&"ownerSVGElement"in e}var Ah=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function rw(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 pD={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},mD=is.length;function gD(e,t,n){let r="",i=!0;for(let o=0;o<mD;o++){const a=is[o],l=e[a];if(l===void 0)continue;let c=!0;if(typeof l=="number")c=l===(a.startsWith("scale")?1:0);else{const u=parseFloat(l);c=a.startsWith("scale")?u===1:u===0}if(!c||n){const u=Ah(l,ul[a]);if(!c){i=!1;const h=pD[a]||a;r+=`${h}(${u}) `}n&&(t[a]=u)}}const s=e.pathRotation;return s&&(i=!1,r+=`rotate(${Ah(s,ul.pathRotation)}) `),r=r.trim(),n?r=n(t,i?"":r):i&&(r="none"),r}function Gd(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(ur.has(l)){o=!0;continue}else if(Sb(l)){i[l]=c;continue}else{const u=Ah(c,ul[l]);l.startsWith("origin")?(a=!0,s[l]=u):r[l]=u}}if(t.transform||(o||n?r.transform=gD(t,e.transform,n):r.transform&&(r.transform="none")),a){const{originX:l="50%",originY:c="50%",originZ:u=0}=s;r.transformOrigin=`${l} ${c} ${u}`}}var vD={offset:"stroke-dashoffset",array:"stroke-dasharray"},yD={offset:"strokeDashoffset",array:"strokeDasharray"};function xD(e,t,n=1,r=0,i=!0){e.pathLength=1;const s=i?vD:yD;e[s.offset]=`${-r}`,e[s.array]=`${t} ${n}`}var iw=["transform","opacity","offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function sw(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:s=1,pathOffset:o=0,...a},l,c,u){if(Gd(e,a,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:h,style:f}=e;for(const d of iw)h[d]!==void 0&&(f[d]=h[d],delete h[d]);(f.transform||h.transformOrigin)&&(f.transformOrigin=h.transformOrigin??"50% 50%",delete h.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??"fill-box",delete h.transformBox),t!==void 0&&(h.x=t),n!==void 0&&(h.y=n),r!==void 0&&(h.scale=r),i!==void 0&&xD(h,i,s,o,!1)}function ow({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function bD({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function wD(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 Kc(e){return e===void 0||e===1}function Mh({scale:e,scaleX:t,scaleY:n}){return!Kc(e)||!Kc(t)||!Kc(n)}function Pr(e){return Mh(e)||aw(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function aw(e){return Pm(e.x)||Pm(e.y)}function Pm(e){return e&&e!=="0%"}function hl(e,t,n){return n+t*(e-n)}function Om(e,t,n,r,i){return i!==void 0&&(e=hl(e,i,r)),hl(e,n,r)+t}function Rh(e,t=0,n=1,r,i){e.min=Om(e.min,t,n,r,i),e.max=Om(e.max,t,n,r,i)}function lw(e,{x:t,y:n}){Rh(e.x,t.translate,t.scale,t.originPoint),Rh(e.y,n.translate,n.scale,n.originPoint)}var Im=.999999999999,Dm=1.0000000000001;function SD(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&&(dn(e.x,-s.scroll.offset.x),dn(e.y,-s.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,lw(e,o)),r&&Pr(s.latestValues)&&Aa(e,s.latestValues,s.layout?.layoutBox))}t.x<Dm&&t.x>Im&&(t.x=1),t.y<Dm&&t.y>Im&&(t.y=1)}function dn(e,t){e.min+=t,e.max+=t}function Nm(e,t,n,r,i=.5){Rh(e,t,n,ye(e.min,e.max,i),r)}function Lm(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Aa(e,t,n){const r=n??e;Nm(e.x,Lm(t.x,r.x),t.scaleX,t.scale,t.originX),Nm(e.y,Lm(t.y,r.y),t.scaleY,t.scale,t.originY)}function cw(e,t){return ow(wD(e.getBoundingClientRect(),t))}function kD(e,t,n){const r=cw(e,n),{scroll:i}=t;return i&&(dn(r.x,i.offset.x),dn(r.y,i.offset.y)),r}var{schedule:Qd,cancel:T3}=Pb(queueMicrotask,!1),$t={x:!1,y:!1};function uw(){return $t.x||$t.y}function CD(e){return e==="x"||e==="y"?$t[e]?null:($t[e]=!0,()=>{$t[e]=!1}):$t.x||$t.y?null:($t.x=$t.y=!0,()=>{$t.x=$t.y=!1})}function hw(e,t){const n=rw(e),r=new AbortController,i={passive:!0,...t,signal:r.signal};return[n,i,()=>r.abort()]}function TD(e){return!(e.pointerType==="touch"||uw())}function AD(e,t,n={}){const[r,i,s]=hw(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(!TD(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 fw=(e,t)=>t?e===t?!0:fw(e,t.parentElement):!1,Xd=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,MD=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function RD(e){return MD.has(e.tagName)||e.isContentEditable===!0}var ED=new Set(["INPUT","SELECT","TEXTAREA"]);function PD(e){return ED.has(e.tagName)||e.isContentEditable===!0}var Ma=new WeakSet;function jm(e){return t=>{t.key==="Enter"&&e(t)}}function Gc(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}var OD=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=jm(()=>{if(Ma.has(n))return;Gc(n,"down");const i=jm(()=>{Gc(n,"up")}),s=()=>Gc(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 _m(e){return Xd(e)&&!uw()}var Bm=new WeakSet;function ID(e,t,n={}){const[r,i,s]=hw(e,n),o=a=>{const l=a.currentTarget;if(!_m(a)||Bm.has(a))return;Ma.add(l),n.stopPropagation&&Bm.add(a);const c=t(l,a),u={...i,capture:!0},h=(p,v)=>{window.removeEventListener("pointerup",f,u),window.removeEventListener("pointercancel",d,u),Ma.has(l)&&Ma.delete(l),_m(p)&&typeof c=="function"&&c(p,{success:v})},f=p=>{h(p,l===window||l===document||n.useGlobalTarget||fw(l,p.target))},d=p=>{h(p,!1)};window.addEventListener("pointerup",f,u),window.addEventListener("pointercancel",d,u)};return r.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),dD(a)&&(a.addEventListener("focus",l=>OD(l,i)),!RD(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),s}var Ra=new WeakMap,Ea,dw=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+"Size"]:Kd(r)&&"getBBox"in r?r.getBBox()[t]:r[n],DD=dw("inline","width","offsetWidth"),ND=dw("block","height","offsetHeight");function LD({target:e,borderBoxSize:t}){Ra.get(e)?.forEach(n=>{n(e,{get width(){return DD(e,t)},get height(){return ND(e,t)}})})}function jD(e){e.forEach(LD)}function _D(){typeof ResizeObserver>"u"||(Ea=new ResizeObserver(jD))}function BD(e,t){Ea||_D();const n=rw(e);return n.forEach(r=>{let i=Ra.get(r);i||(i=new Set,Ra.set(r,i)),i.add(t),Ea?.observe(r)}),()=>{n.forEach(r=>{const i=Ra.get(r);i?.delete(t),i?.size||Ea?.unobserve(r)})}}var Pa=new Set,ki;function VD(){ki=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Pa.forEach(t=>t(e))},window.addEventListener("resize",ki)}function FD(e){return Pa.add(e),ki||VD(),()=>{Pa.delete(e),!Pa.size&&typeof ki=="function"&&(window.removeEventListener("resize",ki),ki=void 0)}}function Vm(e,t){return typeof e=="function"?FD(e):BD(e,t)}var gi={value:null,addProjectionMetrics:null};function zD(e){return Kd(e)&&e.tagName==="svg"}var Fm=e=>typeof e=="number"?e:parseFloat(e),zm=()=>({translate:0,scale:1,origin:0,originPoint:0}),Ci=()=>({x:zm(),y:zm()}),$m=()=>({min:0,max:0}),Be=()=>({x:$m(),y:$m()}),$D=new WeakMap;function Zl(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function ro(e){return typeof e=="string"||Array.isArray(e)}var Yd=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Wm=["initial",...Yd];function ec(e){if(Zl(e.animate))return!0;for(let t=0;t<Wm.length;t++)if(ro(e[Wm[t]]))return!0;return!1}function pw(e){return!!(ec(e)||e.variants)}function WD(e,t,n){for(const r in t){const i=t[r],s=n[r];if(Ze(i))e.addValue(r,i);else if(Ze(s))e.addValue(r,Hi(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,Hi(o!==void 0?o:i,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}var fl={current:null},Jd={current:!1},HD=typeof window<"u";function mw(){if(Jd.current=!0,!!HD)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>fl.current=e.matches;e.addEventListener("change",t),t()}else fl.current=!1}var Hm=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],dl={};function gw(e){dl=e}function qD(){return dl}var UD=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=$d,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=Je.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,we.render(this.render,!1,!0))};const{latestValues:l,renderState:c}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=t.initial?{...l}:{},this.renderState=c,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=a,this.blockInitialAnimation=!!s,this.isControllingVariants=ec(t),this.isVariantNode=pw(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&&Ze(d)&&d.set(l[f])}}mount(e){if(this.hasBeenMounted)for(const t in this.initialValues)this.values.get(t)?.jump(this.initialValues[t]),this.latestValues[t]=this.initialValues[t];if(this.current=e,$D.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.isVariantNode&&!this.isControllingVariants){let t=this;do t=t.props.inherit!==!1&&t.parent;while(t&&!t.isVariantNode);if(t){const{variantChildren:n}=t;n.add(this),this.removeFromVariantTree=()=>n.delete(this)}}this.values.forEach((t,n)=>this.bindToMotionValue(n,t)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(Jd.current||mw(),this.shouldReduceMotion=fl.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(),pr(this.notifyUpdate),pr(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&&kh.has(e)&&this.current instanceof HTMLElement){const{factory:s,keyframes:o,times:a,ease:l,duration:c}=t.accelerate,u=new Ub({element:this.current,name:e,keyframes:o,times:a,ease:l,duration:Et(c)}),h=s(u);this.valueSubscriptions.set(e,()=>{h(),u.cancel()});return}const n=ur.has(e);n&&this.onBindTransform&&this.onBindTransform();const r=t.on("change",s=>{this.latestValues[e]=s,this.props.onUpdate&&we.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let i;typeof window<"u"&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!e.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in dl){const t=dl[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):Be()}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<Hm.length;n++){const r=Hm[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=WD(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}addValue(e,t){const n=this.values.get(e);if(t!==n){n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t);const r=t.get();r!==void 0&&(this.latestValues[e]=r)}}removeValue(e){this.values.delete(e);const t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=Hi(t??this.getDefaultValue?.(e),{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n=="string"&&(Rd(n)||Ed(n))?n=parseFloat(n):typeof n!="number"&&!Pt.test(n)&&Pt.test(t)&&(n=zd(e,t)),this.setBaseTarget(e,Ze(n)?n.get():n)),Ze(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new ol),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Qd.render(this.render)}},vw=class extends UD{constructor(){super(...arguments),this.KeyframeResolver=fD}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;Ze(e)&&(this.childSubscription=e.on("change",t=>{this.current&&(this.current.textContent=`${t}`)}))}},kr=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function yw(e,{style:t,vars:n},r,i){const s=e.style;let o;for(o in t)s[o]=t[o];i?.applyProjectionStyles(s,r);for(o in n)s.setProperty(o,n[o])}var io={};function xw(e,{layout:t,layoutId:n}){return ur.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!io[e]||e==="opacity")}function Zd(e,t,n){const r=e.style,i=t?.style,s={};if(!r)return s;for(const o in r)(Ze(r[o])||i&&Ze(i[o])||xw(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(s[o]=r[o]);return s}function KD(e){return window.getComputedStyle(e)}var GD=class extends vw{constructor(){super(...arguments),this.type="html",this.renderInstance=yw}mount(e){Yr(!!e.style,"motion.create() components must forward their ref to a HTML or SVG element","custom-component-ref"),super.mount(e)}readValueFromInstance(e,t){if(ur.has(t))return this.projection?.isProjecting?no(t):pI(e,t);{const n=KD(e),r=(Sb(t)?n.getPropertyValue(t):n[t])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return cw(e,t)}build(e,t,n){Gd(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Zd(e,t,n)}},bw=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"]),ww=e=>typeof e=="string"&&e.toLowerCase()==="svg";function QD(e,t,n,r){yw(e,t,void 0,r);for(const i in t.attrs)e.setAttribute(bw.has(i)?i:qd(i),t.attrs[i])}function Sw(e,t,n){const r=Zd(e,t,n);for(const i in e)if(Ze(e[i])||Ze(t[i])){const s=is.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[s]=e[i]}return r}var XD=class extends vw{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Be}getBaseTargetFromProps(e,t){return ur.has(t)?super.getBaseTargetFromProps(e,t)??no(t):e[t]}getDefaultValue(e){return ur.has(e)?this.latestValues[e]??no(e):void 0}readValueFromInstance(e,t){if(ur.has(t)){const n=Bb(t);return n&&n.default||0}if(iw.includes(t)){const n=getComputedStyle(e)[t];if(typeof n=="string"&&n)return n.trim()}return t=bw.has(t)?t:qd(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Sw(e,t,n)}build(e,t,n){sw(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){QD(e,t,n,r)}mount(e){this.isSVGTag=ww(e.tagName),super.mount(e)}};function kw(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 YD=[...Yd].reverse();function JD(e){let t=a=>Promise.all(a.map(({animation:l,options:c})=>sD(e,l,c))),n=qm(),r=!0,i=!1;function s(a){const{props:l,parent:c,manuallyAnimateOnMount:u}=e,h=r||i,f=[],d=new Set;let p={},v=1/0,y=e;do y=y.props.inherit!==!1&&y.parent;while(y&&!y.isControllingVariants);if(YD.forEach((b,w)=>{const S=n[b],C=l[b],T=y&&y.props[b],k=C!==void 0?C:ro(T)||T===!1?T:void 0,A=ro(k),M=b===a?S.isActive:null;M===!1&&(v=w);const E=A&&C===void 0&&!(h&&u);if(S.protectedKeys={...p},!S.isActive&&M===null||!k&&!S.prevProp||Zl(k)||typeof k=="boolean")return;if(b==="exit"&&S.isActive&&M!==!0){p={...p,...S.prevResolvedValues};return}const O=ZD(S.prevProp,k);let R=O||A&&(M&&!E||w>v),L=!1;const N=Array.isArray(k)?k:[k];let P={};if(M!==!1)for(const V of N){const{transition:W,transitionEnd:B,...D}=$r(e,V,Jb(e,b))||{};P={...P,...D,...B}}const{prevResolvedValues:j}=S;for(const V in{...j,...P}){if(V in p)continue;const W=P[V],B=j[V],D=Array.isArray(W)&&Array.isArray(B)?!kw(W,B)||O:W!==B;if(D&&W==null)d.add(V);else if(D||W!==void 0&&d.has(V)){R=!0,d.delete(V)&&(L=!0),S.needsAnimating[V]=!0;const te=e.getValue(V);te&&(te.liveStyle=!1)}else S.protectedKeys[V]=!0}if(S.prevProp=k,S.prevResolvedValues=P,S.isActive&&(p={...p,...P}),R&&(!(E&&O)||L))for(const V of N){const W={type:b};if(typeof V=="string"&&h&&u&&c?.enteringChildren){const B=$r(c,V)?.transition?.delayChildren;W.delay=Gb(c.enteringChildren,e,B)}f.push({animation:V,options:W})}}),d.size){const{initial:b}=l,w={},S=typeof b!="boolean"&&$r(e,Array.isArray(b)?b[0]:b,e.presenceContext?.custom);S&&S.transition&&(w.transition=S.transition),d.forEach(C=>{const T=e.getValue(C);T&&(T.liveStyle=!0);const k=S&&!Array.isArray(b)?S[C]:void 0,A=e.getBaseTargetFromProps(l,C);w[C]=(k!==void 0?k:A!==void 0&&!Ze(A)?A:e.initialValues[C]===void 0?e.baseTarget[C]:void 0)??null}),f.push({animation:w})}const x=h&&e.blockInitialAnimation||r&&!u&&(l.initial===!1||l.initial===l.animate);return r=i=!1,!x&&f.length?t(f):Promise.resolve()}function o(a,l){if(n[a].isActive===l)return Promise.resolve();e.variantChildren?.forEach(u=>u.animationState?.setActive(a,l)),n[a].isActive=l;const c=s(a);for(const u in n)n[u].protectedKeys={};return c}return{animateChanges:s,setActive:o,setAnimateFunction:a=>{t=a(e)},getState:()=>n,reset:()=>{n=qm(),i=!0}}}function ZD(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!kw(t,e):!1}function qm(){const e={};for(const t of Yd)e[t]={isActive:t==="animate",protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function Eh(e,t){e.min=t.min,e.max=t.max}function Vt(e,t){Eh(e.x,t.x),Eh(e.y,t.y)}function Um(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var e2=.9999,t2=1.0001,n2=-.01,r2=.01;function ut(e){return e.max-e.min}function i2(e,t,n){return Math.abs(e-t)<=n}function Km(e,t,n,r=.5){e.origin=r,e.originPoint=ye(t.min,t.max,e.origin),e.scale=ut(n)/ut(t),e.translate=ye(n.min,n.max,e.origin)-e.originPoint,(e.scale>=e2&&e.scale<=t2||isNaN(e.scale))&&(e.scale=1),(e.translate>=n2&&e.translate<=r2||isNaN(e.translate))&&(e.translate=0)}function Ls(e,t,n,r){Km(e.x,t.x,n.x,r?r.originX:void 0),Km(e.y,t.y,n.y,r?r.originY:void 0)}function Gm(e,t,n,r=0){e.min=(r?ye(n.min,n.max,r):n.min)+t.min,e.max=e.min+ut(t)}function s2(e,t,n,r){Gm(e.x,t.x,n.x,r?.x),Gm(e.y,t.y,n.y,r?.y)}function Qm(e,t,n,r=0){const i=r?ye(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+ut(t)}function pl(e,t,n,r){Qm(e.x,t.x,n.x,r?.x),Qm(e.y,t.y,n.y,r?.y)}function Xm(e,t,n,r,i){return e-=t,e=hl(e,1/n,r),i!==void 0&&(e=hl(e,1/i,r)),e}function o2(e,t=0,n=1,r=.5,i,s=e,o=e){if(wn.test(t)&&(t=parseFloat(t),t=ye(o.min,o.max,t/100)-o.min),typeof t!="number")return;let a=ye(s.min,s.max,r);e===s&&(a-=t),e.min=Xm(e.min,t,n,a,i),e.max=Xm(e.max,t,n,a,i)}function Ym(e,t,[n,r,i],s,o){o2(e,t[n],t[r],t[i],t.scale,s,o)}var a2=["x","scaleX","originX"],l2=["y","scaleY","originY"];function Jm(e,t,n,r){Ym(e.x,t,a2,n?n.x:void 0,r?r.x:void 0),Ym(e.y,t,l2,n?n.y:void 0,r?r.y:void 0)}function Zm(e){return e.translate===0&&e.scale===1}function Cw(e){return Zm(e.x)&&Zm(e.y)}function eg(e,t){return e.min===t.min&&e.max===t.max}function c2(e,t){return eg(e.x,t.x)&&eg(e.y,t.y)}function tg(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Tw(e,t){return tg(e.x,t.x)&&tg(e.y,t.y)}function ng(e){return ut(e.x)/ut(e.y)}function rg(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function un(e){return[e("x"),e("y")]}function ig(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var fs={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Q.test(e))e=parseFloat(e);else return e;return`${ig(e,t.target.x)}% ${ig(e,t.target.y)}%`}},u2={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,i=Pt.parse(e);if(i.length>5)return r;const s=Pt.createTransformer(e),o=typeof i[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;i[0+o]/=a,i[1+o]/=l;const c=ye(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=c),typeof i[3+o]=="number"&&(i[3+o]/=c),s(i)}};function h2(e,t,n){let r="";const i=e.x.translate/t.x,s=e.y.translate/t.y,o=n?.z||0;if((i||s||o)&&(r=`translate3d(${i}px, ${s}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:c,rotate:u,pathRotation:h,rotateX:f,rotateY:d,skewX:p,skewY:v}=n;c&&(r=`perspective(${c}px) ${r}`),u&&(r+=`rotate(${u}deg) `),h&&(r+=`rotate(${h}deg) `),f&&(r+=`rotateX(${f}deg) `),d&&(r+=`rotateY(${d}deg) `),p&&(r+=`skewX(${p}deg) `),v&&(r+=`skewY(${v}deg) `)}const a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(r+=`scale(${a}, ${l})`),r||"none"}var f2=Ud.length,sg=e=>typeof e=="number"||Q.test(e);function d2(e,t,n,r,i,s){i?(e.opacity=ye(0,n.opacity??1,p2(r)),e.opacityExit=ye(t.opacity??1,0,m2(r))):s&&(e.opacity=ye(t.opacity??1,n.opacity??1,r));for(let o=0;o<f2;o++){const a=Ud[o];let l=og(t,a),c=og(n,a);l===void 0&&c===void 0||(l||(l=0),c||(c=0),l===0||c===0||sg(l)===sg(c)?(e[a]=Math.max(ye(Fm(l),Fm(c),r),0),(wn.test(c)||wn.test(l))&&(e[a]+="%")):e[a]=c)}(t.rotate||n.rotate)&&(e.rotate=ye(t.rotate||0,n.rotate||0,r))}function og(e,t){return e[t]!==void 0?e[t]:e.borderRadius}var p2=Aw(0,.5,yb),m2=Aw(.5,.95,Kt);function Aw(e,t,n){return r=>r<e?0:r>t?1:n(Zs(e,t,r))}function g2(e,t,n){const r=Ze(e)?e:Hi(e);return r.start(Hd("",r,t,n)),r.animation}function so(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var v2=(e,t)=>e.depth-t.depth,y2=class{constructor(){this.children=[],this.isDirty=!1}add(e){Md(this.children,e),this.isDirty=!0}remove(e){sl(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(v2),this.isDirty=!1,this.children.forEach(e)}};function x2(e,t){const n=Je.now(),r=({timestamp:i})=>{const s=i-n;s>=t&&(pr(r),e(s-t))};return we.setup(r,!0),()=>pr(r)}function Oa(e){return Ze(e)?e.get():e}var b2=class{constructor(){this.members=[]}add(e){Md(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&&(sl(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(sl(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)}},w2={borderRadius:{...fs,applyTo:[...Ud]},borderTopLeftRadius:fs,borderTopRightRadius:fs,borderBottomLeftRadius:fs,borderBottomRightRadius:fs,boxShadow:u2},Ia={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(io,{...w2,...io});var Or={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Qc=["","X","Y","Z"],S2=1e3,k2=0;function Xc(e,t,n,r){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Mw(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=tw(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:s}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",we,!(i||s))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Mw(r)}function Rw({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(o={},a=t?.()){this.id=k2++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,gi.value&&(Or.nodes=Or.calculatedTargetDeltas=Or.calculatedProjections=0),this.nodes.forEach(A2),this.nodes.forEach(D2),this.nodes.forEach(N2),this.nodes.forEach(M2),gi.addProjectionMetrics&&gi.addProjectionMetrics(Or)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new y2)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new ol),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=Kd(o)&&!zD(o),this.instance=o;const{layoutId:a,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let u,h=0;const f=()=>this.root.updateBlockedByResize=!1;we.read(()=>{h=window.innerWidth}),e(o,()=>{const d=window.innerWidth;d!==h&&(h=d,this.root.updateBlockedByResize=!0,u&&u(),u=x2(f,250),Ia.hasAnimatedSinceResize&&(Ia.hasAnimatedSinceResize=!1,this.nodes.forEach(cg)))})}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()||V2,{onLayoutAnimationStart:v,onLayoutAnimationComplete:y}=c.getProps(),x=!this.targetLayout||!Tw(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={...Wd(p,"layout"),onPlay:v,onComplete:y};(c.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(u,b,w.path)}else h||cg(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(),pr(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(L2),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&&Mw(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(E2),this.nodes.forEach(ag);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(lg);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(P2),this.nodes.forEach(O2),this.nodes.forEach(I2),this.nodes.forEach(C2),this.nodes.forEach(T2)):this.nodes.forEach(lg),this.clearAllSnapshots();const o=Je.now();Ve.delta=er(0,1e3/60,o-Ve.timestamp),Ve.timestamp=o,Ve.isProcessing=!0,Hc.update.process(Ve),Hc.preRender.process(Ve),Hc.render.process(Ve),Ve.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Qd.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(R2),this.sharedNodes.forEach(j2)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,we.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){we.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ut(this.snapshot.measuredBox.x)&&!ut(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected||(this.layoutCorrected=Be()),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&&!Cw(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;o&&this.instance&&(a||Pr(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)),F2(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return Be();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(z2))){const{scroll:l}=this.root;l&&(dn(a.x,l.offset.x),dn(a.y,l.offset.y))}return a}removeElementScroll(o){const a=Be();if(Vt(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&&Vt(a,o),dn(a.x,u.offset.x),dn(a.y,u.offset.y))}return a}applyTransform(o,a=!1,l){const c=l||Be();Vt(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&&(dn(c.x,-h.scroll.offset.x),dn(c.y,-h.scroll.offset.y)),Pr(h.latestValues)&&Aa(c,h.latestValues,h.layout?.layoutBox)}return Pr(this.latestValues)&&Aa(c,this.latestValues,this.layout?.layoutBox),c}removeTransform(o){const a=Be();Vt(a,o);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!Pr(c.latestValues))continue;let u;c.instance&&(Mh(c.latestValues)&&c.updateSnapshot(),u=Be(),Vt(u,c.measurePageBox())),Jm(a,c.latestValues,c.snapshot?.layoutBox,u)}return Pr(this.latestValues)&&Jm(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!==Ve.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=Ve.timestamp;const h=this.getClosestProjectingParent();!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&h&&h.layout?this.createRelativeTarget(h,this.layout.layoutBox,h.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Be(),this.targetWithTransforms=Be()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),s2(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Vt(this.target,this.layout.layoutBox),lw(this.target,this.targetDelta)):Vt(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),gi.value&&Or.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Mh(this.parent.latestValues)||aw(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(o,a,l){this.relativeParent=o,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Be(),this.relativeTargetOrigin=Be(),pl(this.relativeTargetOrigin,a,l,this.options.layoutAnchor||void 0),Vt(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===Ve.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;Vt(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,f=this.treeScale.y;SD(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=Be());const{target:d}=o;if(!d){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Um(this.prevProjectionDelta.x,this.projectionDelta.x),Um(this.prevProjectionDelta.y,this.projectionDelta.y)),Ls(this.projectionDelta,this.layoutCorrected,d,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==f||!rg(this.projectionDelta.x,this.prevProjectionDelta.x)||!rg(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",d)),gi.value&&Or.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=Ci(),this.projectionDelta=Ci(),this.projectionDeltaWithTransform=Ci()}setAnimationOrigin(o,a=!1,l){const c=this.snapshot,u=c?c.latestValues:{},h={...this.latestValues},f=Ci();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const d=Be(),p=(c?c.source:void 0)!==(this.layout?this.layout.source:void 0),v=this.getStack(),y=!v||v.members.length<=1,x=!!(p&&!y&&this.options.crossfade===!0&&!this.path.some(B2));this.animationProgress=0;let b;const w=l?.interpolateProjection(o);this.mixTargetDelta=S=>{const C=S/1e3,T=w?.(C);T?(f.x.translate=T.x,f.x.scale=ye(o.x.scale,1,C),f.x.origin=o.x.origin,f.x.originPoint=o.x.originPoint,f.y.translate=T.y,f.y.scale=ye(o.y.scale,1,C),f.y.origin=o.y.origin,f.y.originPoint=o.y.originPoint):(ug(f.x,o.x,C),ug(f.y,o.y,C)),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(pl(d,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),_2(this.relativeTarget,this.relativeTargetOrigin,d,C),b&&c2(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=Be()),Vt(b,this.relativeTarget)),p&&(this.animationValues=h,d2(h,u,this.latestValues,C,x,y)),T&&T.rotate!==void 0&&(this.animationValues||(this.animationValues=h),this.animationValues.pathRotation=T.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=C},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(pr(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=we.update(()=>{Ia.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Hi(0)),this.motionValue.jump(0,!1),this.currentAnimation=g2(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),rI(this.currentAnimation,this),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(S2),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead(),{targetWithTransforms:a,layout:l,latestValues:c}=o;let{target:u}=o;if(!(!a||!u||!l)){if(this!==o&&this.layout&&l&&Ew(this.options.animationType,this.layout.layoutBox,l.layoutBox)){u=this.target||Be();const h=ut(this.layout.layoutBox.x);u.x.min=o.target.x.min,u.x.max=u.x.min+h;const f=ut(this.layout.layoutBox.y);u.y.min=o.target.y.min,u.y.max=u.y.min+f}Vt(a,u),Aa(a,c),Ls(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new b2),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&&Xc("z",o,c,this.animationValues);for(let u=0;u<Qc.length;u++)Xc(`rotate${Qc[u]}`,o,c,this.animationValues),Xc(`skew${Qc[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=Oa(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=Oa(a?.pointerEvents)||""),this.hasProjected&&!Pr(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let h=h2(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 io){if(u[p]===void 0)continue;const{correct:v,applyTo:y,isCSSVariable:x}=io[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?Oa(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(ag),this.root.sharedNodes.clear()}}}function C2(e){e.updateLayout()}function T2(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")un(u=>{const h=s?t.measuredBox[u]:t.layoutBox[u],f=ut(h);h.min=n[u].min,h.max=h.min+f});else if(i==="x"||i==="y"){const u=i==="x"?"y":"x";Eh(s?t.measuredBox[u]:t.layoutBox[u],n[u])}else Ew(i,t.layoutBox,n)&&un(u=>{const h=s?t.measuredBox[u]:t.layoutBox[u],f=ut(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=Ci();Ls(o,n,t.layoutBox);const a=Ci();s?Ls(a,e.applyTransform(r,!0),t.measuredBox):Ls(a,n,t.layoutBox);const l=!Cw(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=Be();pl(p,t.layoutBox,h.layoutBox,d);const v=Be();pl(v,n,f.layoutBox,d),Tw(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 A2(e){gi.value&&Or.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 M2(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function R2(e){e.clearSnapshot()}function ag(e){e.clearMeasurements()}function E2(e){e.isLayoutDirty=!0,e.updateLayout()}function lg(e){e.isLayoutDirty=!1}function P2(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function O2(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function I2(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function cg(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function D2(e){e.resolveTargetDelta()}function N2(e){e.calcProjection()}function L2(e){e.resetSkewAndRotation()}function j2(e){e.removeLeadSnapshot()}function ug(e,t,n){e.translate=ye(t.translate,0,n),e.scale=ye(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function hg(e,t,n,r){e.min=ye(t.min,n.min,r),e.max=ye(t.max,n.max,r)}function _2(e,t,n,r){hg(e.x,t.x,n.x,r),hg(e.y,t.y,n.y,r)}function B2(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var V2={duration:.45,ease:[.4,0,.1,1]},fg=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),dg=fg("applewebkit/")&&!fg("chrome/")?Math.round:Kt;function pg(e){e.min=dg(e.min),e.max=dg(e.max)}function F2(e){pg(e.x),pg(e.y)}function Ew(e,t,n){return e==="position"||e==="preserve-aspect"&&!i2(ng(t),ng(n),.2)}function z2(e){return e!==e.root&&e.scroll?.wasRoot}var $2=Rw({attachResizeListener:(e,t)=>so(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Yc={current:void 0},Pw=Rw({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Yc.current){const e=new $2({});e.mount(window),e.setOptions({layoutScroll:!0}),Yc.current=e}return Yc.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Ow=(0,m.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function W2(e=!0){const t=(0,m.useContext)(Ad);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 Iw=(0,m.createContext)({strict:!1}),mg={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"]},gg=!1;function H2(){if(gg)return;const e={};for(const t in mg)e[t]={isEnabled:n=>mg[t].some(r=>!!n[r])};gw(e),gg=!0}function Dw(){return H2(),qD()}function q2(e){const t=Dw();for(const n in e)t[n]={...t[n],...e[n]};gw(t)}var tc=(0,m.createContext)({});function U2(e,t){if(ec(e)){const{initial:n,animate:r}=e;return{initial:n===!1||ro(n)?n:void 0,animate:ro(r)?r:void 0}}return e.inherit!==!1?t:{}}function K2(e){const{initial:t,animate:n}=U2(e,(0,m.useContext)(tc));return(0,m.useMemo)(()=>({initial:t,animate:n}),[vg(t),vg(n)])}function vg(e){return Array.isArray(e)?e.join(" "):e}var ep=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Nw(e,t,n){for(const r in t)!Ze(t[r])&&!xw(r,n)&&(e[r]=t[r])}function G2({transformTemplate:e},t){return(0,m.useMemo)(()=>{const n=ep();return Gd(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Q2(e,t){const n=e.style||{},r={};return Nw(r,n,e),Object.assign(r,G2(e,t)),r}function X2(e,t){const n={},r=Q2(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 Lw=()=>({...ep(),attrs:{}});function Y2(e,t,n,r){const i=(0,m.useMemo)(()=>{const s=Lw();return sw(s,t,ww(r),e.transformTemplate,e.style),{...s.attrs,style:{...s.style}}},[t]);if(e.style){const s={};Nw(s,e.style,e),i.style={...s,...i.style}}return i}var J2=new Set(["animate","exit","variants","initial","style","values","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function ml(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||J2.has(e)}function Z2(e,t){return e.startsWith("on")?!ml(e):t?.(e)??!ml(e)}function eN(e,t,n,r){const i={};for(const s in e)s==="values"&&typeof e.values=="object"||Ze(e[s])||(Z2(s,r)||n===!0&&ml(s)||!t&&!ml(s)||e.draggable&&s.startsWith("onDrag"))&&(i[s]=e[s]);return i}var tN=["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 tp(e){return typeof e!="string"||e.includes("-")?!1:!!(tN.indexOf(e)>-1||/[A-Z]/u.test(e))}function nN(e,t,n,{latestValues:r},i,s=!1,o,a){const l=(o??tp(e)?Y2:X2)(t,r,i,e),c=eN(t,typeof e=="string",s,a),u=e!==m.Fragment?{...c,...l,ref:n}:{},{children:h}=t,f=(0,m.useMemo)(()=>Ze(h)?h.get():h,[h]);return(0,m.createElement)(e,{...u,children:f})}function rN({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:iN(n,r,i,e),renderState:t()}}function iN(e,t,n,r){const i={},s=r(e,{});for(const f in s)i[f]=Oa(s[f]);let{initial:o,animate:a}=e;const l=ec(e),c=pw(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"&&!Zl(h)){const f=Array.isArray(h)?h:[h];for(let d=0;d<f.length;d++){const p=Yb(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 jw=e=>(t,n)=>{const r=(0,m.useContext)(tc),i=(0,m.useContext)(Ad),s=()=>rN(e,t,r,i);return n?s():tO(s)},sN=jw({scrapeMotionValuesFromProps:Zd,createRenderState:ep}),oN=jw({scrapeMotionValuesFromProps:Sw,createRenderState:Lw}),aN=Symbol.for("motionComponentSymbol");function lN(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),t&&(s?t.mount(s):t.unmount());const o=r.current;if(typeof o=="function")if(s){const a=o(s);typeof a=="function"&&(i.current=a)}else i.current?(i.current(),i.current=null):o(s);else o&&(o.current=s)},[t])}var _w=(0,m.createContext)({});function vi(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function cN(e,t,n,r,i,s){const{visualElement:o}=(0,m.useContext)(tc),a=(0,m.useContext)(Iw),l=(0,m.useContext)(Ad),c=(0,m.useContext)(Ow),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)(_w);p&&!p.projection&&i&&(p.type==="html"||p.type==="svg")&&uN(f.current,n,i,v);const y=(0,m.useRef)(!1);(0,m.useInsertionEffect)(()=>{p&&y.current&&p.update(n,l)});const x=n[ew],b=(0,m.useRef)(!!x&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(x)&&window.MotionHasOptimisedAnimation?.(x));return lm(()=>{!d.current||!p||(p.animationState?.animateChanges(),p.enteringChildren=void 0)},[]),lm(()=>{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 uN(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:Bw(e.parent)),e.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!o||a&&vi(a),visualElement:e,animationType:typeof s=="string"?s:"both",initialPromotionConfig:r,crossfade:h,layoutScroll:l,layoutRoot:c,layoutAnchor:u})}function Bw(e){if(e)return e.options.allowProjection!==!1?e.projection:Bw(e.parent)}function Jc(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&q2(r);const s=n?n==="svg":tp(e),o=s?oN:sN;function a(c,u){let h;const f={...(0,m.useContext)(Ow),...c,layoutId:hN(c)},{isStatic:d,isValidProp:p}=f,v=K2(c),y=o(c,d);if(!d&&typeof window<"u"){fN(f,r);const x=dN(f);h=x.MeasureLayout,v.visualElement=cN(e,y,f,i,x.ProjectionNode,s)}return(0,g.jsxs)(tc.Provider,{value:v,children:[h&&v.visualElement?(0,g.jsx)(h,{visualElement:v.visualElement,...f}):null,nN(e,c,lN(y,v.visualElement,u),y,d,t,s,p)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const l=(0,m.forwardRef)(a);return l[aN]=e,l}function hN({layoutId:e}){const t=(0,m.useContext)(lb).id;return t&&e!==void 0?t+"-"+e:e}function fN(e,t){(0,m.useContext)(Iw).strict}function dN(e){const{drag:t,layout:n}=Dw();if(!t&&!n)return{};const r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function pN(e,t){if(typeof Proxy>"u")return Jc;const n=new Map,r=(s,o)=>Jc(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,Jc(o,void 0,e,t)),n.get(o))})}var mN=(e,t)=>t.isSVG??tp(e)?new XD(t):new GD(t,{allowProjection:e!==m.Fragment}),gN=class extends kr{constructor(e){super(e),e.animationState||(e.animationState=JD(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Zl(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?.()}},vN=0,yN=class extends kr{constructor(){super(...arguments),this.id=vN++}update(){const{presenceContext:e,prevPresenceContext:t,animationState:n}=this.node;if(!e||!n)return;const{isPresent:r,onExitComplete:i}=e,s=t?.isPresent;if(r===s)return;if(r&&s===!1){if(this.exit===!0){const{initial:a}=this.node.getProps();if(a&&!Array.isArray(a)){const{transition:l,transitionEnd:c,...u}=$r(this.node,a)||{};for(const h in u)this.node.getValue(h)?.jump(u[h])}this.node.blockInitialAnimation=!1,n.reset(),n.animateChanges()}else n.setActive("exit",!1);this.exit=void 0;return}const o=this.exit=n.setActive("exit",!r);i&&!r&&o.then(()=>{this.exit===o&&(this.exit=!0,i(this.id))})}mount(){const{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}},xN={animation:{Feature:gN},exit:{Feature:yN}};function nc(e){return{point:{x:e.pageX,y:e.pageY}}}var bN=e=>t=>Xd(t)&&e(t,nc(t));function js(e,t,n,r){return so(e,t,bN(n),r)}var Vw=({current:e})=>e?e.ownerDocument.defaultView:null,yg=(e,t)=>Math.abs(e-t);function wN(e,t){const n=yg(e.x,t.x),r=yg(e.y,t.y);return Math.sqrt(n**2+r**2)}var xg=new Set(["auto","scroll"]),Fw=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:s=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=f=>{this.handleScroll(f.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.hasPendingMove=!1,this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Xo(this.lastRawMoveEventInfo,this.transformPagePoint));const f=Zc(this.lastMoveEventInfo,this.history),d=this.startEvent!==null,p=wN(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!d&&!p)return;const{point:v}=f;this.history.push({...v,timestamp:Je.now()});const{onStart:y,onMove:x}=this.handlers;d||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,f)},this.handlePointerMove=(f,d)=>{this.lastMoveEvent=f,this.lastRawMoveEventInfo=d,this.lastMoveEventInfo=Xo(d,this.transformPagePoint),this.hasPendingMove=!0,we.update(this.updatePoint,!0)},this.handlePointerUp=(f,d)=>{this.hasPendingMove&&this.updatePoint(),this.end();const{onEnd:p,onSessionEnd:v,resumeAnimation:y}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&y&&y(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=Zc(f.type==="pointercancel"?this.lastMoveEventInfo:Xo(d,this.transformPagePoint),this.history);this.startEvent&&p&&p(f,x),v&&v(f,x)},!Xd(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=s,this.contextWindow=r||window;const a=Xo(nc(e),this.transformPagePoint),{point:l}=a,{timestamp:c}=Ve;this.history=[{...l,timestamp:c}];const{onSessionStart:u}=t;u&&u(e,Zc(a,this.history));const h={passive:!0,capture:!0};this.removeListeners=Po(js(this.contextWindow,"pointermove",this.handlePointerMove,h),js(this.contextWindow,"pointerup",this.handlePointerUp,h),js(this.contextWindow,"pointercancel",this.handlePointerUp,h)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){const n=getComputedStyle(t);(xg.has(n.overflowX)||xg.has(n.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const t=this.scrollPositions.get(e);if(!t)return;const n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),we.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),pr(this.updatePoint)}};function Xo(e,t){return t?{point:t(e.point)}:e}function bg(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Zc({point:e},t){return{point:e,delta:bg(e,zw(t)),offset:bg(e,SN(t)),velocity:kN(t,.1)}}function SN(e){return e[0]}function zw(e){return e[e.length-1]}function kN(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const i=zw(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Et(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Et(t)*2&&(r=e[1]);const s=Nt(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 CN(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?ye(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?ye(n,e,r.max):Math.min(e,n)),e}function wg(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 TN(e,{top:t,left:n,bottom:r,right:i}){return{x:wg(e.x,n,i),y:wg(e.y,t,r)}}function Sg(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 AN(e,t){return{x:Sg(e.x,t.x),y:Sg(e.y,t.y)}}function MN(e,t){let n=.5;const r=ut(e),i=ut(t);return i>r?n=Zs(t.min,t.max-r,e.min):r>i&&(n=Zs(e.min,e.max-i,t.min)),er(0,1,n)}function RN(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 Ph=.35;function EN(e=Ph){return e===!1?e=0:e===!0&&(e=Ph),{x:kg(e,"left","right"),y:kg(e,"top","bottom")}}function kg(e,t,n){return{min:Cg(e,t),max:Cg(e,n)}}function Cg(e,t){return typeof e=="number"?e:e[t]||0}var PN=new WeakMap,ON=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=Be(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const i=u=>{t&&this.snapToCursor(u),this.stopAnimation()},s=(u,h)=>{const{drag:f,dragPropagation:d,onDragStart:p}=this.getProps();if(f&&!d&&(this.openDragLock&&this.openDragLock(),this.openDragLock=CD(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),un(y=>{let x=this.getAxisMotionValue(y).get()||0;if(wn.test(x)){const{projection:b}=this.visualElement;if(b&&b.layout){const w=b.layout.layoutBox[y];w&&(x=ut(w)*(parseFloat(x)/100))}}this.originPoint[y]=x}),p&&we.update(()=>p(u,h),!1,!0),Ch(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=DN(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&&we.update(()=>v(u,h),!1,!0)},a=(u,h)=>{this.latestPointerEvent=u,this.latestPanInfo=h,this.stop(u,h),this.latestPointerEvent=null,this.latestPanInfo=null},l=()=>{const{dragSnapToOrigin:u}=this.getProps();(u||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:c}=this.getProps();this.panSession=new Fw(e,{onSessionStart:i,onStart:s,onMove:o,onSessionEnd:a,resumeAnimation:l},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:n,contextWindow:Vw(this.visualElement),element:this.visualElement.current})}stop(e,t){const n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;const{velocity:s}=r;this.startAnimation(s);const{onDragEnd:o}=this.getProps();o&&we.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){const{drag:r}=this.getProps();if(!n||!Yo(e,r,this.currentDirection))return;const i=this.getAxisMotionValue(e);let s=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(s=CN(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&&vi(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&n?this.constraints=TN(n.layoutBox,e):this.constraints=!1,this.elastic=EN(t),r!==this.constraints&&!vi(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&un(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=RN(n.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!vi(e))return!1;const n=e.current;Yr(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());const i=kD(n,r.root,this.visualElement.getTransformPagePoint());let s=AN(r.layout.layoutBox,i);if(t){const o=t(bD(s));this.hasMutatedConstraints=!!o,o&&(s=ow(o))}return s}startAnimation(e){const{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:s,onDragTransitionEnd:o}=this.getProps(),a=this.constraints||{},l=un(c=>{if(!Yo(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 Ch(this.visualElement,e),n.start(Hd(e,n,0,t,this.visualElement,!1))}stopAnimation(){un(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps()[t];return n||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor({clientX:e,clientY:t}){const{drag:n}=this.getProps(),r={x:e,y:t},i=this.visualElement.getTransformPagePoint()?.(r)||r,s=this.visualElement.measureViewportBox();un(o=>{if(!Yo(o,n,this.currentDirection))return;const a=this.getAxisMotionValue(o),{min:l,max:c}=s[o];a.set((a.get()||0)+i[o]-ye(l,c,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!vi(t)||!n||!this.constraints)return;this.stopAnimation();const r=this.constraints,i={x:0,y:0};un(o=>{const a=this.getAxisMotionValue(o).get();i[o]=MN({min:a,max:a},r[o])});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),un(o=>{const a=this.getAxisMotionValue(o);if(!Yo(o,e,null)||!a.get())return;const{min:l,max:c}=this.constraints[o];a.set(ye(l,c,i[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;PN.set(this.visualElement,this);const e=this.visualElement.current,t=js(e,"pointerdown",l=>{const{drag:c,dragListener:u=!0}=this.getProps(),h=l.target,f=h!==e&&PD(h);c&&u&&!f&&this.start(l)});let n;const r=()=>{const{dragConstraints:l}=this.getProps();vi(l)&&l.current&&(this.constraints=this.resolveRefConstraints(),n||(n=IN(e,l.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,s=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),we.read(r);const o=so(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(un(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=Ph,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:s,dragMomentum:o}}};function Tg(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function IN(e,t,n){const r=Vm(e,Tg(n)),i=Vm(t,Tg(n));return()=>{r(),i()}}function Yo(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function DN(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}var NN=class extends kr{constructor(e){super(e),this.removeGroupControls=Kt,this.removeListeners=Kt,this.controls=new ON(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Kt}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()}},eu=e=>(t,n)=>{e&&we.update(()=>e(t,n),!1,!0)},LN=class extends kr{constructor(){super(...arguments),this.removePointerDownListener=Kt}onPointerDown(e){this.session=new Fw(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Vw(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:eu(e),onStart:eu(t),onMove:eu(n),onEnd:(i,s)=>{delete this.session,r&&we.postRender(()=>r(i,s))}}}mount(){this.removePointerDownListener=js(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},tu=!1,jN=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),tu&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Ia.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}),tu=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?s.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?s.promote():s.relegate()||we.postRender(()=>{const o=s.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),Qd.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;tu=!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 $w(e){const[t,n]=W2(),r=(0,m.useContext)(lb);return(0,g.jsx)(jN,{...e,layoutGroup:r,switchLayoutGroup:(0,m.useContext)(_w),isPresent:t,safeToRemove:n})}var _N={pan:{Feature:LN},drag:{Feature:NN,ProjectionNode:Pw,MeasureLayout:$w}};function Ag(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i=r["onHover"+n];i&&we.postRender(()=>i(t,nc(t)))}var BN=class extends kr{mount(){const{current:e}=this.node;e&&(this.unmount=AD(e,(t,n)=>(Ag(this.node,n,"Start"),r=>Ag(this.node,r,"End"))))}unmount(){}},VN=class extends kr{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=Po(so(this.node.current,"focus",()=>this.onFocus()),so(this.node.current,"blur",()=>this.onBlur()))}unmount(){}};function Mg(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i=r["onTap"+(n==="End"?"":n)];i&&we.postRender(()=>i(t,nc(t)))}var FN=class extends kr{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=ID(e,(r,i)=>(Mg(this.node,i,"Start"),(s,{success:o})=>Mg(this.node,s,o?"End":"Cancel")),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},Oh=new WeakMap,nu=new WeakMap,zN=e=>{const t=Oh.get(e.target);t&&t(e)},$N=e=>{e.forEach(zN)};function WN({root:e,...t}){const n=e||document;nu.has(n)||nu.set(n,{});const r=nu.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver($N,{root:e,...t})),r[i]}function HN(e,t,n){const r=WN(t);return Oh.set(e,n),r.observe(e),()=>{Oh.delete(e),r.unobserve(e)}}var qN={some:0,all:1},UN=class extends kr{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:qN[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=HN(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(KN(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function KN({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var GN={inView:{Feature:UN},tap:{Feature:FN},focus:{Feature:VN},hover:{Feature:BN}},QN={layout:{ProjectionNode:Pw,MeasureLayout:$w}},XN={...xN,...GN,..._N,...QN},Ww=pN(XN,mN);function YN(){!Jd.current&&mw();const[e]=(0,m.useState)(fl.current);return e}var Rg="1.46.0",oo=Symbol.for("functionName"),JN=Symbol.for("toReferencePath");function ZN(e){return e[JN]??null}function eL(e){return e.startsWith("function://")}function tL(e){let t;if(typeof e=="string")eL(e)?t={functionHandle:e}:t={name:e};else if(e[oo])t={name:e[oo]};else{const n=ZN(e);if(!n)throw new Error(`${e} is not a functionReference`);t={reference:n}}return t}function ht(e){const t=tL(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[oo];if(!n)throw new Error(`${e} is not a functionReference`);return n}function np(e){return{[oo]:e}}function Hw(e=[]){return new Proxy({},{get(t,n){if(typeof n=="string")return Hw([...e,n]);if(n===oo){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 M3=Hw(),nL=Object.defineProperty,rL=(e,t,n)=>t in e?nL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Eg=(e,t,n)=>rL(e,typeof t!="symbol"?t+"":t,n),iL="color:rgb(0, 145, 255)";function qw(e){switch(e){case"query":return"Q";case"mutation":return"M";case"action":return"A";case"any":return"?"}}var Uw=class{constructor(e){Eg(this,"_onLogLineFuncs"),Eg(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 Kw(e){const t=new Uw(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 Gw(e){return new Uw(e)}function gl(e,t,n,r,i){const s=qw(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}]`,iL,l)}else e.error(`[CONVEX ${s}(${r})] ${i}`)}function sL(e,t){const n=`[CONVEX FATAL ERROR] ${t}`;return e.error(n),new Error(n)}function Ti(e,t,n){return`[CONVEX ${qw(e)}(${t})] ${n.errorMessage}
42
+ Called by client`}function Ih(e,t){return t.data=e.errorData,t}function Jr(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 Wr(e,t){return JSON.stringify({udfPath:Jr(e),args:Sn(t)})}function Pg(e,t,n){const{initialNumItems:r,id:i}=n;return JSON.stringify({type:"paginated",udfPath:Jr(e),args:Sn(t),options:Sn({initialNumItems:r,id:i})})}var oL=Object.defineProperty,aL=(e,t,n)=>t in e?oL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rn=(e,t,n)=>aL(e,typeof t!="symbol"?t+"":t,n),lL=class{constructor(){rn(this,"nextQueryId"),rn(this,"querySetVersion"),rn(this,"querySet"),rn(this,"queryIdToToken"),rn(this,"identityVersion"),rn(this,"auth"),rn(this,"outstandingQueriesOlderThanRestart"),rn(this,"outstandingAuthOlderThanRestart"),rn(this,"paused"),rn(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=Jr(e),s=Wr(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:[Sn(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=Jr(e),r=Wr(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:[Sn(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]}}}},cL=Object.defineProperty,uL=(e,t,n)=>t in e?cL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jo=(e,t,n)=>uL(e,typeof t!="symbol"?t+"":t,n),hL=class{constructor(e,t){this.logger=e,this.markConnectionStateDirty=t,Jo(this,"inflightRequests"),Jo(this,"requestsOlderThanRestart"),Jo(this,"inflightMutationsCount",0),Jo(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)gl(this.logger,"info",n,r,a);const i=t.status;let s,o;if(e.success)s={success:!0,logLines:e.logLines,value:el(e.result)},o=()=>i.onResult(s);else{const a=e.result,{errorData:l}=e;gl(this.logger,"error",n,r,a),s={success:!1,errorMessage:a,errorData:l!==void 0?el(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}},fL=Object.defineProperty,dL=(e,t,n)=>t in e?fL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vl=(e,t,n)=>dL(e,typeof t!="symbol"?t+"":t,n),Og=class Dh{constructor(t){vl(this,"queryResults"),vl(this,"modifiedQueries"),this.queryResults=t,this.modifiedQueries=[]}getQuery(t,...n){const r=Dn(n[0]),i=ht(t),s=this.queryResults.get(Wr(i,r));if(s!==void 0)return Dh.queryValue(s.result)}getAllQueries(t){const n=[],r=ht(t);for(const i of this.queryResults.values())i.udfPath===Jr(r)&&n.push({args:i.args,value:Dh.queryValue(i.result)});return n}setQuery(t,n,r){const i=Dn(n),s=ht(t),o=Wr(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}},pL=class{constructor(){vl(this,"queryResults"),vl(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 Og(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 Og(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?Ih(n,new Wu(Ti("query",t.udfPath,n))):new Error(Ti("query",t.udfPath,n))}}hasQueryResult(e){return this.queryResults.get(e)!==void 0}queryLogs(e){return this.queryResults.get(e)?.result?.logLines}},mL=Object.defineProperty,gL=(e,t,n)=>t in e?mL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ru=(e,t,n)=>gL(e,typeof t!="symbol"?t+"":t,n),Do=class Pn{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 Pn(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?Ig:t>=vL?yL:new Pn(t%_s|0,t/_s|0)}toString(){return(BigInt(this.high)*BigInt(_s)+BigInt(this.low)).toString()}equals(t){return Pn.isLong(t)||(t=Pn.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 Pn.isLong(t)||(t=Pn.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"?Pn.fromNumber(t):new Pn(t.low,t.high)}},Ig=new Do(0,0),Dg=65536,_s=Dg*Dg,vL=_s*_s,yL=new Do(-1,-1),xL=Object.defineProperty,bL=(e,t,n)=>t in e?xL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zo=(e,t,n)=>bL(e,typeof t!="symbol"?t+"":t,n),Ng=class{constructor(e,t){Zo(this,"version"),Zo(this,"remoteQuerySet"),Zo(this,"queryPath"),Zo(this,"logger"),this.version={querySet:0,ts:Do.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)gl(this.logger,"info","query",r,s);const i=el(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)gl(this.logger,"info","query",r,s);const{errorData:i}=n;this.remoteQuerySet.set(n.queryId,{success:!1,errorMessage:n.errorMessage,errorData:i!==void 0?el(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=HC(e);return Do.fromBytesLE(Array.from(t))}function wL(e){const t=new Uint8Array(e.toBytesLE());return qC(t)}function Lg(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 SL(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:wL(e.maxObservedTimestamp)}:{...e,maxObservedTimestamp:void 0}}}var kL=Object.defineProperty,CL=(e,t,n)=>t in e?kL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Le=(e,t,n)=>CL(e,typeof t!="symbol"?t+"":t,n),TL=1e3,AL=1001,ML=1005,RL=4040,Da;function yi(){return Da===void 0&&(Da=Date.now()),typeof performance>"u"||!performance.now?Date.now():Math.round(Da+performance.now())}function jg(){return`t=${Math.round((yi()-Da)/100)/10}s`}var Qw={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 EL(e){if(e===void 0)return"Unknown";for(const t of Object.keys(Qw))if(e.startsWith(t))return t;return"Unknown"}var PL=class{constructor(e,t,n,r,i,s){this.markConnectionStateDirty=i,this.debug=s,Le(this,"socket"),Le(this,"connectionCount"),Le(this,"_hasEverConnected",!1),Le(this,"lastCloseReason"),Le(this,"transitionChunkBuffer",null),Le(this,"defaultInitialBackoff"),Le(this,"maxBackoff"),Le(this,"retries"),Le(this,"serverInactivityThreshold"),Le(this,"reconnectDueToServerInactivityTimeout"),Le(this,"scheduledReconnect",null),Le(this,"networkOnlineHandler",null),Le(this,"pendingNetworkRecoveryInfo",null),Le(this,"uri"),Le(this,"onOpen"),Le(this,"onResume"),Le(this,"onMessage"),Le(this,"webSocketConstructor"),Le(this,"logger"),Le(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=Lg(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:yi()})),this.lastCloseReason!=="InitialConnect"&&(this.lastCloseReason?this.logger.log("WebSocket reconnected at",jg(),"after disconnect due to",this.lastCloseReason):this.logger.log("WebSocket reconnected at",jg())),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=Lg(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!==TL&&t.code!==AL&&t.code!==ML&&t.code!==RL){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=EL(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=SL(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=yi(),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=yi()-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:yi()})):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:Qw[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=yi()-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 OL(){return IL()}function IL(){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 Ss=class extends Error{};Ss.prototype.name="InvalidTokenError";function DL(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 NL(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 DL(t)}catch{return atob(t)}}function Xw(e,t){if(typeof e!="string")throw new Ss("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 Ss(`Invalid token specified: missing part #${n+1}`);let i;try{i=NL(r)}catch(s){throw new Ss(`Invalid token specified: invalid base64 for part #${n+1} (${s.message})`)}try{return JSON.parse(i)}catch(s){throw new Ss(`Invalid token specified: invalid json for part #${n+1} (${s.message})`)}}var LL=Object.defineProperty,jL=(e,t,n)=>t in e?LL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mt=(e,t,n)=>jL(e,typeof t!="symbol"?t+"":t,n),_L=1728e6,_g=2,BL=class{constructor(e,t,n){mt(this,"authState",{state:"noAuth"}),mt(this,"configVersion",0),mt(this,"syncState"),mt(this,"authenticate"),mt(this,"stopSocket"),mt(this,"tryRestartSocket"),mt(this,"pauseSocket"),mt(this,"resumeSocket"),mt(this,"clearAuth"),mt(this,"logger"),mt(this,"refreshTokenLeewaySeconds"),mt(this,"initialAuthTokenReuse"),mt(this,"lastRefreshChange"),mt(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>=_g){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, ${_g-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(_L,(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 Xw(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}]`)}},VL=["convexClientConstructed","convexWebSocketOpen","convexFirstMessageReceived"];function FL(e,t){const n={sessionId:t};typeof performance>"u"||!performance.mark||performance.mark(e,{detail:n})}function zL(e){let t=e.name.slice(6);return t=t.charAt(0).toLowerCase()+t.slice(1),{name:t,startTime:e.startTime}}function $L(e){if(typeof performance>"u"||!performance.getEntriesByName)return[];const t=[];for(const n of VL){const r=performance.getEntriesByName(n).filter(i=>i.entryType==="mark").filter(i=>i.detail.sessionId===e);t.push(...r)}return t.map(zL)}var WL=Object.defineProperty,HL=(e,t,n)=>t in e?WL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,je=(e,t,n)=>HL(e,typeof t!="symbol"?t+"":t,n),qL=class{constructor(e,t,n){if(je(this,"address"),je(this,"state"),je(this,"requestManager"),je(this,"webSocketManager"),je(this,"authenticationManager"),je(this,"remoteQuerySet"),je(this,"optimisticQueryResults"),je(this,"_transitionHandlerCounter",0),je(this,"_nextRequestId"),je(this,"_onTransitionFns",new Map),je(this,"_sessionId"),je(this,"firstMessageReceived",!1),je(this,"debug"),je(this,"logger"),je(this,"maxObservedTimestamp"),je(this,"connectionStateSubscribers",new Map),je(this,"nextConnectionStateSubscriberId",0),je(this,"_lastPublishedConnectionState"),je(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)}})}),je(this,"mark",f=>{this.debug&&FL(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&&UC(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?Gw({verbose:n.verbose??!1}):n.logger!==!0&&n.logger?n.logger:Kw({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/${Rg}/sync`;this.state=new lL,this.remoteQuerySet=new Ng(f=>this.state.queryPath(f),this.logger),this.requestManager=new hL(this.logger,this.markConnectionStateDirty);const u=()=>{this.webSocketManager.pause(),this.state.pause()};this.authenticationManager=new BL(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 pL,this.addOnTransitionHandler(f=>{t(f.queries.map(d=>d.token))}),this._nextRequestId=0,this._sessionId=OL();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 PL(c,{onOpen:f=>{this.mark("convexWebSocketOpen"),this.webSocketManager.sendMessage({...f,type:"Connect",sessionId:this._sessionId,maxObservedTimestamp:this.maxObservedTimestamp}),this.remoteQuerySet=new Ng(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=sL(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?Xw(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=Dn(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=Dn(t),r=Wr(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=Dn(t),r=Wr(e,n);return this.optimisticQueryResults.queryLogs(r)}queryJournal(e,t){const n=Dn(t),r=Wr(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?Ih(r,new Wu(Ti("mutation",e,r))):new Error(Ti("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=Dn(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:[Sn(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?Ih(n,new Wu(Ti("action",e,n))):new Error(Ti("action",e,n));return n.value}async actionInternal(e,t,n){const r=Dn(t),i=this.nextRequestId;this._nextRequestId++,this.tryReportLongDisconnect();const s={type:"Action",requestId:i,udfPath:e,componentPath:n,args:[Sn(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=$L(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-${Rg}`},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 UL=Object.defineProperty,KL=(e,t,n)=>t in e?UL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bg=(e,t,n)=>KL(e,typeof t!="symbol"?t+"":t,n),GL=class{constructor(e,t){this.client=e,this.onTransition=t,Bg(this,"paginatedQuerySet",new Map),Bg(this,"lastTransitionTs"),this.lastTransitionTs=Do.fromNumber(0),this.client.addOnTransitionHandler(n=>this.onBaseTransition(n))}subscribe(e,t,n){const r=Jr(e),i=Pg(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=Jr(e),i=Pg(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 QL({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 XL=Object.defineProperty,YL=(e,t,n)=>t in e?XL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Rn=(e,t,n)=>YL(e,typeof t!="symbol"?t+"":t,n),JL=5e3;if(typeof m.default>"u")throw new Error("Required dependency 'react' not found");function Yw(e,t,n){function r(i){return nj(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 ${ht(e)}`);return Yw(e,t,s)},r}function ZL(e,t){return function(n){return t.action(e,n)}}var R3=class{constructor(e,t){if(Rn(this,"address"),Rn(this,"cachedSync"),Rn(this,"cachedPaginatedQueryClient"),Rn(this,"listeners"),Rn(this,"options"),Rn(this,"closed",!1),Rn(this,"_logger"),Rn(this,"adminAuth"),Rn(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?Gw({verbose:t?.verbose??!1}):t?.logger!==!0&&t?.logger?t.logger:Kw({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 qL(this.address,()=>{},this.options),this.adminAuth&&this.cachedSync.setAdminAuth(this.adminAuth,this.fakeUserIdentity),this.cachedPaginatedQueryClient=new GL(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=ht(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??JL,n=this.watchQuery(e.query,e.args||{}).onUpdate(()=>{});setTimeout(n,t)}watchPaginatedQuery(e,t,n){const r=ht(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=ht(e);return this.sync.mutation(i,n,r)}action(e,...t){const n=ht(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()}}},rc=m.createContext(void 0);function ej(){return(0,m.useContext)(rc)}var E3=({client:e,children:t})=>m.createElement(rc.Provider,{value:e},t);function tj(e,...t){const n=t[0]==="skip",r=t[0]==="skip"?{}:Dn(t[0]),i=typeof e=="string"?np(e):e,s=ht(i),o=(0,m.useMemo)(()=>n?{}:{query:{query:i,args:r}},[JSON.stringify(Sn(r)),s,n]),a=oj(o).query;if(a instanceof Error)throw a;return a}function P3(e){const t=typeof e=="string"?np(e):e,n=(0,m.useContext)(rc);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)(()=>Yw(t,n),[n,ht(t)])}function O3(e){const t=(0,m.useContext)(rc),n=typeof e=="string"?np(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)(()=>ZL(n,t),[t,ht(n)])}function nj(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 rj=Object.defineProperty,ij=(e,t,n)=>t in e?rj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ou=(e,t,n)=>ij(e,typeof t!="symbol"?t+"":t,n),sj=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(ht(n),this.queries[t]===void 0)this.addQuery(t,n,r,i?{paginationOptions:i}:{});else{const s=this.queries[t];(ht(n)!==ht(s.query)||JSON.stringify(Sn(r))!==JSON.stringify(Sn(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;ht(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 oj(e){const t=ej();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 aj(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 aj(e,t){const[n]=(0,m.useState)(()=>new sj(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 QL(r)}var Nh=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),GC(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)(Xl,{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)(Ot,{onClick:this.handleReset,variant:"outline",children:"Try again"})]})}):this.props.children}};function Jw({...e}){return(0,g.jsx)(vE,{"data-slot":"dropdown-menu",...e})}function Zw({...e}){return(0,g.jsx)(yE,{"data-slot":"dropdown-menu-trigger",...e})}function eS({className:e,sideOffset:t=4,...n}){return(0,g.jsx)(xE,{children:(0,g.jsx)(bE,{"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 lj({className:e,inset:t,variant:n="default",...r}){return(0,g.jsx)(SE,{"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 I3({className:e,children:t,checked:n,...r}){return(0,g.jsxs)(kE,{"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)(mx,{children:(0,g.jsx)($i,{className:"size-4"})})}),t]})}function cj({...e}){return(0,g.jsx)(CE,{"data-slot":"dropdown-menu-radio-group",...e})}function uj({className:e,children:t,hideIndicator:n=!1,...r}){return(0,g.jsxs)(TE,{"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)(mx,{children:(0,g.jsx)(jP,{className:"size-2 fill-current"})})}),t]})}function D3({className:e,inset:t,...n}){return(0,g.jsx)(wE,{"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 N3({className:e,...t}){return(0,g.jsx)(AE,{"data-slot":"dropdown-menu-separator",className:X("bg-border -mx-1 my-1 h-px",e),...t})}function L3({...e}){return(0,g.jsx)(ME,{"data-slot":"dropdown-menu-sub",...e})}function j3({className:e,inset:t,children:n,...r}){return(0,g.jsxs)(RE,{"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)(Wi,{className:"ml-auto size-4"})]})}function _3({className:e,...t}){return(0,g.jsx)(EE,{"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})}var hj=zC("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 tS({className:e,variant:t,asChild:n=!1,...r}){const i=n?FC:"span";return(0,g.jsx)(i,{"data-slot":"badge",className:X(hj({variant:t}),e),...r})}function fj({delayDuration:e=0,...t}){return(0,g.jsx)(dP,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Ir({...e}){return(0,g.jsx)(fj,{children:(0,g.jsx)(pP,{"data-slot":"tooltip",...e})})}function Dr({...e}){return(0,g.jsx)(mP,{"data-slot":"tooltip-trigger",...e})}function Nr({className:e,sideOffset:t=0,children:n,variant:r="default",...i}){const s=r==="muted";return(0,g.jsx)(gP,{children:(0,g.jsxs)(vP,{"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",s?"border border-border bg-popover text-popover-foreground shadow-md":"bg-primary text-primary-foreground",e),...i,children:[n,(0,g.jsx)(yP,{className:X("z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]",s?"fill-popover":"bg-primary fill-primary")})]})})}var dj=50,au="null";function ci(){return{line:1,column:1}}function pj(e){if(e===void 0)return au;try{return JSON.stringify(e,null,2)??au}catch{return au}}function ui(e){try{return{value:JSON.parse(e),error:null}}catch(t){return{value:void 0,error:t instanceof Error?t.message:"Invalid JSON"}}}function hi(e){try{return JSON.stringify(e)}catch{return null}}function Hr(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null)return Hr(t)}catch{}return e}if(Array.isArray(e))return e.map(Hr);if(typeof e=="object"&&e!==null){const t={};for(const[n,r]of Object.entries(e))t[n]=Hr(r);return t}return e}function Bs(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?Bs(s,r[i]):s;return n}return Array.isArray(e)&&Array.isArray(t)?e.map((n,r)=>r<t.length?Bs(n,t[r]):n):e}function ea(e,t,n){return e!==void 0?e:pj(n?Hr(t):t)}function mj({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=ea(t,e,s),j=ui(P);let V;j.error!==null?V=null:s?V=hi(Bs(j.value,e)):V=hi(j.value),o.current={content:P,lastEmitted:V,error:j.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)(ci),x=(0,m.useRef)([{content:o.current.content,cursorPosition:ci()}]),b=(0,m.useRef)(0),w=(0,m.useCallback)(P=>{const j=ui(P);return p(j.error),i?.(j.error),j},[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=hi(e);P!==null&&P===f.current?(c.current=e,h.current=u.current):(c.current=e,h.current=ea(void 0,e,!0))}else c.current=e,h.current=ea(t,e,s);(0,m.useEffect)(()=>{const P=h.current;if(P===u.current)return;u.current=P,l(P),y(ci()),x.current=[{content:P,cursorPosition:ci()}],b.current=0,w(P);const j=ui(P);if(j.error===null&&s){const V=Bs(j.value,e);f.current=hi(V)}else f.current=j.error===null?hi(j.value):null},[e,t,w,s]);const C=(0,m.useCallback)((P,j,V)=>{r?.(P);const W=B=>{const D=s?Bs(B,c.current):B,te=hi(D);if(te===null){n?.(D);return}te!==f.current&&(f.current=te,n?.(D))};if(V===void 0){const B=ui(P);B.error===null&&W(B.value);return}V===null&&W(j)},[n,r,s]),T=(0,m.useCallback)(P=>{if(P===u.current)return;u.current=P,l(P);const{value:j,error:V}=w(P),W=b.current;let B=x.current;W<B.length-1&&(B=B.slice(0,W+1));const D=B[B.length-1];(!D||D.content!==P)&&(B=[...B,{content:P,cursorPosition:v}]),B.length>dj&&(B=B.slice(-50)),x.current=B,b.current=B.length-1,C(P,j,V)},[v,C,w]),k=(0,m.useCallback)(P=>{u.current=P.content,l(P.content),y(P.cursorPosition);const{value:j,error:V}=w(P.content);C(P.content,j,V)},[C,w]),A=(0,m.useCallback)(()=>{const P=x.current,j=b.current;if(j>0){b.current=j-1;const V=P[j-1];k(V)}},[k]),M=(0,m.useCallback)(()=>{const P=x.current,j=b.current;if(j<P.length-1){b.current=j+1;const V=P[j+1];k(V)}},[k]),E=(0,m.useCallback)(()=>{const{value:P,error:j}=ui(a);if(j===null){const V=s?Hr(P):P,W=JSON.stringify(V,null,2);T(W)}},[a,T,s]),O=(0,m.useCallback)(()=>{c.current=e;const P=ea(t,e,s);h.current=P,u.current=P,l(P),y(ci()),x.current=[{content:P,cursorPosition:ci()}],b.current=0;const{value:j,error:V}=w(P);C(P,j,V)},[e,t,w,C,s]),R=(0,m.useCallback)(()=>{const{value:P,error:j}=ui(a);return j===null?P:void 0},[a]),L=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:M,canUndo:L,canRedo:N,format:E,reset:O,getParsedValue:R,sourceContent:h.current}}function gj(e){return typeof e=="object"?e.key:e}function vj(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 fi(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 Vg(e,t){if(e===void 0)throw new Error(`Unexpected undefined${t?`: ${t}`:""}`);return e}var Fg=(e,t)=>Math.abs(e-t)<1.01,yj=(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)}})},ds,lu=()=>{if(ds!==void 0)return ds;if(typeof navigator>"u")return ds=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return ds=!0;const e=navigator.maxTouchPoints;return ds=navigator.platform==="MacIntel"&&e!==void 0&&e>0},zg=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},xj=e=>e,bj=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=new Array(n);for(let i=0;i<n;i++)r[i]=t+i;return r},wj=(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(zg(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(zg(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},yl={passive:!0},Sj=typeof window>"u"?!0:"onscrollend"in window,kj=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const i=e.targetWindow;if(!i)return;const s=e.options.useScrollendEvent&&Sj;let o=0;const a=s?null:yj(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,yl),s&&r.addEventListener("scrollend",u,yl),()=>{r.removeEventListener("scroll",c),s&&r.removeEventListener("scrollend",u),a?.cancel()}},Cj=(e,t)=>kj(e,t,n=>{const{horizontal:r,isRtl:i}=e.options;return r?n.scrollLeft*(i&&-1||1):n.scrollTop}),Tj=(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"]},Aj=(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})},Mj=Aj;function Rj(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 Ej=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this.now=()=>{var t,n,r;return((r=(n=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:n.now)==null?void 0:r.call(n))??Date.now()},this.observer=(()=>{let t=null;const n=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(r=>{r.forEach(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:xj,rangeExtractor:bj,onChange:()=>{},measureElement:Tj,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=>gj(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||Rj(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=fi(()=>(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,!(!lu()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};s.addEventListener("touchstart",o,yl),s.addEventListener("touchend",a,yl),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&&(lu()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):((n=this.scrollState)==null?void 0:n.behavior)==="smooth"&&!Fg(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=fi(()=>[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=fi(()=>[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),M=typeof A=="number"?A:this.options.estimateSize(T);b[T*2]=S,b[T*2+1]=M,S+=M+l}this._singleLaneMeasurements={flat:b,items:w};const C=vj(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 E=p[S],O=E!==void 0?d[E]:void 0;C=O?O.end+l:n+r}else if(y===o){let E=0,O=v[0],R=p[0];for(let L=1;L<o;L++){const N=v[L];(N<O||N===O&&p[L]<R)&&(E=L,O=N,R=p[L])}S=E,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),M=C+A;d[x]={index:x,start:C,size:A,end:M,key:b,lane:S},p[S]===void 0&&y++,p[S]=x,v[S]=M}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=fi(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,n,r,i)=>t.length===0||n===0?(this.range=null,null):(this.range=Oj(t,n,r,i,i===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=fi(()=>{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=fi(()=>[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=nS(0,r.length-1,s?a=>i[a*2]:a=>Vg(r[a]).start,t);return Vg(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(lu()&&(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&&Fg(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()}},nS=(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 Pj(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 Oj(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=Pj(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=nS(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 Ij({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,ko.flushSync)(i):i()),(d=r.onChange)==null||d.call(r,h,f)}},[u]=m.useState(()=>{const h=new Ej(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 Dj(e){return Ij({observeElementRect:wj,observeElementOffset:Cj,scrollToFn:Mj,...e})}function Nj(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}function rS(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 iS(e){const t=rS(e);let n="",r=0;const i=s=>{s&&(n+=`<span class="json-punctuation">${$g(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}">${$g(s.value)}</span>`,r=s.end}return r<e.length&&i(e.slice(r)),n}function $g(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function sS({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 Ql(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?Nj(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)($i,{className:"h-3 w-3 text-green-500"}):(0,g.jsx)(Ii,{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)(Jw,{children:[(0,g.jsx)(Zw,{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)($i,{className:"h-3 w-3 text-green-500"}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ii,{className:"h-3 w-3 text-muted-foreground/60"}),(0,g.jsx)(jx,{className:"h-2 w-2 text-muted-foreground/60 -ml-0.5"})]})})}),(0,g.jsx)(eS,{align:"start",className:"min-w-[140px]",children:x.map(b=>(0,g.jsxs)(lj,{onClick:()=>p(b.value,b.key),className:"text-xs",children:[(0,g.jsx)(Ii,{className:"h-3 w-3 mr-2"}),b.label]},b.key))})]})]})}function Wg(e,t){return t?(0,g.jsx)("span",{className:"json-punctuation",children:t},e):null}function uu({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 Ql(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)($i,{className:"h-3 w-3 text-green-500"}):(0,g.jsx)(Ii,{className:"h-3 w-3 text-muted-foreground/60 hover:text-muted-foreground"})})]})}function Hg(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 Lj({content:e,onCopy:t,collapseStringsAfterLength:n}){const r=(0,m.useMemo)(()=>{const i=rS(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(Wg(`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=Hg(e,h.start);s.push((0,g.jsx)(uu,{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=Hg(e,h.start);a=null,s.push((0,g.jsx)(uu,{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)(sS,{value:v,displayValue:h.value,maxLength:n,onCopy:t,keyName:h.keyName,path:h.path},`token-${u}`))}else d?s.push((0,g.jsx)(uu,{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(Wg("ws-end",e.slice(o))),s},[e,t,n]);return(0,g.jsx)(g.Fragment,{children:r})}var Vr=20,qg=30,Ug=12,Lh=80,jj=2;function _j(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 Bj(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 Lh;const i=Number.parseFloat(t.paddingLeft)||0,s=Number.parseFloat(t.paddingRight)||0,o=e.clientWidth-i-s;return o<=0?Lh:Math.max(1,Math.floor(o/r))}function Vj(e,t){const n=e.replace(/\t/g," ".repeat(jj)).length;return n===0?1:Math.max(1,Math.ceil(n/t))}function Fj(e,t,n){let r=0;return e.map((i,s)=>{const o=t?Vj(i,n)*Vr:Vr,a=t?r:s*Vr;return r+=o,{top:a,height:o}})}function zj(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-qg),d=Math.min(o-1,h+qg),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:iS(p),paddingTop:w,paddingBottom:S}},[e,t,n,r,i])}function oS({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,M]=(0,m.useState)(0),[E,O]=(0,m.useState)(0),[R,L]=(0,m.useState)(400),N=(0,m.useRef)(null),P=(0,m.useRef)(null),j=(0,m.useRef)(0),[V,W]=(0,m.useState)(Lh),B=a?p:d,D=a&&c==="auto",te=(0,m.useMemo)(()=>e.split(`
46
+ `),[e]),re=(0,m.useMemo)(()=>Fj(te,B,V),[V,B,te]),_=te.length,U=re[Math.min(Math.max(T-1,0),_-1)],K=U?.top??0,G=U?.height??Vr,$=!a,J=K-A+Ug,ae=(0,m.useCallback)(()=>{const Y=a?b.current:v.current;if(!B||!Y)return;const ve=Bj(Y);W(De=>De===ve?De:ve)},[B,a]),ue=Dj({count:_,getScrollElement:()=>a?x.current:y.current,estimateSize:Y=>re[Y]?.height??Vr,overscan:20}),{highlightedHtml:se,paddingTop:Xe}=zj(e,A,R,$,re),Ie=(0,m.useMemo)(()=>a?"":$?se:iS(e),[e,a,$,se]),tt=$?Xe:0,We=(0,m.useRef)(0);We.current=tt;const dt=(0,m.useRef)(0);dt.current=K;const Ae=(0,m.useCallback)(()=>{if(v.current){const Y=v.current.scrollTop,ve=v.current.scrollLeft;y.current&&(y.current.scrollTop=Y),N.current&&(N.current.style.transform=`translate(${-ve}px, ${We.current-Y}px)`),P.current&&(P.current.style.transform=`translateY(${dt.current-Y+Ug}px)`),cancelAnimationFrame(j.current),j.current=requestAnimationFrame(()=>{M(Y),O(ve)})}},[]),nt=(0,m.useCallback)(()=>{if(v.current&&n){const Y=_j(v.current);n(Y),k(Y.line)}},[n]),Tr=(0,m.useCallback)(Y=>{const ve=Y.currentTarget,{selectionStart:De,selectionEnd:Bo,value:pt}=ve;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 I=" ";if(Y.shiftKey){const ee=pt.lastIndexOf(`
47
+ `,De-1)+1;if(pt.substring(ee,De).startsWith(I)){const le=pt.substring(0,ee)+pt.substring(ee+2);t?.(le),requestAnimationFrame(()=>{ve.selectionStart=ve.selectionEnd=De-2})}}else{const ee=pt.substring(0,De)+I+pt.substring(Bo);t?.(ee),requestAnimationFrame(()=>{ve.selectionStart=ve.selectionEnd=De+2})}return}if(Y.key==="Enter"){Y.preventDefault();const I=pt.lastIndexOf(`
48
+ `,De-1)+1,ee=pt.substring(I,De).match(/^(\s*)/)?.[1]||"",le=pt[De-1],ke=pt[De],ie=le==="{"||le==="[",xt=ke==="}"||ke==="]";let rt=`
49
+ `+ee,tn=rt.length;ie&&(rt=`
50
+ `+ee+" ",tn=rt.length,xt&&(rt+=`
51
+ `+ee));const bt=pt.substring(0,De)+rt+pt.substring(Bo);t?.(bt),requestAnimationFrame(()=>{ve.selectionStart=ve.selectionEnd=De+tn})}},[t,r,i,s]);(0,m.useEffect)(()=>{a||v.current?.focus()},[a]),(0,m.useEffect)(()=>{const Y=()=>{w.current&&L(w.current.clientHeight)};return Y(),window.addEventListener("resize",Y),()=>window.removeEventListener("resize",Y)},[]),(0,m.useEffect)(()=>()=>cancelAnimationFrame(j.current),[]),(0,m.useEffect)(()=>{T>_&&k(_)},[T,_]),(0,m.useEffect)(()=>{ue.measure()},[re,ue]),(0,m.useEffect)(()=>{if(!B)return;ae(),window.addEventListener("resize",ae);let Y;const ve=a?b.current:v.current;return window.ResizeObserver&&ve&&(Y=new ResizeObserver(()=>ae()),Y.observe(ve)),()=>{window.removeEventListener("resize",ae),Y?.disconnect()}},[B,a,ae]);const as={height:c??"auto",maxHeight:u??"none"},pe={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:as,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:{...pe,height:`${ue.getTotalSize()}px`},children:ue.getVirtualItems().map(Y=>{const ve=Y.index+1,De=re[Y.index]?.height??Vr;return(0,g.jsx)("div",{className:X("leading-5 transition-colors duration-150 absolute left-0 right-0 pr-2",ve===T&&S&&"text-foreground font-medium"),style:{transform:`translateY(${Y.start}px)`,height:`${De}px`},children:ve},Y.index)})})}),(0,g.jsx)("div",{className:X("relative flex-1 min-w-0",D?"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",D?"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",!D&&"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:{...pe,height:`${ue.getTotalSize()}px`},children:ue.getVirtualItems().map(Y=>{const ve=Y.index+1,De=re[Y.index]?.height??Vr;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:`${De}px`},children:ve},Y.index)})})}),(0,g.jsx)("div",{className:X("relative self-start overflow-visible",B?"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",B?"w-full whitespace-pre-wrap break-words":"w-max min-w-full whitespace-pre"),style:pe,children:(0,g.jsx)(Lj,{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",B?"whitespace-pre-wrap break-words":"whitespace-pre","pointer-events-none m-0","text-muted-foreground"),style:{...pe,scrollbarGutter:"stable"},"aria-hidden":"true",children:(0,g.jsx)("div",{ref:N,style:{transform:`translate(${-E}px, ${tt-A}px)`,willChange:"transform"},children:(0,g.jsx)("div",{dangerouslySetInnerHTML:{__html:Ie+`
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:B?"soft":"off",onChange:Y=>t?.(Y.target.value),onScroll:Ae,onSelect:nt,onClick:nt,onKeyDown:Tr,onKeyUp:nt,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",B?"overflow-auto whitespace-pre-wrap break-words":"overflow-auto whitespace-pre"),style:{...pe,tabSize:2,scrollbarGutter:"stable"}})]})})]})}var Kg=100;function $j(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function aS(e,t){const n=Math.min(t,Kg),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>=Kg){s.depth>=n&&$j(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 Wj(e){return aS(e,0)}function Hj({value:e,defaultExpandDepth:t,initialCollapsedPaths:n,onCollapseChange:r}={}){const[i]=(0,m.useState)(()=>n!==void 0||t===void 0?null:new Set(aS(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=Wj(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 ta=50,qj=100,Uj=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)},Kj=typeof cancelIdleCallback<"u"?cancelIdleCallback:clearTimeout;function lS(e,t){const[n,r]=(0,m.useState)(e.length<=ta?e.length:ta);return(0,m.useEffect)(()=>{if(!t){r(Math.min(e.length,ta));return}r(i=>i>e.length?Math.min(e.length,ta):i)},[e.length,t]),(0,m.useEffect)(()=>{if(!t||n>=e.length)return;const i=Uj(()=>{r(s=>Math.min(s+qj,e.length))},{timeout:100});return()=>Kj(i)},[e.length,n,t]),e.slice(0,n)}var vn=(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 Ql(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)($i,{className:"h-3 w-3 text-green-500"}):(0,g.jsx)(Ii,{className:"h-3 w-3 text-muted-foreground/60 hover:text-muted-foreground"})})]})});function Gj({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=lS(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)(vn,{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)(Wi,{className:"h-3 w-3"})}),d(),(0,g.jsxs)(vn,{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)(Wi,{className:"h-3 w-3"})}),d(),(0,g.jsx)(vn,{value:f,onCopy:l,alwaysVisible:!0,children:(0,g.jsx)("span",{className:"json-punctuation",children:"["})})]}),h.map((y,x)=>(0,g.jsx)(rp,{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 Qj({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=lS(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)(vn,{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)(Wi,{className:"h-3 w-3"})}),p(),(0,g.jsxs)(vn,{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)(Wi,{className:"h-3 w-3"})}),p(),(0,g.jsx)(vn,{value:d,onCopy:l,alwaysVisible:!0,children:(0,g.jsx)("span",{className:"json-punctuation",children:"{"})})]}),f.map(([x,b],w)=>(0,g.jsx)(rp,{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 Xj({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)(vn,{value:"null",onCopy:l,children:(0,g.jsx)("span",{className:"json-null",children:"null"})});if(typeof e=="boolean")return(0,g.jsx)(vn,{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)(vn,{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)(sS,{value:e,displayValue:d,maxLength:a,onCopy:l}):(0,g.jsx)(vn,{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)(Gj,{value:e,path:t,keyName:n,isLast:r,depth:i,isCollapsed:s,toggleCollapse:o,collapseStringsAfterLength:a,onCopy:l}):typeof e=="object"?(0,g.jsx)(Qj,{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 Yj(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 rp=(0,m.memo)(Xj,Yj);function Jj({value:e,className:t,height:n,maxHeight:r,defaultExpandDepth:i,collapsedPaths:s,onCollapseChange:o,collapseStringsAfterLength:a,onCopy:l}){const{isCollapsed:c,toggleCollapse:u}=Hj({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)(rp,{value:e,path:"root",isCollapsed:c,toggleCollapse:u,collapseStringsAfterLength:a,onCopy:l})})}function jh({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)(Jj,{value:e,className:t,height:n??"100%",maxHeight:r,defaultExpandDepth:l,collapsedPaths:c,onCollapseChange:u,collapseStringsAfterLength:s}):(0,g.jsx)(oS,{content:h,readOnly:!0,className:t,height:n??"100%",maxHeight:r,showLineNumbers:i,collapseStringsAfterLength:s,wrapLongLinesInView:o})}var cS=1024,Zj=0,hu=class{constructor(e,t){this.from=e,this.to=t}},he=class{constructor(e={}){this.id=Zj++,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=jt.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};he.closedBy=new he({deserialize:e=>e.split(" ")});he.openedBy=new he({deserialize:e=>e.split(" ")});he.group=new he({deserialize:e=>e.split(" ")});he.isolate=new he({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});he.contextHash=new he({perNode:!0});he.lookAhead=new he({perNode:!0});he.mounted=new he({perNode:!0});var Vs=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[he.mounted.id]}},e_=Object.create(null),jt=class uS{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):e_,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new uS(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(he.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(he.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}};jt.none=new jt("",Object.create(null),0,8);var t_=class hS{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 jt(r.name,i,r.id,r.flags):r)}return new hS(n)}},na=new WeakMap,Gg=new WeakMap,Ee;(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"})(Ee||(Ee={}));var Qe=class _h{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=Vs.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 Fh(this.topNode,t)}cursorAt(t,n=0,r=0){let i=na.get(this)||this.topNode,s=new Fh(i);return s.moveTo(t,n),na.set(this,s._tree),s}get topNode(){return new mr(this,0,0,null)}resolve(t,n=0){let r=ao(na.get(this)||this.topNode,t,n,!1);return na.set(this,r),r}resolveInner(t,n=0){let r=ao(Gg.get(this)||this.topNode,t,n,!0);return Gg.set(this,r),r}resolveStack(t,n=0){return s_(this,t,n)}iterate(t){let{enter:n,leave:r,from:i=0,to:s=this.length}=t,o=t.mode||0,a=(o&Ee.IncludeAnonymous)>0;for(let l=this.cursor(o|Ee.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:sp(jt.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new _h(this.type,n,r,i,this.propValues),t.makeTree||((n,r,i)=>new _h(jt.none,n,r,i)))}static build(t){return o_(t)}};Qe.empty=new Qe(jt.none,[],[],0);var n_=class fS{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 fS(this.buffer,this.index)}},qi=class dS{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return jt.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&&!(pS(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 dS(s,o,this.set)}};function pS(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 ao(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 mr&&e.index<0?null:e.parent;if(!o)return e;e=o}let s=r?0:Ee.IgnoreOverlays;if(r)for(let o=e,a=o.parent;a;o=a,a=o.parent)o instanceof mr&&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 mS=class{cursor(e=0){return new Fh(this,e)}getChild(e,t=null,n=null){let r=Qg(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Qg(this,e,t,n)}resolve(e,t=0){return ao(this,e,t,!1)}resolveInner(e,t=0){return ao(this,e,t,!0)}matchContext(e){return Bh(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}},mr=class Na extends mS{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&Ee.EnterBracketed&&u instanceof Qe&&(f=Vs.get(u))&&!f.overlay&&f.bracketed&&r>=h&&r<=h+u.length)&&!pS(i,r,h,h+u.length))){if(u instanceof qi){if(s&Ee.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,n,r-h,i);if(d>-1)return new Vh(new r_(o,u,t,h),null,d)}else if(s&Ee.IncludeAnonymous||!u.type.isAnonymous||ip(u)){let d;if(!(s&Ee.IgnoreMounts)&&(d=Vs.get(u))&&!d.overlay)return new Na(d.tree,h,t,o);let p=new Na(u,h,t,o);return s&Ee.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?u.children.length-1:0,n,r,i,s)}}}if(s&Ee.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&Ee.IgnoreOverlays)&&(i=Vs.get(this._tree))&&i.overlay){let s=t-this.from,o=r&Ee.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 Na(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 Qg(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 Bh(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 r_=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},Vh=class ks extends mS{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 ks(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&Ee.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 ks(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 ks(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 ks(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 Qe(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function gS(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 mr&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new i_(i,n)}var i_=class{constructor(e,t){this.heads=e,this.node=t}get next(){return gS(this.heads)}};function s_(e,t,n){let r=e.resolveInner(t,n),i=null;for(let s=r instanceof mr?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=Vs.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let a=new mr(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(ao(a,t,n,!1))}}return i?gS(i):r}var Fh=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&~Ee.EnterBracketed,e instanceof mr)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 mr?(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&Ee.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ee.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Ee.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&Ee.IncludeAnonymous||o instanceof qi||!o.type.isAnonymous||ip(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 Vh(this.buffer,t,this.stack[r]);return this.bufferNode=new Vh(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 Bh(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 Bh(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 ip(e){return e.children.some(t=>t instanceof qi||!t.type.isAnonymous||ip(t))}function o_(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=cS,reused:s=[],minRepeatType:o=r.types.length}=e,a=Array.isArray(n)?new n_(n,n.length):n,l=r.types,c=0,u=0;function h(C,T,k,A,M,E){let{id:O,start:R,end:L,size:N}=a,P=u,j=c;if(N<0)if(a.next(),N==-1){let te=s[O];k.push(te),A.push(R-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 V=l[O],W,B,D=R-C;if(L-R<=i&&(B=y(a.pos-T,M))){let te=new Uint16Array(B.size-B.skip),re=a.pos-B.size,_=te.length;for(;a.pos>re;)_=x(B.start,te,_);W=new qi(te,L-B.start,r),D=B.start-C}else{let te=a.pos-N;a.next();let re=[],_=[],U=O>=o?O:-1,K=0,G=L;for(;a.pos>te;)U>=0&&a.id==U&&a.size>=0?(a.end<=G-i&&(p(re,_,R,K,a.end,G,U,P,j),K=re.length,G=a.end),a.next()):E>2500?f(R,te,re,_):h(R,te,re,_,U,E+1);if(U>=0&&K>0&&K<re.length&&p(re,_,R,K,R,G,U,P,j),re.reverse(),_.reverse(),U>-1&&K>0){let $=d(V,j);W=sp(V,re,_,0,re.length,0,L-R,$,$)}else W=v(V,re,_,L-R,P-L,j)}k.push(W),A.push(D)}function f(C,T,k,A){let M=[],E=0,O=-1;for(;a.pos>T;){let{id:R,start:L,end:N,size:P}=a;if(P>4)a.next();else{if(O>-1&&L<O)break;O<0&&(O=N-i),M.push(R,L,N),E++,a.next()}}if(E){let R=new Uint16Array(E*4),L=M[M.length-2];for(let N=M.length-3,P=0;N>=0;N-=3)R[P++]=M[N],R[P++]=M[N+1]-L,R[P++]=M[N+2]-L,R[P++]=P;k.push(new qi(R,M[2]-L,r)),A.push(L-C)}}function d(C,T){return(k,A,M)=>{let E=0,O=k.length-1,R,L;if(O>=0&&(R=k[O])instanceof Qe){if(!O&&R.type==C&&R.length==M)return R;(L=R.prop(he.lookAhead))&&(E=A[O]+R.length+L)}return v(C,k,A,M,E,T)}}function p(C,T,k,A,M,E,O,R,L){let N=[],P=[];for(;C.length>A;)N.push(C.pop()),P.push(T.pop()+k-M);C.push(v(r.types[O],N,P,E-M,R-E,L)),T.push(M-k)}function v(C,T,k,A,M,E,O){if(E){let R=[he.contextHash,E];O=O?[R].concat(O):[R]}if(M>25){let R=[he.lookAhead,M];O=O?[R].concat(O):[R]}return new Qe(C,T,k,A,O)}function y(C,T){let k=a.fork(),A=0,M=0,E=0,O=k.end-i,R={size:0,start:0,skip:0};e:for(let L=k.pos-C;k.pos>L;){let N=k.size;if(k.id==T&&N>=0){R.size=A,R.start=M,R.skip=E,E+=4,A+=4,k.next();continue}let P=k.pos-N;if(N<0||P<L||k.start<O)break;let j=k.id>=o?4:0,V=k.start;for(k.next();k.pos>P;){if(k.size<0)if(k.size==-3||k.size==-4)j+=4;else break e;else k.id>=o&&(j+=4);k.next()}M=V,A+=N,E+=j}return(T<0||A==C)&&(R.size=A,R.start=M,R.skip=E),R.size>4?R:void 0}function x(C,T,k){let{id:A,start:M,end:E,size:O}=a;if(a.next(),O>=0&&A<o){let R=k;if(O>4){let L=a.pos-(O-4);for(;a.pos>L;)k=x(C,T,k)}T[--k]=R,T[--k]=E-C,T[--k]=M-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 Qe(l[e.topID],b.reverse(),w.reverse(),S)}var Xg=new WeakMap;function La(e,t){if(!e.isAnonymous||t instanceof qi||t.type!=e)return 1;let n=Xg.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof Qe)){n=1;break}n+=La(e,r)}Xg.set(t,n)}return n}function sp(e,t,n,r,i,s,o,a,l){let c=0;for(let p=r;p<i;p++)c+=La(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=La(e,p[w]);for(w++;w<x;w++){let k=La(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(sp(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 ja=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}},vS=class{startParse(e,t,n){return typeof e=="string"&&(e=new a_(e)),n=n?n.length?n.map(r=>new hu(r.from,r.to)):[new hu(0,0)]:[new hu(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}}},a_=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)}},B3=new he({perNode:!0}),l_=class $h{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 $h(t,[],n,r,r,0,[],0,i?new Yg(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 $h(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 c_(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 Yg(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()}},Yg=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},c_=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}},u_=class Wh{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 Wh(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 Wh(this.stack,this.pos,this.index)}};function Cs(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 _a=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},Jg=new _a,h_=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=Jg,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=Jg,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}},Ni=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;yS(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};Ni.prototype.contextual=Ni.prototype.fallback=Ni.prototype.extend=!1;var f_=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?Cs(e):e}token(e,t){let n=e.pos,r=0;for(;;){let i=e.next<0,s=e.resolveOffset(1,1);if(yS(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))}};f_.prototype.contextual=Ni.prototype.fallback=Ni.prototype.extend=!1;function yS(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||d_(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 Zg(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function d_(e,t,n,r){let i=Zg(n,r,t);return i<0||Zg(n,r,e)<i}var Ct=typeof process<"u"&&/\bparse\b/.test({}.LOG),fu=null;function e0(e,t,n){let r=e.cursor(Ee.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 p_=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?e0(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?e0(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 Qe){if(s==e){if(s<this.safeFrom)return null;let o=s+i.length;if(o<=this.safeTo){let a=i.prop(he.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}}},m_=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new _a)}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 _a,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 _a,{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=Nn(o,l+2);else{r==0&&o[l+1]==2&&(r=this.putAction(Nn(o,l+2),t,n,r));break}o[l]==t&&(r=this.putAction(Nn(o,l+1),t,n,r))}return r}},g_=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 h_(t,r),this.tokens=new m_(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[l_.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new p_(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&&x_(r);if(s)return Ct&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw Ct&&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 Ct&&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=Ct?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(he.contextHash)||0)==c))return e.useNode(u,h),Ct&&console.log(s+this.stackID(e)+` (via reuse of ${i.getName(u.type.id)})`),!0;if(!(u instanceof Qe)||u.children.length==0||u.positions[0]>0)break;let f=u.children[0];if(f instanceof Qe&&u.positions[0]==0)u=f;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),Ct&&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),Ct&&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 t0(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=Ct?this.stackID(o)+" -> ":"";if(o.deadEnd&&(i||(i=!0,o.restart(),Ct&&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()&&(Ct&&console.log(h+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,n));f++)Ct&&(h=this.stackID(u)+" -> ");for(let f of o.recoverByInsert(a))Ct&&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),Ct&&console.log(c+this.stackID(o)+` (via recover-delete ${this.parser.getName(a)})`),t0(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),Qe.build({buffer:u_.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=(fu||(fu=new WeakMap)).get(e);return t||fu.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function t0(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 v_=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},y_=class Hh extends vS{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=he[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 t_(n.map((a,l)=>jt.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=cS;let o=Cs(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(n0),this.states=Cs(t.states,Uint32Array),this.data=Cs(t.stateData),this.goto=Cs(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(a=>typeof a=="number"?new Ni(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 g_(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=Nn(r,s+2)];else{if(r[s+1]==2)return Nn(r,s+2);break}if(o==n||o==0)return Nn(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=Nn(this.data,s+2);else break;i=n(Nn(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=Nn(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(Hh.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]=n0(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 v_(t,r,i)}static deserialize(t){return new Hh(t)}};function Nn(e,t){return e[t]|e[t+1]<<16}function x_(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 n0(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}var b_=0,Ln=class qh{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=b_++}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 qh&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new qh(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 r0(t);return r=>r.modified.indexOf(n)>-1?r:r0.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}},w_=0,r0=class xS{constructor(t){this.name=t,this.instances=[],this.id=w_++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(a=>a.base==t&&S_(n,a.modified));if(r)return r;let i=[],s=new Ln(t.name,i,t,n);for(let a of n)a.instances.push(s);let o=k_(n);for(let a of t.set)if(!a.modified.length)for(let l of o)i.push(xS.get(a,l));return s}};function S_(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function k_(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 bS(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 lo(r,o,l>0?s.slice(0,l):null).sort(t[c])}}return wS.add(t)}var wS=new he({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 lo(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}}),lo=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}};lo.empty=new lo([],2,null);function SS(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 C_(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function T_(e,t,n,r=0,i=e.length){let s=new A_(r,Array.isArray(t)?t:[t],n);s.highlightRange(e.cursor(),r,i,"",s.highlighters),s.flush(i)}var A_=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=M_(e)||lo.empty,u=C_(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(he.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 M_(e){let t=e.type.prop(wS);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var H=Ln.define,ra=H(),rr=H(),i0=H(rr),s0=H(rr),ir=H(),ia=H(ir),du=H(ir),ln=H(),Rr=H(ln),sn=H(),on=H(),Uh=H(),ps=H(Uh),sa=H(),F={comment:ra,lineComment:H(ra),blockComment:H(ra),docComment:H(ra),name:rr,variableName:H(rr),typeName:i0,tagName:H(i0),propertyName:s0,attributeName:H(s0),className:H(rr),labelName:H(rr),namespace:H(rr),macroName:H(rr),literal:ir,string:ia,docString:H(ia),character:H(ia),attributeValue:H(ia),number:du,integer:H(du),float:H(du),bool:H(ir),regexp:H(ir),escape:H(ir),color:H(ir),url:H(ir),keyword:sn,self:H(sn),null:H(sn),atom:H(sn),unit:H(sn),modifier:H(sn),operatorKeyword:H(sn),controlKeyword:H(sn),definitionKeyword:H(sn),moduleKeyword:H(sn),operator:on,derefOperator:H(on),arithmeticOperator:H(on),logicOperator:H(on),bitwiseOperator:H(on),compareOperator:H(on),updateOperator:H(on),definitionOperator:H(on),typeOperator:H(on),controlOperator:H(on),punctuation:Uh,separator:H(Uh),bracket:ps,angleBracket:H(ps),squareBracket:H(ps),paren:H(ps),brace:H(ps),content:ln,heading:Rr,heading1:H(Rr),heading2:H(Rr),heading3:H(Rr),heading4:H(Rr),heading5:H(Rr),heading6:H(Rr),contentSeparator:H(ln),list:H(ln),quote:H(ln),emphasis:H(ln),strong:H(ln),link:H(ln),monospace:H(ln),strikethrough:H(ln),inserted:H(),deleted:H(),changed:H(),invalid:H(),meta:sa,documentMeta:H(sa),annotation:H(sa),processingInstruction:H(sa),definition:Ln.defineModifier("definition"),constant:Ln.defineModifier("constant"),function:Ln.defineModifier("function"),standard:Ln.defineModifier("standard"),local:Ln.defineModifier("local"),special:Ln.defineModifier("special")};for(let e in F){let t=F[e];t instanceof Ln&&(t.name=e)}var V3=SS([{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"}]),R_=bS({String:F.string,Number:F.number,"True False":F.bool,PropertyName:F.propertyName,Null:F.null,", :":F.separator,"[ ]":F.squareBracket,"{ }":F.brace}),E_=y_.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:[R_],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}),Kh=[],kS=[];(()=>{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?kS:Kh).push(n=n+e[t])})();function P_(e){if(e<768)return!1;for(let t=0,n=Kh.length;;){let r=t+n>>1;if(e<Kh[r])n=r;else if(e>=kS[r])t=r+1;else return!0;if(t==n)return!1}}function o0(e){return e>=127462&&e<=127487}var a0=8205;function O_(e,t,n=!0,r=!0){return(n?CS:I_)(e,t,r)}function CS(e,t,n){if(t==e.length)return t;t&&TS(e.charCodeAt(t))&&AS(e.charCodeAt(t-1))&&t--;let r=pu(e,t);for(t+=l0(r);t<e.length;){let i=pu(e,t);if(r==a0||i==a0||n&&P_(i))t+=l0(i),r=i;else if(o0(i)){let s=0,o=t-2;for(;o>=0&&o0(pu(e,o));)s++,o-=2;if(s%2==0)break;t+=2}else break}return t}function I_(e,t,n){for(;t>0;){let r=CS(e,t-2,n);if(r<t)return r;t--}return 0}function pu(e,t){let n=e.charCodeAt(t);if(!AS(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return TS(r)?(n-55296<<10)+(r-56320)+65536:n}function TS(e){return e>=56320&&e<57344}function AS(e){return e>=55296&&e<56320}function l0(e){return e<65536?1:2}var me=class MS{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]=Ui(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),Ba.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]=Ui(this,t,n);let r=[];return this.decompose(t,n,r,0),Ba.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 Fs(this),s=new Fs(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 Fs(this,t)}iterRange(t,n=this.length){return new RS(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 ES(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]?MS.empty:t.length<=32?new Wt(t):Ba.from(Wt.split(t,[]))}},Wt=class cn extends me{constructor(t,n=D_(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 N_(i,a,r,o);i=a+1,r++}}decompose(t,n,r,i){let s=t<=0&&n>=this.length?this:new cn(c0(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let o=r.pop(),a=Va(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new cn(a,o.length+s.length));else{let l=a.length>>1;r.push(new cn(a.slice(0,l)),new cn(a.slice(l)))}}else r.push(s)}replace(t,n,r){if(!(r instanceof cn))return super.replace(t,n,r);[t,n]=Ui(this,t,n);let i=Va(this.text,Va(r.text,c0(this.text,0,t)),n),s=this.length+r.length-(n-t);return i.length<=32?new cn(i,s):Ba.from(cn.split(i,[]),s)}sliceString(t,n=this.length,r=`
53
+ `){[t,n]=Ui(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 cn(r,i)),r=[],i=-1);return i>-1&&n.push(new cn(r,i)),n}},Ba=class xi extends me{constructor(t,n){super(),this.children=t,this.length=n,this.lines=0;for(let r of t)this.lines+=r.lines}lineInner(t,n,r,i){for(let s=0;;s++){let o=this.children[s],a=i+o.length,l=r+o.lines-1;if((n?l:a)>=t)return o.lineInner(t,n,r,i);i=a+1,r=l+1}}decompose(t,n,r,i){for(let s=0,o=0;o<=n&&s<this.children.length;s++){let a=this.children[s],l=o+a.length;if(t<=l&&n>=o){let c=i&((o<=t?1:0)|(l>=n?2:0));o>=t&&l<=n&&!c?r.push(a):a.decompose(t-o,n-o,r,c)}o=l+1}}replace(t,n,r){if([t,n]=Ui(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 xi(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]=Ui(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 xi))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 Wt(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 xi)for(let v of d.children)h(v);else d.lines>o&&(l>o||!l)?(f(),a.push(d)):d instanceof Wt&&l&&(p=u[u.length-1])instanceof Wt&&d.lines+p.lines<=32?(l+=d.lines,c+=d.length+1,u[u.length-1]=new Wt(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]:xi.from(u,c)),c=-1,l=u.length=0)}for(let d of t)h(d);return f(),a.length==1?a[0]:new xi(a,n)}};me.empty=new Wt([""],0);function D_(e){let t=-1;for(let n of e)t+=n.length+1;return t}function Va(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 c0(e,t,n){return Va(e,[""],t,n)}var Fs=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 Wt?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 Wt?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 Wt){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 Wt?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)}},RS=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Fs(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!=""}},ES=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(me.prototype[Symbol.iterator]=function(){return this.iter()},Fs.prototype[Symbol.iterator]=RS.prototype[Symbol.iterator]=ES.prototype[Symbol.iterator]=function(){return this});var N_=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 Ui(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function st(e,t,n=!0,r=!0){return O_(e,t,n,r)}function L_(e){return e>=56320&&e<57344}function j_(e){return e>=55296&&e<56320}function __(e,t){let n=e.charCodeAt(t);if(!j_(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return L_(r)?(n-55296<<10)+(r-56320)+65536:n}function B_(e){return e<65536?1:2}var Gh=/\r\n?|\n/,Mt=(function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e})(Mt||(Mt={})),Li=class Fa{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){Qh(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 Fa(t)}composeDesc(t){return this.empty?t:t.empty?this:PS(this,t)}mapDesc(t,n=!1){return t.empty?this:Xh(this,t,n)}mapPos(t,n=-1,r=Mt.Simple){let i=0,s=0;for(let o=0;o<this.sections.length;){let a=this.sections[o++],l=this.sections[o++],c=i+a;if(l<0){if(c>t)return s+(t-i);s+=a}else{if(r!=Mt.Simple&&c>=t&&(r==Mt.TrackDel&&i<t&&c>t||r==Mt.TrackBefore&&i<t||r==Mt.TrackAfter&&c>t))return null;if(c>t||c==t&&n<0&&!a)return t==i||n<0?s:s+l;s+=l}i=c}if(t>i)throw new RangeError(`Position ${t} is out of range for changeset of length ${i}`);return s}touchesRange(t,n=t){for(let r=0,i=0;r<this.sections.length&&i<=n;){let s=this.sections[r++],o=this.sections[r++],a=i+s;if(o>=0&&i<=n&&a>=t)return i<t&&a>n?"cover":!0;i=a}return!1}toString(){let t="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];t+=(t?" ":"")+r+(i>=0?":"+i:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Fa(t)}static create(t){return new Fa(t)}},Yt=class nr extends Li{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 Qh(this,(n,r,i,s,o)=>t=t.replace(i,i+(r-n),o),!1),t}mapDesc(t,n=!1){return Xh(this,t,n,!0)}invert(t){let n=this.sections.slice(),r=[];for(let i=0,s=0;i<n.length;i+=2){let o=n[i],a=n[i+1];if(a>=0){n[i]=a,n[i+1]=o;let l=i>>1;for(;r.length<l;)r.push(me.empty);r.push(o?t.slice(s,s+o):me.empty)}s+=o}return new nr(n,r)}compose(t){return this.empty?t:t.empty?this:PS(this,t,!0)}map(t,n=!1){return t.empty?this:Xh(this,t,n,!0)}iterChanges(t,n=!1){Qh(this,t,n)}get desc(){return Li.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);it(i,u,-1);let h=s.ins==-1?-1:s.off==0?s.ins:0;it(n,u,h),h>0&&lr(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);it(n,u,-1),it(i,u,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(u),a+=u}}return{changes:new nr(n,r),filtered:Li.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&&it(i,n-o,-1);let h=new nr(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 nr){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"?me.of(d.split(r||Gh)):d:me.empty,v=p.length;if(h==f&&v==0)return;h<o&&l(),h>o&&it(i,h-o,-1),it(i,f-h,v),lr(s,i,p),o=f}}return c(t),l(!a),a}static empty(t){return new nr(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;i<t.length;i++){let s=t[i];if(typeof s=="number")n.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,a)=>a&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length<i;)r.push(me.empty);r[i]=me.of(s.slice(1)),n.push(s[0],r[i].length)}}}return new nr(n,r)}static createSet(t,n){return new nr(t,n)}};function it(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 lr(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(me.empty);e.push(n)}}function Qh(e,t,n){let r=e.inserted;for(let i=0,s=0,o=0;o<e.sections.length;){let a=e.sections[o++],l=e.sections[o++];if(l<0)i+=a,s+=a;else{let c=i,u=s,h=me.empty;for(;c+=a,u+=l,l&&r&&(h=h.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)a=e.sections[o++],l=e.sections[o++];t(i,c,s,u,h),i=c,s=u}}}function Xh(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);it(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(it(i,a.ins,-1);c;){let u=Math.min(o.len,c);o.ins>=0&&l<o.i&&o.len<=u&&(it(i,0,o.ins),s&&lr(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;it(i,c,l<o.i?o.ins:0),s&&l<o.i&&lr(s,i,o.text),l=o.i,o.forward(o.len-u)}else{if(o.done&&a.done)return s?Yt.createSet(i,s):Li.create(i);throw new Error("Mismatched change set lengths")}}}function PS(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?Yt.createSet(r,i):Li.create(r);if(s.ins==0)it(r,s.len,0,a),s.next();else if(o.len==0&&!o.done)it(r,0,o.ins,a),i&&lr(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;it(r,l,u,a),i&&u&&lr(i,r,o.text)}else o.ins==-1?(it(r,s.off?0:s.len,l,a),i&&lr(i,r,s.textBit(l))):(it(r,s.off?0:s.len,o.off?0:o.ins,a),i&&!o.off&&lr(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?me.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?me.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},ms=class Yh{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 Yh(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 Yh(t,n,r,i)}},z=class Tt{constructor(t,n){this.ranges=t,this.mainIndex=n}map(t,n=-1){return t.empty?this:Tt.create(this.ranges.map(r=>r.map(t,n)),this.mainIndex)}eq(t,n=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(t.ranges[r],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new Tt([this.main],0)}addRange(t,n=!0){return Tt.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,Tt.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Tt(t.ranges.map(n=>ms.fromJSON(n)),t.main)}static single(t,n=t){return new Tt([Tt.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<t.length;i++){let s=t[i];if(s.empty?s.from<=r:s.from<r)return Tt.normalized(t.slice(),n);r=s.to}return new Tt(t,n)}static cursor(t,n=0,r,i){return ms.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?ms.create(n,t,o|32,r):ms.create(t,n,o,r)}static undirectionalRange(t,n){return ms.create(t,n,64,void 0)}static normalized(t,n=0){let r=t[n];t.sort((i,s)=>i.from-s.from),n=t.indexOf(r);for(let i=1;i<t.length;i++){let s=t[i],o=t[i-1];if(s.empty?s.from<=o.to:s.from<o.to){let a=o.from,l=Math.max(s.to,o.to);i<=n&&n--,t.splice(--i,2,s.anchor>s.head?Tt.range(l,a):Tt.range(a,l))}}return new Tt(t,n)}};function OS(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}var op=0,Z=class IS{constructor(t,n,r,i,s){this.combine=t,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=op++,this.default=t([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(t={}){return new IS(t.combine||(n=>n),t.compareInput||((n,r)=>n===r),t.compare||(t.combine?(n,r)=>n===r:ap),!!t.static,t.enables)}of(t){return new za([],this,0,t)}compute(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new za(t,this,1,n)}computeN(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new za(t,this,2,n)}from(t,n){return n||(n=r=>r),this.compute([t],r=>n(r.field(t)))}};function ap(e,t){return e==t||e.length==t.length&&e.every((n,r)=>n===t[r])}var za=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=op++}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)||Jh(u,c)){let f=n(u);if(o?!u0(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=xl(h,d);if(this.dependencies.every(v=>v instanceof Z?h.facet(v)===u.facet(v):v instanceof No?h.field(v,!1)==u.field(v,!1):!0)||(o?u0(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 u0(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 Jh(e,t){let n=!1;for(let r of t)zs(e,r)&1&&(n=!0);return n}function V_(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=xl(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)zs(l,c);return l.values[o]=a(l),1},update(l,c){if(!Jh(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=Jh(l,r),h=c.config.facets[t.id],f=c.facet(t);if(h&&!u&&ap(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 oa=Z.define({static:!0}),No=class DS{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 DS(op++,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(oa).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(oa),o=i.facet(oa),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,oa.of({field:this,create:t})]}get extension(){return this}},jr={lowest:4,low:3,default:2,high:1,highest:0};function gs(e){return t=>new NS(t,e)}var ic={highest:gs(jr.highest),high:gs(jr.high),default:gs(jr.default),low:gs(jr.low),lowest:gs(jr.lowest)},NS=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},LS=class jS{of(t){return new Zh(this,t)}reconfigure(t){return jS.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}},Zh=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},h0=class _S{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 F_(t,n,o))f instanceof No?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,ap(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=>V_(y,p,d))}}let h=c.map(f=>f(a));return new _S(t,o,h,a,l,s)}};function F_(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 Zh&&n.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let c of o)s(c,a);else if(o instanceof Zh){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 NS)s(o.inner,o.prec);else if(o instanceof No)r[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof za)r[a].push(o),o.facet.extensions&&s(o.facet.extensions,jr.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,jr.default),r.reduce((o,a)=>o.concat(a))}function zs(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 xl(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var BS=Z.define(),ef=Z.define({combine:e=>e.some(t=>t),static:!0}),VS=Z.define({combine:e=>e.length?e[0]:void 0,static:!0}),FS=Z.define(),zS=Z.define(),$S=Z.define(),WS=Z.define({combine:e=>e.length?e[0]:!1}),ii=class{constructor(e,t){this.type=e,this.value=t}static define(){return new z_}},z_=class{of(e){return new ii(this,e)}},$_=class{constructor(e){this.map=e}of(e){return new $e(this,e)}},$e=class HS{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 HS(this.type,n)}is(t){return this.type==t}static define(t={}){return new $_(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}};$e.reconfigure=$e.define();$e.appendConfig=$e.define();var Gt=class Ts{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&&OS(r,n.newLength),s.some(a=>a.type==Ts.time)||(this.annotations=s.concat(Ts.time.of(Date.now())))}static create(t,n,r,i,s,o){return new Ts(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(Ts.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]=="."))}};Gt.time=ii.define();Gt.userEvent=ii.define();Gt.addToHistory=ii.define();Gt.remote=ii.define();function W_(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 qS(e,t,n){var r;let i,s,o;return n?(i=t.changes,s=Yt.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:$e.mapEffects(e.effects,i).concat($e.mapEffects(t.effects,s)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function tf(e,t,n){let r=t.selection,i=ji(t.annotations);return t.userEvent&&(i=i.concat(Gt.userEvent.of(t.userEvent))),{changes:t.changes instanceof Yt?t.changes:Yt.of(t.changes||[],n,e.facet(VS)),selection:r&&(r instanceof z?r:z.single(r.anchor,r.head)),effects:ji(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function US(e,t,n){let r=tf(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=qS(r,tf(e,t[s],o?r.changes.newLength:e.doc.length),o)}let i=Gt.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return q_(n?H_(i):i)}function H_(e){let t=e.startState,n=!0;for(let i of t.facet(FS)){let s=i(e);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:W_(n,s))}if(n!==!0){let i,s;if(n===!1)s=e.changes.invertedDesc,i=Yt.empty(t.doc.length);else{let o=e.changes.filter(n);i=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}e=Gt.create(t,i,e.selection&&e.selection.map(s),$e.mapEffects(e.effects,s),e.annotations,e.scrollIntoView)}let r=t.facet(zS);for(let i=r.length-1;i>=0;i--){let s=r[i](e);s instanceof Gt?e=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Gt?e=s[0]:e=US(t,ji(s),!1)}return e}function q_(e){let t=e.startState,n=t.facet($S),r=e;for(let i=n.length-1;i>=0;i--){let s=n[i](e);s&&Object.keys(s).length&&(r=qS(r,tf(t,s,e.changes.newLength),!0))}return r==e?e:Gt.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var U_=[];function ji(e){return e==null?U_:Array.isArray(e)?e:[e]}var zn=(function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e})(zn||(zn={})),K_=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,nf;try{nf=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function G_(e){if(nf)return nf.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||K_.test(n)))return!0}return!1}function Q_(e){return t=>{if(!/\S/.test(t))return zn.Space;if(G_(t))return zn.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return zn.Word;return zn.Other}}var _e=class Ft{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++)zs(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 zs(this,r),xl(this,r)}update(...t){return US(this,t,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let a of t.effects)a.is(LS.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($e.reconfigure)?(n=null,r=a.value):a.is($e.appendConfig)&&(n=null,r=ji(r).concat(a.value));let s;n?s=t.startState.values.slice():(n=h0.resolve(r,i,this),s=new Ft(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,l)=>l.reconfigure(a,this),null).values);let o=t.startState.facet(ef)?t.newSelection:t.newSelection.asSingle();new Ft(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=ji(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=$e.mapEffects(o,u).concat($e.mapEffects(ji(l.effects),h))}return{changes:i,selection:z.create(s,n.mainIndex),effects:o}}changes(t=[]){return t instanceof Yt?t:Yt.of(t,this.doc.length,this.facet(Ft.lineSeparator))}toText(t){return me.of(t.split(this.facet(Ft.lineSeparator)||Gh))}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:(zs(this,n),xl(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 No&&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 Ft.create({doc:t.doc,selection:z.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=h0.resolve(t.extensions||[],new Map),r=t.doc instanceof me?t.doc:me.of((t.doc||"").split(n.staticFacet(Ft.lineSeparator)||Gh)),i=t.selection?t.selection instanceof z?t.selection:z.single(t.selection.anchor,t.selection.head):z.single(0);return OS(i,r.length),n.staticFacet(ef)||(i=i.asSingle()),new Ft(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Ft.tabSize)}get lineBreak(){return this.facet(Ft.lineSeparator)||`
56
+ `}get readOnly(){return this.facet(WS)}phrase(t,...n){for(let r of this.facet(Ft.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(BS))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 Q_(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=st(n,o,!1);if(s(n.slice(l,o))!=zn.Word)break;o=l}for(;a<i;){let l=st(n,a);if(s(n.slice(a,l))!=zn.Word)break;a=l}return o==a?null:z.range(o+r,a+r)}};_e.allowMultipleSelections=ef;_e.tabSize=Z.define({combine:e=>e.length?e[0]:4});_e.lineSeparator=VS;_e.readOnly=WS;_e.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])}});_e.languageData=BS;_e.changeFilter=FS;_e.transactionFilter=zS;_e.transactionExtender=$S;LS.reconfigure=$e.define();function lp(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 Zr=class{eq(e){return this==e}range(e,t=e){return rf.create(e,t,this)}};Zr.prototype.startSide=Zr.prototype.endSide=0;Zr.prototype.point=!1;Zr.prototype.mapMode=Mt.TrackDel;function cp(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var rf=class KS{constructor(t,n,r){this.from=t,this.to=n,this.value=r}static create(t,n,r){return new KS(t,n,r)}};function sf(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var X_=class GS{constructor(t,n,r,i){this.from=t,this.to=n,this.value=r,this.maxPoint=i}get length(){return bi(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 GS(a,l,o,u):null,pos:c}}},Te=class On{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 On(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(sf)),this.isEmpty)return n.length?On.of(n):this;let a=new XS(this,null,-1).goto(0),l=0,c=[],u=new $a;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(rf.create(a.from,a.to,a.value))),a.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?On.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 $a),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?[bi(r)+bi(n).length,bi(bi(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 On(r,n,a||On.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 of.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,n=0){return of.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=f0(o,a,r),c=new vs(o,l,s),u=new vs(a,l,s);r.iterGaps((h,f,d)=>d0(c,h,u,f,d,i)),r.empty&&r.length==0&&d0(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=f0(s,o),l=new vs(s,a,0).goto(r),c=new vs(o,a,0).goto(r);for(;;){if(l.to!=c.to||!af(l.active,c.active)||l.point&&(!c.point||!cp(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 vs(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 $a;for(let i of t instanceof rf?[t]:n?Y_(t):t)r.add(i.from,i.to,i.value);return r.finish()}static join(t){if(!t.length)return On.empty;let n=bi(t);for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=On.empty;i=i.nextLayer)n=new On(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};Te.empty=new Te([],[],null,-1);function bi(e){return e[e.length-1]}function Y_(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(sf(t,r)>0)return e.slice().sort(sf);t=r}return e}Te.empty.nextLayer=Te.empty;var $a=class QS{finishChunk(t){this.chunks.push(new X_(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 QS)).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(Te.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let n=Te.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,n}};function f0(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 XS=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}},of=class YS{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 XS(o,n,r,s));return i.length==1?i[0]:new YS(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--)mu(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--)mu(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(),mu(this.heap,0)}}};function mu(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 vs=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=of.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){aa(this.active,e),aa(this.activeTo,e),aa(this.activeRank,e),this.minActive=p0(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++;la(this.active,t,n),la(this.activeTo,t,r),la(this.activeRank,t,i),e&&la(e,t,this.cursor.from),this.minActive=p0(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&&aa(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 d0(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&&cp(e.point,n.point)&&af(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&&!af(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 af(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!cp(e[n],t[n]))return!1;return!0}function aa(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function la(e,t,n){for(let r=e.length-1;r>=t;r--)e[r+1]=e[r];e[t]=n}function p0(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 sc(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=st(e,i));return r}function J_(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=st(e,i)}return r===!0?-1:e.length}var JS="ͼ",m0=typeof Symbol>"u"?"__ͼ":Symbol.for(JS),lf=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),g0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},gr=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=g0[m0]||1;return g0[m0]=e+1,JS+e.toString(36)}static mount(e,t,n){let r=e[lf],i=n&&n.nonce;r?i&&r.setNonce(i):r=new Z_(e,i),r.mount(Array.isArray(t)?t:[t],e)}},v0=new Map,Z_=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let i=v0.get(n);if(i)return e[lf]=i;this.sheet=new r.CSSStyleSheet,v0.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[lf]=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)}},vr={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:"'"},uo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},eB=typeof navigator<"u"&&/Mac/.test(navigator.platform),tB=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ye=0;Ye<10;Ye++)vr[48+Ye]=vr[96+Ye]=String(Ye);for(var Ye=1;Ye<=24;Ye++)vr[Ye+111]="F"+Ye;for(var Ye=65;Ye<=90;Ye++)vr[Ye]=String.fromCharCode(Ye+32),uo[Ye]=String.fromCharCode(Ye);for(var gu in vr)uo.hasOwnProperty(gu)||(uo[gu]=vr[gu]);function nB(e){var t=!(eB&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||tB&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified")&&e.key||(e.shiftKey?uo:vr)[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 lt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},cf=typeof document<"u"?document:{documentElement:{style:{}}},uf=/Edge\/(\d+)/.exec(lt.userAgent),ZS=/MSIE \d/.test(lt.userAgent),hf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(lt.userAgent),oc=!!(ZS||hf||uf),y0=!oc&&/gecko\/(\d+)/i.test(lt.userAgent),vu=!oc&&/Chrome\/(\d+)/.exec(lt.userAgent),x0="webkitFontSmoothing"in cf.documentElement.style,ff=!oc&&/Apple Computer/.test(lt.vendor),b0=ff&&(/Mobile\/\w+/.test(lt.userAgent)||lt.maxTouchPoints>2),q={mac:b0||/Mac/.test(lt.platform),windows:/Win/.test(lt.platform),linux:/Linux|X11/.test(lt.platform),ie:oc,ie_version:ZS?cf.documentMode||6:hf?+hf[1]:uf?+uf[1]:0,gecko:y0,gecko_version:y0?+(/Firefox\/(\d+)/.exec(lt.userAgent)||[0,0])[1]:0,chrome:!!vu,chrome_version:vu?+vu[1]:0,ios:b0,android:/Android\b/.test(lt.userAgent),webkit:x0,webkit_version:x0?+(/\bAppleWebKit\/(\d+)/.exec(lt.userAgent)||[0,0])[1]:0,safari:ff,safari_version:ff?+(/\bVersion\/(\d+(\.\d+)?)/.exec(lt.userAgent)||[0,0])[1]:0,tabSize:cf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function up(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 bl=Object.create(null);function hp(e,t,n){if(e==t)return!0;e||(e=bl),t||(t=bl);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 rB(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 w0(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 iB(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){}},et=(function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e})(et||(et={})),Re=class extends Zr{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 fp(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 ho(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}=r1(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(s?t?2e8:1:-6e8)+1}return new ho(e,n,r,t,e.widget||null,!0)}static line(e){return new dp(e)}static set(e,t=!1){return Te.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Re.none=Te.empty;var fp=class e1 extends Re{constructor(t){let{start:n,end:r}=r1(t);super(n?-1:5e8,r?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?up(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||bl}eq(t){return this==t||t instanceof e1&&this.tagName==t.tagName&&hp(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)}};fp.prototype.point=!1;var dp=class t1 extends Re{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof t1&&this.spec.class==t.spec.class&&hp(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)}};dp.prototype.mapMode=Mt.TrackBefore;dp.prototype.point=!0;var ho=class n1 extends Re{constructor(t,n,r,i,s,o){super(n,r,s,t),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?Mt.TrackBefore:Mt.TrackAfter:Mt.TrackDel}get type(){return this.startSide!=this.endSide?et.WidgetRange:this.startSide<=0?et.WidgetBefore:et.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof n1&&sB(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)}};ho.prototype.point=!0;function r1(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 sB(e,t){return e==t||!!(e&&t&&e.compare(t))}function _i(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 S0=class df extends Zr{constructor(t,n,r){super(),this.tagName=t,this.attributes=n,this.rank=r}eq(t){return t==this||t instanceof df&&this.tagName==t.tagName&&hp(this.attributes,t.attributes)}static create(t){return new df(t.tagName,t.attributes||bl,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(t,n=!1){return Te.of(t,n)}};S0.prototype.startSide=S0.prototype.endSide=-1;function fo(e){let t;return e.nodeType==11?t=e.getSelection?e:e.ownerDocument:t=e,t.getSelection()}function pf(e,t){return t?e==t||e.contains(t.nodeType!=1?t.parentNode:t):!1}function $s(e,t){if(!t.anchorNode)return!1;try{return pf(e,t.anchorNode)}catch{return!1}}function Wa(e){return e.nodeType==3?po(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function Ws(e,t,n,r){return n?k0(e,t,n,r,-1)||k0(e,t,n,r,1):!1}function yr(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function wl(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function k0(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Xn(e))){if(e.nodeName=="DIV")return!1;let s=e.parentNode;if(!s||s.nodeType!=1)return!1;t=yr(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?Xn(e):0}else return!1}}function Xn(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Sl(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 oB(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 i1(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 aB(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=oB(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}=i1(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 s1(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 lB=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?Xn(t):0),n,Math.min(e.focusOffset,n?Xn(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}};function o1(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 a1(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 Lr=null;q.safari&&q.safari_version>=26&&(Lr=!1);function l1(e){if(e.setActive)return e.setActive();if(Lr)return e.focus(Lr);let t=o1(e);e.focus(Lr==null?{get preventScroll(){return Lr={preventScroll:!0},!0}}:void 0),Lr||(Lr=!1,a1(t))}var C0;function po(e,t,n=t){let r=C0||(C0=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function Bi(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 cB(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function uB(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,Xn(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=Xn(n))}else{if(n==e)return!0;r=yr(n),n=n.parentNode}}function c1(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 u1(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=Xn(n)}else if(n.parentNode&&!wl(n))r=yr(n),n=n.parentNode;else return null}}function h1(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&&!wl(n))r=yr(n)+1,n=n.parentNode;else return null}}var cr=class mf{constructor(t,n,r=!0){this.node=t,this.offset=n,this.precise=r}static before(t,n){return new mf(t.parentNode,yr(t),n)}static after(t,n){return new mf(t.parentNode,yr(t)+1,n)}},Me=(function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e})(Me||(Me={})),ei=Me.LTR,pp=Me.RTL;function f1(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}var hB=f1("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),fB=f1("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),gf=Object.create(null),an=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);gf[t]=n,gf[n]=-t}function d1(e){return e<=247?hB[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?fB[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var dB=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,yn=class{get dir(){return this.level%2?pp:ei}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 p1(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||!p1(r.inner,i.inner))return!1}return!0}var be=[];function pB(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=d1(e.charCodeAt(c));f==512?f=u:f==8&&h==4&&(f=16),be[c]=f==4?2:f,f&7&&(h=f),u=f}for(let c=o,u=l,h=l;c<a;c++){let f=be[c];if(f==128)c<a-1&&u==be[c+1]&&u&24?f=be[c]=u:be[c]=256;else if(f==64){let d=c+1;for(;d<a&&be[d]==64;)d++;let p=c&&u==8||d<n&&be[d]==8?h==1?1:8:256;for(let v=c;v<d;v++)be[v]=p;c=d-1}else f==8&&h==1&&(be[c]=1);u=f,f&7&&(h=f)}}}function mB(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=gf[f=e.charCodeAt(h)])if(d<0){for(let v=a-3;v>=0;v-=3)if(an[v+1]==-d){let y=an[v+2],x=y&2?i:y&4?y&1?s:i:0;x&&(be[h]=be[an[v]]=x),a=v;break}}else{if(an.length==189)break;an[a++]=h,an[a++]=f,an[a++]=l}else if((p=be[h])==2||p==1){let v=p==i;l=v?0:1;for(let y=a-3;y>=0;y-=3){let x=an[y+2];if(x&2)break;if(v)an[y+2]|=2;else{if(x&4)break;an[y+2]|=4}}}}}function gB(e,t,n,r){for(let i=0,s=r;i<=n.length;i++){let o=i?n[i-1].to:e,a=i<n.length?n[i].from:t;for(let l=o;l<a;){let c=be[l];if(c==256){let u=l+1;for(;;)if(u==a){if(i==n.length)break;u=n[i++].to,a=i<n.length?n[i].from:t}else if(be[u]==256)u++;else break;let h=s==1,f=h==((u<t?be[u]:r)==1)?h?1:2:r;for(let d=u,p=i,v=p?n[p-1].to:e;d>l;)d==v&&(d=n[--p].from,v=p?n[p-1].to:e),be[--d]=f;l=u}else s=c,l++}}}function vf(e,t,n,r,i,s,o){let a=r%2?2:1;if(r%2==i%2)for(let l=t,c=0;l<n;){let u=!0,h=!1;if(c==s.length||l<s[c].from){let v=be[l];v!=a&&(u=!1,h=v==16)}let f=!u&&a==1?[]:null,d=u?r:r+1,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(be[y]==a)break e;break}}c++,f?f.push(v):(v.from>l&&o.push(new yn(l,v.from,d)),yf(e,v.direction==ei!=!(d%2)?r+1:r,i,v.inner,v.from,v.to,o),l=v.to),p=v.to}else{if(p==n||(u?be[p]!=a:be[p]==a))break;p++}f?vf(e,l,p,r+1,i,f,o):l<p&&o.push(new yn(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=be[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(be[y-1]==a)break e;break}}f?f.push(v):(v.to<l&&o.push(new yn(v.to,l,d)),yf(e,v.direction==ei!=!(d%2)?r+1:r,i,v.inner,v.from,v.to,o),l=v.from),p=v.from}else{if(p==t||(u?be[p-1]!=a:be[p-1]==a))break;p--}f?vf(e,p,l,r+1,i,f,o):p<l&&o.push(new yn(p,l,d)),l=p}}function yf(e,t,n,r,i,s,o){let a=t%2?2:1;pB(e,i,s,r,a),mB(e,i,s,r,a),gB(i,s,r,a),vf(e,i,s,t,n,r,o)}function vB(e,t,n){if(!e)return[new yn(0,0,t==pp?1:0)];if(t==ei&&!n.length&&!dB.test(e))return m1(e.length);if(n.length)for(;e.length>be.length;)be[be.length]=256;let r=[],i=t==ei?0:1;return yf(e,i,i,n,0,e.length,r),r}function m1(e){return[new yn(0,e,0)]}var g1="";function yB(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=yn.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=st(e.text,o,l.forward(i,n));(u<l.from||u>l.to)&&(u=c),g1=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 xB(e,t,n){for(let r=t;r<n;r++){let i=d1(e.charCodeAt(r));if(i==1)return ei;if(i==2||i==4)return pp}return ei}var v1=Z.define(),y1=Z.define(),x1=Z.define(),b1=Z.define(),xf=Z.define(),w1=Z.define(),S1=Z.define(),mp=Z.define(),gp=Z.define(),k1=Z.define({combine:e=>e.some(t=>t)}),C1=Z.define({combine:e=>e.some(t=>t)}),T1=Z.define(),yu=class bf{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 bf(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 bf(z.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},ca=$e.define({map:(e,t)=>e.map(t)}),A1=$e.define();function xn(e,t,n){let r=e.facet(b1);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 _n=Z.define({combine:e=>e.length?e[0]:!0}),bB=0,Ai=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})}}),xr=class wf{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(Ai.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(Ai.of({plugin:this,arg:t}))}static define(t,n){const{eventHandlers:r,eventObservers:i,provide:s,decorations:o}=n||{};return new wf(bB++,t,r,i,a=>{let l=[];return o&&l.push(lc.of(c=>{let u=c.plugin(a);return u?o(u):Re.none})),s&&l.push(s(a)),l})}static fromClass(t,n){return wf.define((r,i)=>new t(r,i),n)}},xu=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(xn(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){xn(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){xn(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},M1=Z.define(),vp=Z.define(),lc=Z.define(),R1=Z.define(),yp=Z.define(),Lo=Z.define(),E1=Z.define();function T0(e,t){let n=e.state.facet(E1);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(e):s),i=[];return Te.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=xB(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 P1=Z.define();function O1(e){let t=0,n=0,r=0,i=0;for(let s of e.state.facet(P1)){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 As=Z.define(),$n=class Sf{constructor(t,n,r,i){this.fromA=t,this.toA=n,this.fromB=r,this.toB=i}join(t){return new Sf(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 Sf(u,f,c,h))}return r}},A0=class I1{constructor(t,n,r){this.view=t,this.state=n,this.transactions=r,this.flags=0,this.startState=t.state,this.changes=Yt.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 $n(s,o,a,l))),this.changedRanges=i}static create(t,n,r){return new I1(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}},wB=[],Oe=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 wB}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&&rB(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=yr(this.dom),r=this.length?e>0:t>0;return new cr(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 uc)return e;return null}static get(e){return e.cmTile}},cc=class extends Oe{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=M0(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=M0(r);this.length=s}};function M0(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var uc=class extends cc{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=Oe.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 qr)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}}},qr=class D1 extends cc{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 D1(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},kl=class N1 extends cc{constructor(t,n){super(t),this.attrs=n}isLine(){return!0}static start(t,n,r){let i=new N1(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&&kB(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):SB(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 cr(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 cr(l.dom,0);l==r.tile&&(a=!0)}}return new cr(this.dom,0)}};function SB(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Wa(t);return n[n.length-1]||null}function kB(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var Dt=class L1 extends cc{constructor(t,n){super(t),this.mark=n}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new L1(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},Ms=class j1 extends Oe{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=po(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:Sl(c,(a?a>0:n<0)==r)}static of(t,n){let r=new j1(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},mo=class _1 extends Oe{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 Sl(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 Sl(o,!a)}}get overrideDOMText(){if(!this.length)return me.empty;let{root:t}=this;if(!t)return me.empty;let n=this.posAtStart;return t.view.state.doc.slice(n,n+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,i,s){return s||(s=t.toDOM(n),t.editable||(s.contentEditable="false")),new _1(s,r,t,i)}},Cl=class extends Oe{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return me.empty}coordsIn(e,t,n){let r=this.dom.getBoundingClientRect();return n==null?r:Sl(r,t>0==n)}},CB=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}},TB=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},AB=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 Ms(o.dom,o.text+e);a.parent=s}else s.append(r||Ms.of(e,(i=this.cache.find(Ms))===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)?bu(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 Dt&&l.mark.eq(a.mark))l.dom!=a.dom&&l.setDOM(bu(a.dom)),r=l;else{let{dom:c}=a;this.cache.reused.get(a)&&Oe.get(a.dom)&&(c=bu(a.dom));let u=Dt.of(a.mark,c);r.append(u),r=u}this.cache.reused.set(a,2)}let i=Oe.get(e.text);i&&this.cache.reused.set(i,2);let s=new Ms(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=B1);let r=kl.start(e,t||((n=this.cache.find(kl))===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 Dt&&o.mark.eq(s))r=o,t--;else{let a=Dt.of(s,(n=this.cache.find(Dt,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||!R0(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(q.ios&&R0(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(wu,0,32)||new mo(wu.toDOM(),0,wu,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 TB(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 qr&&r.wrapper.eq(n.wrapper))t=r;else{let i=qr.of(n.wrapper,(e=this.cache.find(qr,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(Cl,void 0,1);return n&&(n.flags=t),n||new Cl(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},MB=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}},Tl=[mo,kl,Ms,Dt,Cl,qr,uc];for(let e=0;e<Tl.length;e++)Tl[e].bucket=e;var RB=class{constructor(e){this.view=e,this.buckets=Tl.map(()=>[]),this.index=Tl.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 mo(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}},EB=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 RB(e),this.text=new MB(e.state.doc),this.builder=new AB(this.cache,new uc(e,e.contentDOM),Te.iter(n)),this.cache.reused.set(t,2),this.old=new CB(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=IB(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?mo.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 Cl)this.cache.add(s);else if(s instanceof Dt)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 Dt&&r.unshift(s.mark)),this.openWidget=!1},leave:s=>{s.isLine()?r.length&&(r.length=i=0):s instanceof Dt&&(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=Te.spans(this.decorations,e,t,{point:(o,a,l,c,u,h)=>{if(l instanceof ho){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?Ki.block:Ki.inline),d=PB(l),p=this.cache.findWidget(f,a-o,d)||mo.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=OB(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=Oe.get(r);if(r==this.view.contentDOM)break;i instanceof Dt?t.push(i):i?.isLine()?n=i:i instanceof qr||(r.nodeName=="DIV"&&!n?n=new kl(r,B1):n||t.push(Dt.of(new fp({tagName:r.nodeName.toLowerCase(),attributes:iB(r)}),r)))}return n?{line:n,marks:t}:null}};function R0(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 PB(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 B1={class:"cm-line"};function OB(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r||(e||(e={class:"cm-line"}),n&&up(n,e),r&&(e.class+=" "+r)),e}function IB(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 Dt&&t.push(r.mark)}return t}function bu(e){let t=Oe.get(e);return t&&t.setDOM(e.cloneNode()),e}var Ki=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}};Ki.inline=new Ki("span");Ki.block=new Ki("div");var wu=new class extends ac{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},E0=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Re.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 uc(e,e.contentDOM),this.updateInner([new $n(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:!zB(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let i=r>-1?NB(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:u}=this.hasComposition;n=new $n(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=_B(s,this.decorations,e.changes);a.length&&(n=$n.extendWithRanges(n,a));let l=VB(o,this.blockWrappers,e.changes);return l.length&&(n=$n.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 EB(this.view,s,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Oe.get(t.text)&&o.cache.reused.set(Oe.get(t.text),2),this.tile=o.run(e,t),kf(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 Su&&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(A1)&&(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(_n)||n.tabIndex>-1)&&$s(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&&DB(l)){let h=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(h,l.node.childNodes[l.offset]||null)),l=c=new cr(h,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!Ws(l.node,l.offset,u.anchorNode,u.anchorOffset)||!Ws(c.node,c.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{q.android&&q.chrome&&n.contains(u.focusNode)&&FB(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let h=fo(this.view.root);if(h)if(a.empty){if(q.gecko){let f=LB(l.node,l.offset);if(f&&f!=3){let d=(f==1?u1:h1)(l.node,l.offset);d&&(l=new cr(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 cr(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new cr(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Ws(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=fo(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=Xn(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&&!Oe.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 Su?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=st(i.text,s);if(o==s)return null;let a=po(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==Me.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 qr)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?Wa(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"?Me.RTL:Me.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=Wa(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=Wa(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(Re.replace({widget:new Su(o),block:!0,inclusive:!0,isBlockGap:!0}).range(n,s))}if(!i)break;n=i.to+1}return Re.set(e)}updateDeco(){let e=1,t=this.view.state.facet(lc).map(i=>(this.dynamicDecorationMap[e++]=typeof i=="function")?i(this.view):i),n=!1,r=this.view.state.facet(yp).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(Te.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(R1).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(T1))try{if(l(this.view,e.range,e))return!0}catch(c){xn(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=O1(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(aB(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==Me.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=o1(l.dom);l.dom.scrollIntoView({block:"nearest"}),a1(c,!1)}}}lineHasWidget(e){let t=n=>n.isWidget()||n.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){kf(this.tile)}};function kf(e,t){let n=t?.get(e);if(n!=1){n==null&&e.destroy();for(let r of e.children)kf(r,t)}}function DB(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 V1(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=u1(n.focusNode,n.focusOffset),i=h1(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let a=Oe.get(i.node);if(!a||a.isText()&&a.text!=i.node.nodeValue)s=i;else if(e.docView.lastCompositionAfterCursor){let l=Oe.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 NB(e,t,n){let r=V1(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 $n(l.mapPos(s),l.mapPos(o),s,o),text:i}}function LB(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 jB=class{constructor(){this.changes=[]}compareRange(t,n){_i(t,n,this.changes)}comparePoint(t,n){_i(t,n,this.changes)}boundChange(t){_i(t,t,this.changes)}};function _B(e,t,n){let r=new jB;return Te.compare(e,t,n,r),r.changes}var BB=class{constructor(){this.changes=[]}compareRange(e,t){_i(e,t,this.changes)}comparePoint(){}boundChange(e){_i(e,e,this.changes)}};function VB(e,t,n){let r=new BB;return Te.compare(e,t,n,r),r.changes}function FB(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 zB(e,t){let n=!1;return t&&e.iterChangedRanges((r,i)=>{r<t.to&&i>t.from&&(n=!0)}),n}var Su=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 $B(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=st(i.text,s,!1):a=st(i.text,s);let l=r(i.text.slice(o,a));for(;o>0;){let c=st(i.text,o,!1);if(r(i.text.slice(c,o))!=l)break;o=c}for(;a<i.length;){let c=st(i.text,a);if(r(i.text.slice(a,c))!=l)break;a=c}return z.undirectionalRange(o+i.from,a+i.from)}function WB(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+J_(o,s,e.state.tabSize)}function Cf(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==et.Text&&(i.type!=s.type||(n<0?s.from<t:s.to>t)))&&(i=s)}}return i||r}return r}function HB(e,t,n,r){let i=Cf(e,t.head,t.assoc||-1),s=!r||i.type!=et.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==Me.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 P0(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=yB(i,s,o,a,n),u=g1;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 qB(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return s=>{let o=r(s);return i==zn.Space&&(i=o),i==o}}function UB(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=Tf(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 Hs(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 F1(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=Hs(e,i.from,0);o!=i.from&&(s=z.cursor(o,-1))}else{let o=Hs(e,i.from,-1),a=Hs(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 ku(e,t,n){let r=Hs(e.state.facet(Lo).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 mn=class{constructor(e,t){this.pos=e,this.assoc=t}};function Tf(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 mn(0,1);if(l>e.viewState.docHeight)return new mn(e.state.doc.length,-1);if(c=e.elementAtHeight(l),r==null)break;if(c.type==et.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==et.Text){let h=WB(e,i,c,o,a);return new mn(h,h==c.from?1:-1)}}if(c.type!=et.Text)return l<(c.top+c.bottom)/2?new mn(c.from,1):new mn(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 KB(e,o,a,e.textDirectionAt(c.from)).scanTile(u,c.from)}var KB=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[yn.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[yn.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==Me.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)==Me.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=st(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 po(e.dom,s,o).getClientRects()});return r.after?new mn(n[r.i+1],-1):new mn(n[r.i],1)}scanTile(e,t){if(!e.length)return new mn(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:po(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 mn(n[r.i+1],-1):new mn(s,1)}},Ha="￿",GB=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(_e.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ha}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=Oe.get(r),o=r.nextSibling;if(o==t){s?.breakAfter&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let a=Oe.get(o);(s&&a?s.breakAfter:(s?s.breakAfter:wl(r))||wl(o)&&(r.nodeName!="BR"||s?.isWidget())&&this.text.length>i)&&!XB(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=Oe.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+(QB(e,n.node,n.offset)?t:0))}};function QB(e,t,n){for(;;){if(!t||n<Xn(t))return!1;if(t==e)return!0;n=yr(t)+1,t=t.parentNode}}function XB(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let r=Oe.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 O0=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},YB=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=z1(e.docView.tile,t,n,0))){let a=i||s?[]:ZB(e),l=new GB(a,e);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=eV(a,this.bounds.from)}else{let a=e.observer.selectionRange,l=i&&i.node==a.focusNode&&i.offset==a.focusOffset||!pf(e.contentDOM,a.focusNode)?o.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=s&&s.node==a.anchorNode&&s.offset==a.anchorOffset||!pf(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 z1(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 z1(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 $1(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,Ha),f,d;!s.empty&&s.from>=a&&s.to<=l&&(t.typeOver||h!=t.text)&&h.slice(0,s.from-a)==t.text.slice(0,s.from-a)&&h.slice(s.to-a)==t.text.slice(f=t.text.length-(h.length-(s.to-a)))?n={from:s.from,to:s.to,insert:me.of(t.text.slice(s.from-a,f).split(Ha))}:(d=W1(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:me.of(t.text.slice(d.from,d.toB).split(Ha))})}else r&&(!e.hasFocus&&i.facet(_n)||Al(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:me.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(s.from).to<s.to&&e.docView.lineHasWidget(s.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:s.from,to:s.to,insert:i.toText(e.inputState.insertingText)}: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:me.of([" "])}),n)return xp(e,n,r,o);if(r&&!Al(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=F1(i.facet(Lo).map(c=>c(e)),r))),e.dispatch({selection:r,scrollIntoView:a,userEvent:l}),!0}else return!1}function xp(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&&Bi(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)&&Bi(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&Bi(e.contentDOM,"Delete",46)))return!0;let s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,a=()=>o||(o=JB(e,t,n));return e.state.facet(w1).some(l=>l(e,t.from,t.to,s,a))||e.dispatch(a()),!0}function JB(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=Hs(i.facet(Lo).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&&V1(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 W1(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 ZB(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 O0(n,r)),(i!=n||s!=r)&&t.push(new O0(i,s))),t}function eV(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 Al(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var tV=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&&vV(e.contentDOM.ownerDocument)}handleEvent(e){!uV(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=rV(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&&q1.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&&(H1.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||iV.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)&&nV(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,Bi(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 nV(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function I0(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(i){xn(n.state,i)}}}function rV(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(I0(r.value,l))}if(o)for(let a in o){let l=o[a];l&&n(a).observers.push(I0(r.value,l))}}for(let r in Jt)n(r).handlers.push(Jt[r]);for(let r in ft)n(r).observers.push(ft[r]);return t}var H1=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],iV="dthko",q1=[16,17,18,20,91,92,224,225],ua=6;function ha(e){return Math.max(0,e)*.7+8}function sV(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var oV=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=s1(e.contentDOM),this.atoms=e.state.facet(Lo).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(_e.allowMultipleSelections)&&aV(e,t),this.dragging=cV(e,t)&&G1(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&&sV(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=O1(this.view);e.clientX-a.left<=r+ua?t=-ha(r-e.clientX):e.clientX+a.right>=s-ua&&(t=ha(e.clientX-s)),e.clientY-a.top<=i+ua?n=-ha(i-e.clientY):e.clientY+a.bottom>=o-ua&&(n=ha(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=F1(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 aV(e,t){let n=e.state.facet(v1);return n.length?n[0](t):q.mac?t.metaKey:t.ctrlKey}function lV(e,t){let n=e.state.facet(y1);return n.length?n[0](t):q.mac?!t.altKey:!t.ctrlKey}function cV(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=fo(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 uV(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=Oe.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var Jt=Object.create(null),ft=Object.create(null),U1=q.ie&&q.ie_version<15||q.ios&&q.webkit_version<604;function hV(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(),K1(e,n.value)},50)}function hc(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function K1(e,t){t=hc(e.state,mp,t);let{state:n}=e,r,i=1,s=n.toText(t),o=s.lines==n.selection.ranges.length;if(Af!=null&&n.selection.ranges.every(a=>a.empty)&&Af==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})}ft.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,q.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())};ft.wheel=ft.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()};Jt.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1);ft.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")};ft.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")};ft.touchend=(e,t)=>{e.inputState.touchActive=!1};Jt.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(x1))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=dV(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new oV(e,t,n,r)),r&&e.observer.ignore(()=>{l1(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 D0(e,t,n,r){if(r==1)return z.cursor(t,n);if(r==2)return $B(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 fV=q.ie&&q.ie_version<=11,N0=null,L0=0,j0=0;function G1(e){if(!fV)return e.detail;let t=N0,n=j0;return N0=e,j0=Date.now(),L0=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(L0+1)%3:1}function dV(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=G1(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=D0(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){let h=D0(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=pV(i,l.pos))?c:a?i.addRange(u):z.create([u])}}}function pV(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}Jt.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",hc(e.state,gp,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1};Jt.dragend=e=>(e.inputState.draggedContent=null,!1);function _0(e,t,n,r){if(n=hc(e.state,mp,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:s}=e.inputState,o=r&&s&&lV(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}Jt.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&&_0(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 _0(e,t,r,!0),!0}return!1};Jt.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=U1?null:t.clipboardData;return n?(K1(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(hV(e),!1)};function mV(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 gV(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:hc(e,gp,t.join(e.lineBreak)),ranges:n,linewise:r}}var Af=null;Jt.copy=Jt.cut=(e,t)=>{if(!$s(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=gV(e.state);if(!n&&!i)return!1;Af=i?n:null,t.type=="cut"&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=U1?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(mV(e,n),!1)};var Q1=ii.define();function X1(e,t){let n=[];for(let r of e.facet(S1)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:Q1.of(!0)}):null}function Y1(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=X1(e.state,t);n?e.dispatch(n):e.update([])}},10)}ft.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),Y1(e)};ft.blur=e=>{e.observer.clearSelectionRange(),Y1(e)};ft.compositionstart=ft.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}};ft.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))};ft.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()};Jt.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 xp(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=H1.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(()=>ft.compositionend(e,t),20),!1};var B0=new Set;function vV(e){B0.has(e)||(B0.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}var V0=["pre-wrap","normal","pre-line","break-spaces"],Gi=!1;function F0(){Gi=!1}var yV=class{constructor(e){this.lineWrapping=e,this.doc=me.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return V0.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=V0.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}},xV=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},Bn=class J1{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"?et.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 ho?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 J1(this.from,this.length+t.length,this.top,this.height+t.height,n)}},Se=(function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e})(Se||(Se={})),qa=.001,Qt=class Ua{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)>qa&&(Gi=!0),this.height=t)}replace(t,n,r){return Ua.of(r)}decomposeLeft(t,n){n.push(this)}decomposeRight(t,n){n.push(this)}applyChanges(t,n,r,i){let s=this,o=r.doc;for(let a=i.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:h}=i[a],f=s.lineAt(l,Se.ByPosNoHeight,r.setDoc(n),0,0),d=f.to>=c?f:s.lineAt(c,Se.ByPosNoHeight,r,0,0);for(h+=d.to-c,c=d.to;a>0&&f.from<=i[a-1].toA;)l=i[a-1].fromA,u=i[a-1].fromB,a--,l<f.from&&(f=s.lineAt(l,Se.ByPosNoHeight,r,0,0));u+=f.from-l,l=f.from;let p=kV.build(r.setDoc(o),t,u,h);s=Ml(s,s.replace(l,c,p))}return s.updateHeight(r,0)}static empty(){return new hn(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 wV(Ua.of(t.slice(0,n)),o,Ua.of(t.slice(r)))}};function Ml(e,t){return e==t?e:(e.constructor!=t.constructor&&(Gi=!0),t)}Qt.prototype.size=1;var bV=Re.replace({}),Z1=class extends Qt{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new Bn(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 Bn(r,0,n,this.spaceAbove,bV):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let s=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(s):s}forEachLine(e,t,n,r,i,s){e<=i+this.length&&t>=i&&s(this.lineAt(0,Se.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},hn=class Mf extends Z1{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 Bn(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 Mf||i instanceof Vi&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Vi?i=new Mf(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):Qt.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:""})`}},Vi=class zt extends Qt{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 Bn(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 Bn(u,h,r+a*c,a,0)}}lineAt(t,n,r,i,s){if(n==Se.ByHeight)return this.blockAt(t,r,i,s);if(n==Se.ByPosNoHeight){let{from:d,to:p}=r.doc.lineAt(t);return new Bn(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 Bn(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 Bn(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 zt?r[r.length-1]=new zt(s.length+i):r.push(null,new zt(i-1))}if(t>0){let s=r[0];s instanceof zt?r[0]=new zt(t+s.length):r.unshift(new zt(t-1),null)}return Qt.of(r)}decomposeLeft(t,n){n.push(new zt(t-1),null)}decomposeRight(t,n){n.push(null,new zt(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 zt(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)>=qa&&(l=-2);let d=new hn(u,h,f);d.outdated=!1,o.push(d),a+=u+1}a<=s&&o.push(null,new zt(s-a).updateHeight(t,a));let c=Qt.of(o);return(l<0||Math.abs(c.height-this.height)>=qa||Math.abs(l-this.heightMetrics(t,n).perLine)>=qa)&&(Gi=!0),Ml(this,c)}else(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},wV=class extends Qt{constructor(e,t,n){super(e.length+(t?1:0)+n.length,e.height+n.height,(t?1:0)|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let s=r+this.left.height,o=i+this.left.length+this.break,a=t==Se.ByHeight?e<s:e<o,l=a?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,s,o);if(this.break||(a?l.to<o:l.from>o))return l;let c=t==Se.ByPosNoHeight?Se.ByPosNoHeight:Se.ByPos;return a?l.join(this.right.lineAt(o,c,n,s,o)):this.left.lineAt(o,c,n,r,i).join(l)}forEachLine(e,t,n,r,i,s){let o=r+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,i,s),t>=a&&this.right.forEachLine(e,t,n,o,a,s);else{let l=this.lineAt(a,Se.ByPos,n,r,i);e<l.from&&this.left.forEachLine(e,Math.min(t,l.from-1),n,r,i,s),l.to>=e&&l.from<=t&&s(l),t>l.to&&this.right.forEachLine(Math.max(e,l.to+1),t,n,o,a,s)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let s=i.length;for(let o of n)i.push(o);if(e>0&&z0(i,s-1),t<this.length){let o=i.length;this.decomposeRight(t,i),z0(i,o)}return Qt.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?Qt.of(this.break?[e,null,t]:[e,t]):(this.left=Ml(this.left,e),this.right=Ml(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 z0(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof Vi&&(r=e[t+1])instanceof Vi&&e.splice(t-1,3,new Vi(n.length+1+r.length))}var SV=5,kV=class ek{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 hn?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new hn(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 Z1(o,i,r)):(o||s||i>=SV)&&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 hn(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,n){let r=new Vi(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 hn)return t;let n=new hn(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 hn)&&!this.isCovered?this.nodes.push(new hn(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 hn&&i.updateHeight(this.oracle,r),r+=i?i.length:1;return this.nodes}static build(t,n,r,i){let s=new ek(r,t);return Te.spans(n,r,i,s,0),s.finish(r)}};function CV(e,t,n){let r=new TV;return Te.compare(e,t,n,r,0),r.changes}var TV=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&_i(e,t,this.changes,5)}};function AV(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 MV(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 RV(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var Cu=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 Re.replace({widget:new EV(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},EV=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}},$0=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=W0,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Me.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(vp).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new yV(n),this.stateDeco=H0(t),this.heightMap=Qt.empty().applyChanges(this.stateDeco,me.empty,this.heightOracle.setDoc(t.doc),[new $n(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=Re.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 fa(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?W0:new IV(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(Rs(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=H0(this.state);let r=e.changedRanges,i=$n.extendWithRanges(r,CV(n,this.stateDeco,e?e.changes:Yt.empty(this.state.doc.length))),s=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);F0(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=s||Gi)&&(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(C1)&&(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"?Me.RTL:Me.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}=i1(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=s1(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=c1(this.scrollParent||e.win);let p=(this.printing?RV:AV)(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&&!MV(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)),F0();for(let C of this.viewports){let T=C.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(C);this.heightMap=(s?Qt.empty().applyChanges(this.stateDeco,me.empty,this.heightOracle,[new $n(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,s,new xV(C.from,T))}Gi&&(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 fa(r.lineAt(s-n*1e3,Se.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,Se.ByHeight,i,0,0).to);if(t){let{head:l}=t.range;if(l<a.from||l>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=r.lineAt(l,Se.ByPos,i,0,0),h;t.y=="center"?h=(u.top+u.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&l<a.from?h=u.top:h=u.bottom-c,a=new fa(r.lineAt(h-500,Se.ByHeight,i,0,0).from,r.lineAt(h+c+500,Se.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new fa(this.heightMap.lineAt(n,Se.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,Se.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,Se.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,Se.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:o}=this;return(e==0||r<=s-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&r>s-2e3&&i<o+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new Cu(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!=Me.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=OV(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 Cu(c,u,y,n||y<2e6?y:2e6)}o.push(v)},l=c=>{if(c.length<s||c.type!=et.Text)return;let u=PV(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=pa(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=da(u,v),d=da(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=pa(u,h),T=((b-x)/2+v)/p;w=C-T,S=C+T}else w=(x-v)/p,S=(b+v)/p;f=da(u,w),d=da(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=pa(r,n)-pa(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){Cu.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Re.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=[];Te.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)||Rs(this.heightMap.lineAt(e,Se.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Rs(this.heightMap.lineAt(this.scaler.fromDOM(e),Se.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Rs(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}},fa=class{constructor(e,t){this.from=e,this.to=t}};function PV(e,t,n){let r=[],i=e,s=0;return Te.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 da({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 pa(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 OV(e,t){for(let n of e)if(t(n))return n}var W0={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function H0(e){let t=e.facet(lc).filter(r=>typeof r!="function"),n=e.facet(yp).filter(r=>typeof r!="function");return n.length&&t.push(Te.join(n)),t}var IV=class tk{constructor(t,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:a,to:l})=>{let c=n.lineAt(a,Se.ByPos,t,0,0).top,u=n.lineAt(l,Se.ByPos,t,0,0).bottom;return i+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(t){for(let n=0,r=0,i=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||t<s.top)return i+(t-r)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);r=s.bottom,i=s.domBottom}}fromDOM(t){for(let n=0,r=0,i=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||t<s.domTop)return r+(t-i)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);r=s.bottom,i=s.domBottom}}eq(t){return t instanceof tk?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 Rs(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new Bn(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(i=>Rs(i,t)):e._content)}var ma=Z.define({combine:e=>e.join(" ")}),Rf=Z.define({combine:e=>e.indexOf(!0)>-1}),Ef=gr.newName(),nk=gr.newName(),rk=gr.newName(),ik={"&light":"."+nk,"&dark":"."+rk};function Pf(e,t,n){return new gr(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 DV=Pf("."+Ef,{"&":{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"}},ik),NV={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Tu=q.ie&&q.ie_version<=11,LV=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new lB,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 _V(e),e.state.facet(_n)&&(e.contentDOM.editContext=this.editContext.editContext)),Tu&&(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(_n)?n.root.activeElement!=this.dom:!$s(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&&Ws(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=fo(e.root);if(!t)return!1;let n=q.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&jV(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=$s(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&uB(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,NV),Tu&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Tu&&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&&Bi(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&&$s(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 YB(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=$1(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Al(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=q0(t,e.previousSibling||e.target.previousSibling,-1),r=q0(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(_n)!=e.state.facet(_n)&&(e.view.contentDOM.editContext=e.state.facet(_n)?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 q0(e,t,n){for(;t;){let r=Oe.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 U0(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 Ws(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function jV(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return U0(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?U0(e,n):null}var _V=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=W1(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));Al(h,r)||e.dispatch({selection:h,userEvent:"select"});return}let u={from:c.from+o,to:c.toA+o,insert:me.of(n.text.slice(c.from,c.toB).split(`
61
+ `))};if((q.mac||q.android)&&u.from==s-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:o,to:a,insert:me.of([n.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let h=this.to-this.from+(u.to-u.from+u.insert.length);xp(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(Re.mark({attributes:{style:c}}).range(a,l))}}}e.dispatch({effects:A1.of(Re.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=fo(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 Ka{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||cB(t.parent)||document,this.viewState=new $0(this,t.state||_e.create(t)),t.scrollTo&&t.scrollTo.is(ca)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ai).map(i=>new xu(i));for(let i of this.plugins)i.update(this);this.observer=new LV(this),this.inputState=new tV(this),this.inputState.ensureHandlers(this.plugins),this.docView=new E0(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 Gt?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(Q1))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=X1(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(_e.phrases)!=this.state.facet(_e.phrases))return this.setState(s);i=A0.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(Ka.cursorScrollMargin);h=new yu(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(ca)&&(h=d.value.clip(this.state))}this.viewState.update(i,h),this.bidiCache=G0.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(As)!=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(ma)!=i.state.facet(ma)&&(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(xf))try{f(i)}catch(d){xn(this.state,d,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!$1(this,u)&&c.force&&Bi(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 $0(this,t),this.plugins=t.facet(Ai).map(r=>new xu(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new E0(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(Ai),r=t.state.facet(Ai);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new xu(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){xn(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(c1(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 xn(this.state,v),K0}}),f=A0.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]!=K0)try{let v=u[p];v.write&&v.write(h[p],this)}catch(v){xn(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(xf))l(n)}get themeClasses(){return Ef+" "+(this.state.facet(Rf)?rk:nk)+" "+this.state.facet(ma)}updateAttrs(){let t=Q0(this,M1,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(_n)?"true":"false",class:"cm-content",style:`${q.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Q0(this,vp,n);let r=this.observer.ignore(()=>{let i=w0(this.contentDOM,this.contentAttrs,n),s=w0(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(Ka.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(As);let t=this.state.facet(Ka.cspNonce);gr.mount(this.root,this.styleModules.concat(DV).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 ku(this,t,P0(this,t,n,r))}moveByGroup(t,n){return ku(this,t,P0(this,t,n,r=>qB(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 HB(this,t,n,r)}moveVertically(t,n,r){return ku(this,t,UB(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=Tf(this,t,n);return r&&r.pos}posAndSideAtCoords(t,n=!0){return this.readMeasured(),Tf(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let r=this.state.doc.lineAt(t),i=this.bidiSpans(r),s=i[yn.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==Me.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(k1)||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>BV)return m1(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||p1(s.isolates,r=T0(this,t))))return s.order;r||(r=T0(this,t));let i=vB(t.text,n,r);return this.bidiCache.push(new G0(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(()=>{l1(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 ca.of(new yu(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 ca.of(new yu(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 xr.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return xr.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=gr.newName(),i=[ma.of(r),As.of(Pf(`.${r}`,t))];return n&&n.dark&&i.push(Rf.of(!0)),i}static baseTheme(t){return ic.lowest(As.of(Pf("."+Ef,t,ik)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&Oe.get(r)||Oe.get(t);return((n=i?.root)===null||n===void 0?void 0:n.view)||null}};oe.styleModule=As;oe.inputHandler=w1;oe.clipboardInputFilter=mp;oe.clipboardOutputFilter=gp;oe.scrollHandler=T1;oe.focusChangeEffect=S1;oe.perLineTextDirection=k1;oe.exceptionSink=b1;oe.updateListener=xf;oe.editable=_n;oe.mouseSelectionStyle=x1;oe.dragMovesSelection=y1;oe.clickAddsSelectionRange=v1;oe.decorations=lc;oe.blockWrappers=R1;oe.outerDecorations=yp;oe.atomicRanges=Lo;oe.bidiIsolatedRanges=E1;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=P1;oe.darkTheme=Rf;oe.cspNonce=Z.define({combine:e=>e.length?e[0]:""});oe.contentAttributes=vp;oe.editorAttributes=M1;oe.lineWrapping=oe.contentAttributes.of({class:"cm-lineWrapping"});oe.announce=$e.define();var BV=4096,K0={},G0=class sk{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:Me.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 sk(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function Q0(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&&up(o,n)}return n}var VV=q.mac?"mac":q.windows?"win":q.linux?"linux":"key";function FV(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 ga(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 zV=ic.default(oe.domEventHandlers({keydown(e,t){return qV($V(t.state),e,t,"editor")}})),ok=Z.define({enables:zV}),X0=new WeakMap;function $V(e){let t=e.facet(ok),n=X0.get(t);return n||X0.set(t,n=HV(t.reduce((r,i)=>r.concat(i),[]))),n}var or=null,WV=4e3;function HV(e,t=VV){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=>FV(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=or={view:w,prefix:b,scope:o};return setTimeout(()=>{or==S&&(or=null)},WV),!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,Of))}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 Of=null;function qV(e,t,n,r){Of=t;let i=nB(t),s=__(i,0),o=B_(s)==i.length&&i!=" ",a="",l=!1,c=!1,u=!1;or&&or.view==n&&or.scope==r&&(a=or.prefix+" ",q1.indexOf(t.keyCode)<0&&(c=!0,or=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+ga(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=vr[t.keyCode])&&p!=i?(f(d[a+ga(p,t,!0)])||t.shiftKey&&(v=uo[t.keyCode])!=i&&v!=p&&f(d[a+ga(v,t,!1)]))&&(l=!0):o&&t.shiftKey&&f(d[a+ga(i,t,!0)])&&(l=!0),!l&&f(d._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),Of=null,l}var qs=class ak{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=lk(t);return[new ak(n,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return UV(t,n,r)}};function lk(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Me.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function Y0(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 UV(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==Me.LTR,o=e.contentDOM,a=o.getBoundingClientRect(),l=lk(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=Cf(e,r,1),p=Cf(e,i,-1),v=d.type==et.Text?d:null,y=p.type==et.Text?p:null;if(v&&(e.lineWrapping||d.widgetLineBreaks)&&(v=Y0(e,r,1,v)),y&&(e.lineWrapping||p.widgetLineBreaks)&&(y=Y0(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==et.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 qs(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 M=0;M<k.length;M+=2)A.push(x(k[M],C,k[M+1],T));return A}function w(C,T,k){let A=1e9,M=-1e9,E=[];function O(N,P,j,V,W){let B=e.coordsAtPos(N,N==k.to?-2:2),D=e.coordsAtPos(j,j==k.from?2:-2);!B||!D||(A=Math.min(B.top,D.top,A),M=Math.max(B.bottom,D.bottom,M),W==Me.LTR?E.push(s&&P?h:B.left,s&&V?f:D.right):E.push(!s&&V?h:D.left,!s&&P?f:B.right))}let R=C??k.from,L=T??k.to;for(let N of e.visibleRanges)if(N.to>R&&N.from<L)for(let P=Math.max(N.from,R),j=Math.min(N.to,L);;){let V=e.state.doc.lineAt(P);for(let W of e.bidiSpans(V)){let B=W.from+V.from,D=W.to+V.from;if(B>=j)break;D>P&&O(Math.max(B,P),C==null&&B<=R,Math.min(D,j),T==null&&D>=L,W.dir)}if(P=V.to+1,P>=j)break}return E.length==0&&O(R,C==null,L,T==null,e.textDirection),{top:A,bottom:M,horizontal:E}}function S(C,T){let k=a.top+(T?C.top:C.bottom);return{top:k,bottom:k,horizontal:[]}}}function KV(e,t){return e.constructor==t.constructor&&e.eq(t)}var GV=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(Ga)!=e.state.facet(Ga)&&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(Ga);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)=>!KV(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()}},Ga=Z.define();function ck(e){return[xr.define(t=>new GV(t,e)),Ga.of(e)]}var Qi=Z.define({combine(e){return lp(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function QV(e={}){return[Qi.of(e),XV,YV,ZV,C1.of(!0)]}function uk(e){return e.startState.facet(Qi)!=e.state.facet(Qi)}var XV=ck({above:!0,markers(e){let{state:t}=e,n=t.facet(Qi),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 qs.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=uk(e);return n&&J0(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){J0(t.state,e)},class:"cm-cursorLayer"});function J0(e,t){t.style.animationDuration=e.facet(Qi).cursorBlinkRate+"ms"}var YV=ck({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 qs.forRange(e,"cm-selectionBackground",i))t.push(s);if(q.ios&&!n.empty&&e.state.facet(Qi).iosSelectionHandles){for(let i of qs.forRange(e,"cm-selectionHandle cm-selectionHandle-start",z.cursor(n.from,1)))t.push(i);for(let i of qs.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||uk(e)},class:"cm-selectionLayer"}),JV=q.gecko&&q.gecko_version==153?"#ffffff01":"transparent",ZV=ic.highest(oe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${JV} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),z3=/x/.unicode!=null?"gu":"g";function eF(){return nF}var tF=Re.line({class:"cm-activeLine"}),nF=xr.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(tF.range(i.from)),t=i.from)}return Re.set(n)}},{decorations:e=>e.decorations}),br=class extends Zr{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};br.prototype.elementClass="";br.prototype.toDOM=void 0;br.prototype.mapMode=Mt.TrackBefore;br.prototype.startSide=br.prototype.endSide=-1;br.prototype.point=!0;var Qa=Z.define(),rF=Z.define(),Xa=Z.define(),If=Z.define({combine:e=>e.some(t=>t)});function iF(e){let t=[sF];return e&&e.fixed===!1&&t.push(If.of(!0)),t}var sF=xr.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(Xa).map(t=>new ev(e,t)),this.fixed=!e.state.facet(If);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(If)!=!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=Te.iter(this.view.state.facet(Qa),this.view.viewport.from),r=[],i=this.gutters.map(s=>new oF(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==et.Text&&o){Df(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==et.Text){Df(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(Xa),n=e.state.facet(Xa),r=e.docChanged||e.heightChanged||e.viewportChanged||!Te.eq(e.startState.facet(Qa),e.state.facet(Qa),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 ev(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==Me.LTR?{left:r,right:i}:{right:r,left:i}})});function Z0(e){return Array.isArray(e)?e:[e]}function Df(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var oF=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=Te.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 hk(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=[];Df(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(rF)){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()}}},ev=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=Z0(t.markers(e)),t.initialSpacer&&(this.spacer=new hk(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=Z0(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!Te.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()}},hk=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":""),aF(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 aF(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 lF=Z.define(),cF=Z.define(),Mi=Z.define({combine(e){return lp(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}})}}),Au=class extends br{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Mu(e,t){return e.state.facet(Mi).formatNumber(t,e.state)}var uF=Xa.compute([Mi],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(lF)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new Au(Mu(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(cF)){let s=i(t,n,r);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(Mi)!=t.state.facet(Mi),initialSpacer(t){return new Au(Mu(t,tv(t.state.doc.lines)))},updateSpacer(t,n){let r=Mu(n.view,tv(n.view.state.doc.lines));return r==t.number?t:new Au(r)},domEventHandlers:e.facet(Mi).domEventHandlers,side:"before"}));function hF(e={}){return[Mi.of(e),iF(),uF]}function tv(e){let t=9;for(;t<e;)t=t*10+9;return t}var fF=new class extends br{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},dF=Qa.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(fF.range(i)))}return Te.of(t)});function pF(){return dF}var Ru,Ri=new he;function mF(e){return Z.define({combine:e?t=>t.concat(e):void 0})}var gF=new he,Ht=class{constructor(e,t,n=[],r=""){this.data=e,this.name=r,_e.prototype.hasOwnProperty("tree")||Object.defineProperty(_e.prototype,"tree",{get(){return Tn(this)}}),this.parser=t,this.extension=[Xi.of(this),_e.languageData.of((i,s,o)=>{let a=nv(i,s,o),l=a.type.prop(Ri);if(!l)return[];let c=i.facet(l),u=a.type.prop(gF);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 nv(e,t,n).type.prop(Ri)==this.data}findRegions(e){let t=e.facet(Xi);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(Ri)==this.data){n.push({from:s,to:s+i.length});return}let o=i.prop(he.mounted);if(o){if(o.tree.prop(Ri)==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 Qe&&r(l,i.positions[a]+s)}};return r(Tn(e),0),n}get allowsNesting(){return!0}};Ht.setState=$e.define();function nv(e,t,n){let r=e.facet(Xi),i=Tn(e).topNode;if(!r||r.allowsNesting)for(let s=i;s;s=s.enter(t,n,Ee.ExcludeBuffers|Ee.EnterBracketed))s.type.isTop&&(i=s);return i}var vF=class Nf extends Ht{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=mF(t.languageData);return new Nf(n,t.parser.configure({props:[Ri.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new Nf(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Tn(e){let t=e.field(Ht.state,!1);return t?t.tree:Qe.empty}var yF=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)}},ys=null,xF=class Lf{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 Lf(t,n,[],Qe.empty,0,r,[],null)}startParse(){return this.parser.startParse(new yF(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Qe.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(ja.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(ja.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=ys;ys=this;try{return t()}finally{ys=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=rv(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=ja.applyChanges(r,l),i=Qe.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 Lf(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=rv(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 vS{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=ys;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 Qe(jt.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 ys}};function rv(e,t,n){return ja.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var jf=class _f{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 _f(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=xF.create(t.facet(Xi).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new _f(r)}};Ht.state=No.define({create:jf.init,update(e,t){for(let n of t.effects)if(n.is(Ht.setState))return n.value;return t.startState.facet(Xi)!=t.state.facet(Xi)?jf.init(t.state):e.apply(t)}});var fk=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(fk=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var Eu=typeof navigator<"u"&&(!((Ru=navigator.scheduling)===null||Ru===void 0)&&Ru.isInputPending)?()=>navigator.scheduling.isInputPending():null,bF=xr.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(Ht.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(Ht.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=fk(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(Ht.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!Eu?Math.max(25,t.timeRemaining()-5):1e9),a=s.context.treeLen<i&&r.doc.length>i+1e3,l=s.context.work(()=>Eu&&Eu()||Date.now()>o,i+(a?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ht.setState.of(new jf(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=>xn(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()}}}),Xi=Z.define({combine(e){return e.length?e[0]:null},enables:e=>[Ht.state,bF,oe.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),wF=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},SF=Z.define(),bp=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 Rl(e){let t=e.facet(bp);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function go(e,t){let n="",r=e.tabSize,i=e.facet(bp)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let s=0;s<t;s++)n+=i;return n}function wp(e,t){e instanceof _e&&(e=new fc(e));for(let r of e.state.facet(SF)){let i=r(e,t);if(i!==void 0)return i}let n=Tn(e.state);return n.length>=t?kF(e,n,t):null}var fc=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Rl(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 sc(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}},dk=new he;function kF(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 pk(r,e,n)}function pk(e,t,n){for(let r=e;r;r=r.next){let i=TF(r.node);if(i)return i(MF.create(t,n,r))}return 0}function CF(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function TF(e){let t=e.type.prop(dk);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(he.closedBy))){let i=e.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>PF(o,!0,1,void 0,s&&!CF(o)?i.from:void 0)}return e.parent==null?AF:null}function AF(){return 0}var MF=class mk extends fc{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 mk(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(RF(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return pk(this.context.next,this.base,this.pos)}};function RF(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function EF(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 PF(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?EF(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}function iv({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var OF=200;function IF(){return _e.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+OF)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=wp(o,u.from);if(h==null)continue;let f=/^\s*/.exec(u.text)[0],d=go(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 DF=new he;function NF(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 Sp=class gk{constructor(t,n){this.specs=t;let r;function i(a){let l=gr.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 Ht?a=>a.prop(Ri)==o.data:o?a=>a==o:void 0,this.style=SS(t.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=r?new gr(r):null,this.themeType=n.themeType}static define(t,n){return new gk(t,n||{})}},Bf=Z.define(),vk=Z.define({combine(e){return e.length?[e[0]]:null}});function Pu(e){let t=e.facet(Bf);return t.length?t:e.facet(vk)}function LF(e,t){let n=[_F],r;return e instanceof Sp&&(e.module&&n.push(oe.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(vk.of(e)):r?n.push(Bf.computeN([oe.darkTheme],i=>i.facet(oe.darkTheme)==(r=="dark")?[e]:[])):n.push(Bf.of(e)),n}var jF=class{constructor(e){this.markCache=Object.create(null),this.tree=Tn(e.state),this.decorations=this.buildDeco(e,Pu(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Tn(e.state),n=Pu(e.state),r=n!=Pu(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 Re.none;let n=new $a;for(let{from:r,to:i}of e.visibleRanges)T_(this.tree,t,(s,o,a)=>{n.add(s,o,this.markCache[a]||(this.markCache[a]=Re.mark({class:a})))},r,i);return n.finish()}},_F=ic.high(xr.fromClass(jF,{decorations:e=>e.decorations})),W3=Sp.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"}]),BF=oe.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),yk=1e4,xk="()[]{}",bk=Z.define({combine(e){return lp(e,{afterCursor:!0,brackets:xk,maxScanDistance:yk,renderMatch:zF})}}),VF=Re.mark({class:"cm-matchingBracket"}),FF=Re.mark({class:"cm-nonmatchingBracket"});function zF(e){let t=[],n=e.matched?VF:FF;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 sv(e){let t=[],n=e.facet(bk);for(let r of e.selection.ranges){if(!r.empty)continue;let i=bn(e,r.head,-1,n)||r.head>0&&bn(e,r.head-1,1,n)||n.afterCursor&&(bn(e,r.head,1,n)||r.head<e.doc.length&&bn(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return Re.set(t,!0)}var $F=[xr.fromClass(class{constructor(e){this.paused=!1,this.decorations=sv(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=sv(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),BF];function WF(e={}){return[bk.of(e),$F]}var HF=new he;function Vf(e,t,n){let r=e.prop(t<0?he.openedBy:he.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 Ff(e){let t=e.type.prop(HF);return t?t(e.node):e}function bn(e,t,n,r={}){let i=r.maxScanDistance||yk,s=r.brackets||xk,o=Tn(e),a=o.resolveInner(t,n);for(let l=a;l;l=l.parent){let c=Vf(l.type,n,s);if(c&&l.from<l.to){let u=Ff(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return qF(e,t,n,l,u,c,s)}}return UF(e,t,n,o,a.type,i,s)}function qF(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=Ff(u);return{start:l,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(Vf(u.type,n,o))c++;else if(Vf(u.type,-n,o)){if(c==0){let h=Ff(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 UF(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 KF=Object.create(null),ov=[jt.none],av=[],lv=Object.create(null),GF=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"]])GF[e]=QF(KF,t);function Ou(e,t){av.indexOf(e)>-1||(av.push(e),console.warn(t))}function QF(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):Ou(c,`Modifier ${c} used at start of tag`):l.length?Ou(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:Ou(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=lv[i];if(s)return s.id;let o=lv[i]=jt.define({id:ov.length,name:r,props:[bS({[r]:n})]});return ov.push(o),o.id}var H3={rtl:Re.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:Me.RTL}),ltr:Re.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:Me.LTR}),auto:Re.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})},XF=vF.define({name:"json",parser:E_.configure({props:[dk.add({Object:iv({except:/^\s*\}/}),Array:iv({except:/^\s*\]/})}),DF.add({"Object Array":NF})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function YF(){return new wF(XF)}var JF=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Cp(e.state,n.from);return r.line?ZF(e):r.block?tz(e):!1};function kp(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 ZF=kp(iz,0),ez=kp(wk,0),tz=kp((e,t)=>wk(e,t,rz(t)),0);function Cp(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var va=50;function nz(e,{open:t,close:n},r,i){let s=e.sliceDoc(r-va,r),o=e.sliceDoc(i,i+va),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+va),h=e.sliceDoc(i-va,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 rz(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 wk(e,t,n=t.selection.ranges){let r=n.map(s=>Cp(t,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>nz(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 iz(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=Cp(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 cv=ii.define(),sz=Z.define(),vo=class Es{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 Es(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 Es(t.changes&&Yt.fromJSON(t.changes),[],t.mapped&&Li.fromJSON(t.mapped),t.startSelection&&z.fromJSON(t.startSelection),t.selectionsAfter.map(z.fromJSON))}static fromTransaction(t,n){let r=Lt;for(let i of t.startState.facet(sz)){let s=i(t);s.length&&(r=r.concat(s))}return!r.length&&t.changes.empty?null:new Es(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,Lt)}static selection(t){return new Es(void 0,Lt,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 oz(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 az(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function Sk(e,t){return e.length?t.length?e.concat(t):e:t}var Lt=[],lz=200;function cz(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-lz));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),zf(e,e.length-1,1e9,n.setSelAfter(r)))}else return[vo.selection([t])]}function uz(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 Iu(e,t){if(!e.length)return e;let n=e.length,r=Lt;for(;n;){let i=hz(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?[vo.selection(r)]:Lt}function hz(e,t,n){let r=Sk(e.selectionsAfter.length?e.selectionsAfter.map(a=>a.map(t)):Lt,n);if(!e.changes)return vo.selection(r);let i=e.changes.map(t),s=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(s):s;return new vo(i,$e.mapEffects(e.effects,t),o,e.startSelection.map(s),r)}var fz=/^(input\.type|delete)($|\.)/,uv=class Ps{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 Ps(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||fz.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(s,oz(a.changes,t.changes))||r=="input.type.compose")?o=zf(o,o.length-1,i.minDepth,new vo(t.changes.compose(a.changes),Sk($e.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,Lt)):o=zf(o,o.length,i.minDepth,t),new Ps(o,Lt,n,r)}addSelection(t,n,r,i){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Lt;return s.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&az(s[s.length-1],t)?this:new Ps(cz(this.done,t),this.undone,n,r)}addMapping(t){return new Ps(Iu(this.done,t),Iu(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:cv.of({side:t,rest:uz(i),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=i.length==1?Lt:i.slice(0,i.length-1);return s.mapped&&(a=Iu(a,s.mapped)),n.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:cv.of({side:t,rest:a,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};uv.empty=new uv(Lt,Lt);function ss(e,t){return z.create(e.ranges.map(t),e.mainIndex)}function Zt(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function en({state:e,dispatch:t},n){let r=ss(e.selection,n);return r.eq(e.selection,!0)?!1:(t(Zt(e,r)),!0)}function dc(e,t){return z.cursor(t?e.to:e.from)}function kk(e,t){return en(e,n=>n.empty?e.moveByChar(n,t):dc(n,t))}function ot(e){return e.textDirectionAt(e.state.selection.main.head)==Me.LTR}var Ck=e=>kk(e,!ot(e)),Tk=e=>kk(e,ot(e));function Ak(e,t){return en(e,n=>n.empty?e.moveByGroup(n,t):dc(n,t))}var dz=e=>Ak(e,!ot(e)),pz=e=>Ak(e,ot(e)),q3=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function mz(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 pc(e,t,n){let r=Tn(e).resolveInner(t.head),i=n?he.closedBy:he.openedBy;for(let l=t.head;;){let c=n?r.childAfter(l):r.childBefore(l);if(!c)break;mz(e,c,i)?r=c:l=n?c.to:c.from}let s=r.type.prop(i),o,a;return s&&(o=n?bn(e,r.from,1):bn(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 gz=e=>en(e,t=>pc(e.state,t,!ot(e))),vz=e=>en(e,t=>pc(e.state,t,ot(e)));function Mk(e,t){return en(e,n=>{if(!n.empty)return dc(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}var Rk=e=>Mk(e,!1),Ek=e=>Mk(e,!0);function Pk(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 Ok(e,t){let n=Pk(e),{state:r}=e,i=ss(r.selection,o=>o.empty?e.moveVertically(o,t,n.height):dc(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(Zt(r,i),{effects:s}),!0}var hv=e=>Ok(e,!1),$f=e=>Ok(e,!0);function Cr(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 yz=e=>en(e,t=>Cr(e,t,!0)),xz=e=>en(e,t=>Cr(e,t,!1)),bz=e=>en(e,t=>Cr(e,t,!ot(e))),wz=e=>en(e,t=>Cr(e,t,ot(e))),Sz=e=>en(e,t=>e.moveToLineBoundary(t,!1,!1)),kz=e=>en(e,t=>e.moveToLineBoundary(t,!0,!1));function Cz(e,t,n){let r=!1,i=ss(e.selection,s=>{let o=bn(e,s.head,-1)||bn(e,s.head,1)||s.head>0&&bn(e,s.head-1,1)||s.head<e.doc.length&&bn(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(Zt(e,i)),!0):!1}var Tz=({state:e,dispatch:t})=>Cz(e,t,!1);function Bt(e,t,n){let r=ss(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(Zt(e.state,r)),!0)}function Ik(e,t){return Bt(e,t,n=>e.moveByChar(n,t))}var Dk=e=>Ik(e,!ot(e)),Nk=e=>Ik(e,ot(e));function Lk(e,t){return Bt(e,t,n=>e.moveByGroup(n,t))}var Az=e=>Lk(e,!ot(e)),Mz=e=>Lk(e,ot(e)),Rz=e=>{let t=!ot(e);return Bt(e,t,n=>pc(e.state,n,t))},Ez=e=>{let t=ot(e);return Bt(e,t,n=>pc(e.state,n,t))};function jk(e,t){return Bt(e,t,n=>e.moveVertically(n,t))}var _k=e=>jk(e,!1),Bk=e=>jk(e,!0);function Vk(e,t){return Bt(e,t,n=>e.moveVertically(n,t,Pk(e).height))}var fv=e=>Vk(e,!1),dv=e=>Vk(e,!0),Pz=e=>Bt(e,!0,t=>Cr(e,t,!0)),Oz=e=>Bt(e,!1,t=>Cr(e,t,!1)),Iz=e=>{let t=!ot(e);return Bt(e,t,n=>Cr(e,n,t))},Dz=e=>{let t=ot(e);return Bt(e,t,n=>Cr(e,n,t))},Nz=e=>Bt(e,!1,t=>z.cursor(e.lineBlockAt(t.head).from)),Lz=e=>Bt(e,!0,t=>z.cursor(e.lineBlockAt(t.head).to)),pv=({state:e,dispatch:t})=>(t(Zt(e,{anchor:0})),!0),mv=({state:e,dispatch:t})=>(t(Zt(e,{anchor:e.doc.length})),!0),gv=({state:e,dispatch:t})=>(t(Zt(e,{anchor:e.selection.main.anchor,head:0})),!0),vv=({state:e,dispatch:t})=>(t(Zt(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),jz=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),_z=({state:e,dispatch:t})=>{let n=mc(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},Bz=({state:e,dispatch:t})=>{let n=ss(e.selection,r=>{let i=Tn(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(Zt(e,n)),!0)};function Fk(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(Zt(n,z.create(i,i.length-1))),!0)}var Vz=e=>Fk(e,!1),Fz=e=>Fk(e,!0),zz=({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(Zt(e,r)),!0):!1};function jo(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=ya(e,l,!1)):l>o&&(n="delete.forward",l=ya(e,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=ya(e,o,!1),a=ya(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 ya(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 zk=(e,t,n)=>jo(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=sc(a,s.tabSize)%Rl(s)||Rl(s);for(let u=0;u<c&&a[a.length-1-u]==" ";u++)i--;l=i}else l=st(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=st(o.text,l-o.from,!1,!1)+o.from);return l}),Wf=e=>zk(e,!1,!0),$k=e=>zk(e,!0,!1),Wk=(e,t)=>jo(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=st(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}),Hk=e=>Wk(e,!1),$z=e=>Wk(e,!0),Wz=e=>jo(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Hz=e=>jo(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),qz=e=>jo(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Uz=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:me.of(["",""])},range:z.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},Kz=({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:st(s.text,i-s.from,!1)+s.from,a=i==s.to?i+1:st(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 mc(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 qk(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let s of mc(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 Gz=({state:e,dispatch:t})=>qk(e,t,!1),Qz=({state:e,dispatch:t})=>qk(e,t,!0);function Uk(e,t,n){if(e.readOnly)return!1;let r=[];for(let s of mc(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 Xz=({state:e,dispatch:t})=>Uk(e,t,!1),Yz=({state:e,dispatch:t})=>Uk(e,t,!0),Jz=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(mc(t).map(({from:i,to:s})=>(i>0?i--:s<t.doc.length&&s++,{from:i,to:s}))),r=ss(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 Zz(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Tn(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(he.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 yv=Kk(!1),e5=Kk(!0);function Kk(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&&Zz(t,s);e&&(s=o=(o<=a.to?a:t.doc.lineAt(o)).to);let c=new fc(t,{simulateBreak:s,simulateDoubleBreak:!!l}),u=wp(c,s);for(u==null&&(u=sc(/^\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=["",go(t,u)];return l&&h.push(go(t,c.lineIndent(a.from,-1))),{changes:{from:s,to:o,insert:me.of(h)},range:z.cursor(s+1+h[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Tp(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 t5=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new fc(e,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=Tp(e,(s,o,a)=>{let l=wp(r,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let c=/^\s*/.exec(s.text)[0],u=go(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},Gk=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Tp(e,(n,r)=>{r.push({from:n.from,insert:e.facet(bp)})}),{userEvent:"input.indent"})),!0),Qk=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Tp(e,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=sc(i,e.tabSize),o=0,a=go(e,Math.max(0,s-Rl(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),n5=e=>(e.setTabFocusMode(),!0),r5=[{key:"Ctrl-b",run:Ck,shift:Dk,preventDefault:!0},{key:"Ctrl-f",run:Tk,shift:Nk},{key:"Ctrl-p",run:Rk,shift:_k},{key:"Ctrl-n",run:Ek,shift:Bk},{key:"Ctrl-a",run:Sz,shift:Nz},{key:"Ctrl-e",run:kz,shift:Lz},{key:"Ctrl-d",run:$k},{key:"Ctrl-h",run:Wf},{key:"Ctrl-k",run:Wz},{key:"Ctrl-Alt-h",run:Hk},{key:"Ctrl-o",run:Uz},{key:"Ctrl-t",run:Kz},{key:"Ctrl-v",run:$f}],i5=[{key:"ArrowLeft",run:Ck,shift:Dk,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:dz,shift:Az,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:bz,shift:Iz,preventDefault:!0},{key:"ArrowRight",run:Tk,shift:Nk,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:pz,shift:Mz,preventDefault:!0},{mac:"Cmd-ArrowRight",run:wz,shift:Dz,preventDefault:!0},{key:"ArrowUp",run:Rk,shift:_k,preventDefault:!0},{mac:"Cmd-ArrowUp",run:pv,shift:gv},{mac:"Ctrl-ArrowUp",run:hv,shift:fv},{key:"ArrowDown",run:Ek,shift:Bk,preventDefault:!0},{mac:"Cmd-ArrowDown",run:mv,shift:vv},{mac:"Ctrl-ArrowDown",run:$f,shift:dv},{key:"PageUp",run:hv,shift:fv},{key:"PageDown",run:$f,shift:dv},{key:"Home",run:xz,shift:Oz,preventDefault:!0},{key:"Mod-Home",run:pv,shift:gv},{key:"End",run:yz,shift:Pz,preventDefault:!0},{key:"Mod-End",run:mv,shift:vv},{key:"Enter",run:yv,shift:yv},{key:"Mod-a",run:jz},{key:"Backspace",run:Wf,shift:Wf,preventDefault:!0},{key:"Delete",run:$k,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Hk,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:$z,preventDefault:!0},{mac:"Mod-Backspace",run:Hz,preventDefault:!0},{mac:"Mod-Delete",run:qz,preventDefault:!0}].concat(r5.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),s5=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:gz,shift:Rz},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:vz,shift:Ez},{key:"Alt-ArrowUp",run:Gz},{key:"Shift-Alt-ArrowUp",run:Xz},{key:"Alt-ArrowDown",run:Qz},{key:"Shift-Alt-ArrowDown",run:Yz},{key:"Mod-Alt-ArrowUp",run:Vz},{key:"Mod-Alt-ArrowDown",run:Fz},{key:"Escape",run:zz},{key:"Mod-Enter",run:e5},{key:"Alt-l",mac:"Ctrl-l",run:_z},{key:"Mod-i",run:Bz,preventDefault:!0},{key:"Mod-[",run:Qk},{key:"Mod-]",run:Gk},{key:"Mod-Alt-\\",run:t5},{key:"Shift-Mod-k",run:Jz},{key:"Shift-Mod-\\",run:Tz},{key:"Mod-/",run:JF},{key:"Alt-A",mac:"Ctrl-A",run:ez},{key:"Ctrl-m",mac:"Shift-Alt-m",run:n5}].concat(i5),o5={key:"Tab",run:Gk,shift:Qk},a5=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)"}}),l5=Sp.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 xv(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 c5({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=[a5,LF(l5),YF(),QV(),IF(),WF(),eF(),oe.updateListener.of(b=>{b.docChanged&&v.current.onChange?.(b.state.doc.toString()),(b.docChanged||b.selectionSet||b.focusChanged)&&v.current.onCursorChange?.(xv(b.view))}),ok.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)},o5,...s5])];return c&&x.push(hF(),pF()),u&&x.push(oe.lineWrapping),x},[c,u]);return(0,m.useEffect)(()=>{if(!f.current)return;const x=new oe({state:_e.create({doc:p.current,extensions:y}),parent:f.current});return d.current=x,v.current.onCursorChange?.(xv(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 u5({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 h5=[{value:"view",label:"View",icon:(0,g.jsx)(BP,{className:"h-3 w-3"})},{value:"edit",label:"Edit",icon:(0,g.jsx)(KP,{className:"h-3 w-3"})}];function f5({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)(u5,{options:h5,value:e,onChange:t})]}),x?(0,g.jsxs)(Ir,{children:[(0,g.jsx)(Dr,{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)(Xl,{className:"h-3 w-3 shrink-0"}),(0,g.jsx)("span",{className:"truncate",children:x})]})}),(0,g.jsx)(Nr,{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)(Ir,{children:[(0,g.jsx)(Dr,{asChild:!0,children:(0,g.jsx)(Ot,{size:"sm",variant:"ghost",onClick:o,disabled:!l,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:(0,g.jsx)(JP,{className:"h-3.5 w-3.5"})})}),(0,g.jsx)(Nr,{side:"bottom",children:(0,g.jsx)("p",{children:"Undo (Ctrl+Z)"})})]}),(0,g.jsxs)(Ir,{children:[(0,g.jsx)(Dr,{asChild:!0,children:(0,g.jsx)(Ot,{size:"sm",variant:"ghost",onClick:a,disabled:!c,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:(0,g.jsx)(QP,{className:"h-3.5 w-3.5"})})}),(0,g.jsx)(Nr,{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)(Ir,{children:[(0,g.jsx)(Dr,{asChild:!0,children:(0,g.jsx)(Ot,{size:"sm",variant:"ghost",onClick:i,disabled:!d,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:(0,g.jsx)(YP,{className:"h-3.5 w-3.5"})})}),(0,g.jsx)(Nr,{side:"bottom",children:(0,g.jsx)("p",{children:"Format JSON"})})]})]}),(0,g.jsxs)(Ir,{children:[(0,g.jsx)(Dr,{asChild:!0,children:(0,g.jsx)(Ot,{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)($i,{className:"h-3.5 w-3.5 text-success"}):(0,g.jsx)(Ii,{className:"h-3.5 w-3.5"})})}),(0,g.jsx)(Nr,{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)(Ir,{children:[(0,g.jsx)(Dr,{asChild:!0,children:(0,g.jsx)(Ot,{size:"sm",variant:"ghost",onClick:h,className:"h-7 w-7 p-0 transition-all duration-200 hover:scale-105",children:u?(0,g.jsx)(HP,{className:"h-3.5 w-3.5"}):(0,g.jsx)($P,{className:"h-3.5 w-3.5"})})}),(0,g.jsx)(Nr,{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 d5({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)(Ir,{children:[(0,g.jsx)(Dr,{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)(Xl,{className:"h-3 w-3 shrink-0"}),(0,g.jsx)("span",{className:"truncate",children:n})]})}),(0,g.jsx)(Nr,{side:"top",className:"max-w-[min(40rem,calc(100vw-2rem))] break-words",children:(0,g.jsx)("p",{children:n})})]}):null]})}function p5(e){if(e===void 0)return"null";try{return JSON.stringify(e,null,2)??"null"}catch{return"null"}}function Hf(){return(0,g.jsxs)("div",{className:"flex items-center justify-center p-4 text-sm text-muted-foreground",children:[(0,g.jsx)(Xl,{className:"h-4 w-4 mr-2 text-destructive"}),"Failed to render JSON content"]})}function m5(e){return e.viewOnly&&e.rawContent===void 0?(0,g.jsx)(g5,{...e}):(0,g.jsx)(v5,{...e})}function g5({value:e,expandJsonStrings:t=!1,className:n,height:r,maxHeight:i,collapsible:s=!1,defaultExpandDepth:o,collapsedPaths:a,onCollapseChange:l,showLineNumbers:c=!0,collapseStringsAfterLength:u,wrapLongLinesInView:h=!0}){const f=(0,m.useMemo)(()=>t?Hr(e):e,[t,e]);return(0,g.jsx)(Nh,{fallback:(0,g.jsx)(Hf,{}),children:(0,g.jsx)(jh,{value:f,className:n,height:r??"100%",maxHeight:i,collapsible:s,defaultExpandDepth:o,collapsedPaths:a,onCollapseChange:l,showLineNumbers:c,collapseStringsAfterLength:u,wrapLongLinesInView:h})})}function v5({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:M=!0,toolbarLeftContent:E,toolbarRightContent:O,error:R,showValidationErrorInStatusBar:L=!0}){const N=n!==void 0,[P,j]=(0,m.useState)("view"),V=o?"view":i??P,[W,B]=(0,m.useState)(!1),D=mj({initialValue:N?void 0:e,initialContent:N?n:void 0,onChange:t,onRawChange:N?r:void 0,onValidationError:d,expandJsonStrings:S}),te=N?n??"":D.sourceContent,re=D.content!==te,_=(0,m.useRef)(V),U=(0,m.useRef)(!1),K=(0,m.useMemo)(()=>N?D.getParsedValue():S?Hr(e):e,[D.content,S,N,e]);(0,m.useEffect)(()=>{const se=_.current,Xe=!U.current;U.current=!0,_.current=V,!(w||o||!C)&&(!(V==="edit"&&(Xe||se!=="edit"))||!D.isValid||D.format())},[V,D.format,D.isValid,C,o,w]);const G=(0,m.useCallback)(se=>{if(!o){if(V==="edit"&&se==="view"&&re&&!D.isValid){if(!window.confirm("The JSON is invalid. Switching to view mode will lose your changes. Continue?"))return;D.reset()}j(se),s?.(se)}},[V,re,D,s,o]),$=(0,m.useCallback)(async()=>{let se;return V==="edit"?se=D.content:N?se=n??"":se=p5(e),Ql(se)},[V,D.content,e,N,n]),J=(0,m.useCallback)(()=>{re&&!window.confirm("You have unsaved changes. Discard them?")||(D.reset(),j("view"),s?.("view"))},[re,D,s]),ae=(0,m.useCallback)(()=>{B(se=>!se)},[]);if(w)return(0,g.jsx)(Nh,{fallback:(0,g.jsx)(Hf,{}),children:(0,g.jsx)(jh,{value:K,className:f,height:u??"100%",maxHeight:h,collapsible:p,defaultExpandDepth:v,collapsedPaths:y,onCollapseChange:x,showLineNumbers:M,collapseStringsAfterLength:b,wrapLongLinesInView:A})});const ue=W?{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:50}:{height:u??"100%",maxHeight:h??"none"};return(0,g.jsx)(Nh,{fallback:(0,g.jsx)(Hf,{}),children:(0,g.jsxs)("div",{className:X("flex flex-col rounded-lg bg-background overflow-hidden",W&&"rounded-none",f),style:ue,children:[l&&(0,g.jsx)(f5,{mode:V,onModeChange:G,showModeToggle:a&&!o,readOnly:o,onFormat:D.format,onCopy:$,onUndo:D.undo,onRedo:D.redo,canUndo:D.canUndo,canRedo:D.canRedo,isMaximized:W,onToggleMaximize:ae,allowMaximize:c,isValid:D.isValid,leftContent:E,rightContent:O,error:R}),(0,g.jsx)("div",{className:"flex-1 min-h-0 h-full",children:V==="view"?(0,g.jsx)(jh,{value:K,height:u??"100%",collapsible:p,defaultExpandDepth:v,collapsedPaths:y,onCollapseChange:x,showLineNumbers:M,collapseStringsAfterLength:b,wrapLongLinesInView:A}):k==="codemirror"?(0,g.jsx)(c5,{content:D.content,onChange:D.setContent,onCursorChange:D.setCursorPosition,onUndo:D.undo,onRedo:D.redo,onEscape:J,isValid:D.isValid,height:u??"100%",maxHeight:W?void 0:h,showLineNumbers:M,wrapLongLines:T}):(0,g.jsx)(oS,{content:D.content,onChange:D.setContent,onCursorChange:D.setCursorPosition,onUndo:D.undo,onRedo:D.redo,onEscape:J,isValid:D.isValid,height:u??"100%",maxHeight:W?void 0:h,showLineNumbers:M,wrapLongLinesInEdit:T,wrapLongLinesInView:A})}),V==="edit"&&(0,g.jsx)(d5,{cursorPosition:D.cursorPosition,characterCount:D.content.length,validationError:L?D.validationError:null})]})})}function y5({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)(m5,{value:e,className:t,collapsible:n,defaultExpandDepth:r,collapsedPaths:i,onCollapseChange:s,collapseStringsAfterLength:o,expandJsonStrings:a,wrapLongLinesInView:l,showLineNumbers:c,height:"auto",viewOnly:!0,showToolbar:!1})})}var Xk=(0,m.createContext)({linkBase:null,trustLinks:!1});function U3({base:e,trustLinks:t=!1,children:n}){const r=(0,m.useMemo)(()=>({linkBase:e,trustLinks:t}),[e,t]);return(0,g.jsx)(Xk.Provider,{value:r,children:n})}function x5(e){if(!e)return;const t=e.replace(/\/$/,"");return(n,r,i)=>n.startsWith("/")&&!n.startsWith("//")?t+n:XC(n,r,i)}function b5(e){const t=YC.lexer(e);return t.length===0?[e]:t.map(n=>n.raw)}var Yk=(0,m.memo)(({content:e})=>{const{linkBase:t,trustLinks:n}=(0,m.useContext)(Xk),r=(0,m.useMemo)(()=>x5(t),[t]),i=(0,m.useMemo)(()=>n?{enabled:!1}:void 0,[n]);return(0,g.jsx)(QC,{linkSafety:i,urlTransform:r,children:e})},(e,t)=>e.content===t.content);Yk.displayName="MemoizedMarkdownBlock";var Jk=(0,m.memo)(({content:e,className:t})=>(0,m.useMemo)(()=>b5(e),[e]).map((n,r)=>(0,g.jsx)("div",{className:t,children:(0,g.jsx)(Yk,{content:n})},`markdown-block_${r}`)),(e,t)=>!(e.content!==t.content||e.className!==t.className));Jk.displayName="MemoizedMarkdown";var Zk="/web/artifact",eC=3e4,w5=15e3,S5=2e3,k5=2e4,C5=new Set([401,403,404,410]),T5=new Set([404,410]),A5=1,M5=6e5;function gc(e){if(!e)return!1;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&t.pathname.endsWith(Zk)&&t.searchParams.has("t")}catch{return!1}}function vc(e){if(!gc(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 Ap(e,t){return`artifact:${new URL(e).origin}:${t.k}:${t.s}`}function Mp(e){const t=vc(e);return t?Ap(e,t):e}var Yi=new Map,tC=0,yo=new Set;function R5(e){for(const[t,n]of Yi)n.expiresAt<=e&&Yi.delete(t)}function E5(e){const t=vc(e);if(!t)return!1;const n=Ap(e,t),r=t.e*1e3,i=Yi.get(n);return i&&i.expiresAt>=r?!1:(Yi.set(n,{url:e,expiresAt:r}),!0)}function P5(e){let t=!1,n=k5;const r=[e];for(;r.length>0&&n>0;){n-=1;const i=r.pop();if(typeof i=="string")i.includes(Zk)&&E5(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){Yi.size>S5&&R5(Date.now()),tC+=1;for(const i of yo)i()}}function El(e){const t=vc(e);if(!t)return e;const n=Yi.get(Ap(e,t));return n&&n.expiresAt>t.e*1e3?n.url:e}function O5(e){return yo.add(e),()=>{yo.delete(e)}}function wv(){return tC}function I5(e,t){const n=El(e);return n!==e?Promise.resolve(n):new Promise(r=>{const i=()=>{const a=El(e);a!==e&&(o(),r(a))},s=setTimeout(()=>{o(),r(null)},t),o=()=>{clearTimeout(s),yo.delete(i)};yo.add(i)})}function nC(e){return(0,m.useSyncExternalStore)(O5,wv,wv),typeof e=="string"?El(e):e}var qf,Uf=Number.NEGATIVE_INFINITY,Kf=new Set,Pl=new Map;function rC(e){return(Pl.get(Mp(e))??0)<A5}function iC(e){const t=Mp(e);Pl.set(t,(Pl.get(t)??0)+1)}function Gf(e){Pl.delete(Mp(e))}function sC(e=Date.now()){if(e-Uf<eC)return!1;Uf=e,qf=Math.max((qf??0)+1,Math.floor(e/6e4));for(const t of Kf)t();return!0}function D5(e){return Kf.add(e),()=>{Kf.delete(e)}}function Sv(){return qf}function N5(){return(0,m.useSyncExternalStore)(D5,Sv,Sv)}async function K3(e,t){const n=El(e),r=t===void 0?await fetch(n):await fetch(n,t);if(!gc(n))return r;if(r.ok)return Gf(n),r;if(!C5.has(r.status))return r;const i=T5.has(r.status);if(i&&!rC(n))return r;sC()&&i&&iC(n);const s=await I5(n,w5);if(!s||t?.signal?.aborted)return r;const o=t===void 0?await fetch(s):await fetch(s,t);return o.ok&&Gf(s),o}function oC(e,t=Date.now()){if(!gc(e))return null;const n=vc(e),r=n!==null&&n.e*1e3-t<=M5;return!r&&!rC(e)?null:sC(t)?(r||iC(e),0):Uf+eC-t}function aC(e){gc(e)&&Gf(e)}function G3(e,t){const n=N5(),r=t==="skip"||n===void 0?t:{...t,urlEpoch:n},i=tj(e,r);(0,m.useEffect)(()=>{i!==void 0&&P5(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 lC({src:e,alt:t,onError:n,onLoad:r,...i}){const s=nC(e);return(0,g.jsx)("img",{...i,src:s,alt:t,onError:o=>{oC(s),n?.(o)},onLoad:o=>{aC(s),r?.(o)}})}var yc=(0,m.createContext)(null);yc.displayName="PanelGroupContext";var Pe={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"},Rp=10,Ur=m.useLayoutEffect,kv=m.useId,L5=typeof kv=="function"?kv:()=>null,j5=0;function Ep(e=null){const t=L5(),n=(0,m.useRef)(e||t||null);return n.current===null&&(n.current=""+j5++),e??n.current}function cC({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)(yc);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:M,unregisterPanel:E}=y,O=Ep(o),R=(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}),Ur(()=>{const{callbacks:N,constraints:P}=R.current,j={...P};R.current.id=O,R.current.idIsFromProps=o!==void 0,R.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,(j.collapsedSize!==P.collapsedSize||j.collapsible!==P.collapsible||j.maxSize!==P.maxSize||j.minSize!==P.minSize)&&k(R.current,j)}),Ur(()=>{const N=R.current;return A(N),()=>{E(N)}},[f,O,A,E]),(0,m.useImperativeHandle)(s,()=>({collapse:()=>{x(R.current)},expand:N=>{b(R.current,N)},getId(){return O},getSize(){return w(R.current)},isCollapsed(){return T(R.current)},isExpanded(){return!T(R.current)},resize:N=>{M(R.current,N)}}),[x,b,w,T,O,M]);const L=S(R.current,i);return(0,m.createElement)(p,{...v,children:e,className:t,id:O,style:{...L,...d},[Pe.groupId]:C,[Pe.panel]:"",[Pe.panelCollapsible]:r||void 0,[Pe.panelId]:O,[Pe.panelSize]:parseFloat(""+L.flexGrow).toFixed(1)})}var Pp=(0,m.forwardRef)((e,t)=>(0,m.createElement)(cC,{...e,forwardedRef:t}));cC.displayName="Panel";Pp.displayName="forwardRef(Panel)";var _5;function B5(){return _5}var Qf=null,V5=!0,Cv=null,Ya=-1,jn=null;function F5(e,t,n){const r=(t&pC)!==0,i=(t&mC)!==0,s=(t&gC)!==0,o=(t&vC)!==0;if(Cv)return Cv({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 z5(){jn!==null&&(document.head.removeChild(jn),Qf=null,jn=null,Ya=-1)}function Du(e,t,n){var r,i;if(!V5)return;const s=F5(e,t,n);if(Qf!==s){if(Qf=s,jn===null){jn=document.createElement("style");const a=B5();a&&jn.setAttribute("nonce",a),document.head.appendChild(jn)}if(Ya>=0){var o;(o=jn.sheet)===null||o===void 0||o.removeRule(Ya)}Ya=(r=(i=jn.sheet)===null||i===void 0?void 0:i.insertRule(`*{cursor: ${s} !important;}`))!==null&&r!==void 0?r:-1}}function uC(e){return e.type==="keydown"}function hC(e){return e.type.startsWith("pointer")}function fC(e){return e.type.startsWith("mouse")}function xc(e){if(hC(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(fC(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function $5(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function W5(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 H5(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Mv(e),b:Mv(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;ce(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Av(Tv(n.a)),b:Av(Tv(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 q5=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function U5(e){var t;const n=getComputedStyle((t=dC(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"||U5(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"||q5.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Tv(e){let t=e.length;for(;t--;){const n=e[t];if(ce(n,"Missing node"),K5(n))return n}return null}function Av(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Mv(e){const t=[];for(;e;)t.push(e),e=dC(e);return t}function dC(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}var pC=1,mC=2,gC=4,vC=8,G5=$5()==="coarse",Xt=[],Un=!1,ar=new Map,bc=new Map,xo=new Set;function Q5(e,t,n,r,i){var s;const{ownerDocument:o}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=ar.get(o))!==null&&s!==void 0?s:0;return ar.set(o,l+1),xo.add(a),Ol(),function(){var u;bc.delete(e),xo.delete(a);const h=(u=ar.get(o))!==null&&u!==void 0?u:1;if(ar.set(o,h-1),Ol(),h===1&&ar.delete(o),Xt.includes(a)){const f=Xt.indexOf(a);f>=0&&Xt.splice(f,1),wc(),i("up",!0,null)}}}function X5(e){const{target:t}=e,{x:n,y:r}=xc(e);Un=!0,Op({target:t,x:n,y:r}),Ol(),Xt.length>0&&(Il("down",e),wc(),e.preventDefault(),yC(t)||e.stopImmediatePropagation())}function Nu(e){const{x:t,y:n}=xc(e);if(Un&&e.type!=="pointerleave"&&e.buttons===0&&(Un=!1,Il("up",e)),!Un){const{target:r}=e;Op({target:r,x:t,y:n})}Il("move",e),wc(),Xt.length>0&&e.preventDefault()}function Lu(e){const{target:t}=e,{x:n,y:r}=xc(e);bc.clear(),Un=!1,Xt.length>0&&(e.preventDefault(),yC(t)||e.stopImmediatePropagation()),Il("up",e),Op({target:t,x:n,y:r}),wc(),Ol()}function yC(e){let t=e;for(;t;){if(t.hasAttribute(Pe.resizeHandle))return!0;t=t.parentElement}return!1}function Op({target:e,x:t,y:n}){Xt.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),xo.forEach(i=>{const{element:s,hitAreaMargins:o}=i,a=s.getBoundingClientRect(),{bottom:l,left:c,right:u,top:h}=a,f=G5?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)&&H5(r,s)>0){let d=r,p=!1;for(;d&&!d.contains(s);){if(W5(d.getBoundingClientRect(),a,!0)){p=!0;break}d=d.parentElement}if(p)return}Xt.push(i)}})}function ju(e,t){bc.set(e,t)}function wc(){let e=!1,t=!1;Xt.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;bc.forEach(r=>{n|=r}),e&&t?Du("intersection",n,Un):e?Du("horizontal",n,Un):t?Du("vertical",n,Un):z5()}var _u;function Ol(){var e;(e=_u)===null||e===void 0||e.abort(),_u=new AbortController;const t={capture:!0,signal:_u.signal};xo.size&&(Un?(Xt.length>0&&ar.forEach((n,r)=>{const{body:i}=r;n>0&&(i.addEventListener("contextmenu",Lu,t),i.addEventListener("pointerleave",Nu,t),i.addEventListener("pointermove",Nu,t))}),ar.forEach((n,r)=>{const{body:i}=r;i.addEventListener("pointerup",Lu,t),i.addEventListener("pointercancel",Lu,t)})):ar.forEach((n,r)=>{const{body:i}=r;n>0&&(i.addEventListener("pointerdown",X5,t),i.addEventListener("pointermove",Nu,t))}))}function Il(e,t){xo.forEach(n=>{const{setResizeHandlerState:r}=n;r(e,Xt.includes(n),t)})}function Y5(){const[e,t]=(0,m.useState)(0);return(0,m.useCallback)(()=>t(n=>n+1),[])}function ce(e,t){if(!e)throw console.error(t),Error(t)}function ti(e,t,n=Rp){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Vn(e,t,n=Rp){return ti(e,t,n)===0}function At(e,t,n){return ti(e,t,n)===0}function J5(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(!At(i,s,n))return!1}return!0}function Ei({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];ce(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:o=100,minSize:a=0}=r;if(ti(n,a)<0)if(s){const l=(i+a)/2;ti(n,l)<0?n=i:n=a}else n=a;return n=Math.min(o,n),n=parseFloat(n.toFixed(Rp)),n}function Os({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(At(e,0))return t;const o=[...t],[a,l]=r;ce(a!=null,"Invalid first pivot index"),ce(l!=null,"Invalid second pivot index");let c=0;if(s==="keyboard"){{const u=e<0?l:a,h=n[u];ce(h,`Panel constraints not found for index ${u}`);const{collapsedSize:f=0,collapsible:d,minSize:p=0}=h;if(d){const v=t[u];if(ce(v!=null,`Previous layout not found for panel index ${u}`),At(v,f)){const y=p-v;ti(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{const u=e<0?a:l,h=n[u];ce(h,`No panel constraints found for index ${u}`);const{collapsedSize:f=0,collapsible:d,minSize:p=0}=h;if(d){const v=t[u];if(ce(v!=null,`Previous layout not found for panel index ${u}`),At(v,p)){const y=v-f;ti(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];ce(p!=null,`Previous layout not found for panel index ${h}`);const v=Ei({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];ce(f!=null,`Previous layout not found for panel index ${u}`);const d=f-h,p=Ei({panelConstraints:n,panelIndex:u,size:d});if(!At(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(J5(i,o))return i;{const u=e<0?l:a,h=t[u];ce(h!=null,`Previous layout not found for panel index ${u}`);const f=h+c,d=Ei({panelConstraints:n,panelIndex:u,size:f});if(o[u]=d,!At(d,f)){let p=f-d,v=e<0?l:a;for(;v>=0&&v<n.length;){const y=o[v];ce(y!=null,`Previous layout not found for panel index ${v}`);const x=y+p,b=Ei({panelConstraints:n,panelIndex:v,size:x});if(At(y,b)||(p-=b-y,o[v]=b),At(p,0))break;e>0?v--:v++}}}return At(o.reduce((u,h)=>h+u,0),100)?o:i}function Z5({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,o=0;const a=n[0];return ce(a!=null,"No pivot index found"),t.forEach((l,c)=>{const{constraints:u}=l,{maxSize:h=100,minSize:f=0}=u;c===a?(r=f,i=h):(s+=f,o+=h)}),{valueMax:Math.min(i,100-s),valueMin:Math.max(r,100-o),valueNow:e[a]}}function bo(e,t=document){return Array.from(t.querySelectorAll(`[${Pe.resizeHandleId}][data-panel-group-id="${e}"]`))}function xC(e,t,n=document){const r=bo(e,n).findIndex(i=>i.getAttribute(Pe.resizeHandleId)===t);return r??null}function bC(e,t,n){const r=xC(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function e$(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function wC(e,t=document){if(e$(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Sc(e,t=document){const n=t.querySelector(`[${Pe.resizeHandleId}="${e}"]`);return n||null}function t$(e,t,n,r=document){var i,s,o,a;const l=Sc(t,r),c=bo(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 n$({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:o}){(0,m.useRef)({didWarnAboutMissingResizeHandle:!1}),Ur(()=>{if(!s)return;const a=bo(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:c,valueMin:u,valueNow:h}=Z5({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),f=a[l];if(f!=null){const d=i[l];ce(d,`No panel data found for index "${l}"`),f.setAttribute("aria-controls",d.id),f.setAttribute("aria-valuemax",""+Math.round(c)),f.setAttribute("aria-valuemin",""+Math.round(u)),f.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{a.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,i,s]),(0,m.useEffect)(()=>{if(!s)return;const a=t.current;ce(a,"Eager values not found");const{panelDataArray:l}=a;ce(wC(n,s)!=null,`No group found for id "${n}"`);const c=bo(n,s);ce(c,`No resize handles found for group id "${n}"`);const u=c.map(h=>{const f=h.getAttribute(Pe.resizeHandleId);ce(f,"Resize handle element has no handle id attribute");const[d,p]=t$(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];ce(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=Os({delta:At(w,S)?T-S:S-w,initialLayout:r,panelConstraints:l.map(A=>A.constraints),pivotIndices:bC(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 Rv(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 SC(e,t){const n=e==="horizontal",{x:r,y:i}=xc(t);return n?r:i}function r$(e,t,n,r,i){const s=n==="horizontal",o=Sc(t,i);ce(o,`No resize handle element found for id "${t}"`);const a=o.getAttribute(Pe.groupId);ce(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=SC(n,e),u=wC(a,i);ce(u,`No group element found for id "${a}"`);const h=u.getBoundingClientRect(),f=s?h.width:h.height;return(c-l)/f*100}function i$(e,t,n,r,i,s){if(uC(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:r$(e,t,n,r,s)}function s$({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,i=100;for(let s=0;s<e.length;s++){const o=n[s];ce(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;a!=null&&(r++,t[s]=a,i-=a)}for(let s=0;s<e.length;s++){const o=n[s];ce(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;if(a!=null)continue;const l=e.length-r,c=i/l;r++,t[s]=c,i-=c}return t}function di(e,t,n){t.forEach((r,i)=>{const s=e[i];ce(s,`Panel data not found for index ${i}`);const{callbacks:o,constraints:a,id:l}=s,{collapsedSize:c=0,collapsible:u}=a,h=n[l];if(h==null||r!==h){n[l]=r;const{onCollapse:f,onExpand:d,onResize:p}=o;p&&p(r,h),u&&(f||d)&&(d&&(h==null||Vn(h,c))&&!Vn(r,c)&&d(),f&&(h==null||!Vn(h,c))&&Vn(r,c)&&f())}})}function xa(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 o$({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 a$(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function Ev(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 kC(e){return`react-resizable-panels:${e}`}function CC(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 TC(e,t){try{const n=kC(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function l$(e,t,n){var r,i;return(i=((r=TC(e,n))!==null&&r!==void 0?r:{})[CC(t)])!==null&&i!==void 0?i:null}function c$(e,t,n,r,i){var s;const o=kC(e),a=CC(t),l=(s=TC(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 Pv({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(!At(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];ce(o!=null,`No layout data found for index ${s}`);const a=100/r*o;n[s]=a}let i=0;for(let s=0;s<t.length;s++){const o=n[s];ce(o!=null,`No layout data found for index ${s}`);const a=Ei({panelConstraints:t,panelIndex:s,size:o});o!=a&&(i+=o-a,n[s]=a)}if(!At(i,0))for(let s=0;s<t.length;s++){const o=n[s];ce(o!=null,`No layout data found for index ${s}`);const a=o+i,l=Ei({panelConstraints:t,panelIndex:s,size:a});if(o!==l&&(i-=l-o,n[s]=l,At(i,0)))break}return n}var u$=100,Is={getItem:e=>(Ev(Is),Is.getItem(e)),setItem:(e,t)=>{Ev(Is),Is.setItem(e,t)}},Ov={};function AC({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:o=null,keyboardResizeBy:a=null,storage:l=Is,style:c,tagName:u="div",...h}){const f=Ep(s),d=(0,m.useRef)(null),[p,v]=(0,m.useState)(null),[y,x]=(0,m.useState)([]),b=Y5(),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,$=Pv({layout:_,panelConstraints:G.map(J=>J.constraints)});Rv(K,$)||(x($),k.current.layout=$,U&&U($),di(G,$,w.current))}}),[]),Ur(()=>{T.current.autoSaveId=e,T.current.direction=r,T.current.dragState=p,T.current.id=f,T.current.onLayout=o,T.current.storage=l}),n$({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=Ov[e];U==null&&(U=a$(c$,u$),Ov[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:ue}=Er(G,_,K);if(ce(ae!=null,`Panel size not found for panel "${_.id}"`),!Vn(ae,J)){S.current.set(_.id,ae);const se=Os({delta:wi(G,_)===G.length-1?ae-J:J-ae,initialLayout:K,panelConstraints:$,pivotIndices:ue,prevLayout:K,trigger:"imperative-api"});xa(K,se)||(x(se),k.current.layout=se,U&&U(se),di(G,se,w.current))}}},[]),M=(0,m.useCallback)((_,U)=>{const{onLayout:K}=T.current,{layout:G,panelDataArray:$}=k.current;if(_.constraints.collapsible){const J=$.map(tt=>tt.constraints),{collapsedSize:ae=0,panelSize:ue=0,minSize:se=0,pivotIndices:Xe}=Er($,_,G),Ie=U??se;if(Vn(ue,ae)){const tt=S.current.get(_.id),We=tt!=null&&tt>=Ie?tt:Ie,dt=Os({delta:wi($,_)===$.length-1?ue-We:We-ue,initialLayout:G,panelConstraints:J,pivotIndices:Xe,prevLayout:G,trigger:"imperative-api"});xa(G,dt)||(x(dt),k.current.layout=dt,K&&K(dt),di($,dt,w.current))}}},[]),E=(0,m.useCallback)(_=>{const{layout:U,panelDataArray:K}=k.current,{panelSize:G}=Er(K,_,U);return ce(G!=null,`Panel size not found for panel "${_.id}"`),G},[]),O=(0,m.useCallback)((_,U)=>{const{panelDataArray:K}=k.current,G=wi(K,_);return o$({defaultSize:U,dragState:p,layout:y,panelData:K,panelIndex:G})},[p,y]),R=(0,m.useCallback)(_=>{const{layout:U,panelDataArray:K}=k.current,{collapsedSize:G=0,collapsible:$,panelSize:J}=Er(K,_,U);return ce(J!=null,`Panel size not found for panel "${_.id}"`),$===!0&&Vn(J,G)},[]),L=(0,m.useCallback)(_=>{const{layout:U,panelDataArray:K}=k.current,{collapsedSize:G=0,collapsible:$,panelSize:J}=Er(K,_,U);return ce(J!=null,`Panel size not found for panel "${_.id}"`),!$||ti(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]);Ur(()=>{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 ue=l$(_,$,K);ue&&(S.current=new Map(Object.entries(ue.expandToSizes)),J=ue.layout)}J==null&&(J=s$({panelDataArray:$}));const ae=Pv({layout:J,panelConstraints:$.map(ue=>ue.constraints)});Rv(G,ae)||(x(ae),k.current.layout=ae,U&&U(ae),di($,ae,w.current))}}),Ur(()=>{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:ue,id:se,keyboardResizeBy:Xe,onLayout:Ie}=T.current,{layout:tt,panelDataArray:We}=k.current,{initialLayout:dt}=ue??{},Ae=bC(se,_,J);let nt=i$($,_,ae,ue,Xe,J);const Tr=ae==="horizontal";Tr&&U&&(nt=-nt);const as=We.map(ve=>ve.constraints),pe=Os({delta:nt,initialLayout:dt??tt,panelConstraints:as,pivotIndices:Ae,prevLayout:tt,trigger:uC($)?"keyboard":"mouse-or-touch"}),Y=!xa(tt,pe);(hC($)||fC($))&&C.current!=nt&&(C.current=nt,!Y&&nt!==0?Tr?ju(_,nt<0?pC:mC):ju(_,nt<0?gC:vC):ju(_,0)),Y&&(x(pe),k.current.layout=pe,Ie&&Ie(pe),di(We,pe,w.current))}},[]),j=(0,m.useCallback)((_,U)=>{const{onLayout:K}=T.current,{layout:G,panelDataArray:$}=k.current,J=$.map(Xe=>Xe.constraints),{panelSize:ae,pivotIndices:ue}=Er($,_,G);ce(ae!=null,`Panel size not found for panel "${_.id}"`);const se=Os({delta:wi($,_)===$.length-1?ae-U:U-ae,initialLayout:G,panelConstraints:J,pivotIndices:ue,prevLayout:G,trigger:"imperative-api"});xa(G,se)||(x(se),k.current.layout=se,K&&K(se),di($,se,w.current))},[]),V=(0,m.useCallback)((_,U)=>{const{layout:K,panelDataArray:G}=k.current,{collapsedSize:$=0,collapsible:J}=U,{collapsedSize:ae=0,collapsible:ue,maxSize:se=100,minSize:Xe=0}=_.constraints,{panelSize:Ie}=Er(G,_,K);Ie!=null&&(J&&ue&&Vn(Ie,$)?Vn($,ae)||j(_,ae):Ie<Xe?j(_,Xe):Ie>se&&j(_,se))},[j]),W=(0,m.useCallback)((_,U)=>{const{direction:K}=T.current,{layout:G}=k.current;if(!d.current)return;const $=Sc(_,d.current);ce($,`Drag handle element not found for id "${_}"`);const J=SC(K,U);v({dragHandleId:_,dragHandleRect:$.getBoundingClientRect(),initialCursorPosition:J,initialLayout:G})},[]),B=(0,m.useCallback)(()=>{v(null)},[]),D=(0,m.useCallback)(_=>{const{panelDataArray:U}=k.current,K=wi(U,_);K>=0&&(U.splice(K,1),delete w.current[_.id],k.current.panelDataArrayChanged=!0,b())},[b]),te=(0,m.useMemo)(()=>({collapsePanel:A,direction:r,dragState:p,expandPanel:M,getPanelSize:E,getPanelStyle:O,groupId:f,isPanelCollapsed:R,isPanelExpanded:L,reevaluatePanelConstraints:V,registerPanel:N,registerResizeHandle:P,resizePanel:j,startDragging:W,stopDragging:B,unregisterPanel:D,panelGroupElement:d.current}),[A,p,r,M,E,O,f,R,L,V,N,P,j,W,B,D]),re={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return(0,m.createElement)(yc.Provider,{value:te},(0,m.createElement)(u,{...h,children:t,className:n,id:s,ref:d,style:{...re,...c},[Pe.group]:"",[Pe.groupDirection]:r,[Pe.groupId]:f}))}var MC=(0,m.forwardRef)((e,t)=>(0,m.createElement)(AC,{...e,forwardedRef:t}));AC.displayName="PanelGroup";MC.displayName="forwardRef(PanelGroup)";function wi(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Er(e,t,n){const r=wi(e,t),i=r===e.length-1?[r-1,r]:[r,r+1],s=n[r];return{...t.constraints,panelSize:s,pivotIndices:i}}function h$({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){(0,m.useEffect)(()=>{if(e||n==null||r==null)return;const i=Sc(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(Pe.groupId);ce(a,`No group element found for id "${a}"`);const l=bo(a,r),c=xC(a,t,r);ce(c!==null,`No resize element found for id "${t}"`),l[o.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0].focus();break}}};return i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function RC({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)(yc);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:M}=w,E=Ep(i),[O,R]=(0,m.useState)("inactive"),[L,N]=(0,m.useState)(!1),[P,j]=(0,m.useState)(null),V=(0,m.useRef)({state:O});Ur(()=>{V.current.state=O}),(0,m.useEffect)(()=>{if(n)j(null);else{const te=T(E);j(()=>te)}},[n,E,T]);const W=(v=r?.coarse)!==null&&v!==void 0?v:15,B=(y=r?.fine)!==null&&y!==void 0?y:5;(0,m.useEffect)(()=>{if(n||P==null)return;const te=x.current;ce(te,"Element ref not attached");let re=!1;return Q5(E,te,S,{coarse:W,fine:B},(U,K,G)=>{if(!K){R("inactive");return}switch(U){case"down":{R("drag"),re=!1,ce(G,'Expected event to be defined for "down" action'),k(E,G);const{onDragging:$,onPointerDown:J}=b.current;$?.(!0),J?.();break}case"move":{const{state:$}=V.current;re=!0,$!=="drag"&&R("hover"),ce(G,'Expected event to be defined for "move" action'),P(G);break}case"up":{R("hover"),A();const{onClick:$,onDragging:J,onPointerUp:ae}=b.current;J?.(!1),ae?.(),re||$?.();break}}})},[W,S,n,B,T,E,P,k,A]),h$({disabled:n,handleId:E,resizeHandler:P,panelGroupElement:M});const D={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:{...D,...h},tabIndex:f,[Pe.groupDirection]:S,[Pe.groupId]:C,[Pe.resizeHandle]:"",[Pe.resizeHandleActive]:O==="drag"?"pointer":L?"keyboard":void 0,[Pe.resizeHandleEnabled]:!n,[Pe.resizeHandleId]:E,[Pe.resizeHandleState]:O})}RC.displayName="PanelResizeHandle";function f$({className:e,...t}){return(0,g.jsx)(MC,{"data-slot":"resizable-panel-group",className:X("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}var Xf=m.forwardRef((e,t)=>(0,g.jsx)(Pp,{ref:t,"data-slot":"resizable-panel",...e}));Xf.displayName=Pp.displayName;function d$({withHandle:e,className:t,...n}){return(0,g.jsx)(RC,{"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)(VP,{className:"size-2.5"})})})}function Dl(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 p$(e){try{const t=JSON.parse(e);if(Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t))return t}catch{}return null}function m$(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function g$(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 xs(e){if(e==null)return null;if(Array.isArray(e))return{kind:"json",value:e};if(typeof e=="string"){const t=m$(e)?p$(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 Q3(e){if(e==null)return null;if(typeof e!="object"||Array.isArray(e))return xs(e);const t=e;if(g$(t))return null;if(typeof t.text=="string")return xs(t.text);const n=Dl(t.content);if(n.length>0)return xs(n.join(`
62
+
63
+ `));const r=Dl((t.value&&typeof t.value=="object"?t.value:null)?.content);return r.length>0?xs(r.join(`
64
+
65
+ `)):xs(t)}function Bu(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=Dl(t.content);if(n.length>0)return n.join(`
66
+
67
+ `);const r=Dl((t.value&&typeof t.value=="object"?t.value:null)?.content);return r.length>0?r.join(`
68
+
69
+ `):null}function v$({className:e,children:t,...n}){return(0,g.jsxs)(QE,{"data-slot":"scroll-area",className:X("relative",e),...n,children:[(0,g.jsx)(XE,{"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)(y$,{}),(0,g.jsx)(YE,{})]})}function y$({className:e,orientation:t="vertical",...n}){return(0,g.jsx)(BE,{"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)(HE,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}var x$=500,b$={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 EC(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 Ji(e){const t=EC(e.action),n=e.locatorLabel?.trim();return n?`Interact · ${t} ${n}`:`Interact · ${t}`}function Nl(e){return e.assertion?e.assertion.passed?"ok":"error":e.ok===!0?"ok":e.ok===!1?"error":"unknown"}function bs(e){return`${e.toolCallId}:${e.stepIndex}`}function w$(e){if(!e)return[];const t=[];return typeof e.durationMs=="number"&&e.durationMs>0&&t.push({key:"duration",label:S$(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 S$(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 PC(e){return typeof e=="string"&&e.length>0?e:null}function X3(e){return(e.widgetRenderObservations?.length??0)>0||(e.browserInteractionSteps?.length??0)>0||PC(e.videoUrl)!==null}function k$(e){return e==="ok"?"OK":e==="error"?"Failed":"Unknown"}function OC({step:e,leading:t,className:n}){const r=Nl(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:Ji(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",b$[r]),children:k$(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)(lC,{src:e.screenshotUrl,alt:Ji(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 C$(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,"0")}`}function T$(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 Y3({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,p]=(0,m.useState)(null),v=nC(PC(t)),y=(0,m.useMemo)(()=>w$(n),[n]),x=(0,m.useMemo)(()=>[...e].sort((M,E)=>(M.videoOffsetMs??Number.POSITIVE_INFINITY)-(E.videoOffsetMs??Number.POSITIVE_INFINITY)||M.promptIndex-E.promptIndex||M.ts-E.ts),[e]),b=o??l??null,w=(0,m.useMemo)(()=>x.find(M=>bs(M)===b)??null,[x,b]),S=v!=null&&!h,C=x.some(M=>M.screenshotUrl),T=(0,m.useCallback)(M=>{a(bs(M));const E=s.current;if(!E||!S||M.videoOffsetMs==null)return;const O=M.videoOffsetMs/1e3;u.current=O,E.currentTime=O},[S]),k=(0,m.useCallback)(()=>{u.current=null},[]),A=(0,m.useCallback)(()=>{const M=s.current;if(!M)return;const E=T$(x,M.currentTime*1e3);if(c(E?bs(E):null),u.current==null){if(o!=null){const O=x.find(R=>bs(R)===o);if(O?.videoOffsetMs!=null){const R=O.videoOffsetMs-M.currentTime*1e3;if(R>0&&R<x$)return}}a(null)}},[x,o]);return(0,m.useEffect)(()=>{f(!1)},[v]),(0,m.useEffect)(()=>{if(!d||d.url!==v)return;const M=setTimeout(()=>{p(null),f(!1)},d.delayMs);return()=>clearTimeout(M)},[d,v]),x.length===0&&!v?(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"})]}),v&&!h&&(y.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:[y.map(M=>(0,g.jsx)("span",{title:M.title,children:M.label},M.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,v&&!h?(0,g.jsx)("video",{ref:s,src:v,controls:!0,preload:"metadata",onTimeUpdate:A,onSeeked:k,onError:()=>{const M=oC(v);f(!0),p(M!==null&&M>0?{url:v,delayMs:M}:null)},onLoadedMetadata:()=>aC(v),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?C?"Recording failed to load — screenshots preserved.":"Recording failed to load, and no screenshots were captured.":C?"Video unavailable — screenshots preserved.":"Partial capture — no recording, and no screenshots survived."})]}),x.length>0?(0,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:x.map(M=>{const E=bs(M),O=Nl(M),R=E===b;return(0,g.jsxs)("button",{type:"button",onClick:()=>T(M),"aria-pressed":R,title:Ji(M),"data-testid":"browser-filmstrip-frame","data-step-key":E,"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:[M.screenshotUrl?(0,g.jsx)(lC,{src:M.screenshotUrl,alt:Ji(M),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:EC(M.action)}),(0,g.jsx)("span",{className:X("truncate text-[10px]",O==="error"?"text-destructive":"text-muted-foreground"),children:M.videoOffsetMs!=null?C$(M.videoOffsetMs):`turn ${M.promptIndex+1}`})]},E)})}),w?(0,g.jsx)(OC,{step:w,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 A$={[-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 M$(e){const t=A$[e];return t?`${e} · ${t}`:String(e)}var R$=hr({id:ge(),parentId:ge().optional(),name:ge(),category:Za(["step","llm","tool","error","connection","discovery"]),startMs:at(),endMs:at(),promptIndex:at().optional(),stepIndex:at().optional(),authoredStepId:ge().optional(),status:Za(["ok","error"]).optional(),toolCallId:ge().optional(),toolName:ge().optional(),serverId:ge().optional(),connectionId:ge().optional(),modelId:ge().optional(),inputTokens:at().optional(),outputTokens:at().optional(),totalTokens:at().optional(),messageStartIndex:at().optional(),messageEndIndex:at().optional(),finishReason:ge().optional(),provider:ge().optional(),responseId:ge().optional(),responseTimestamp:ge().optional(),ttfcMs:at().optional(),mcpErrorCode:at().optional(),outputSource:$u([sr("narration"),sr("evidence"),sr("reconstructed")]).optional(),wireCorroborated:He().optional(),evidenceRequestId:ge().optional(),evidenceStatus:$u([sr("complete"),sr("incomplete")]).optional()}),pi=hr({toolName:ge(),arguments:ba(ge(),zv())}),E$=hr({promptIndex:at(),prompt:ge(),expectedToolCalls:fn(pi),actualToolCalls:fn(pi),expectedOutput:ge().optional(),passed:He(),missing:fn(pi),unexpected:fn(pi),argumentMismatches:fn(hr({expected:pi,actual:pi,mismatchedArguments:fn(ge())}))}),P$=hr({toolCallId:ge(),toolName:ge(),protocol:$u([sr("mcp-apps"),sr("openai-apps")]),serverId:ge(),resourceUri:ge().optional(),toolMetadata:ba(ge(),Mc()),widgetCsp:ba(ge(),Mc()).nullable().optional(),widgetPermissions:ba(ge(),Mc()).nullable().optional(),widgetPermissive:He().optional(),prefersBorder:He().optional(),widgetHtmlBlobId:ge().optional(),widgetHtmlUrl:ge().nullable().optional(),injectedOpenAiCompat:He().optional(),injectedOpenAiCompatCapabilities:hr({callTool:He().optional(),sendFollowUpMessage:He().optional(),setWidgetState:He().optional(),requestDisplayMode:Za(["all","fullscreen-only","none"]).optional(),notifyIntrinsicHeight:He().optional(),openExternal:He().optional(),setOpenInAppUrl:He().optional(),requestModal:He().optional(),uploadFile:He().optional(),selectFiles:He().optional(),getFileDownloadUrl:He().optional(),requestCheckout:He().optional(),requestClose:He().optional()}).optional()}),O$=hr({source:Za(["hosted","widget"]),fps:at().optional(),durationMs:at().optional(),distinctFrames:at().optional(),truncated:He().optional()}),J3=hr({traceVersion:sr(1),messages:fn(zv()),widgetSnapshots:fn(P$).optional(),spans:fn(R$).optional(),prompts:fn(E$).optional(),videoBlobId:ge().optional(),videoMeta:O$.optional()}),I$=["all","connection","discovery","llm","tool","error"];function Vu(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 D$({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)(Jw,{children:[(0,g.jsx)(Zw,{asChild:!0,children:(0,g.jsxs)(Ot,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 gap-1.5 border-border/50 px-2 text-[10px] font-medium text-foreground","aria-label":`Filter timeline rows: ${Vu(e)}`,children:[(0,g.jsx)(zP,{className:"size-3.5 shrink-0 opacity-80","aria-hidden":!0}),Vu(e)]})}),(0,g.jsx)(eS,{align:"start",className:"min-w-[8rem]",children:(0,g.jsx)(cj,{value:e,onValueChange:a=>t(a),children:I$.map(a=>(0,g.jsx)(uj,{value:a,className:"text-xs",children:Vu(a)},a))})})]}),(0,g.jsx)(Ot,{type:"button",variant:"outline",size:"icon",disabled:r,className:"h-7 w-7 shrink-0 border-border/50 text-muted-foreground hover:text-foreground disabled:opacity-40",title:n?"Collapse all":"Expand all","aria-label":n?"Collapse all":"Expand all","aria-pressed":n,onClick:i,children:n?(0,g.jsx)(XP,{className:"size-3.5",strokeWidth:2,"aria-hidden":!0}):(0,g.jsx)(_P,{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 Iv=[0,25,50,75,100],N$=54,L$=120;function j$(e){if(!Number.isFinite(e))return[0,100];if(e<=0)return[0,100];const t=Math.max(2,Math.floor(e/N$));return t>=Iv.length?[...Iv]:t<=2?[0,100]:t===3?[0,50,100]:[0,25,75,100]}function _$(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 Dv(e){return e<=0?Ja(0):`${Ja(0)}–${Ja(e)}`}function B$(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 kc(e,t){return t}function Nv(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 kc(e,9)}}function V$(e,t){if(e.startMs!==t.startMs)return e.startMs-t.startMs;const n=Nv(e.category)-Nv(t.category);return n!==0?n:e.endMs!==t.endMs?e.endMs-t.endMs:e.name.localeCompare(t.name)}function F$(e,t){return typeof e!="number"||t<50?null:e/(t/1e3)}function Us(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?1:2)}s`:`${Math.round(e)}ms`}function Ja(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`}function Fn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function wo(e){const t=e.toolName??e.name;return typeof t=="string"&&t.trim()?t:void 0}function _o(e){return Array.isArray(e.content)?e.content.filter(t=>Fn(t)&&typeof t.type=="string"):typeof e.content=="string"?[{type:"text",text:e.content}]:[]}function IC(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(Fn(e)){const t=Object.keys(e);return t.length>0?`{ ${t.slice(0,4).join(", ")}${t.length>4?", ...":""} }`:"{}"}return String(e)}function z$(e){const t=_o(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: ${wo(r)??"Tool"}`:r.type==="tool-result"?`Tool result: ${wo(r)??"Tool"}`:typeof r.type=="string"?r.type:"content").join(" | ");return n.length>220?`${n.slice(0,217)}...`:n}function $$(e){return!Fn(e)||!("type"in e)||!("value"in e)?e:e.value}function W$(e){return e.result!==void 0?e.result:$$(e.output)}function H$(e){const t=W$(e);if(typeof e.error=="string"&&e.error.trim())return e.error.trim();if(Fn(e.error)&&typeof e.error.message=="string")return e.error.message;if(Fn(e.output)&&e.output.type==="error-text")return typeof e.output.value=="string"?e.output.value:"Tool error";if(Fn(e.result)&&e.result.isError===!0||Fn(e.output)&&Fn(e.output.value)&&e.output.value.isError===!0||e.isError===!0)return Bu(t)??"Tool error"}function Cc(e,t,n){if(!t&&!n)return{};let r,i,s;for(const o of e)for(const a of _o(o)){const l=typeof t=="string"&&a.toolCallId===t,c=!l&&typeof n=="string"&&wo(a)===n;if(!(!l&&!c)&&(a.type==="tool-call"&&(r=a.input??a.parameters??a.args),a.type==="tool-result")){i=a.result??(Fn(a.output)&&"value"in a.output?a.output.value:a.output);const u=H$(a);u&&(s=u)}}return{input:r,output:i,errorText:s}}function Pi(e,t){return e.category==="error"||e.status==="error"?!0:e.category==="tool"?!!Cc(t,e.toolCallId,e.toolName??e.name).errorText:!1}function os(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 q$(e){return os(e.messageStartIndex,e.messageEndIndex)}function U$(e){return os(e.span.messageStartIndex,e.span.messageEndIndex)}function DC(e){if(!e)return[];const t=[];for(let n=e.startIndex;n<=e.endIndex;n+=1)t.push(n);return t}function NC(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 Ip(e,t,n){if(!e.length)return;const r=os(t,n);if(!r){const s=e.findIndex(o=>o.role==="user");return s>=0?s:void 0}const i=NC(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 K$(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 kc(n,"trace-waterfall-bar-step")}}function G$(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 kc(e,"text-muted-foreground")}}function Q$(e,t){if(e.kind==="prompt")return"trace-waterfall-row-accent-prompt";if(e.kind==="interaction")return e.status==="error"?"trace-waterfall-row-accent-error":"trace-waterfall-row-accent-tool";const n=t?"error":e.span.category;switch(n){case"llm":return"trace-waterfall-row-accent-llm";case"tool":return"trace-waterfall-row-accent-tool";case"error":return"trace-waterfall-row-accent-error";case"step":case"connection":case"discovery":return"trace-waterfall-row-accent-step";default:return kc(n,"border-l-muted-foreground")}}function X$(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)=>V$(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 Lv(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 Fu(e){return{role:e.role,content:e.content}}function LC(e,t,n){const r=os(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 Y$(e,t,n){const r=os(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(Fu),output:null};const o=LC(e,t,n),a=i[s];return{input:o.length>0?o.map(Fu):null,output:Fu(a)}}var J$=96;function qt(e,t=J$){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function So(e){return typeof e.content=="string"?e.content.trim():_o(e).map(t=>t.type==="text"&&typeof t.text=="string"?t.text.trim():"").filter(Boolean).join(" ")}function Z$(e){const t=_o(e),n=[];for(const r of t)r.type==="tool-call"&&n.push(wo(r)??"tool");return n}function e3(e,t){if(!e.length)return;const n=LC(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=So(i);if(s)return qt(s)}}for(const r of n)if(r.role==="system"){const i=So(r);if(i)return qt(i)}for(let r=n.length-1;r>=0;r--){const i=n[r];if(i.role==="tool"){const s=z$(i);if(s&&s!=="No content")return qt(s)}}}}function t3(e,t){if(!e.length)return;const n=os(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=So(s);if(o)return{kind:"text",preview:qt(o)};const a=Z$(s);if(a.length>0)return{kind:"tools",preview:qt(`Calling ${a.join(", ")}`)}}}function n3(e,t,n){const r=Ip(e,t,n);if(typeof r!="number")return;const i=So(e[r]);return i?qt(i):void 0}function r3(e,t,n){const r=Ip(e,t,n);if(typeof r=="number")return So(e[r])||void 0}function jv(e,t){if(typeof t.toolCallId=="string"&&e.toolCallId===t.toolCallId)return!0;const n=t.toolName?.trim()||t.name?.trim();return!!(n&&wo(e)===n)}function i3(e,t,n){if(n)for(let r=n.startIndex;r<=n.endIndex;r+=1){const i=e[r];if(!i)continue;const s=_o(i);if(s.some(o=>o.type==="tool-call"&&jv(o,t))||s.some(o=>o.type==="tool-result"&&jv(o,t)))return r}}function s3(e,t){const n=Ip(t,e.messageStartIndex,e.messageEndIndex);if(typeof n=="number")return{focusSourceIndex:n,highlightSourceIndices:[n]};const r=DC(q$(e));if(r.length!==0)return{focusSourceIndex:r[0],highlightSourceIndices:r}}function o3(e,t){const n=U$(e),r=DC(n);if(r.length===0)return;const i=NC(t,n,s=>s.role==="assistant");return{focusSourceIndex:(e.span.category==="tool"?i3(t,e.span,n):void 0)??i??r[0],highlightSourceIndices:r}}function a3(e,t){const n=Cc(e,t.toolCallId,t.toolName??t.name);if(n.input==null)return;const r=IC(n.input);if(!(!r||r==="None"))return qt(r)}function Zi({category:e,size:t="sm"}){const n=X(t==="lg"?"h-5 w-5 shrink-0":"h-3.5 w-3.5 shrink-0",G$(e));switch(e){case"prompt":return(0,g.jsx)(ZP,{className:n,"aria-hidden":!0});case"llm":return(0,g.jsx)(NP,{className:n,"aria-hidden":!0});case"tool":return(0,g.jsx)(eO,{className:n,"aria-hidden":!0});case"interaction":return(0,g.jsx)(UP,{className:n,"aria-hidden":!0});case"error":return(0,g.jsx)(LP,{className:n,"aria-hidden":!0});case"connection":case"discovery":case"step":return(0,g.jsx)(am,{className:n,"aria-hidden":!0});default:return(0,g.jsx)(am,{className:n,"aria-hidden":!0})}}function l3(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 c3(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=l3(t,e.span);return typeof r.inputTokens=="number"||typeof r.outputTokens=="number"||typeof r.totalTokens=="number"?r:n}function zu(e){return typeof e=="number"?e.toLocaleString():"—"}function _v(e){return typeof e=="number"&&Number.isFinite(e)?new Date(e).toLocaleString():"—"}function u3({traceStartedAtMs:e,traceEndedAtMs:t,traceDurationMs:n}){return typeof e=="number"&&Number.isFinite(e)?e:typeof t=="number"&&Number.isFinite(t)?t-n:null}function Yf(e,t){const{span:n,promptIndex:r}=e,i=n.modelId?.trim()?qt(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?qt(s,64):a,u=e3(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=t3(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":qt(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=a3(t,n),l=!a||a==="{}"||a==="None";if(a&&!l)return{title:o,subtitle:a};if(l){const c=Cc(t,n.toolCallId,n.toolName??n.name);if(c.output!=null){const u=IC(c.output);if(u&&u!=="None"&&u!=="{}")return{title:o,subtitle:qt(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 Jf(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 h3({format:e,onFormatChange:t}){return(0,g.jsx)("div",{className:"flex flex-wrap gap-1",children:["plain","markdown"].map(n=>(0,g.jsx)(Ot,{type:"button",size:"sm",variant:e===n?"secondary":"outline",className:"h-7 text-[10px] capitalize",onClick:()=>t(n),children:n==="plain"?"Plain":"Markdown"},n))})}function Bv({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)(h3,{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)(Jk,{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)(y5,{value:e,containerClassName:"max-h-56 rounded-md border border-border/60 bg-background"})}function f3({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)(OC,{step:e.step,leading:(0,g.jsx)(Zi,{category:"interaction",size:"lg"})})})}function Vv(e){return e.split(/[-_\s]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function d3(e){return e.engine==="harness"?e.harness?Vv(e.harness):"Harness":e.engine==="emulated"?"Emulated":e.harness?Vv(e.harness):"Unknown"}function p3({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)(FP,{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)(f3,{row:e});const i=e.kind==="prompt"?s3(e,t):o3(e,t),s=e.kind==="span"?Cc(t,e.span.toolCallId,e.span.toolName??e.span.name):{},{durationMs:o}=Jf(e),a=e.kind==="span"?Yf(e,t):null,l=e.kind==="prompt"?e.label:a.title,c=e.kind==="prompt"?e.hasAnyFailure?"error":"ok":Pi(e.span,t)?"error":"ok",u=e.kind==="prompt"?"prompt":e.span.category==="tool"&&Pi(e.span,t)?"error":e.span.category,h=r?.get(e.promptIndex),f=e.kind==="span"&&(e.span.category==="llm"||e.span.category==="step")?Y$(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"?r3(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)(Zi,{category:"prompt",size:"lg"}):(0,g.jsx)(Zi,{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)(tS,{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: ",d3(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:Us(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"?F$(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:Us(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)(Ot,{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)(WP,{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)(Bv,{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)(Bv,{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:M$(e.span.mcpErrorCode)})]}):null]})]}):null]})}function Z3({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=YN(),w=e&&e.length>0?"recorded":(n??0)>0?"estimated":"none",S=(0,m.useMemo)(()=>e?.length?X$(e):[],[e]),C=(0,m.useMemo)(()=>{const I=new Map;for(const ee of t??[]){const le=I.get(ee.toolCallId);le?le.push(ee):I.set(ee.toolCallId,[ee])}for(const ee of I.values())ee.sort((le,ke)=>le.stepIndex-ke.stepIndex);return I},[t]),T=e?.length?e.reduce((I,ee)=>Math.max(I,ee.endMs),1):Math.max(n??0,1),k=(0,m.useMemo)(()=>e?.map(I=>`${I.id}:${I.startMs}:${I.endMs}`).join("|")??w,[w,e]),[A,M]=(0,m.useState)(1);(0,m.useEffect)(()=>{v===void 0&&M(T)},[T,k,v]);const E=Math.max(1,v!==void 0?v:A),O=Math.max(1,Math.round(T/50)),R=(0,m.useMemo)(()=>u3({traceStartedAtMs:s,traceEndedAtMs:o,traceDurationMs:T}),[T,o,s]),[L,N]=(0,m.useState)("all"),P=c!==void 0?c:L,j=u??N,[V,W]=(0,m.useState)(new Set),[B,D]=(0,m.useState)(new Set),te=h!==void 0?h:V,re=f??W,_=d!==void 0?d:B,U=p??D,[K,G]=(0,m.useState)(null),[$,J]=(0,m.useState)(null),[ae,ue]=(0,m.useState)(null),se=(0,m.useRef)(null),Xe=(0,m.useRef)(null),[Ie,tt]=(0,m.useState)(-1);(0,m.useLayoutEffect)(()=>{const I=Xe.current;if(!I)return;const ee=()=>{const ke=I.getBoundingClientRect().width;tt(Number.isFinite(ke)?ke:0)};if(ee(),typeof ResizeObserver>"u")return;const le=new ResizeObserver(ee);return le.observe(I),()=>le.disconnect()},[]);const We=(0,m.useMemo)(()=>j$(Ie),[Ie]),dt=(0,m.useMemo)(()=>We.length!==2?!1:Ie<0||Ie===0?!0:Ie<L$,[Ie,We]);(0,m.useEffect)(()=>{l||(W(new Set(S.map(I=>I.key))),D(Lv(S)))},[l,S]);const Ae=(0,m.useMemo)(()=>{if(w!=="recorded")return[];const I=[],ee=new Set;function le(ie){return P==="all"?!0:P==="error"?Pi(ie,i):ie.category===P}function ke(ie,xt,rt){const tn=ie.span.category==="step",bt=tn?rt:rt+1,nn=ie.children.map(wt=>ke(wt,xt,bt)),ls=nn.flatMap(wt=>wt.rows),cs=nn.some(wt=>wt.hasVisibleContent);if(tn)return{hasVisibleContent:cs||ie.children.length>0,rows:ls};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 Mn=ie.span.toolCallId,us=ie.span.category==="tool"&&!!Mn&&!ee.has(Mn);us&&Mn&&ee.add(Mn);const Vo=us&&Mn?(C.get(Mn)??[]).filter(wt=>P==="all"||P==="tool"?!0:P==="error"?Nl(wt)==="error":!1).map((wt,Tc)=>({kind:"interaction",key:`interaction-${ie.span.id}-${wt.stepIndex}-${Tc}`,promptIndex:xt,depth:rt+1,step:wt,startMs:ie.span.startMs,endMs:ie.span.endMs,status:Nl(wt)})):[];if(!(le(ie.span)||cs||Vo.length>0))return{hasVisibleContent:cs,rows:ls};const hs={kind:"span",key:ie.span.id,promptIndex:xt,depth:rt,span:ie.span,hasChildren:ie.children.length>0,isExpanded:_.has(ie.span.id)};return{hasVisibleContent:!0,rows:[hs,...hs.hasChildren&&hs.isExpanded?ls:[],...Vo]}}for(const ie of S){const xt=ie.roots.map(nn=>ke(nn,ie.promptIndex,0)).flatMap(nn=>nn.rows);if(!(xt.length>0||P==="all"&&ie.spans.length>0))continue;const rt=ie.spans.some(nn=>Pi(nn,i)),tn=n3(i,ie.messageStartIndex,ie.messageEndIndex),bt=B$(ie.spans);I.push({kind:"prompt",key:ie.key,promptIndex:ie.promptIndex,label:ie.label,conversationLabel:tn?`User: "${tn}"`:void 0,startMs:ie.startMs,endMs:ie.endMs,messageStartIndex:ie.messageStartIndex,messageEndIndex:ie.messageEndIndex,counts:ie.counts,hasAnyFailure:rt,isExpanded:te.has(ie.key),aggregatedInputTokens:bt.inputTokens,aggregatedOutputTokens:bt.outputTokens,aggregatedTotalTokens:bt.totalTokens}),te.has(ie.key)&&I.push(...xt)}return I},[te,_,P,S,C,w,i]),nt=(0,m.useMemo)(()=>Lv(S),[S]),Tr=(0,m.useMemo)(()=>{if(S.length===0)return!1;for(const I of S)if(!te.has(I.key))return!1;for(const I of nt)if(!_.has(I))return!1;return!0},[S,te,_,nt]);(0,m.useEffect)(()=>{if(Ae.length===0){G(null);return}(!K||!Ae.some(I=>I.key===K))&&G(Ae[0].key)},[Ae,K]);const as=Ae.find(I=>I.key===K),pe=$?Ae.find(I=>I.key===$):void 0,Y=$?Ae.findIndex(I=>I.key===$):-1;(0,m.useEffect)(()=>{$&&!Ae.some(I=>I.key===$)&&(J(null),ue(null),se.current=null)},[$,Ae]);const ve=(0,m.useCallback)(I=>{const ee=(I.querySelector('[data-testid="trace-row-glyph"]')??I).getBoundingClientRect();return{anchorX:ee.left+ee.width/2,anchorY:ee.top,anchorBottom:ee.bottom}},[]);(0,m.useEffect)(()=>{if(!$)return;const I=()=>{const ee=se.current;ee&&ue(ve(ee))};return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[$,ve]);const De=(0,m.useMemo)(()=>{if(!pe)return null;const{startMs:I,endMs:ee}=Jf(pe),le=pe.kind==="span"&&Pi(pe.span,i),ke=pe.kind==="span"?Yf(pe,i):null,ie=pe.kind==="prompt"?pe.conversationLabel??pe.label:pe.kind==="interaction"?Ji(pe.step):ke.title,xt=c3(pe,e),rt=pe.kind==="prompt"?"prompt":pe.kind==="interaction"?"interaction":pe.span.category==="tool"&&le?"error":pe.span.category;return{label:ie,spanShowsFailure:le,tokenStats:xt,rowStartTimestamp:R!==null?R+I:null,rowEndTimestamp:R!==null?R+ee:null,glyphCategory:rt}},[pe,e,R,i]),Bo=(0,m.useCallback)(I=>{if(Ae.length===0)return;const ee=Ae.findIndex(le=>le.key===K);if(I.key==="ArrowDown"){I.preventDefault();const le=ee<0?0:Math.min(Ae.length-1,ee+1);G(Ae[le].key);return}if(I.key==="ArrowUp"){I.preventDefault();const le=ee<=0?0:ee-1;G(Ae[le].key);return}if(I.key==="Enter"&&ee>=0){const le=Ae[ee];if(le.kind==="prompt"){I.preventDefault();const ke=new Set(te);ke.has(le.key)?ke.delete(le.key):ke.add(le.key),re(ke);return}if(le.kind==="span"&&le.hasChildren){I.preventDefault();const ke=new Set(_);ke.has(le.key)?ke.delete(le.key):ke.add(le.key),U(ke)}}},[te,_,Ae,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)(tS,{className:"border-warning/50 bg-warning/50 text-foreground",children:"Estimated total only"}),(0,g.jsx)("span",{className:"text-xs text-muted-foreground",children:Us(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 pt=v===void 0?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ot,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7 border-border/50",title:"Zoom in timeline","aria-label":"Zoom in timeline",disabled:A<=O,onClick:()=>M(I=>Math.max(O,Math.round(I*.8))),children:(0,g.jsx)(GP,{className:"size-3.5","aria-hidden":!0})}),(0,g.jsx)(Ot,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7 border-border/50",title:"Zoom out timeline","aria-label":"Zoom out timeline",disabled:A>=T*4,onClick:()=>M(I=>Math.min(T*4,Math.round(I*1.25))),children:(0,g.jsx)(qP,{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)(D$,{filter:P,onFilterChange:j,isFullyExpanded:Tr,expandDisabled:S.length===0,zoomControls:pt,onToggleExpandAll:()=>{Tr?(re(new Set),U(new Set)):(re(new Set(S.map(I=>I.key))),U(new Set(nt)))}}),(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:I,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)}),I]},I))})]}),(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)(f$,{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)(Xf,{defaultSize:65,minSize:0,className:"min-h-0 min-w-0 overflow-hidden",children:(0,g.jsx)(v$,{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:Bo,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(${Ae.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:Xe,className:"relative h-6 min-w-0",children:dt?(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:Dv(E),children:Dv(E)})}):We.map(I=>{const ee=I>=100?"100%":`${I}%`;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",_$(I)),children:Ja(E*I/100)})},I)})})})]})}),(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)(om,{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"})]})}),Ae.length>0?(0,g.jsx)("div",{className:"pointer-events-none relative z-0 bg-transparent",style:{gridColumn:2,gridRow:`2 / ${Ae.length+2}`},children:We.map(I=>(0,g.jsx)("div",{className:"absolute top-0 bottom-0 w-px bg-border/40",style:{left:I>=100?"100%":`${I}%`}},I))}):null,Ae.map((I,ee)=>{const le=I.key===K,{startMs:ke,endMs:ie,durationMs:xt}=Jf(I),rt=ke/E*100,tn=Math.max((ie-ke)/E*100,.45),bt=I.kind==="span"&&Pi(I.span,i),nn=I.kind==="prompt"?"prompt":I.kind==="interaction"?"interaction":I.span.category==="tool"&&bt?"error":I.span.category,ls=I.kind==="interaction"&&I.status==="error",cs=I.kind==="span"?Yf(I,i):null,Mn=I.kind==="prompt"?I.conversationLabel??I.label:I.kind==="interaction"?Ji(I.step):cs.title,us=Us(xt),Vo=I.kind==="prompt"?!0:I.kind==="interaction"?!1:I.hasChildren||I.span.category==="llm",hs=ee+2,wt=Q$(I,bt),Tc=K$(I,bt),Dp=()=>{kP("trace_span_clicked",{location:"trace_timeline",span_kind:I.kind}),G(I.key)},Ac=St=>{St.stopPropagation(),Dp()},jC=le?X("bg-transparent",wt):"border-l-transparent bg-background group-hover:bg-muted/20 hover:bg-muted/20",Np=le?"bg-transparent":"bg-background group-hover:bg-muted/20 hover:bg-muted/20";return(0,g.jsxs)(Ww.div,{"data-testid":"trace-row","data-state":le?"selected":void 0,onClick:Dp,onMouseEnter:St=>{J(I.key);const kt=St.currentTarget;se.current=kt,ue(ve(kt))},onMouseLeave:()=>{J(St=>St===I.key?null:St),ue(null),se.current=null},onFocus:St=>{J(I.key);const kt=St.currentTarget;se.current=kt,ue(ve(kt))},onBlur:St=>{St.currentTarget.contains(St.relatedTarget)||(J(kt=>kt===I.key?null:kt),ue(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:hs,display:"grid",gridTemplateColumns:"subgrid"},className:X("group min-h-0 min-w-0 cursor-pointer items-stretch",le&&"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",jC),children:[(0,g.jsx)("div",{className:"flex shrink-0 items-center",style:{paddingLeft:I.kind==="prompt"?0:I.depth*16},children:Vo?(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:St=>{if(St.stopPropagation(),I.kind==="prompt"){const Fo=new Set(te);Fo.has(I.key)?Fo.delete(I.key):Fo.add(I.key),re(Fo);return}const kt=new Set(_);kt.has(I.key)?kt.delete(I.key):kt.add(I.key),U(kt)},"aria-label":I.kind==="prompt"?`${I.isExpanded?"Collapse":"Expand"} ${I.label}`:`${"isExpanded"in I&&I.isExpanded?"Collapse":"Expand"} ${Mn}`,children:"isExpanded"in I&&I.isExpanded?(0,g.jsx)(jx,{className:"h-3.5 w-3.5"}):(0,g.jsx)(Wi,{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:Ac,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:I.kind==="prompt"?(0,g.jsx)(Zi,{category:"prompt"}):(0,g.jsx)(Zi,{category:nn})}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:Mn}),I.kind==="prompt"&&I.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,I.kind==="span"&&bt||ls?(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":le?"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",Np),"aria-label":`Select on timeline (${Us(xt)})`,onClick:Ac,children:(0,g.jsx)("div",{"data-testid":I.kind==="span"&&bt?"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",Tc),style:{left:`${rt}%`,width:`max(${tn}%, 3px)`}})}),(0,g.jsxs)("button",{type:"button","data-testid":"trace-row-duration-hit","data-state":le?"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",Np),"aria-label":`Select row duration (${us})`,onClick:Ac,children:[(0,g.jsx)(om,{className:"size-3 shrink-0 opacity-80","aria-hidden":!0}),us]})]},I.key)})]})})})}),(0,g.jsx)(d$,{withHandle:!0}),(0,g.jsx)(Xf,{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)(p3,{row:as,transcriptMessages:i,onRevealInTranscript:a,turnRuntimeByPromptIndex:y})})})]})}),pe&&De&&ae?(0,g.jsx)(m3,{hoverPos:ae,info:De,placement:Y===0?"bottom":"top",reduceMotion:b??!1,rowKey:pe.key}):null]})}function m3({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,ko.createPortal)((0,g.jsx)("div",{className:"pointer-events-none",style:d,children:(0,g.jsx)(Ww.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)(Zi,{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:_v(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:_v(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:zu(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:zu(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:zu(t.tokenStats.totalTokens)})]})]})]})]})},i)}),document.body)}export{ej as $,dy as $t,Lj as A,Ii as At,D3 as B,Ql as Bt,N5 as C,HP as Ct,m5 as D,FP as Dt,y5 as E,zP as Et,tS as F,jx as Ft,_3 as G,Fy as Gt,uj as H,sR as Ht,Jw as I,$i as It,Nh as J,$l as Jt,j3 as K,zy as Kt,I3 as L,NP as Lt,Nr as M,jP as Mt,fj as N,LP as Nt,u5 as O,VP as Ot,Dr as P,Wi as Pt,O3 as Q,sd as Qt,eS as R,xe as Rt,G3 as S,qP as St,Jk as T,$P as Tt,N3 as U,iR as Ut,cj as V,gx as Vt,L3 as W,Ky as Wt,E3 as X,SA as Xt,oj as Y,ky as Yt,R3 as Z,wy as Zt,f$ as _,Xl as _t,D$ as a,Kr as an,Ww as at,K3 as b,KP as bt,Y3 as c,Rt as cn,dD as ct,v$ as d,Yn as dn,lm as dt,IT as en,P3 as et,y$ as f,nT as fn,tO as ft,Xf as g,JP as gt,d$ as h,ZP as ht,j$ as i,Ll as in,YN as it,Ir as j,om as jt,Fj as k,BP as kt,X3 as l,ne as ln,we as lt,xs as m,eO as mt,X$ as n,ET as nn,ht as nt,R$ as o,An as on,W2 as ot,Q3 as p,Ne as pn,lb as pt,Zw as q,fd as qt,Lv as r,Ge as rn,np as rt,O$ as s,To as sn,Ow as st,Z3 as t,iy as tn,tj as tt,PC as u,ed as un,Ad as ut,lC as v,YP as vt,U3 as w,WP as wt,P5 as x,UP as xt,Mp as y,GP as yt,lj as z,kP as zt};
70
+
71
+ //# sourceMappingURL=trace-timeline-PnE1ouRj.js.map