@get-enlace/ui 0.0.3 → 0.0.5

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.
@@ -0,0 +1,65 @@
1
+ var cC=Object.defineProperty;var hC=(t,e,n)=>e in t?cC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Km=(t,e,n)=>hC(t,typeof e!="symbol"?e+"":e,n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();function Sv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var kv={exports:{}},lc={},bv={exports:{}},se={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Al=Symbol.for("react.element"),fC=Symbol.for("react.portal"),dC=Symbol.for("react.fragment"),pC=Symbol.for("react.strict_mode"),mC=Symbol.for("react.profiler"),gC=Symbol.for("react.provider"),yC=Symbol.for("react.context"),vC=Symbol.for("react.forward_ref"),wC=Symbol.for("react.suspense"),xC=Symbol.for("react.memo"),SC=Symbol.for("react.lazy"),qm=Symbol.iterator;function kC(t){return t===null||typeof t!="object"?null:(t=qm&&t[qm]||t["@@iterator"],typeof t=="function"?t:null)}var Cv={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ev=Object.assign,Nv={};function Us(t,e,n){this.props=t,this.context=e,this.refs=Nv,this.updater=n||Cv}Us.prototype.isReactComponent={};Us.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Us.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function _v(){}_v.prototype=Us.prototype;function Jd(t,e,n){this.props=t,this.context=e,this.refs=Nv,this.updater=n||Cv}var Zd=Jd.prototype=new _v;Zd.constructor=Jd;Ev(Zd,Us.prototype);Zd.isPureReactComponent=!0;var Ym=Array.isArray,Av=Object.prototype.hasOwnProperty,ep={current:null},Tv={key:!0,ref:!0,__self:!0,__source:!0};function Mv(t,e,n){var i,r={},s=null,o=null;if(e!=null)for(i in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)Av.call(e,i)&&!Tv.hasOwnProperty(i)&&(r[i]=e[i]);var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){for(var a=Array(l),u=0;u<l;u++)a[u]=arguments[u+2];r.children=a}if(t&&t.defaultProps)for(i in l=t.defaultProps,l)r[i]===void 0&&(r[i]=l[i]);return{$$typeof:Al,type:t,key:s,ref:o,props:r,_owner:ep.current}}function bC(t,e){return{$$typeof:Al,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function tp(t){return typeof t=="object"&&t!==null&&t.$$typeof===Al}function CC(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return e[n]})}var Qm=/\/+/g;function Kc(t,e){return typeof t=="object"&&t!==null&&t.key!=null?CC(""+t.key):e.toString(36)}function Da(t,e,n,i,r){var s=typeof t;(s==="undefined"||s==="boolean")&&(t=null);var o=!1;if(t===null)o=!0;else switch(s){case"string":case"number":o=!0;break;case"object":switch(t.$$typeof){case Al:case fC:o=!0}}if(o)return o=t,r=r(o),t=i===""?"."+Kc(o,0):i,Ym(r)?(n="",t!=null&&(n=t.replace(Qm,"$&/")+"/"),Da(r,e,n,"",function(u){return u})):r!=null&&(tp(r)&&(r=bC(r,n+(!r.key||o&&o.key===r.key?"":(""+r.key).replace(Qm,"$&/")+"/")+t)),e.push(r)),1;if(o=0,i=i===""?".":i+":",Ym(t))for(var l=0;l<t.length;l++){s=t[l];var a=i+Kc(s,l);o+=Da(s,e,n,a,r)}else if(a=kC(t),typeof a=="function")for(t=a.call(t),l=0;!(s=t.next()).done;)s=s.value,a=i+Kc(s,l++),o+=Da(s,e,n,a,r);else if(s==="object")throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return o}function Hl(t,e,n){if(t==null)return t;var i=[],r=0;return Da(t,i,"","",function(s){return e.call(n,s,r++)}),i}function EC(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(n){(t._status===0||t._status===-1)&&(t._status=1,t._result=n)},function(n){(t._status===0||t._status===-1)&&(t._status=2,t._result=n)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var ht={current:null},Ba={transition:null},NC={ReactCurrentDispatcher:ht,ReactCurrentBatchConfig:Ba,ReactCurrentOwner:ep};function Ov(){throw Error("act(...) is not supported in production builds of React.")}se.Children={map:Hl,forEach:function(t,e,n){Hl(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Hl(t,function(){e++}),e},toArray:function(t){return Hl(t,function(e){return e})||[]},only:function(t){if(!tp(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};se.Component=Us;se.Fragment=dC;se.Profiler=mC;se.PureComponent=Jd;se.StrictMode=pC;se.Suspense=wC;se.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=NC;se.act=Ov;se.cloneElement=function(t,e,n){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var i=Ev({},t.props),r=t.key,s=t.ref,o=t._owner;if(e!=null){if(e.ref!==void 0&&(s=e.ref,o=ep.current),e.key!==void 0&&(r=""+e.key),t.type&&t.type.defaultProps)var l=t.type.defaultProps;for(a in e)Av.call(e,a)&&!Tv.hasOwnProperty(a)&&(i[a]=e[a]===void 0&&l!==void 0?l[a]:e[a])}var a=arguments.length-2;if(a===1)i.children=n;else if(1<a){l=Array(a);for(var u=0;u<a;u++)l[u]=arguments[u+2];i.children=l}return{$$typeof:Al,type:t.type,key:r,ref:s,props:i,_owner:o}};se.createContext=function(t){return t={$$typeof:yC,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:gC,_context:t},t.Consumer=t};se.createElement=Mv;se.createFactory=function(t){var e=Mv.bind(null,t);return e.type=t,e};se.createRef=function(){return{current:null}};se.forwardRef=function(t){return{$$typeof:vC,render:t}};se.isValidElement=tp;se.lazy=function(t){return{$$typeof:SC,_payload:{_status:-1,_result:t},_init:EC}};se.memo=function(t,e){return{$$typeof:xC,type:t,compare:e===void 0?null:e}};se.startTransition=function(t){var e=Ba.transition;Ba.transition={};try{t()}finally{Ba.transition=e}};se.unstable_act=Ov;se.useCallback=function(t,e){return ht.current.useCallback(t,e)};se.useContext=function(t){return ht.current.useContext(t)};se.useDebugValue=function(){};se.useDeferredValue=function(t){return ht.current.useDeferredValue(t)};se.useEffect=function(t,e){return ht.current.useEffect(t,e)};se.useId=function(){return ht.current.useId()};se.useImperativeHandle=function(t,e,n){return ht.current.useImperativeHandle(t,e,n)};se.useInsertionEffect=function(t,e){return ht.current.useInsertionEffect(t,e)};se.useLayoutEffect=function(t,e){return ht.current.useLayoutEffect(t,e)};se.useMemo=function(t,e){return ht.current.useMemo(t,e)};se.useReducer=function(t,e,n){return ht.current.useReducer(t,e,n)};se.useRef=function(t){return ht.current.useRef(t)};se.useState=function(t){return ht.current.useState(t)};se.useSyncExternalStore=function(t,e,n){return ht.current.useSyncExternalStore(t,e,n)};se.useTransition=function(){return ht.current.useTransition()};se.version="18.3.1";bv.exports=se;var O=bv.exports;const j=Sv(O);/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var _C=O,AC=Symbol.for("react.element"),TC=Symbol.for("react.fragment"),MC=Object.prototype.hasOwnProperty,OC=_C.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,PC={key:!0,ref:!0,__self:!0,__source:!0};function Pv(t,e,n){var i,r={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(i in e)MC.call(e,i)&&!PC.hasOwnProperty(i)&&(r[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)r[i]===void 0&&(r[i]=e[i]);return{$$typeof:AC,type:t,key:s,ref:o,props:r,_owner:OC.current}}lc.Fragment=TC;lc.jsx=Pv;lc.jsxs=Pv;kv.exports=lc;var k=kv.exports,Gh={},Rv={exports:{}},It={},Iv={exports:{}},Dv={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */(function(t){function e(R,A){var D=R.length;R.push(A);e:for(;0<D;){var I=D-1>>>1,$=R[I];if(0<r($,A))R[I]=A,R[D]=$,D=I;else break e}}function n(R){return R.length===0?null:R[0]}function i(R){if(R.length===0)return null;var A=R[0],D=R.pop();if(D!==A){R[0]=D;e:for(var I=0,$=R.length,U=$>>>1;I<U;){var W=2*(I+1)-1,Q=R[W],te=W+1,ne=R[te];if(0>r(Q,D))te<$&&0>r(ne,Q)?(R[I]=ne,R[te]=D,I=te):(R[I]=Q,R[W]=D,I=W);else if(te<$&&0>r(ne,D))R[I]=ne,R[te]=D,I=te;else break e}}return A}function r(R,A){var D=R.sortIndex-A.sortIndex;return D!==0?D:R.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var a=[],u=[],c=1,h=null,f=3,d=!1,p=!1,g=!1,S=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(R){for(var A=n(u);A!==null;){if(A.callback===null)i(u);else if(A.startTime<=R)i(u),A.sortIndex=A.expirationTime,e(a,A);else break;A=n(u)}}function x(R){if(g=!1,v(R),!p)if(n(a)!==null)p=!0,T(b);else{var A=n(u);A!==null&&z(x,A.startTime-R)}}function b(R,A){p=!1,g&&(g=!1,m(M),M=-1),d=!0;var D=f;try{for(v(A),h=n(a);h!==null&&(!(h.expirationTime>A)||R&&!B());){var I=h.callback;if(typeof I=="function"){h.callback=null,f=h.priorityLevel;var $=I(h.expirationTime<=A);A=t.unstable_now(),typeof $=="function"?h.callback=$:h===n(a)&&i(a),v(A)}else i(a);h=n(a)}if(h!==null)var U=!0;else{var W=n(u);W!==null&&z(x,W.startTime-A),U=!1}return U}finally{h=null,f=D,d=!1}}var C=!1,N=null,M=-1,_=5,P=-1;function B(){return!(t.unstable_now()-P<_)}function L(){if(N!==null){var R=t.unstable_now();P=R;var A=!0;try{A=N(!0,R)}finally{A?F():(C=!1,N=null)}}else C=!1}var F;if(typeof y=="function")F=function(){y(L)};else if(typeof MessageChannel<"u"){var w=new MessageChannel,E=w.port2;w.port1.onmessage=L,F=function(){E.postMessage(null)}}else F=function(){S(L,0)};function T(R){N=R,C||(C=!0,F())}function z(R,A){M=S(function(){R(t.unstable_now())},A)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(R){R.callback=null},t.unstable_continueExecution=function(){p||d||(p=!0,T(b))},t.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<R?Math.floor(1e3/R):5},t.unstable_getCurrentPriorityLevel=function(){return f},t.unstable_getFirstCallbackNode=function(){return n(a)},t.unstable_next=function(R){switch(f){case 1:case 2:case 3:var A=3;break;default:A=f}var D=f;f=A;try{return R()}finally{f=D}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(R,A){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var D=f;f=R;try{return A()}finally{f=D}},t.unstable_scheduleCallback=function(R,A,D){var I=t.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?I+D:I):D=I,R){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=D+$,R={id:c++,callback:A,priorityLevel:R,startTime:D,expirationTime:$,sortIndex:-1},D>I?(R.sortIndex=D,e(u,R),n(a)===null&&R===n(u)&&(g?(m(M),M=-1):g=!0,z(x,D-I))):(R.sortIndex=$,e(a,R),p||d||(p=!0,T(b))),R},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(R){var A=f;return function(){var D=f;f=A;try{return R.apply(this,arguments)}finally{f=D}}}})(Dv);Iv.exports=Dv;var RC=Iv.exports;/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var IC=O,Pt=RC;function H(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n<arguments.length;n++)e+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Bv=new Set,Ko={};function Mr(t,e){Es(t,e),Es(t+"Capture",e)}function Es(t,e){for(Ko[t]=e,t=0;t<e.length;t++)Bv.add(e[t])}var ti=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Jh=Object.prototype.hasOwnProperty,DC=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Xm={},Gm={};function BC(t){return Jh.call(Gm,t)?!0:Jh.call(Xm,t)?!1:DC.test(t)?Gm[t]=!0:(Xm[t]=!0,!1)}function LC(t,e,n,i){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return i?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function zC(t,e,n,i){if(e===null||typeof e>"u"||LC(t,e,n,i))return!0;if(i)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ft(t,e,n,i,r,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=i,this.attributeNamespace=r,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Xe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Xe[t]=new ft(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Xe[e]=new ft(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Xe[t]=new ft(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Xe[t]=new ft(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Xe[t]=new ft(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Xe[t]=new ft(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Xe[t]=new ft(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Xe[t]=new ft(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Xe[t]=new ft(t,5,!1,t.toLowerCase(),null,!1,!1)});var np=/[\-:]([a-z])/g;function ip(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(np,ip);Xe[e]=new ft(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(np,ip);Xe[e]=new ft(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(np,ip);Xe[e]=new ft(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Xe[t]=new ft(t,1,!1,t.toLowerCase(),null,!1,!1)});Xe.xlinkHref=new ft("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Xe[t]=new ft(t,1,!1,t.toLowerCase(),null,!0,!0)});function rp(t,e,n,i){var r=Xe.hasOwnProperty(e)?Xe[e]:null;(r!==null?r.type!==0:i||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(zC(e,n,r,i)&&(n=null),i||r===null?BC(e)&&(n===null?t.removeAttribute(e):t.setAttribute(e,""+n)):r.mustUseProperty?t[r.propertyName]=n===null?r.type===3?!1:"":n:(e=r.attributeName,i=r.attributeNamespace,n===null?t.removeAttribute(e):(r=r.type,n=r===3||r===4&&n===!0?"":""+n,i?t.setAttributeNS(i,e,n):t.setAttribute(e,n))))}var ai=IC.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Wl=Symbol.for("react.element"),Ur=Symbol.for("react.portal"),Kr=Symbol.for("react.fragment"),sp=Symbol.for("react.strict_mode"),Zh=Symbol.for("react.profiler"),Lv=Symbol.for("react.provider"),zv=Symbol.for("react.context"),op=Symbol.for("react.forward_ref"),ef=Symbol.for("react.suspense"),tf=Symbol.for("react.suspense_list"),lp=Symbol.for("react.memo"),fi=Symbol.for("react.lazy"),$v=Symbol.for("react.offscreen"),Jm=Symbol.iterator;function eo(t){return t===null||typeof t!="object"?null:(t=Jm&&t[Jm]||t["@@iterator"],typeof t=="function"?t:null)}var Ce=Object.assign,qc;function xo(t){if(qc===void 0)try{throw Error()}catch(n){var e=n.stack.trim().match(/\n( *(at )?)/);qc=e&&e[1]||""}return`
34
+ `+qc+t}var Yc=!1;function Qc(t,e){if(!t||Yc)return"";Yc=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(u){var i=u}Reflect.construct(t,[],e)}else{try{e.call()}catch(u){i=u}t.call(e.prototype)}else{try{throw Error()}catch(u){i=u}t()}}catch(u){if(u&&i&&typeof u.stack=="string"){for(var r=u.stack.split(`
35
+ `),s=i.stack.split(`
36
+ `),o=r.length-1,l=s.length-1;1<=o&&0<=l&&r[o]!==s[l];)l--;for(;1<=o&&0<=l;o--,l--)if(r[o]!==s[l]){if(o!==1||l!==1)do if(o--,l--,0>l||r[o]!==s[l]){var a=`
37
+ `+r[o].replace(" at new "," at ");return t.displayName&&a.includes("<anonymous>")&&(a=a.replace("<anonymous>",t.displayName)),a}while(1<=o&&0<=l);break}}}finally{Yc=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?xo(t):""}function $C(t){switch(t.tag){case 5:return xo(t.type);case 16:return xo("Lazy");case 13:return xo("Suspense");case 19:return xo("SuspenseList");case 0:case 2:case 15:return t=Qc(t.type,!1),t;case 11:return t=Qc(t.type.render,!1),t;case 1:return t=Qc(t.type,!0),t;default:return""}}function nf(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Kr:return"Fragment";case Ur:return"Portal";case Zh:return"Profiler";case sp:return"StrictMode";case ef:return"Suspense";case tf:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case zv:return(t.displayName||"Context")+".Consumer";case Lv:return(t._context.displayName||"Context")+".Provider";case op:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case lp:return e=t.displayName||null,e!==null?e:nf(t.type)||"Memo";case fi:e=t._payload,t=t._init;try{return nf(t(e))}catch{}}return null}function jC(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return nf(e);case 8:return e===sp?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Li(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function jv(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function FC(t){var e=jv(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),i=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var r=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return r.call(this)},set:function(o){i=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return i},setValue:function(o){i=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Ul(t){t._valueTracker||(t._valueTracker=FC(t))}function Fv(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),i="";return t&&(i=jv(t)?t.checked?"true":"false":t.value),t=i,t!==n?(e.setValue(t),!0):!1}function ru(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function rf(t,e){var n=e.checked;return Ce({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Zm(t,e){var n=e.defaultValue==null?"":e.defaultValue,i=e.checked!=null?e.checked:e.defaultChecked;n=Li(e.value!=null?e.value:n),t._wrapperState={initialChecked:i,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Vv(t,e){e=e.checked,e!=null&&rp(t,"checked",e,!1)}function sf(t,e){Vv(t,e);var n=Li(e.value),i=e.type;if(n!=null)i==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(i==="submit"||i==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?of(t,e.type,n):e.hasOwnProperty("defaultValue")&&of(t,e.type,Li(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function eg(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var i=e.type;if(!(i!=="submit"&&i!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function of(t,e,n){(e!=="number"||ru(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var So=Array.isArray;function as(t,e,n,i){if(t=t.options,e){e={};for(var r=0;r<n.length;r++)e["$"+n[r]]=!0;for(n=0;n<t.length;n++)r=e.hasOwnProperty("$"+t[n].value),t[n].selected!==r&&(t[n].selected=r),r&&i&&(t[n].defaultSelected=!0)}else{for(n=""+Li(n),e=null,r=0;r<t.length;r++){if(t[r].value===n){t[r].selected=!0,i&&(t[r].defaultSelected=!0);return}e!==null||t[r].disabled||(e=t[r])}e!==null&&(e.selected=!0)}}function lf(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(H(91));return Ce({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function tg(t,e){var n=e.value;if(n==null){if(n=e.children,e=e.defaultValue,n!=null){if(e!=null)throw Error(H(92));if(So(n)){if(1<n.length)throw Error(H(93));n=n[0]}e=n}e==null&&(e=""),n=e}t._wrapperState={initialValue:Li(n)}}function Hv(t,e){var n=Li(e.value),i=Li(e.defaultValue);n!=null&&(n=""+n,n!==t.value&&(t.value=n),e.defaultValue==null&&t.defaultValue!==n&&(t.defaultValue=n)),i!=null&&(t.defaultValue=""+i)}function ng(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function Wv(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function af(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?Wv(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Kl,Uv=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,i,r){MSApp.execUnsafeLocalFunction(function(){return t(e,n,i,r)})}:t}(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Kl=Kl||document.createElement("div"),Kl.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=Kl.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function qo(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Oo={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},VC=["Webkit","ms","Moz","O"];Object.keys(Oo).forEach(function(t){VC.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Oo[e]=Oo[t]})});function Kv(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Oo.hasOwnProperty(t)&&Oo[t]?(""+e).trim():e+"px"}function qv(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var i=n.indexOf("--")===0,r=Kv(n,e[n],i);n==="float"&&(n="cssFloat"),i?t.setProperty(n,r):t[n]=r}}var HC=Ce({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function uf(t,e){if(e){if(HC[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(H(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(H(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(H(61))}if(e.style!=null&&typeof e.style!="object")throw Error(H(62))}}function cf(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var hf=null;function ap(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var ff=null,us=null,cs=null;function ig(t){if(t=Ol(t)){if(typeof ff!="function")throw Error(H(280));var e=t.stateNode;e&&(e=fc(e),ff(t.stateNode,t.type,e))}}function Yv(t){us?cs?cs.push(t):cs=[t]:us=t}function Qv(){if(us){var t=us,e=cs;if(cs=us=null,ig(t),e)for(t=0;t<e.length;t++)ig(e[t])}}function Xv(t,e){return t(e)}function Gv(){}var Xc=!1;function Jv(t,e,n){if(Xc)return t(e,n);Xc=!0;try{return Xv(t,e,n)}finally{Xc=!1,(us!==null||cs!==null)&&(Gv(),Qv())}}function Yo(t,e){var n=t.stateNode;if(n===null)return null;var i=fc(n);if(i===null)return null;n=i[e];e:switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(t=t.type,i=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!i;break e;default:t=!1}if(t)return null;if(n&&typeof n!="function")throw Error(H(231,e,typeof n));return n}var df=!1;if(ti)try{var to={};Object.defineProperty(to,"passive",{get:function(){df=!0}}),window.addEventListener("test",to,to),window.removeEventListener("test",to,to)}catch{df=!1}function WC(t,e,n,i,r,s,o,l,a){var u=Array.prototype.slice.call(arguments,3);try{e.apply(n,u)}catch(c){this.onError(c)}}var Po=!1,su=null,ou=!1,pf=null,UC={onError:function(t){Po=!0,su=t}};function KC(t,e,n,i,r,s,o,l,a){Po=!1,su=null,WC.apply(UC,arguments)}function qC(t,e,n,i,r,s,o,l,a){if(KC.apply(this,arguments),Po){if(Po){var u=su;Po=!1,su=null}else throw Error(H(198));ou||(ou=!0,pf=u)}}function Or(t){var e=t,n=t;if(t.alternate)for(;e.return;)e=e.return;else{t=e;do e=t,e.flags&4098&&(n=e.return),t=e.return;while(t)}return e.tag===3?n:null}function Zv(t){if(t.tag===13){var e=t.memoizedState;if(e===null&&(t=t.alternate,t!==null&&(e=t.memoizedState)),e!==null)return e.dehydrated}return null}function rg(t){if(Or(t)!==t)throw Error(H(188))}function YC(t){var e=t.alternate;if(!e){if(e=Or(t),e===null)throw Error(H(188));return e!==t?null:t}for(var n=t,i=e;;){var r=n.return;if(r===null)break;var s=r.alternate;if(s===null){if(i=r.return,i!==null){n=i;continue}break}if(r.child===s.child){for(s=r.child;s;){if(s===n)return rg(r),t;if(s===i)return rg(r),e;s=s.sibling}throw Error(H(188))}if(n.return!==i.return)n=r,i=s;else{for(var o=!1,l=r.child;l;){if(l===n){o=!0,n=r,i=s;break}if(l===i){o=!0,i=r,n=s;break}l=l.sibling}if(!o){for(l=s.child;l;){if(l===n){o=!0,n=s,i=r;break}if(l===i){o=!0,i=s,n=r;break}l=l.sibling}if(!o)throw Error(H(189))}}if(n.alternate!==i)throw Error(H(190))}if(n.tag!==3)throw Error(H(188));return n.stateNode.current===n?t:e}function e1(t){return t=YC(t),t!==null?t1(t):null}function t1(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=t1(t);if(e!==null)return e;t=t.sibling}return null}var n1=Pt.unstable_scheduleCallback,sg=Pt.unstable_cancelCallback,QC=Pt.unstable_shouldYield,XC=Pt.unstable_requestPaint,Re=Pt.unstable_now,GC=Pt.unstable_getCurrentPriorityLevel,up=Pt.unstable_ImmediatePriority,i1=Pt.unstable_UserBlockingPriority,lu=Pt.unstable_NormalPriority,JC=Pt.unstable_LowPriority,r1=Pt.unstable_IdlePriority,ac=null,Dn=null;function ZC(t){if(Dn&&typeof Dn.onCommitFiberRoot=="function")try{Dn.onCommitFiberRoot(ac,t,void 0,(t.current.flags&128)===128)}catch{}}var fn=Math.clz32?Math.clz32:n2,e2=Math.log,t2=Math.LN2;function n2(t){return t>>>=0,t===0?32:31-(e2(t)/t2|0)|0}var ql=64,Yl=4194304;function ko(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function au(t,e){var n=t.pendingLanes;if(n===0)return 0;var i=0,r=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var l=o&~r;l!==0?i=ko(l):(s&=o,s!==0&&(i=ko(s)))}else o=n&~r,o!==0?i=ko(o):s!==0&&(i=ko(s));if(i===0)return 0;if(e!==0&&e!==i&&!(e&r)&&(r=i&-i,s=e&-e,r>=s||r===16&&(s&4194240)!==0))return e;if(i&4&&(i|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=i;0<e;)n=31-fn(e),r=1<<n,i|=t[n],e&=~r;return i}function i2(t,e){switch(t){case 1:case 2:case 4:return e+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function r2(t,e){for(var n=t.suspendedLanes,i=t.pingedLanes,r=t.expirationTimes,s=t.pendingLanes;0<s;){var o=31-fn(s),l=1<<o,a=r[o];a===-1?(!(l&n)||l&i)&&(r[o]=i2(l,e)):a<=e&&(t.expiredLanes|=l),s&=~l}}function mf(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function s1(){var t=ql;return ql<<=1,!(ql&4194240)&&(ql=64),t}function Gc(t){for(var e=[],n=0;31>n;n++)e.push(t);return e}function Tl(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-fn(e),t[e]=n}function s2(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var i=t.eventTimes;for(t=t.expirationTimes;0<n;){var r=31-fn(n),s=1<<r;e[r]=0,i[r]=-1,t[r]=-1,n&=~s}}function cp(t,e){var n=t.entangledLanes|=e;for(t=t.entanglements;n;){var i=31-fn(n),r=1<<i;r&e|t[i]&e&&(t[i]|=e),n&=~r}}var ce=0;function o1(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var l1,hp,a1,u1,c1,gf=!1,Ql=[],_i=null,Ai=null,Ti=null,Qo=new Map,Xo=new Map,vi=[],o2="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function og(t,e){switch(t){case"focusin":case"focusout":_i=null;break;case"dragenter":case"dragleave":Ai=null;break;case"mouseover":case"mouseout":Ti=null;break;case"pointerover":case"pointerout":Qo.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":Xo.delete(e.pointerId)}}function no(t,e,n,i,r,s){return t===null||t.nativeEvent!==s?(t={blockedOn:e,domEventName:n,eventSystemFlags:i,nativeEvent:s,targetContainers:[r]},e!==null&&(e=Ol(e),e!==null&&hp(e)),t):(t.eventSystemFlags|=i,e=t.targetContainers,r!==null&&e.indexOf(r)===-1&&e.push(r),t)}function l2(t,e,n,i,r){switch(e){case"focusin":return _i=no(_i,t,e,n,i,r),!0;case"dragenter":return Ai=no(Ai,t,e,n,i,r),!0;case"mouseover":return Ti=no(Ti,t,e,n,i,r),!0;case"pointerover":var s=r.pointerId;return Qo.set(s,no(Qo.get(s)||null,t,e,n,i,r)),!0;case"gotpointercapture":return s=r.pointerId,Xo.set(s,no(Xo.get(s)||null,t,e,n,i,r)),!0}return!1}function h1(t){var e=ar(t.target);if(e!==null){var n=Or(e);if(n!==null){if(e=n.tag,e===13){if(e=Zv(n),e!==null){t.blockedOn=e,c1(t.priority,function(){a1(n)});return}}else if(e===3&&n.stateNode.current.memoizedState.isDehydrated){t.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}t.blockedOn=null}function La(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var n=yf(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(n===null){n=t.nativeEvent;var i=new n.constructor(n.type,n);hf=i,n.target.dispatchEvent(i),hf=null}else return e=Ol(n),e!==null&&hp(e),t.blockedOn=n,!1;e.shift()}return!0}function lg(t,e,n){La(t)&&n.delete(e)}function a2(){gf=!1,_i!==null&&La(_i)&&(_i=null),Ai!==null&&La(Ai)&&(Ai=null),Ti!==null&&La(Ti)&&(Ti=null),Qo.forEach(lg),Xo.forEach(lg)}function io(t,e){t.blockedOn===e&&(t.blockedOn=null,gf||(gf=!0,Pt.unstable_scheduleCallback(Pt.unstable_NormalPriority,a2)))}function Go(t){function e(r){return io(r,t)}if(0<Ql.length){io(Ql[0],t);for(var n=1;n<Ql.length;n++){var i=Ql[n];i.blockedOn===t&&(i.blockedOn=null)}}for(_i!==null&&io(_i,t),Ai!==null&&io(Ai,t),Ti!==null&&io(Ti,t),Qo.forEach(e),Xo.forEach(e),n=0;n<vi.length;n++)i=vi[n],i.blockedOn===t&&(i.blockedOn=null);for(;0<vi.length&&(n=vi[0],n.blockedOn===null);)h1(n),n.blockedOn===null&&vi.shift()}var hs=ai.ReactCurrentBatchConfig,uu=!0;function u2(t,e,n,i){var r=ce,s=hs.transition;hs.transition=null;try{ce=1,fp(t,e,n,i)}finally{ce=r,hs.transition=s}}function c2(t,e,n,i){var r=ce,s=hs.transition;hs.transition=null;try{ce=4,fp(t,e,n,i)}finally{ce=r,hs.transition=s}}function fp(t,e,n,i){if(uu){var r=yf(t,e,n,i);if(r===null)lh(t,e,i,cu,n),og(t,i);else if(l2(r,t,e,n,i))i.stopPropagation();else if(og(t,i),e&4&&-1<o2.indexOf(t)){for(;r!==null;){var s=Ol(r);if(s!==null&&l1(s),s=yf(t,e,n,i),s===null&&lh(t,e,i,cu,n),s===r)break;r=s}r!==null&&i.stopPropagation()}else lh(t,e,i,null,n)}}var cu=null;function yf(t,e,n,i){if(cu=null,t=ap(i),t=ar(t),t!==null)if(e=Or(t),e===null)t=null;else if(n=e.tag,n===13){if(t=Zv(e),t!==null)return t;t=null}else if(n===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;t=null}else e!==t&&(t=null);return cu=t,null}function f1(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(GC()){case up:return 1;case i1:return 4;case lu:case JC:return 16;case r1:return 536870912;default:return 16}default:return 16}}var bi=null,dp=null,za=null;function d1(){if(za)return za;var t,e=dp,n=e.length,i,r="value"in bi?bi.value:bi.textContent,s=r.length;for(t=0;t<n&&e[t]===r[t];t++);var o=n-t;for(i=1;i<=o&&e[n-i]===r[s-i];i++);return za=r.slice(t,1<i?1-i:void 0)}function $a(t){var e=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&e===13&&(t=13)):t=e,t===10&&(t=13),32<=t||t===13?t:0}function Xl(){return!0}function ag(){return!1}function Dt(t){function e(n,i,r,s,o){this._reactName=n,this._targetInst=r,this.type=i,this.nativeEvent=s,this.target=o,this.currentTarget=null;for(var l in t)t.hasOwnProperty(l)&&(n=t[l],this[l]=n?n(s):s[l]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?Xl:ag,this.isPropagationStopped=ag,this}return Ce(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Xl)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Xl)},persist:function(){},isPersistent:Xl}),e}var Ks={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},pp=Dt(Ks),Ml=Ce({},Ks,{view:0,detail:0}),h2=Dt(Ml),Jc,Zc,ro,uc=Ce({},Ml,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:mp,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==ro&&(ro&&t.type==="mousemove"?(Jc=t.screenX-ro.screenX,Zc=t.screenY-ro.screenY):Zc=Jc=0,ro=t),Jc)},movementY:function(t){return"movementY"in t?t.movementY:Zc}}),ug=Dt(uc),f2=Ce({},uc,{dataTransfer:0}),d2=Dt(f2),p2=Ce({},Ml,{relatedTarget:0}),eh=Dt(p2),m2=Ce({},Ks,{animationName:0,elapsedTime:0,pseudoElement:0}),g2=Dt(m2),y2=Ce({},Ks,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),v2=Dt(y2),w2=Ce({},Ks,{data:0}),cg=Dt(w2),x2={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},S2={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},k2={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function b2(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=k2[t])?!!e[t]:!1}function mp(){return b2}var C2=Ce({},Ml,{key:function(t){if(t.key){var e=x2[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=$a(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?S2[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:mp,charCode:function(t){return t.type==="keypress"?$a(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?$a(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),E2=Dt(C2),N2=Ce({},uc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),hg=Dt(N2),_2=Ce({},Ml,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:mp}),A2=Dt(_2),T2=Ce({},Ks,{propertyName:0,elapsedTime:0,pseudoElement:0}),M2=Dt(T2),O2=Ce({},uc,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),P2=Dt(O2),R2=[9,13,27,32],gp=ti&&"CompositionEvent"in window,Ro=null;ti&&"documentMode"in document&&(Ro=document.documentMode);var I2=ti&&"TextEvent"in window&&!Ro,p1=ti&&(!gp||Ro&&8<Ro&&11>=Ro),fg=" ",dg=!1;function m1(t,e){switch(t){case"keyup":return R2.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function g1(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var qr=!1;function D2(t,e){switch(t){case"compositionend":return g1(e);case"keypress":return e.which!==32?null:(dg=!0,fg);case"textInput":return t=e.data,t===fg&&dg?null:t;default:return null}}function B2(t,e){if(qr)return t==="compositionend"||!gp&&m1(t,e)?(t=d1(),za=dp=bi=null,qr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return p1&&e.locale!=="ko"?null:e.data;default:return null}}var L2={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function pg(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!L2[t.type]:e==="textarea"}function y1(t,e,n,i){Yv(i),e=hu(e,"onChange"),0<e.length&&(n=new pp("onChange","change",null,n,i),t.push({event:n,listeners:e}))}var Io=null,Jo=null;function z2(t){A1(t,0)}function cc(t){var e=Xr(t);if(Fv(e))return t}function $2(t,e){if(t==="change")return e}var v1=!1;if(ti){var th;if(ti){var nh="oninput"in document;if(!nh){var mg=document.createElement("div");mg.setAttribute("oninput","return;"),nh=typeof mg.oninput=="function"}th=nh}else th=!1;v1=th&&(!document.documentMode||9<document.documentMode)}function gg(){Io&&(Io.detachEvent("onpropertychange",w1),Jo=Io=null)}function w1(t){if(t.propertyName==="value"&&cc(Jo)){var e=[];y1(e,Jo,t,ap(t)),Jv(z2,e)}}function j2(t,e,n){t==="focusin"?(gg(),Io=e,Jo=n,Io.attachEvent("onpropertychange",w1)):t==="focusout"&&gg()}function F2(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return cc(Jo)}function V2(t,e){if(t==="click")return cc(e)}function H2(t,e){if(t==="input"||t==="change")return cc(e)}function W2(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var mn=typeof Object.is=="function"?Object.is:W2;function Zo(t,e){if(mn(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;var n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(i=0;i<n.length;i++){var r=n[i];if(!Jh.call(e,r)||!mn(t[r],e[r]))return!1}return!0}function yg(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function vg(t,e){var n=yg(t);t=0;for(var i;n;){if(n.nodeType===3){if(i=t+n.textContent.length,t<=e&&i>=e)return{node:n,offset:e-t};t=i}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=yg(n)}}function x1(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?x1(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function S1(){for(var t=window,e=ru();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=ru(t.document)}return e}function yp(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function U2(t){var e=S1(),n=t.focusedElem,i=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&x1(n.ownerDocument.documentElement,n)){if(i!==null&&yp(n)){if(e=i.start,t=i.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var r=n.textContent.length,s=Math.min(i.start,r);i=i.end===void 0?s:Math.min(i.end,r),!t.extend&&s>i&&(r=i,i=s,s=r),r=vg(n,s);var o=vg(n,i);r&&o&&(t.rangeCount!==1||t.anchorNode!==r.node||t.anchorOffset!==r.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(r.node,r.offset),t.removeAllRanges(),s>i?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<e.length;n++)t=e[n],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var K2=ti&&"documentMode"in document&&11>=document.documentMode,Yr=null,vf=null,Do=null,wf=!1;function wg(t,e,n){var i=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;wf||Yr==null||Yr!==ru(i)||(i=Yr,"selectionStart"in i&&yp(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Do&&Zo(Do,i)||(Do=i,i=hu(vf,"onSelect"),0<i.length&&(e=new pp("onSelect","select",null,e,n),t.push({event:e,listeners:i}),e.target=Yr)))}function Gl(t,e){var n={};return n[t.toLowerCase()]=e.toLowerCase(),n["Webkit"+t]="webkit"+e,n["Moz"+t]="moz"+e,n}var Qr={animationend:Gl("Animation","AnimationEnd"),animationiteration:Gl("Animation","AnimationIteration"),animationstart:Gl("Animation","AnimationStart"),transitionend:Gl("Transition","TransitionEnd")},ih={},k1={};ti&&(k1=document.createElement("div").style,"AnimationEvent"in window||(delete Qr.animationend.animation,delete Qr.animationiteration.animation,delete Qr.animationstart.animation),"TransitionEvent"in window||delete Qr.transitionend.transition);function hc(t){if(ih[t])return ih[t];if(!Qr[t])return t;var e=Qr[t],n;for(n in e)if(e.hasOwnProperty(n)&&n in k1)return ih[t]=e[n];return t}var b1=hc("animationend"),C1=hc("animationiteration"),E1=hc("animationstart"),N1=hc("transitionend"),_1=new Map,xg="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Wi(t,e){_1.set(t,e),Mr(e,[t])}for(var rh=0;rh<xg.length;rh++){var sh=xg[rh],q2=sh.toLowerCase(),Y2=sh[0].toUpperCase()+sh.slice(1);Wi(q2,"on"+Y2)}Wi(b1,"onAnimationEnd");Wi(C1,"onAnimationIteration");Wi(E1,"onAnimationStart");Wi("dblclick","onDoubleClick");Wi("focusin","onFocus");Wi("focusout","onBlur");Wi(N1,"onTransitionEnd");Es("onMouseEnter",["mouseout","mouseover"]);Es("onMouseLeave",["mouseout","mouseover"]);Es("onPointerEnter",["pointerout","pointerover"]);Es("onPointerLeave",["pointerout","pointerover"]);Mr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Mr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Mr("onBeforeInput",["compositionend","keypress","textInput","paste"]);Mr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Mr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Mr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var bo="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Q2=new Set("cancel close invalid load scroll toggle".split(" ").concat(bo));function Sg(t,e,n){var i=t.type||"unknown-event";t.currentTarget=n,qC(i,e,void 0,t),t.currentTarget=null}function A1(t,e){e=(e&4)!==0;for(var n=0;n<t.length;n++){var i=t[n],r=i.event;i=i.listeners;e:{var s=void 0;if(e)for(var o=i.length-1;0<=o;o--){var l=i[o],a=l.instance,u=l.currentTarget;if(l=l.listener,a!==s&&r.isPropagationStopped())break e;Sg(r,l,u),s=a}else for(o=0;o<i.length;o++){if(l=i[o],a=l.instance,u=l.currentTarget,l=l.listener,a!==s&&r.isPropagationStopped())break e;Sg(r,l,u),s=a}}}if(ou)throw t=pf,ou=!1,pf=null,t}function ve(t,e){var n=e[Cf];n===void 0&&(n=e[Cf]=new Set);var i=t+"__bubble";n.has(i)||(T1(e,t,2,!1),n.add(i))}function oh(t,e,n){var i=0;e&&(i|=4),T1(n,t,i,e)}var Jl="_reactListening"+Math.random().toString(36).slice(2);function el(t){if(!t[Jl]){t[Jl]=!0,Bv.forEach(function(n){n!=="selectionchange"&&(Q2.has(n)||oh(n,!1,t),oh(n,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[Jl]||(e[Jl]=!0,oh("selectionchange",!1,e))}}function T1(t,e,n,i){switch(f1(e)){case 1:var r=u2;break;case 4:r=c2;break;default:r=fp}n=r.bind(null,e,n,t),r=void 0,!df||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(r=!0),i?r!==void 0?t.addEventListener(e,n,{capture:!0,passive:r}):t.addEventListener(e,n,!0):r!==void 0?t.addEventListener(e,n,{passive:r}):t.addEventListener(e,n,!1)}function lh(t,e,n,i,r){var s=i;if(!(e&1)&&!(e&2)&&i!==null)e:for(;;){if(i===null)return;var o=i.tag;if(o===3||o===4){var l=i.stateNode.containerInfo;if(l===r||l.nodeType===8&&l.parentNode===r)break;if(o===4)for(o=i.return;o!==null;){var a=o.tag;if((a===3||a===4)&&(a=o.stateNode.containerInfo,a===r||a.nodeType===8&&a.parentNode===r))return;o=o.return}for(;l!==null;){if(o=ar(l),o===null)return;if(a=o.tag,a===5||a===6){i=s=o;continue e}l=l.parentNode}}i=i.return}Jv(function(){var u=s,c=ap(n),h=[];e:{var f=_1.get(t);if(f!==void 0){var d=pp,p=t;switch(t){case"keypress":if($a(n)===0)break e;case"keydown":case"keyup":d=E2;break;case"focusin":p="focus",d=eh;break;case"focusout":p="blur",d=eh;break;case"beforeblur":case"afterblur":d=eh;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":d=ug;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":d=d2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":d=A2;break;case b1:case C1:case E1:d=g2;break;case N1:d=M2;break;case"scroll":d=h2;break;case"wheel":d=P2;break;case"copy":case"cut":case"paste":d=v2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":d=hg}var g=(e&4)!==0,S=!g&&t==="scroll",m=g?f!==null?f+"Capture":null:f;g=[];for(var y=u,v;y!==null;){v=y;var x=v.stateNode;if(v.tag===5&&x!==null&&(v=x,m!==null&&(x=Yo(y,m),x!=null&&g.push(tl(y,x,v)))),S)break;y=y.return}0<g.length&&(f=new d(f,p,null,n,c),h.push({event:f,listeners:g}))}}if(!(e&7)){e:{if(f=t==="mouseover"||t==="pointerover",d=t==="mouseout"||t==="pointerout",f&&n!==hf&&(p=n.relatedTarget||n.fromElement)&&(ar(p)||p[ni]))break e;if((d||f)&&(f=c.window===c?c:(f=c.ownerDocument)?f.defaultView||f.parentWindow:window,d?(p=n.relatedTarget||n.toElement,d=u,p=p?ar(p):null,p!==null&&(S=Or(p),p!==S||p.tag!==5&&p.tag!==6)&&(p=null)):(d=null,p=u),d!==p)){if(g=ug,x="onMouseLeave",m="onMouseEnter",y="mouse",(t==="pointerout"||t==="pointerover")&&(g=hg,x="onPointerLeave",m="onPointerEnter",y="pointer"),S=d==null?f:Xr(d),v=p==null?f:Xr(p),f=new g(x,y+"leave",d,n,c),f.target=S,f.relatedTarget=v,x=null,ar(c)===u&&(g=new g(m,y+"enter",p,n,c),g.target=v,g.relatedTarget=S,x=g),S=x,d&&p)t:{for(g=d,m=p,y=0,v=g;v;v=Lr(v))y++;for(v=0,x=m;x;x=Lr(x))v++;for(;0<y-v;)g=Lr(g),y--;for(;0<v-y;)m=Lr(m),v--;for(;y--;){if(g===m||m!==null&&g===m.alternate)break t;g=Lr(g),m=Lr(m)}g=null}else g=null;d!==null&&kg(h,f,d,g,!1),p!==null&&S!==null&&kg(h,S,p,g,!0)}}e:{if(f=u?Xr(u):window,d=f.nodeName&&f.nodeName.toLowerCase(),d==="select"||d==="input"&&f.type==="file")var b=$2;else if(pg(f))if(v1)b=H2;else{b=F2;var C=j2}else(d=f.nodeName)&&d.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(b=V2);if(b&&(b=b(t,u))){y1(h,b,n,c);break e}C&&C(t,f,u),t==="focusout"&&(C=f._wrapperState)&&C.controlled&&f.type==="number"&&of(f,"number",f.value)}switch(C=u?Xr(u):window,t){case"focusin":(pg(C)||C.contentEditable==="true")&&(Yr=C,vf=u,Do=null);break;case"focusout":Do=vf=Yr=null;break;case"mousedown":wf=!0;break;case"contextmenu":case"mouseup":case"dragend":wf=!1,wg(h,n,c);break;case"selectionchange":if(K2)break;case"keydown":case"keyup":wg(h,n,c)}var N;if(gp)e:{switch(t){case"compositionstart":var M="onCompositionStart";break e;case"compositionend":M="onCompositionEnd";break e;case"compositionupdate":M="onCompositionUpdate";break e}M=void 0}else qr?m1(t,n)&&(M="onCompositionEnd"):t==="keydown"&&n.keyCode===229&&(M="onCompositionStart");M&&(p1&&n.locale!=="ko"&&(qr||M!=="onCompositionStart"?M==="onCompositionEnd"&&qr&&(N=d1()):(bi=c,dp="value"in bi?bi.value:bi.textContent,qr=!0)),C=hu(u,M),0<C.length&&(M=new cg(M,t,null,n,c),h.push({event:M,listeners:C}),N?M.data=N:(N=g1(n),N!==null&&(M.data=N)))),(N=I2?D2(t,n):B2(t,n))&&(u=hu(u,"onBeforeInput"),0<u.length&&(c=new cg("onBeforeInput","beforeinput",null,n,c),h.push({event:c,listeners:u}),c.data=N))}A1(h,e)})}function tl(t,e,n){return{instance:t,listener:e,currentTarget:n}}function hu(t,e){for(var n=e+"Capture",i=[];t!==null;){var r=t,s=r.stateNode;r.tag===5&&s!==null&&(r=s,s=Yo(t,n),s!=null&&i.unshift(tl(t,s,r)),s=Yo(t,e),s!=null&&i.push(tl(t,s,r))),t=t.return}return i}function Lr(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function kg(t,e,n,i,r){for(var s=e._reactName,o=[];n!==null&&n!==i;){var l=n,a=l.alternate,u=l.stateNode;if(a!==null&&a===i)break;l.tag===5&&u!==null&&(l=u,r?(a=Yo(n,s),a!=null&&o.unshift(tl(n,a,l))):r||(a=Yo(n,s),a!=null&&o.push(tl(n,a,l)))),n=n.return}o.length!==0&&t.push({event:e,listeners:o})}var X2=/\r\n?/g,G2=/\u0000|\uFFFD/g;function bg(t){return(typeof t=="string"?t:""+t).replace(X2,`
38
+ `).replace(G2,"")}function Zl(t,e,n){if(e=bg(e),bg(t)!==e&&n)throw Error(H(425))}function fu(){}var xf=null,Sf=null;function kf(t,e){return t==="textarea"||t==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var bf=typeof setTimeout=="function"?setTimeout:void 0,J2=typeof clearTimeout=="function"?clearTimeout:void 0,Cg=typeof Promise=="function"?Promise:void 0,Z2=typeof queueMicrotask=="function"?queueMicrotask:typeof Cg<"u"?function(t){return Cg.resolve(null).then(t).catch(eE)}:bf;function eE(t){setTimeout(function(){throw t})}function ah(t,e){var n=e,i=0;do{var r=n.nextSibling;if(t.removeChild(n),r&&r.nodeType===8)if(n=r.data,n==="/$"){if(i===0){t.removeChild(r),Go(e);return}i--}else n!=="$"&&n!=="$?"&&n!=="$!"||i++;n=r}while(n);Go(e)}function Mi(t){for(;t!=null;t=t.nextSibling){var e=t.nodeType;if(e===1||e===3)break;if(e===8){if(e=t.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return t}function Eg(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="$"||n==="$!"||n==="$?"){if(e===0)return t;e--}else n==="/$"&&e++}t=t.previousSibling}return null}var qs=Math.random().toString(36).slice(2),Mn="__reactFiber$"+qs,nl="__reactProps$"+qs,ni="__reactContainer$"+qs,Cf="__reactEvents$"+qs,tE="__reactListeners$"+qs,nE="__reactHandles$"+qs;function ar(t){var e=t[Mn];if(e)return e;for(var n=t.parentNode;n;){if(e=n[ni]||n[Mn]){if(n=e.alternate,e.child!==null||n!==null&&n.child!==null)for(t=Eg(t);t!==null;){if(n=t[Mn])return n;t=Eg(t)}return e}t=n,n=t.parentNode}return null}function Ol(t){return t=t[Mn]||t[ni],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Xr(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(H(33))}function fc(t){return t[nl]||null}var Ef=[],Gr=-1;function Ui(t){return{current:t}}function we(t){0>Gr||(t.current=Ef[Gr],Ef[Gr]=null,Gr--)}function pe(t,e){Gr++,Ef[Gr]=t.current,t.current=e}var zi={},it=Ui(zi),xt=Ui(!1),wr=zi;function Ns(t,e){var n=t.type.contextTypes;if(!n)return zi;var i=t.stateNode;if(i&&i.__reactInternalMemoizedUnmaskedChildContext===e)return i.__reactInternalMemoizedMaskedChildContext;var r={},s;for(s in n)r[s]=e[s];return i&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=r),r}function St(t){return t=t.childContextTypes,t!=null}function du(){we(xt),we(it)}function Ng(t,e,n){if(it.current!==zi)throw Error(H(168));pe(it,e),pe(xt,n)}function M1(t,e,n){var i=t.stateNode;if(e=e.childContextTypes,typeof i.getChildContext!="function")return n;i=i.getChildContext();for(var r in i)if(!(r in e))throw Error(H(108,jC(t)||"Unknown",r));return Ce({},n,i)}function pu(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||zi,wr=it.current,pe(it,t),pe(xt,xt.current),!0}function _g(t,e,n){var i=t.stateNode;if(!i)throw Error(H(169));n?(t=M1(t,e,wr),i.__reactInternalMemoizedMergedChildContext=t,we(xt),we(it),pe(it,t)):we(xt),pe(xt,n)}var Kn=null,dc=!1,uh=!1;function O1(t){Kn===null?Kn=[t]:Kn.push(t)}function iE(t){dc=!0,O1(t)}function Ki(){if(!uh&&Kn!==null){uh=!0;var t=0,e=ce;try{var n=Kn;for(ce=1;t<n.length;t++){var i=n[t];do i=i(!0);while(i!==null)}Kn=null,dc=!1}catch(r){throw Kn!==null&&(Kn=Kn.slice(t+1)),n1(up,Ki),r}finally{ce=e,uh=!1}}return null}var Jr=[],Zr=0,mu=null,gu=0,zt=[],$t=0,xr=null,Qn=1,Xn="";function nr(t,e){Jr[Zr++]=gu,Jr[Zr++]=mu,mu=t,gu=e}function P1(t,e,n){zt[$t++]=Qn,zt[$t++]=Xn,zt[$t++]=xr,xr=t;var i=Qn;t=Xn;var r=32-fn(i)-1;i&=~(1<<r),n+=1;var s=32-fn(e)+r;if(30<s){var o=r-r%5;s=(i&(1<<o)-1).toString(32),i>>=o,r-=o,Qn=1<<32-fn(e)+r|n<<r|i,Xn=s+t}else Qn=1<<s|n<<r|i,Xn=t}function vp(t){t.return!==null&&(nr(t,1),P1(t,1,0))}function wp(t){for(;t===mu;)mu=Jr[--Zr],Jr[Zr]=null,gu=Jr[--Zr],Jr[Zr]=null;for(;t===xr;)xr=zt[--$t],zt[$t]=null,Xn=zt[--$t],zt[$t]=null,Qn=zt[--$t],zt[$t]=null}var Ot=null,Tt=null,xe=!1,on=null;function R1(t,e){var n=Ft(5,null,null,0);n.elementType="DELETED",n.stateNode=e,n.return=t,e=t.deletions,e===null?(t.deletions=[n],t.flags|=16):e.push(n)}function Ag(t,e){switch(t.tag){case 5:var n=t.type;return e=e.nodeType!==1||n.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(t.stateNode=e,Ot=t,Tt=Mi(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,Ot=t,Tt=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(n=xr!==null?{id:Qn,overflow:Xn}:null,t.memoizedState={dehydrated:e,treeContext:n,retryLane:1073741824},n=Ft(18,null,null,0),n.stateNode=e,n.return=t,t.child=n,Ot=t,Tt=null,!0):!1;default:return!1}}function Nf(t){return(t.mode&1)!==0&&(t.flags&128)===0}function _f(t){if(xe){var e=Tt;if(e){var n=e;if(!Ag(t,e)){if(Nf(t))throw Error(H(418));e=Mi(n.nextSibling);var i=Ot;e&&Ag(t,e)?R1(i,n):(t.flags=t.flags&-4097|2,xe=!1,Ot=t)}}else{if(Nf(t))throw Error(H(418));t.flags=t.flags&-4097|2,xe=!1,Ot=t}}}function Tg(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;Ot=t}function ea(t){if(t!==Ot)return!1;if(!xe)return Tg(t),xe=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!kf(t.type,t.memoizedProps)),e&&(e=Tt)){if(Nf(t))throw I1(),Error(H(418));for(;e;)R1(t,e),e=Mi(e.nextSibling)}if(Tg(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(H(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="/$"){if(e===0){Tt=Mi(t.nextSibling);break e}e--}else n!=="$"&&n!=="$!"&&n!=="$?"||e++}t=t.nextSibling}Tt=null}}else Tt=Ot?Mi(t.stateNode.nextSibling):null;return!0}function I1(){for(var t=Tt;t;)t=Mi(t.nextSibling)}function _s(){Tt=Ot=null,xe=!1}function xp(t){on===null?on=[t]:on.push(t)}var rE=ai.ReactCurrentBatchConfig;function so(t,e,n){if(t=n.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(H(309));var i=n.stateNode}if(!i)throw Error(H(147,t));var r=i,s=""+t;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===s?e.ref:(e=function(o){var l=r.refs;o===null?delete l[s]:l[s]=o},e._stringRef=s,e)}if(typeof t!="string")throw Error(H(284));if(!n._owner)throw Error(H(290,t))}return t}function ta(t,e){throw t=Object.prototype.toString.call(e),Error(H(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function Mg(t){var e=t._init;return e(t._payload)}function D1(t){function e(m,y){if(t){var v=m.deletions;v===null?(m.deletions=[y],m.flags|=16):v.push(y)}}function n(m,y){if(!t)return null;for(;y!==null;)e(m,y),y=y.sibling;return null}function i(m,y){for(m=new Map;y!==null;)y.key!==null?m.set(y.key,y):m.set(y.index,y),y=y.sibling;return m}function r(m,y){return m=Ii(m,y),m.index=0,m.sibling=null,m}function s(m,y,v){return m.index=v,t?(v=m.alternate,v!==null?(v=v.index,v<y?(m.flags|=2,y):v):(m.flags|=2,y)):(m.flags|=1048576,y)}function o(m){return t&&m.alternate===null&&(m.flags|=2),m}function l(m,y,v,x){return y===null||y.tag!==6?(y=gh(v,m.mode,x),y.return=m,y):(y=r(y,v),y.return=m,y)}function a(m,y,v,x){var b=v.type;return b===Kr?c(m,y,v.props.children,x,v.key):y!==null&&(y.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===fi&&Mg(b)===y.type)?(x=r(y,v.props),x.ref=so(m,y,v),x.return=m,x):(x=Ka(v.type,v.key,v.props,null,m.mode,x),x.ref=so(m,y,v),x.return=m,x)}function u(m,y,v,x){return y===null||y.tag!==4||y.stateNode.containerInfo!==v.containerInfo||y.stateNode.implementation!==v.implementation?(y=yh(v,m.mode,x),y.return=m,y):(y=r(y,v.children||[]),y.return=m,y)}function c(m,y,v,x,b){return y===null||y.tag!==7?(y=mr(v,m.mode,x,b),y.return=m,y):(y=r(y,v),y.return=m,y)}function h(m,y,v){if(typeof y=="string"&&y!==""||typeof y=="number")return y=gh(""+y,m.mode,v),y.return=m,y;if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Wl:return v=Ka(y.type,y.key,y.props,null,m.mode,v),v.ref=so(m,null,y),v.return=m,v;case Ur:return y=yh(y,m.mode,v),y.return=m,y;case fi:var x=y._init;return h(m,x(y._payload),v)}if(So(y)||eo(y))return y=mr(y,m.mode,v,null),y.return=m,y;ta(m,y)}return null}function f(m,y,v,x){var b=y!==null?y.key:null;if(typeof v=="string"&&v!==""||typeof v=="number")return b!==null?null:l(m,y,""+v,x);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Wl:return v.key===b?a(m,y,v,x):null;case Ur:return v.key===b?u(m,y,v,x):null;case fi:return b=v._init,f(m,y,b(v._payload),x)}if(So(v)||eo(v))return b!==null?null:c(m,y,v,x,null);ta(m,v)}return null}function d(m,y,v,x,b){if(typeof x=="string"&&x!==""||typeof x=="number")return m=m.get(v)||null,l(y,m,""+x,b);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Wl:return m=m.get(x.key===null?v:x.key)||null,a(y,m,x,b);case Ur:return m=m.get(x.key===null?v:x.key)||null,u(y,m,x,b);case fi:var C=x._init;return d(m,y,v,C(x._payload),b)}if(So(x)||eo(x))return m=m.get(v)||null,c(y,m,x,b,null);ta(y,x)}return null}function p(m,y,v,x){for(var b=null,C=null,N=y,M=y=0,_=null;N!==null&&M<v.length;M++){N.index>M?(_=N,N=null):_=N.sibling;var P=f(m,N,v[M],x);if(P===null){N===null&&(N=_);break}t&&N&&P.alternate===null&&e(m,N),y=s(P,y,M),C===null?b=P:C.sibling=P,C=P,N=_}if(M===v.length)return n(m,N),xe&&nr(m,M),b;if(N===null){for(;M<v.length;M++)N=h(m,v[M],x),N!==null&&(y=s(N,y,M),C===null?b=N:C.sibling=N,C=N);return xe&&nr(m,M),b}for(N=i(m,N);M<v.length;M++)_=d(N,m,M,v[M],x),_!==null&&(t&&_.alternate!==null&&N.delete(_.key===null?M:_.key),y=s(_,y,M),C===null?b=_:C.sibling=_,C=_);return t&&N.forEach(function(B){return e(m,B)}),xe&&nr(m,M),b}function g(m,y,v,x){var b=eo(v);if(typeof b!="function")throw Error(H(150));if(v=b.call(v),v==null)throw Error(H(151));for(var C=b=null,N=y,M=y=0,_=null,P=v.next();N!==null&&!P.done;M++,P=v.next()){N.index>M?(_=N,N=null):_=N.sibling;var B=f(m,N,P.value,x);if(B===null){N===null&&(N=_);break}t&&N&&B.alternate===null&&e(m,N),y=s(B,y,M),C===null?b=B:C.sibling=B,C=B,N=_}if(P.done)return n(m,N),xe&&nr(m,M),b;if(N===null){for(;!P.done;M++,P=v.next())P=h(m,P.value,x),P!==null&&(y=s(P,y,M),C===null?b=P:C.sibling=P,C=P);return xe&&nr(m,M),b}for(N=i(m,N);!P.done;M++,P=v.next())P=d(N,m,M,P.value,x),P!==null&&(t&&P.alternate!==null&&N.delete(P.key===null?M:P.key),y=s(P,y,M),C===null?b=P:C.sibling=P,C=P);return t&&N.forEach(function(L){return e(m,L)}),xe&&nr(m,M),b}function S(m,y,v,x){if(typeof v=="object"&&v!==null&&v.type===Kr&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case Wl:e:{for(var b=v.key,C=y;C!==null;){if(C.key===b){if(b=v.type,b===Kr){if(C.tag===7){n(m,C.sibling),y=r(C,v.props.children),y.return=m,m=y;break e}}else if(C.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===fi&&Mg(b)===C.type){n(m,C.sibling),y=r(C,v.props),y.ref=so(m,C,v),y.return=m,m=y;break e}n(m,C);break}else e(m,C);C=C.sibling}v.type===Kr?(y=mr(v.props.children,m.mode,x,v.key),y.return=m,m=y):(x=Ka(v.type,v.key,v.props,null,m.mode,x),x.ref=so(m,y,v),x.return=m,m=x)}return o(m);case Ur:e:{for(C=v.key;y!==null;){if(y.key===C)if(y.tag===4&&y.stateNode.containerInfo===v.containerInfo&&y.stateNode.implementation===v.implementation){n(m,y.sibling),y=r(y,v.children||[]),y.return=m,m=y;break e}else{n(m,y);break}else e(m,y);y=y.sibling}y=yh(v,m.mode,x),y.return=m,m=y}return o(m);case fi:return C=v._init,S(m,y,C(v._payload),x)}if(So(v))return p(m,y,v,x);if(eo(v))return g(m,y,v,x);ta(m,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,y!==null&&y.tag===6?(n(m,y.sibling),y=r(y,v),y.return=m,m=y):(n(m,y),y=gh(v,m.mode,x),y.return=m,m=y),o(m)):n(m,y)}return S}var As=D1(!0),B1=D1(!1),yu=Ui(null),vu=null,es=null,Sp=null;function kp(){Sp=es=vu=null}function bp(t){var e=yu.current;we(yu),t._currentValue=e}function Af(t,e,n){for(;t!==null;){var i=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,i!==null&&(i.childLanes|=e)):i!==null&&(i.childLanes&e)!==e&&(i.childLanes|=e),t===n)break;t=t.return}}function fs(t,e){vu=t,Sp=es=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(yt=!0),t.firstContext=null)}function Qt(t){var e=t._currentValue;if(Sp!==t)if(t={context:t,memoizedValue:e,next:null},es===null){if(vu===null)throw Error(H(308));es=t,vu.dependencies={lanes:0,firstContext:t}}else es=es.next=t;return e}var ur=null;function Cp(t){ur===null?ur=[t]:ur.push(t)}function L1(t,e,n,i){var r=e.interleaved;return r===null?(n.next=n,Cp(e)):(n.next=r.next,r.next=n),e.interleaved=n,ii(t,i)}function ii(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var di=!1;function Ep(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function z1(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Zn(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Oi(t,e,n){var i=t.updateQueue;if(i===null)return null;if(i=i.shared,le&2){var r=i.pending;return r===null?e.next=e:(e.next=r.next,r.next=e),i.pending=e,ii(t,n)}return r=i.interleaved,r===null?(e.next=e,Cp(i)):(e.next=r.next,r.next=e),i.interleaved=e,ii(t,n)}function ja(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var i=e.lanes;i&=t.pendingLanes,n|=i,e.lanes=n,cp(t,n)}}function Og(t,e){var n=t.updateQueue,i=t.alternate;if(i!==null&&(i=i.updateQueue,n===i)){var r=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?r=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?r=s=e:s=s.next=e}else r=s=e;n={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:s,shared:i.shared,effects:i.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function wu(t,e,n,i){var r=t.updateQueue;di=!1;var s=r.firstBaseUpdate,o=r.lastBaseUpdate,l=r.shared.pending;if(l!==null){r.shared.pending=null;var a=l,u=a.next;a.next=null,o===null?s=u:o.next=u,o=a;var c=t.alternate;c!==null&&(c=c.updateQueue,l=c.lastBaseUpdate,l!==o&&(l===null?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=a))}if(s!==null){var h=r.baseState;o=0,c=u=a=null,l=s;do{var f=l.lane,d=l.eventTime;if((i&f)===f){c!==null&&(c=c.next={eventTime:d,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var p=t,g=l;switch(f=e,d=n,g.tag){case 1:if(p=g.payload,typeof p=="function"){h=p.call(d,h,f);break e}h=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=g.payload,f=typeof p=="function"?p.call(d,h,f):p,f==null)break e;h=Ce({},h,f);break e;case 2:di=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,f=r.effects,f===null?r.effects=[l]:f.push(l))}else d={eventTime:d,lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},c===null?(u=c=d,a=h):c=c.next=d,o|=f;if(l=l.next,l===null){if(l=r.shared.pending,l===null)break;f=l,l=f.next,f.next=null,r.lastBaseUpdate=f,r.shared.pending=null}}while(!0);if(c===null&&(a=h),r.baseState=a,r.firstBaseUpdate=u,r.lastBaseUpdate=c,e=r.shared.interleaved,e!==null){r=e;do o|=r.lane,r=r.next;while(r!==e)}else s===null&&(r.shared.lanes=0);kr|=o,t.lanes=o,t.memoizedState=h}}function Pg(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;e<t.length;e++){var i=t[e],r=i.callback;if(r!==null){if(i.callback=null,i=n,typeof r!="function")throw Error(H(191,r));r.call(i)}}}var Pl={},Bn=Ui(Pl),il=Ui(Pl),rl=Ui(Pl);function cr(t){if(t===Pl)throw Error(H(174));return t}function Np(t,e){switch(pe(rl,e),pe(il,t),pe(Bn,Pl),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:af(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=af(e,t)}we(Bn),pe(Bn,e)}function Ts(){we(Bn),we(il),we(rl)}function $1(t){cr(rl.current);var e=cr(Bn.current),n=af(e,t.type);e!==n&&(pe(il,t),pe(Bn,n))}function _p(t){il.current===t&&(we(Bn),we(il))}var ke=Ui(0);function xu(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var ch=[];function Ap(){for(var t=0;t<ch.length;t++)ch[t]._workInProgressVersionPrimary=null;ch.length=0}var Fa=ai.ReactCurrentDispatcher,hh=ai.ReactCurrentBatchConfig,Sr=0,be=null,Le=null,Fe=null,Su=!1,Bo=!1,sl=0,sE=0;function Je(){throw Error(H(321))}function Tp(t,e){if(e===null)return!1;for(var n=0;n<e.length&&n<t.length;n++)if(!mn(t[n],e[n]))return!1;return!0}function Mp(t,e,n,i,r,s){if(Sr=s,be=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,Fa.current=t===null||t.memoizedState===null?uE:cE,t=n(i,r),Bo){s=0;do{if(Bo=!1,sl=0,25<=s)throw Error(H(301));s+=1,Fe=Le=null,e.updateQueue=null,Fa.current=hE,t=n(i,r)}while(Bo)}if(Fa.current=ku,e=Le!==null&&Le.next!==null,Sr=0,Fe=Le=be=null,Su=!1,e)throw Error(H(300));return t}function Op(){var t=sl!==0;return sl=0,t}function An(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Fe===null?be.memoizedState=Fe=t:Fe=Fe.next=t,Fe}function Xt(){if(Le===null){var t=be.alternate;t=t!==null?t.memoizedState:null}else t=Le.next;var e=Fe===null?be.memoizedState:Fe.next;if(e!==null)Fe=e,Le=t;else{if(t===null)throw Error(H(310));Le=t,t={memoizedState:Le.memoizedState,baseState:Le.baseState,baseQueue:Le.baseQueue,queue:Le.queue,next:null},Fe===null?be.memoizedState=Fe=t:Fe=Fe.next=t}return Fe}function ol(t,e){return typeof e=="function"?e(t):e}function fh(t){var e=Xt(),n=e.queue;if(n===null)throw Error(H(311));n.lastRenderedReducer=t;var i=Le,r=i.baseQueue,s=n.pending;if(s!==null){if(r!==null){var o=r.next;r.next=s.next,s.next=o}i.baseQueue=r=s,n.pending=null}if(r!==null){s=r.next,i=i.baseState;var l=o=null,a=null,u=s;do{var c=u.lane;if((Sr&c)===c)a!==null&&(a=a.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),i=u.hasEagerState?u.eagerState:t(i,u.action);else{var h={lane:c,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};a===null?(l=a=h,o=i):a=a.next=h,be.lanes|=c,kr|=c}u=u.next}while(u!==null&&u!==s);a===null?o=i:a.next=l,mn(i,e.memoizedState)||(yt=!0),e.memoizedState=i,e.baseState=o,e.baseQueue=a,n.lastRenderedState=i}if(t=n.interleaved,t!==null){r=t;do s=r.lane,be.lanes|=s,kr|=s,r=r.next;while(r!==t)}else r===null&&(n.lanes=0);return[e.memoizedState,n.dispatch]}function dh(t){var e=Xt(),n=e.queue;if(n===null)throw Error(H(311));n.lastRenderedReducer=t;var i=n.dispatch,r=n.pending,s=e.memoizedState;if(r!==null){n.pending=null;var o=r=r.next;do s=t(s,o.action),o=o.next;while(o!==r);mn(s,e.memoizedState)||(yt=!0),e.memoizedState=s,e.baseQueue===null&&(e.baseState=s),n.lastRenderedState=s}return[s,i]}function j1(){}function F1(t,e){var n=be,i=Xt(),r=e(),s=!mn(i.memoizedState,r);if(s&&(i.memoizedState=r,yt=!0),i=i.queue,Pp(W1.bind(null,n,i,t),[t]),i.getSnapshot!==e||s||Fe!==null&&Fe.memoizedState.tag&1){if(n.flags|=2048,ll(9,H1.bind(null,n,i,r,e),void 0,null),He===null)throw Error(H(349));Sr&30||V1(n,e,r)}return r}function V1(t,e,n){t.flags|=16384,t={getSnapshot:e,value:n},e=be.updateQueue,e===null?(e={lastEffect:null,stores:null},be.updateQueue=e,e.stores=[t]):(n=e.stores,n===null?e.stores=[t]:n.push(t))}function H1(t,e,n,i){e.value=n,e.getSnapshot=i,U1(e)&&K1(t)}function W1(t,e,n){return n(function(){U1(e)&&K1(t)})}function U1(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!mn(t,n)}catch{return!0}}function K1(t){var e=ii(t,1);e!==null&&dn(e,t,1,-1)}function Rg(t){var e=An();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ol,lastRenderedState:t},e.queue=t,t=t.dispatch=aE.bind(null,be,t),[e.memoizedState,t]}function ll(t,e,n,i){return t={tag:t,create:e,destroy:n,deps:i,next:null},e=be.updateQueue,e===null?(e={lastEffect:null,stores:null},be.updateQueue=e,e.lastEffect=t.next=t):(n=e.lastEffect,n===null?e.lastEffect=t.next=t:(i=n.next,n.next=t,t.next=i,e.lastEffect=t)),t}function q1(){return Xt().memoizedState}function Va(t,e,n,i){var r=An();be.flags|=t,r.memoizedState=ll(1|e,n,void 0,i===void 0?null:i)}function pc(t,e,n,i){var r=Xt();i=i===void 0?null:i;var s=void 0;if(Le!==null){var o=Le.memoizedState;if(s=o.destroy,i!==null&&Tp(i,o.deps)){r.memoizedState=ll(e,n,s,i);return}}be.flags|=t,r.memoizedState=ll(1|e,n,s,i)}function Ig(t,e){return Va(8390656,8,t,e)}function Pp(t,e){return pc(2048,8,t,e)}function Y1(t,e){return pc(4,2,t,e)}function Q1(t,e){return pc(4,4,t,e)}function X1(t,e){if(typeof e=="function")return t=t(),e(t),function(){e(null)};if(e!=null)return t=t(),e.current=t,function(){e.current=null}}function G1(t,e,n){return n=n!=null?n.concat([t]):null,pc(4,4,X1.bind(null,e,t),n)}function Rp(){}function J1(t,e){var n=Xt();e=e===void 0?null:e;var i=n.memoizedState;return i!==null&&e!==null&&Tp(e,i[1])?i[0]:(n.memoizedState=[t,e],t)}function Z1(t,e){var n=Xt();e=e===void 0?null:e;var i=n.memoizedState;return i!==null&&e!==null&&Tp(e,i[1])?i[0]:(t=t(),n.memoizedState=[t,e],t)}function ew(t,e,n){return Sr&21?(mn(n,e)||(n=s1(),be.lanes|=n,kr|=n,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,yt=!0),t.memoizedState=n)}function oE(t,e){var n=ce;ce=n!==0&&4>n?n:4,t(!0);var i=hh.transition;hh.transition={};try{t(!1),e()}finally{ce=n,hh.transition=i}}function tw(){return Xt().memoizedState}function lE(t,e,n){var i=Ri(t);if(n={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null},nw(t))iw(e,n);else if(n=L1(t,e,n,i),n!==null){var r=at();dn(n,t,i,r),rw(n,e,i)}}function aE(t,e,n){var i=Ri(t),r={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null};if(nw(t))iw(e,r);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,l=s(o,n);if(r.hasEagerState=!0,r.eagerState=l,mn(l,o)){var a=e.interleaved;a===null?(r.next=r,Cp(e)):(r.next=a.next,a.next=r),e.interleaved=r;return}}catch{}finally{}n=L1(t,e,r,i),n!==null&&(r=at(),dn(n,t,i,r),rw(n,e,i))}}function nw(t){var e=t.alternate;return t===be||e!==null&&e===be}function iw(t,e){Bo=Su=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function rw(t,e,n){if(n&4194240){var i=e.lanes;i&=t.pendingLanes,n|=i,e.lanes=n,cp(t,n)}}var ku={readContext:Qt,useCallback:Je,useContext:Je,useEffect:Je,useImperativeHandle:Je,useInsertionEffect:Je,useLayoutEffect:Je,useMemo:Je,useReducer:Je,useRef:Je,useState:Je,useDebugValue:Je,useDeferredValue:Je,useTransition:Je,useMutableSource:Je,useSyncExternalStore:Je,useId:Je,unstable_isNewReconciler:!1},uE={readContext:Qt,useCallback:function(t,e){return An().memoizedState=[t,e===void 0?null:e],t},useContext:Qt,useEffect:Ig,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Va(4194308,4,X1.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Va(4194308,4,t,e)},useInsertionEffect:function(t,e){return Va(4,2,t,e)},useMemo:function(t,e){var n=An();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var i=An();return e=n!==void 0?n(e):e,i.memoizedState=i.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},i.queue=t,t=t.dispatch=lE.bind(null,be,t),[i.memoizedState,t]},useRef:function(t){var e=An();return t={current:t},e.memoizedState=t},useState:Rg,useDebugValue:Rp,useDeferredValue:function(t){return An().memoizedState=t},useTransition:function(){var t=Rg(!1),e=t[0];return t=oE.bind(null,t[1]),An().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var i=be,r=An();if(xe){if(n===void 0)throw Error(H(407));n=n()}else{if(n=e(),He===null)throw Error(H(349));Sr&30||V1(i,e,n)}r.memoizedState=n;var s={value:n,getSnapshot:e};return r.queue=s,Ig(W1.bind(null,i,s,t),[t]),i.flags|=2048,ll(9,H1.bind(null,i,s,n,e),void 0,null),n},useId:function(){var t=An(),e=He.identifierPrefix;if(xe){var n=Xn,i=Qn;n=(i&~(1<<32-fn(i)-1)).toString(32)+n,e=":"+e+"R"+n,n=sl++,0<n&&(e+="H"+n.toString(32)),e+=":"}else n=sE++,e=":"+e+"r"+n.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},cE={readContext:Qt,useCallback:J1,useContext:Qt,useEffect:Pp,useImperativeHandle:G1,useInsertionEffect:Y1,useLayoutEffect:Q1,useMemo:Z1,useReducer:fh,useRef:q1,useState:function(){return fh(ol)},useDebugValue:Rp,useDeferredValue:function(t){var e=Xt();return ew(e,Le.memoizedState,t)},useTransition:function(){var t=fh(ol)[0],e=Xt().memoizedState;return[t,e]},useMutableSource:j1,useSyncExternalStore:F1,useId:tw,unstable_isNewReconciler:!1},hE={readContext:Qt,useCallback:J1,useContext:Qt,useEffect:Pp,useImperativeHandle:G1,useInsertionEffect:Y1,useLayoutEffect:Q1,useMemo:Z1,useReducer:dh,useRef:q1,useState:function(){return dh(ol)},useDebugValue:Rp,useDeferredValue:function(t){var e=Xt();return Le===null?e.memoizedState=t:ew(e,Le.memoizedState,t)},useTransition:function(){var t=dh(ol)[0],e=Xt().memoizedState;return[t,e]},useMutableSource:j1,useSyncExternalStore:F1,useId:tw,unstable_isNewReconciler:!1};function rn(t,e){if(t&&t.defaultProps){e=Ce({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function Tf(t,e,n,i){e=t.memoizedState,n=n(i,e),n=n==null?e:Ce({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}var mc={isMounted:function(t){return(t=t._reactInternals)?Or(t)===t:!1},enqueueSetState:function(t,e,n){t=t._reactInternals;var i=at(),r=Ri(t),s=Zn(i,r);s.payload=e,n!=null&&(s.callback=n),e=Oi(t,s,r),e!==null&&(dn(e,t,r,i),ja(e,t,r))},enqueueReplaceState:function(t,e,n){t=t._reactInternals;var i=at(),r=Ri(t),s=Zn(i,r);s.tag=1,s.payload=e,n!=null&&(s.callback=n),e=Oi(t,s,r),e!==null&&(dn(e,t,r,i),ja(e,t,r))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var n=at(),i=Ri(t),r=Zn(n,i);r.tag=2,e!=null&&(r.callback=e),e=Oi(t,r,i),e!==null&&(dn(e,t,i,n),ja(e,t,i))}};function Dg(t,e,n,i,r,s,o){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(i,s,o):e.prototype&&e.prototype.isPureReactComponent?!Zo(n,i)||!Zo(r,s):!0}function sw(t,e,n){var i=!1,r=zi,s=e.contextType;return typeof s=="object"&&s!==null?s=Qt(s):(r=St(e)?wr:it.current,i=e.contextTypes,s=(i=i!=null)?Ns(t,r):zi),e=new e(n,s),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=mc,t.stateNode=e,e._reactInternals=t,i&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=r,t.__reactInternalMemoizedMaskedChildContext=s),e}function Bg(t,e,n,i){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,i),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,i),e.state!==t&&mc.enqueueReplaceState(e,e.state,null)}function Mf(t,e,n,i){var r=t.stateNode;r.props=n,r.state=t.memoizedState,r.refs={},Ep(t);var s=e.contextType;typeof s=="object"&&s!==null?r.context=Qt(s):(s=St(e)?wr:it.current,r.context=Ns(t,s)),r.state=t.memoizedState,s=e.getDerivedStateFromProps,typeof s=="function"&&(Tf(t,e,s,n),r.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(e=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),e!==r.state&&mc.enqueueReplaceState(r,r.state,null),wu(t,n,r,i),r.state=t.memoizedState),typeof r.componentDidMount=="function"&&(t.flags|=4194308)}function Ms(t,e){try{var n="",i=e;do n+=$C(i),i=i.return;while(i);var r=n}catch(s){r=`
39
+ Error generating stack: `+s.message+`
40
+ `+s.stack}return{value:t,source:e,stack:r,digest:null}}function ph(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function Of(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var fE=typeof WeakMap=="function"?WeakMap:Map;function ow(t,e,n){n=Zn(-1,n),n.tag=3,n.payload={element:null};var i=e.value;return n.callback=function(){Cu||(Cu=!0,Ff=i),Of(t,e)},n}function lw(t,e,n){n=Zn(-1,n),n.tag=3;var i=t.type.getDerivedStateFromError;if(typeof i=="function"){var r=e.value;n.payload=function(){return i(r)},n.callback=function(){Of(t,e)}}var s=t.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){Of(t,e),typeof i!="function"&&(Pi===null?Pi=new Set([this]):Pi.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),n}function Lg(t,e,n){var i=t.pingCache;if(i===null){i=t.pingCache=new fE;var r=new Set;i.set(e,r)}else r=i.get(e),r===void 0&&(r=new Set,i.set(e,r));r.has(n)||(r.add(n),t=NE.bind(null,t,e,n),e.then(t,t))}function zg(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function $g(t,e,n,i,r){return t.mode&1?(t.flags|=65536,t.lanes=r,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=Zn(-1,1),e.tag=2,Oi(n,e,1))),n.lanes|=1),t)}var dE=ai.ReactCurrentOwner,yt=!1;function ot(t,e,n,i){e.child=t===null?B1(e,null,n,i):As(e,t.child,n,i)}function jg(t,e,n,i,r){n=n.render;var s=e.ref;return fs(e,r),i=Mp(t,e,n,i,s,r),n=Op(),t!==null&&!yt?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~r,ri(t,e,r)):(xe&&n&&vp(e),e.flags|=1,ot(t,e,i,r),e.child)}function Fg(t,e,n,i,r){if(t===null){var s=n.type;return typeof s=="function"&&!Fp(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=s,aw(t,e,s,i,r)):(t=Ka(n.type,null,i,e,e.mode,r),t.ref=e.ref,t.return=e,e.child=t)}if(s=t.child,!(t.lanes&r)){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:Zo,n(o,i)&&t.ref===e.ref)return ri(t,e,r)}return e.flags|=1,t=Ii(s,i),t.ref=e.ref,t.return=e,e.child=t}function aw(t,e,n,i,r){if(t!==null){var s=t.memoizedProps;if(Zo(s,i)&&t.ref===e.ref)if(yt=!1,e.pendingProps=i=s,(t.lanes&r)!==0)t.flags&131072&&(yt=!0);else return e.lanes=t.lanes,ri(t,e,r)}return Pf(t,e,n,i,r)}function uw(t,e,n){var i=e.pendingProps,r=i.children,s=t!==null?t.memoizedState:null;if(i.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},pe(ns,Nt),Nt|=n;else{if(!(n&1073741824))return t=s!==null?s.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,pe(ns,Nt),Nt|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},i=s!==null?s.baseLanes:n,pe(ns,Nt),Nt|=i}else s!==null?(i=s.baseLanes|n,e.memoizedState=null):i=n,pe(ns,Nt),Nt|=i;return ot(t,e,r,n),e.child}function cw(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function Pf(t,e,n,i,r){var s=St(n)?wr:it.current;return s=Ns(e,s),fs(e,r),n=Mp(t,e,n,i,s,r),i=Op(),t!==null&&!yt?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~r,ri(t,e,r)):(xe&&i&&vp(e),e.flags|=1,ot(t,e,n,r),e.child)}function Vg(t,e,n,i,r){if(St(n)){var s=!0;pu(e)}else s=!1;if(fs(e,r),e.stateNode===null)Ha(t,e),sw(e,n,i),Mf(e,n,i,r),i=!0;else if(t===null){var o=e.stateNode,l=e.memoizedProps;o.props=l;var a=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=Qt(u):(u=St(n)?wr:it.current,u=Ns(e,u));var c=n.getDerivedStateFromProps,h=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==i||a!==u)&&Bg(e,o,i,u),di=!1;var f=e.memoizedState;o.state=f,wu(e,i,o,r),a=e.memoizedState,l!==i||f!==a||xt.current||di?(typeof c=="function"&&(Tf(e,n,c,i),a=e.memoizedState),(l=di||Dg(e,n,l,i,f,a,u))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=i,e.memoizedState=a),o.props=i,o.state=a,o.context=u,i=l):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),i=!1)}else{o=e.stateNode,z1(t,e),l=e.memoizedProps,u=e.type===e.elementType?l:rn(e.type,l),o.props=u,h=e.pendingProps,f=o.context,a=n.contextType,typeof a=="object"&&a!==null?a=Qt(a):(a=St(n)?wr:it.current,a=Ns(e,a));var d=n.getDerivedStateFromProps;(c=typeof d=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==h||f!==a)&&Bg(e,o,i,a),di=!1,f=e.memoizedState,o.state=f,wu(e,i,o,r);var p=e.memoizedState;l!==h||f!==p||xt.current||di?(typeof d=="function"&&(Tf(e,n,d,i),p=e.memoizedState),(u=di||Dg(e,n,u,i,f,p,a)||!1)?(c||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(i,p,a),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(i,p,a)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),e.memoizedProps=i,e.memoizedState=p),o.props=i,o.state=p,o.context=a,i=u):(typeof o.componentDidUpdate!="function"||l===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),i=!1)}return Rf(t,e,n,i,s,r)}function Rf(t,e,n,i,r,s){cw(t,e);var o=(e.flags&128)!==0;if(!i&&!o)return r&&_g(e,n,!1),ri(t,e,s);i=e.stateNode,dE.current=e;var l=o&&typeof n.getDerivedStateFromError!="function"?null:i.render();return e.flags|=1,t!==null&&o?(e.child=As(e,t.child,null,s),e.child=As(e,null,l,s)):ot(t,e,l,s),e.memoizedState=i.state,r&&_g(e,n,!0),e.child}function hw(t){var e=t.stateNode;e.pendingContext?Ng(t,e.pendingContext,e.pendingContext!==e.context):e.context&&Ng(t,e.context,!1),Np(t,e.containerInfo)}function Hg(t,e,n,i,r){return _s(),xp(r),e.flags|=256,ot(t,e,n,i),e.child}var If={dehydrated:null,treeContext:null,retryLane:0};function Df(t){return{baseLanes:t,cachePool:null,transitions:null}}function fw(t,e,n){var i=e.pendingProps,r=ke.current,s=!1,o=(e.flags&128)!==0,l;if((l=o)||(l=t!==null&&t.memoizedState===null?!1:(r&2)!==0),l?(s=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(r|=1),pe(ke,r&1),t===null)return _f(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=i.children,t=i.fallback,s?(i=e.mode,s=e.child,o={mode:"hidden",children:o},!(i&1)&&s!==null?(s.childLanes=0,s.pendingProps=o):s=vc(o,i,0,null),t=mr(t,i,n,null),s.return=e,t.return=e,s.sibling=t,e.child=s,e.child.memoizedState=Df(n),e.memoizedState=If,t):Ip(e,o));if(r=t.memoizedState,r!==null&&(l=r.dehydrated,l!==null))return pE(t,e,o,i,l,r,n);if(s){s=i.fallback,o=e.mode,r=t.child,l=r.sibling;var a={mode:"hidden",children:i.children};return!(o&1)&&e.child!==r?(i=e.child,i.childLanes=0,i.pendingProps=a,e.deletions=null):(i=Ii(r,a),i.subtreeFlags=r.subtreeFlags&14680064),l!==null?s=Ii(l,s):(s=mr(s,o,n,null),s.flags|=2),s.return=e,i.return=e,i.sibling=s,e.child=i,i=s,s=e.child,o=t.child.memoizedState,o=o===null?Df(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=t.childLanes&~n,e.memoizedState=If,i}return s=t.child,t=s.sibling,i=Ii(s,{mode:"visible",children:i.children}),!(e.mode&1)&&(i.lanes=n),i.return=e,i.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=i,e.memoizedState=null,i}function Ip(t,e){return e=vc({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function na(t,e,n,i){return i!==null&&xp(i),As(e,t.child,null,n),t=Ip(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function pE(t,e,n,i,r,s,o){if(n)return e.flags&256?(e.flags&=-257,i=ph(Error(H(422))),na(t,e,o,i)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(s=i.fallback,r=e.mode,i=vc({mode:"visible",children:i.children},r,0,null),s=mr(s,r,o,null),s.flags|=2,i.return=e,s.return=e,i.sibling=s,e.child=i,e.mode&1&&As(e,t.child,null,o),e.child.memoizedState=Df(o),e.memoizedState=If,s);if(!(e.mode&1))return na(t,e,o,null);if(r.data==="$!"){if(i=r.nextSibling&&r.nextSibling.dataset,i)var l=i.dgst;return i=l,s=Error(H(419)),i=ph(s,i,void 0),na(t,e,o,i)}if(l=(o&t.childLanes)!==0,yt||l){if(i=He,i!==null){switch(o&-o){case 4:r=2;break;case 16:r=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:r=32;break;case 536870912:r=268435456;break;default:r=0}r=r&(i.suspendedLanes|o)?0:r,r!==0&&r!==s.retryLane&&(s.retryLane=r,ii(t,r),dn(i,t,r,-1))}return jp(),i=ph(Error(H(421))),na(t,e,o,i)}return r.data==="$?"?(e.flags|=128,e.child=t.child,e=_E.bind(null,t),r._reactRetry=e,null):(t=s.treeContext,Tt=Mi(r.nextSibling),Ot=e,xe=!0,on=null,t!==null&&(zt[$t++]=Qn,zt[$t++]=Xn,zt[$t++]=xr,Qn=t.id,Xn=t.overflow,xr=e),e=Ip(e,i.children),e.flags|=4096,e)}function Wg(t,e,n){t.lanes|=e;var i=t.alternate;i!==null&&(i.lanes|=e),Af(t.return,e,n)}function mh(t,e,n,i,r){var s=t.memoizedState;s===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:i,tail:n,tailMode:r}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=i,s.tail=n,s.tailMode=r)}function dw(t,e,n){var i=e.pendingProps,r=i.revealOrder,s=i.tail;if(ot(t,e,i.children,n),i=ke.current,i&2)i=i&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Wg(t,n,e);else if(t.tag===19)Wg(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}i&=1}if(pe(ke,i),!(e.mode&1))e.memoizedState=null;else switch(r){case"forwards":for(n=e.child,r=null;n!==null;)t=n.alternate,t!==null&&xu(t)===null&&(r=n),n=n.sibling;n=r,n===null?(r=e.child,e.child=null):(r=n.sibling,n.sibling=null),mh(e,!1,r,n,s);break;case"backwards":for(n=null,r=e.child,e.child=null;r!==null;){if(t=r.alternate,t!==null&&xu(t)===null){e.child=r;break}t=r.sibling,r.sibling=n,n=r,r=t}mh(e,!0,n,null,s);break;case"together":mh(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function Ha(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function ri(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),kr|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(H(153));if(e.child!==null){for(t=e.child,n=Ii(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=Ii(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function mE(t,e,n){switch(e.tag){case 3:hw(e),_s();break;case 5:$1(e);break;case 1:St(e.type)&&pu(e);break;case 4:Np(e,e.stateNode.containerInfo);break;case 10:var i=e.type._context,r=e.memoizedProps.value;pe(yu,i._currentValue),i._currentValue=r;break;case 13:if(i=e.memoizedState,i!==null)return i.dehydrated!==null?(pe(ke,ke.current&1),e.flags|=128,null):n&e.child.childLanes?fw(t,e,n):(pe(ke,ke.current&1),t=ri(t,e,n),t!==null?t.sibling:null);pe(ke,ke.current&1);break;case 19:if(i=(n&e.childLanes)!==0,t.flags&128){if(i)return dw(t,e,n);e.flags|=128}if(r=e.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),pe(ke,ke.current),i)break;return null;case 22:case 23:return e.lanes=0,uw(t,e,n)}return ri(t,e,n)}var pw,Bf,mw,gw;pw=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Bf=function(){};mw=function(t,e,n,i){var r=t.memoizedProps;if(r!==i){t=e.stateNode,cr(Bn.current);var s=null;switch(n){case"input":r=rf(t,r),i=rf(t,i),s=[];break;case"select":r=Ce({},r,{value:void 0}),i=Ce({},i,{value:void 0}),s=[];break;case"textarea":r=lf(t,r),i=lf(t,i),s=[];break;default:typeof r.onClick!="function"&&typeof i.onClick=="function"&&(t.onclick=fu)}uf(n,i);var o;n=null;for(u in r)if(!i.hasOwnProperty(u)&&r.hasOwnProperty(u)&&r[u]!=null)if(u==="style"){var l=r[u];for(o in l)l.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Ko.hasOwnProperty(u)?s||(s=[]):(s=s||[]).push(u,null));for(u in i){var a=i[u];if(l=r!=null?r[u]:void 0,i.hasOwnProperty(u)&&a!==l&&(a!=null||l!=null))if(u==="style")if(l){for(o in l)!l.hasOwnProperty(o)||a&&a.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in a)a.hasOwnProperty(o)&&l[o]!==a[o]&&(n||(n={}),n[o]=a[o])}else n||(s||(s=[]),s.push(u,n)),n=a;else u==="dangerouslySetInnerHTML"?(a=a?a.__html:void 0,l=l?l.__html:void 0,a!=null&&l!==a&&(s=s||[]).push(u,a)):u==="children"?typeof a!="string"&&typeof a!="number"||(s=s||[]).push(u,""+a):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Ko.hasOwnProperty(u)?(a!=null&&u==="onScroll"&&ve("scroll",t),s||l===a||(s=[])):(s=s||[]).push(u,a))}n&&(s=s||[]).push("style",n);var u=s;(e.updateQueue=u)&&(e.flags|=4)}};gw=function(t,e,n,i){n!==i&&(e.flags|=4)};function oo(t,e){if(!xe)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:i.sibling=null}}function Ze(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,i=0;if(e)for(var r=t.child;r!==null;)n|=r.lanes|r.childLanes,i|=r.subtreeFlags&14680064,i|=r.flags&14680064,r.return=t,r=r.sibling;else for(r=t.child;r!==null;)n|=r.lanes|r.childLanes,i|=r.subtreeFlags,i|=r.flags,r.return=t,r=r.sibling;return t.subtreeFlags|=i,t.childLanes=n,e}function gE(t,e,n){var i=e.pendingProps;switch(wp(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ze(e),null;case 1:return St(e.type)&&du(),Ze(e),null;case 3:return i=e.stateNode,Ts(),we(xt),we(it),Ap(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(t===null||t.child===null)&&(ea(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,on!==null&&(Wf(on),on=null))),Bf(t,e),Ze(e),null;case 5:_p(e);var r=cr(rl.current);if(n=e.type,t!==null&&e.stateNode!=null)mw(t,e,n,i,r),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!i){if(e.stateNode===null)throw Error(H(166));return Ze(e),null}if(t=cr(Bn.current),ea(e)){i=e.stateNode,n=e.type;var s=e.memoizedProps;switch(i[Mn]=e,i[nl]=s,t=(e.mode&1)!==0,n){case"dialog":ve("cancel",i),ve("close",i);break;case"iframe":case"object":case"embed":ve("load",i);break;case"video":case"audio":for(r=0;r<bo.length;r++)ve(bo[r],i);break;case"source":ve("error",i);break;case"img":case"image":case"link":ve("error",i),ve("load",i);break;case"details":ve("toggle",i);break;case"input":Zm(i,s),ve("invalid",i);break;case"select":i._wrapperState={wasMultiple:!!s.multiple},ve("invalid",i);break;case"textarea":tg(i,s),ve("invalid",i)}uf(n,s),r=null;for(var o in s)if(s.hasOwnProperty(o)){var l=s[o];o==="children"?typeof l=="string"?i.textContent!==l&&(s.suppressHydrationWarning!==!0&&Zl(i.textContent,l,t),r=["children",l]):typeof l=="number"&&i.textContent!==""+l&&(s.suppressHydrationWarning!==!0&&Zl(i.textContent,l,t),r=["children",""+l]):Ko.hasOwnProperty(o)&&l!=null&&o==="onScroll"&&ve("scroll",i)}switch(n){case"input":Ul(i),eg(i,s,!0);break;case"textarea":Ul(i),ng(i);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(i.onclick=fu)}i=r,e.updateQueue=i,i!==null&&(e.flags|=4)}else{o=r.nodeType===9?r:r.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=Wv(n)),t==="http://www.w3.org/1999/xhtml"?n==="script"?(t=o.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof i.is=="string"?t=o.createElement(n,{is:i.is}):(t=o.createElement(n),n==="select"&&(o=t,i.multiple?o.multiple=!0:i.size&&(o.size=i.size))):t=o.createElementNS(t,n),t[Mn]=e,t[nl]=i,pw(t,e,!1,!1),e.stateNode=t;e:{switch(o=cf(n,i),n){case"dialog":ve("cancel",t),ve("close",t),r=i;break;case"iframe":case"object":case"embed":ve("load",t),r=i;break;case"video":case"audio":for(r=0;r<bo.length;r++)ve(bo[r],t);r=i;break;case"source":ve("error",t),r=i;break;case"img":case"image":case"link":ve("error",t),ve("load",t),r=i;break;case"details":ve("toggle",t),r=i;break;case"input":Zm(t,i),r=rf(t,i),ve("invalid",t);break;case"option":r=i;break;case"select":t._wrapperState={wasMultiple:!!i.multiple},r=Ce({},i,{value:void 0}),ve("invalid",t);break;case"textarea":tg(t,i),r=lf(t,i),ve("invalid",t);break;default:r=i}uf(n,r),l=r;for(s in l)if(l.hasOwnProperty(s)){var a=l[s];s==="style"?qv(t,a):s==="dangerouslySetInnerHTML"?(a=a?a.__html:void 0,a!=null&&Uv(t,a)):s==="children"?typeof a=="string"?(n!=="textarea"||a!=="")&&qo(t,a):typeof a=="number"&&qo(t,""+a):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(Ko.hasOwnProperty(s)?a!=null&&s==="onScroll"&&ve("scroll",t):a!=null&&rp(t,s,a,o))}switch(n){case"input":Ul(t),eg(t,i,!1);break;case"textarea":Ul(t),ng(t);break;case"option":i.value!=null&&t.setAttribute("value",""+Li(i.value));break;case"select":t.multiple=!!i.multiple,s=i.value,s!=null?as(t,!!i.multiple,s,!1):i.defaultValue!=null&&as(t,!!i.multiple,i.defaultValue,!0);break;default:typeof r.onClick=="function"&&(t.onclick=fu)}switch(n){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}}i&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return Ze(e),null;case 6:if(t&&e.stateNode!=null)gw(t,e,t.memoizedProps,i);else{if(typeof i!="string"&&e.stateNode===null)throw Error(H(166));if(n=cr(rl.current),cr(Bn.current),ea(e)){if(i=e.stateNode,n=e.memoizedProps,i[Mn]=e,(s=i.nodeValue!==n)&&(t=Ot,t!==null))switch(t.tag){case 3:Zl(i.nodeValue,n,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Zl(i.nodeValue,n,(t.mode&1)!==0)}s&&(e.flags|=4)}else i=(n.nodeType===9?n:n.ownerDocument).createTextNode(i),i[Mn]=e,e.stateNode=i}return Ze(e),null;case 13:if(we(ke),i=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(xe&&Tt!==null&&e.mode&1&&!(e.flags&128))I1(),_s(),e.flags|=98560,s=!1;else if(s=ea(e),i!==null&&i.dehydrated!==null){if(t===null){if(!s)throw Error(H(318));if(s=e.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(H(317));s[Mn]=e}else _s(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;Ze(e),s=!1}else on!==null&&(Wf(on),on=null),s=!0;if(!s)return e.flags&65536?e:null}return e.flags&128?(e.lanes=n,e):(i=i!==null,i!==(t!==null&&t.memoizedState!==null)&&i&&(e.child.flags|=8192,e.mode&1&&(t===null||ke.current&1?$e===0&&($e=3):jp())),e.updateQueue!==null&&(e.flags|=4),Ze(e),null);case 4:return Ts(),Bf(t,e),t===null&&el(e.stateNode.containerInfo),Ze(e),null;case 10:return bp(e.type._context),Ze(e),null;case 17:return St(e.type)&&du(),Ze(e),null;case 19:if(we(ke),s=e.memoizedState,s===null)return Ze(e),null;if(i=(e.flags&128)!==0,o=s.rendering,o===null)if(i)oo(s,!1);else{if($e!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(o=xu(t),o!==null){for(e.flags|=128,oo(s,!1),i=o.updateQueue,i!==null&&(e.updateQueue=i,e.flags|=4),e.subtreeFlags=0,i=n,n=e.child;n!==null;)s=n,t=i,s.flags&=14680066,o=s.alternate,o===null?(s.childLanes=0,s.lanes=t,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=o.childLanes,s.lanes=o.lanes,s.child=o.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=o.memoizedProps,s.memoizedState=o.memoizedState,s.updateQueue=o.updateQueue,s.type=o.type,t=o.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),n=n.sibling;return pe(ke,ke.current&1|2),e.child}t=t.sibling}s.tail!==null&&Re()>Os&&(e.flags|=128,i=!0,oo(s,!1),e.lanes=4194304)}else{if(!i)if(t=xu(o),t!==null){if(e.flags|=128,i=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),oo(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!xe)return Ze(e),null}else 2*Re()-s.renderingStartTime>Os&&n!==1073741824&&(e.flags|=128,i=!0,oo(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Re(),e.sibling=null,n=ke.current,pe(ke,i?n&1|2:n&1),e):(Ze(e),null);case 22:case 23:return $p(),i=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==i&&(e.flags|=8192),i&&e.mode&1?Nt&1073741824&&(Ze(e),e.subtreeFlags&6&&(e.flags|=8192)):Ze(e),null;case 24:return null;case 25:return null}throw Error(H(156,e.tag))}function yE(t,e){switch(wp(e),e.tag){case 1:return St(e.type)&&du(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ts(),we(xt),we(it),Ap(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return _p(e),null;case 13:if(we(ke),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(H(340));_s()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return we(ke),null;case 4:return Ts(),null;case 10:return bp(e.type._context),null;case 22:case 23:return $p(),null;case 24:return null;default:return null}}var ia=!1,tt=!1,vE=typeof WeakSet=="function"?WeakSet:Set,Y=null;function ts(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(i){Ne(t,e,i)}else n.current=null}function Lf(t,e,n){try{n()}catch(i){Ne(t,e,i)}}var Ug=!1;function wE(t,e){if(xf=uu,t=S1(),yp(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var r=i.anchorOffset,s=i.focusNode;i=i.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,l=-1,a=-1,u=0,c=0,h=t,f=null;t:for(;;){for(var d;h!==n||r!==0&&h.nodeType!==3||(l=o+r),h!==s||i!==0&&h.nodeType!==3||(a=o+i),h.nodeType===3&&(o+=h.nodeValue.length),(d=h.firstChild)!==null;)f=h,h=d;for(;;){if(h===t)break t;if(f===n&&++u===r&&(l=o),f===s&&++c===i&&(a=o),(d=h.nextSibling)!==null)break;h=f,f=h.parentNode}h=d}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(Sf={focusedElem:t,selectionRange:n},uu=!1,Y=e;Y!==null;)if(e=Y,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Y=t;else for(;Y!==null;){e=Y;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var g=p.memoizedProps,S=p.memoizedState,m=e.stateNode,y=m.getSnapshotBeforeUpdate(e.elementType===e.type?g:rn(e.type,g),S);m.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var v=e.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(H(163))}}catch(x){Ne(e,e.return,x)}if(t=e.sibling,t!==null){t.return=e.return,Y=t;break}Y=e.return}return p=Ug,Ug=!1,p}function Lo(t,e,n){var i=e.updateQueue;if(i=i!==null?i.lastEffect:null,i!==null){var r=i=i.next;do{if((r.tag&t)===t){var s=r.destroy;r.destroy=void 0,s!==void 0&&Lf(e,n,s)}r=r.next}while(r!==i)}}function gc(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var i=n.create;n.destroy=i()}n=n.next}while(n!==e)}}function zf(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function yw(t){var e=t.alternate;e!==null&&(t.alternate=null,yw(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Mn],delete e[nl],delete e[Cf],delete e[tE],delete e[nE])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function vw(t){return t.tag===5||t.tag===3||t.tag===4}function Kg(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||vw(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function $f(t,e,n){var i=t.tag;if(i===5||i===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=fu));else if(i!==4&&(t=t.child,t!==null))for($f(t,e,n),t=t.sibling;t!==null;)$f(t,e,n),t=t.sibling}function jf(t,e,n){var i=t.tag;if(i===5||i===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(i!==4&&(t=t.child,t!==null))for(jf(t,e,n),t=t.sibling;t!==null;)jf(t,e,n),t=t.sibling}var Ue=null,sn=!1;function ci(t,e,n){for(n=n.child;n!==null;)ww(t,e,n),n=n.sibling}function ww(t,e,n){if(Dn&&typeof Dn.onCommitFiberUnmount=="function")try{Dn.onCommitFiberUnmount(ac,n)}catch{}switch(n.tag){case 5:tt||ts(n,e);case 6:var i=Ue,r=sn;Ue=null,ci(t,e,n),Ue=i,sn=r,Ue!==null&&(sn?(t=Ue,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Ue.removeChild(n.stateNode));break;case 18:Ue!==null&&(sn?(t=Ue,n=n.stateNode,t.nodeType===8?ah(t.parentNode,n):t.nodeType===1&&ah(t,n),Go(t)):ah(Ue,n.stateNode));break;case 4:i=Ue,r=sn,Ue=n.stateNode.containerInfo,sn=!0,ci(t,e,n),Ue=i,sn=r;break;case 0:case 11:case 14:case 15:if(!tt&&(i=n.updateQueue,i!==null&&(i=i.lastEffect,i!==null))){r=i=i.next;do{var s=r,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&Lf(n,e,o),r=r.next}while(r!==i)}ci(t,e,n);break;case 1:if(!tt&&(ts(n,e),i=n.stateNode,typeof i.componentWillUnmount=="function"))try{i.props=n.memoizedProps,i.state=n.memoizedState,i.componentWillUnmount()}catch(l){Ne(n,e,l)}ci(t,e,n);break;case 21:ci(t,e,n);break;case 22:n.mode&1?(tt=(i=tt)||n.memoizedState!==null,ci(t,e,n),tt=i):ci(t,e,n);break;default:ci(t,e,n)}}function qg(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new vE),e.forEach(function(i){var r=AE.bind(null,t,i);n.has(i)||(n.add(i),i.then(r,r))})}}function nn(t,e){var n=e.deletions;if(n!==null)for(var i=0;i<n.length;i++){var r=n[i];try{var s=t,o=e,l=o;e:for(;l!==null;){switch(l.tag){case 5:Ue=l.stateNode,sn=!1;break e;case 3:Ue=l.stateNode.containerInfo,sn=!0;break e;case 4:Ue=l.stateNode.containerInfo,sn=!0;break e}l=l.return}if(Ue===null)throw Error(H(160));ww(s,o,r),Ue=null,sn=!1;var a=r.alternate;a!==null&&(a.return=null),r.return=null}catch(u){Ne(r,e,u)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)xw(e,t),e=e.sibling}function xw(t,e){var n=t.alternate,i=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(nn(e,t),kn(t),i&4){try{Lo(3,t,t.return),gc(3,t)}catch(g){Ne(t,t.return,g)}try{Lo(5,t,t.return)}catch(g){Ne(t,t.return,g)}}break;case 1:nn(e,t),kn(t),i&512&&n!==null&&ts(n,n.return);break;case 5:if(nn(e,t),kn(t),i&512&&n!==null&&ts(n,n.return),t.flags&32){var r=t.stateNode;try{qo(r,"")}catch(g){Ne(t,t.return,g)}}if(i&4&&(r=t.stateNode,r!=null)){var s=t.memoizedProps,o=n!==null?n.memoizedProps:s,l=t.type,a=t.updateQueue;if(t.updateQueue=null,a!==null)try{l==="input"&&s.type==="radio"&&s.name!=null&&Vv(r,s),cf(l,o);var u=cf(l,s);for(o=0;o<a.length;o+=2){var c=a[o],h=a[o+1];c==="style"?qv(r,h):c==="dangerouslySetInnerHTML"?Uv(r,h):c==="children"?qo(r,h):rp(r,c,h,u)}switch(l){case"input":sf(r,s);break;case"textarea":Hv(r,s);break;case"select":var f=r._wrapperState.wasMultiple;r._wrapperState.wasMultiple=!!s.multiple;var d=s.value;d!=null?as(r,!!s.multiple,d,!1):f!==!!s.multiple&&(s.defaultValue!=null?as(r,!!s.multiple,s.defaultValue,!0):as(r,!!s.multiple,s.multiple?[]:"",!1))}r[nl]=s}catch(g){Ne(t,t.return,g)}}break;case 6:if(nn(e,t),kn(t),i&4){if(t.stateNode===null)throw Error(H(162));r=t.stateNode,s=t.memoizedProps;try{r.nodeValue=s}catch(g){Ne(t,t.return,g)}}break;case 3:if(nn(e,t),kn(t),i&4&&n!==null&&n.memoizedState.isDehydrated)try{Go(e.containerInfo)}catch(g){Ne(t,t.return,g)}break;case 4:nn(e,t),kn(t);break;case 13:nn(e,t),kn(t),r=t.child,r.flags&8192&&(s=r.memoizedState!==null,r.stateNode.isHidden=s,!s||r.alternate!==null&&r.alternate.memoizedState!==null||(Lp=Re())),i&4&&qg(t);break;case 22:if(c=n!==null&&n.memoizedState!==null,t.mode&1?(tt=(u=tt)||c,nn(e,t),tt=u):nn(e,t),kn(t),i&8192){if(u=t.memoizedState!==null,(t.stateNode.isHidden=u)&&!c&&t.mode&1)for(Y=t,c=t.child;c!==null;){for(h=Y=c;Y!==null;){switch(f=Y,d=f.child,f.tag){case 0:case 11:case 14:case 15:Lo(4,f,f.return);break;case 1:ts(f,f.return);var p=f.stateNode;if(typeof p.componentWillUnmount=="function"){i=f,n=f.return;try{e=i,p.props=e.memoizedProps,p.state=e.memoizedState,p.componentWillUnmount()}catch(g){Ne(i,n,g)}}break;case 5:ts(f,f.return);break;case 22:if(f.memoizedState!==null){Qg(h);continue}}d!==null?(d.return=f,Y=d):Qg(h)}c=c.sibling}e:for(c=null,h=t;;){if(h.tag===5){if(c===null){c=h;try{r=h.stateNode,u?(s=r.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(l=h.stateNode,a=h.memoizedProps.style,o=a!=null&&a.hasOwnProperty("display")?a.display:null,l.style.display=Kv("display",o))}catch(g){Ne(t,t.return,g)}}}else if(h.tag===6){if(c===null)try{h.stateNode.nodeValue=u?"":h.memoizedProps}catch(g){Ne(t,t.return,g)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===t)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===t)break e;for(;h.sibling===null;){if(h.return===null||h.return===t)break e;c===h&&(c=null),h=h.return}c===h&&(c=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:nn(e,t),kn(t),i&4&&qg(t);break;case 21:break;default:nn(e,t),kn(t)}}function kn(t){var e=t.flags;if(e&2){try{e:{for(var n=t.return;n!==null;){if(vw(n)){var i=n;break e}n=n.return}throw Error(H(160))}switch(i.tag){case 5:var r=i.stateNode;i.flags&32&&(qo(r,""),i.flags&=-33);var s=Kg(t);jf(t,s,r);break;case 3:case 4:var o=i.stateNode.containerInfo,l=Kg(t);$f(t,l,o);break;default:throw Error(H(161))}}catch(a){Ne(t,t.return,a)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function xE(t,e,n){Y=t,Sw(t)}function Sw(t,e,n){for(var i=(t.mode&1)!==0;Y!==null;){var r=Y,s=r.child;if(r.tag===22&&i){var o=r.memoizedState!==null||ia;if(!o){var l=r.alternate,a=l!==null&&l.memoizedState!==null||tt;l=ia;var u=tt;if(ia=o,(tt=a)&&!u)for(Y=r;Y!==null;)o=Y,a=o.child,o.tag===22&&o.memoizedState!==null?Xg(r):a!==null?(a.return=o,Y=a):Xg(r);for(;s!==null;)Y=s,Sw(s),s=s.sibling;Y=r,ia=l,tt=u}Yg(t)}else r.subtreeFlags&8772&&s!==null?(s.return=r,Y=s):Yg(t)}}function Yg(t){for(;Y!==null;){var e=Y;if(e.flags&8772){var n=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:tt||gc(5,e);break;case 1:var i=e.stateNode;if(e.flags&4&&!tt)if(n===null)i.componentDidMount();else{var r=e.elementType===e.type?n.memoizedProps:rn(e.type,n.memoizedProps);i.componentDidUpdate(r,n.memoizedState,i.__reactInternalSnapshotBeforeUpdate)}var s=e.updateQueue;s!==null&&Pg(e,s,i);break;case 3:var o=e.updateQueue;if(o!==null){if(n=null,e.child!==null)switch(e.child.tag){case 5:n=e.child.stateNode;break;case 1:n=e.child.stateNode}Pg(e,o,n)}break;case 5:var l=e.stateNode;if(n===null&&e.flags&4){n=l;var a=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":a.autoFocus&&n.focus();break;case"img":a.src&&(n.src=a.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var u=e.alternate;if(u!==null){var c=u.memoizedState;if(c!==null){var h=c.dehydrated;h!==null&&Go(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(H(163))}tt||e.flags&512&&zf(e)}catch(f){Ne(e,e.return,f)}}if(e===t){Y=null;break}if(n=e.sibling,n!==null){n.return=e.return,Y=n;break}Y=e.return}}function Qg(t){for(;Y!==null;){var e=Y;if(e===t){Y=null;break}var n=e.sibling;if(n!==null){n.return=e.return,Y=n;break}Y=e.return}}function Xg(t){for(;Y!==null;){var e=Y;try{switch(e.tag){case 0:case 11:case 15:var n=e.return;try{gc(4,e)}catch(a){Ne(e,n,a)}break;case 1:var i=e.stateNode;if(typeof i.componentDidMount=="function"){var r=e.return;try{i.componentDidMount()}catch(a){Ne(e,r,a)}}var s=e.return;try{zf(e)}catch(a){Ne(e,s,a)}break;case 5:var o=e.return;try{zf(e)}catch(a){Ne(e,o,a)}}}catch(a){Ne(e,e.return,a)}if(e===t){Y=null;break}var l=e.sibling;if(l!==null){l.return=e.return,Y=l;break}Y=e.return}}var SE=Math.ceil,bu=ai.ReactCurrentDispatcher,Dp=ai.ReactCurrentOwner,Kt=ai.ReactCurrentBatchConfig,le=0,He=null,De=null,Qe=0,Nt=0,ns=Ui(0),$e=0,al=null,kr=0,yc=0,Bp=0,zo=null,pt=null,Lp=0,Os=1/0,Un=null,Cu=!1,Ff=null,Pi=null,ra=!1,Ci=null,Eu=0,$o=0,Vf=null,Wa=-1,Ua=0;function at(){return le&6?Re():Wa!==-1?Wa:Wa=Re()}function Ri(t){return t.mode&1?le&2&&Qe!==0?Qe&-Qe:rE.transition!==null?(Ua===0&&(Ua=s1()),Ua):(t=ce,t!==0||(t=window.event,t=t===void 0?16:f1(t.type)),t):1}function dn(t,e,n,i){if(50<$o)throw $o=0,Vf=null,Error(H(185));Tl(t,n,i),(!(le&2)||t!==He)&&(t===He&&(!(le&2)&&(yc|=n),$e===4&&wi(t,Qe)),kt(t,i),n===1&&le===0&&!(e.mode&1)&&(Os=Re()+500,dc&&Ki()))}function kt(t,e){var n=t.callbackNode;r2(t,e);var i=au(t,t===He?Qe:0);if(i===0)n!==null&&sg(n),t.callbackNode=null,t.callbackPriority=0;else if(e=i&-i,t.callbackPriority!==e){if(n!=null&&sg(n),e===1)t.tag===0?iE(Gg.bind(null,t)):O1(Gg.bind(null,t)),Z2(function(){!(le&6)&&Ki()}),n=null;else{switch(o1(i)){case 1:n=up;break;case 4:n=i1;break;case 16:n=lu;break;case 536870912:n=r1;break;default:n=lu}n=Tw(n,kw.bind(null,t))}t.callbackPriority=e,t.callbackNode=n}}function kw(t,e){if(Wa=-1,Ua=0,le&6)throw Error(H(327));var n=t.callbackNode;if(ds()&&t.callbackNode!==n)return null;var i=au(t,t===He?Qe:0);if(i===0)return null;if(i&30||i&t.expiredLanes||e)e=Nu(t,i);else{e=i;var r=le;le|=2;var s=Cw();(He!==t||Qe!==e)&&(Un=null,Os=Re()+500,pr(t,e));do try{CE();break}catch(l){bw(t,l)}while(!0);kp(),bu.current=s,le=r,De!==null?e=0:(He=null,Qe=0,e=$e)}if(e!==0){if(e===2&&(r=mf(t),r!==0&&(i=r,e=Hf(t,r))),e===1)throw n=al,pr(t,0),wi(t,i),kt(t,Re()),n;if(e===6)wi(t,i);else{if(r=t.current.alternate,!(i&30)&&!kE(r)&&(e=Nu(t,i),e===2&&(s=mf(t),s!==0&&(i=s,e=Hf(t,s))),e===1))throw n=al,pr(t,0),wi(t,i),kt(t,Re()),n;switch(t.finishedWork=r,t.finishedLanes=i,e){case 0:case 1:throw Error(H(345));case 2:ir(t,pt,Un);break;case 3:if(wi(t,i),(i&130023424)===i&&(e=Lp+500-Re(),10<e)){if(au(t,0)!==0)break;if(r=t.suspendedLanes,(r&i)!==i){at(),t.pingedLanes|=t.suspendedLanes&r;break}t.timeoutHandle=bf(ir.bind(null,t,pt,Un),e);break}ir(t,pt,Un);break;case 4:if(wi(t,i),(i&4194240)===i)break;for(e=t.eventTimes,r=-1;0<i;){var o=31-fn(i);s=1<<o,o=e[o],o>r&&(r=o),i&=~s}if(i=r,i=Re()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*SE(i/1960))-i,10<i){t.timeoutHandle=bf(ir.bind(null,t,pt,Un),i);break}ir(t,pt,Un);break;case 5:ir(t,pt,Un);break;default:throw Error(H(329))}}}return kt(t,Re()),t.callbackNode===n?kw.bind(null,t):null}function Hf(t,e){var n=zo;return t.current.memoizedState.isDehydrated&&(pr(t,e).flags|=256),t=Nu(t,e),t!==2&&(e=pt,pt=n,e!==null&&Wf(e)),t}function Wf(t){pt===null?pt=t:pt.push.apply(pt,t)}function kE(t){for(var e=t;;){if(e.flags&16384){var n=e.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var i=0;i<n.length;i++){var r=n[i],s=r.getSnapshot;r=r.value;try{if(!mn(s(),r))return!1}catch{return!1}}}if(n=e.child,e.subtreeFlags&16384&&n!==null)n.return=e,e=n;else{if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function wi(t,e){for(e&=~Bp,e&=~yc,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var n=31-fn(e),i=1<<n;t[n]=-1,e&=~i}}function Gg(t){if(le&6)throw Error(H(327));ds();var e=au(t,0);if(!(e&1))return kt(t,Re()),null;var n=Nu(t,e);if(t.tag!==0&&n===2){var i=mf(t);i!==0&&(e=i,n=Hf(t,i))}if(n===1)throw n=al,pr(t,0),wi(t,e),kt(t,Re()),n;if(n===6)throw Error(H(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,ir(t,pt,Un),kt(t,Re()),null}function zp(t,e){var n=le;le|=1;try{return t(e)}finally{le=n,le===0&&(Os=Re()+500,dc&&Ki())}}function br(t){Ci!==null&&Ci.tag===0&&!(le&6)&&ds();var e=le;le|=1;var n=Kt.transition,i=ce;try{if(Kt.transition=null,ce=1,t)return t()}finally{ce=i,Kt.transition=n,le=e,!(le&6)&&Ki()}}function $p(){Nt=ns.current,we(ns)}function pr(t,e){t.finishedWork=null,t.finishedLanes=0;var n=t.timeoutHandle;if(n!==-1&&(t.timeoutHandle=-1,J2(n)),De!==null)for(n=De.return;n!==null;){var i=n;switch(wp(i),i.tag){case 1:i=i.type.childContextTypes,i!=null&&du();break;case 3:Ts(),we(xt),we(it),Ap();break;case 5:_p(i);break;case 4:Ts();break;case 13:we(ke);break;case 19:we(ke);break;case 10:bp(i.type._context);break;case 22:case 23:$p()}n=n.return}if(He=t,De=t=Ii(t.current,null),Qe=Nt=e,$e=0,al=null,Bp=yc=kr=0,pt=zo=null,ur!==null){for(e=0;e<ur.length;e++)if(n=ur[e],i=n.interleaved,i!==null){n.interleaved=null;var r=i.next,s=n.pending;if(s!==null){var o=s.next;s.next=r,i.next=o}n.pending=i}ur=null}return t}function bw(t,e){do{var n=De;try{if(kp(),Fa.current=ku,Su){for(var i=be.memoizedState;i!==null;){var r=i.queue;r!==null&&(r.pending=null),i=i.next}Su=!1}if(Sr=0,Fe=Le=be=null,Bo=!1,sl=0,Dp.current=null,n===null||n.return===null){$e=1,al=e,De=null;break}e:{var s=t,o=n.return,l=n,a=e;if(e=Qe,l.flags|=32768,a!==null&&typeof a=="object"&&typeof a.then=="function"){var u=a,c=l,h=c.tag;if(!(c.mode&1)&&(h===0||h===11||h===15)){var f=c.alternate;f?(c.updateQueue=f.updateQueue,c.memoizedState=f.memoizedState,c.lanes=f.lanes):(c.updateQueue=null,c.memoizedState=null)}var d=zg(o);if(d!==null){d.flags&=-257,$g(d,o,l,s,e),d.mode&1&&Lg(s,u,e),e=d,a=u;var p=e.updateQueue;if(p===null){var g=new Set;g.add(a),e.updateQueue=g}else p.add(a);break e}else{if(!(e&1)){Lg(s,u,e),jp();break e}a=Error(H(426))}}else if(xe&&l.mode&1){var S=zg(o);if(S!==null){!(S.flags&65536)&&(S.flags|=256),$g(S,o,l,s,e),xp(Ms(a,l));break e}}s=a=Ms(a,l),$e!==4&&($e=2),zo===null?zo=[s]:zo.push(s),s=o;do{switch(s.tag){case 3:s.flags|=65536,e&=-e,s.lanes|=e;var m=ow(s,a,e);Og(s,m);break e;case 1:l=a;var y=s.type,v=s.stateNode;if(!(s.flags&128)&&(typeof y.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(Pi===null||!Pi.has(v)))){s.flags|=65536,e&=-e,s.lanes|=e;var x=lw(s,l,e);Og(s,x);break e}}s=s.return}while(s!==null)}Nw(n)}catch(b){e=b,De===n&&n!==null&&(De=n=n.return);continue}break}while(!0)}function Cw(){var t=bu.current;return bu.current=ku,t===null?ku:t}function jp(){($e===0||$e===3||$e===2)&&($e=4),He===null||!(kr&268435455)&&!(yc&268435455)||wi(He,Qe)}function Nu(t,e){var n=le;le|=2;var i=Cw();(He!==t||Qe!==e)&&(Un=null,pr(t,e));do try{bE();break}catch(r){bw(t,r)}while(!0);if(kp(),le=n,bu.current=i,De!==null)throw Error(H(261));return He=null,Qe=0,$e}function bE(){for(;De!==null;)Ew(De)}function CE(){for(;De!==null&&!QC();)Ew(De)}function Ew(t){var e=Aw(t.alternate,t,Nt);t.memoizedProps=t.pendingProps,e===null?Nw(t):De=e,Dp.current=null}function Nw(t){var e=t;do{var n=e.alternate;if(t=e.return,e.flags&32768){if(n=yE(n,e),n!==null){n.flags&=32767,De=n;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{$e=6,De=null;return}}else if(n=gE(n,e,Nt),n!==null){De=n;return}if(e=e.sibling,e!==null){De=e;return}De=e=t}while(e!==null);$e===0&&($e=5)}function ir(t,e,n){var i=ce,r=Kt.transition;try{Kt.transition=null,ce=1,EE(t,e,n,i)}finally{Kt.transition=r,ce=i}return null}function EE(t,e,n,i){do ds();while(Ci!==null);if(le&6)throw Error(H(327));n=t.finishedWork;var r=t.finishedLanes;if(n===null)return null;if(t.finishedWork=null,t.finishedLanes=0,n===t.current)throw Error(H(177));t.callbackNode=null,t.callbackPriority=0;var s=n.lanes|n.childLanes;if(s2(t,s),t===He&&(De=He=null,Qe=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||ra||(ra=!0,Tw(lu,function(){return ds(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=Kt.transition,Kt.transition=null;var o=ce;ce=1;var l=le;le|=4,Dp.current=null,wE(t,n),xw(n,t),U2(Sf),uu=!!xf,Sf=xf=null,t.current=n,xE(n),XC(),le=l,ce=o,Kt.transition=s}else t.current=n;if(ra&&(ra=!1,Ci=t,Eu=r),s=t.pendingLanes,s===0&&(Pi=null),ZC(n.stateNode),kt(t,Re()),e!==null)for(i=t.onRecoverableError,n=0;n<e.length;n++)r=e[n],i(r.value,{componentStack:r.stack,digest:r.digest});if(Cu)throw Cu=!1,t=Ff,Ff=null,t;return Eu&1&&t.tag!==0&&ds(),s=t.pendingLanes,s&1?t===Vf?$o++:($o=0,Vf=t):$o=0,Ki(),null}function ds(){if(Ci!==null){var t=o1(Eu),e=Kt.transition,n=ce;try{if(Kt.transition=null,ce=16>t?16:t,Ci===null)var i=!1;else{if(t=Ci,Ci=null,Eu=0,le&6)throw Error(H(331));var r=le;for(le|=4,Y=t.current;Y!==null;){var s=Y,o=s.child;if(Y.flags&16){var l=s.deletions;if(l!==null){for(var a=0;a<l.length;a++){var u=l[a];for(Y=u;Y!==null;){var c=Y;switch(c.tag){case 0:case 11:case 15:Lo(8,c,s)}var h=c.child;if(h!==null)h.return=c,Y=h;else for(;Y!==null;){c=Y;var f=c.sibling,d=c.return;if(yw(c),c===u){Y=null;break}if(f!==null){f.return=d,Y=f;break}Y=d}}}var p=s.alternate;if(p!==null){var g=p.child;if(g!==null){p.child=null;do{var S=g.sibling;g.sibling=null,g=S}while(g!==null)}}Y=s}}if(s.subtreeFlags&2064&&o!==null)o.return=s,Y=o;else e:for(;Y!==null;){if(s=Y,s.flags&2048)switch(s.tag){case 0:case 11:case 15:Lo(9,s,s.return)}var m=s.sibling;if(m!==null){m.return=s.return,Y=m;break e}Y=s.return}}var y=t.current;for(Y=y;Y!==null;){o=Y;var v=o.child;if(o.subtreeFlags&2064&&v!==null)v.return=o,Y=v;else e:for(o=y;Y!==null;){if(l=Y,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:gc(9,l)}}catch(b){Ne(l,l.return,b)}if(l===o){Y=null;break e}var x=l.sibling;if(x!==null){x.return=l.return,Y=x;break e}Y=l.return}}if(le=r,Ki(),Dn&&typeof Dn.onPostCommitFiberRoot=="function")try{Dn.onPostCommitFiberRoot(ac,t)}catch{}i=!0}return i}finally{ce=n,Kt.transition=e}}return!1}function Jg(t,e,n){e=Ms(n,e),e=ow(t,e,1),t=Oi(t,e,1),e=at(),t!==null&&(Tl(t,1,e),kt(t,e))}function Ne(t,e,n){if(t.tag===3)Jg(t,t,n);else for(;e!==null;){if(e.tag===3){Jg(e,t,n);break}else if(e.tag===1){var i=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(Pi===null||!Pi.has(i))){t=Ms(n,t),t=lw(e,t,1),e=Oi(e,t,1),t=at(),e!==null&&(Tl(e,1,t),kt(e,t));break}}e=e.return}}function NE(t,e,n){var i=t.pingCache;i!==null&&i.delete(e),e=at(),t.pingedLanes|=t.suspendedLanes&n,He===t&&(Qe&n)===n&&($e===4||$e===3&&(Qe&130023424)===Qe&&500>Re()-Lp?pr(t,0):Bp|=n),kt(t,e)}function _w(t,e){e===0&&(t.mode&1?(e=Yl,Yl<<=1,!(Yl&130023424)&&(Yl=4194304)):e=1);var n=at();t=ii(t,e),t!==null&&(Tl(t,e,n),kt(t,n))}function _E(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),_w(t,n)}function AE(t,e){var n=0;switch(t.tag){case 13:var i=t.stateNode,r=t.memoizedState;r!==null&&(n=r.retryLane);break;case 19:i=t.stateNode;break;default:throw Error(H(314))}i!==null&&i.delete(e),_w(t,n)}var Aw;Aw=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||xt.current)yt=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return yt=!1,mE(t,e,n);yt=!!(t.flags&131072)}else yt=!1,xe&&e.flags&1048576&&P1(e,gu,e.index);switch(e.lanes=0,e.tag){case 2:var i=e.type;Ha(t,e),t=e.pendingProps;var r=Ns(e,it.current);fs(e,n),r=Mp(null,e,i,t,r,n);var s=Op();return e.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,St(i)?(s=!0,pu(e)):s=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,Ep(e),r.updater=mc,e.stateNode=r,r._reactInternals=e,Mf(e,i,t,n),e=Rf(null,e,i,!0,s,n)):(e.tag=0,xe&&s&&vp(e),ot(null,e,r,n),e=e.child),e;case 16:i=e.elementType;e:{switch(Ha(t,e),t=e.pendingProps,r=i._init,i=r(i._payload),e.type=i,r=e.tag=ME(i),t=rn(i,t),r){case 0:e=Pf(null,e,i,t,n);break e;case 1:e=Vg(null,e,i,t,n);break e;case 11:e=jg(null,e,i,t,n);break e;case 14:e=Fg(null,e,i,rn(i.type,t),n);break e}throw Error(H(306,i,""))}return e;case 0:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:rn(i,r),Pf(t,e,i,r,n);case 1:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:rn(i,r),Vg(t,e,i,r,n);case 3:e:{if(hw(e),t===null)throw Error(H(387));i=e.pendingProps,s=e.memoizedState,r=s.element,z1(t,e),wu(e,i,null,n);var o=e.memoizedState;if(i=o.element,s.isDehydrated)if(s={element:i,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){r=Ms(Error(H(423)),e),e=Hg(t,e,i,n,r);break e}else if(i!==r){r=Ms(Error(H(424)),e),e=Hg(t,e,i,n,r);break e}else for(Tt=Mi(e.stateNode.containerInfo.firstChild),Ot=e,xe=!0,on=null,n=B1(e,null,i,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(_s(),i===r){e=ri(t,e,n);break e}ot(t,e,i,n)}e=e.child}return e;case 5:return $1(e),t===null&&_f(e),i=e.type,r=e.pendingProps,s=t!==null?t.memoizedProps:null,o=r.children,kf(i,r)?o=null:s!==null&&kf(i,s)&&(e.flags|=32),cw(t,e),ot(t,e,o,n),e.child;case 6:return t===null&&_f(e),null;case 13:return fw(t,e,n);case 4:return Np(e,e.stateNode.containerInfo),i=e.pendingProps,t===null?e.child=As(e,null,i,n):ot(t,e,i,n),e.child;case 11:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:rn(i,r),jg(t,e,i,r,n);case 7:return ot(t,e,e.pendingProps,n),e.child;case 8:return ot(t,e,e.pendingProps.children,n),e.child;case 12:return ot(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(i=e.type._context,r=e.pendingProps,s=e.memoizedProps,o=r.value,pe(yu,i._currentValue),i._currentValue=o,s!==null)if(mn(s.value,o)){if(s.children===r.children&&!xt.current){e=ri(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var l=s.dependencies;if(l!==null){o=s.child;for(var a=l.firstContext;a!==null;){if(a.context===i){if(s.tag===1){a=Zn(-1,n&-n),a.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),Af(s.return,n,e),l.lanes|=n;break}a=a.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(H(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Af(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}ot(t,e,r.children,n),e=e.child}return e;case 9:return r=e.type,i=e.pendingProps.children,fs(e,n),r=Qt(r),i=i(r),e.flags|=1,ot(t,e,i,n),e.child;case 14:return i=e.type,r=rn(i,e.pendingProps),r=rn(i.type,r),Fg(t,e,i,r,n);case 15:return aw(t,e,e.type,e.pendingProps,n);case 17:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:rn(i,r),Ha(t,e),e.tag=1,St(i)?(t=!0,pu(e)):t=!1,fs(e,n),sw(e,i,r),Mf(e,i,r,n),Rf(null,e,i,!0,t,n);case 19:return dw(t,e,n);case 22:return uw(t,e,n)}throw Error(H(156,e.tag))};function Tw(t,e){return n1(t,e)}function TE(t,e,n,i){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ft(t,e,n,i){return new TE(t,e,n,i)}function Fp(t){return t=t.prototype,!(!t||!t.isReactComponent)}function ME(t){if(typeof t=="function")return Fp(t)?1:0;if(t!=null){if(t=t.$$typeof,t===op)return 11;if(t===lp)return 14}return 2}function Ii(t,e){var n=t.alternate;return n===null?(n=Ft(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Ka(t,e,n,i,r,s){var o=2;if(i=t,typeof t=="function")Fp(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Kr:return mr(n.children,r,s,e);case sp:o=8,r|=8;break;case Zh:return t=Ft(12,n,e,r|2),t.elementType=Zh,t.lanes=s,t;case ef:return t=Ft(13,n,e,r),t.elementType=ef,t.lanes=s,t;case tf:return t=Ft(19,n,e,r),t.elementType=tf,t.lanes=s,t;case $v:return vc(n,r,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Lv:o=10;break e;case zv:o=9;break e;case op:o=11;break e;case lp:o=14;break e;case fi:o=16,i=null;break e}throw Error(H(130,t==null?t:typeof t,""))}return e=Ft(o,n,e,r),e.elementType=t,e.type=i,e.lanes=s,e}function mr(t,e,n,i){return t=Ft(7,t,i,e),t.lanes=n,t}function vc(t,e,n,i){return t=Ft(22,t,i,e),t.elementType=$v,t.lanes=n,t.stateNode={isHidden:!1},t}function gh(t,e,n){return t=Ft(6,t,null,e),t.lanes=n,t}function yh(t,e,n){return e=Ft(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function OE(t,e,n,i,r){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Gc(0),this.expirationTimes=Gc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Gc(0),this.identifierPrefix=i,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function Vp(t,e,n,i,r,s,o,l,a){return t=new OE(t,e,n,l,a),e===1?(e=1,s===!0&&(e|=8)):e=0,s=Ft(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:i,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ep(s),t}function PE(t,e,n){var i=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Ur,key:i==null?null:""+i,children:t,containerInfo:e,implementation:n}}function Mw(t){if(!t)return zi;t=t._reactInternals;e:{if(Or(t)!==t||t.tag!==1)throw Error(H(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(St(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(H(171))}if(t.tag===1){var n=t.type;if(St(n))return M1(t,n,e)}return e}function Ow(t,e,n,i,r,s,o,l,a){return t=Vp(n,i,!0,t,r,s,o,l,a),t.context=Mw(null),n=t.current,i=at(),r=Ri(n),s=Zn(i,r),s.callback=e??null,Oi(n,s,r),t.current.lanes=r,Tl(t,r,i),kt(t,i),t}function wc(t,e,n,i){var r=e.current,s=at(),o=Ri(r);return n=Mw(n),e.context===null?e.context=n:e.pendingContext=n,e=Zn(s,o),e.payload={element:t},i=i===void 0?null:i,i!==null&&(e.callback=i),t=Oi(r,e,o),t!==null&&(dn(t,r,o,s),ja(t,r,o)),o}function _u(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function Zg(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var n=t.retryLane;t.retryLane=n!==0&&n<e?n:e}}function Hp(t,e){Zg(t,e),(t=t.alternate)&&Zg(t,e)}function RE(){return null}var Pw=typeof reportError=="function"?reportError:function(t){console.error(t)};function Wp(t){this._internalRoot=t}xc.prototype.render=Wp.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(H(409));wc(t,e,null,null)};xc.prototype.unmount=Wp.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;br(function(){wc(null,t,null,null)}),e[ni]=null}};function xc(t){this._internalRoot=t}xc.prototype.unstable_scheduleHydration=function(t){if(t){var e=u1();t={blockedOn:null,target:t,priority:e};for(var n=0;n<vi.length&&e!==0&&e<vi[n].priority;n++);vi.splice(n,0,t),n===0&&h1(t)}};function Up(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Sc(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function e0(){}function IE(t,e,n,i,r){if(r){if(typeof i=="function"){var s=i;i=function(){var u=_u(o);s.call(u)}}var o=Ow(e,i,t,0,null,!1,!1,"",e0);return t._reactRootContainer=o,t[ni]=o.current,el(t.nodeType===8?t.parentNode:t),br(),o}for(;r=t.lastChild;)t.removeChild(r);if(typeof i=="function"){var l=i;i=function(){var u=_u(a);l.call(u)}}var a=Vp(t,0,!1,null,null,!1,!1,"",e0);return t._reactRootContainer=a,t[ni]=a.current,el(t.nodeType===8?t.parentNode:t),br(function(){wc(e,a,n,i)}),a}function kc(t,e,n,i,r){var s=n._reactRootContainer;if(s){var o=s;if(typeof r=="function"){var l=r;r=function(){var a=_u(o);l.call(a)}}wc(e,o,t,r)}else o=IE(n,e,t,r,i);return _u(o)}l1=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var n=ko(e.pendingLanes);n!==0&&(cp(e,n|1),kt(e,Re()),!(le&6)&&(Os=Re()+500,Ki()))}break;case 13:br(function(){var i=ii(t,1);if(i!==null){var r=at();dn(i,t,1,r)}}),Hp(t,1)}};hp=function(t){if(t.tag===13){var e=ii(t,134217728);if(e!==null){var n=at();dn(e,t,134217728,n)}Hp(t,134217728)}};a1=function(t){if(t.tag===13){var e=Ri(t),n=ii(t,e);if(n!==null){var i=at();dn(n,t,e,i)}Hp(t,e)}};u1=function(){return ce};c1=function(t,e){var n=ce;try{return ce=t,e()}finally{ce=n}};ff=function(t,e,n){switch(e){case"input":if(sf(t,n),e=n.name,n.type==="radio"&&e!=null){for(n=t;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<n.length;e++){var i=n[e];if(i!==t&&i.form===t.form){var r=fc(i);if(!r)throw Error(H(90));Fv(i),sf(i,r)}}}break;case"textarea":Hv(t,n);break;case"select":e=n.value,e!=null&&as(t,!!n.multiple,e,!1)}};Xv=zp;Gv=br;var DE={usingClientEntryPoint:!1,Events:[Ol,Xr,fc,Yv,Qv,zp]},lo={findFiberByHostInstance:ar,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},BE={bundleType:lo.bundleType,version:lo.version,rendererPackageName:lo.rendererPackageName,rendererConfig:lo.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:ai.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=e1(t),t===null?null:t.stateNode},findFiberByHostInstance:lo.findFiberByHostInstance||RE,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var sa=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!sa.isDisabled&&sa.supportsFiber)try{ac=sa.inject(BE),Dn=sa}catch{}}It.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=DE;It.createPortal=function(t,e){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Up(e))throw Error(H(200));return PE(t,e,null,n)};It.createRoot=function(t,e){if(!Up(t))throw Error(H(299));var n=!1,i="",r=Pw;return e!=null&&(e.unstable_strictMode===!0&&(n=!0),e.identifierPrefix!==void 0&&(i=e.identifierPrefix),e.onRecoverableError!==void 0&&(r=e.onRecoverableError)),e=Vp(t,1,!1,null,null,n,!1,i,r),t[ni]=e.current,el(t.nodeType===8?t.parentNode:t),new Wp(e)};It.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var e=t._reactInternals;if(e===void 0)throw typeof t.render=="function"?Error(H(188)):(t=Object.keys(t).join(","),Error(H(268,t)));return t=e1(e),t=t===null?null:t.stateNode,t};It.flushSync=function(t){return br(t)};It.hydrate=function(t,e,n){if(!Sc(e))throw Error(H(200));return kc(null,t,e,!0,n)};It.hydrateRoot=function(t,e,n){if(!Up(t))throw Error(H(405));var i=n!=null&&n.hydratedSources||null,r=!1,s="",o=Pw;if(n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),e=Ow(e,null,t,1,n??null,r,!1,s,o),t[ni]=e.current,el(t),i)for(t=0;t<i.length;t++)n=i[t],r=n._getVersion,r=r(n._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[n,r]:e.mutableSourceEagerHydrationData.push(n,r);return new xc(e)};It.render=function(t,e,n){if(!Sc(e))throw Error(H(200));return kc(null,t,e,!1,n)};It.unmountComponentAtNode=function(t){if(!Sc(t))throw Error(H(40));return t._reactRootContainer?(br(function(){kc(null,null,t,!1,function(){t._reactRootContainer=null,t[ni]=null})}),!0):!1};It.unstable_batchedUpdates=zp;It.unstable_renderSubtreeIntoContainer=function(t,e,n,i){if(!Sc(n))throw Error(H(200));if(t==null||t._reactInternals===void 0)throw Error(H(38));return kc(t,e,n,!1,i)};It.version="18.3.1-next-f1338f8080-20240426";function Rw(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Rw)}catch(t){console.error(t)}}Rw(),Rv.exports=It;var Iw=Rv.exports,t0=Iw;Gh.createRoot=t0.createRoot,Gh.hydrateRoot=t0.hydrateRoot;const LE={},n0=t=>{let e;const n=new Set,i=(c,h)=>{const f=typeof c=="function"?c(e):c;if(!Object.is(f,e)){const d=e;e=h??(typeof f!="object"||f===null)?f:Object.assign({},e,f),n.forEach(p=>p(e,d))}},r=()=>e,a={setState:i,getState:r,getInitialState:()=>u,subscribe:c=>(n.add(c),()=>n.delete(c)),destroy:()=>{(LE?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=e=t(i,r,a);return a},Dw=t=>t?n0(t):n0;var Bw={exports:{}},Lw={},zw={exports:{}},$w={};/**
41
+ * @license React
42
+ * use-sync-external-store-shim.production.js
43
+ *
44
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
45
+ *
46
+ * This source code is licensed under the MIT license found in the
47
+ * LICENSE file in the root directory of this source tree.
48
+ */var Ps=O;function zE(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var $E=typeof Object.is=="function"?Object.is:zE,jE=Ps.useState,FE=Ps.useEffect,VE=Ps.useLayoutEffect,HE=Ps.useDebugValue;function WE(t,e){var n=e(),i=jE({inst:{value:n,getSnapshot:e}}),r=i[0].inst,s=i[1];return VE(function(){r.value=n,r.getSnapshot=e,vh(r)&&s({inst:r})},[t,n,e]),FE(function(){return vh(r)&&s({inst:r}),t(function(){vh(r)&&s({inst:r})})},[t]),HE(n),n}function vh(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!$E(t,n)}catch{return!0}}function UE(t,e){return e()}var KE=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?UE:WE;$w.useSyncExternalStore=Ps.useSyncExternalStore!==void 0?Ps.useSyncExternalStore:KE;zw.exports=$w;var qE=zw.exports;/**
49
+ * @license React
50
+ * use-sync-external-store-shim/with-selector.production.js
51
+ *
52
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
53
+ *
54
+ * This source code is licensed under the MIT license found in the
55
+ * LICENSE file in the root directory of this source tree.
56
+ */var bc=O,YE=qE;function QE(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var XE=typeof Object.is=="function"?Object.is:QE,GE=YE.useSyncExternalStore,JE=bc.useRef,ZE=bc.useEffect,eN=bc.useMemo,tN=bc.useDebugValue;Lw.useSyncExternalStoreWithSelector=function(t,e,n,i,r){var s=JE(null);if(s.current===null){var o={hasValue:!1,value:null};s.current=o}else o=s.current;s=eN(function(){function a(d){if(!u){if(u=!0,c=d,d=i(d),r!==void 0&&o.hasValue){var p=o.value;if(r(p,d))return h=p}return h=d}if(p=h,XE(c,d))return p;var g=i(d);return r!==void 0&&r(p,g)?(c=d,p):(c=d,h=g)}var u=!1,c,h,f=n===void 0?null:n;return[function(){return a(e())},f===null?void 0:function(){return a(f())}]},[e,n,i,r]);var l=GE(t,s[0],s[1]);return ZE(function(){o.hasValue=!0,o.value=l},[l]),tN(l),l};Bw.exports=Lw;var nN=Bw.exports;const jw=Sv(nN),Fw={},{useDebugValue:iN}=j,{useSyncExternalStoreWithSelector:rN}=jw;let i0=!1;const sN=t=>t;function oN(t,e=sN,n){(Fw?"production":void 0)!=="production"&&n&&!i0&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),i0=!0);const i=rN(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return iN(i),i}const r0=t=>{(Fw?"production":void 0)!=="production"&&typeof t!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e=typeof t=="function"?Dw(t):t,n=(i,r)=>oN(e,i,r);return Object.assign(n,e),n},lN=t=>t?r0(t):r0,aN="api";async function uN(){const t=await fetch(`${aN}/spec`);if(!t.ok)throw new Error(`Failed to load spec: ${t.status}`);return t.json()}const cN=["get","post","put","patch","delete"];function hN(t){var i,r,s;const e=[],n=t.paths??{};for(const[o,l]of Object.entries(n)){const a=l.parameters??[];for(const u of cN){const c=l[u];if(!c)continue;const h=[...a,...c.parameters??[]].map(p=>({name:p.name,in:p.in,required:!!p.required,schema:ps(t,p.schema)??{}})),f=ps(t,((s=(r=(i=c.requestBody)==null?void 0:i.content)==null?void 0:r["application/json"])==null?void 0:s.schema)??null),d=ps(t,fN(c.responses));e.push({id:`${u.toUpperCase()} ${o}`,method:u,path:o,summary:c.summary,operationId:c.operationId,parameters:h,requestBodySchema:f,responseSchema:d})}}return e}function fN(t){var n,i,r;if(!t)return null;const e=Object.keys(t).find(s=>/^2\d\d$/.test(s));return e?((r=(i=(n=t[e])==null?void 0:n.content)==null?void 0:i["application/json"])==null?void 0:r.schema)??null:null}function ps(t,e,n=new Set){if(!e||typeof e!="object")return e??null;if(typeof e.$ref=="string"){if(n.has(e.$ref))return{};const i=dN(t,e.$ref);return i?ps(t,i,new Set(n).add(e.$ref)):e}if(e.type==="array"&&e.items)return{...e,items:ps(t,e.items,n)};if(e.properties){const i={};for(const[r,s]of Object.entries(e.properties))i[r]=ps(t,s,n);return{...e,properties:i}}return e}function dN(t,e){if(e.startsWith("#/"))return e.slice(2).split("/").reduce((n,i)=>n==null?void 0:n[i],t)}function pN(t){return btoa(unescape(encodeURIComponent(t)))}const s0=new Map,wh=new Map,mN=3e4,gN=300;async function yN(t,e){const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(e).toString()});if(!n.ok)throw new Error(`OAuth2 token request to ${t} failed with status ${n.status}`);const i=await n.json().catch(()=>null);if(!(i!=null&&i.access_token))throw new Error(`OAuth2 token response from ${t} had no access_token`);const r=typeof i.expires_in=="number"?i.expires_in:gN;return{accessToken:i.access_token,expiresInSeconds:r}}async function o0(t,e,n){const i=s0.get(t);if(i&&i.expiresAt>Date.now()+mN)return i.accessToken;const r=wh.get(t);if(r)return r;const s=(async()=>{const{accessToken:o,expiresInSeconds:l}=await yN(e,n);return s0.set(t,{accessToken:o,expiresAt:Date.now()+l*1e3}),o})();return wh.set(t,s),s.finally(()=>wh.delete(t)).catch(()=>{}),s}async function vN(t){switch(t.type){case"bearer":return{headers:{Authorization:`Bearer ${t.token}`}};case"basic":return{headers:{Authorization:`Basic ${pN(`${t.username}:${t.password}`)}`}};case"apiKey":return t.in==="query"?{query:{[t.paramName]:t.key}}:{headers:{[t.paramName]:t.key}};case"oauth2_clientCredentials":{const e={grant_type:"client_credentials",client_id:t.clientId,client_secret:t.clientSecret};return t.scope&&(e.scope=t.scope),{headers:{Authorization:`Bearer ${await o0(t.id,t.tokenUrl,e)}`}}}case"oauth2_password":{const e={grant_type:"password",username:t.username,password:t.password};return t.clientId&&(e.client_id=t.clientId),t.clientSecret&&(e.client_secret=t.clientSecret),t.scope&&(e.scope=t.scope),{headers:{Authorization:`Bearer ${await o0(t.id,t.tokenUrl,e)}`}}}case"popup_login":return{credentials:"include"}}}function Rl(){return/\{\{enlace:([a-zA-Z0-9_-]+)\}\}/g}function Vw(t){return`{{enlace:${t}}}`}function wN(t,e,n){return t[e-1]==='"'&&t[n]==='"'}function Hw(t,e){if(!e)return t;const n=e.trim().replace(/^\$\.?/,"");return qp(t,n)}function Ww(t,e){const n=e.toLowerCase();for(const[i,r]of Object.entries(t))if(i.toLowerCase()===n)return r}function Uf(t,e){const n=e.get(t.sourceNodeId);if(!n||!n.response)throw new Error(`Body tag references node "${t.sourceNodeId}", which has no captured response yet.`);switch(t.type){case"response_body":return Hw(n.response.body,t.jsonPath);case"response_raw":return n.response.body;case"response_header":{const i=t.headerName??"",r=Ww(n.response.headers,i);if(r===void 0)throw new Error(`Body tag references header "${i}" on node "${t.sourceNodeId}", but the response has no such header.`);return r}}}function xN(t){return t.includes("{{enlace:")}function SN(t,e,n){if(!xN(t))return t;const i=[...t.matchAll(Rl())],r=l=>{const a=e[l];if(!a)throw new Error(`Body references unknown tag "${l}".`);return a};if(i.length===1&&i[0][0]===t)return Uf(r(i[0][1]),n);let s="",o=0;for(const l of i){const a=l.index??0,u=Uf(r(l[1]),n);s+=t.slice(o,a)+String(u),o=a+l[0].length}return s+t.slice(o)}function Kf(t,e,n){return typeof t=="string"?SN(t,e,n):Array.isArray(t)?t.map(i=>Kf(i,e,n)):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([i,r])=>[i,Kf(r,e,n)])):t}function kN(t){return JSON.stringify(String(t)).slice(1,-1)}function bN(t,e){const n=t.template;let i="",r=0;for(const s of n.matchAll(Rl())){const o=s.index??0,l=o+s[0].length,a=s[1],u=t.tags[a];if(!u)throw new Error(`Body references unknown tag "${a}".`);const c=Uf(u,e),h=wN(n,o,l),f=h?o-1:o,d=h?l+1:l,p=h?JSON.stringify(c):kN(c);i+=n.slice(r,f)+p,r=d}return i+=n.slice(r),JSON.parse(i)}function Kp(t,e){const n=new Map(t.map(r=>[r.id,r])),i=new Map;for(const r of t)i.set(r.id,new Set);for(const{fromNodeId:r,toNodeId:s}of e)n.has(r)&&i.has(s)&&i.get(s).add(r);for(const r of t)for(const s of Object.values(r.fieldValues))s.source==="mapped"&&n.has(s.fromNodeId)&&i.get(r.id).add(s.fromNodeId);return i}function CN(t,e,n){const i=Kp(t,e),r=new Set,s=[...i.get(n)??[]];for(;s.length>0;){const o=s.shift();r.has(o)||(r.add(o),s.push(...i.get(o)??[]))}return r}function Au(t,e){return`${t}->${e}`}class Uw extends Error{constructor(e){super(`Workflow has a cyclic dependency involving nodes: ${e.join(", ")}`),this.nodeIds=e,this.name="CyclicWorkflowError"}}function Kw(t,e=[]){const n=Kp(t,e),i=new Set(t.map(s=>s.id)),r=[];for(;i.size>0;){const s=t.filter(o=>i.has(o.id)&&[...n.get(o.id)].every(l=>!i.has(l)));if(s.length===0)throw new Uw([...i]);r.push(s);for(const o of s)i.delete(o.id)}return r}function EN(t,e=[]){return Kw(t,e).flat()}function qp(t,e){if(!e)return;const n=e.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let i=t;for(const r of n){if(i==null)return;i=i[r]}return i}function ul(t,e,n){const i=e.split(".").filter(Boolean);let r=t;i.forEach((s,o)=>{o===i.length-1?r[s]=n:(r[s]=r[s]??{},r=r[s])})}function NN(t,e){var i;if(t.source==="static")return t.value;const n=e.get(t.fromNodeId);return qp((i=n==null?void 0:n.response)==null?void 0:i.body,t.fromResponseFieldPath)}async function qw(t,e,n,i,r){var S;let s=e.path;const o=new URLSearchParams,l={"Content-Type":"application/json"},a={},u=(S=t.rawBody)==null?void 0:S.tags;for(const[m,y]of Object.entries(t.fieldValues)){let v=NN(y,n);u&&Object.keys(u).length>0&&(v=Kf(v,u,n));const[x,...b]=m.split("."),C=b.join(".");x==="path"?s=s.replace(`{${C}}`,encodeURIComponent(String(v??""))):x==="query"?v!==void 0&&o.set(C,String(v)):x==="header"?v!==void 0&&(l[C]=String(v)):x==="body"&&ul(a,C,v)}const c=[];let h;if(t.credentialId){const m=i.get(t.credentialId);if(m){const y=await vN(m);Object.assign(l,y.headers);for(const[v,x]of Object.entries(y.query??{}))o.set(v,x),c.push(v);h=y.credentials}}const f=o.toString(),d=`${r}${s}${f?`?${f}`:""}`,p=t.bodyMode==="raw"&&t.rawBody?bN(t.rawBody,n):Object.keys(a).length>0?a:void 0,g=!!e.requestBodySchema&&p!==void 0;return{method:e.method.toUpperCase(),url:d,headers:l,body:g?p:void 0,redactQueryParams:c.length>0?c:void 0,credentials:h}}async function _N(t,e,n,i,r){const s=new Date().toISOString();let o;try{o=await qw(t,e,n,i,r)}catch(a){return{nodeId:t.id,request:{method:e.method.toUpperCase(),url:`${r}${e.path}`,headers:{}},timestampStart:s,timestampEnd:new Date().toISOString(),error:a instanceof Error?a.message:String(a)}}const l={nodeId:t.id,request:o,timestampStart:s,timestampEnd:""};try{const a=await fetch(o.url,{method:o.method,headers:o.headers,body:o.body!==void 0?JSON.stringify(o.body):void 0,credentials:o.credentials}),u={};a.headers.forEach((f,d)=>u[d]=f);const h=(a.headers.get("content-type")??"").includes("application/json")?await a.json().catch(()=>null):await a.text();l.response={status:a.status,headers:u,body:h},l.timestampEnd=new Date().toISOString(),a.status>=400&&(l.error=`Request failed with status ${a.status}`)}catch(a){l.timestampEnd=new Date().toISOString(),l.error=a instanceof Error?a.message:String(a)}return l}async function AN(t,e,n,i){const{nodes:r,connections:s}=t;Kw(r,s);const o=Kp(r,s),l=new Map(r.map(_=>[_.id,"pending"])),a=new Map,u=[],c=i.armedBreakpoints??new Set,h=new Set,f=(_,P,B,L)=>{var F;return(F=i.onEvent)==null?void 0:F.call(i,{nodeId:_,status:P,step:B,request:L})},d=_=>[...o.get(_)].every(P=>l.get(P)==="completed"),p=_=>!h.has(_)&&s.some(P=>P.toNodeId===_&&c.has(Au(P.fromNodeId,P.toNodeId)));let g=!1,S=0,m=0,y=null,v=null;const x=()=>{v==null||v(),v=null},b=()=>new Promise(_=>v=_);function C(){for(const _ of r){const P=l.get(_.id);(P==="pending"||P==="paused")&&(P==="paused"&&m--,l.set(_.id,"skipped"),f(_.id,"skipped"))}}function N(_,P){l.set(_.id,"in-flight"),S++,f(_.id,"in-flight"),_N(_,P,a,n,i.baseUrl).then(B=>{u.push(B),a.set(B.nodeId,B);const L=B.error?"failed":"completed";l.set(_.id,L),S--,f(_.id,L,B),B.error&&(g=!0,C()),x()})}function M(){for(const _ of r){if(y)return;if(l.get(_.id)!=="pending"||g||!d(_.id))continue;const P=e.get(_.operationId);if(!P){y=new Error(`Unknown operation "${_.operationId}" referenced by node ${_.id}`),x();return}if(p(_.id)){l.set(_.id,"paused"),m++,f(_.id,"paused"),qw(_,P,a,n,i.baseUrl).then(B=>{l.get(_.id)==="paused"&&f(_.id,"paused",void 0,B)}).catch(()=>{});continue}N(_,P)}}for(i.onControl&&i.onControl({continue:()=>{let _=!1;for(const P of r)l.get(P.id)==="paused"&&(h.add(P.id),l.set(P.id,"pending"),m--,_=!0);_&&x()},step:_=>{l.get(_)==="paused"&&(h.add(_),l.set(_,"pending"),m--,x())},stop:()=>{g=!0,C(),x()}}),M();(S>0||m>0)&&(await b(),!y);)M();if(y)throw y;return{steps:u}}function TN(t){var i;const e=((i=t==null?void 0:t.components)==null?void 0:i.securitySchemes)??{},n=[];for(const[r,s]of Object.entries(e)){const o=MN(r,s);o&&n.push({schemeName:r,description:s==null?void 0:s.description,template:o})}return n}function MN(t,e){if(!e||typeof e!="object")return null;if(e.type==="http"&&e.scheme==="bearer")return zr(t,{name:t,type:"bearer",token:""});if(e.type==="http"&&e.scheme==="basic")return zr(t,{name:t,type:"basic",username:"",password:""});if(e.type==="apiKey"&&(e.in==="header"||e.in==="query"))return zr(t,{name:t,type:"apiKey",paramName:e.name??"",in:e.in,key:""});if(e.type==="apiKey"&&e.in==="cookie")return zr(t,{name:t,type:"popup_login",loginUrl:""});if(e.type==="oauth2"){const n=e.flows??{};return n.clientCredentials?zr(t,{name:t,type:"oauth2_clientCredentials",tokenUrl:n.clientCredentials.tokenUrl??"",clientId:"",clientSecret:"",scope:l0(n.clientCredentials.scopes)}):n.password?zr(t,{name:t,type:"oauth2_password",tokenUrl:n.password.tokenUrl??"",username:"",password:"",clientId:"",clientSecret:"",scope:l0(n.password.scopes)}):null}return null}function zr(t,e){return{...e,fromSecurityScheme:t}}function l0(t){return t?Object.keys(t).join(" "):""}function Tu(){return crypto.randomUUID()}function ON(t){return{x:80+t%4*220,y:80+Math.floor(t/4)*140}}function PN(t){var n;const e=t.servers??[];return e.length===0||!((n=e[0])!=null&&n.url)?null:(e.length>1&&console.warn(`enlace: spec declares ${e.length} servers; defaulting to the first (${e[0].url}).`),e[0].url)}function bn(t){return t.isRunning}const Ye=lN((t,e)=>({operations:[],baseUrl:null,nodes:[],connections:[],nodePositions:{},credentials:[],declaredCredentials:[],selectedNodeId:null,runResult:null,stepStatusByNodeId:{},armedBreakpoints:new Set,previewRequestByNodeId:{},activeControl:null,isRunning:!1,error:null,loadOperations:async()=>{try{const n=await uN(),i=hN(n),r=PN(n),s=TN(n);t({operations:i,baseUrl:r,declaredCredentials:s,error:r?null:"Could not determine a target base URL — add a `servers` entry to the OpenAPI spec."})}catch(n){t({error:n instanceof Error?n.message:String(n)})}},addNode:(n,i)=>{if(bn(e()))return"";const r=Tu(),s={id:r,operationId:n,credentialId:null,fieldValues:{}};return t(o=>({nodes:[...o.nodes,s],nodePositions:{...o.nodePositions,[r]:i??ON(o.nodes.length)},selectedNodeId:r})),r},updateNodePosition:(n,i)=>t(r=>({nodePositions:{...r.nodePositions,[n]:i}})),removeNode:n=>t(i=>{if(bn(i))return i;const r={...i.nodePositions};return delete r[n],{nodes:i.nodes.filter(o=>o.id!==n).map(o=>{const l={...o.fieldValues};let a=!1;for(const[u,c]of Object.entries(l))c.source==="mapped"&&c.fromNodeId===n&&(l[u]={source:"static",value:""},a=!0);return a?{...o,fieldValues:l}:o}),nodePositions:r,connections:i.connections.filter(o=>o.fromNodeId!==n&&o.toNodeId!==n),selectedNodeId:i.selectedNodeId===n?null:i.selectedNodeId}}),selectNode:n=>t({selectedNodeId:n}),setCredential:(n,i)=>t(r=>bn(r)?r:{nodes:r.nodes.map(s=>s.id===n?{...s,credentialId:i}:s)}),setFieldValue:(n,i,r)=>t(s=>bn(s)?s:{nodes:s.nodes.map(o=>o.id===n?{...o,fieldValues:{...o.fieldValues,[i]:r}}:o)}),mergeFieldValues:(n,i)=>t(r=>bn(r)?r:{nodes:r.nodes.map(s=>s.id===n?{...s,fieldValues:{...s.fieldValues,...i}}:s)}),setBodyMode:(n,i)=>t(r=>bn(r)?r:{nodes:r.nodes.map(s=>s.id===n?{...s,bodyMode:i}:s)}),setRawBody:(n,i)=>t(r=>bn(r)?r:{nodes:r.nodes.map(s=>s.id===n?{...s,rawBody:i}:s)}),connectNodes:(n,i)=>t(r=>bn(r)||n===i||r.connections.some(o=>o.fromNodeId===n&&o.toNodeId===i)?r:{connections:[...r.connections,{fromNodeId:n,toNodeId:i}]}),disconnectNodes:(n,i)=>t(r=>{if(bn(r))return r;const s=new Set(r.armedBreakpoints);return s.delete(Au(n,i)),{connections:r.connections.filter(o=>!(o.fromNodeId===n&&o.toNodeId===i)),armedBreakpoints:s}}),toggleBreakpoint:(n,i)=>t(r=>{if(bn(r))return r;const s=Au(n,i),o=new Set(r.armedBreakpoints);return o.has(s)?o.delete(s):o.add(s),{armedBreakpoints:o}}),continueExecution:()=>{var n;return(n=e().activeControl)==null?void 0:n.continue()},stepNode:n=>{var i;return(i=e().activeControl)==null?void 0:i.step(n)},stopExecution:()=>{var n;return(n=e().activeControl)==null?void 0:n.stop()},addCredential:n=>{const i={...n,id:Tu()};t(r=>({credentials:[...r.credentials,i]}))},updateCredential:(n,i)=>{const r={...i,id:n};t(s=>({credentials:s.credentials.map(o=>o.id===n?r:o)}))},removeCredential:n=>t(i=>({credentials:i.credentials.filter(r=>r.id!==n),nodes:i.nodes.map(r=>r.credentialId===n?{...r,credentialId:null}:r)})),run:async n=>{const i=(n==null?void 0:n.useBreakpoints)??!1,{nodes:r,armedBreakpoints:s}=e();t({isRunning:!0,error:null,runResult:{steps:[]},stepStatusByNodeId:r.reduce((o,l)=>(o[l.id]="pending",o),{}),previewRequestByNodeId:{}});try{const{connections:o,operations:l,credentials:a,baseUrl:u}=e();if(!u)throw new Error("Could not determine a target base URL — add a `servers` entry to the OpenAPI spec.");const c=new Map(l.map(d=>[d.id,d])),h=new Map(a.map(d=>[d.id,d])),f=await AN({nodes:r,connections:o},c,h,{baseUrl:u,onEvent:d=>{t(p=>{var g;return{stepStatusByNodeId:{...p.stepStatusByNodeId,[d.nodeId]:d.status},runResult:d.step?{steps:[...((g=p.runResult)==null?void 0:g.steps)??[],d.step]}:p.runResult,previewRequestByNodeId:d.request?{...p.previewRequestByNodeId,[d.nodeId]:d.request}:p.previewRequestByNodeId}})},...i?{armedBreakpoints:new Set(s),onControl:d=>t({activeControl:d})}:{}});t({runResult:f})}catch(o){t({error:o instanceof Error?o.message:String(o)})}finally{t({isRunning:!1,activeControl:null})}}}));function RN({operations:t}){const[e,n]=O.useState(""),i=e.trim().toLowerCase(),r=i?t.filter(s=>{var o;return(o=s.operationId)==null?void 0:o.toLowerCase().includes(i)}):t;return k.jsxs("aside",{className:"operation-list",children:[k.jsx("h2",{children:"Operations"}),k.jsx("div",{className:"operation-list__search",children:k.jsx("input",{type:"text",placeholder:"Search by operationId…","aria-label":"Search operations by operationId",value:e,onChange:s=>n(s.target.value)})}),i&&r.length===0?k.jsxs("p",{className:"operation-list__empty",children:['No operations match "',e,'".']}):k.jsx("ul",{children:r.map(s=>k.jsx("li",{draggable:!0,onDragStart:o=>o.dataTransfer.setData("text/operation-id",s.id),children:k.jsxs("fieldset",{className:`operation-list__item operation-list__item--${s.method}`,children:[s.operationId&&k.jsx("legend",{className:"operation-list__operation-id",children:s.operationId}),k.jsx("span",{className:`method-badge method-badge--${s.method}`,children:s.method.toUpperCase()}),k.jsx("span",{className:"operation-list__path",children:s.path})]})},s.id))})]})}function dt(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n=0,i;n<t.length;n++)(i=dt(t[n]))!==""&&(e+=(e&&" ")+i);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}const{useDebugValue:IN}=j,{useSyncExternalStoreWithSelector:DN}=jw,BN=t=>t;function Yw(t,e=BN,n){const i=DN(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return IN(i),i}const a0=(t,e)=>{const n=Dw(t),i=(r,s=e)=>Yw(n,r,s);return Object.assign(i,n),i},LN=(t,e)=>t?a0(t,e):a0;function rt(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[i,r]of t)if(!Object.is(r,e.get(i)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(e,i)||!Object.is(t[i],e[i]))return!1;return!0}var zN={value:()=>{}};function Cc(){for(var t=0,e=arguments.length,n={},i;t<e;++t){if(!(i=arguments[t]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new qa(n)}function qa(t){this._=t}function $N(t,e){return t.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}qa.prototype=Cc.prototype={constructor:qa,on:function(t,e){var n=this._,i=$N(t+"",n),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(t=i[s]).type)&&(r=jN(n[r],t.name)))return r;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(r=(t=i[s]).type)n[r]=u0(n[r],t.name,e);else if(e==null)for(r in n)n[r]=u0(n[r],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new qa(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,s;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=this._[t],i=0,r=s.length;i<r;++i)s[i].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var i=this._[t],r=0,s=i.length;r<s;++r)i[r].value.apply(e,n)}};function jN(t,e){for(var n=0,i=t.length,r;n<i;++n)if((r=t[n]).name===e)return r.value}function u0(t,e,n){for(var i=0,r=t.length;i<r;++i)if(t[i].name===e){t[i]=zN,t=t.slice(0,i).concat(t.slice(i+1));break}return n!=null&&t.push({name:e,value:n}),t}var qf="http://www.w3.org/1999/xhtml";const c0={svg:"http://www.w3.org/2000/svg",xhtml:qf,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ec(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),c0.hasOwnProperty(e)?{space:c0[e],local:t}:t}function FN(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===qf&&e.documentElement.namespaceURI===qf?e.createElement(t):e.createElementNS(n,t)}}function VN(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Qw(t){var e=Ec(t);return(e.local?VN:FN)(e)}function HN(){}function Yp(t){return t==null?HN:function(){return this.querySelector(t)}}function WN(t){typeof t!="function"&&(t=Yp(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r<n;++r)for(var s=e[r],o=s.length,l=i[r]=new Array(o),a,u,c=0;c<o;++c)(a=s[c])&&(u=t.call(a,a.__data__,c,s))&&("__data__"in a&&(u.__data__=a.__data__),l[c]=u);return new Rt(i,this._parents)}function UN(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function KN(){return[]}function Xw(t){return t==null?KN:function(){return this.querySelectorAll(t)}}function qN(t){return function(){return UN(t.apply(this,arguments))}}function YN(t){typeof t=="function"?t=qN(t):t=Xw(t);for(var e=this._groups,n=e.length,i=[],r=[],s=0;s<n;++s)for(var o=e[s],l=o.length,a,u=0;u<l;++u)(a=o[u])&&(i.push(t.call(a,a.__data__,u,o)),r.push(a));return new Rt(i,r)}function Gw(t){return function(){return this.matches(t)}}function Jw(t){return function(e){return e.matches(t)}}var QN=Array.prototype.find;function XN(t){return function(){return QN.call(this.children,t)}}function GN(){return this.firstElementChild}function JN(t){return this.select(t==null?GN:XN(typeof t=="function"?t:Jw(t)))}var ZN=Array.prototype.filter;function e_(){return Array.from(this.children)}function t_(t){return function(){return ZN.call(this.children,t)}}function n_(t){return this.selectAll(t==null?e_:t_(typeof t=="function"?t:Jw(t)))}function i_(t){typeof t!="function"&&(t=Gw(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r<n;++r)for(var s=e[r],o=s.length,l=i[r]=[],a,u=0;u<o;++u)(a=s[u])&&t.call(a,a.__data__,u,s)&&l.push(a);return new Rt(i,this._parents)}function Zw(t){return new Array(t.length)}function r_(){return new Rt(this._enter||this._groups.map(Zw),this._parents)}function Mu(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}Mu.prototype={constructor:Mu,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function s_(t){return function(){return t}}function o_(t,e,n,i,r,s){for(var o=0,l,a=e.length,u=s.length;o<u;++o)(l=e[o])?(l.__data__=s[o],i[o]=l):n[o]=new Mu(t,s[o]);for(;o<a;++o)(l=e[o])&&(r[o]=l)}function l_(t,e,n,i,r,s,o){var l,a,u=new Map,c=e.length,h=s.length,f=new Array(c),d;for(l=0;l<c;++l)(a=e[l])&&(f[l]=d=o.call(a,a.__data__,l,e)+"",u.has(d)?r[l]=a:u.set(d,a));for(l=0;l<h;++l)d=o.call(t,s[l],l,s)+"",(a=u.get(d))?(i[l]=a,a.__data__=s[l],u.delete(d)):n[l]=new Mu(t,s[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(f[l])===a&&(r[l]=a)}function a_(t){return t.__data__}function u_(t,e){if(!arguments.length)return Array.from(this,a_);var n=e?l_:o_,i=this._parents,r=this._groups;typeof t!="function"&&(t=s_(t));for(var s=r.length,o=new Array(s),l=new Array(s),a=new Array(s),u=0;u<s;++u){var c=i[u],h=r[u],f=h.length,d=c_(t.call(c,c&&c.__data__,u,i)),p=d.length,g=l[u]=new Array(p),S=o[u]=new Array(p),m=a[u]=new Array(f);n(c,h,g,S,m,d,e);for(var y=0,v=0,x,b;y<p;++y)if(x=g[y]){for(y>=v&&(v=y+1);!(b=S[v])&&++v<p;);x._next=b||null}}return o=new Rt(o,i),o._enter=l,o._exit=a,o}function c_(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function h_(){return new Rt(this._exit||this._groups.map(Zw),this._parents)}function f_(t,e,n){var i=this.enter(),r=this,s=this.exit();return typeof t=="function"?(i=t(i),i&&(i=i.selection())):i=i.append(t+""),e!=null&&(r=e(r),r&&(r=r.selection())),n==null?s.remove():n(s),i&&r?i.merge(r).order():r}function d_(t){for(var e=t.selection?t.selection():t,n=this._groups,i=e._groups,r=n.length,s=i.length,o=Math.min(r,s),l=new Array(r),a=0;a<o;++a)for(var u=n[a],c=i[a],h=u.length,f=l[a]=new Array(h),d,p=0;p<h;++p)(d=u[p]||c[p])&&(f[p]=d);for(;a<r;++a)l[a]=n[a];return new Rt(l,this._parents)}function p_(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var i=t[e],r=i.length-1,s=i[r],o;--r>=0;)(o=i[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function m_(t){t||(t=g_);function e(h,f){return h&&f?t(h.__data__,f.__data__):!h-!f}for(var n=this._groups,i=n.length,r=new Array(i),s=0;s<i;++s){for(var o=n[s],l=o.length,a=r[s]=new Array(l),u,c=0;c<l;++c)(u=o[c])&&(a[c]=u);a.sort(e)}return new Rt(r,this._parents).order()}function g_(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function y_(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function v_(){return Array.from(this)}function w_(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var i=t[e],r=0,s=i.length;r<s;++r){var o=i[r];if(o)return o}return null}function x_(){let t=0;for(const e of this)++t;return t}function S_(){return!this.node()}function k_(t){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var r=e[n],s=0,o=r.length,l;s<o;++s)(l=r[s])&&t.call(l,l.__data__,s,r);return this}function b_(t){return function(){this.removeAttribute(t)}}function C_(t){return function(){this.removeAttributeNS(t.space,t.local)}}function E_(t,e){return function(){this.setAttribute(t,e)}}function N_(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function __(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function A_(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function T_(t,e){var n=Ec(t);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((e==null?n.local?C_:b_:typeof e=="function"?n.local?A_:__:n.local?N_:E_)(n,e))}function ex(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function M_(t){return function(){this.style.removeProperty(t)}}function O_(t,e,n){return function(){this.style.setProperty(t,e,n)}}function P_(t,e,n){return function(){var i=e.apply(this,arguments);i==null?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function R_(t,e,n){return arguments.length>1?this.each((e==null?M_:typeof e=="function"?P_:O_)(t,e,n??"")):Rs(this.node(),t)}function Rs(t,e){return t.style.getPropertyValue(e)||ex(t).getComputedStyle(t,null).getPropertyValue(e)}function I_(t){return function(){delete this[t]}}function D_(t,e){return function(){this[t]=e}}function B_(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function L_(t,e){return arguments.length>1?this.each((e==null?I_:typeof e=="function"?B_:D_)(t,e)):this.node()[t]}function tx(t){return t.trim().split(/^|\s+/)}function Qp(t){return t.classList||new nx(t)}function nx(t){this._node=t,this._names=tx(t.getAttribute("class")||"")}nx.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function ix(t,e){for(var n=Qp(t),i=-1,r=e.length;++i<r;)n.add(e[i])}function rx(t,e){for(var n=Qp(t),i=-1,r=e.length;++i<r;)n.remove(e[i])}function z_(t){return function(){ix(this,t)}}function $_(t){return function(){rx(this,t)}}function j_(t,e){return function(){(e.apply(this,arguments)?ix:rx)(this,t)}}function F_(t,e){var n=tx(t+"");if(arguments.length<2){for(var i=Qp(this.node()),r=-1,s=n.length;++r<s;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof e=="function"?j_:e?z_:$_)(n,e))}function V_(){this.textContent=""}function H_(t){return function(){this.textContent=t}}function W_(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function U_(t){return arguments.length?this.each(t==null?V_:(typeof t=="function"?W_:H_)(t)):this.node().textContent}function K_(){this.innerHTML=""}function q_(t){return function(){this.innerHTML=t}}function Y_(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function Q_(t){return arguments.length?this.each(t==null?K_:(typeof t=="function"?Y_:q_)(t)):this.node().innerHTML}function X_(){this.nextSibling&&this.parentNode.appendChild(this)}function G_(){return this.each(X_)}function J_(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Z_(){return this.each(J_)}function eA(t){var e=typeof t=="function"?t:Qw(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function tA(){return null}function nA(t,e){var n=typeof t=="function"?t:Qw(t),i=e==null?tA:typeof e=="function"?e:Yp(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function iA(){var t=this.parentNode;t&&t.removeChild(this)}function rA(){return this.each(iA)}function sA(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function oA(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function lA(t){return this.select(t?oA:sA)}function aA(t){return arguments.length?this.property("__data__",t):this.node().__data__}function uA(t){return function(e){t.call(this,e,this.__data__)}}function cA(t){return t.trim().split(/^|\s+/).map(function(e){var n="",i=e.indexOf(".");return i>=0&&(n=e.slice(i+1),e=e.slice(0,i)),{type:e,name:n}})}function hA(t){return function(){var e=this.__on;if(e){for(var n=0,i=-1,r=e.length,s;n<r;++n)s=e[n],(!t.type||s.type===t.type)&&s.name===t.name?this.removeEventListener(s.type,s.listener,s.options):e[++i]=s;++i?e.length=i:delete this.__on}}}function fA(t,e,n){return function(){var i=this.__on,r,s=uA(e);if(i){for(var o=0,l=i.length;o<l;++o)if((r=i[o]).type===t.type&&r.name===t.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=e;return}}this.addEventListener(t.type,s,n),r={type:t.type,name:t.name,value:e,listener:s,options:n},i?i.push(r):this.__on=[r]}}function dA(t,e,n){var i=cA(t+""),r,s=i.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,u=l.length,c;a<u;++a)for(r=0,c=l[a];r<s;++r)if((o=i[r]).type===c.type&&o.name===c.name)return c.value}return}for(l=e?fA:hA,r=0;r<s;++r)this.each(l(i[r],e,n));return this}function sx(t,e,n){var i=ex(t),r=i.CustomEvent;typeof r=="function"?r=new r(e,n):(r=i.document.createEvent("Event"),n?(r.initEvent(e,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(e,!1,!1)),t.dispatchEvent(r)}function pA(t,e){return function(){return sx(this,t,e)}}function mA(t,e){return function(){return sx(this,t,e.apply(this,arguments))}}function gA(t,e){return this.each((typeof e=="function"?mA:pA)(t,e))}function*yA(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var i=t[e],r=0,s=i.length,o;r<s;++r)(o=i[r])&&(yield o)}var ox=[null];function Rt(t,e){this._groups=t,this._parents=e}function Il(){return new Rt([[document.documentElement]],ox)}function vA(){return this}Rt.prototype=Il.prototype={constructor:Rt,select:WN,selectAll:YN,selectChild:JN,selectChildren:n_,filter:i_,data:u_,enter:r_,exit:h_,join:f_,merge:d_,selection:vA,order:p_,sort:m_,call:y_,nodes:v_,node:w_,size:x_,empty:S_,each:k_,attr:T_,style:R_,property:L_,classed:F_,text:U_,html:Q_,raise:G_,lower:Z_,append:eA,insert:nA,remove:rA,clone:lA,datum:aA,on:dA,dispatch:gA,[Symbol.iterator]:yA};function ln(t){return typeof t=="string"?new Rt([[document.querySelector(t)]],[document.documentElement]):new Rt([[t]],ox)}function wA(t){let e;for(;e=t.sourceEvent;)t=e;return t}function Tn(t,e){if(t=wA(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=t.clientX,i.y=t.clientY,i=i.matrixTransform(e.getScreenCTM().inverse()),[i.x,i.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}const xA={passive:!1},cl={capture:!0,passive:!1};function xh(t){t.stopImmediatePropagation()}function ms(t){t.preventDefault(),t.stopImmediatePropagation()}function lx(t){var e=t.document.documentElement,n=ln(t).on("dragstart.drag",ms,cl);"onselectstart"in e?n.on("selectstart.drag",ms,cl):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function ax(t,e){var n=t.document.documentElement,i=ln(t).on("dragstart.drag",null);e&&(i.on("click.drag",ms,cl),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const oa=t=>()=>t;function Yf(t,{sourceEvent:e,subject:n,target:i,identifier:r,active:s,x:o,y:l,dx:a,dy:u,dispatch:c}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}Yf.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function SA(t){return!t.ctrlKey&&!t.button}function kA(){return this.parentNode}function bA(t,e){return e??{x:t.x,y:t.y}}function CA(){return navigator.maxTouchPoints||"ontouchstart"in this}function EA(){var t=SA,e=kA,n=bA,i=CA,r={},s=Cc("start","drag","end"),o=0,l,a,u,c,h=0;function f(x){x.on("mousedown.drag",d).filter(i).on("touchstart.drag",S).on("touchmove.drag",m,xA).on("touchend.drag touchcancel.drag",y).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(x,b){if(!(c||!t.call(this,x,b))){var C=v(this,e.call(this,x,b),x,b,"mouse");C&&(ln(x.view).on("mousemove.drag",p,cl).on("mouseup.drag",g,cl),lx(x.view),xh(x),u=!1,l=x.clientX,a=x.clientY,C("start",x))}}function p(x){if(ms(x),!u){var b=x.clientX-l,C=x.clientY-a;u=b*b+C*C>h}r.mouse("drag",x)}function g(x){ln(x.view).on("mousemove.drag mouseup.drag",null),ax(x.view,u),ms(x),r.mouse("end",x)}function S(x,b){if(t.call(this,x,b)){var C=x.changedTouches,N=e.call(this,x,b),M=C.length,_,P;for(_=0;_<M;++_)(P=v(this,N,x,b,C[_].identifier,C[_]))&&(xh(x),P("start",x,C[_]))}}function m(x){var b=x.changedTouches,C=b.length,N,M;for(N=0;N<C;++N)(M=r[b[N].identifier])&&(ms(x),M("drag",x,b[N]))}function y(x){var b=x.changedTouches,C=b.length,N,M;for(c&&clearTimeout(c),c=setTimeout(function(){c=null},500),N=0;N<C;++N)(M=r[b[N].identifier])&&(xh(x),M("end",x,b[N]))}function v(x,b,C,N,M,_){var P=s.copy(),B=Tn(_||C,b),L,F,w;if((w=n.call(x,new Yf("beforestart",{sourceEvent:C,target:f,identifier:M,active:o,x:B[0],y:B[1],dx:0,dy:0,dispatch:P}),N))!=null)return L=w.x-B[0]||0,F=w.y-B[1]||0,function E(T,z,R){var A=B,D;switch(T){case"start":r[M]=E,D=o++;break;case"end":delete r[M],--o;case"drag":B=Tn(R||z,b),D=o;break}P.call(T,x,new Yf(T,{sourceEvent:z,subject:w,target:f,identifier:M,active:D,x:B[0]+L,y:B[1]+F,dx:B[0]-A[0],dy:B[1]-A[1],dispatch:P}),N)}}return f.filter=function(x){return arguments.length?(t=typeof x=="function"?x:oa(!!x),f):t},f.container=function(x){return arguments.length?(e=typeof x=="function"?x:oa(x),f):e},f.subject=function(x){return arguments.length?(n=typeof x=="function"?x:oa(x),f):n},f.touchable=function(x){return arguments.length?(i=typeof x=="function"?x:oa(!!x),f):i},f.on=function(){var x=s.on.apply(s,arguments);return x===s?f:x},f.clickDistance=function(x){return arguments.length?(h=(x=+x)*x,f):Math.sqrt(h)},f}function Xp(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function ux(t,e){var n=Object.create(t.prototype);for(var i in e)n[i]=e[i];return n}function Dl(){}var hl=.7,Ou=1/hl,gs="\\s*([+-]?\\d+)\\s*",fl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ln="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",NA=/^#([0-9a-f]{3,8})$/,_A=new RegExp(`^rgb\\(${gs},${gs},${gs}\\)$`),AA=new RegExp(`^rgb\\(${Ln},${Ln},${Ln}\\)$`),TA=new RegExp(`^rgba\\(${gs},${gs},${gs},${fl}\\)$`),MA=new RegExp(`^rgba\\(${Ln},${Ln},${Ln},${fl}\\)$`),OA=new RegExp(`^hsl\\(${fl},${Ln},${Ln}\\)$`),PA=new RegExp(`^hsla\\(${fl},${Ln},${Ln},${fl}\\)$`),h0={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Xp(Dl,dl,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:f0,formatHex:f0,formatHex8:RA,formatHsl:IA,formatRgb:d0,toString:d0});function f0(){return this.rgb().formatHex()}function RA(){return this.rgb().formatHex8()}function IA(){return cx(this).formatHsl()}function d0(){return this.rgb().formatRgb()}function dl(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=NA.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?p0(e):n===3?new vt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?la(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?la(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=_A.exec(t))?new vt(e[1],e[2],e[3],1):(e=AA.exec(t))?new vt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=TA.exec(t))?la(e[1],e[2],e[3],e[4]):(e=MA.exec(t))?la(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=OA.exec(t))?y0(e[1],e[2]/100,e[3]/100,1):(e=PA.exec(t))?y0(e[1],e[2]/100,e[3]/100,e[4]):h0.hasOwnProperty(t)?p0(h0[t]):t==="transparent"?new vt(NaN,NaN,NaN,0):null}function p0(t){return new vt(t>>16&255,t>>8&255,t&255,1)}function la(t,e,n,i){return i<=0&&(t=e=n=NaN),new vt(t,e,n,i)}function DA(t){return t instanceof Dl||(t=dl(t)),t?(t=t.rgb(),new vt(t.r,t.g,t.b,t.opacity)):new vt}function Qf(t,e,n,i){return arguments.length===1?DA(t):new vt(t,e,n,i??1)}function vt(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}Xp(vt,Qf,ux(Dl,{brighter(t){return t=t==null?Ou:Math.pow(Ou,t),new vt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?hl:Math.pow(hl,t),new vt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new vt(gr(this.r),gr(this.g),gr(this.b),Pu(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:m0,formatHex:m0,formatHex8:BA,formatRgb:g0,toString:g0}));function m0(){return`#${hr(this.r)}${hr(this.g)}${hr(this.b)}`}function BA(){return`#${hr(this.r)}${hr(this.g)}${hr(this.b)}${hr((isNaN(this.opacity)?1:this.opacity)*255)}`}function g0(){const t=Pu(this.opacity);return`${t===1?"rgb(":"rgba("}${gr(this.r)}, ${gr(this.g)}, ${gr(this.b)}${t===1?")":`, ${t})`}`}function Pu(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function gr(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function hr(t){return t=gr(t),(t<16?"0":"")+t.toString(16)}function y0(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new an(t,e,n,i)}function cx(t){if(t instanceof an)return new an(t.h,t.s,t.l,t.opacity);if(t instanceof Dl||(t=dl(t)),!t)return new an;if(t instanceof an)return t;t=t.rgb();var e=t.r/255,n=t.g/255,i=t.b/255,r=Math.min(e,n,i),s=Math.max(e,n,i),o=NaN,l=s-r,a=(s+r)/2;return l?(e===s?o=(n-i)/l+(n<i)*6:n===s?o=(i-e)/l+2:o=(e-n)/l+4,l/=a<.5?s+r:2-s-r,o*=60):l=a>0&&a<1?0:o,new an(o,l,a,t.opacity)}function LA(t,e,n,i){return arguments.length===1?cx(t):new an(t,e,n,i??1)}function an(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}Xp(an,LA,ux(Dl,{brighter(t){return t=t==null?Ou:Math.pow(Ou,t),new an(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?hl:Math.pow(hl,t),new an(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new vt(Sh(t>=240?t-240:t+120,r,i),Sh(t,r,i),Sh(t<120?t+240:t-120,r,i),this.opacity)},clamp(){return new an(v0(this.h),aa(this.s),aa(this.l),Pu(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Pu(this.opacity);return`${t===1?"hsl(":"hsla("}${v0(this.h)}, ${aa(this.s)*100}%, ${aa(this.l)*100}%${t===1?")":`, ${t})`}`}}));function v0(t){return t=(t||0)%360,t<0?t+360:t}function aa(t){return Math.max(0,Math.min(1,t||0))}function Sh(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const hx=t=>()=>t;function zA(t,e){return function(n){return t+n*e}}function $A(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(i){return Math.pow(t+i*e,n)}}function jA(t){return(t=+t)==1?fx:function(e,n){return n-e?$A(e,n,t):hx(isNaN(e)?n:e)}}function fx(t,e){var n=e-t;return n?zA(t,n):hx(isNaN(t)?e:t)}const w0=function t(e){var n=jA(e);function i(r,s){var o=n((r=Qf(r)).r,(s=Qf(s)).r),l=n(r.g,s.g),a=n(r.b,s.b),u=fx(r.opacity,s.opacity);return function(c){return r.r=o(c),r.g=l(c),r.b=a(c),r.opacity=u(c),r+""}}return i.gamma=t,i}(1);function pi(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var Xf=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,kh=new RegExp(Xf.source,"g");function FA(t){return function(){return t}}function VA(t){return function(e){return t(e)+""}}function HA(t,e){var n=Xf.lastIndex=kh.lastIndex=0,i,r,s,o=-1,l=[],a=[];for(t=t+"",e=e+"";(i=Xf.exec(t))&&(r=kh.exec(e));)(s=r.index)>n&&(s=e.slice(n,s),l[o]?l[o]+=s:l[++o]=s),(i=i[0])===(r=r[0])?l[o]?l[o]+=r:l[++o]=r:(l[++o]=null,a.push({i:o,x:pi(i,r)})),n=kh.lastIndex;return n<e.length&&(s=e.slice(n),l[o]?l[o]+=s:l[++o]=s),l.length<2?a[0]?VA(a[0].x):FA(e):(e=a.length,function(u){for(var c=0,h;c<e;++c)l[(h=a[c]).i]=h.x(u);return l.join("")})}var x0=180/Math.PI,Gf={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function dx(t,e,n,i,r,s){var o,l,a;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(a=t*n+e*i)&&(n-=t*a,i-=e*a),(l=Math.sqrt(n*n+i*i))&&(n/=l,i/=l,a/=l),t*i<e*n&&(t=-t,e=-e,a=-a,o=-o),{translateX:r,translateY:s,rotate:Math.atan2(e,t)*x0,skewX:Math.atan(a)*x0,scaleX:o,scaleY:l}}var ua;function WA(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Gf:dx(e.a,e.b,e.c,e.d,e.e,e.f)}function UA(t){return t==null||(ua||(ua=document.createElementNS("http://www.w3.org/2000/svg","g")),ua.setAttribute("transform",t),!(t=ua.transform.baseVal.consolidate()))?Gf:(t=t.matrix,dx(t.a,t.b,t.c,t.d,t.e,t.f))}function px(t,e,n,i){function r(u){return u.length?u.pop()+" ":""}function s(u,c,h,f,d,p){if(u!==h||c!==f){var g=d.push("translate(",null,e,null,n);p.push({i:g-4,x:pi(u,h)},{i:g-2,x:pi(c,f)})}else(h||f)&&d.push("translate("+h+e+f+n)}function o(u,c,h,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.push({i:h.push(r(h)+"rotate(",null,i)-2,x:pi(u,c)})):c&&h.push(r(h)+"rotate("+c+i)}function l(u,c,h,f){u!==c?f.push({i:h.push(r(h)+"skewX(",null,i)-2,x:pi(u,c)}):c&&h.push(r(h)+"skewX("+c+i)}function a(u,c,h,f,d,p){if(u!==h||c!==f){var g=d.push(r(d)+"scale(",null,",",null,")");p.push({i:g-4,x:pi(u,h)},{i:g-2,x:pi(c,f)})}else(h!==1||f!==1)&&d.push(r(d)+"scale("+h+","+f+")")}return function(u,c){var h=[],f=[];return u=t(u),c=t(c),s(u.translateX,u.translateY,c.translateX,c.translateY,h,f),o(u.rotate,c.rotate,h,f),l(u.skewX,c.skewX,h,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,h,f),u=c=null,function(d){for(var p=-1,g=f.length,S;++p<g;)h[(S=f[p]).i]=S.x(d);return h.join("")}}}var KA=px(WA,"px, ","px)","deg)"),qA=px(UA,", ",")",")"),YA=1e-12;function S0(t){return((t=Math.exp(t))+1/t)/2}function QA(t){return((t=Math.exp(t))-1/t)/2}function XA(t){return((t=Math.exp(2*t))-1)/(t+1)}const GA=function t(e,n,i){function r(s,o){var l=s[0],a=s[1],u=s[2],c=o[0],h=o[1],f=o[2],d=c-l,p=h-a,g=d*d+p*p,S,m;if(g<YA)m=Math.log(f/u)/e,S=function(N){return[l+N*d,a+N*p,u*Math.exp(e*N*m)]};else{var y=Math.sqrt(g),v=(f*f-u*u+i*g)/(2*u*n*y),x=(f*f-u*u-i*g)/(2*f*n*y),b=Math.log(Math.sqrt(v*v+1)-v),C=Math.log(Math.sqrt(x*x+1)-x);m=(C-b)/e,S=function(N){var M=N*m,_=S0(b),P=u/(n*y)*(_*XA(e*M+b)-QA(b));return[l+P*d,a+P*p,u*_/S0(e*M+b)]}}return S.duration=m*1e3*e/Math.SQRT2,S}return r.rho=function(s){var o=Math.max(.001,+s),l=o*o,a=l*l;return t(o,l,a)},r}(Math.SQRT2,2,4);var Is=0,Co=0,ao=0,mx=1e3,Ru,Eo,Iu=0,Cr=0,Nc=0,pl=typeof performance=="object"&&performance.now?performance:Date,gx=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Gp(){return Cr||(gx(JA),Cr=pl.now()+Nc)}function JA(){Cr=0}function Du(){this._call=this._time=this._next=null}Du.prototype=yx.prototype={constructor:Du,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Gp():+n)+(e==null?0:+e),!this._next&&Eo!==this&&(Eo?Eo._next=this:Ru=this,Eo=this),this._call=t,this._time=n,Jf()},stop:function(){this._call&&(this._call=null,this._time=1/0,Jf())}};function yx(t,e,n){var i=new Du;return i.restart(t,e,n),i}function ZA(){Gp(),++Is;for(var t=Ru,e;t;)(e=Cr-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Is}function k0(){Cr=(Iu=pl.now())+Nc,Is=Co=0;try{ZA()}finally{Is=0,tT(),Cr=0}}function eT(){var t=pl.now(),e=t-Iu;e>mx&&(Nc-=e,Iu=t)}function tT(){for(var t,e=Ru,n,i=1/0;e;)e._call?(i>e._time&&(i=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Ru=n);Eo=t,Jf(i)}function Jf(t){if(!Is){Co&&(Co=clearTimeout(Co));var e=t-Cr;e>24?(t<1/0&&(Co=setTimeout(k0,t-pl.now()-Nc)),ao&&(ao=clearInterval(ao))):(ao||(Iu=pl.now(),ao=setInterval(eT,mx)),Is=1,gx(k0))}}function b0(t,e,n){var i=new Du;return e=e==null?0:+e,i.restart(r=>{i.stop(),t(r+e)},e,n),i}var nT=Cc("start","end","cancel","interrupt"),iT=[],vx=0,C0=1,Zf=2,Ya=3,E0=4,ed=5,Qa=6;function _c(t,e,n,i,r,s){var o=t.__transition;if(!o)t.__transition={};else if(n in o)return;rT(t,n,{name:e,index:i,group:r,on:nT,tween:iT,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:vx})}function Jp(t,e){var n=yn(t,e);if(n.state>vx)throw new Error("too late; already scheduled");return n}function jn(t,e){var n=yn(t,e);if(n.state>Ya)throw new Error("too late; already running");return n}function yn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function rT(t,e,n){var i=t.__transition,r;i[e]=n,n.timer=yx(s,0,n.time);function s(u){n.state=C0,n.timer.restart(o,n.delay,n.time),n.delay<=u&&o(u-n.delay)}function o(u){var c,h,f,d;if(n.state!==C0)return a();for(c in i)if(d=i[c],d.name===n.name){if(d.state===Ya)return b0(o);d.state===E0?(d.state=Qa,d.timer.stop(),d.on.call("interrupt",t,t.__data__,d.index,d.group),delete i[c]):+c<e&&(d.state=Qa,d.timer.stop(),d.on.call("cancel",t,t.__data__,d.index,d.group),delete i[c])}if(b0(function(){n.state===Ya&&(n.state=E0,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Zf,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Zf){for(n.state=Ya,r=new Array(f=n.tween.length),c=0,h=-1;c<f;++c)(d=n.tween[c].value.call(t,t.__data__,n.index,n.group))&&(r[++h]=d);r.length=h+1}}function l(u){for(var c=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(a),n.state=ed,1),h=-1,f=r.length;++h<f;)r[h].call(t,c);n.state===ed&&(n.on.call("end",t,t.__data__,n.index,n.group),a())}function a(){n.state=Qa,n.timer.stop(),delete i[e];for(var u in i)return;delete t.__transition}}function Xa(t,e){var n=t.__transition,i,r,s=!0,o;if(n){e=e==null?null:e+"";for(o in n){if((i=n[o]).name!==e){s=!1;continue}r=i.state>Zf&&i.state<ed,i.state=Qa,i.timer.stop(),i.on.call(r?"interrupt":"cancel",t,t.__data__,i.index,i.group),delete n[o]}s&&delete t.__transition}}function sT(t){return this.each(function(){Xa(this,t)})}function oT(t,e){var n,i;return function(){var r=jn(this,t),s=r.tween;if(s!==n){i=n=s;for(var o=0,l=i.length;o<l;++o)if(i[o].name===e){i=i.slice(),i.splice(o,1);break}}r.tween=i}}function lT(t,e,n){var i,r;if(typeof n!="function")throw new Error;return function(){var s=jn(this,t),o=s.tween;if(o!==i){r=(i=o).slice();for(var l={name:e,value:n},a=0,u=r.length;a<u;++a)if(r[a].name===e){r[a]=l;break}a===u&&r.push(l)}s.tween=r}}function aT(t,e){var n=this._id;if(t+="",arguments.length<2){for(var i=yn(this.node(),n).tween,r=0,s=i.length,o;r<s;++r)if((o=i[r]).name===t)return o.value;return null}return this.each((e==null?oT:lT)(n,t,e))}function Zp(t,e,n){var i=t._id;return t.each(function(){var r=jn(this,i);(r.value||(r.value={}))[e]=n.apply(this,arguments)}),function(r){return yn(r,i).value[e]}}function wx(t,e){var n;return(typeof e=="number"?pi:e instanceof dl?w0:(n=dl(e))?(e=n,w0):HA)(t,e)}function uT(t){return function(){this.removeAttribute(t)}}function cT(t){return function(){this.removeAttributeNS(t.space,t.local)}}function hT(t,e,n){var i,r=n+"",s;return function(){var o=this.getAttribute(t);return o===r?null:o===i?s:s=e(i=o,n)}}function fT(t,e,n){var i,r=n+"",s;return function(){var o=this.getAttributeNS(t.space,t.local);return o===r?null:o===i?s:s=e(i=o,n)}}function dT(t,e,n){var i,r,s;return function(){var o,l=n(this),a;return l==null?void this.removeAttribute(t):(o=this.getAttribute(t),a=l+"",o===a?null:o===i&&a===r?s:(r=a,s=e(i=o,l)))}}function pT(t,e,n){var i,r,s;return function(){var o,l=n(this),a;return l==null?void this.removeAttributeNS(t.space,t.local):(o=this.getAttributeNS(t.space,t.local),a=l+"",o===a?null:o===i&&a===r?s:(r=a,s=e(i=o,l)))}}function mT(t,e){var n=Ec(t),i=n==="transform"?qA:wx;return this.attrTween(t,typeof e=="function"?(n.local?pT:dT)(n,i,Zp(this,"attr."+t,e)):e==null?(n.local?cT:uT)(n):(n.local?fT:hT)(n,i,e))}function gT(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function yT(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function vT(t,e){var n,i;function r(){var s=e.apply(this,arguments);return s!==i&&(n=(i=s)&&yT(t,s)),n}return r._value=e,r}function wT(t,e){var n,i;function r(){var s=e.apply(this,arguments);return s!==i&&(n=(i=s)&&gT(t,s)),n}return r._value=e,r}function xT(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var i=Ec(t);return this.tween(n,(i.local?vT:wT)(i,e))}function ST(t,e){return function(){Jp(this,t).delay=+e.apply(this,arguments)}}function kT(t,e){return e=+e,function(){Jp(this,t).delay=e}}function bT(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?ST:kT)(e,t)):yn(this.node(),e).delay}function CT(t,e){return function(){jn(this,t).duration=+e.apply(this,arguments)}}function ET(t,e){return e=+e,function(){jn(this,t).duration=e}}function NT(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?CT:ET)(e,t)):yn(this.node(),e).duration}function _T(t,e){if(typeof e!="function")throw new Error;return function(){jn(this,t).ease=e}}function AT(t){var e=this._id;return arguments.length?this.each(_T(e,t)):yn(this.node(),e).ease}function TT(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;jn(this,t).ease=n}}function MT(t){if(typeof t!="function")throw new Error;return this.each(TT(this._id,t))}function OT(t){typeof t!="function"&&(t=Gw(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r<n;++r)for(var s=e[r],o=s.length,l=i[r]=[],a,u=0;u<o;++u)(a=s[u])&&t.call(a,a.__data__,u,s)&&l.push(a);return new si(i,this._parents,this._name,this._id)}function PT(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,i=e.length,r=n.length,s=Math.min(i,r),o=new Array(i),l=0;l<s;++l)for(var a=e[l],u=n[l],c=a.length,h=o[l]=new Array(c),f,d=0;d<c;++d)(f=a[d]||u[d])&&(h[d]=f);for(;l<i;++l)o[l]=e[l];return new si(o,this._parents,this._name,this._id)}function RT(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function IT(t,e,n){var i,r,s=RT(e)?Jp:jn;return function(){var o=s(this,t),l=o.on;l!==i&&(r=(i=l).copy()).on(e,n),o.on=r}}function DT(t,e){var n=this._id;return arguments.length<2?yn(this.node(),n).on.on(t):this.each(IT(n,t,e))}function BT(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function LT(){return this.on("end.remove",BT(this._id))}function zT(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Yp(t));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o<r;++o)for(var l=i[o],a=l.length,u=s[o]=new Array(a),c,h,f=0;f<a;++f)(c=l[f])&&(h=t.call(c,c.__data__,f,l))&&("__data__"in c&&(h.__data__=c.__data__),u[f]=h,_c(u[f],e,n,f,u,yn(c,n)));return new si(s,this._parents,e,n)}function $T(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Xw(t));for(var i=this._groups,r=i.length,s=[],o=[],l=0;l<r;++l)for(var a=i[l],u=a.length,c,h=0;h<u;++h)if(c=a[h]){for(var f=t.call(c,c.__data__,h,a),d,p=yn(c,n),g=0,S=f.length;g<S;++g)(d=f[g])&&_c(d,e,n,g,f,p);s.push(f),o.push(c)}return new si(s,o,e,n)}var jT=Il.prototype.constructor;function FT(){return new jT(this._groups,this._parents)}function VT(t,e){var n,i,r;return function(){var s=Rs(this,t),o=(this.style.removeProperty(t),Rs(this,t));return s===o?null:s===n&&o===i?r:r=e(n=s,i=o)}}function xx(t){return function(){this.style.removeProperty(t)}}function HT(t,e,n){var i,r=n+"",s;return function(){var o=Rs(this,t);return o===r?null:o===i?s:s=e(i=o,n)}}function WT(t,e,n){var i,r,s;return function(){var o=Rs(this,t),l=n(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(t),Rs(this,t))),o===a?null:o===i&&a===r?s:(r=a,s=e(i=o,l))}}function UT(t,e){var n,i,r,s="style."+e,o="end."+s,l;return function(){var a=jn(this,t),u=a.on,c=a.value[s]==null?l||(l=xx(e)):void 0;(u!==n||r!==c)&&(i=(n=u).copy()).on(o,r=c),a.on=i}}function KT(t,e,n){var i=(t+="")=="transform"?KA:wx;return e==null?this.styleTween(t,VT(t,i)).on("end.style."+t,xx(t)):typeof e=="function"?this.styleTween(t,WT(t,i,Zp(this,"style."+t,e))).each(UT(this._id,t)):this.styleTween(t,HT(t,i,e),n).on("end.style."+t,null)}function qT(t,e,n){return function(i){this.style.setProperty(t,e.call(this,i),n)}}function YT(t,e,n){var i,r;function s(){var o=e.apply(this,arguments);return o!==r&&(i=(r=o)&&qT(t,o,n)),i}return s._value=e,s}function QT(t,e,n){var i="style."+(t+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(e==null)return this.tween(i,null);if(typeof e!="function")throw new Error;return this.tween(i,YT(t,e,n??""))}function XT(t){return function(){this.textContent=t}}function GT(t){return function(){var e=t(this);this.textContent=e??""}}function JT(t){return this.tween("text",typeof t=="function"?GT(Zp(this,"text",t)):XT(t==null?"":t+""))}function ZT(t){return function(e){this.textContent=t.call(this,e)}}function eM(t){var e,n;function i(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&ZT(r)),e}return i._value=t,i}function tM(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,eM(t))}function nM(){for(var t=this._name,e=this._id,n=Sx(),i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],l=o.length,a,u=0;u<l;++u)if(a=o[u]){var c=yn(a,e);_c(a,t,n,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new si(i,this._parents,t,n)}function iM(){var t,e,n=this,i=n._id,r=n.size();return new Promise(function(s,o){var l={value:o},a={value:function(){--r===0&&s()}};n.each(function(){var u=jn(this,i),c=u.on;c!==t&&(e=(t=c).copy(),e._.cancel.push(l),e._.interrupt.push(l),e._.end.push(a)),u.on=e}),r===0&&s()})}var rM=0;function si(t,e,n,i){this._groups=t,this._parents=e,this._name=n,this._id=i}function Sx(){return++rM}var Wn=Il.prototype;si.prototype={constructor:si,select:zT,selectAll:$T,selectChild:Wn.selectChild,selectChildren:Wn.selectChildren,filter:OT,merge:PT,selection:FT,transition:nM,call:Wn.call,nodes:Wn.nodes,node:Wn.node,size:Wn.size,empty:Wn.empty,each:Wn.each,on:DT,attr:mT,attrTween:xT,style:KT,styleTween:QT,text:JT,textTween:tM,remove:LT,tween:aT,delay:bT,duration:NT,ease:AT,easeVarying:MT,end:iM,[Symbol.iterator]:Wn[Symbol.iterator]};function sM(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var oM={time:null,delay:0,duration:250,ease:sM};function lM(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function aM(t){var e,n;t instanceof si?(e=t._id,t=t._name):(e=Sx(),(n=oM).time=Gp(),t=t==null?null:t+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],l=o.length,a,u=0;u<l;++u)(a=o[u])&&_c(a,t,e,u,o,n||lM(a,e));return new si(i,this._parents,t,e)}Il.prototype.interrupt=sT;Il.prototype.transition=aM;const ca=t=>()=>t;function uM(t,{sourceEvent:e,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function Gn(t,e,n){this.k=t,this.x=e,this.y=n}Gn.prototype={constructor:Gn,scale:function(t){return t===1?this:new Gn(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new Gn(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Di=new Gn(1,0,0);Gn.prototype;function bh(t){t.stopImmediatePropagation()}function uo(t){t.preventDefault(),t.stopImmediatePropagation()}function cM(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function hM(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function N0(){return this.__zoom||Di}function fM(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function dM(){return navigator.maxTouchPoints||"ontouchstart"in this}function pM(t,e,n){var i=t.invertX(e[0][0])-n[0][0],r=t.invertX(e[1][0])-n[1][0],s=t.invertY(e[0][1])-n[0][1],o=t.invertY(e[1][1])-n[1][1];return t.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function mM(){var t=cM,e=hM,n=pM,i=fM,r=dM,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=GA,u=Cc("start","zoom","end"),c,h,f,d=500,p=150,g=0,S=10;function m(w){w.property("__zoom",N0).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",_).on("dblclick.zoom",P).filter(r).on("touchstart.zoom",B).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(w,E,T,z){var R=w.selection?w.selection():w;R.property("__zoom",N0),w!==R?b(w,E,T,z):R.interrupt().each(function(){C(this,arguments).event(z).start().zoom(null,typeof E=="function"?E.apply(this,arguments):E).end()})},m.scaleBy=function(w,E,T,z){m.scaleTo(w,function(){var R=this.__zoom.k,A=typeof E=="function"?E.apply(this,arguments):E;return R*A},T,z)},m.scaleTo=function(w,E,T,z){m.transform(w,function(){var R=e.apply(this,arguments),A=this.__zoom,D=T==null?x(R):typeof T=="function"?T.apply(this,arguments):T,I=A.invert(D),$=typeof E=="function"?E.apply(this,arguments):E;return n(v(y(A,$),D,I),R,o)},T,z)},m.translateBy=function(w,E,T,z){m.transform(w,function(){return n(this.__zoom.translate(typeof E=="function"?E.apply(this,arguments):E,typeof T=="function"?T.apply(this,arguments):T),e.apply(this,arguments),o)},null,z)},m.translateTo=function(w,E,T,z,R){m.transform(w,function(){var A=e.apply(this,arguments),D=this.__zoom,I=z==null?x(A):typeof z=="function"?z.apply(this,arguments):z;return n(Di.translate(I[0],I[1]).scale(D.k).translate(typeof E=="function"?-E.apply(this,arguments):-E,typeof T=="function"?-T.apply(this,arguments):-T),A,o)},z,R)};function y(w,E){return E=Math.max(s[0],Math.min(s[1],E)),E===w.k?w:new Gn(E,w.x,w.y)}function v(w,E,T){var z=E[0]-T[0]*w.k,R=E[1]-T[1]*w.k;return z===w.x&&R===w.y?w:new Gn(w.k,z,R)}function x(w){return[(+w[0][0]+ +w[1][0])/2,(+w[0][1]+ +w[1][1])/2]}function b(w,E,T,z){w.on("start.zoom",function(){C(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(z).end()}).tween("zoom",function(){var R=this,A=arguments,D=C(R,A).event(z),I=e.apply(R,A),$=T==null?x(I):typeof T=="function"?T.apply(R,A):T,U=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),W=R.__zoom,Q=typeof E=="function"?E.apply(R,A):E,te=a(W.invert($).concat(U/W.k),Q.invert($).concat(U/Q.k));return function(ne){if(ne===1)ne=Q;else{var he=te(ne),Ee=U/he[2];ne=new Gn(Ee,$[0]-he[0]*Ee,$[1]-he[1]*Ee)}D.zoom(null,ne)}})}function C(w,E,T){return!T&&w.__zooming||new N(w,E)}function N(w,E){this.that=w,this.args=E,this.active=0,this.sourceEvent=null,this.extent=e.apply(w,E),this.taps=0}N.prototype={event:function(w){return w&&(this.sourceEvent=w),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(w,E){return this.mouse&&w!=="mouse"&&(this.mouse[1]=E.invert(this.mouse[0])),this.touch0&&w!=="touch"&&(this.touch0[1]=E.invert(this.touch0[0])),this.touch1&&w!=="touch"&&(this.touch1[1]=E.invert(this.touch1[0])),this.that.__zoom=E,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(w){var E=ln(this.that).datum();u.call(w,this.that,new uM(w,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:u}),E)}};function M(w,...E){if(!t.apply(this,arguments))return;var T=C(this,E).event(w),z=this.__zoom,R=Math.max(s[0],Math.min(s[1],z.k*Math.pow(2,i.apply(this,arguments)))),A=Tn(w);if(T.wheel)(T.mouse[0][0]!==A[0]||T.mouse[0][1]!==A[1])&&(T.mouse[1]=z.invert(T.mouse[0]=A)),clearTimeout(T.wheel);else{if(z.k===R)return;T.mouse=[A,z.invert(A)],Xa(this),T.start()}uo(w),T.wheel=setTimeout(D,p),T.zoom("mouse",n(v(y(z,R),T.mouse[0],T.mouse[1]),T.extent,o));function D(){T.wheel=null,T.end()}}function _(w,...E){if(f||!t.apply(this,arguments))return;var T=w.currentTarget,z=C(this,E,!0).event(w),R=ln(w.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",U,!0),A=Tn(w,T),D=w.clientX,I=w.clientY;lx(w.view),bh(w),z.mouse=[A,this.__zoom.invert(A)],Xa(this),z.start();function $(W){if(uo(W),!z.moved){var Q=W.clientX-D,te=W.clientY-I;z.moved=Q*Q+te*te>g}z.event(W).zoom("mouse",n(v(z.that.__zoom,z.mouse[0]=Tn(W,T),z.mouse[1]),z.extent,o))}function U(W){R.on("mousemove.zoom mouseup.zoom",null),ax(W.view,z.moved),uo(W),z.event(W).end()}}function P(w,...E){if(t.apply(this,arguments)){var T=this.__zoom,z=Tn(w.changedTouches?w.changedTouches[0]:w,this),R=T.invert(z),A=T.k*(w.shiftKey?.5:2),D=n(v(y(T,A),z,R),e.apply(this,E),o);uo(w),l>0?ln(this).transition().duration(l).call(b,D,z,w):ln(this).call(m.transform,D,z,w)}}function B(w,...E){if(t.apply(this,arguments)){var T=w.touches,z=T.length,R=C(this,E,w.changedTouches.length===z).event(w),A,D,I,$;for(bh(w),D=0;D<z;++D)I=T[D],$=Tn(I,this),$=[$,this.__zoom.invert($),I.identifier],R.touch0?!R.touch1&&R.touch0[2]!==$[2]&&(R.touch1=$,R.taps=0):(R.touch0=$,A=!0,R.taps=1+!!c);c&&(c=clearTimeout(c)),A&&(R.taps<2&&(h=$[0],c=setTimeout(function(){c=null},d)),Xa(this),R.start())}}function L(w,...E){if(this.__zooming){var T=C(this,E).event(w),z=w.changedTouches,R=z.length,A,D,I,$;for(uo(w),A=0;A<R;++A)D=z[A],I=Tn(D,this),T.touch0&&T.touch0[2]===D.identifier?T.touch0[0]=I:T.touch1&&T.touch1[2]===D.identifier&&(T.touch1[0]=I);if(D=T.that.__zoom,T.touch1){var U=T.touch0[0],W=T.touch0[1],Q=T.touch1[0],te=T.touch1[1],ne=(ne=Q[0]-U[0])*ne+(ne=Q[1]-U[1])*ne,he=(he=te[0]-W[0])*he+(he=te[1]-W[1])*he;D=y(D,Math.sqrt(ne/he)),I=[(U[0]+Q[0])/2,(U[1]+Q[1])/2],$=[(W[0]+te[0])/2,(W[1]+te[1])/2]}else if(T.touch0)I=T.touch0[0],$=T.touch0[1];else return;T.zoom("touch",n(v(D,I,$),T.extent,o))}}function F(w,...E){if(this.__zooming){var T=C(this,E).event(w),z=w.changedTouches,R=z.length,A,D;for(bh(w),f&&clearTimeout(f),f=setTimeout(function(){f=null},d),A=0;A<R;++A)D=z[A],T.touch0&&T.touch0[2]===D.identifier?delete T.touch0:T.touch1&&T.touch1[2]===D.identifier&&delete T.touch1;if(T.touch1&&!T.touch0&&(T.touch0=T.touch1,delete T.touch1),T.touch0)T.touch0[1]=this.__zoom.invert(T.touch0[0]);else if(T.end(),T.taps===2&&(D=Tn(D,this),Math.hypot(h[0]-D[0],h[1]-D[1])<S)){var I=ln(this).on("dblclick.zoom");I&&I.apply(this,arguments)}}}return m.wheelDelta=function(w){return arguments.length?(i=typeof w=="function"?w:ca(+w),m):i},m.filter=function(w){return arguments.length?(t=typeof w=="function"?w:ca(!!w),m):t},m.touchable=function(w){return arguments.length?(r=typeof w=="function"?w:ca(!!w),m):r},m.extent=function(w){return arguments.length?(e=typeof w=="function"?w:ca([[+w[0][0],+w[0][1]],[+w[1][0],+w[1][1]]]),m):e},m.scaleExtent=function(w){return arguments.length?(s[0]=+w[0],s[1]=+w[1],m):[s[0],s[1]]},m.translateExtent=function(w){return arguments.length?(o[0][0]=+w[0][0],o[1][0]=+w[1][0],o[0][1]=+w[0][1],o[1][1]=+w[1][1],m):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},m.constrain=function(w){return arguments.length?(n=w,m):n},m.duration=function(w){return arguments.length?(l=+w,m):l},m.interpolate=function(w){return arguments.length?(a=w,m):a},m.on=function(){var w=u.on.apply(u,arguments);return w===u?m:w},m.clickDistance=function(w){return arguments.length?(g=(w=+w)*w,m):Math.sqrt(g)},m.tapDistance=function(w){return arguments.length?(S=+w,m):S},m}const Ac=O.createContext(null),gM=Ac.Provider,oi={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,e)=>`Couldn't create edge for ${t?"target":"source"} handle id: "${t?e.targetHandle:e.sourceHandle}", edge id: ${e.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},kx=oi.error001();function Se(t,e){const n=O.useContext(Ac);if(n===null)throw new Error(kx);return Yw(n,t,e)}const We=()=>{const t=O.useContext(Ac);if(t===null)throw new Error(kx);return O.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy}),[t])},yM=t=>t.userSelectionActive?"none":"all";function bx({position:t,children:e,className:n,style:i,...r}){const s=Se(yM),o=`${t}`.split("-");return j.createElement("div",{className:dt(["react-flow__panel",n,...o]),style:{...i,pointerEvents:s},...r},e)}function vM({proOptions:t,position:e="bottom-right"}){return t!=null&&t.hideAttribution?null:j.createElement(bx,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},j.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const wM=({x:t,y:e,label:n,labelStyle:i={},labelShowBg:r=!0,labelBgStyle:s={},labelBgPadding:o=[2,4],labelBgBorderRadius:l=2,children:a,className:u,...c})=>{const h=O.useRef(null),[f,d]=O.useState({x:0,y:0,width:0,height:0}),p=dt(["react-flow__edge-textwrapper",u]);return O.useEffect(()=>{if(h.current){const g=h.current.getBBox();d({x:g.x,y:g.y,width:g.width,height:g.height})}},[n]),typeof n>"u"||!n?null:j.createElement("g",{transform:`translate(${t-f.width/2} ${e-f.height/2})`,className:p,visibility:f.width?"visible":"hidden",...c},r&&j.createElement("rect",{width:f.width+2*o[0],x:-o[0],y:-o[1],height:f.height+2*o[1],className:"react-flow__edge-textbg",style:s,rx:l,ry:l}),j.createElement("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:h,style:i},n),a)};var xM=O.memo(wM);const em=t=>({width:t.offsetWidth,height:t.offsetHeight}),Ds=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),tm=(t={x:0,y:0},e)=>({x:Ds(t.x,e[0][0],e[1][0]),y:Ds(t.y,e[0][1],e[1][1])}),_0=(t,e,n)=>t<e?Ds(Math.abs(t-e),1,50)/50:t>n?-Ds(Math.abs(t-n),1,50)/50:0,Cx=(t,e)=>{const n=_0(t.x,35,e.width-35)*20,i=_0(t.y,35,e.height-35)*20;return[n,i]},Ex=t=>{var e;return((e=t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},SM=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),nm=({x:t,y:e,width:n,height:i})=>({x:t,y:e,x2:t+n,y2:e+i}),kM=({x:t,y:e,x2:n,y2:i})=>({x:t,y:e,width:n-t,height:i-e}),A0=t=>({...t.positionAbsolute||{x:0,y:0},width:t.width||0,height:t.height||0}),td=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),i=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*i)},bM=t=>Vt(t.width)&&Vt(t.height)&&Vt(t.x)&&Vt(t.y),Vt=t=>!isNaN(t)&&isFinite(t),Ae=Symbol.for("internals"),Nx=["Enter"," ","Escape"],CM=(t,e)=>{},EM=t=>"nativeEvent"in t;function nd(t){var r,s;const e=EM(t)?t.nativeEvent:t,n=((s=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:s[0])||t.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const _x=t=>"clientX"in t,Bi=(t,e)=>{var s,o;const n=_x(t),i=n?t.clientX:(s=t.touches)==null?void 0:s[0].clientX,r=n?t.clientY:(o=t.touches)==null?void 0:o[0].clientY;return{x:i-((e==null?void 0:e.left)??0),y:r-((e==null?void 0:e.top)??0)}},Bu=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0},Ys=({id:t,path:e,labelX:n,labelY:i,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:h,markerStart:f,interactionWidth:d=20})=>j.createElement(j.Fragment,null,j.createElement("path",{id:t,style:c,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:h,markerStart:f}),d&&j.createElement("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}),r&&Vt(n)&&Vt(i)?j.createElement(xM,{x:n,y:i,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u}):null);Ys.displayName="BaseEdge";function co(t,e,n){return n===void 0?n:i=>{const r=e().edges.find(s=>s.id===t);r&&n(i,{...r})}}function Ax({sourceX:t,sourceY:e,targetX:n,targetY:i}){const r=Math.abs(n-t)/2,s=n<t?n+r:n-r,o=Math.abs(i-e)/2,l=i<e?i+o:i-o;return[s,l,r,o]}function Tx({sourceX:t,sourceY:e,targetX:n,targetY:i,sourceControlX:r,sourceControlY:s,targetControlX:o,targetControlY:l}){const a=t*.125+r*.375+o*.375+n*.125,u=e*.125+s*.375+l*.375+i*.125,c=Math.abs(a-t),h=Math.abs(u-e);return[a,u,c,h]}var Er;(function(t){t.Strict="strict",t.Loose="loose"})(Er||(Er={}));var fr;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(fr||(fr={}));var ml;(function(t){t.Partial="partial",t.Full="full"})(ml||(ml={}));var xi;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(xi||(xi={}));var gl;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(gl||(gl={}));var G;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(G||(G={}));function T0({pos:t,x1:e,y1:n,x2:i,y2:r}){return t===G.Left||t===G.Right?[.5*(e+i),n]:[e,.5*(n+r)]}function Mx({sourceX:t,sourceY:e,sourcePosition:n=G.Bottom,targetX:i,targetY:r,targetPosition:s=G.Top}){const[o,l]=T0({pos:n,x1:t,y1:e,x2:i,y2:r}),[a,u]=T0({pos:s,x1:i,y1:r,x2:t,y2:e}),[c,h,f,d]=Tx({sourceX:t,sourceY:e,targetX:i,targetY:r,sourceControlX:o,sourceControlY:l,targetControlX:a,targetControlY:u});return[`M${t},${e} C${o},${l} ${a},${u} ${i},${r}`,c,h,f,d]}const im=O.memo(({sourceX:t,sourceY:e,targetX:n,targetY:i,sourcePosition:r=G.Bottom,targetPosition:s=G.Top,label:o,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:h,style:f,markerEnd:d,markerStart:p,interactionWidth:g})=>{const[S,m,y]=Mx({sourceX:t,sourceY:e,sourcePosition:r,targetX:n,targetY:i,targetPosition:s});return j.createElement(Ys,{path:S,labelX:m,labelY:y,label:o,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:h,style:f,markerEnd:d,markerStart:p,interactionWidth:g})});im.displayName="SimpleBezierEdge";const M0={[G.Left]:{x:-1,y:0},[G.Right]:{x:1,y:0},[G.Top]:{x:0,y:-1},[G.Bottom]:{x:0,y:1}},NM=({source:t,sourcePosition:e=G.Bottom,target:n})=>e===G.Left||e===G.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},O0=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function _M({source:t,sourcePosition:e=G.Bottom,target:n,targetPosition:i=G.Top,center:r,offset:s}){const o=M0[e],l=M0[i],a={x:t.x+o.x*s,y:t.y+o.y*s},u={x:n.x+l.x*s,y:n.y+l.y*s},c=NM({source:a,sourcePosition:e,target:u}),h=c.x!==0?"x":"y",f=c[h];let d=[],p,g;const S={x:0,y:0},m={x:0,y:0},[y,v,x,b]=Ax({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(o[h]*l[h]===-1){p=r.x??y,g=r.y??v;const N=[{x:p,y:a.y},{x:p,y:u.y}],M=[{x:a.x,y:g},{x:u.x,y:g}];o[h]===f?d=h==="x"?N:M:d=h==="x"?M:N}else{const N=[{x:a.x,y:u.y}],M=[{x:u.x,y:a.y}];if(h==="x"?d=o.x===f?M:N:d=o.y===f?N:M,e===i){const F=Math.abs(t[h]-n[h]);if(F<=s){const w=Math.min(s-1,s-F);o[h]===f?S[h]=(a[h]>t[h]?-1:1)*w:m[h]=(u[h]>n[h]?-1:1)*w}}if(e!==i){const F=h==="x"?"y":"x",w=o[h]===l[F],E=a[F]>u[F],T=a[F]<u[F];(o[h]===1&&(!w&&E||w&&T)||o[h]!==1&&(!w&&T||w&&E))&&(d=h==="x"?N:M)}const _={x:a.x+S.x,y:a.y+S.y},P={x:u.x+m.x,y:u.y+m.y},B=Math.max(Math.abs(_.x-d[0].x),Math.abs(P.x-d[0].x)),L=Math.max(Math.abs(_.y-d[0].y),Math.abs(P.y-d[0].y));B>=L?(p=(_.x+P.x)/2,g=d[0].y):(p=d[0].x,g=(_.y+P.y)/2)}return[[t,{x:a.x+S.x,y:a.y+S.y},...d,{x:u.x+m.x,y:u.y+m.y},n],p,g,x,b]}function AM(t,e,n,i){const r=Math.min(O0(t,e)/2,O0(e,n)/2,i),{x:s,y:o}=e;if(t.x===s&&s===n.x||t.y===o&&o===n.y)return`L${s} ${o}`;if(t.y===o){const u=t.x<n.x?-1:1,c=t.y<n.y?1:-1;return`L ${s+r*u},${o}Q ${s},${o} ${s},${o+r*c}`}const l=t.x<n.x?1:-1,a=t.y<n.y?-1:1;return`L ${s},${o+r*a}Q ${s},${o} ${s+r*l},${o}`}function id({sourceX:t,sourceY:e,sourcePosition:n=G.Bottom,targetX:i,targetY:r,targetPosition:s=G.Top,borderRadius:o=5,centerX:l,centerY:a,offset:u=20}){const[c,h,f,d,p]=_M({source:{x:t,y:e},sourcePosition:n,target:{x:i,y:r},targetPosition:s,center:{x:l,y:a},offset:u});return[c.reduce((S,m,y)=>{let v="";return y>0&&y<c.length-1?v=AM(c[y-1],m,c[y+1],o):v=`${y===0?"M":"L"}${m.x} ${m.y}`,S+=v,S},""),h,f,d,p]}const Tc=O.memo(({sourceX:t,sourceY:e,targetX:n,targetY:i,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,sourcePosition:h=G.Bottom,targetPosition:f=G.Top,markerEnd:d,markerStart:p,pathOptions:g,interactionWidth:S})=>{const[m,y,v]=id({sourceX:t,sourceY:e,sourcePosition:h,targetX:n,targetY:i,targetPosition:f,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset});return j.createElement(Ys,{path:m,labelX:y,labelY:v,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:d,markerStart:p,interactionWidth:S})});Tc.displayName="SmoothStepEdge";const rm=O.memo(t=>{var e;return j.createElement(Tc,{...t,pathOptions:O.useMemo(()=>{var n;return{borderRadius:0,offset:(n=t.pathOptions)==null?void 0:n.offset}},[(e=t.pathOptions)==null?void 0:e.offset])})});rm.displayName="StepEdge";function TM({sourceX:t,sourceY:e,targetX:n,targetY:i}){const[r,s,o,l]=Ax({sourceX:t,sourceY:e,targetX:n,targetY:i});return[`M ${t},${e}L ${n},${i}`,r,s,o,l]}const sm=O.memo(({sourceX:t,sourceY:e,targetX:n,targetY:i,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:h,markerStart:f,interactionWidth:d})=>{const[p,g,S]=TM({sourceX:t,sourceY:e,targetX:n,targetY:i});return j.createElement(Ys,{path:p,labelX:g,labelY:S,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:h,markerStart:f,interactionWidth:d})});sm.displayName="StraightEdge";function ha(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function P0({pos:t,x1:e,y1:n,x2:i,y2:r,c:s}){switch(t){case G.Left:return[e-ha(e-i,s),n];case G.Right:return[e+ha(i-e,s),n];case G.Top:return[e,n-ha(n-r,s)];case G.Bottom:return[e,n+ha(r-n,s)]}}function om({sourceX:t,sourceY:e,sourcePosition:n=G.Bottom,targetX:i,targetY:r,targetPosition:s=G.Top,curvature:o=.25}){const[l,a]=P0({pos:n,x1:t,y1:e,x2:i,y2:r,c:o}),[u,c]=P0({pos:s,x1:i,y1:r,x2:t,y2:e,c:o}),[h,f,d,p]=Tx({sourceX:t,sourceY:e,targetX:i,targetY:r,sourceControlX:l,sourceControlY:a,targetControlX:u,targetControlY:c});return[`M${t},${e} C${l},${a} ${u},${c} ${i},${r}`,h,f,d,p]}const Lu=O.memo(({sourceX:t,sourceY:e,targetX:n,targetY:i,sourcePosition:r=G.Bottom,targetPosition:s=G.Top,label:o,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:h,style:f,markerEnd:d,markerStart:p,pathOptions:g,interactionWidth:S})=>{const[m,y,v]=om({sourceX:t,sourceY:e,sourcePosition:r,targetX:n,targetY:i,targetPosition:s,curvature:g==null?void 0:g.curvature});return j.createElement(Ys,{path:m,labelX:y,labelY:v,label:o,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:h,style:f,markerEnd:d,markerStart:p,interactionWidth:S})});Lu.displayName="BezierEdge";const lm=O.createContext(null),MM=lm.Provider;lm.Consumer;const OM=()=>O.useContext(lm),PM=t=>"id"in t&&"source"in t&&"target"in t,RM=({source:t,sourceHandle:e,target:n,targetHandle:i})=>`reactflow__edge-${t}${e||""}-${n}${i||""}`,rd=(t,e)=>typeof t>"u"?"":typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("&")}`,IM=(t,e)=>e.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),DM=(t,e)=>{if(!t.source||!t.target)return e;let n;return PM(t)?n={...t}:n={...t,id:RM(t)},IM(n,e)?e:e.concat(n)},sd=({x:t,y:e},[n,i,r],s,[o,l])=>{const a={x:(t-n)/r,y:(e-i)/r};return s?{x:o*Math.round(a.x/o),y:l*Math.round(a.y/l)}:a},Ox=({x:t,y:e},[n,i,r])=>({x:t*r+n,y:e*r+i}),ys=(t,e=[0,0])=>{if(!t)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(t.width??0)*e[0],i=(t.height??0)*e[1],r={x:t.position.x-n,y:t.position.y-i};return{...r,positionAbsolute:t.positionAbsolute?{x:t.positionAbsolute.x-n,y:t.positionAbsolute.y-i}:r}},am=(t,e=[0,0])=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((i,r)=>{const{x:s,y:o}=ys(r,e).positionAbsolute;return SM(i,nm({x:s,y:o,width:r.width||0,height:r.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return kM(n)},Px=(t,e,[n,i,r]=[0,0,1],s=!1,o=!1,l=[0,0])=>{const a={x:(e.x-n)/r,y:(e.y-i)/r,width:e.width/r,height:e.height/r},u=[];return t.forEach(c=>{const{width:h,height:f,selectable:d=!0,hidden:p=!1}=c;if(o&&!d||p)return!1;const{positionAbsolute:g}=ys(c,l),S={x:g.x,y:g.y,width:h||0,height:f||0},m=td(a,S),y=typeof h>"u"||typeof f>"u"||h===null||f===null,v=s&&m>0,x=(h||0)*(f||0);(y||v||m>=x||c.dragging)&&u.push(c)}),u},Rx=(t,e)=>{const n=t.map(i=>i.id);return e.filter(i=>n.includes(i.source)||n.includes(i.target))},Ix=(t,e,n,i,r,s=.1)=>{const o=e/(t.width*(1+s)),l=n/(t.height*(1+s)),a=Math.min(o,l),u=Ds(a,i,r),c=t.x+t.width/2,h=t.y+t.height/2,f=e/2-c*u,d=n/2-h*u;return{x:f,y:d,zoom:u}},rr=(t,e=0)=>t.transition().duration(e);function R0(t,e,n,i){return(e[n]||[]).reduce((r,s)=>{var o,l;return`${t.id}-${s.id}-${n}`!==i&&r.push({id:s.id||null,type:n,nodeId:t.id,x:(((o=t.positionAbsolute)==null?void 0:o.x)??0)+s.x+s.width/2,y:(((l=t.positionAbsolute)==null?void 0:l.y)??0)+s.y+s.height/2}),r},[])}function BM(t,e,n,i,r,s){const{x:o,y:l}=Bi(t),u=e.elementsFromPoint(o,l).find(p=>p.classList.contains("react-flow__handle"));if(u){const p=u.getAttribute("data-nodeid");if(p){const g=um(void 0,u),S=u.getAttribute("data-handleid"),m=s({nodeId:p,id:S,type:g});if(m){const y=r.find(v=>v.nodeId===p&&v.type===g&&v.id===S);return{handle:{id:S,type:g,nodeId:p,x:(y==null?void 0:y.x)||n.x,y:(y==null?void 0:y.y)||n.y},validHandleResult:m}}}}let c=[],h=1/0;if(r.forEach(p=>{const g=Math.sqrt((p.x-n.x)**2+(p.y-n.y)**2);if(g<=i){const S=s(p);g<=h&&(g<h?c=[{handle:p,validHandleResult:S}]:g===h&&c.push({handle:p,validHandleResult:S}),h=g)}}),!c.length)return{handle:null,validHandleResult:Dx()};if(c.length===1)return c[0];const f=c.some(({validHandleResult:p})=>p.isValid),d=c.some(({handle:p})=>p.type==="target");return c.find(({handle:p,validHandleResult:g})=>d?p.type==="target":f?g.isValid:!0)||c[0]}const LM={source:null,target:null,sourceHandle:null,targetHandle:null},Dx=()=>({handleDomNode:null,isValid:!1,connection:LM,endHandle:null});function Bx(t,e,n,i,r,s,o){const l=r==="target",a=o.querySelector(`.react-flow__handle[data-id="${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`),u={...Dx(),handleDomNode:a};if(a){const c=um(void 0,a),h=a.getAttribute("data-nodeid"),f=a.getAttribute("data-handleid"),d=a.classList.contains("connectable"),p=a.classList.contains("connectableend"),g={source:l?h:n,sourceHandle:l?f:i,target:l?n:h,targetHandle:l?i:f};u.connection=g,d&&p&&(e===Er.Strict?l&&c==="source"||!l&&c==="target":h!==n||f!==i)&&(u.endHandle={nodeId:h,handleId:f,type:c},u.isValid=s(g))}return u}function zM({nodes:t,nodeId:e,handleId:n,handleType:i}){return t.reduce((r,s)=>{if(s[Ae]){const{handleBounds:o}=s[Ae];let l=[],a=[];o&&(l=R0(s,o,"source",`${e}-${n}-${i}`),a=R0(s,o,"target",`${e}-${n}-${i}`)),r.push(...l,...a)}return r},[])}function um(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function Ch(t){t==null||t.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function $M(t,e){let n=null;return e?n="valid":t&&!e&&(n="invalid"),n}function Lx({event:t,handleId:e,nodeId:n,onConnect:i,isTarget:r,getState:s,setState:o,isValidConnection:l,edgeUpdaterType:a,onReconnectEnd:u}){const c=Ex(t.target),{connectionMode:h,domNode:f,autoPanOnConnect:d,connectionRadius:p,onConnectStart:g,panBy:S,getNodes:m,cancelConnection:y}=s();let v=0,x;const{x:b,y:C}=Bi(t),N=c==null?void 0:c.elementFromPoint(b,C),M=um(a,N),_=f==null?void 0:f.getBoundingClientRect();if(!_||!M)return;let P,B=Bi(t,_),L=!1,F=null,w=!1,E=null;const T=zM({nodes:m(),nodeId:n,handleId:e,handleType:M}),z=()=>{if(!d)return;const[D,I]=Cx(B,_);S({x:D,y:I}),v=requestAnimationFrame(z)};o({connectionPosition:B,connectionStatus:null,connectionNodeId:n,connectionHandleId:e,connectionHandleType:M,connectionStartHandle:{nodeId:n,handleId:e,type:M},connectionEndHandle:null}),g==null||g(t,{nodeId:n,handleId:e,handleType:M});function R(D){const{transform:I}=s();B=Bi(D,_);const{handle:$,validHandleResult:U}=BM(D,c,sd(B,I,!1,[1,1]),p,T,W=>Bx(W,h,n,e,r?"target":"source",l,c));if(x=$,L||(z(),L=!0),E=U.handleDomNode,F=U.connection,w=U.isValid,o({connectionPosition:x&&w?Ox({x:x.x,y:x.y},I):B,connectionStatus:$M(!!x,w),connectionEndHandle:U.endHandle}),!x&&!w&&!E)return Ch(P);F.source!==F.target&&E&&(Ch(P),P=E,E.classList.add("connecting","react-flow__handle-connecting"),E.classList.toggle("valid",w),E.classList.toggle("react-flow__handle-valid",w))}function A(D){var I,$;(x||E)&&F&&w&&(i==null||i(F)),($=(I=s()).onConnectEnd)==null||$.call(I,D),a&&(u==null||u(D)),Ch(P),y(),cancelAnimationFrame(v),L=!1,w=!1,F=null,E=null,c.removeEventListener("mousemove",R),c.removeEventListener("mouseup",A),c.removeEventListener("touchmove",R),c.removeEventListener("touchend",A)}c.addEventListener("mousemove",R),c.addEventListener("mouseup",A),c.addEventListener("touchmove",R),c.addEventListener("touchend",A)}const I0=()=>!0,jM=t=>({connectionStartHandle:t.connectionStartHandle,connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName}),FM=(t,e,n)=>i=>{const{connectionStartHandle:r,connectionEndHandle:s,connectionClickStartHandle:o}=i;return{connecting:(r==null?void 0:r.nodeId)===t&&(r==null?void 0:r.handleId)===e&&(r==null?void 0:r.type)===n||(s==null?void 0:s.nodeId)===t&&(s==null?void 0:s.handleId)===e&&(s==null?void 0:s.type)===n,clickConnecting:(o==null?void 0:o.nodeId)===t&&(o==null?void 0:o.handleId)===e&&(o==null?void 0:o.type)===n}},zx=O.forwardRef(({type:t="source",position:e=G.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:r=!0,isConnectableEnd:s=!0,id:o,onConnect:l,children:a,className:u,onMouseDown:c,onTouchStart:h,...f},d)=>{var _,P;const p=o||null,g=t==="target",S=We(),m=OM(),{connectOnClick:y,noPanClassName:v}=Se(jM,rt),{connecting:x,clickConnecting:b}=Se(FM(m,p,t),rt);m||(P=(_=S.getState()).onError)==null||P.call(_,"010",oi.error010());const C=B=>{const{defaultEdgeOptions:L,onConnect:F,hasDefaultEdges:w}=S.getState(),E={...L,...B};if(w){const{edges:T,setEdges:z}=S.getState();z(DM(E,T))}F==null||F(E),l==null||l(E)},N=B=>{if(!m)return;const L=_x(B);r&&(L&&B.button===0||!L)&&Lx({event:B,handleId:p,nodeId:m,onConnect:C,isTarget:g,getState:S.getState,setState:S.setState,isValidConnection:n||S.getState().isValidConnection||I0}),L?c==null||c(B):h==null||h(B)},M=B=>{const{onClickConnectStart:L,onClickConnectEnd:F,connectionClickStartHandle:w,connectionMode:E,isValidConnection:T}=S.getState();if(!m||!w&&!r)return;if(!w){L==null||L(B,{nodeId:m,handleId:p,handleType:t}),S.setState({connectionClickStartHandle:{nodeId:m,type:t,handleId:p}});return}const z=Ex(B.target),R=n||T||I0,{connection:A,isValid:D}=Bx({nodeId:m,id:p,type:t},E,w.nodeId,w.handleId||null,w.type,R,z);D&&C(A),F==null||F(B),S.setState({connectionClickStartHandle:null})};return j.createElement("div",{"data-handleid":p,"data-nodeid":m,"data-handlepos":e,"data-id":`${m}-${p}-${t}`,className:dt(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",v,u,{source:!g,target:g,connectable:i,connectablestart:r,connectableend:s,connecting:b,connectionindicator:i&&(r&&!x||s&&x)}]),onMouseDown:N,onTouchStart:N,onClick:y?M:void 0,ref:d,...f},a)});zx.displayName="Handle";var Bs=O.memo(zx);const $x=({data:t,isConnectable:e,targetPosition:n=G.Top,sourcePosition:i=G.Bottom})=>j.createElement(j.Fragment,null,j.createElement(Bs,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,j.createElement(Bs,{type:"source",position:i,isConnectable:e}));$x.displayName="DefaultNode";var od=O.memo($x);const jx=({data:t,isConnectable:e,sourcePosition:n=G.Bottom})=>j.createElement(j.Fragment,null,t==null?void 0:t.label,j.createElement(Bs,{type:"source",position:n,isConnectable:e}));jx.displayName="InputNode";var Fx=O.memo(jx);const Vx=({data:t,isConnectable:e,targetPosition:n=G.Top})=>j.createElement(j.Fragment,null,j.createElement(Bs,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label);Vx.displayName="OutputNode";var Hx=O.memo(Vx);const cm=()=>null;cm.displayName="GroupNode";const VM=t=>({selectedNodes:t.getNodes().filter(e=>e.selected),selectedEdges:t.edges.filter(e=>e.selected).map(e=>({...e}))}),fa=t=>t.id;function HM(t,e){return rt(t.selectedNodes.map(fa),e.selectedNodes.map(fa))&&rt(t.selectedEdges.map(fa),e.selectedEdges.map(fa))}const Wx=O.memo(({onSelectionChange:t})=>{const e=We(),{selectedNodes:n,selectedEdges:i}=Se(VM,HM);return O.useEffect(()=>{const r={nodes:n,edges:i};t==null||t(r),e.getState().onSelectionChange.forEach(s=>s(r))},[n,i,t]),null});Wx.displayName="SelectionListener";const WM=t=>!!t.onSelectionChange;function UM({onSelectionChange:t}){const e=Se(WM);return t||e?j.createElement(Wx,{onSelectionChange:t}):null}const KM=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset});function $r(t,e){O.useEffect(()=>{typeof t<"u"&&e(t)},[t])}function ie(t,e,n){O.useEffect(()=>{typeof e<"u"&&n({[t]:e})},[e])}const qM=({nodes:t,edges:e,defaultNodes:n,defaultEdges:i,onConnect:r,onConnectStart:s,onConnectEnd:o,onClickConnectStart:l,onClickConnectEnd:a,nodesDraggable:u,nodesConnectable:c,nodesFocusable:h,edgesFocusable:f,edgesUpdatable:d,elevateNodesOnSelect:p,minZoom:g,maxZoom:S,nodeExtent:m,onNodesChange:y,onEdgesChange:v,elementsSelectable:x,connectionMode:b,snapGrid:C,snapToGrid:N,translateExtent:M,connectOnClick:_,defaultEdgeOptions:P,fitView:B,fitViewOptions:L,onNodesDelete:F,onEdgesDelete:w,onNodeDrag:E,onNodeDragStart:T,onNodeDragStop:z,onSelectionDrag:R,onSelectionDragStart:A,onSelectionDragStop:D,noPanClassName:I,nodeOrigin:$,rfId:U,autoPanOnConnect:W,autoPanOnNodeDrag:Q,onError:te,connectionRadius:ne,isValidConnection:he,nodeDragThreshold:Ee})=>{const{setNodes:ge,setEdges:Zt,setDefaultNodesAndEdges:Bt,setMinZoom:en,setMaxZoom:Lt,setTranslateExtent:Be,setNodeExtent:xn,reset:ye}=Se(KM,rt),Z=We();return O.useEffect(()=>{const Ct=i==null?void 0:i.map(Yi=>({...Yi,...P}));return Bt(n,Ct),()=>{ye()}},[]),ie("defaultEdgeOptions",P,Z.setState),ie("connectionMode",b,Z.setState),ie("onConnect",r,Z.setState),ie("onConnectStart",s,Z.setState),ie("onConnectEnd",o,Z.setState),ie("onClickConnectStart",l,Z.setState),ie("onClickConnectEnd",a,Z.setState),ie("nodesDraggable",u,Z.setState),ie("nodesConnectable",c,Z.setState),ie("nodesFocusable",h,Z.setState),ie("edgesFocusable",f,Z.setState),ie("edgesUpdatable",d,Z.setState),ie("elementsSelectable",x,Z.setState),ie("elevateNodesOnSelect",p,Z.setState),ie("snapToGrid",N,Z.setState),ie("snapGrid",C,Z.setState),ie("onNodesChange",y,Z.setState),ie("onEdgesChange",v,Z.setState),ie("connectOnClick",_,Z.setState),ie("fitViewOnInit",B,Z.setState),ie("fitViewOnInitOptions",L,Z.setState),ie("onNodesDelete",F,Z.setState),ie("onEdgesDelete",w,Z.setState),ie("onNodeDrag",E,Z.setState),ie("onNodeDragStart",T,Z.setState),ie("onNodeDragStop",z,Z.setState),ie("onSelectionDrag",R,Z.setState),ie("onSelectionDragStart",A,Z.setState),ie("onSelectionDragStop",D,Z.setState),ie("noPanClassName",I,Z.setState),ie("nodeOrigin",$,Z.setState),ie("rfId",U,Z.setState),ie("autoPanOnConnect",W,Z.setState),ie("autoPanOnNodeDrag",Q,Z.setState),ie("onError",te,Z.setState),ie("connectionRadius",ne,Z.setState),ie("isValidConnection",he,Z.setState),ie("nodeDragThreshold",Ee,Z.setState),$r(t,ge),$r(e,Zt),$r(g,en),$r(S,Lt),$r(M,Be),$r(m,xn),null},D0={display:"none"},YM={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ux="react-flow__node-desc",Kx="react-flow__edge-desc",QM="react-flow__aria-live",XM=t=>t.ariaLiveMessage;function GM({rfId:t}){const e=Se(XM);return j.createElement("div",{id:`${QM}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:YM},e)}function JM({rfId:t,disableKeyboardA11y:e}){return j.createElement(j.Fragment,null,j.createElement("div",{id:`${Ux}-${t}`,style:D0},"Press enter or space to select a node.",!e&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),j.createElement("div",{id:`${Kx}-${t}`,style:D0},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!e&&j.createElement(GM,{rfId:t}))}var yl=(t=null,e={actInsideInputWithModifier:!0})=>{const[n,i]=O.useState(!1),r=O.useRef(!1),s=O.useRef(new Set([])),[o,l]=O.useMemo(()=>{if(t!==null){const u=(Array.isArray(t)?t:[t]).filter(h=>typeof h=="string").map(h=>h.split("+")),c=u.reduce((h,f)=>h.concat(...f),[]);return[u,c]}return[[],[]]},[t]);return O.useEffect(()=>{const a=typeof document<"u"?document:null,u=(e==null?void 0:e.target)||a;if(t!==null){const c=d=>{if(r.current=d.ctrlKey||d.metaKey||d.shiftKey,(!r.current||r.current&&!e.actInsideInputWithModifier)&&nd(d))return!1;const g=L0(d.code,l);s.current.add(d[g]),B0(o,s.current,!1)&&(d.preventDefault(),i(!0))},h=d=>{if((!r.current||r.current&&!e.actInsideInputWithModifier)&&nd(d))return!1;const g=L0(d.code,l);B0(o,s.current,!0)?(i(!1),s.current.clear()):s.current.delete(d[g]),d.key==="Meta"&&s.current.clear(),r.current=!1},f=()=>{s.current.clear(),i(!1)};return u==null||u.addEventListener("keydown",c),u==null||u.addEventListener("keyup",h),window.addEventListener("blur",f),()=>{u==null||u.removeEventListener("keydown",c),u==null||u.removeEventListener("keyup",h),window.removeEventListener("blur",f)}}},[t,i]),n};function B0(t,e,n){return t.filter(i=>n||i.length===e.size).some(i=>i.every(r=>e.has(r)))}function L0(t,e){return e.includes(t)?"code":"key"}function qx(t,e,n,i){var l,a;const r=t.parentNode||t.parentId;if(!r)return n;const s=e.get(r),o=ys(s,i);return qx(s,e,{x:(n.x??0)+o.x,y:(n.y??0)+o.y,z:(((l=s[Ae])==null?void 0:l.z)??0)>(n.z??0)?((a=s[Ae])==null?void 0:a.z)??0:n.z??0},i)}function Yx(t,e,n){t.forEach(i=>{var s;const r=i.parentNode||i.parentId;if(r&&!t.has(r))throw new Error(`Parent node ${r} not found`);if(r||n!=null&&n[i.id]){const{x:o,y:l,z:a}=qx(i,t,{...i.position,z:((s=i[Ae])==null?void 0:s.z)??0},e);i.positionAbsolute={x:o,y:l},i[Ae].z=a,n!=null&&n[i.id]&&(i[Ae].isParent=!0)}})}function Eh(t,e,n,i){const r=new Map,s={},o=i?1e3:0;return t.forEach(l=>{var d;const a=(Vt(l.zIndex)?l.zIndex:0)+(l.selected?o:0),u=e.get(l.id),c={...l,positionAbsolute:{x:l.position.x,y:l.position.y}},h=l.parentNode||l.parentId;h&&(s[h]=!0);const f=(u==null?void 0:u.type)&&(u==null?void 0:u.type)!==l.type;Object.defineProperty(c,Ae,{enumerable:!1,value:{handleBounds:f||(d=u==null?void 0:u[Ae])==null?void 0:d.handleBounds,z:a}}),r.set(l.id,c)}),Yx(r,n,s),r}function Qx(t,e={}){const{getNodes:n,width:i,height:r,minZoom:s,maxZoom:o,d3Zoom:l,d3Selection:a,fitViewOnInitDone:u,fitViewOnInit:c,nodeOrigin:h}=t(),f=e.initial&&!u&&c;if(l&&a&&(f||!e.initial)){const p=n().filter(S=>{var y;const m=e.includeHiddenNodes?S.width&&S.height:!S.hidden;return(y=e.nodes)!=null&&y.length?m&&e.nodes.some(v=>v.id===S.id):m}),g=p.every(S=>S.width&&S.height);if(p.length>0&&g){const S=am(p,h),{x:m,y,zoom:v}=Ix(S,i,r,e.minZoom??s,e.maxZoom??o,e.padding??.1),x=Di.translate(m,y).scale(v);return typeof e.duration=="number"&&e.duration>0?l.transform(rr(a,e.duration),x):l.transform(a,x),!0}}return!1}function ZM(t,e){return t.forEach(n=>{const i=e.get(n.id);i&&e.set(i.id,{...i,[Ae]:i[Ae],selected:n.selected})}),new Map(e)}function eO(t,e){return e.map(n=>{const i=t.find(r=>r.id===n.id);return i&&(n.selected=i.selected),n})}function da({changedNodes:t,changedEdges:e,get:n,set:i}){const{nodeInternals:r,edges:s,onNodesChange:o,onEdgesChange:l,hasDefaultNodes:a,hasDefaultEdges:u}=n();t!=null&&t.length&&(a&&i({nodeInternals:ZM(t,r)}),o==null||o(t)),e!=null&&e.length&&(u&&i({edges:eO(e,s)}),l==null||l(e))}const jr=()=>{},tO={zoomIn:jr,zoomOut:jr,zoomTo:jr,getZoom:()=>1,setViewport:jr,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:jr,fitBounds:jr,project:t=>t,screenToFlowPosition:t=>t,flowToScreenPosition:t=>t,viewportInitialized:!1},nO=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection}),iO=()=>{const t=We(),{d3Zoom:e,d3Selection:n}=Se(nO,rt);return O.useMemo(()=>n&&e?{zoomIn:r=>e.scaleBy(rr(n,r==null?void 0:r.duration),1.2),zoomOut:r=>e.scaleBy(rr(n,r==null?void 0:r.duration),1/1.2),zoomTo:(r,s)=>e.scaleTo(rr(n,s==null?void 0:s.duration),r),getZoom:()=>t.getState().transform[2],setViewport:(r,s)=>{const[o,l,a]=t.getState().transform,u=Di.translate(r.x??o,r.y??l).scale(r.zoom??a);e.transform(rr(n,s==null?void 0:s.duration),u)},getViewport:()=>{const[r,s,o]=t.getState().transform;return{x:r,y:s,zoom:o}},fitView:r=>Qx(t.getState,r),setCenter:(r,s,o)=>{const{width:l,height:a,maxZoom:u}=t.getState(),c=typeof(o==null?void 0:o.zoom)<"u"?o.zoom:u,h=l/2-r*c,f=a/2-s*c,d=Di.translate(h,f).scale(c);e.transform(rr(n,o==null?void 0:o.duration),d)},fitBounds:(r,s)=>{const{width:o,height:l,minZoom:a,maxZoom:u}=t.getState(),{x:c,y:h,zoom:f}=Ix(r,o,l,a,u,(s==null?void 0:s.padding)??.1),d=Di.translate(c,h).scale(f);e.transform(rr(n,s==null?void 0:s.duration),d)},project:r=>{const{transform:s,snapToGrid:o,snapGrid:l}=t.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),sd(r,s,o,l)},screenToFlowPosition:r=>{const{transform:s,snapToGrid:o,snapGrid:l,domNode:a}=t.getState();if(!a)return r;const{x:u,y:c}=a.getBoundingClientRect(),h={x:r.x-u,y:r.y-c};return sd(h,s,o,l)},flowToScreenPosition:r=>{const{transform:s,domNode:o}=t.getState();if(!o)return r;const{x:l,y:a}=o.getBoundingClientRect(),u=Ox(r,s);return{x:u.x+l,y:u.y+a}},viewportInitialized:!0}:tO,[e,n])};function Mc(){const t=iO(),e=We(),n=O.useCallback(()=>e.getState().getNodes().map(g=>({...g})),[]),i=O.useCallback(g=>e.getState().nodeInternals.get(g),[]),r=O.useCallback(()=>{const{edges:g=[]}=e.getState();return g.map(S=>({...S}))},[]),s=O.useCallback(g=>{const{edges:S=[]}=e.getState();return S.find(m=>m.id===g)},[]),o=O.useCallback(g=>{const{getNodes:S,setNodes:m,hasDefaultNodes:y,onNodesChange:v}=e.getState(),x=S(),b=typeof g=="function"?g(x):g;if(y)m(b);else if(v){const C=b.length===0?x.map(N=>({type:"remove",id:N.id})):b.map(N=>({item:N,type:"reset"}));v(C)}},[]),l=O.useCallback(g=>{const{edges:S=[],setEdges:m,hasDefaultEdges:y,onEdgesChange:v}=e.getState(),x=typeof g=="function"?g(S):g;if(y)m(x);else if(v){const b=x.length===0?S.map(C=>({type:"remove",id:C.id})):x.map(C=>({item:C,type:"reset"}));v(b)}},[]),a=O.useCallback(g=>{const S=Array.isArray(g)?g:[g],{getNodes:m,setNodes:y,hasDefaultNodes:v,onNodesChange:x}=e.getState();if(v){const C=[...m(),...S];y(C)}else if(x){const b=S.map(C=>({item:C,type:"add"}));x(b)}},[]),u=O.useCallback(g=>{const S=Array.isArray(g)?g:[g],{edges:m=[],setEdges:y,hasDefaultEdges:v,onEdgesChange:x}=e.getState();if(v)y([...m,...S]);else if(x){const b=S.map(C=>({item:C,type:"add"}));x(b)}},[]),c=O.useCallback(()=>{const{getNodes:g,edges:S=[],transform:m}=e.getState(),[y,v,x]=m;return{nodes:g().map(b=>({...b})),edges:S.map(b=>({...b})),viewport:{x:y,y:v,zoom:x}}},[]),h=O.useCallback(({nodes:g,edges:S})=>{const{nodeInternals:m,getNodes:y,edges:v,hasDefaultNodes:x,hasDefaultEdges:b,onNodesDelete:C,onEdgesDelete:N,onNodesChange:M,onEdgesChange:_}=e.getState(),P=(g||[]).map(E=>E.id),B=(S||[]).map(E=>E.id),L=y().reduce((E,T)=>{const z=T.parentNode||T.parentId,R=!P.includes(T.id)&&z&&E.find(D=>D.id===z);return(typeof T.deletable=="boolean"?T.deletable:!0)&&(P.includes(T.id)||R)&&E.push(T),E},[]),F=v.filter(E=>typeof E.deletable=="boolean"?E.deletable:!0),w=F.filter(E=>B.includes(E.id));if(L||w){const E=Rx(L,F),T=[...w,...E],z=T.reduce((R,A)=>(R.includes(A.id)||R.push(A.id),R),[]);if((b||x)&&(b&&e.setState({edges:v.filter(R=>!z.includes(R.id))}),x&&(L.forEach(R=>{m.delete(R.id)}),e.setState({nodeInternals:new Map(m)}))),z.length>0&&(N==null||N(T),_&&_(z.map(R=>({id:R,type:"remove"})))),L.length>0&&(C==null||C(L),M)){const R=L.map(A=>({id:A.id,type:"remove"}));M(R)}}},[]),f=O.useCallback(g=>{const S=bM(g),m=S?null:e.getState().nodeInternals.get(g.id);return!S&&!m?[null,null,S]:[S?g:A0(m),m,S]},[]),d=O.useCallback((g,S=!0,m)=>{const[y,v,x]=f(g);return y?(m||e.getState().getNodes()).filter(b=>{if(!x&&(b.id===v.id||!b.positionAbsolute))return!1;const C=A0(b),N=td(C,y);return S&&N>0||N>=y.width*y.height}):[]},[]),p=O.useCallback((g,S,m=!0)=>{const[y]=f(g);if(!y)return!1;const v=td(y,S);return m&&v>0||v>=y.width*y.height},[]);return O.useMemo(()=>({...t,getNodes:n,getNode:i,getEdges:r,getEdge:s,setNodes:o,setEdges:l,addNodes:a,addEdges:u,toObject:c,deleteElements:h,getIntersectingNodes:d,isNodeIntersecting:p}),[t,n,i,r,s,o,l,a,u,c,h,d,p])}const rO={actInsideInputWithModifier:!1};var sO=({deleteKeyCode:t,multiSelectionKeyCode:e})=>{const n=We(),{deleteElements:i}=Mc(),r=yl(t,rO),s=yl(e);O.useEffect(()=>{if(r){const{edges:o,getNodes:l}=n.getState(),a=l().filter(c=>c.selected),u=o.filter(c=>c.selected);i({nodes:a,edges:u}),n.setState({nodesSelectionActive:!1})}},[r]),O.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])};function oO(t){const e=We();O.useEffect(()=>{let n;const i=()=>{var s,o;if(!t.current)return;const r=em(t.current);(r.height===0||r.width===0)&&((o=(s=e.getState()).onError)==null||o.call(s,"004",oi.error004())),e.setState({width:r.width||500,height:r.height||500})};return i(),window.addEventListener("resize",i),t.current&&(n=new ResizeObserver(()=>i()),n.observe(t.current)),()=>{window.removeEventListener("resize",i),n&&t.current&&n.unobserve(t.current)}},[])}const hm={position:"absolute",width:"100%",height:"100%",top:0,left:0},lO=(t,e)=>t.x!==e.x||t.y!==e.y||t.zoom!==e.k,pa=t=>({x:t.x,y:t.y,zoom:t.k}),Fr=(t,e)=>t.target.closest(`.${e}`),z0=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),$0=t=>{const e=t.ctrlKey&&Bu()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e},aO=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection,d3ZoomHandler:t.d3ZoomHandler,userSelectionActive:t.userSelectionActive}),uO=({onMove:t,onMoveStart:e,onMoveEnd:n,onPaneContextMenu:i,zoomOnScroll:r=!0,zoomOnPinch:s=!0,panOnScroll:o=!1,panOnScrollSpeed:l=.5,panOnScrollMode:a=fr.Free,zoomOnDoubleClick:u=!0,elementsSelectable:c,panOnDrag:h=!0,defaultViewport:f,translateExtent:d,minZoom:p,maxZoom:g,zoomActivationKeyCode:S,preventScrolling:m=!0,children:y,noWheelClassName:v,noPanClassName:x})=>{const b=O.useRef(),C=We(),N=O.useRef(!1),M=O.useRef(!1),_=O.useRef(null),P=O.useRef({x:0,y:0,zoom:0}),{d3Zoom:B,d3Selection:L,d3ZoomHandler:F,userSelectionActive:w}=Se(aO,rt),E=yl(S),T=O.useRef(0),z=O.useRef(!1),R=O.useRef();return oO(_),O.useEffect(()=>{if(_.current){const A=_.current.getBoundingClientRect(),D=mM().scaleExtent([p,g]).translateExtent(d),I=ln(_.current).call(D),$=Di.translate(f.x,f.y).scale(Ds(f.zoom,p,g)),U=[[0,0],[A.width,A.height]],W=D.constrain()($,U,d);D.transform(I,W),D.wheelDelta($0),C.setState({d3Zoom:D,d3Selection:I,d3ZoomHandler:I.on("wheel.zoom"),transform:[W.x,W.y,W.k],domNode:_.current.closest(".react-flow")})}},[]),O.useEffect(()=>{L&&B&&(o&&!E&&!w?L.on("wheel.zoom",A=>{if(Fr(A,v))return!1;A.preventDefault(),A.stopImmediatePropagation();const D=L.property("__zoom").k||1;if(A.ctrlKey&&s){const he=Tn(A),Ee=$0(A),ge=D*Math.pow(2,Ee);B.scaleTo(L,ge,he,A);return}const I=A.deltaMode===1?20:1;let $=a===fr.Vertical?0:A.deltaX*I,U=a===fr.Horizontal?0:A.deltaY*I;!Bu()&&A.shiftKey&&a!==fr.Vertical&&($=A.deltaY*I,U=0),B.translateBy(L,-($/D)*l,-(U/D)*l,{internal:!0});const W=pa(L.property("__zoom")),{onViewportChangeStart:Q,onViewportChange:te,onViewportChangeEnd:ne}=C.getState();clearTimeout(R.current),z.current||(z.current=!0,e==null||e(A,W),Q==null||Q(W)),z.current&&(t==null||t(A,W),te==null||te(W),R.current=setTimeout(()=>{n==null||n(A,W),ne==null||ne(W),z.current=!1},150))},{passive:!1}):typeof F<"u"&&L.on("wheel.zoom",function(A,D){if(!m&&A.type==="wheel"&&!A.ctrlKey||Fr(A,v))return null;A.preventDefault(),F.call(this,A,D)},{passive:!1}))},[w,o,a,L,B,F,E,s,m,v,e,t,n]),O.useEffect(()=>{B&&B.on("start",A=>{var $,U;if(!A.sourceEvent||A.sourceEvent.internal)return null;T.current=($=A.sourceEvent)==null?void 0:$.button;const{onViewportChangeStart:D}=C.getState(),I=pa(A.transform);N.current=!0,P.current=I,((U=A.sourceEvent)==null?void 0:U.type)==="mousedown"&&C.setState({paneDragging:!0}),D==null||D(I),e==null||e(A.sourceEvent,I)})},[B,e]),O.useEffect(()=>{B&&(w&&!N.current?B.on("zoom",null):w||B.on("zoom",A=>{var I;const{onViewportChange:D}=C.getState();if(C.setState({transform:[A.transform.x,A.transform.y,A.transform.k]}),M.current=!!(i&&z0(h,T.current??0)),(t||D)&&!((I=A.sourceEvent)!=null&&I.internal)){const $=pa(A.transform);D==null||D($),t==null||t(A.sourceEvent,$)}}))},[w,B,t,h,i]),O.useEffect(()=>{B&&B.on("end",A=>{if(!A.sourceEvent||A.sourceEvent.internal)return null;const{onViewportChangeEnd:D}=C.getState();if(N.current=!1,C.setState({paneDragging:!1}),i&&z0(h,T.current??0)&&!M.current&&i(A.sourceEvent),M.current=!1,(n||D)&&lO(P.current,A.transform)){const I=pa(A.transform);P.current=I,clearTimeout(b.current),b.current=setTimeout(()=>{D==null||D(I),n==null||n(A.sourceEvent,I)},o?150:0)}})},[B,o,h,n,i]),O.useEffect(()=>{B&&B.filter(A=>{const D=E||r,I=s&&A.ctrlKey;if((h===!0||Array.isArray(h)&&h.includes(1))&&A.button===1&&A.type==="mousedown"&&(Fr(A,"react-flow__node")||Fr(A,"react-flow__edge")))return!0;if(!h&&!D&&!o&&!u&&!s||w||!u&&A.type==="dblclick"||Fr(A,v)&&A.type==="wheel"||Fr(A,x)&&(A.type!=="wheel"||o&&A.type==="wheel"&&!E)||!s&&A.ctrlKey&&A.type==="wheel"||!D&&!o&&!I&&A.type==="wheel"||!h&&(A.type==="mousedown"||A.type==="touchstart")||Array.isArray(h)&&!h.includes(A.button)&&A.type==="mousedown")return!1;const $=Array.isArray(h)&&h.includes(A.button)||!A.button||A.button<=1;return(!A.ctrlKey||A.type==="wheel")&&$})},[w,B,r,s,o,u,h,c,E]),j.createElement("div",{className:"react-flow__renderer",ref:_,style:hm},y)},cO=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function hO(){const{userSelectionActive:t,userSelectionRect:e}=Se(cO,rt);return t&&e?j.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}function j0(t,e){const n=e.parentNode||e.parentId,i=t.find(r=>r.id===n);if(i){const r=e.position.x+e.width-i.width,s=e.position.y+e.height-i.height;if(r>0||s>0||e.position.x<0||e.position.y<0){if(i.style={...i.style},i.style.width=i.style.width??i.width,i.style.height=i.style.height??i.height,r>0&&(i.style.width+=r),s>0&&(i.style.height+=s),e.position.x<0){const o=Math.abs(e.position.x);i.position.x=i.position.x-o,i.style.width+=o,e.position.x=0}if(e.position.y<0){const o=Math.abs(e.position.y);i.position.y=i.position.y-o,i.style.height+=o,e.position.y=0}i.width=i.style.width,i.height=i.style.height}}}function fO(t,e){if(t.some(i=>i.type==="reset"))return t.filter(i=>i.type==="reset").map(i=>i.item);const n=t.filter(i=>i.type==="add").map(i=>i.item);return e.reduce((i,r)=>{const s=t.filter(l=>l.id===r.id);if(s.length===0)return i.push(r),i;const o={...r};for(const l of s)if(l)switch(l.type){case"select":{o.selected=l.selected;break}case"position":{typeof l.position<"u"&&(o.position=l.position),typeof l.positionAbsolute<"u"&&(o.positionAbsolute=l.positionAbsolute),typeof l.dragging<"u"&&(o.dragging=l.dragging),o.expandParent&&j0(i,o);break}case"dimensions":{typeof l.dimensions<"u"&&(o.width=l.dimensions.width,o.height=l.dimensions.height),typeof l.updateStyle<"u"&&(o.style={...o.style||{},...l.dimensions}),typeof l.resizing=="boolean"&&(o.resizing=l.resizing),o.expandParent&&j0(i,o);break}case"remove":return i}return i.push(o),i},n)}function dO(t,e){return fO(t,e)}const mi=(t,e)=>({id:t,type:"select",selected:e});function is(t,e){return t.reduce((n,i)=>{const r=e.includes(i.id);return!i.selected&&r?(i.selected=!0,n.push(mi(i.id,!0))):i.selected&&!r&&(i.selected=!1,n.push(mi(i.id,!1))),n},[])}const Nh=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},pO=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging}),Xx=O.memo(({isSelecting:t,selectionMode:e=ml.Full,panOnDrag:n,onSelectionStart:i,onSelectionEnd:r,onPaneClick:s,onPaneContextMenu:o,onPaneScroll:l,onPaneMouseEnter:a,onPaneMouseMove:u,onPaneMouseLeave:c,children:h})=>{const f=O.useRef(null),d=We(),p=O.useRef(0),g=O.useRef(0),S=O.useRef(),{userSelectionActive:m,elementsSelectable:y,dragging:v}=Se(pO,rt),x=()=>{d.setState({userSelectionActive:!1,userSelectionRect:null}),p.current=0,g.current=0},b=F=>{s==null||s(F),d.getState().resetSelectedElements(),d.setState({nodesSelectionActive:!1})},C=F=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){F.preventDefault();return}o==null||o(F)},N=l?F=>l(F):void 0,M=F=>{const{resetSelectedElements:w,domNode:E}=d.getState();if(S.current=E==null?void 0:E.getBoundingClientRect(),!y||!t||F.button!==0||F.target!==f.current||!S.current)return;const{x:T,y:z}=Bi(F,S.current);w(),d.setState({userSelectionRect:{width:0,height:0,startX:T,startY:z,x:T,y:z}}),i==null||i(F)},_=F=>{const{userSelectionRect:w,nodeInternals:E,edges:T,transform:z,onNodesChange:R,onEdgesChange:A,nodeOrigin:D,getNodes:I}=d.getState();if(!t||!S.current||!w)return;d.setState({userSelectionActive:!0,nodesSelectionActive:!1});const $=Bi(F,S.current),U=w.startX??0,W=w.startY??0,Q={...w,x:$.x<U?$.x:U,y:$.y<W?$.y:W,width:Math.abs($.x-U),height:Math.abs($.y-W)},te=I(),ne=Px(E,Q,z,e===ml.Partial,!0,D),he=Rx(ne,T).map(ge=>ge.id),Ee=ne.map(ge=>ge.id);if(p.current!==Ee.length){p.current=Ee.length;const ge=is(te,Ee);ge.length&&(R==null||R(ge))}if(g.current!==he.length){g.current=he.length;const ge=is(T,he);ge.length&&(A==null||A(ge))}d.setState({userSelectionRect:Q})},P=F=>{if(F.button!==0)return;const{userSelectionRect:w}=d.getState();!m&&w&&F.target===f.current&&(b==null||b(F)),d.setState({nodesSelectionActive:p.current>0}),x(),r==null||r(F)},B=F=>{m&&(d.setState({nodesSelectionActive:p.current>0}),r==null||r(F)),x()},L=y&&(t||m);return j.createElement("div",{className:dt(["react-flow__pane",{dragging:v,selection:t}]),onClick:L?void 0:Nh(b,f),onContextMenu:Nh(C,f),onWheel:Nh(N,f),onMouseEnter:L?void 0:a,onMouseDown:L?M:void 0,onMouseMove:L?_:u,onMouseUp:L?P:void 0,onMouseLeave:L?B:c,ref:f,style:hm},h,j.createElement(hO,null))});Xx.displayName="Pane";function Gx(t,e){const n=t.parentNode||t.parentId;if(!n)return!1;const i=e.get(n);return i?i.selected?!0:Gx(i,e):!1}function F0(t,e,n){let i=t;do{if(i!=null&&i.matches(e))return!0;if(i===n.current)return!1;i=i.parentElement}while(i);return!1}function mO(t,e,n,i){return Array.from(t.values()).filter(r=>(r.selected||r.id===i)&&(!r.parentNode||r.parentId||!Gx(r,t))&&(r.draggable||e&&typeof r.draggable>"u")).map(r=>{var s,o;return{id:r.id,position:r.position||{x:0,y:0},positionAbsolute:r.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((s=r.positionAbsolute)==null?void 0:s.x)??0),y:n.y-(((o=r.positionAbsolute)==null?void 0:o.y)??0)},delta:{x:0,y:0},extent:r.extent,parentNode:r.parentNode||r.parentId,parentId:r.parentNode||r.parentId,width:r.width,height:r.height,expandParent:r.expandParent}})}function gO(t,e){return!e||e==="parent"?e:[e[0],[e[1][0]-(t.width||0),e[1][1]-(t.height||0)]]}function Jx(t,e,n,i,r=[0,0],s){const o=gO(t,t.extent||i);let l=o;const a=t.parentNode||t.parentId;if(t.extent==="parent"&&!t.expandParent)if(a&&t.width&&t.height){const h=n.get(a),{x:f,y:d}=ys(h,r).positionAbsolute;l=h&&Vt(f)&&Vt(d)&&Vt(h.width)&&Vt(h.height)?[[f+t.width*r[0],d+t.height*r[1]],[f+h.width-t.width+t.width*r[0],d+h.height-t.height+t.height*r[1]]]:l}else s==null||s("005",oi.error005()),l=o;else if(t.extent&&a&&t.extent!=="parent"){const h=n.get(a),{x:f,y:d}=ys(h,r).positionAbsolute;l=[[t.extent[0][0]+f,t.extent[0][1]+d],[t.extent[1][0]+f,t.extent[1][1]+d]]}let u={x:0,y:0};if(a){const h=n.get(a);u=ys(h,r).positionAbsolute}const c=l&&l!=="parent"?tm(e,l):e;return{position:{x:c.x-u.x,y:c.y-u.y},positionAbsolute:c}}function _h({nodeId:t,dragItems:e,nodeInternals:n}){const i=e.map(r=>({...n.get(r.id),position:r.position,positionAbsolute:r.positionAbsolute}));return[t?i.find(r=>r.id===t):i[0],i]}const V0=(t,e,n,i)=>{const r=e.querySelectorAll(t);if(!r||!r.length)return null;const s=Array.from(r),o=e.getBoundingClientRect(),l={x:o.width*i[0],y:o.height*i[1]};return s.map(a=>{const u=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),position:a.getAttribute("data-handlepos"),x:(u.left-o.left-l.x)/n,y:(u.top-o.top-l.y)/n,...em(a)}})};function ho(t,e,n){return n===void 0?n:i=>{const r=e().nodeInternals.get(t);r&&n(i,{...r})}}function ld({id:t,store:e,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:r,unselectNodesAndEdges:s,multiSelectionActive:o,nodeInternals:l,onError:a}=e.getState(),u=l.get(t);if(!u){a==null||a("012",oi.error012(t));return}e.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&o)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var c;return(c=i==null?void 0:i.current)==null?void 0:c.blur()})):r([t])}function yO(){const t=We();return O.useCallback(({sourceEvent:n})=>{const{transform:i,snapGrid:r,snapToGrid:s}=t.getState(),o=n.touches?n.touches[0].clientX:n.clientX,l=n.touches?n.touches[0].clientY:n.clientY,a={x:(o-i[0])/i[2],y:(l-i[1])/i[2]};return{xSnapped:s?r[0]*Math.round(a.x/r[0]):a.x,ySnapped:s?r[1]*Math.round(a.y/r[1]):a.y,...a}},[])}function Ah(t){return(e,n,i)=>t==null?void 0:t(e,i)}function Zx({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:i,nodeId:r,isSelectable:s,selectNodesOnDrag:o}){const l=We(),[a,u]=O.useState(!1),c=O.useRef([]),h=O.useRef({x:null,y:null}),f=O.useRef(0),d=O.useRef(null),p=O.useRef({x:0,y:0}),g=O.useRef(null),S=O.useRef(!1),m=O.useRef(!1),y=O.useRef(!1),v=yO();return O.useEffect(()=>{if(t!=null&&t.current){const x=ln(t.current),b=({x:M,y:_})=>{const{nodeInternals:P,onNodeDrag:B,onSelectionDrag:L,updateNodePositions:F,nodeExtent:w,snapGrid:E,snapToGrid:T,nodeOrigin:z,onError:R}=l.getState();h.current={x:M,y:_};let A=!1,D={x:0,y:0,x2:0,y2:0};if(c.current.length>1&&w){const $=am(c.current,z);D=nm($)}if(c.current=c.current.map($=>{const U={x:M-$.distance.x,y:_-$.distance.y};T&&(U.x=E[0]*Math.round(U.x/E[0]),U.y=E[1]*Math.round(U.y/E[1]));const W=[[w[0][0],w[0][1]],[w[1][0],w[1][1]]];c.current.length>1&&w&&!$.extent&&(W[0][0]=$.positionAbsolute.x-D.x+w[0][0],W[1][0]=$.positionAbsolute.x+($.width??0)-D.x2+w[1][0],W[0][1]=$.positionAbsolute.y-D.y+w[0][1],W[1][1]=$.positionAbsolute.y+($.height??0)-D.y2+w[1][1]);const Q=Jx($,U,P,W,z,R);return A=A||$.position.x!==Q.position.x||$.position.y!==Q.position.y,$.position=Q.position,$.positionAbsolute=Q.positionAbsolute,$}),!A)return;F(c.current,!0,!0),u(!0);const I=r?B:Ah(L);if(I&&g.current){const[$,U]=_h({nodeId:r,dragItems:c.current,nodeInternals:P});I(g.current,$,U)}},C=()=>{if(!d.current)return;const[M,_]=Cx(p.current,d.current);if(M!==0||_!==0){const{transform:P,panBy:B}=l.getState();h.current.x=(h.current.x??0)-M/P[2],h.current.y=(h.current.y??0)-_/P[2],B({x:M,y:_})&&b(h.current)}f.current=requestAnimationFrame(C)},N=M=>{var z;const{nodeInternals:_,multiSelectionActive:P,nodesDraggable:B,unselectNodesAndEdges:L,onNodeDragStart:F,onSelectionDragStart:w}=l.getState();m.current=!0;const E=r?F:Ah(w);(!o||!s)&&!P&&r&&((z=_.get(r))!=null&&z.selected||L()),r&&s&&o&&ld({id:r,store:l,nodeRef:t});const T=v(M);if(h.current=T,c.current=mO(_,B,T,r),E&&c.current){const[R,A]=_h({nodeId:r,dragItems:c.current,nodeInternals:_});E(M.sourceEvent,R,A)}};if(e)x.on(".drag",null);else{const M=EA().on("start",_=>{const{domNode:P,nodeDragThreshold:B}=l.getState();B===0&&N(_),y.current=!1;const L=v(_);h.current=L,d.current=(P==null?void 0:P.getBoundingClientRect())||null,p.current=Bi(_.sourceEvent,d.current)}).on("drag",_=>{var F,w;const P=v(_),{autoPanOnNodeDrag:B,nodeDragThreshold:L}=l.getState();if(_.sourceEvent.type==="touchmove"&&_.sourceEvent.touches.length>1&&(y.current=!0),!y.current){if(!S.current&&m.current&&B&&(S.current=!0,C()),!m.current){const E=P.xSnapped-(((F=h==null?void 0:h.current)==null?void 0:F.x)??0),T=P.ySnapped-(((w=h==null?void 0:h.current)==null?void 0:w.y)??0);Math.sqrt(E*E+T*T)>L&&N(_)}(h.current.x!==P.xSnapped||h.current.y!==P.ySnapped)&&c.current&&m.current&&(g.current=_.sourceEvent,p.current=Bi(_.sourceEvent,d.current),b(P))}}).on("end",_=>{if(!(!m.current||y.current)&&(u(!1),S.current=!1,m.current=!1,cancelAnimationFrame(f.current),c.current)){const{updateNodePositions:P,nodeInternals:B,onNodeDragStop:L,onSelectionDragStop:F}=l.getState(),w=r?L:Ah(F);if(P(c.current,!1,!1),w){const[E,T]=_h({nodeId:r,dragItems:c.current,nodeInternals:B});w(_.sourceEvent,E,T)}}}).filter(_=>{const P=_.target;return!_.button&&(!n||!F0(P,`.${n}`,t))&&(!i||F0(P,i,t))});return x.call(M),()=>{x.on(".drag",null)}}}},[t,e,n,i,s,l,r,o,v]),a}function eS(){const t=We();return O.useCallback(n=>{const{nodeInternals:i,nodeExtent:r,updateNodePositions:s,getNodes:o,snapToGrid:l,snapGrid:a,onError:u,nodesDraggable:c}=t.getState(),h=o().filter(y=>y.selected&&(y.draggable||c&&typeof y.draggable>"u")),f=l?a[0]:5,d=l?a[1]:5,p=n.isShiftPressed?4:1,g=n.x*f*p,S=n.y*d*p,m=h.map(y=>{if(y.positionAbsolute){const v={x:y.positionAbsolute.x+g,y:y.positionAbsolute.y+S};l&&(v.x=a[0]*Math.round(v.x/a[0]),v.y=a[1]*Math.round(v.y/a[1]));const{positionAbsolute:x,position:b}=Jx(y,v,i,r,void 0,u);y.position=b,y.positionAbsolute=x}return y});s(m,!0,!1)},[])}const vs={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var fo=t=>{const e=({id:n,type:i,data:r,xPos:s,yPos:o,xPosOrigin:l,yPosOrigin:a,selected:u,onClick:c,onMouseEnter:h,onMouseMove:f,onMouseLeave:d,onContextMenu:p,onDoubleClick:g,style:S,className:m,isDraggable:y,isSelectable:v,isConnectable:x,isFocusable:b,selectNodesOnDrag:C,sourcePosition:N,targetPosition:M,hidden:_,resizeObserver:P,dragHandle:B,zIndex:L,isParent:F,noDragClassName:w,noPanClassName:E,initialized:T,disableKeyboardA11y:z,ariaLabel:R,rfId:A,hasHandleBounds:D})=>{const I=We(),$=O.useRef(null),U=O.useRef(null),W=O.useRef(N),Q=O.useRef(M),te=O.useRef(i),ne=v||y||c||h||f||d,he=eS(),Ee=ho(n,I.getState,h),ge=ho(n,I.getState,f),Zt=ho(n,I.getState,d),Bt=ho(n,I.getState,p),en=ho(n,I.getState,g),Lt=ye=>{const{nodeDragThreshold:Z}=I.getState();if(v&&(!C||!y||Z>0)&&ld({id:n,store:I,nodeRef:$}),c){const Ct=I.getState().nodeInternals.get(n);Ct&&c(ye,{...Ct})}},Be=ye=>{if(!nd(ye)&&!z)if(Nx.includes(ye.key)&&v){const Z=ye.key==="Escape";ld({id:n,store:I,unselect:Z,nodeRef:$})}else y&&u&&Object.prototype.hasOwnProperty.call(vs,ye.key)&&(I.setState({ariaLiveMessage:`Moved selected node ${ye.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~s}, y: ${~~o}`}),he({x:vs[ye.key].x,y:vs[ye.key].y,isShiftPressed:ye.shiftKey}))};O.useEffect(()=>()=>{U.current&&(P==null||P.unobserve(U.current),U.current=null)},[]),O.useEffect(()=>{if($.current&&!_){const ye=$.current;(!T||!D||U.current!==ye)&&(U.current&&(P==null||P.unobserve(U.current)),P==null||P.observe(ye),U.current=ye)}},[_,T,D]),O.useEffect(()=>{const ye=te.current!==i,Z=W.current!==N,Ct=Q.current!==M;$.current&&(ye||Z||Ct)&&(ye&&(te.current=i),Z&&(W.current=N),Ct&&(Q.current=M),I.getState().updateNodeDimensions([{id:n,nodeElement:$.current,forceUpdate:!0}]))},[n,i,N,M]);const xn=Zx({nodeRef:$,disabled:_||!y,noDragClassName:w,handleSelector:B,nodeId:n,isSelectable:v,selectNodesOnDrag:C});return _?null:j.createElement("div",{className:dt(["react-flow__node",`react-flow__node-${i}`,{[E]:y},m,{selected:u,selectable:v,parent:F,dragging:xn}]),ref:$,style:{zIndex:L,transform:`translate(${l}px,${a}px)`,pointerEvents:ne?"all":"none",visibility:T?"visible":"hidden",...S},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:Ee,onMouseMove:ge,onMouseLeave:Zt,onContextMenu:Bt,onClick:Lt,onDoubleClick:en,onKeyDown:b?Be:void 0,tabIndex:b?0:void 0,role:b?"button":void 0,"aria-describedby":z?void 0:`${Ux}-${A}`,"aria-label":R},j.createElement(MM,{value:n},j.createElement(t,{id:n,data:r,type:i,xPos:s,yPos:o,selected:u,isConnectable:x,sourcePosition:N,targetPosition:M,dragging:xn,dragHandle:B,zIndex:L})))};return e.displayName="NodeWrapper",O.memo(e)};const vO=t=>{const e=t.getNodes().filter(n=>n.selected);return{...am(e,t.nodeOrigin),transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`,userSelectionActive:t.userSelectionActive}};function wO({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const i=We(),{width:r,height:s,x:o,y:l,transformString:a,userSelectionActive:u}=Se(vO,rt),c=eS(),h=O.useRef(null);if(O.useEffect(()=>{var p;n||(p=h.current)==null||p.focus({preventScroll:!0})},[n]),Zx({nodeRef:h}),u||!r||!s)return null;const f=t?p=>{const g=i.getState().getNodes().filter(S=>S.selected);t(p,g)}:void 0,d=p=>{Object.prototype.hasOwnProperty.call(vs,p.key)&&c({x:vs[p.key].x,y:vs[p.key].y,isShiftPressed:p.shiftKey})};return j.createElement("div",{className:dt(["react-flow__nodesselection","react-flow__container",e]),style:{transform:a}},j.createElement("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:r,height:s,top:l,left:o}}))}var xO=O.memo(wO);const SO=t=>t.nodesSelectionActive,tS=({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:o,deleteKeyCode:l,onMove:a,onMoveStart:u,onMoveEnd:c,selectionKeyCode:h,selectionOnDrag:f,selectionMode:d,onSelectionStart:p,onSelectionEnd:g,multiSelectionKeyCode:S,panActivationKeyCode:m,zoomActivationKeyCode:y,elementsSelectable:v,zoomOnScroll:x,zoomOnPinch:b,panOnScroll:C,panOnScrollSpeed:N,panOnScrollMode:M,zoomOnDoubleClick:_,panOnDrag:P,defaultViewport:B,translateExtent:L,minZoom:F,maxZoom:w,preventScrolling:E,onSelectionContextMenu:T,noWheelClassName:z,noPanClassName:R,disableKeyboardA11y:A})=>{const D=Se(SO),I=yl(h),$=yl(m),U=$||P,W=$||C,Q=I||f&&U!==!0;return sO({deleteKeyCode:l,multiSelectionKeyCode:S}),j.createElement(uO,{onMove:a,onMoveStart:u,onMoveEnd:c,onPaneContextMenu:s,elementsSelectable:v,zoomOnScroll:x,zoomOnPinch:b,panOnScroll:W,panOnScrollSpeed:N,panOnScrollMode:M,zoomOnDoubleClick:_,panOnDrag:!I&&U,defaultViewport:B,translateExtent:L,minZoom:F,maxZoom:w,zoomActivationKeyCode:y,preventScrolling:E,noWheelClassName:z,noPanClassName:R},j.createElement(Xx,{onSelectionStart:p,onSelectionEnd:g,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:o,panOnDrag:U,isSelecting:!!Q,selectionMode:d},t,D&&j.createElement(xO,{onSelectionContextMenu:T,noPanClassName:R,disableKeyboardA11y:A})))};tS.displayName="FlowRenderer";var kO=O.memo(tS);function bO(t){return Se(O.useCallback(n=>t?Px(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[t]))}function CO(t){const e={input:fo(t.input||Fx),default:fo(t.default||od),output:fo(t.output||Hx),group:fo(t.group||cm)},n={},i=Object.keys(t).filter(r=>!["input","default","output","group"].includes(r)).reduce((r,s)=>(r[s]=fo(t[s]||od),r),n);return{...e,...i}}const EO=({x:t,y:e,width:n,height:i,origin:r})=>!n||!i?{x:t,y:e}:r[0]<0||r[1]<0||r[0]>1||r[1]>1?{x:t,y:e}:{x:t-n*r[0],y:e-i*r[1]},NO=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,updateNodeDimensions:t.updateNodeDimensions,onError:t.onError}),nS=t=>{const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:i,elementsSelectable:r,updateNodeDimensions:s,onError:o}=Se(NO,rt),l=bO(t.onlyRenderVisibleElements),a=O.useRef(),u=O.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const c=new ResizeObserver(h=>{const f=h.map(d=>({id:d.target.getAttribute("data-id"),nodeElement:d.target,forceUpdate:!0}));s(f)});return a.current=c,c},[]);return O.useEffect(()=>()=>{var c;(c=a==null?void 0:a.current)==null||c.disconnect()},[]),j.createElement("div",{className:"react-flow__nodes",style:hm},l.map(c=>{var b,C,N;let h=c.type||"default";t.nodeTypes[h]||(o==null||o("003",oi.error003(h)),h="default");const f=t.nodeTypes[h]||t.nodeTypes.default,d=!!(c.draggable||e&&typeof c.draggable>"u"),p=!!(c.selectable||r&&typeof c.selectable>"u"),g=!!(c.connectable||n&&typeof c.connectable>"u"),S=!!(c.focusable||i&&typeof c.focusable>"u"),m=t.nodeExtent?tm(c.positionAbsolute,t.nodeExtent):c.positionAbsolute,y=(m==null?void 0:m.x)??0,v=(m==null?void 0:m.y)??0,x=EO({x:y,y:v,width:c.width??0,height:c.height??0,origin:t.nodeOrigin});return j.createElement(f,{key:c.id,id:c.id,className:c.className,style:c.style,type:h,data:c.data,sourcePosition:c.sourcePosition||G.Bottom,targetPosition:c.targetPosition||G.Top,hidden:c.hidden,xPos:y,yPos:v,xPosOrigin:x.x,yPosOrigin:x.y,selectNodesOnDrag:t.selectNodesOnDrag,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,selected:!!c.selected,isDraggable:d,isSelectable:p,isConnectable:g,isFocusable:S,resizeObserver:u,dragHandle:c.dragHandle,zIndex:((b=c[Ae])==null?void 0:b.z)??0,isParent:!!((C=c[Ae])!=null&&C.isParent),noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,initialized:!!c.width&&!!c.height,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,ariaLabel:c.ariaLabel,hasHandleBounds:!!((N=c[Ae])!=null&&N.handleBounds)})}))};nS.displayName="NodeRenderer";var _O=O.memo(nS);const AO=(t,e,n)=>n===G.Left?t-e:n===G.Right?t+e:t,TO=(t,e,n)=>n===G.Top?t-e:n===G.Bottom?t+e:t,H0="react-flow__edgeupdater",W0=({position:t,centerX:e,centerY:n,radius:i=10,onMouseDown:r,onMouseEnter:s,onMouseOut:o,type:l})=>j.createElement("circle",{onMouseDown:r,onMouseEnter:s,onMouseOut:o,className:dt([H0,`${H0}-${l}`]),cx:AO(e,i,t),cy:TO(n,i,t),r:i,stroke:"transparent",fill:"transparent"}),MO=()=>!0;var Vr=t=>{const e=({id:n,className:i,type:r,data:s,onClick:o,onEdgeDoubleClick:l,selected:a,animated:u,label:c,labelStyle:h,labelShowBg:f,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:g,style:S,source:m,target:y,sourceX:v,sourceY:x,targetX:b,targetY:C,sourcePosition:N,targetPosition:M,elementsSelectable:_,hidden:P,sourceHandleId:B,targetHandleId:L,onContextMenu:F,onMouseEnter:w,onMouseMove:E,onMouseLeave:T,reconnectRadius:z,onReconnect:R,onReconnectStart:A,onReconnectEnd:D,markerEnd:I,markerStart:$,rfId:U,ariaLabel:W,isFocusable:Q,isReconnectable:te,pathOptions:ne,interactionWidth:he,disableKeyboardA11y:Ee})=>{const ge=O.useRef(null),[Zt,Bt]=O.useState(!1),[en,Lt]=O.useState(!1),Be=We(),xn=O.useMemo(()=>`url('#${rd($,U)}')`,[$,U]),ye=O.useMemo(()=>`url('#${rd(I,U)}')`,[I,U]);if(P)return null;const Z=Ge=>{var Sn;const{edges:tn,addSelectedEdges:Gi,unselectNodesAndEdges:Ji,multiSelectionActive:Zi}=Be.getState(),Hn=tn.find(Js=>Js.id===n);Hn&&(_&&(Be.setState({nodesSelectionActive:!1}),Hn.selected&&Zi?(Ji({nodes:[],edges:[Hn]}),(Sn=ge.current)==null||Sn.blur()):Gi([n])),o&&o(Ge,Hn))},Ct=co(n,Be.getState,l),Yi=co(n,Be.getState,F),Xs=co(n,Be.getState,w),Pr=co(n,Be.getState,E),Rr=co(n,Be.getState,T),Vn=(Ge,tn)=>{if(Ge.button!==0)return;const{edges:Gi,isValidConnection:Ji}=Be.getState(),Zi=tn?y:m,Hn=(tn?L:B)||null,Sn=tn?"target":"source",Js=Ji||MO,Hc=tn,Zs=Gi.find(er=>er.id===n);Lt(!0),A==null||A(Ge,Zs,Sn);const Wc=er=>{Lt(!1),D==null||D(er,Zs,Sn)};Lx({event:Ge,handleId:Hn,nodeId:Zi,onConnect:er=>R==null?void 0:R(Zs,er),isTarget:Hc,getState:Be.getState,setState:Be.setState,isValidConnection:Js,edgeUpdaterType:Sn,onReconnectEnd:Wc})},Ir=Ge=>Vn(Ge,!0),Qi=Ge=>Vn(Ge,!1),Xi=()=>Bt(!0),Dr=()=>Bt(!1),Br=!_&&!o,Gs=Ge=>{var tn;if(!Ee&&Nx.includes(Ge.key)&&_){const{unselectNodesAndEdges:Gi,addSelectedEdges:Ji,edges:Zi}=Be.getState();Ge.key==="Escape"?((tn=ge.current)==null||tn.blur(),Gi({edges:[Zi.find(Sn=>Sn.id===n)]})):Ji([n])}};return j.createElement("g",{className:dt(["react-flow__edge",`react-flow__edge-${r}`,i,{selected:a,animated:u,inactive:Br,updating:Zt}]),onClick:Z,onDoubleClick:Ct,onContextMenu:Yi,onMouseEnter:Xs,onMouseMove:Pr,onMouseLeave:Rr,onKeyDown:Q?Gs:void 0,tabIndex:Q?0:void 0,role:Q?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":W===null?void 0:W||`Edge from ${m} to ${y}`,"aria-describedby":Q?`${Kx}-${U}`:void 0,ref:ge},!en&&j.createElement(t,{id:n,source:m,target:y,selected:a,animated:u,label:c,labelStyle:h,labelShowBg:f,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:g,data:s,style:S,sourceX:v,sourceY:x,targetX:b,targetY:C,sourcePosition:N,targetPosition:M,sourceHandleId:B,targetHandleId:L,markerStart:xn,markerEnd:ye,pathOptions:ne,interactionWidth:he}),te&&j.createElement(j.Fragment,null,(te==="source"||te===!0)&&j.createElement(W0,{position:N,centerX:v,centerY:x,radius:z,onMouseDown:Ir,onMouseEnter:Xi,onMouseOut:Dr,type:"source"}),(te==="target"||te===!0)&&j.createElement(W0,{position:M,centerX:b,centerY:C,radius:z,onMouseDown:Qi,onMouseEnter:Xi,onMouseOut:Dr,type:"target"})))};return e.displayName="EdgeWrapper",O.memo(e)};function OO(t){const e={default:Vr(t.default||Lu),straight:Vr(t.bezier||sm),step:Vr(t.step||rm),smoothstep:Vr(t.step||Tc),simplebezier:Vr(t.simplebezier||im)},n={},i=Object.keys(t).filter(r=>!["default","bezier"].includes(r)).reduce((r,s)=>(r[s]=Vr(t[s]||Lu),r),n);return{...e,...i}}function U0(t,e,n=null){const i=((n==null?void 0:n.x)||0)+e.x,r=((n==null?void 0:n.y)||0)+e.y,s=(n==null?void 0:n.width)||e.width,o=(n==null?void 0:n.height)||e.height;switch(t){case G.Top:return{x:i+s/2,y:r};case G.Right:return{x:i+s,y:r+o/2};case G.Bottom:return{x:i+s/2,y:r+o};case G.Left:return{x:i,y:r+o/2}}}function K0(t,e){return t?t.length===1||!e?t[0]:e&&t.find(n=>n.id===e)||null:null}const PO=(t,e,n,i,r,s)=>{const o=U0(n,t,e),l=U0(s,i,r);return{sourceX:o.x,sourceY:o.y,targetX:l.x,targetY:l.y}};function RO({sourcePos:t,targetPos:e,sourceWidth:n,sourceHeight:i,targetWidth:r,targetHeight:s,width:o,height:l,transform:a}){const u={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x+n,e.x+r),y2:Math.max(t.y+i,e.y+s)};u.x===u.x2&&(u.x2+=1),u.y===u.y2&&(u.y2+=1);const c=nm({x:(0-a[0])/a[2],y:(0-a[1])/a[2],width:o/a[2],height:l/a[2]}),h=Math.max(0,Math.min(c.x2,u.x2)-Math.max(c.x,u.x)),f=Math.max(0,Math.min(c.y2,u.y2)-Math.max(c.y,u.y));return Math.ceil(h*f)>0}function q0(t){var i,r,s,o,l;const e=((i=t==null?void 0:t[Ae])==null?void 0:i.handleBounds)||null,n=e&&(t==null?void 0:t.width)&&(t==null?void 0:t.height)&&typeof((r=t==null?void 0:t.positionAbsolute)==null?void 0:r.x)<"u"&&typeof((s=t==null?void 0:t.positionAbsolute)==null?void 0:s.y)<"u";return[{x:((o=t==null?void 0:t.positionAbsolute)==null?void 0:o.x)||0,y:((l=t==null?void 0:t.positionAbsolute)==null?void 0:l.y)||0,width:(t==null?void 0:t.width)||0,height:(t==null?void 0:t.height)||0},e,!!n]}const IO=[{level:0,isMaxLevel:!0,edges:[]}];function DO(t,e,n=!1){let i=-1;const r=t.reduce((o,l)=>{var c,h;const a=Vt(l.zIndex);let u=a?l.zIndex:0;if(n){const f=e.get(l.target),d=e.get(l.source),p=l.selected||(f==null?void 0:f.selected)||(d==null?void 0:d.selected),g=Math.max(((c=d==null?void 0:d[Ae])==null?void 0:c.z)||0,((h=f==null?void 0:f[Ae])==null?void 0:h.z)||0,1e3);u=(a?l.zIndex:0)+(p?g:0)}return o[u]?o[u].push(l):o[u]=[l],i=u>i?u:i,o},{}),s=Object.entries(r).map(([o,l])=>{const a=+o;return{edges:l,level:a,isMaxLevel:a===i}});return s.length===0?IO:s}function BO(t,e,n){const i=Se(O.useCallback(r=>t?r.edges.filter(s=>{const o=e.get(s.source),l=e.get(s.target);return(o==null?void 0:o.width)&&(o==null?void 0:o.height)&&(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&RO({sourcePos:o.positionAbsolute||{x:0,y:0},targetPos:l.positionAbsolute||{x:0,y:0},sourceWidth:o.width,sourceHeight:o.height,targetWidth:l.width,targetHeight:l.height,width:r.width,height:r.height,transform:r.transform})}):r.edges,[t,e]));return DO(i,e,n)}const LO=({color:t="none",strokeWidth:e=1})=>j.createElement("polyline",{style:{stroke:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),zO=({color:t="none",strokeWidth:e=1})=>j.createElement("polyline",{style:{stroke:t,fill:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Y0={[gl.Arrow]:LO,[gl.ArrowClosed]:zO};function $O(t){const e=We();return O.useMemo(()=>{var r,s;return Object.prototype.hasOwnProperty.call(Y0,t)?Y0[t]:((s=(r=e.getState()).onError)==null||s.call(r,"009",oi.error009(t)),null)},[t])}const jO=({id:t,type:e,color:n,width:i=12.5,height:r=12.5,markerUnits:s="strokeWidth",strokeWidth:o,orient:l="auto-start-reverse"})=>{const a=$O(e);return a?j.createElement("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${i}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:l,refX:"0",refY:"0"},j.createElement(a,{color:n,strokeWidth:o})):null},FO=({defaultColor:t,rfId:e})=>n=>{const i=[];return n.edges.reduce((r,s)=>([s.markerStart,s.markerEnd].forEach(o=>{if(o&&typeof o=="object"){const l=rd(o,e);i.includes(l)||(r.push({id:l,color:o.color||t,...o}),i.push(l))}}),r),[]).sort((r,s)=>r.id.localeCompare(s.id))},iS=({defaultColor:t,rfId:e})=>{const n=Se(O.useCallback(FO({defaultColor:t,rfId:e}),[t,e]),(i,r)=>!(i.length!==r.length||i.some((s,o)=>s.id!==r[o].id)));return j.createElement("defs",null,n.map(i=>j.createElement(jO,{id:i.id,key:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient})))};iS.displayName="MarkerDefinitions";var VO=O.memo(iS);const HO=t=>({nodesConnectable:t.nodesConnectable,edgesFocusable:t.edgesFocusable,edgesUpdatable:t.edgesUpdatable,elementsSelectable:t.elementsSelectable,width:t.width,height:t.height,connectionMode:t.connectionMode,nodeInternals:t.nodeInternals,onError:t.onError}),rS=({defaultMarkerColor:t,onlyRenderVisibleElements:e,elevateEdgesOnSelect:n,rfId:i,edgeTypes:r,noPanClassName:s,onEdgeContextMenu:o,onEdgeMouseEnter:l,onEdgeMouseMove:a,onEdgeMouseLeave:u,onEdgeClick:c,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:d,onReconnectEnd:p,reconnectRadius:g,children:S,disableKeyboardA11y:m})=>{const{edgesFocusable:y,edgesUpdatable:v,elementsSelectable:x,width:b,height:C,connectionMode:N,nodeInternals:M,onError:_}=Se(HO,rt),P=BO(e,M,n);return b?j.createElement(j.Fragment,null,P.map(({level:B,edges:L,isMaxLevel:F})=>j.createElement("svg",{key:B,style:{zIndex:B},width:b,height:C,className:"react-flow__edges react-flow__container"},F&&j.createElement(VO,{defaultColor:t,rfId:i}),j.createElement("g",null,L.map(w=>{const[E,T,z]=q0(M.get(w.source)),[R,A,D]=q0(M.get(w.target));if(!z||!D)return null;let I=w.type||"default";r[I]||(_==null||_("011",oi.error011(I)),I="default");const $=r[I]||r.default,U=N===Er.Strict?A.target:(A.target??[]).concat(A.source??[]),W=K0(T.source,w.sourceHandle),Q=K0(U,w.targetHandle),te=(W==null?void 0:W.position)||G.Bottom,ne=(Q==null?void 0:Q.position)||G.Top,he=!!(w.focusable||y&&typeof w.focusable>"u"),Ee=w.reconnectable||w.updatable,ge=typeof f<"u"&&(Ee||v&&typeof Ee>"u");if(!W||!Q)return _==null||_("008",oi.error008(W,w)),null;const{sourceX:Zt,sourceY:Bt,targetX:en,targetY:Lt}=PO(E,W,te,R,Q,ne);return j.createElement($,{key:w.id,id:w.id,className:dt([w.className,s]),type:I,data:w.data,selected:!!w.selected,animated:!!w.animated,hidden:!!w.hidden,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,style:w.style,source:w.source,target:w.target,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerEnd:w.markerEnd,markerStart:w.markerStart,sourceX:Zt,sourceY:Bt,targetX:en,targetY:Lt,sourcePosition:te,targetPosition:ne,elementsSelectable:x,onContextMenu:o,onMouseEnter:l,onMouseMove:a,onMouseLeave:u,onClick:c,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:d,onReconnectEnd:p,reconnectRadius:g,rfId:i,ariaLabel:w.ariaLabel,isFocusable:he,isReconnectable:ge,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth,disableKeyboardA11y:m})})))),S):null};rS.displayName="EdgeRenderer";var WO=O.memo(rS);const UO=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function KO({children:t}){const e=Se(UO);return j.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:e}},t)}function qO(t){const e=Mc(),n=O.useRef(!1);O.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)},[t,e.viewportInitialized])}const YO={[G.Left]:G.Right,[G.Right]:G.Left,[G.Top]:G.Bottom,[G.Bottom]:G.Top},sS=({nodeId:t,handleType:e,style:n,type:i=xi.Bezier,CustomComponent:r,connectionStatus:s})=>{var C,N,M;const{fromNode:o,handleId:l,toX:a,toY:u,connectionMode:c}=Se(O.useCallback(_=>({fromNode:_.nodeInternals.get(t),handleId:_.connectionHandleId,toX:(_.connectionPosition.x-_.transform[0])/_.transform[2],toY:(_.connectionPosition.y-_.transform[1])/_.transform[2],connectionMode:_.connectionMode}),[t]),rt),h=(C=o==null?void 0:o[Ae])==null?void 0:C.handleBounds;let f=h==null?void 0:h[e];if(c===Er.Loose&&(f=f||(h==null?void 0:h[e==="source"?"target":"source"])),!o||!f)return null;const d=l?f.find(_=>_.id===l):f[0],p=d?d.x+d.width/2:(o.width??0)/2,g=d?d.y+d.height/2:o.height??0,S=(((N=o.positionAbsolute)==null?void 0:N.x)??0)+p,m=(((M=o.positionAbsolute)==null?void 0:M.y)??0)+g,y=d==null?void 0:d.position,v=y?YO[y]:null;if(!y||!v)return null;if(r)return j.createElement(r,{connectionLineType:i,connectionLineStyle:n,fromNode:o,fromHandle:d,fromX:S,fromY:m,toX:a,toY:u,fromPosition:y,toPosition:v,connectionStatus:s});let x="";const b={sourceX:S,sourceY:m,sourcePosition:y,targetX:a,targetY:u,targetPosition:v};return i===xi.Bezier?[x]=om(b):i===xi.Step?[x]=id({...b,borderRadius:0}):i===xi.SmoothStep?[x]=id(b):i===xi.SimpleBezier?[x]=Mx(b):x=`M${S},${m} ${a},${u}`,j.createElement("path",{d:x,fill:"none",className:"react-flow__connection-path",style:n})};sS.displayName="ConnectionLine";const QO=t=>({nodeId:t.connectionNodeId,handleType:t.connectionHandleType,nodesConnectable:t.nodesConnectable,connectionStatus:t.connectionStatus,width:t.width,height:t.height});function XO({containerStyle:t,style:e,type:n,component:i}){const{nodeId:r,handleType:s,nodesConnectable:o,width:l,height:a,connectionStatus:u}=Se(QO,rt);return!(r&&s&&l&&o)?null:j.createElement("svg",{style:t,width:l,height:a,className:"react-flow__edges react-flow__connectionline react-flow__container"},j.createElement("g",{className:dt(["react-flow__connection",u])},j.createElement(sS,{nodeId:r,handleType:s,style:e,type:n,CustomComponent:i,connectionStatus:u})))}function Q0(t,e){return O.useRef(null),We(),O.useMemo(()=>e(t),[t])}const oS=({nodeTypes:t,edgeTypes:e,onMove:n,onMoveStart:i,onMoveEnd:r,onInit:s,onNodeClick:o,onEdgeClick:l,onNodeDoubleClick:a,onEdgeDoubleClick:u,onNodeMouseEnter:c,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:d,onSelectionContextMenu:p,onSelectionStart:g,onSelectionEnd:S,connectionLineType:m,connectionLineStyle:y,connectionLineComponent:v,connectionLineContainerStyle:x,selectionKeyCode:b,selectionOnDrag:C,selectionMode:N,multiSelectionKeyCode:M,panActivationKeyCode:_,zoomActivationKeyCode:P,deleteKeyCode:B,onlyRenderVisibleElements:L,elementsSelectable:F,selectNodesOnDrag:w,defaultViewport:E,translateExtent:T,minZoom:z,maxZoom:R,preventScrolling:A,defaultMarkerColor:D,zoomOnScroll:I,zoomOnPinch:$,panOnScroll:U,panOnScrollSpeed:W,panOnScrollMode:Q,zoomOnDoubleClick:te,panOnDrag:ne,onPaneClick:he,onPaneMouseEnter:Ee,onPaneMouseMove:ge,onPaneMouseLeave:Zt,onPaneScroll:Bt,onPaneContextMenu:en,onEdgeContextMenu:Lt,onEdgeMouseEnter:Be,onEdgeMouseMove:xn,onEdgeMouseLeave:ye,onReconnect:Z,onReconnectStart:Ct,onReconnectEnd:Yi,reconnectRadius:Xs,noDragClassName:Pr,noWheelClassName:Rr,noPanClassName:Vn,elevateEdgesOnSelect:Ir,disableKeyboardA11y:Qi,nodeOrigin:Xi,nodeExtent:Dr,rfId:Br})=>{const Gs=Q0(t,CO),Ge=Q0(e,OO);return qO(s),j.createElement(kO,{onPaneClick:he,onPaneMouseEnter:Ee,onPaneMouseMove:ge,onPaneMouseLeave:Zt,onPaneContextMenu:en,onPaneScroll:Bt,deleteKeyCode:B,selectionKeyCode:b,selectionOnDrag:C,selectionMode:N,onSelectionStart:g,onSelectionEnd:S,multiSelectionKeyCode:M,panActivationKeyCode:_,zoomActivationKeyCode:P,elementsSelectable:F,onMove:n,onMoveStart:i,onMoveEnd:r,zoomOnScroll:I,zoomOnPinch:$,zoomOnDoubleClick:te,panOnScroll:U,panOnScrollSpeed:W,panOnScrollMode:Q,panOnDrag:ne,defaultViewport:E,translateExtent:T,minZoom:z,maxZoom:R,onSelectionContextMenu:p,preventScrolling:A,noDragClassName:Pr,noWheelClassName:Rr,noPanClassName:Vn,disableKeyboardA11y:Qi},j.createElement(KO,null,j.createElement(WO,{edgeTypes:Ge,onEdgeClick:l,onEdgeDoubleClick:u,onlyRenderVisibleElements:L,onEdgeContextMenu:Lt,onEdgeMouseEnter:Be,onEdgeMouseMove:xn,onEdgeMouseLeave:ye,onReconnect:Z,onReconnectStart:Ct,onReconnectEnd:Yi,reconnectRadius:Xs,defaultMarkerColor:D,noPanClassName:Vn,elevateEdgesOnSelect:!!Ir,disableKeyboardA11y:Qi,rfId:Br},j.createElement(XO,{style:y,type:m,component:v,containerStyle:x})),j.createElement("div",{className:"react-flow__edgelabel-renderer"}),j.createElement(_O,{nodeTypes:Gs,onNodeClick:o,onNodeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:d,selectNodesOnDrag:w,onlyRenderVisibleElements:L,noPanClassName:Vn,noDragClassName:Pr,disableKeyboardA11y:Qi,nodeOrigin:Xi,nodeExtent:Dr,rfId:Br})))};oS.displayName="GraphView";var GO=O.memo(oS);const ad=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],hi={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:ad,nodeExtent:ad,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Er.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:CM,isValidConnection:void 0},JO=()=>LN((t,e)=>({...hi,setNodes:n=>{const{nodeInternals:i,nodeOrigin:r,elevateNodesOnSelect:s}=e();t({nodeInternals:Eh(n,i,r,s)})},getNodes:()=>Array.from(e().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:i={}}=e();t({edges:n.map(r=>({...i,...r}))})},setDefaultNodesAndEdges:(n,i)=>{const r=typeof n<"u",s=typeof i<"u",o=r?Eh(n,new Map,e().nodeOrigin,e().elevateNodesOnSelect):new Map;t({nodeInternals:o,edges:s?i:[],hasDefaultNodes:r,hasDefaultEdges:s})},updateNodeDimensions:n=>{const{onNodesChange:i,nodeInternals:r,fitViewOnInit:s,fitViewOnInitDone:o,fitViewOnInitOptions:l,domNode:a,nodeOrigin:u}=e(),c=a==null?void 0:a.querySelector(".react-flow__viewport");if(!c)return;const h=window.getComputedStyle(c),{m22:f}=new window.DOMMatrixReadOnly(h.transform),d=n.reduce((g,S)=>{const m=r.get(S.id);if(m!=null&&m.hidden)r.set(m.id,{...m,[Ae]:{...m[Ae],handleBounds:void 0}});else if(m){const y=em(S.nodeElement);!!(y.width&&y.height&&(m.width!==y.width||m.height!==y.height||S.forceUpdate))&&(r.set(m.id,{...m,[Ae]:{...m[Ae],handleBounds:{source:V0(".source",S.nodeElement,f,u),target:V0(".target",S.nodeElement,f,u)}},...y}),g.push({id:m.id,type:"dimensions",dimensions:y}))}return g},[]);Yx(r,u);const p=o||s&&!o&&Qx(e,{initial:!0,...l});t({nodeInternals:new Map(r),fitViewOnInitDone:p}),(d==null?void 0:d.length)>0&&(i==null||i(d))},updateNodePositions:(n,i=!0,r=!1)=>{const{triggerNodeChanges:s}=e(),o=n.map(l=>{const a={id:l.id,type:"position",dragging:r};return i&&(a.positionAbsolute=l.positionAbsolute,a.position=l.position),a});s(o)},triggerNodeChanges:n=>{const{onNodesChange:i,nodeInternals:r,hasDefaultNodes:s,nodeOrigin:o,getNodes:l,elevateNodesOnSelect:a}=e();if(n!=null&&n.length){if(s){const u=dO(n,l()),c=Eh(u,r,o,a);t({nodeInternals:c})}i==null||i(n)}},addSelectedNodes:n=>{const{multiSelectionActive:i,edges:r,getNodes:s}=e();let o,l=null;i?o=n.map(a=>mi(a,!0)):(o=is(s(),n),l=is(r,[])),da({changedNodes:o,changedEdges:l,get:e,set:t})},addSelectedEdges:n=>{const{multiSelectionActive:i,edges:r,getNodes:s}=e();let o,l=null;i?o=n.map(a=>mi(a,!0)):(o=is(r,n),l=is(s(),[])),da({changedNodes:l,changedEdges:o,get:e,set:t})},unselectNodesAndEdges:({nodes:n,edges:i}={})=>{const{edges:r,getNodes:s}=e(),o=n||s(),l=i||r,a=o.map(c=>(c.selected=!1,mi(c.id,!1))),u=l.map(c=>mi(c.id,!1));da({changedNodes:a,changedEdges:u,get:e,set:t})},setMinZoom:n=>{const{d3Zoom:i,maxZoom:r}=e();i==null||i.scaleExtent([n,r]),t({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:i,minZoom:r}=e();i==null||i.scaleExtent([r,n]),t({maxZoom:n})},setTranslateExtent:n=>{var i;(i=e().d3Zoom)==null||i.translateExtent(n),t({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:i}=e(),s=i().filter(l=>l.selected).map(l=>mi(l.id,!1)),o=n.filter(l=>l.selected).map(l=>mi(l.id,!1));da({changedNodes:s,changedEdges:o,get:e,set:t})},setNodeExtent:n=>{const{nodeInternals:i}=e();i.forEach(r=>{r.positionAbsolute=tm(r.position,n)}),t({nodeExtent:n,nodeInternals:new Map(i)})},panBy:n=>{const{transform:i,width:r,height:s,d3Zoom:o,d3Selection:l,translateExtent:a}=e();if(!o||!l||!n.x&&!n.y)return!1;const u=Di.translate(i[0]+n.x,i[1]+n.y).scale(i[2]),c=[[0,0],[r,s]],h=o==null?void 0:o.constrain()(u,c,a);return o.transform(l,h),i[0]!==h.x||i[1]!==h.y||i[2]!==h.k},cancelConnection:()=>t({connectionNodeId:hi.connectionNodeId,connectionHandleId:hi.connectionHandleId,connectionHandleType:hi.connectionHandleType,connectionStatus:hi.connectionStatus,connectionStartHandle:hi.connectionStartHandle,connectionEndHandle:hi.connectionEndHandle}),reset:()=>t({...hi})}),Object.is),fm=({children:t})=>{const e=O.useRef(null);return e.current||(e.current=JO()),j.createElement(gM,{value:e.current},t)};fm.displayName="ReactFlowProvider";const lS=({children:t})=>O.useContext(Ac)?j.createElement(j.Fragment,null,t):j.createElement(fm,null,t);lS.displayName="ReactFlowWrapper";const ZO={input:Fx,default:od,output:Hx,group:cm},eP={default:Lu,straight:sm,step:rm,smoothstep:Tc,simplebezier:im},tP=[0,0],nP=[15,15],iP={x:0,y:0,zoom:1},rP={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},aS=O.forwardRef(({nodes:t,edges:e,defaultNodes:n,defaultEdges:i,className:r,nodeTypes:s=ZO,edgeTypes:o=eP,onNodeClick:l,onEdgeClick:a,onInit:u,onMove:c,onMoveStart:h,onMoveEnd:f,onConnect:d,onConnectStart:p,onConnectEnd:g,onClickConnectStart:S,onClickConnectEnd:m,onNodeMouseEnter:y,onNodeMouseMove:v,onNodeMouseLeave:x,onNodeContextMenu:b,onNodeDoubleClick:C,onNodeDragStart:N,onNodeDrag:M,onNodeDragStop:_,onNodesDelete:P,onEdgesDelete:B,onSelectionChange:L,onSelectionDragStart:F,onSelectionDrag:w,onSelectionDragStop:E,onSelectionContextMenu:T,onSelectionStart:z,onSelectionEnd:R,connectionMode:A=Er.Strict,connectionLineType:D=xi.Bezier,connectionLineStyle:I,connectionLineComponent:$,connectionLineContainerStyle:U,deleteKeyCode:W="Backspace",selectionKeyCode:Q="Shift",selectionOnDrag:te=!1,selectionMode:ne=ml.Full,panActivationKeyCode:he="Space",multiSelectionKeyCode:Ee=Bu()?"Meta":"Control",zoomActivationKeyCode:ge=Bu()?"Meta":"Control",snapToGrid:Zt=!1,snapGrid:Bt=nP,onlyRenderVisibleElements:en=!1,selectNodesOnDrag:Lt=!0,nodesDraggable:Be,nodesConnectable:xn,nodesFocusable:ye,nodeOrigin:Z=tP,edgesFocusable:Ct,edgesUpdatable:Yi,elementsSelectable:Xs,defaultViewport:Pr=iP,minZoom:Rr=.5,maxZoom:Vn=2,translateExtent:Ir=ad,preventScrolling:Qi=!0,nodeExtent:Xi,defaultMarkerColor:Dr="#b1b1b7",zoomOnScroll:Br=!0,zoomOnPinch:Gs=!0,panOnScroll:Ge=!1,panOnScrollSpeed:tn=.5,panOnScrollMode:Gi=fr.Free,zoomOnDoubleClick:Ji=!0,panOnDrag:Zi=!0,onPaneClick:Hn,onPaneMouseEnter:Sn,onPaneMouseMove:Js,onPaneMouseLeave:Hc,onPaneScroll:Zs,onPaneContextMenu:Wc,children:Vm,onEdgeContextMenu:er,onEdgeDoubleClick:Ob,onEdgeMouseEnter:Pb,onEdgeMouseMove:Rb,onEdgeMouseLeave:Ib,onEdgeUpdate:Db,onEdgeUpdateStart:Bb,onEdgeUpdateEnd:Lb,onReconnect:zb,onReconnectStart:$b,onReconnectEnd:jb,reconnectRadius:Fb=10,edgeUpdaterRadius:Vb=10,onNodesChange:Hb,onEdgesChange:Wb,noDragClassName:Ub="nodrag",noWheelClassName:Kb="nowheel",noPanClassName:Hm="nopan",fitView:qb=!1,fitViewOptions:Yb,connectOnClick:Qb=!0,attributionPosition:Xb,proOptions:Gb,defaultEdgeOptions:Jb,elevateNodesOnSelect:Zb=!0,elevateEdgesOnSelect:eC=!1,disableKeyboardA11y:Wm=!1,autoPanOnConnect:tC=!0,autoPanOnNodeDrag:nC=!0,connectionRadius:iC=20,isValidConnection:rC,onError:sC,style:oC,id:Um,nodeDragThreshold:lC,...aC},uC)=>{const Uc=Um||"1";return j.createElement("div",{...aC,style:{...oC,...rP},ref:uC,className:dt(["react-flow",r]),"data-testid":"rf__wrapper",id:Um},j.createElement(lS,null,j.createElement(GO,{onInit:u,onMove:c,onMoveStart:h,onMoveEnd:f,onNodeClick:l,onEdgeClick:a,onNodeMouseEnter:y,onNodeMouseMove:v,onNodeMouseLeave:x,onNodeContextMenu:b,onNodeDoubleClick:C,nodeTypes:s,edgeTypes:o,connectionLineType:D,connectionLineStyle:I,connectionLineComponent:$,connectionLineContainerStyle:U,selectionKeyCode:Q,selectionOnDrag:te,selectionMode:ne,deleteKeyCode:W,multiSelectionKeyCode:Ee,panActivationKeyCode:he,zoomActivationKeyCode:ge,onlyRenderVisibleElements:en,selectNodesOnDrag:Lt,defaultViewport:Pr,translateExtent:Ir,minZoom:Rr,maxZoom:Vn,preventScrolling:Qi,zoomOnScroll:Br,zoomOnPinch:Gs,zoomOnDoubleClick:Ji,panOnScroll:Ge,panOnScrollSpeed:tn,panOnScrollMode:Gi,panOnDrag:Zi,onPaneClick:Hn,onPaneMouseEnter:Sn,onPaneMouseMove:Js,onPaneMouseLeave:Hc,onPaneScroll:Zs,onPaneContextMenu:Wc,onSelectionContextMenu:T,onSelectionStart:z,onSelectionEnd:R,onEdgeContextMenu:er,onEdgeDoubleClick:Ob,onEdgeMouseEnter:Pb,onEdgeMouseMove:Rb,onEdgeMouseLeave:Ib,onReconnect:zb??Db,onReconnectStart:$b??Bb,onReconnectEnd:jb??Lb,reconnectRadius:Fb??Vb,defaultMarkerColor:Dr,noDragClassName:Ub,noWheelClassName:Kb,noPanClassName:Hm,elevateEdgesOnSelect:eC,rfId:Uc,disableKeyboardA11y:Wm,nodeOrigin:Z,nodeExtent:Xi}),j.createElement(qM,{nodes:t,edges:e,defaultNodes:n,defaultEdges:i,onConnect:d,onConnectStart:p,onConnectEnd:g,onClickConnectStart:S,onClickConnectEnd:m,nodesDraggable:Be,nodesConnectable:xn,nodesFocusable:ye,edgesFocusable:Ct,edgesUpdatable:Yi,elementsSelectable:Xs,elevateNodesOnSelect:Zb,minZoom:Rr,maxZoom:Vn,nodeExtent:Xi,onNodesChange:Hb,onEdgesChange:Wb,snapToGrid:Zt,snapGrid:Bt,connectionMode:A,translateExtent:Ir,connectOnClick:Qb,defaultEdgeOptions:Jb,fitView:qb,fitViewOptions:Yb,onNodesDelete:P,onEdgesDelete:B,onNodeDragStart:N,onNodeDrag:M,onNodeDragStop:_,onSelectionDrag:w,onSelectionDragStart:F,onSelectionDragStop:E,noPanClassName:Hm,nodeOrigin:Z,rfId:Uc,autoPanOnConnect:tC,autoPanOnNodeDrag:nC,onError:sC,connectionRadius:iC,isValidConnection:rC,nodeDragThreshold:lC}),j.createElement(UM,{onSelectionChange:L}),Vm,j.createElement(vM,{proOptions:Gb,position:Xb}),j.createElement(JM,{rfId:Uc,disableKeyboardA11y:Wm})))});aS.displayName="ReactFlow";const sP=t=>{var e;return(e=t.domNode)==null?void 0:e.querySelector(".react-flow__edgelabel-renderer")};function oP({children:t}){const e=Se(sP);return e?Iw.createPortal(t,e):null}function lP(){return j.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},j.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function aP(){return j.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},j.createElement("path",{d:"M0 0h32v4.2H0z"}))}function uP(){return j.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},j.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function cP(){return j.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},j.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function hP(){return j.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},j.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const No=({children:t,className:e,...n})=>j.createElement("button",{type:"button",className:dt(["react-flow__controls-button",e]),...n},t);No.displayName="ControlButton";const fP=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom}),uS=({style:t,showZoom:e=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:r,onZoomIn:s,onZoomOut:o,onFitView:l,onInteractiveChange:a,className:u,children:c,position:h="bottom-left"})=>{const f=We(),[d,p]=O.useState(!1),{isInteractive:g,minZoomReached:S,maxZoomReached:m}=Se(fP,rt),{zoomIn:y,zoomOut:v,fitView:x}=Mc();if(O.useEffect(()=>{p(!0)},[]),!d)return null;const b=()=>{y(),s==null||s()},C=()=>{v(),o==null||o()},N=()=>{x(r),l==null||l()},M=()=>{f.setState({nodesDraggable:!g,nodesConnectable:!g,elementsSelectable:!g}),a==null||a(!g)};return j.createElement(bx,{className:dt(["react-flow__controls",u]),position:h,style:t,"data-testid":"rf__controls"},e&&j.createElement(j.Fragment,null,j.createElement(No,{onClick:b,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:m},j.createElement(lP,null)),j.createElement(No,{onClick:C,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},j.createElement(aP,null))),n&&j.createElement(No,{className:"react-flow__controls-fitview",onClick:N,title:"fit view","aria-label":"fit view"},j.createElement(uP,null)),i&&j.createElement(No,{className:"react-flow__controls-interactive",onClick:M,title:"toggle interactivity","aria-label":"toggle interactivity"},g?j.createElement(hP,null):j.createElement(cP,null)),c)};uS.displayName="Controls";var dP=O.memo(uS),pn;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(pn||(pn={}));function pP({color:t,dimensions:e,lineWidth:n}){return j.createElement("path",{stroke:t,strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`})}function mP({color:t,radius:e}){return j.createElement("circle",{cx:e,cy:e,r:e,fill:t})}const gP={[pn.Dots]:"#91919a",[pn.Lines]:"#eee",[pn.Cross]:"#e2e2e2"},yP={[pn.Dots]:1,[pn.Lines]:1,[pn.Cross]:6},vP=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function cS({id:t,variant:e=pn.Dots,gap:n=20,size:i,lineWidth:r=1,offset:s=2,color:o,style:l,className:a}){const u=O.useRef(null),{transform:c,patternId:h}=Se(vP,rt),f=o||gP[e],d=i||yP[e],p=e===pn.Dots,g=e===pn.Cross,S=Array.isArray(n)?n:[n,n],m=[S[0]*c[2]||1,S[1]*c[2]||1],y=d*c[2],v=g?[y,y]:m,x=p?[y/s,y/s]:[v[0]/s,v[1]/s];return j.createElement("svg",{className:dt(["react-flow__background",a]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:u,"data-testid":"rf__background"},j.createElement("pattern",{id:h+t,x:c[0]%m[0],y:c[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${x[0]},-${x[1]})`},p?j.createElement(mP,{color:f,radius:y/s}):j.createElement(pP,{dimensions:v,color:f,lineWidth:r})),j.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${h+t})`}))}cS.displayName="Background";var wP=O.memo(cS);function xP(t,e){const n=e.get(t.operationId);return(n==null?void 0:n.operationId)??(n==null?void 0:n.id)??t.operationId}function hS(t,e){const n=t.map(o=>xP(o,e)),i=new Map;for(const o of n)i.set(o,(i.get(o)??0)+1);const r=new Map,s=new Map;return t.forEach((o,l)=>{const a=n[l];if((i.get(a)??0)<2){s.set(o.id,a);return}const u=(r.get(a)??0)+1;r.set(a,u),s.set(o.id,`${a} #${u}`)}),s}function SP({id:t,sourceX:e,sourceY:n,targetX:i,targetY:r,sourcePosition:s,targetPosition:o,markerEnd:l,style:a,data:u}){const c=Ye(S=>S.toggleBreakpoint),h=Ye(S=>S.isRunning),[f,d,p]=om({sourceX:e,sourceY:n,sourcePosition:s,targetX:i,targetY:r,targetPosition:o}),g=h?"Can't change breakpoints while the workflow is running":u!=null&&u.armed?"Click to select · Double-click to remove debug point":"Click to select · Double-click to add debug point";return k.jsxs(k.Fragment,{children:[k.jsx(Ys,{id:t,path:f,markerEnd:l,style:a}),k.jsx("title",{children:g}),(u==null?void 0:u.armed)&&k.jsx(oP,{children:k.jsx("button",{type:"button",className:"nodrag nopan breakpoint-marker breakpoint-marker--armed",disabled:h,style:{transform:`translate(-50%, -50%) translate(${d}px, ${p}px) scale(calc(1 / var(--rf-zoom, 1)))`},onMouseDown:S=>S.stopPropagation(),onClick:S=>{S.stopPropagation(),c(u.fromNodeId,u.toNodeId)},onDoubleClick:S=>S.stopPropagation(),title:h?"Can't change breakpoints while the workflow is running":"Remove breakpoint","aria-label":"Remove breakpoint","aria-pressed":!0})})]})}const kP={"in-flight":"●",paused:"⏸",completed:"✓",failed:"!"};function bP({data:t}){const{node:e,operation:n,selected:i,status:r,label:s}=t,o=Ye(h=>h.removeNode),l=Ye(h=>h.isRunning),a=(n==null?void 0:n.method)??"get",u=!!(n!=null&&n.operationId)||s!==void 0&&/#\d+$/.test(s),c=r&&kP[r];return k.jsxs("fieldset",{className:`workflow-node workflow-node--${a}${i?" workflow-node--selected":""}${r?` workflow-node--${r}`:""}`,children:[u&&k.jsx("legend",{className:"workflow-node__operation-id",children:s}),c&&k.jsx("span",{className:`workflow-node__status-badge workflow-node__status-badge--${r}`,"aria-hidden":"true",children:c}),k.jsx(Bs,{type:"target",position:G.Left,title:"Drop here to connect — sets run order, not data"}),k.jsx("button",{type:"button",className:"workflow-node__remove-btn",disabled:l,onMouseDown:h=>h.stopPropagation(),onClick:h=>{h.stopPropagation(),o(e.id)},title:l?"Can't remove a node while the workflow is running":"Remove this node","aria-label":"Remove this node",children:"×"}),k.jsxs("div",{className:"workflow-node__header",children:[k.jsx("span",{className:`method-badge method-badge--${a}`,children:a.toUpperCase()}),k.jsx("span",{className:"workflow-node__path",children:(n==null?void 0:n.path)??"Unknown operation"})]}),(n==null?void 0:n.summary)&&k.jsx("div",{className:"workflow-node__summary",title:n.summary,children:n.summary}),r==="paused"&&k.jsx("div",{className:"workflow-node__paused-label",children:"⏸ Paused here"}),k.jsx(Bs,{type:"source",position:G.Right,title:"Drag to connect — sets run order, not data"})]})}const CP={workflowNode:bP},EP={connection:SP};function NP(){return k.jsx(fm,{children:k.jsx(_P,{})})}function _P(){const{nodes:t,nodePositions:e,connections:n,operations:i,selectedNodeId:r,stepStatusByNodeId:s,armedBreakpoints:o,addNode:l,updateNodePosition:a,selectNode:u,connectNodes:c,disconnectNodes:h,removeNode:f,toggleBreakpoint:d}=Ye(),{screenToFlowPosition:p,fitView:g,getViewport:S}=Mc(),m=O.useRef(null),y=O.useRef(t.length),[v,x]=O.useState(null),b=O.useCallback(w=>{var E;(E=m.current)==null||E.style.setProperty("--rf-zoom",String(w.zoom))},[]);O.useEffect(()=>{b(S())},[S,b]);const C=O.useMemo(()=>{const w=new Map(i.map(E=>[E.id,E]));return hS(t,w)},[t,i]),N=O.useMemo(()=>t.map(w=>({id:w.id,type:"workflowNode",position:e[w.id]??{x:80,y:80},data:{node:w,operation:i.find(E=>E.id===w.operationId),selected:w.id===r,status:s[w.id],label:C.get(w.id)}})),[t,e,i,r,s,C]),M=O.useMemo(()=>{const w=n.map(E=>({id:`conn-${E.fromNodeId}->${E.toNodeId}`,source:E.fromNodeId,target:E.toNodeId,type:"connection",className:"edge-connection",markerEnd:{type:gl.ArrowClosed,color:"#9aa0a6"},data:{fromNodeId:E.fromNodeId,toNodeId:E.toNodeId,armed:o.has(Au(E.fromNodeId,E.toNodeId))}}));for(const E of t)for(const T of Object.values(E.fieldValues))T.source==="mapped"&&w.push({id:`map-${T.fromNodeId}->${E.id}-${w.length}`,source:T.fromNodeId,target:E.id,className:"edge-mapping",animated:!0});return w.map(E=>({...E,selected:E.id===v}))},[t,n,v,o]),_=O.useCallback(w=>{w.preventDefault();const E=w.dataTransfer.getData("text/operation-id");if(!E)return;const T=p({x:w.clientX,y:w.clientY});l(E,T)},[l,p]),P=O.useCallback(w=>{w.source&&w.target&&c(w.source,w.target)},[c]),B=O.useCallback(w=>{for(const E of w)E.type==="position"&&E.position?a(E.id,E.position):E.type==="remove"&&f(E.id)},[a,f]),L=O.useCallback(w=>{for(const E of w)if(E.type==="select")x(E.selected?E.id:null),E.selected&&u(null);else if(E.type==="remove"){const T=M.find(z=>z.id===E.id);T!=null&&T.data&&h(T.data.fromNodeId,T.data.toNodeId)}},[M,h,u]),F=O.useCallback(()=>{const w=m.current;if(!w||t.length===0)return;const E=w.getBoundingClientRect();[...w.querySelectorAll(".react-flow__node")].some(R=>{const A=R.getBoundingClientRect();return A.left<E.left||A.top<E.top||A.right>E.right||A.bottom>E.bottom})&&g({padding:.2,duration:300})},[t.length,g]);return O.useEffect(()=>{if(y.current===t.length)return;y.current=t.length;const w=requestAnimationFrame(F);return()=>cancelAnimationFrame(w)},[t.length,F]),O.useEffect(()=>{const w=m.current;if(!w)return;let E=0;const T=new ResizeObserver(()=>{cancelAnimationFrame(E),E=requestAnimationFrame(F)});return T.observe(w),()=>{T.disconnect(),cancelAnimationFrame(E)}},[F]),k.jsx("div",{className:"canvas",ref:m,onDrop:_,onDragOver:w=>w.preventDefault(),children:k.jsxs(aS,{nodes:N,edges:M,nodeTypes:CP,edgeTypes:EP,onNodeClick:(w,E)=>{u(E.id),x(null)},onPaneClick:()=>{u(null),x(null)},onConnect:P,onNodesChange:B,onEdgesChange:L,onEdgeDoubleClick:(w,E)=>{const T=E.data;T!=null&&T.fromNodeId&&T.toNodeId&&d(T.fromNodeId,T.toNodeId)},onMove:(w,E)=>b(E),fitView:!0,fitViewOptions:{padding:.2},children:[k.jsx(wP,{color:"#3a3d42",gap:16}),k.jsx(dP,{})]})})}function Th(t,e){if(e==="integer"||e==="number"){if(t.trim()==="")return t;const n=Number(t);return Number.isNaN(n)?t:n}if(e==="boolean")return t==="true"?!0:t==="false"?!1:t;if(e==="array"){if(t.trim()==="")return t;try{return JSON.parse(t)}catch{return t}}return t}const AP="Unrecognized schema shape (e.g. oneOf/anyOf/allOf) — not supported yet.",TP=new Set(["string","integer","number","boolean"]);function Nr(t){return(t==null?void 0:t.type)==="array"}function Ls(t){return!Nr(t)&&!!t&&(t.type==="object"||!!t.properties)}function _o(t){var e;return(e=t==null?void 0:t.enum)!=null&&e.length?t.enum[0]:(t==null?void 0:t.type)==="integer"||(t==null?void 0:t.type)==="number"?0:(t==null?void 0:t.type)==="boolean"?!0:"string"}function MP(t){if(Ls(t)){const e={};for(const[n,i]of Object.entries(t.properties??{}))e[n]=Nr(i)?[]:Ls(i)?{}:_o(i);return JSON.stringify([e])}return Nr(t)?JSON.stringify([[_o(t.items)]]):JSON.stringify([_o(t),_o(t)])}function fS(t,e,n){return{path:t,required:e,supported:!0,type:"array",reason:MP(n.items)}}function dm(t,e){const n=[],i=(t==null?void 0:t.properties)??{},r=(t==null?void 0:t.required)??[];for(const[s,o]of Object.entries(i)){const l=e?`${e}.${s}`:s,a=r.includes(s);if(Ls(o)){n.push(...dm(o,l));continue}if(Nr(o)){n.push(fS(l,a,o));continue}const u=TP.has(o==null?void 0:o.type)||!!(o!=null&&o.enum);n.push(u?{path:l,required:a,supported:!0,type:o==null?void 0:o.type,enum:o==null?void 0:o.enum}:{path:l,required:a,supported:!1,reason:AP})}return n}function dS(t){return[...t.parameters.map(n=>{var r,s;const i=`${n.in}.${n.name}`;return Nr(n.schema)?fS(i,n.required,n.schema):{path:i,required:n.required,supported:!0,type:(r=n.schema)==null?void 0:r.type,enum:(s=n.schema)==null?void 0:s.enum}}),...dm(t.requestBodySchema,"body")]}function OP(t){return dm(t.responseSchema,"")}function PP(t,e){if(!t||!e||t===e)return!0;const n=new Set(["integer","number"]);return n.has(t)&&n.has(e)}function RP(t){const e={type:"object",properties:{},required:[]};for(const n of t)Object.assign(e.properties,n.properties??{}),e.required.push(...n.required??[]),n.type&&!e.type&&(e.type=n.type);return e}function IP(t){var e,n;return((e=t.oneOf)==null?void 0:e[0])??((n=t.anyOf)==null?void 0:n[0])}function Ao(t){var n;if(!t)return null;if((n=t.allOf)!=null&&n.length)return Ao(RP(t.allOf));const e=IP(t);if(e)return Ao(e);if(Nr(t))return[Ao(t.items)];if(Ls(t)){const i={};for(const[r,s]of Object.entries(t.properties??{}))i[r]=Ao(s);return i}return _o(t)}function ud(t){var e,n,i;if(!t)return!1;if((e=t.oneOf)!=null&&e.length||(n=t.anyOf)!=null&&n.length||(i=t.allOf)!=null&&i.length)return!0;if(Nr(t)){const r=t.items;return Ls(r)?!0:ud(r)}return Ls(t)?Object.values(t.properties??{}).some(ud):!1}const DP=/"__ENLACE_RAW_TAG__([a-zA-Z0-9_-]+)__"/g,BP=t=>`__ENLACE_RAW_TAG__${t}__`;function pS(t){return dS(t).filter(e=>e.supported&&e.path.startsWith("body.")).map(e=>e.path.slice(5))}function LP(t,e){const n=Ao(t.requestBodySchema),i=typeof n=="object"&&n!==null?n:{},r={};for(const o of pS(t)){const l=e[`body.${o}`];if(l)if(l.source==="static")ul(i,o,l.value);else{const a=Tu();r[a]={id:a,type:"response_body",sourceNodeId:l.fromNodeId,jsonPath:l.fromResponseFieldPath||void 0},ul(i,o,BP(a))}}return{template:JSON.stringify(i,null,2).replace(DP,(o,l)=>`"${Vw(l)}"`),tags:r}}function cd(t,e){if(t===e)return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t)||Array.isArray(e))return!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length?!1:t.every((n,i)=>cd(n,e[i]));if(typeof t=="object"){const n=Object.keys(t),i=Object.keys(e);return n.length!==i.length?!1:n.every(r=>cd(t[r],e[r]))}return!1}function zP(t,e){let n;try{n=JSON.parse(t.template)}catch(u){return{fieldValues:{},lossy:!1,parseError:u instanceof Error?u.message:String(u)}}const i={},r={},s=new Set;for(const u of pS(e)){const c=qp(n,u),h=typeof c=="string"?c.match(/^\{\{enlace:([a-zA-Z0-9_-]+)\}\}$/):null,f=h?t.tags[h[1]]:void 0;f&&f.type==="response_body"?(i[`body.${u}`]={source:"mapped",fromNodeId:f.sourceNodeId,fromResponseFieldPath:f.jsonPath??""},s.add(f.id),ul(r,u,c)):(i[`body.${u}`]={source:"static",value:c},ul(r,u,c))}const a=[...new Set([...t.template.matchAll(Rl())].map(u=>u[1]))].some(u=>!s.has(u))||!cd(r,n);return{fieldValues:i,lossy:a}}let hd=[],mS=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?mS:hd).push(n=n+t[e])})();function $P(t){if(t<768)return!1;for(let e=0,n=hd.length;;){let i=e+n>>1;if(t<hd[i])n=i;else if(t>=mS[i])e=i+1;else return!0;if(e==n)return!1}}function X0(t){return t>=127462&&t<=127487}const G0=8205;function jP(t,e,n=!0,i=!0){return(n?gS:FP)(t,e,i)}function gS(t,e,n){if(e==t.length)return e;e&&yS(t.charCodeAt(e))&&vS(t.charCodeAt(e-1))&&e--;let i=Mh(t,e);for(e+=J0(i);e<t.length;){let r=Mh(t,e);if(i==G0||r==G0||n&&$P(r))e+=J0(r),i=r;else if(X0(r)){let s=0,o=e-2;for(;o>=0&&X0(Mh(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function FP(t,e,n){for(;e>1;){let i=gS(t,e-2,n);if(i<e)return i;e--}return 0}function Mh(t,e){let n=t.charCodeAt(e);if(!vS(n)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return yS(i)?(n-55296<<10)+(i-56320)+65536:n}function yS(t){return t>=56320&&t<57344}function vS(t){return t>=55296&&t<56320}function J0(t){return t<65536?1:2}class oe{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,i){[e,n]=zs(this,e,n);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(n,this.length,r,1),On.from(r,this.length-(n-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=zs(this,e,n);let i=[];return this.decompose(e,n,i,0),On.from(i,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new jo(this),s=new jo(e);for(let o=n,l=n;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new jo(this,e)}iterRange(e,n=this.length){return new wS(this,e,n)}iterLines(e,n){let i;if(e==null)i=this.iter();else{n==null&&(n=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new xS(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?oe.empty:e.length<=32?new Pe(e):On.from(Pe.split(e,[]))}}class Pe extends oe{constructor(e,n=VP(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((n?i:l)>=e)return new HP(r,l,i,o);r=l+1,i++}}decompose(e,n,i,r){let s=e<=0&&n>=this.length?this:new Pe(Z0(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Ga(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new Pe(l,o.length+s.length));else{let a=l.length>>1;i.push(new Pe(l.slice(0,a)),new Pe(l.slice(a)))}}else i.push(s)}replace(e,n,i){if(!(i instanceof Pe))return super.replace(e,n,i);[e,n]=zs(this,e,n);let r=Ga(this.text,Ga(i.text,Z0(this.text,0,e)),n),s=this.length+i.length-(n-e);return r.length<=32?new Pe(r,s):On.from(Pe.split(r,[]),s)}sliceString(e,n=this.length,i=`
57
+ `){[e,n]=zs(this,e,n);let r="";for(let s=0,o=0;s<=n&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=i),e<a&&n>s&&(r+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return r}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(n.push(new Pe(i,r)),i=[],r=-1);return r>-1&&n.push(new Pe(i,r)),n}}class On extends oe{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,n,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,i,r);r=l+1,i=a+1}}decompose(e,n,i,r){for(let s=0,o=0;o<=n&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&n>=o){let u=r&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?i.push(l):l.decompose(e-o,n-o,i,u)}o=a+1}}replace(e,n,i){if([e,n]=zs(this,e,n),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&n<=l){let a=o.replace(e-s,n-s,i),u=this.lines-o.lines+a.lines;if(a.lines<u>>4&&a.lines>u>>6){let c=this.children.slice();return c[r]=a,new On(c,this.length-(n-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,i)}sliceString(e,n=this.length,i=`
58
+ `){[e,n]=zs(this,e,n);let r="";for(let s=0,o=0;s<this.children.length&&o<=n;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&n>o&&(r+=l.sliceString(e-o,n-o,i)),o=a+1}return r}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof On))return 0;let i=0,[r,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=n,s+=n){if(r==o||s==l)return i;let a=this.children[r],u=e.children[s];if(a!=u)return i+a.scanIdentical(u,n);i+=a.length+1}}static from(e,n=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new Pe(d,n)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,u=-1,c=[];function h(d){let p;if(d.lines>s&&d instanceof On)for(let g of d.children)h(g);else d.lines>o&&(a>o||!a)?(f(),l.push(d)):d instanceof Pe&&a&&(p=c[c.length-1])instanceof Pe&&d.lines+p.lines<=32?(a+=d.lines,u+=d.length+1,c[c.length-1]=new Pe(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>r&&f(),a+=d.lines,u+=d.length+1,c.push(d))}function f(){a!=0&&(l.push(c.length==1?c[0]:On.from(c,u)),u=-1,a=c.length=0)}for(let d of e)h(d);return f(),l.length==1?l[0]:new On(l,n)}}oe.empty=new Pe([""],0);function VP(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ga(t,e,n=0,i=1e9){for(let r=0,s=0,o=!0;s<t.length&&r<=i;s++){let l=t[s],a=r+l.length;a>=n&&(a>i&&(l=l.slice(0,i-r)),r<n&&(l=l.slice(n-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function Z0(t,e,n){return Ga(t,[""],e,n)}class jo{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof Pe?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof Pe?r.text.length:r.children.length;if(o==(n>0?l:0)){if(i==0)return this.done=!0,this.value="",this;n>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[i]+=n,e==0)return this.lineBreak=!0,this.value=`
59
+ `,this;e--}else if(r instanceof Pe){let a=r.text[o+(n<0?-1:0)];if(this.offsets[i]+=n,a.length>Math.max(0,e))return this.value=e==0?a:n>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(n<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=n):(n<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(n>0?1:(a instanceof Pe?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)}}class wS{constructor(e,n,i){this.value="",this.done=!1,this.cursor=new jo(e,n>i?-1:1),this.pos=n>i?e.length:0,this.from=Math.min(n,i),this.to=Math.max(n,i)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let i=n<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*n,this.value=r.length<=i?r:n<0?r.slice(r.length-i):r.slice(0,i),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!=""}}class xS{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:i,value:r}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(oe.prototype[Symbol.iterator]=function(){return this.iter()},jo.prototype[Symbol.iterator]=wS.prototype[Symbol.iterator]=xS.prototype[Symbol.iterator]=function(){return this});class HP{constructor(e,n,i,r){this.from=e,this.to=n,this.number=i,this.text=r}get length(){return this.to-this.from}}function zs(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function nt(t,e,n=!0,i=!0){return jP(t,e,n,i)}function WP(t){return t>=56320&&t<57344}function UP(t){return t>=55296&&t<56320}function sr(t,e){let n=t.charCodeAt(e);if(!UP(n)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return WP(i)?(n-55296<<10)+(i-56320)+65536:n}function KP(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function Hr(t){return t<65536?1:2}const fd=/\r\n?|\n/;var At=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(At||(At={}));class zn{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let i=this.sections[n+1];e+=i<0?this.sections[n]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,i=0,r=0;n<this.sections.length;){let s=this.sections[n++],o=this.sections[n++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,n=!1){dd(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let i=this.sections[n++],r=this.sections[n++];r<0?e.push(i,r):e.push(r,i)}return new zn(e)}composeDesc(e){return this.empty?e:e.empty?this:SS(this,e)}mapDesc(e,n=!1){return e.empty?this:pd(this,e,n)}mapPos(e,n=-1,i=At.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],u=r+l;if(a<0){if(u>e)return s+(e-r);s+=l}else{if(i!=At.Simple&&u>=e&&(i==At.TrackDel&&r<e&&u>e||i==At.TrackBefore&&r<e||i==At.TrackAfter&&u>e))return null;if(u>e||u==e&&n<0&&!l)return e==r||n<0?s:s+a;s+=a}r=u}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,n=e){for(let i=0,r=0;i<this.sections.length&&r<=n;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=n&&l>=e)return r<e&&l>n?"cover":!0;r=l}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let i=this.sections[n++],r=this.sections[n++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zn(e)}static create(e){return new zn(e)}}class ze extends zn{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return dd(this,(n,i,r,s,o)=>e=e.replace(r,r+(i-n),o),!1),e}mapDesc(e,n=!1){return pd(this,e,n,!0)}invert(e){let n=this.sections.slice(),i=[];for(let r=0,s=0;r<n.length;r+=2){let o=n[r],l=n[r+1];if(l>=0){n[r]=l,n[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(oe.empty);i.push(o?e.slice(s,s+o):oe.empty)}s+=o}return new ze(n,i)}compose(e){return this.empty?e:e.empty?this:SS(this,e,!0)}map(e,n=!1){return e.empty?this:pd(this,e,n,!0)}iterChanges(e,n=!1){dd(this,e,n)}get desc(){return zn.create(this.sections)}filter(e){let n=[],i=[],r=[],s=new vl(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);et(r,c,-1);let h=s.ins==-1?-1:s.off==0?s.ins:0;et(n,c,h),h>0&&Ei(i,n,s.text),s.forward(c),l+=c}let u=e[o++];for(;l<u;){if(s.done)break e;let c=Math.min(s.len,u-l);et(n,c,-1),et(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new ze(n,i),filtered:zn.create(r)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let i=this.sections[n],r=this.sections[n+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,i){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<n&&et(r,n-o,-1);let h=new ze(r,s);l=l?l.compose(h.map(l)):h,r=[],s=[],o=0}function u(c){if(Array.isArray(c))for(let h of c)u(h);else if(c instanceof ze){if(c.length!=n)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${n})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:h,to:f=h,insert:d}=c;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"?oe.of(d.split(i||fd)):d:oe.empty,g=p.length;if(h==f&&g==0)return;h<o&&a(),h>o&&et(r,h-o,-1),et(r,f-h,g),Ei(s,r,p),o=f}}return u(e),a(!l),l}static empty(e){return new ze(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")n.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;i.length<r;)i.push(oe.empty);i[r]=oe.of(s.slice(1)),n.push(s[0],i[r].length)}}}return new ze(n,i)}static createSet(e,n){return new ze(e,n)}}function et(t,e,n,i=!1){if(e==0&&n<=0)return;let r=t.length-2;r>=0&&n<=0&&n==t[r+1]?t[r]+=e:r>=0&&e==0&&t[r]==0?t[r+1]+=n:i?(t[r]+=e,t[r+1]+=n):t.push(e,n)}function Ei(t,e,n){if(n.length==0)return;let i=e.length-2>>1;if(i<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<i;)t.push(oe.empty);t.push(n)}}function dd(t,e,n){let i=t.inserted;for(let r=0,s=0,o=0;o<t.sections.length;){let l=t.sections[o++],a=t.sections[o++];if(a<0)r+=l,s+=l;else{let u=r,c=s,h=oe.empty;for(;u+=l,c+=a,a&&i&&(h=h.append(i[o-2>>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(r,u,s,c,h),r=u,s=c}}}function pd(t,e,n,i=!1){let r=[],s=i?[]:null,o=new vl(t),l=new vl(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);et(r,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!n))){let u=l.len;for(et(r,l.ins,-1);u;){let c=Math.min(o.len,u);o.ins>=0&&a<o.i&&o.len<=c&&(et(r,0,o.ins),s&&Ei(s,r,o.text),a=o.i),o.forward(c),u-=c}l.next()}else if(o.ins>=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let h=Math.min(c,l.len);u+=h,c-=h,l.forward(h)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;et(r,u,a<o.i?o.ins:0),s&&a<o.i&&Ei(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?ze.createSet(r,s):zn.create(r);throw new Error("Mismatched change set lengths")}}}function SS(t,e,n=!1){let i=[],r=n?[]:null,s=new vl(t),o=new vl(e);for(let l=!1;;){if(s.done&&o.done)return r?ze.createSet(i,r):zn.create(i);if(s.ins==0)et(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)et(i,0,o.ins,l),r&&Ei(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),u=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;et(i,a,c,l),r&&c&&Ei(r,i,o.text)}else o.ins==-1?(et(i,s.off?0:s.len,a,l),r&&Ei(r,i,s.textBit(a))):(et(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Ei(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>u),s.forward2(a),o.forward(a)}}}}class vl{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,n=this.i-2>>1;return n>=e.length?oe.empty:e[n]}textBit(e){let{inserted:n}=this.set,i=this.i-2>>1;return i>=n.length&&!e?oe.empty:n[i].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)}}class Si{constructor(e,n,i,r){this.from=e,this.to=n,this.flags=i,this.goalColumn=r}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 e=this.flags&7;return e==7?null:e}map(e,n=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,n):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new Si(i,r,this.flags,this.goalColumn)}extend(e,n=e,i=0){if(e<=this.anchor&&n>=this.anchor)return V.range(e,n,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return V.range(this.anchor,r,void 0,void 0,i)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return V.range(e.anchor,e.head)}static create(e,n,i,r){return new Si(e,n,i,r)}}class V{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:V.create(this.ranges.map(i=>i.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new V([this.main],0)}addRange(e,n=!0){return V.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let i=this.ranges.slice();return i[n]=e,V.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new V(e.ranges.map(n=>Si.fromJSON(n)),e.main)}static single(e,n=e){return new V([V.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return V.normalized(e.slice(),n);i=s.to}return new V(e,n)}static cursor(e,n=0,i,r){return Si.create(e,e,(n==0?0:n<0?8:16)|(i==null?7:Math.min(6,i)),r)}static range(e,n,i,r,s){let o=r==null?7:Math.min(6,r);return!s&&e!=n&&(s=n<e?1:-1),s&&(o|=s<0?8:16),n<e?Si.create(n,e,o|32,i):Si.create(e,n,o,i)}static undirectionalRange(e,n){return Si.create(e,n,64,void 0)}static normalized(e,n=0){let i=e[n];e.sort((r,s)=>r.from-s.from),n=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=n&&n--,e.splice(--r,2,s.anchor>s.head?V.range(a,l):V.range(l,a))}}return new V(e,n)}}function kS(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let pm=0;class ee{constructor(e,n,i,r,s){this.combine=e,this.compareInput=n,this.compare=i,this.isStatic=r,this.id=pm++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new ee(e.combine||(n=>n),e.compareInput||((n,i)=>n===i),e.compare||(e.combine?(n,i)=>n===i:mm),!!e.static,e.enables)}of(e){return new Ja([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ja(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ja(e,this,2,n)}from(e,n){return n||(n=i=>i),this.compute([e],i=>n(i.field(e)))}}function mm(t,e){return t==e||t.length==e.length&&t.every((n,i)=>n===e[i])}class Ja{constructor(e,n,i,r){this.dependencies=e,this.facet=n,this.type=i,this.value=r,this.id=pm++}dynamicSlot(e){var n;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let h of this.dependencies)h=="doc"?a=!0:h=="selection"?u=!0:((n=e[h.id])!==null&&n!==void 0?n:1)&1||c.push(e[h.id]);return{create(h){return h.values[o]=i(h),1},update(h,f){if(a&&f.docChanged||u&&(f.docChanged||f.selection)||md(h,c)){let d=i(h);if(l?!ey(d,h.values[o],r):!r(d,h.values[o]))return h.values[o]=d,1}return 0},reconfigure:(h,f)=>{let d,p=f.config.address[s];if(p!=null){let g=$u(f,p);if(this.dependencies.every(S=>S instanceof ee?f.facet(S)===h.facet(S):S instanceof ui?f.field(S,!1)==h.field(S,!1):!0)||(l?ey(d=i(h),g,r):r(d=i(h),g)))return h.values[o]=g,0}else d=i(h);return h.values[o]=d,1}}}get extension(){return this}}function ey(t,e,n){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!n(t[i],e[i]))return!1;return!0}function md(t,e){let n=!1;for(let i of e)Fo(t,i)&1&&(n=!0);return n}function qP(t,e,n){let i=n.map(a=>t[a.id]),r=n.map(a=>a.type),s=i.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let u=[];for(let c=0;c<i.length;c++){let h=$u(a,i[c]);if(r[c]==2)for(let f of h)u.push(f);else u.push(h)}return e.combine(u)}return{create(a){for(let u of i)Fo(a,u);return a.values[o]=l(a),1},update(a,u){if(!md(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,u){let c=md(a,i),h=u.config.facets[e.id],f=u.facet(e);if(h&&!c&&mm(n,h))return a.values[o]=f,0;let d=l(a);return e.compare(d,f)?(a.values[o]=f,0):(a.values[o]=d,1)}}}const ma=ee.define({static:!0});class ui{constructor(e,n,i,r,s){this.id=e,this.createF=n,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let n=new ui(pm++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(ma).find(i=>i.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:i=>(i.values[n]=this.create(i),1),update:(i,r)=>{let s=i.values[n],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[n]=o,1)},reconfigure:(i,r)=>{let s=i.facet(ma),o=r.facet(ma),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[n]=l.create(i),1):r.config.address[this.id]!=null?(i.values[n]=r.field(this),0):(i.values[n]=this.create(i),1)}}}init(e){return[this,ma.of({field:this,create:e})]}get extension(){return this}}const lr={lowest:4,low:3,default:2,high:1,highest:0};function po(t){return e=>new bS(e,t)}const Bl={highest:po(lr.highest),high:po(lr.high),default:po(lr.default),low:po(lr.low),lowest:po(lr.lowest)};class bS{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class Ll{of(e){return new gd(this,e)}reconfigure(e){return Ll.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class gd{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class zu{constructor(e,n,i,r,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,i){let r=[],s=Object.create(null),o=new Map;for(let f of YP(e,n,o))f instanceof ui?r.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],u=[];for(let f of r)l[f.id]=u.length<<1,u.push(d=>f.slot(d));let c=i==null?void 0:i.config.facets;for(let f in s){let d=s[f],p=d[0].facet,g=c&&c[f]||[];if(d.every(S=>S.type==0))if(l[p.id]=a.length<<1|1,mm(g,d))a.push(i.facet(p));else{let S=p.combine(d.map(m=>m.value));a.push(i&&p.compare(S,i.facet(p))?i.facet(p):S)}else{for(let S of d)S.type==0?(l[S.id]=a.length<<1|1,a.push(S.value)):(l[S.id]=u.length<<1,u.push(m=>S.dynamicSlot(m)));l[p.id]=u.length<<1,u.push(S=>qP(S,p,d))}}let h=u.map(f=>f(l));return new zu(e,o,h,l,a,s)}}function YP(t,e,n){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let u=i[a].indexOf(o);u>-1&&i[a].splice(u,1),o instanceof gd&&n.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof gd){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,l)}else if(o instanceof bS)s(o.inner,o.prec);else if(o instanceof ui)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Ja)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,lr.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(u==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(u,l)}}return s(t,lr.default),i.reduce((o,l)=>o.concat(l))}function Fo(t,e){if(e&1)return 2;let n=e>>1,i=t.status[n];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;t.status[n]=4;let r=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|r}function $u(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const CS=ee.define(),yd=ee.define({combine:t=>t.some(e=>e),static:!0}),ES=ee.define({combine:t=>t.length?t[0]:void 0,static:!0}),NS=ee.define(),_S=ee.define(),AS=ee.define(),TS=ee.define({combine:t=>t.length?t[0]:!1});class Fn{constructor(e,n){this.type=e,this.value=n}static define(){return new QP}}class QP{of(e){return new Fn(this,e)}}class XP{constructor(e){this.map=e}of(e){return new me(this,e)}}class me{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new me(this.type,n)}is(e){return this.type==e}static define(e={}){return new XP(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(n);s&&i.push(s)}return i}}me.reconfigure=me.define();me.appendConfig=me.define();class je{constructor(e,n,i,r,s,o){this.startState=e,this.changes=n,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&kS(i,n.newLength),s.some(l=>l.type==je.time)||(this.annotations=s.concat(je.time.of(Date.now())))}static create(e,n,i,r,s,o){return new je(e,n,i,r,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(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(je.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}je.time=Fn.define();je.userEvent=Fn.define();je.addToHistory=Fn.define();je.remote=Fn.define();function GP(t,e){let n=[];for(let i=0,r=0;;){let s,o;if(i<t.length&&(r==e.length||e[r]>=t[i]))s=t[i++],o=t[i++];else if(r<e.length)s=e[r++],o=e[r++];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 MS(t,e,n){var i;let r,s,o;return n?(r=e.changes,s=ze.empty(e.changes.length),o=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=t.selection)===null||i===void 0?void 0:i.map(r),effects:me.mapEffects(t.effects,r).concat(me.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function vd(t,e,n){let i=e.selection,r=ws(e.annotations);return e.userEvent&&(r=r.concat(je.userEvent.of(e.userEvent))),{changes:e.changes instanceof ze?e.changes:ze.of(e.changes||[],n,t.facet(ES)),selection:i&&(i instanceof V?i:V.single(i.anchor,i.head)),effects:ws(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function OS(t,e,n){let i=vd(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(n=!1);let o=!!e[s].sequential;i=MS(i,vd(t,e[s],o?i.changes.newLength:t.doc.length),o)}let r=je.create(t,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return ZP(n?JP(r):r)}function JP(t){let e=t.startState,n=!0;for(let r of e.facet(NS)){let s=r(t);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:GP(n,s))}if(n!==!0){let r,s;if(n===!1)s=t.changes.invertedDesc,r=ze.empty(e.doc.length);else{let o=t.changes.filter(n);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=je.create(e,r,t.selection&&t.selection.map(s),me.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let i=e.facet(_S);for(let r=i.length-1;r>=0;r--){let s=i[r](t);s instanceof je?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof je?t=s[0]:t=OS(e,ws(s),!1)}return t}function ZP(t){let e=t.startState,n=e.facet(AS),i=t;for(let r=n.length-1;r>=0;r--){let s=n[r](t);s&&Object.keys(s).length&&(i=MS(i,vd(e,s,t.changes.newLength),!0))}return i==t?t:je.create(e,t.changes,t.selection,i.effects,i.annotations,i.scrollIntoView)}const eR=[];function ws(t){return t==null?eR:Array.isArray(t)?t:[t]}var Jn=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Jn||(Jn={}));const tR=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let wd;try{wd=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function nR(t){if(wd)return wd.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||tR.test(n)))return!0}return!1}function iR(t){return e=>{if(!/\S/.test(e))return Jn.Space;if(nR(e))return Jn.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return Jn.Word;return Jn.Other}}class ae{constructor(e,n,i,r,s,o){this.config=e,this.doc=n,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Fo(this,l<<1);this.computeSlot=null}field(e,n=!0){let i=this.config.address[e.id];if(i==null){if(n)throw new RangeError("Field is not present in this state");return}return Fo(this,i),$u(this,i)}update(...e){return OS(this,e,!0)}applyTransaction(e){let n=this.config,{base:i,compartments:r}=n;for(let l of e.effects)l.is(Ll.reconfigure)?(n&&(r=new Map,n.compartments.forEach((a,u)=>r.set(u,a)),n=null),r.set(l.value.compartment,l.value.extension)):l.is(me.reconfigure)?(n=null,i=l.value):l.is(me.appendConfig)&&(n=null,i=ws(i).concat(l.value));let s;n?s=e.startState.values.slice():(n=zu.resolve(i,r,this),s=new ae(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(yd)?e.newSelection:e.newSelection.asSingle();new ae(n,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:V.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,i=e(n.ranges[0]),r=this.changes(i.changes),s=[i.range],o=ws(i.effects);for(let l=1;l<n.ranges.length;l++){let a=e(n.ranges[l]),u=this.changes(a.changes),c=u.map(r);for(let f=0;f<l;f++)s[f]=s[f].map(c);let h=r.mapDesc(u,!0);s.push(a.range.map(h)),r=r.compose(c),o=me.mapEffects(o,c).concat(me.mapEffects(ws(a.effects),h))}return{changes:r,selection:V.create(s,n.mainIndex),effects:o}}changes(e=[]){return e instanceof ze?e:ze.of(e,this.doc.length,this.facet(ae.lineSeparator))}toText(e){return oe.of(e.split(this.facet(ae.lineSeparator)||fd))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(Fo(this,n),$u(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof ui&&this.config.address[r.id]!=null&&(n[i]=r.spec.toJSON(this.field(e[i]),this))}return n}static fromJSON(e,n={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return ae.create({doc:e.doc,selection:V.fromJSON(e.selection),extensions:n.extensions?r.concat([n.extensions]):r})}static create(e={}){let n=zu.resolve(e.extensions||[],new Map),i=e.doc instanceof oe?e.doc:oe.of((e.doc||"").split(n.staticFacet(ae.lineSeparator)||fd)),r=e.selection?e.selection instanceof V?e.selection:V.single(e.selection.anchor,e.selection.head):V.single(0);return kS(r,i.length),n.staticFacet(yd)||(r=r.asSingle()),new ae(n,i,r,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(ae.tabSize)}get lineBreak(){return this.facet(ae.lineSeparator)||`
60
+ `}get readOnly(){return this.facet(TS)}phrase(e,...n){for(let i of this.facet(ae.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>n.length?i:n[s-1]})),e}languageDataAt(e,n,i=-1){let r=[];for(let s of this.facet(CS))for(let o of s(this,n,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return iR(n.length?n[0]:"")}wordAt(e){let{text:n,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=nt(n,o,!1);if(s(n.slice(a,o))!=Jn.Word)break;o=a}for(;l<r;){let a=nt(n,l);if(s(n.slice(l,a))!=Jn.Word)break;l=a}return o==l?null:V.range(o+i,l+i)}}ae.allowMultipleSelections=yd;ae.tabSize=ee.define({combine:t=>t.length?t[0]:4});ae.lineSeparator=ES;ae.readOnly=TS;ae.phrases=ee.define({compare(t,e){let n=Object.keys(t),i=Object.keys(e);return n.length==i.length&&n.every(r=>t[r]==e[r])}});ae.languageData=CS;ae.changeFilter=NS;ae.transactionFilter=_S;ae.transactionExtender=AS;Ll.reconfigure=me.define();function PS(t,e,n={}){let i={};for(let r of t)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(n,s))i[s]=n[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}class $i{eq(e){return this==e}range(e,n=e){return xd.create(e,n,this)}}$i.prototype.startSide=$i.prototype.endSide=0;$i.prototype.point=!1;$i.prototype.mapMode=At.TrackDel;function gm(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let xd=class RS{constructor(e,n,i){this.from=e,this.to=n,this.value=i}static create(e,n,i){return new RS(e,n,i)}};function Sd(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class ym{constructor(e,n,i,r){this.from=e,this.to=n,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,n,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,u=s[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-n;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,n,i,r){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,n){let i=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let u=this.value[a],c=this.from[a]+e,h=this.to[a]+e,f,d;if(c==h){let p=n.mapPos(c,u.startSide,u.mapMode);if(p==null||(f=d=p,u.startSide!=u.endSide&&(d=n.mapPos(c,u.endSide),d<f)))continue}else if(f=n.mapPos(c,u.startSide),d=n.mapPos(h,u.endSide),f>d||f==d&&u.startSide>0&&u.endSide<=0)continue;(d-f||u.endSide-u.startSide)<0||(o<0&&(o=f),u.point&&(l=Math.max(l,d-f)),i.push(u),r.push(f-o),s.push(d-o))}return{mapped:i.length?new ym(r,s,i,l):null,pos:o}}}class ue{constructor(e,n,i,r){this.chunkPos=e,this.chunk=n,this.nextLayer=i,this.maxPoint=r}static create(e,n,i,r){return new ue(e,n,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(i&&(n=n.slice().sort(Sd)),this.isEmpty)return n.length?ue.of(n):this;let l=new IS(this,null,-1).goto(0),a=0,u=[],c=new wl;for(;l.value||a<n.length;)if(a<n.length&&(l.from-n[a].from||l.startSide-n[a].value.startSide)>=0){let h=n[a++];c.addInner(h.from,h.to,h.value)||u.push(h)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==n.length||this.chunkEnd(l.chunkIndex)<n[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||u.push(xd.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!u.length?ue.empty:this.nextLayer.update({add:u,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let n=[],i=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],u=e.touchesRange(l,l+a.length);if(u===!1)r=Math.max(r,a.maxPoint),n.push(a),i.push(e.mapPos(l));else if(u===!0){let{mapped:c,pos:h}=a.map(l,e);c&&(r=Math.max(r,c.maxPoint),n.push(c),i.push(h))}}let s=this.nextLayer.map(e);return n.length==0?s:new ue(i,n,s||ue.empty,r)}between(e,n,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(n>=s&&e<=s+o.length&&o.between(s,e-s,n-s,i)===!1)return}this.nextLayer.between(e,n,i)}}iter(e=0){return xl.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return xl.from(e).goto(n)}static compare(e,n,i,r,s=-1){let o=e.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=s),l=n.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=s),a=ty(o,l,i),u=new mo(o,a,s),c=new mo(l,a,s);i.iterGaps((h,f,d)=>ny(u,h,c,f,d,r)),i.empty&&i.length==0&&ny(u,0,c,0,0,r)}static eq(e,n,i=0,r){r==null&&(r=999999999);let s=e.filter(c=>!c.isEmpty&&n.indexOf(c)<0),o=n.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=ty(s,o),a=new mo(s,l,0).goto(i),u=new mo(o,l,0).goto(i);for(;;){if(a.to!=u.to||!kd(a.active,u.active)||a.point&&(!u.point||!gm(a.point,u.point)))return!1;if(a.to>r)return!0;a.next(),u.next()}}static spans(e,n,i,r,s=-1){let o=new mo(e,null,s).goto(n),l=n,a=o.openStart;for(;;){let u=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),h=o.pointFrom<n?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);r.point(l,u,o.point,c,h,o.pointRank),a=Math.min(o.openEnd(u),c.length)}else u>l&&(r.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,n=!1){let i=new wl;for(let r of e instanceof xd?[e]:n?rR(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return ue.empty;let n=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=ue.empty;r=r.nextLayer)n=new ue(r.chunkPos,r.chunk,n,Math.max(r.maxPoint,n.maxPoint));return n}}ue.empty=new ue([],[],null,-1);function rR(t){if(t.length>1)for(let e=t[0],n=1;n<t.length;n++){let i=t[n];if(Sd(e,i)>0)return t.slice().sort(Sd);e=i}return t}ue.empty.nextLayer=ue.empty;class wl{finishChunk(e){this.chunks.push(new ym(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,e&&(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(e,n,i){this.addInner(e,n,i)||(this.nextLayer||(this.nextLayer=new wl)).add(e,n,i)}addInner(e,n,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=n,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-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(e);let i=n.value.length-1;return this.last=n.value[i],this.lastFrom=n.from[i]+e,this.lastTo=n.to[i]+e,!0}finish(){return this.finishInner(ue.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=ue.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function ty(t,e,n){let i=new Map;for(let s of t)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(n?n.mapPos(l):l)==s.chunkPos[o]&&!(n!=null&&n.touchesRange(l,l+s.chunk[o].length))&&r.add(s.chunk[o])}return r}class IS{constructor(e,n,i,r=0){this.layer=e,this.skip=n,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,n=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,n,!1),this}gotoInner(e,n,i){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++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],n,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,n){(this.to-e||this.endSide-n)<0&&this.gotoInner(e,n,!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],n=this.layer.chunk[this.chunkIndex],i=e+n.from[this.rangeIndex];if(this.from=i,this.to=e+n.to[this.rangeIndex],this.value=n.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}}class xl{constructor(e){this.heap=e}static from(e,n=null,i=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&r.push(new IS(o,n,i,s));return r.length==1?r[0]:new xl(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let i of this.heap)i.goto(e,n);for(let i=this.heap.length>>1;i>=0;i--)Oh(this.heap,i);return this.next(),this}forward(e,n){for(let i of this.heap)i.forward(e,n);for(let i=this.heap.length>>1;i>=0;i--)Oh(this.heap,i);(this.to-e||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 e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Oh(this.heap,0)}}}function Oh(t,e){for(let n=t[e];;){let i=(e<<1)+1;if(i>=t.length)break;let r=t[i];if(i+1<t.length&&r.compare(t[i+1])>=0&&(r=t[i+1],i++),n.compare(r)<0)break;t[i]=n,t[e]=r,e=i}}class mo{constructor(e,n,i){this.minPoint=i,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=xl.from(e,n,i)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){ga(this.active,e),ga(this.activeTo,e),ga(this.activeRank,e),this.minActive=iy(this.active,this.activeTo)}addActive(e){let n=0,{value:i,to:r,rank:s}=this.cursor;for(;n<this.activeRank.length&&(s-this.activeRank[n]||r-this.activeTo[n])>0;)n++;ya(this.active,n,i),ya(this.activeTo,n,r),ya(this.activeRank,n,s),e&&ya(e,n,this.cursor.from),this.minActive=iy(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let i=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),i&&ga(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let n=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&n.push(this.active[i]);return n.reverse()}openEnd(e){let n=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)n++;return n}}function ny(t,e,n,i,r,s){t.goto(e),n.goto(i);let o=i+r,l=i,a=i-e,u=!!s.boundChange;for(let c=!1;;){let h=t.to+a-n.to,f=h||t.endSide-n.endSide,d=f<0?t.to+a:n.to,p=Math.min(d,o);if(t.point||n.point?(t.point&&n.point&&gm(t.point,n.point)&&kd(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!kd(t.active,n.active)&&s.compareRange(l,p,t.active,n.active),u&&p<o&&(h||t.openEnd(d)!=n.openEnd(d))&&(c=!0)),d>o)break;l=d,f<=0&&t.next(),f>=0&&n.next()}}function kd(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!=e[n]&&!gm(t[n],e[n]))return!1;return!0}function ga(t,e){for(let n=e,i=t.length-1;n<i;n++)t[n]=t[n+1];t.pop()}function ya(t,e,n){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=n}function iy(t,e){let n=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||t[r].endSide-t[n].endSide)<0&&(n=r,i=e[r]);return n}function Oc(t,e,n=t.length){let i=0;for(let r=0;r<n&&r<t.length;)t.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=nt(t,r));return i}function sR(t,e,n,i){for(let r=0,s=0;;){if(s>=e)return r;if(r==t.length)break;s+=t.charCodeAt(r)==9?n-s%n:1,r=nt(t,r)}return t.length}const bd="ͼ",ry=typeof Symbol>"u"?"__"+bd:Symbol.for(bd),Cd=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),sy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ji{constructor(e,n){this.rules=[];let{finish:i}=n||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,u){let c=[],h=/^@(\w+)\b/.exec(o[0]),f=h&&h[1]=="keyframes";if(h&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))s(d.split(/,\s*/).map(g=>o.map(S=>g.replace(/&/,S))).reduce((g,S)=>g.concat(S)),p,a);else if(p&&typeof p=="object"){if(!h)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),p,c,f)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+p+";")}(c.length||f)&&a.push((i&&!h&&!u?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
61
+ `)}static newName(){let e=sy[ry]||1;return sy[ry]=e+1,bd+e.toString(36)}static mount(e,n,i){let r=e[Cd],s=i&&i.nonce;r?s&&r.setNonce(s):r=new oR(e,s),r.mount(Array.isArray(n)?n:[n],e)}}let oy=new Map;class oR{constructor(e,n){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=oy.get(i);if(s)return e[Cd]=s;this.sheet=new r.CSSStyleSheet,oy.set(i,this)}else this.styleTag=i.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[Cd]=this}mount(e,n){let i=this.sheet,r=0,s=0;for(let o=0;o<e.length;o++){let l=e[o],a=this.modules.indexOf(l);if(a<s&&a>-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),i)for(let u=0;u<l.rules.length;u++)i.insertRule(l.rules[u],r++)}else{for(;s<a;)r+=this.modules[s++].rules.length;r+=l.rules.length,s++}}if(i)n.adoptedStyleSheets.indexOf(this.sheet)<0&&(n.adoptedStyleSheets=[this.sheet,...n.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
62
+ `;this.styleTag.textContent=o;let l=n.head||n;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var Fi={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:"'"},Sl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},lR=typeof navigator<"u"&&/Mac/.test(navigator.platform),aR=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var qe=0;qe<10;qe++)Fi[48+qe]=Fi[96+qe]=String(qe);for(var qe=1;qe<=24;qe++)Fi[qe+111]="F"+qe;for(var qe=65;qe<=90;qe++)Fi[qe]=String.fromCharCode(qe+32),Sl[qe]=String.fromCharCode(qe);for(var Ph in Fi)Sl.hasOwnProperty(Ph)||(Sl[Ph]=Fi[Ph]);function uR(t){var e=lR&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||aR&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sl:Fi)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let lt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Ed=typeof document<"u"?document:{documentElement:{style:{}}};const Nd=/Edge\/(\d+)/.exec(lt.userAgent),DS=/MSIE \d/.test(lt.userAgent),_d=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(lt.userAgent),Pc=!!(DS||_d||Nd),ly=!Pc&&/gecko\/(\d+)/i.test(lt.userAgent),Rh=!Pc&&/Chrome\/(\d+)/.exec(lt.userAgent),ay="webkitFontSmoothing"in Ed.documentElement.style,Ad=!Pc&&/Apple Computer/.test(lt.vendor),uy=Ad&&(/Mobile\/\w+/.test(lt.userAgent)||lt.maxTouchPoints>2);var q={mac:uy||/Mac/.test(lt.platform),windows:/Win/.test(lt.platform),linux:/Linux|X11/.test(lt.platform),ie:Pc,ie_version:DS?Ed.documentMode||6:_d?+_d[1]:Nd?+Nd[1]:0,gecko:ly,gecko_version:ly?+(/Firefox\/(\d+)/.exec(lt.userAgent)||[0,0])[1]:0,chrome:!!Rh,chrome_version:Rh?+Rh[1]:0,ios:uy,android:/Android\b/.test(lt.userAgent),webkit:ay,webkit_version:ay?+(/\bAppleWebKit\/(\d+)/.exec(lt.userAgent)||[0,0])[1]:0,safari:Ad,safari_version:Ad?+(/\bVersion\/(\d+(\.\d+)?)/.exec(lt.userAgent)||[0,0])[1]:0,tabSize:Ed.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function vm(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ju=Object.create(null);function wm(t,e,n){if(t==e)return!0;t||(t=ju),e||(e=ju);let i=Object.keys(t),r=Object.keys(e);if(i.length-0!=r.length-0)return!1;for(let s of i)if(s!=n&&(r.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function cR(t,e){for(let n=t.attributes.length-1;n>=0;n--){let i=t.attributes[n].name;e[i]==null&&t.removeAttribute(i)}for(let n in e){let i=e[n];n=="style"?t.style.cssText=i:t.getAttribute(n)!=i&&t.setAttribute(n,i)}}function cy(t,e,n){let i=!1;if(e)for(let r in e)n&&r in n||(i=!0,r=="style"?t.style.cssText="":t.removeAttribute(r));if(n)for(let r in n)e&&e[r]==n[r]||(i=!0,r=="style"?t.style.cssText=n[r]:t.setAttribute(r,n[r]));return i}function hR(t){let e=Object.create(null);for(let n=0;n<t.attributes.length;n++){let i=t.attributes[n];e[i.name]=i.value}return e}class zl{eq(e){return!1}updateDOM(e,n,i){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,n,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var qt=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(qt||(qt={}));class Me extends $i{constructor(e,n,i,r){super(),this.startSide=e,this.endSide=n,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new $l(e)}static widget(e){let n=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return n+=i&&!e.inlineOrder?n>0?3e8:-4e8:n>0?1e8:-1e8,new _r(e,n,n,i,e.widget||null,!1)}static replace(e){let n=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=BS(e,n);i=(s?n?-3e8:-1:5e8)-1,r=(o?n?2e8:1:-6e8)+1}return new _r(e,i,r,n,e.widget||null,!0)}static line(e){return new jl(e)}static set(e,n=!1){return ue.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Me.none=ue.empty;class $l extends Me{constructor(e){let{start:n,end:i}=BS(e);super(n?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?vm(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ju}eq(e){return this==e||e instanceof $l&&this.tagName==e.tagName&&wm(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}$l.prototype.point=!1;class jl extends Me{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof jl&&this.spec.class==e.spec.class&&wm(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}jl.prototype.mapMode=At.TrackBefore;jl.prototype.point=!0;class _r extends Me{constructor(e,n,i,r,s,o){super(n,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?n<=0?At.TrackBefore:At.TrackAfter:At.TrackDel}get type(){return this.startSide!=this.endSide?qt.WidgetRange:this.startSide<=0?qt.WidgetBefore:qt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof _r&&fR(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}_r.prototype.point=!0;function BS(t,e=!1){let{inclusiveStart:n,inclusiveEnd:i}=t;return n==null&&(n=t.inclusive),i==null&&(i=t.inclusive),{start:n??e,end:i??e}}function fR(t,e){return t==e||!!(t&&e&&t.compare(e))}function xs(t,e,n,i=0){let r=n.length-1;r>=0&&n[r]+i>=t?n[r]=Math.max(n[r],e):n.push(t,e)}class kl extends $i{constructor(e,n,i){super(),this.tagName=e,this.attributes=n,this.rank=i}eq(e){return e==this||e instanceof kl&&this.tagName==e.tagName&&wm(this.attributes,e.attributes)}static create(e){return new kl(e.tagName,e.attributes||ju,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return ue.of(e,n)}}kl.prototype.startSide=kl.prototype.endSide=-1;function bl(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Td(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Vo(t,e){if(!e.anchorNode)return!1;try{return Td(t,e.anchorNode)}catch{return!1}}function Za(t){return t.nodeType==3?Cl(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Ho(t,e,n,i){return n?hy(t,e,n,i,-1)||hy(t,e,n,i,1):!1}function Vi(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Fu(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function hy(t,e,n,i,r){for(;;){if(t==n&&e==i)return!0;if(e==(r<0?0:li(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=Vi(t)+(r<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(r<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=r<0?li(t):0}else return!1}}function li(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Vu(t,e){let{left:n,right:i}=t;if(n==i)return t;let r=e?n:i;return{left:r,right:r,top:t.top,bottom:t.bottom}}function dR(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function LS(t,e){let n=e.width/t.offsetWidth,i=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-t.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}function pR(t,e,n,i,r,s,o,l){let a=t.ownerDocument,u=a.defaultView||window;for(let c=t,h=!1;c&&!h;)if(c.nodeType==1){let f,d=c==a.body,p=1,g=1;if(d)f=dR(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(h=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let y=c.getBoundingClientRect();({scaleX:p,scaleY:g}=LS(c,y)),f={left:y.left,right:y.left+c.clientWidth*p,top:y.top,bottom:y.top+c.clientHeight*g}}let S=0,m=0;if(r=="nearest")e.top<f.top+o?(m=e.top-(f.top+o),n>0&&e.bottom>f.bottom+m&&(m=e.bottom-f.bottom+o)):e.bottom>f.bottom-o&&(m=e.bottom-f.bottom+o,n<0&&e.top-m<f.top&&(m=e.top-(f.top+o)));else{let y=e.bottom-e.top,v=f.bottom-f.top;m=(r=="center"&&y<=v?e.top+y/2-v/2:r=="start"||r=="center"&&n<0?e.top-o:e.bottom-v+o)-f.top}if(i=="nearest"?e.left<f.left+s?(S=e.left-(f.left+s),n>0&&e.right>f.right+S&&(S=e.right-f.right+s)):e.right>f.right-s&&(S=e.right-f.right+s,n<0&&e.left<f.left+S&&(S=e.left-(f.left+s))):S=(i=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:i=="start"==l?e.left-s:e.right-(f.right-f.left)+s)-f.left,S||m)if(d)u.scrollBy(S,m);else{let y=0,v=0;if(m){let x=c.scrollTop;c.scrollTop+=m/g,v=(c.scrollTop-x)*g}if(S){let x=c.scrollLeft;c.scrollLeft+=S/p,y=(c.scrollLeft-x)*p}e={left:e.left-y,top:e.top-v,right:e.right-y,bottom:e.bottom-v},y&&Math.abs(y-S)<1&&(i="nearest"),v&&Math.abs(v-m)<1&&(r="nearest")}if(d)break;(e.top<f.top||e.bottom>f.bottom||e.left<f.left||e.right>f.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function zS(t,e=!0){let n=t.ownerDocument,i=null,r=null;for(let s=t.parentNode;s&&!(s==n.body||(!e||i)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),e&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:r}}class mR{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:n,focusNode:i}=e;this.set(n,Math.min(e.anchorOffset,n?li(n):0),i,Math.min(e.focusOffset,i?li(i):0))}set(e,n,i,r){this.anchorNode=e,this.anchorOffset=n,this.focusNode=i,this.focusOffset=r}}function $S(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function jS(t,e=!0){for(let{node:n,left:i,top:r}of t)e&&n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}let or=null;q.safari&&q.safari_version>=26&&(or=!1);function FS(t){if(t.setActive)return t.setActive();if(or)return t.focus(or);let e=$S(t);t.focus(or==null?{get preventScroll(){return or={preventScroll:!0},!0}}:void 0),or||(or=!1,jS(e))}let fy;function Cl(t,e,n=e){let i=fy||(fy=document.createRange());return i.setEnd(t,n),i.setStart(t,e),i}function Ss(t,e,n,i){let r={key:e,code:e,keyCode:n,which:n,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function gR(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function yR(t,e){let n=e.focusNode,i=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=i)return!1;for(i=Math.min(i,li(n));;)if(i){if(n.nodeType!=1)return!1;let r=n.childNodes[i-1];r.contentEditable=="false"?i--:(n=r,i=li(n))}else{if(n==t)return!0;i=Vi(n),n=n.parentNode}}function VS(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function HS(t,e){for(let n=t,i=e;;){if(n.nodeType==3&&i>0)return{node:n,offset:i};if(n.nodeType==1&&i>0){if(n.contentEditable=="false")return null;n=n.childNodes[i-1],i=li(n)}else if(n.parentNode&&!Fu(n))i=Vi(n),n=n.parentNode;else return null}}function WS(t,e){for(let n=t,i=e;;){if(n.nodeType==3&&i<n.nodeValue.length)return{node:n,offset:i};if(n.nodeType==1&&i<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[i],i=0}else if(n.parentNode&&!Fu(n))i=Vi(n)+1,n=n.parentNode;else return null}}class cn{constructor(e,n,i=!0){this.node=e,this.offset=n,this.precise=i}static before(e,n){return new cn(e.parentNode,Vi(e),n)}static after(e,n){return new cn(e.parentNode,Vi(e)+1,n)}}var Te=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Te||(Te={}));const Ar=Te.LTR,xm=Te.RTL;function US(t){let e=[];for(let n=0;n<t.length;n++)e.push(1<<+t[n]);return e}const vR=US("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),wR=US("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Md=Object.create(null),Cn=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),n=t.charCodeAt(1);Md[e]=n,Md[n]=-e}function KS(t){return t<=247?vR[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?wR[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const xR=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Rn{get dir(){return this.level%2?xm:Ar}constructor(e,n,i){this.from=e,this.to=n,this.level=i}side(e,n){return this.dir==n==e?this.to:this.from}forward(e,n){return e==(this.dir==n)}static find(e,n,i,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=n&&l.to>=n){if(l.level==i)return o;(s<0||(r!=0?r<0?l.from<n:l.to>n:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function qS(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++){let i=t[n],r=e[n];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!qS(i.inner,r.inner))return!1}return!0}const fe=[];function SR(t,e,n,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:n,a=s?256:r;for(let u=o,c=a,h=a;u<l;u++){let f=KS(t.charCodeAt(u));f==512?f=c:f==8&&h==4&&(f=16),fe[u]=f==4?2:f,f&7&&(h=f),c=f}for(let u=o,c=a,h=a;u<l;u++){let f=fe[u];if(f==128)u<l-1&&c==fe[u+1]&&c&24?f=fe[u]=c:fe[u]=256;else if(f==64){let d=u+1;for(;d<l&&fe[d]==64;)d++;let p=u&&c==8||d<n&&fe[d]==8?h==1?1:8:256;for(let g=u;g<d;g++)fe[g]=p;u=d-1}else f==8&&h==1&&(fe[u]=1);c=f,f&7&&(h=f)}}}function kR(t,e,n,i,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let u=o?i[o-1].to:e,c=o<i.length?i[o].from:n;for(let h=u,f,d,p;h<c;h++)if(d=Md[f=t.charCodeAt(h)])if(d<0){for(let g=l-3;g>=0;g-=3)if(Cn[g+1]==-d){let S=Cn[g+2],m=S&2?r:S&4?S&1?s:r:0;m&&(fe[h]=fe[Cn[g]]=m),l=g;break}}else{if(Cn.length==189)break;Cn[l++]=h,Cn[l++]=f,Cn[l++]=a}else if((p=fe[h])==2||p==1){let g=p==r;a=g?0:1;for(let S=l-3;S>=0;S-=3){let m=Cn[S+2];if(m&2)break;if(g)Cn[S+2]|=2;else{if(m&4)break;Cn[S+2]|=4}}}}}function bR(t,e,n,i){for(let r=0,s=i;r<=n.length;r++){let o=r?n[r-1].to:t,l=r<n.length?n[r].from:e;for(let a=o;a<l;){let u=fe[a];if(u==256){let c=a+1;for(;;)if(c==l){if(r==n.length)break;c=n[r++].to,l=r<n.length?n[r].from:e}else if(fe[c]==256)c++;else break;let h=s==1,f=(c<e?fe[c]:i)==1,d=h==f?h?1:2:i;for(let p=c,g=r,S=g?n[g-1].to:t;p>a;)p==S&&(p=n[--g].from,S=g?n[g-1].to:t),fe[--p]=d;a=c}else s=u,a++}}}function Od(t,e,n,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,u=0;a<n;){let c=!0,h=!1;if(u==s.length||a<s[u].from){let g=fe[a];g!=l&&(c=!1,h=g==16)}let f=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(u<s.length&&p==s[u].from){if(h)break e;let g=s[u];if(!c)for(let S=g.to,m=u+1;;){if(S==n)break e;if(m<s.length&&s[m].from==S)S=s[m++].to;else{if(fe[S]==l)break e;break}}if(u++,f)f.push(g);else{g.from>a&&o.push(new Rn(a,g.from,d));let S=g.direction==Ar!=!(d%2);Pd(t,S?i+1:i,r,g.inner,g.from,g.to,o),a=g.to}p=g.to}else{if(p==n||(c?fe[p]!=l:fe[p]==l))break;p++}f?Od(t,a,p,i+1,r,f,o):a<p&&o.push(new Rn(a,p,d)),a=p}else for(let a=n,u=s.length;a>e;){let c=!0,h=!1;if(!u||a>s[u-1].to){let g=fe[a-1];g!=l&&(c=!1,h=g==16)}let f=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(u&&p==s[u-1].to){if(h)break e;let g=s[--u];if(!c)for(let S=g.from,m=u;;){if(S==e)break e;if(m&&s[m-1].to==S)S=s[--m].from;else{if(fe[S-1]==l)break e;break}}if(f)f.push(g);else{g.to<a&&o.push(new Rn(g.to,a,d));let S=g.direction==Ar!=!(d%2);Pd(t,S?i+1:i,r,g.inner,g.from,g.to,o),a=g.from}p=g.from}else{if(p==e||(c?fe[p-1]!=l:fe[p-1]==l))break;p--}f?Od(t,p,a,i+1,r,f,o):p<a&&o.push(new Rn(p,a,d)),a=p}}function Pd(t,e,n,i,r,s,o){let l=e%2?2:1;SR(t,r,s,i,l),kR(t,r,s,i,l),bR(r,s,i,l),Od(t,r,s,e,n,i,o)}function CR(t,e,n){if(!t)return[new Rn(0,0,e==xm?1:0)];if(e==Ar&&!n.length&&!xR.test(t))return YS(t.length);if(n.length)for(;t.length>fe.length;)fe[fe.length]=256;let i=[],r=e==Ar?0:1;return Pd(t,r,r,n,0,t.length,i),i}function YS(t){return[new Rn(0,t,0)]}let QS="";function ER(t,e,n,i,r){var s;let o=i.head-t.from,l=Rn.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),a=e[l],u=a.side(r,n);if(o==u){let f=l+=r?1:-1;if(f<0||f>=e.length)return null;a=e[l=f],o=a.side(!r,n),u=a.side(r,n)}let c=nt(t.text,o,a.forward(r,n));(c<a.from||c>a.to)&&(c=u),QS=t.text.slice(Math.min(o,c),Math.max(o,c));let h=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return h&&c==u&&h.level+(r?0:1)<a.level?V.cursor(h.side(!r,n)+t.from,h.forward(r,n)?1:-1,h.level):V.cursor(c+t.from,a.forward(r,n)?-1:1,a.level)}function NR(t,e,n){for(let i=e;i<n;i++){let r=KS(t.charCodeAt(i));if(r==1)return Ar;if(r==2||r==4)return xm}return Ar}const XS=ee.define(),GS=ee.define(),JS=ee.define(),ZS=ee.define(),Rd=ee.define(),ek=ee.define(),tk=ee.define(),Sm=ee.define(),km=ee.define(),nk=ee.define({combine:t=>t.some(e=>e)}),_R=ee.define({combine:t=>t.some(e=>e)}),ik=ee.define();class ks{constructor(e,n,i,r,s,o=!1){this.range=e,this.y=n,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new ks(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ks(V.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const va=me.define({map:(t,e)=>t.map(e)}),rk=me.define();function Mt(t,e,n){let i=t.facet(ZS);i.length?i[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const Yn=ee.define({combine:t=>t.length?t[0]:!0});let AR=0;const rs=ee.define({combine(t){return t.filter((e,n)=>{for(let i=0;i<n;i++)if(t[i].plugin==e.plugin)return!1;return!0})}});class $n{constructor(e,n,i,r,s){this.id=e,this.create=n,this.domEventHandlers=i,this.domEventObservers=r,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(rs.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(rs.of({plugin:this,arg:e}))}static define(e,n){const{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=n||{};return new $n(AR++,e,i,r,l=>{let a=[];return o&&a.push(Rc.of(u=>{let c=u.plugin(l);return c?o(c):Me.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return $n.define((i,r)=>new e(i,r),n)}}class Ih{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 n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(i){if(Mt(n.state,i,"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(n){Mt(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(i){Mt(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const sk=ee.define(),bm=ee.define(),Rc=ee.define(),ok=ee.define(),Cm=ee.define(),Fl=ee.define(),lk=ee.define();function dy(t,e){let n=t.state.facet(lk);if(!n.length)return n;let i=n.map(s=>s instanceof Function?s(t):s),r=[];return ue.spans(i,e.from,e.to,{point(){},span(s,o,l,a){let u=s-e.from,c=o-e.from,h=r;for(let f=l.length-1;f>=0;f--,a--){let d=l[f].spec.bidiIsolate,p;if(d==null&&(d=NR(e.text,u,c)),a>0&&h.length&&(p=h[h.length-1]).to==u&&p.direction==d)p.to=c,h=p.inner;else{let g={from:u,to:c,direction:d,inner:[]};h.push(g),h=g.inner}}}}),r}const ak=ee.define();function Em(t){let e=0,n=0,i=0,r=0;for(let s of t.state.facet(ak)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:n,top:i,bottom:r}}const To=ee.define();class Ht{constructor(e,n,i,r){this.fromA=e,this.toA=n,this.fromB=i,this.toB=r}join(e){return new Ht(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,i=this;for(;n>0;n--){let r=e[n-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(n-1,1)}}return e.splice(n,0,i),e}static extendWithRanges(e,n){if(n.length==0)return e;let i=[];for(let r=0,s=0,o=0;;){let l=r<e.length?e[r].fromB:1e9,a=s<n.length?n[s]:1e9,u=Math.min(l,a);if(u==1e9)break;let c=u+o,h=u,f=c;for(;;)if(s<n.length&&n[s]<=h){let d=n[s+1];s+=2,h=Math.max(h,d);for(let p=r;p<e.length&&e[p].fromB<=h;p++)o=e[p].toA-e[p].toB;f=Math.max(f,d+o)}else if(r<e.length&&e[r].fromB<=h){let d=e[r++];h=Math.max(h,d.toB),f=Math.max(f,d.toA),o=d.toA-d.toB}else break;i.push(new Ht(c,f,u,h))}return i}}class Hu{constructor(e,n,i){this.view=e,this.state=n,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=ze.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new Ht(s,o,l,a))),this.changedRanges=r}static create(e,n,i){return new Hu(e,n,i)}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(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const TR=[];class Oe{constructor(e,n,i=0){this.dom=e,this.length=n,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return TR}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 n=this.domAttrs;n&&cR(this.dom,n)}}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,n=this.posAtStart){let i=n;for(let r of this.children){if(r==e)return i;i+=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,n,i){return null}domPosFor(e,n){let i=Vi(this.dom),r=this.length?e>0:n>0;return new cn(this.parent.dom,i+(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 Dc)return e;return null}static get(e){return e.cmTile}}class Ic 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 n=this.dom,i=null,r,s=(e==null?void 0:e.node)==n?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,r=i?i.nextSibling:n.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==n)for(;r&&r!=l.dom;)r=py(r);else n.insertBefore(l.dom,r);i=l.dom}for(r=i?i.nextSibling:n.firstChild,s&&r&&(s.written=!0);r;)r=py(r);this.length=o}}function py(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Dc extends Ic{constructor(e,n){super(n),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 n=Oe.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!n.length)return;i=i.parent,i.breakAfter&&s++,r=n.pop()}else{let o=i.children[r++];if(o instanceof ei)n.push(r),i=o,r=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,n){let i,r=-1,s,o=-1;if(this.blockTiles((l,a)=>{let u=a+l.length;if(e>=a&&e<=u){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<e||e==u&&(n<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,r=e-a),(u>e||e==a&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&n<0||!s?{tile:i,offset:r}:{tile:s,offset:o}}}class ei extends Ic{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let i=new ei(n||document.createElement(e.tagName),e);return n||(i.flags|=4),i}}class $s extends Ic{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,i){let r=new $s(n||document.createElement("div"),e);return(!n||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,n,i){let r=null,s=-1,o=null,l=-1;function a(c,h){for(let f=0,d=0;f<c.children.length&&d<=h;f++){let p=c.children[f],g=d+p.length;g>=h&&(p.isComposite()?a(p,h-d):(!o||o.isHidden&&(n>0&&!(o.flags&32)||i&&OR(o,p)))&&(g>h||p.flags&32&&n<=1)?(o=p,l=h-d):(d<h||p.flags&16&&!p.isHidden&&n>=-1)&&(r=p,s=h-d)),d=g}}a(this,e);let u=(n<0?r:o)||r||o;return u?{tile:u,offset:u==r?s:l}:null}coordsIn(e,n,i){let r=this.resolveInline(e,n,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),n,i):MR(this)}domIn(e,n){let i=this.resolveInline(e,n);if(i){let{tile:r,offset:s}=i;if(this.dom.contains(r.dom))return r.isText()?new cn(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:n);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new cn(a.dom,0);a==i.tile&&(l=!0)}}return new cn(this.dom,0)}}function MR(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=Za(e);return n[n.length-1]||null}function OR(t,e){let n=t.coordsIn(0,1),i=e.coordsIn(0,1);return n&&i&&i.top<n.bottom}class gt extends Ic{constructor(e,n){super(e),this.mark=n}get domAttrs(){return this.mark.attrs}static of(e,n){let i=new gt(n||document.createElement(e.tagName),e);return n||(i.flags|=4),i}}class dr extends Oe{constructor(e,n){super(e,n.length),this.text=n}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,n,i){let r=this.dom.nodeValue.length;e>r&&(e=r);let s=e,o=e,l=0;e==0&&n<0||e==r&&n>=0?q.chrome||q.gecko||(e?(s--,l=1):o<r&&(o++,l=-1)):n<0?s--:o<r&&o++;let a=Cl(this.dom,s,o).getClientRects();if(!a.length)return null;let u=a[(l?l<0:n>=0)?0:a.length-1];return q.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(a,c=>c.width)||u),i==null?u:Vu(u,(l?l>0:n<0)==i)}static of(e,n){let i=new dr(n||document.createTextNode(e),e);return n||(i.flags|=2),i}}class Tr extends Oe{constructor(e,n,i,r){super(e,n,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,i){let r=this.widget.coordsAt(this.dom,e,n);if(r)return r;if(i)return Vu(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top<o.bottom);a+=l?-1:1);return Vu(o,!l)}}get overrideDOMText(){if(!this.length)return oe.empty;let{root:e}=this;if(!e)return oe.empty;let n=this.posAtStart;return e.view.state.doc.slice(n,n+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,n,i,r,s){return s||(s=e.toDOM(n),e.editable||(s.contentEditable="false")),new Tr(s,i,e,r)}}class Wu extends Oe{constructor(e){let n=document.createElement("img");n.className="cm-widgetBuffer",n.setAttribute("aria-hidden","true"),super(n,0,e)}get isHidden(){return!0}get overrideDOMText(){return oe.empty}coordsIn(e,n,i){let r=this.dom.getBoundingClientRect();return i==null?r:Vu(r,n>0==i)}}class PR{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,i){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(r.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!l.length)break;i&&i.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let a=r.children[s],u=a.breakAfter;(n>0?a.length<=e:a.length<e)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!u,s++,e-=a.length):(l.push({tile:r,index:s}),r=a,s=0,i&&a.isComposite()&&i.enter(a))}else{let a=r.length;if(s<a&&e){let u=Math.min(e,a-s);i&&i.skip(r,s,s+u),e-=u,s+=u}if(s==a)o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++;else if(!e)break}return this.tile=r,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class RR{constructor(e,n,i,r){this.from=e,this.to=n,this.wrapper=i,this.rank=r}}class IR{constructor(e,n,i){this.cache=e,this.root=n,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,n,i,r){var s;this.flushBuffer();let o=this.ensureMarks(n,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new dr(l.dom,l.text+e);a.parent=o}else o.append(r||dr.of(e,(s=this.cache.find(dr))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,n){let i=this.curLine;i.dom!=n.line.dom&&(i.setDOM(this.cache.reused.has(n.line)?Dh(n.line.dom):n.line.dom),this.cache.reused.set(n.line,2));let r=i;for(let l=n.marks.length-1;l>=0;l--){let a=n.marks[l],u=r.lastChild;if(u instanceof gt&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(Dh(a.dom)),r=u;else{if(this.cache.reused.get(a)){let h=Oe.get(a.dom);h&&h.setDOM(Dh(a.dom))}let c=gt.of(a.mark,a.dom);r.append(c),r=c}this.cache.reused.set(a,2)}let s=Oe.get(e.text);s&&this.cache.reused.set(s,2);let o=new dr(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,r.append(o)}addInlineWidget(e,n,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(n,i);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,i){this.flushBuffer(),this.ensureMarks(n,i).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var i;e||(e=uk);let r=$s.start(e,n||((i=this.cache.find($s))===null||i===void 0?void 0:i.dom),!!n);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,n){var i;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=r.lastChild)&&l instanceof gt&&l.mark.eq(o))r=l,n--;else{let a=gt.of(o,(i=this.cache.find(gt,u=>u.mark.eq(o)))===null||i===void 0?void 0:i.dom);r.append(a),r=a,n=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!my(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(q.ios&&my(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Bh,0,32)||new Tr(Bh.toDOM(),0,Bh,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 n=e.rank*102+e.value.rank,i=new RR(e.from,e.to,e.value,n),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let i of this.wrappers){let r=n.lastChild;if(i.from<this.pos&&r instanceof ei&&r.wrapper.eq(i.wrapper))n=r;else{let s=ei.of(i.wrapper,(e=this.cache.find(ei,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);n.append(s),n=s}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),i=this.cache.find(Wu,void 0,1);return i&&(i.flags=n),i||new Wu(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class DR{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,l)}let n=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,n);return this.textOff=n,i}}const Uu=[Tr,$s,dr,gt,Wu,ei,Dc];for(let t=0;t<Uu.length;t++)Uu[t].bucket=t;class BR{constructor(e){this.view=e,this.buckets=Uu.map(()=>[]),this.index=Uu.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,i=this.buckets[n];i.length<6?i.push(e):i[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,i=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let l=0;l<s.length;l++){let a=(l+o)%s.length,u=s[a];if((!n||n(u))&&!this.reused.has(u))return s.splice(a,1),a<o&&this.index[r]--,this.reused.set(u,i),u}return null}findWidget(e,n,i){let r=this.buckets[0];if(r.length)for(let s=0,o=0;;s++){if(s==r.length){if(o)return null;o=1,s=0}let l=r[s];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return r.splice(s,1),s<this.index[0]&&this.index[0]--,l.widget==e&&l.length==n&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new Tr(l.dom,n,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,n=2){if(!this.reused.has(e))return this.reused.set(e,n),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class LR{constructor(e,n,i,r,s){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new BR(e),this.text=new DR(e.state.doc),this.builder=new IR(this.cache,new Dc(e,e.contentDOM),ue.iter(i)),this.cache.reused.set(n,2),this.old=new PR(n),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let i=n&&this.getCompositionContext(n.text);for(let r=0,s=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>r){let u=a-r;this.preserve(u,!o,!l),r=a,s+=u}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA<n.range.toA?1:-1),this.emit(s,n.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(n,i),this.text.skip(n.range.toB-n.range.fromB),this.forward(n.range.fromA,l.toA),this.emit(n.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(s,l.toB)),s=l.toB,r=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,n,i){let r=jR(this.old),s=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let u=a>0||l<o.length?Tr.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);u.flags&256?(u.flags&=-2,this.builder.addBlockWidget(u)):(this.builder.ensureLine(null),this.builder.addInlineWidget(u,r,s),s=r.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,r,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),r,s)),s=r.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Wu)this.cache.add(o);else if(o instanceof gt)this.builder.ensureLine(null),this.builder.addMark(o,r,s),this.cache.reused.set(o,1),s=r.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof gt&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof gt&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let i=null,r=this.builder,s=-1,o=ue.spans(this.decorations,e,n,{point:(l,a,u,c,h,f)=>{if(u instanceof _r){if(this.disallowBlockEffectsFor[f]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,h>c.length)r.continueWidget(a-l);else{let d=u.widget||(u.block?js.block:js.inline),p=zR(u),g=this.cache.findWidget(d,a-l,p)||Tr.of(d,this.view,a-l,p);u.block?(u.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(g)):(r.ensureLine(i),r.addInlineWidget(g,c,h))}i=null}else i=$R(i,u);a>l&&this.text.skip(a-l)},span:(l,a,u,c)=>{for(let h=l;h<a;){let f=this.text.next(Math.min(512,a-h));f==null?(r.addLineStartIfNotCovered(i),r.addBreak(),h++):(r.ensureLine(i),r.addText(f,u,h==l?c:u.length),h+=f.length),i=null}s=u.length}});s>-1&&(this.openWidget=o>s),this.openWidget||r.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,n,i=1){n-e<=10?this.old.advance(n-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let n=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let s=Oe.get(r);if(r==this.view.contentDOM)break;s instanceof gt?n.push(s):s!=null&&s.isLine()?i=s:s instanceof ei||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new $s(r,uk):i||n.push(gt.of(new $l({tagName:r.nodeName.toLowerCase(),attributes:hR(r)}),r)))}return{line:i,marks:n}}}function my(t,e){let n=i=>{for(let r of i.children)if((e?r.isText():r.length)||n(r))return!0;return!1};return n(t)}function zR(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const uk={class:"cm-line"};function $R(t,e){let n=e.spec.attributes,i=e.spec.class;return!n&&!i||(t||(t={class:"cm-line"}),n&&vm(n,t),i&&(t.class+=" "+i)),t}function jR(t){let e=[];for(let n=t.parents.length;n>1;n--){let i=n==t.parents.length?t.tile:t.parents[n].tile;i instanceof gt&&e.push(i.mark)}return e}function Dh(t){let e=Oe.get(t);return e&&e.setDOM(t.cloneNode()),t}class js extends zl{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}}js.inline=new js("span");js.block=new js("div");const Bh=new class extends zl{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class gy{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Me.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Dc(e,e.contentDOM),this.updateInner([new Ht(0,0,0,e.state.doc.length)],null)}update(e){var n;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:c,toA:h})=>h<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&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?r=this.domChanged.newSel.head:!QR(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?VR(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:h}=this.hasComposition;i=new Ht(c,h,e.changes.mapPos(c,-1),e.changes.mapPos(h,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(q.ie||q.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=UR(o,this.decorations,e.changes);a.length&&(i=Ht.extendWithRanges(i,a));let u=qR(l,this.blockWrappers,e.changes);return u.length&&(i=Ht.extendWithRanges(i,u)),s&&!i.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(n||e.length){let o=this.tile,l=new LR(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Oe.get(n.text)&&l.cache.reused.set(Oe.get(n.text),2),this.tile=l.run(e,n),Id(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=q.chrome||q.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof Lh&&r.push(s.dom);i.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let n of e.transactions)for(let i of n.effects)i.is(rk)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,n=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,r=this.view.root.activeElement,s=r==i,o=!s&&!(this.view.state.facet(Yn)||i.tabIndex>-1)&&Vo(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||n||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,u,c;if(a.empty?c=u=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),u=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),q.gecko&&a.empty&&!this.hasComposition&&FR(u)){let f=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(f,u.node.childNodes[u.offset]||null)),u=c=new cn(f,0),l=!0}let h=this.view.observer.selectionRange;(l||!h.focusNode||(!Ho(u.node,u.offset,h.anchorNode,h.anchorOffset)||!Ho(c.node,c.offset,h.focusNode,h.focusOffset))&&!this.suppressWidgetCursorChange(h,a))&&(this.view.observer.ignore(()=>{q.android&&q.chrome&&i.contains(h.focusNode)&&YR(h.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let f=bl(this.view.root);if(f)if(a.empty){if(q.gecko){let d=HR(u.node,u.offset);if(d&&d!=3){let p=(d==1?HS:WS)(u.node,u.offset);p&&(u=new cn(p.node,p.offset))}}f.collapse(u.node,u.offset),a.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=a.bidiLevel)}else if(f.extend){f.collapse(u.node,u.offset);try{f.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([u,c]=[c,u]),d.setEnd(c.node,c.offset),d.setStart(u.node,u.offset),f.removeAllRanges(),f.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(u,c)),this.impreciseAnchor=u.precise?null:new cn(h.anchorNode,h.anchorOffset),this.impreciseHead=c.precise?null:new cn(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&Ho(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,i=bl(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!n.empty||!n.assoc||!i.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let a=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(n.head+n.assoc,n.assoc);i.collapse(c.node,c.offset),i.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=n.from&&i.collapse(r,s)}posFromDOM(e,n){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[n];else{let o=li(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!Oe.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let o=0,l=r;;o++){let a=i.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?r+n:r+(n?i.length:0):r}domAtPos(e,n){let{tile:i,offset:r}=this.tile.resolveBlock(e,n);return i.isWidget()?i.domPosFor(r,n):i.domIn(r,n)}inlineDOMNearPos(e,n){let i,r=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((u,c)=>{if(u.isWidget()){if(u.flags&32&&c>=e)return!0;u.flags&16&&(s=!0)}else{let h=c+u.length;if(c<=e&&(i=u,r=e-c,s=h<e),h>=e&&!o&&(o=u,l=e-c,a=c>e),c>e&&o)return!0}}),!i&&!o?this.domAtPos(e,n):(s&&o?i=null:a&&i&&(o=null),i&&n<0||!o?i.domIn(r,n):o.domIn(l,n))}coordsAt(e,n,i){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.widget instanceof Lh?null:r.coordsInWidget(s,n,!0):r.coordsIn(s,n,i)}lineAt(e,n){let{tile:i}=this.tile.resolveBlock(e,n);return i.isLine()?i:null}coordsForChar(e){let{tile:n,offset:i}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=r(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&o<s.length){let l=nt(s.text,o);if(l==o)return null;let a=Cl(s.dom,o,l).getClientRects();for(let u=0;u<a.length;u++){let c=a[u];if(u==a.length-1||c.top<c.bottom&&c.left<c.right)return c}}return null}return r(n,i)}measureVisibleLineHeights(e){let n=[],{from:i,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==Te.LTR,u=0,c=(h,f,d)=>{for(let p=0;p<h.children.length&&!(f>r);p++){let g=h.children[p],S=f+g.length,m=g.dom.getBoundingClientRect(),{height:y}=m;if(d&&!p&&(u+=m.top-d.top),g instanceof ei)S>i&&c(g,f,m);else if(f>=i&&(u>0&&n.push(-u),n.push(y+u),u=0,o)){let v=g.dom.lastChild,x=v?Za(v):[];if(x.length){let b=x[x.length-1],C=a?b.right-m.left:m.right-b.left;C>l&&(l=C,this.minWidth=s,this.minWidthFrom=f,this.minWidthTo=S)}}d&&p==h.children.length-1&&(u+=d.bottom-m.bottom),f=S+g.breakAfter}};return c(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Te.RTL:Te.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let u of o.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let c=Za(u.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let n=document.createElement("div"),i,r,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let o=Za(n.firstChild)[0];i=n.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,n.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let i=0,r=0;;r++){let s=r==n.viewports.length?null:n.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>i){let l=(n.lineBlockAt(o).bottom-n.lineBlockAt(i).top)/this.view.scaleY;e.push(Me.replace({widget:new Lh(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return Me.set(e)}updateDeco(){let e=1,n=this.view.state.facet(Rc).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(Cm).map((s,o)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=i,n.push(ue.join(r))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(ok).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(ik))try{if(u(this.view,e.range,e))return!0}catch(c){Mt(this.view.state,c,"scroll handler")}let{range:n}=e,i=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),r;if(!i)return;!n.empty&&(r=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=Em(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(pR(this.view.scrollDOM,o,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==Te.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.visualViewport.offsetTop)){let u=this.view.docView.lineAt(n.head,1);if(u){let c=$S(u.dom);u.dom.scrollIntoView({block:"nearest"}),jS(c,!1)}}}lineHasWidget(e){let n=i=>i.isWidget()||i.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){Id(this.tile)}}function Id(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let i of t.children)Id(i,e)}}function FR(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function ck(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let i=HS(n.focusNode,n.focusOffset),r=WS(n.focusNode,n.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let l=Oe.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(t.docView.lastCompositionAfterCursor){let a=Oe.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(s=r)}}if(t.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function VR(t,e,n){let i=ck(t,n);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new Ht(a.mapPos(s),a.mapPos(o),s,o),text:r}}function HR(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e<t.childNodes.length&&t.childNodes[e].contentEditable=="false"?2:0)}let WR=class{constructor(){this.changes=[]}compareRange(e,n){xs(e,n,this.changes)}comparePoint(e,n){xs(e,n,this.changes)}boundChange(e){xs(e,e,this.changes)}};function UR(t,e,n){let i=new WR;return ue.compare(t,e,n,i),i.changes}class KR{constructor(){this.changes=[]}compareRange(e,n){xs(e,n,this.changes)}comparePoint(){}boundChange(e){xs(e,e,this.changes)}}function qR(t,e,n){let i=new KR;return ue.compare(t,e,n,i),i.changes}function YR(t,e){for(let n=t;n&&n!=e;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable=="false")return!0;return!1}function QR(t,e){let n=!1;return e&&t.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(n=!0)}),n}class Lh extends zl{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 XR(t,e,n=1){let i=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(r.length==0)return V.cursor(e);s==0?n=1:s==r.length&&(n=-1);let o=s,l=s;n<0?o=nt(r.text,s,!1):l=nt(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let u=nt(r.text,o,!1);if(i(r.text.slice(u,o))!=a)break;o=u}for(;l<r.length;){let u=nt(r.text,l);if(i(r.text.slice(l,u))!=a)break;l=u}return V.undirectionalRange(o+r.from,l+r.from)}function GR(t,e,n,i,r){let s=Math.round((i-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&n.height>t.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((r-n.top-(t.defaultLineHeight-l)*.5)/l);s+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+sR(o,s,t.state.tabSize)}function JR(t,e,n){let i=t.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!r||s.type==qt.Text&&(r.type!=s.type||(n<0?s.from<e:s.to>e)))&&(r=s)}}return r||i}return i}function ZR(t,e,n,i){let r=JR(t,e.head,e.assoc||-1),s=!i||r.type!=qt.Text||!(t.lineWrapping||r.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(r.from),a=t.posAtCoords({x:n==(l==Te.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return V.cursor(a,n?-1:1)}return V.cursor(n?r.to:r.from,n?-1:1)}function yy(t,e,n,i){let r=t.state.doc.lineAt(e.head),s=t.bidiSpans(r),o=t.textDirectionAt(r.from);for(let l=e,a=null;;){let u=ER(r,s,o,l,n),c=QS;if(!u){if(r.number==(n?t.state.doc.lines:1))return l;c=`
63
+ `,r=t.state.doc.line(r.number+(n?1:-1)),s=t.bidiSpans(r),u=t.visualLineSide(r,!n)}if(a){if(!a(c))return l}else{if(!i)return u;a=i(c)}l=u}}function eI(t,e,n){let i=t.state.charCategorizer(e),r=i(n);return s=>{let o=i(s);return r==Jn.Space&&(r=o),r==o}}function tI(t,e,n,i){let r=e.head,s=n?1:-1;if(r==(n?t.state.doc.length:0))return V.cursor(r,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),u=t.coordsAtPos(r,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),c=t.documentTop;if(u)o==null&&(o=u.left-a.left),l=s<0?u.top:u.bottom;else{let p=t.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+c}let h=a.left+o,f=t.viewState.heightOracle.textHeight>>1,d=i??f;for(let p=0;;p+=f){let g=l+(d+p)*s,S=Dd(t,{x:h,y:g},!1,s);if(n?g>a.bottom:g<a.top)return V.cursor(S.pos,S.assoc);let m=t.coordsAtPos(S.pos,S.assoc),y=m?(m.top+m.bottom)/2:0;if(!m||(n?y>l:y<l))return V.cursor(S.pos,S.assoc,void 0,o)}}function Wo(t,e,n){for(;;){let i=0;for(let r of t)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=i||n||(e-s<o-e?-1:1);e=a<0?s:o,i=a}});if(!i)return e}}function hk(t,e){let n=null;for(let i=0;i<e.ranges.length;i++){let r=e.ranges[i],s=null;if(r.empty){let o=Wo(t,r.from,0);o!=r.from&&(s=V.cursor(o,-1))}else{let o=Wo(t,r.from,-1),l=Wo(t,r.to,1);(o!=r.from||l!=r.to)&&(r.undirectional?s=V.undirectionalRange(r.from,r.to):s=V.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(n||(n=e.ranges.slice()),n[i]=s)}return n?V.create(n,e.mainIndex):e}function zh(t,e,n){let i=Wo(t.state.facet(Fl).map(r=>r(t)),n.from,e.head>n.from?-1:1);return i==n.from?n:V.cursor(i,i<n.from?1:-1)}class Pn{constructor(e,n){this.pos=e,this.assoc=n}}function Dd(t,e,n,i){let r=t.contentDOM.getBoundingClientRect(),s=r.top+t.viewState.paddingTop,{x:o,y:l}=e,a=l-s,u;for(;;){if(a<0)return new Pn(0,1);if(a>t.viewState.docHeight)return new Pn(t.state.doc.length,-1);if(u=t.elementAtHeight(a),i==null)break;if(u.type==qt.Text){if(i<0?u.to<t.viewport.from:u.from>t.viewport.to)break;let f=t.docView.coordsAt(i<0?u.from:u.to,i>0?-1:1);if(f&&(i<0?f.top<=a+s:f.bottom>=a+s))break}let h=t.viewState.heightOracle.textHeight/2;a=i>0?u.bottom+h:u.top-h}if(t.viewport.from>=u.to||t.viewport.to<=u.from){if(n)return null;if(u.type==qt.Text){let h=GR(t,r,u,o,l);return new Pn(h,h==u.from?1:-1)}}if(u.type!=qt.Text)return a<(u.top+u.bottom)/2?new Pn(u.from,1):new Pn(u.to,-1);let c=t.docView.lineAt(u.from,2);return(!c||c.length!=u.length)&&(c=t.docView.lineAt(u.from,-2)),new nI(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class nI{constructor(e,n,i,r){this.view=e,this.x=n,this.y=i,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,n){let{line:i,spans:r}=this.bidiSpansAt(e);return r[Rn.find(r,e-i.from,-1,n)].level==this.baseDir}dirAt(e,n){let{line:i,spans:r}=this.bidiSpansAt(e);return r[Rn.find(r,e-i.from,-1,n)].dir}bidiIn(e,n){let{spans:i,line:r}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from<n)}scan(e,n,i=!1){let r=0,s=e.length-1,o=new Set,l=this.bidiIn(e[0],e[s]),a,u,c=-1,h=1e9,f;e:for(;r<s;){let p=s-r,g=r+s>>1;t:if(o.has(g)){for(let y=1;y<p;y++){let v=g+y;if(v>=s&&(v-=p),!o.has(v)){g=v;break t}}break e}o.add(g);let S=n(g),m=0;if(S)for(let y=0;y<S.length;y++){let v=S[y];if(!(v.width==0&&S.length>1))if(v.bottom<this.y)(!a||a.bottom<v.bottom)&&(a=v),m=1;else if(v.top>this.y)(!u||u.top>v.top)&&(u=v),m=-1;else{let x=v.left>this.x?this.x-v.left:v.right<this.x?this.x-v.right:0,b=Math.abs(x);b<h&&(c=g,h=b,f=v),x&&(m=x<0==(this.baseDir==Te.LTR)?-1:1)}}m==-1&&(!l||this.baseDirAt(e[g],1))?s=g:m==1&&(!l||this.baseDirAt(e[g+1],-1))&&(r=g+1)}if(!f){if(!u&&!a)return{i:e[0],after:!1};let p=a&&(!u||this.y-a.bottom<u.top-this.y)?a:u;return this.y=(p.top+p.bottom)/2,this.scan(e,n,!0)}if(h&&!i){let{top:p,bottom:g}=f;if(a&&a.bottom>(p+p+g)/3)return this.y=a.bottom-1,this.scan(e,n,!0);if(u&&u.top<(p+g+g)/3)return this.y=u.top+1,this.scan(e,n,!0)}let d=(l?this.dirAt(e[c],1):this.baseDir)==Te.LTR;return{i:c,after:this.x>(f.left+f.right)/2==d}}scanText(e,n){let i=[];for(let s=0;s<e.length;s=nt(e.text,s))i.push(n+s);i.push(n+e.length);let r=this.scan(i,s=>{let o=i[s]-n,l=i[s+1]-n;return Cl(e.dom,o,l).getClientRects()});return r.after?new Pn(i[r.i+1],-1):new Pn(i[r.i],1)}scanTile(e,n){if(!e.length)return new Pn(n,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let i=[n];for(let l=0,a=n;l<e.children.length;l++)i.push(a+=e.children[l].length);let r=this.scan(i,l=>{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Cl(a.dom,0,a.length)).getClientRects()}),s=e.children[r.i],o=i[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new Pn(i[r.i+1],-1):new Pn(o,1)}}const Wr="￿";class iI{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(ae.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Wr}readRange(e,n){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=Oe.get(r),l=r.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=Oe.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Fu(r))||Fu(l)&&(r.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!sI(l,n)&&this.lineBreak(),r=l}return this.findPointBefore(i,n),this}readTextNode(e){let n=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,n.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(n))&&(s=l.index,o=l[0].length),this.append(n.slice(i,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=s+o}}readNode(e){let n=Oe.get(e),i=n&&n.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.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,n){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==n&&(i.pos=this.text.length)}findPointInside(e,n){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(rI(e,i.node,i.offset)?n:0))}}function rI(t,e,n){for(;;){if(!e||n<li(e))return!1;if(e==t)return!0;n=Vi(e)+1,e=e.parentNode}}function sI(t,e){let n;for(;!(t==e||!t);t=t.nextSibling){let i=Oe.get(t);if(!(i!=null&&i.isWidget()))return!1;i&&(n||(n=[])).push(i)}if(n)for(let i of n){let r=i.overrideDOMText;if(r!=null&&r.length)return!1}return!0}class vy{constructor(e,n){this.node=e,this.offset=n,this.pos=-1}}class oI{constructor(e,n,i,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=n>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=fk(e.docView.tile,n,i,0))){let a=s||o?[]:aI(e),u=new iI(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=uI(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!Td(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!Td(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),h=e.viewport;if((q.ios||q.chrome)&&u!=c&&Math.min(u,c)<=l.main.from&&Math.max(u,c)>=l.main.to&&(h.from>0||h.to<e.state.doc.length)){let f=Math.min(u,c),d=Math.max(u,c),p=h.from-f,g=h.to-d;(p==0||p==1||f==0)&&(g==0||g==-1||d==e.state.doc.length)&&(u=0,c=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(V.range(c,u));else if(e.lineWrapping&&c==u&&!(l.main.empty&&l.main.head==u)&&e.inputState.lastTouchTime>Date.now()-100){let f=e.coordsAtPos(u,-1),d=0;f&&(d=e.inputState.lastTouchY<=f.bottom?-1:1),this.newSel=V.create([V.cursor(u,d)])}else this.newSel=V.single(c,u)}}}function fk(t,e,n,i){if(t.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let a=0,u=i,c=i;a<t.children.length;a++){let h=t.children[a],f=u+h.length;if(u<e&&f>n)return fk(h,e,n,u);if(f>=e&&r==-1&&(r=a,s=u),u>n&&h.dom.parentNode==t.dom){o=a,l=c;break}c=f,u=f+h.breakAfter}return{from:s,to:l<0?i+t.length:l,startDOM:(r?t.children[r-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o<t.children.length&&o>=0?t.children[o].dom:null}}else return t.isText()?{from:i,to:i+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function dk(t,e){let n,{newSel:i}=e,{state:r}=t,s=r.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,u=s.from,c=null;(o===8||q.android&&e.text.length<a-l)&&(u=s.to,c="end");let h=r.doc.sliceString(l,a,Wr),f,d;!s.empty&&s.from>=l&&s.to<=a&&(e.typeOver||h!=e.text)&&h.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&h.slice(s.to-l)==e.text.slice(f=e.text.length-(h.length-(s.to-l)))?n={from:s.from,to:s.to,insert:oe.of(e.text.slice(s.from-l,f).split(Wr))}:(d=pk(h,e.text,u-l,c))&&(q.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==Wr+Wr&&d.toB--,n={from:l+d.from,to:l+d.toA,insert:oe.of(e.text.slice(d.from,d.toB).split(Wr))})}else i&&(!t.hasFocus&&r.facet(Yn)||Ku(i,s))&&(i=null);if(!n&&!i)return!1;if((q.mac||q.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(i&&n.insert.length==2&&(i=V.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:oe.of([n.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).to<s.to&&t.docView.lineHasWidget(s.to)&&t.inputState.insertingTextAt>Date.now()-50?n={from:s.from,to:s.to,insert:r.toText(t.inputState.insertingText)}:q.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==`
64
+ `&&t.lineWrapping&&(i&&(i=V.single(i.main.anchor-1,i.main.head-1)),n={from:s.from,to:s.to,insert:oe.of([" "])}),n)return Nm(t,n,i,o);if(i&&!Ku(i,s)){let l=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=hk(r.facet(Fl).map(u=>u(t)),i))),t.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function Nm(t,e,n,i=-1){if(q.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(q.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&t.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ss(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&Ss(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&Ss(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=lI(t,e,n));return t.state.facet(ek).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function lI(t,e,n){let i,r=t.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let a=e.from<s.from?-1:1,u=a<0?s.from:s.to,c=Wo(r.facet(Fl).map(h=>h(t)),u,a);e.from==c&&(o=c)}if(o>-1)i={changes:e,selection:V.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.from<e.from?r.sliceDoc(s.from,e.from):"",u=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+u))}else{let a=r.changes(e),u=n&&n.main.to<=a.newLength?n.main:void 0;if(r.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=t.state.sliceDoc(e.from,e.to),h,f=n&&ck(t,n.main.head);if(f){let p=e.insert.length-(e.to-e.from);h={from:f.from,to:f.to-p}}else h=t.state.doc.lineAt(s.head);let d=s.to-e.to;i=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:u||p.map(a)};let g=p.to-d,S=g-c.length;if(t.state.sliceDoc(S,g)!=c||g>=h.from&&S<=h.to)return{range:p};let m=r.changes({from:S,to:g,insert:e.insert}),y=p.to-s.to;return{changes:m,range:u?V.range(Math.max(0,u.anchor+y),Math.max(0,u.head+y)):p.map(m)}})}else i={changes:a,selection:u&&r.selection.replaceRange(u)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:l,scrollIntoView:!0})}function pk(t,e,n,i){let r=Math.min(t.length,e.length),s=0;for(;s<r&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&t.length==e.length)return null;let o=t.length,l=e.length;for(;o>0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o<s&&t.length<e.length){let a=n<=s&&n>=o?s-n:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=n<=s&&n>=l?s-n:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function aI(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new vy(n,i)),(r!=n||s!=i)&&e.push(new vy(r,s))),e}function uI(t,e){if(t.length==0)return null;let n=t[0].pos,i=t.length==2?t[1].pos:n;return n>-1&&i>-1?V.single(n+e,i+e):null}function Ku(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class cI{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&&NI(e.contentDOM.ownerDocument)}handleEvent(e){!wI(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,n){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,n);for(let r of i.handlers){if(n.defaultPrevented)break;if(r(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=fI(e),i=this.handlers,r=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!n[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=n}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&&gk.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&&(mk.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||dI.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&q.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&hI(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Ss(this.view.contentDOM,n.key,n.keyCode,n.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 hI(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function wy(t,e){return(n,i)=>{try{return e.call(t,i,n)}catch(r){Mt(n.state,r)}}}function fI(t){let e=Object.create(null);function n(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of t){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&n(l).handlers.push(wy(i.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(wy(i.value,a))}}for(let i in gn)n(i).handlers.push(gn[i]);for(let i in ct)n(i).observers.push(ct[i]);return e}const mk=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],dI="dthko",gk=[16,17,18,20,91,92,224,225],wa=6;function xa(t){return Math.max(0,t)*.7+8}function pI(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class mI{constructor(e,n,i,r){this.view=e,this.startEvent=n,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=zS(e.contentDOM),this.atoms=e.state.facet(Fl).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(ae.allowMultipleSelections)&&gI(e,n),this.dragging=vI(e,n)&&wk(n)==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&&pI(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Em(this.view);e.clientX-a.left<=r+wa?n=-xa(r-e.clientX):e.clientX+a.right>=o-wa&&(n=xa(e.clientX-o)),e.clientY-a.top<=s+wa?i=-xa(s-e.clientY):e.clientY+a.bottom>=l-wa&&(i=xa(e.clientY-l)),this.setScrollSpeed(n,i)}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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,i=hk(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function gI(t,e){let n=t.state.facet(XS);return n.length?n[0](e):q.mac?e.metaKey:e.ctrlKey}function yI(t,e){let n=t.state.facet(GS);return n.length?n[0](e):q.mac?!e.altKey:!e.ctrlKey}function vI(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let i=bl(t.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function wI(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,i;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(i=Oe.get(n))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const gn=Object.create(null),ct=Object.create(null),yk=q.ie&&q.ie_version<15||q.ios&&q.webkit_version<604;function xI(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),vk(t,n.value)},50)}function Bc(t,e,n){for(let i of t.facet(e))n=i(n,t);return n}function vk(t,e){e=Bc(t.state,Sm,e);let{state:n}=t,i,r=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(Bd!=null&&n.selection.ranges.every(a=>a.empty)&&Bd==s.toString()){let a=-1;i=n.changeByRange(u=>{let c=n.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let h=n.toText((o?s.line(r++).text:e)+n.lineBreak);return{changes:{from:c.from,insert:h},range:V.cursor(u.from+h.length)}})}else o?i=n.changeByRange(a=>{let u=s.line(r++);return{changes:{from:a.from,to:a.to,insert:u.text},range:V.cursor(a.from+u.length)}}):i=n.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ct.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,q.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};ct.wheel=ct.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};gn.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);ct.touchstart=(t,e)=>{let n=t.inputState,i=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),i&&(n.lastTouchX=i.clientX,n.lastTouchY=i.clientY),n.setSelectionOrigin("select.pointer")};ct.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};ct.touchend=(t,e)=>{t.inputState.touchActive=!1};gn.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of t.state.facet(JS))if(n=i(t,e),n)break;if(!n&&e.button==0&&(n=kI(t,e)),n){let i=!t.hasFocus;t.inputState.startMouseSelection(new mI(t,e,n,i)),i&&t.observer.ignore(()=>{FS(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let r=t.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function xy(t,e,n,i){if(i==1)return V.cursor(e,n);if(i==2)return XR(t.state,e,n);{let r=t.docView.lineAt(e,n),s=t.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<t.state.doc.length&&l==s.to&&l++,V.undirectionalRange(o,l)}}const SI=q.ie&&q.ie_version<=11;let Sy=null,ky=0,by=0;function wk(t){if(!SI)return t.detail;let e=Sy,n=by;return Sy=t,by=Date.now(),ky=!e||n>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(ky+1)%3:1}function kI(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=wk(e),r=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),r=r.map(s.changes))},get(s,o,l){let a=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,c=xy(t,a.pos,a.assoc,i);if(n.pos!=a.pos&&!o){let h=xy(t,n.pos,n.assoc,i),f=Math.min(h.from,c.from),d=Math.max(h.to,c.to);c=f<c.from?V.range(f,d,c.assoc):V.range(d,f,c.assoc)}return o?r.replaceRange(r.main.extend(c.from,c.to,c.assoc)):l&&i==1&&r.ranges.length>1&&(u=bI(r,a.pos))?u:l?r.addRange(c):V.create([c])}}}function bI(t,e){for(let n=0;n<t.ranges.length;n++){let{from:i,to:r}=t.ranges[n];if(i<=e&&r>=e)return V.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}gn.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let r=t.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=n.to||o<=n.from)&&(n=V.undirectionalRange(s,o))}}let{inputState:i}=t;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Bc(t.state,km,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};gn.dragend=t=>(t.inputState.draggedContent=null,!1);function Cy(t,e,n,i){if(n=Bc(t.state,Sm,n),!n)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=i&&s&&yI(t,e)?{from:s.from,to:s.to}:null,l={from:r,insert:n},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}gn.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,s=()=>{++r==n.length&&Cy(t,e,i.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o<n.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(n[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Cy(t,e,i,!0),!0}return!1};gn.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=yk?null:e.clipboardData;return n?(vk(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(xI(t),!1)};function CI(t,e){let n=t.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),t.focus()},50)}function EI(t){let e=[],n=[],i=!1;for(let r of t.selection.ranges)r.empty||(e.push(t.sliceDoc(r.from,r.to)),n.push(r));if(!e.length){let r=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>r&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),r=o.number}i=!0}return{text:Bc(t,km,e.join(t.lineBreak)),ranges:n,linewise:i}}let Bd=null;gn.copy=gn.cut=(t,e)=>{if(!Vo(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:i,linewise:r}=EI(t.state);if(!n&&!r)return!1;Bd=r?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=yk?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(CI(t,n),!1)};const xk=Fn.define();function Sk(t,e){let n=[];for(let i of t.facet(tk)){let r=i(t,e);r&&n.push(r)}return n.length?t.update({effects:n,annotations:xk.of(!0)}):null}function kk(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=Sk(t.state,e);n?t.dispatch(n):t.update([])}},10)}ct.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),kk(t)};ct.blur=t=>{t.observer.clearSelectionRange(),kk(t)};ct.compositionstart=ct.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};ct.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,q.chrome&&q.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};ct.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};gn.beforeinput=(t,e)=>{var n,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=t.posAtDOM(l.startContainer,l.startOffset),u=t.posAtDOM(l.endContainer,l.endOffset);return Nm(t,{from:a,to:u,insert:t.state.toText(s)},null),!0}}let r;if(q.chrome&&q.android&&(r=mk.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return q.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),q.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>ct.compositionend(t,e),20),!1};const Ey=new Set;function NI(t){Ey.has(t)||(Ey.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const Ny=["pre-wrap","normal","pre-line","break-spaces"];let Fs=!1;function _y(){Fs=!1}class _I{constructor(e){this.lineWrapping=e,this.doc=oe.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let i=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((n-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}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 Ny.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(n=!0,this.heightSamples[Math.floor(r*10)]=!0)}return n}refresh(e,n,i,r,s,o){let l=Ny.indexOf(e)>-1,a=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let u=0;u<o.length;u++){let c=o[u];c<0?u++:this.heightSamples[Math.floor(c*10)]=!0}}return a}}class AI{constructor(e,n){this.from=e,this.heights=n,this.index=0}get more(){return this.index<this.heights.length}}class un{constructor(e,n,i,r,s){this.from=e,this.length=n,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?qt.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 _r?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new un(this.from,this.length+e.length,this.top,this.height+e.height,n)}}var de=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(de||(de={}));const eu=.001;class ut{constructor(e,n,i=2){this.length=e,this.height=n,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>eu&&(Fs=!0),this.height=e)}replace(e,n,i){return ut.of(i)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:h}=r[l],f=s.lineAt(a,de.ByPosNoHeight,i.setDoc(n),0,0),d=f.to>=u?f:s.lineAt(u,de.ByPosNoHeight,i,0,0);for(h+=d.to-u,u=d.to;l>0&&f.from<=r[l-1].toA;)a=r[l-1].fromA,c=r[l-1].fromB,l--,a<f.from&&(f=s.lineAt(a,de.ByPosNoHeight,i,0,0));c+=f.from-a,a=f.from;let p=_m.build(i.setDoc(o),e,c,h);s=qu(s,s.replace(a,u,p))}return s.updateHeight(i,0)}static empty(){return new _t(0,0,0)}static of(e){if(e.length==1)return e[0];let n=0,i=e.length,r=0,s=0;for(;;)if(n==i)if(r>s*2){let l=e[n-1];l.break?e.splice(--n,1,l.left,null,l.right):e.splice(--n,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[n++];l&&(r+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[n-1]==null?(o=1,n--):e[n]==null&&(o=1,i++),new MI(ut.of(e.slice(0,n)),o,ut.of(e.slice(i)))}}function qu(t,e){return t==e?t:(t.constructor!=e.constructor&&(Fs=!0),e)}ut.prototype.size=1;const TI=Me.replace({});class bk extends ut{constructor(e,n,i){super(e,n),this.deco=i,this.spaceAbove=0}mainBlock(e,n){return new un(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,n,i,r){return this.spaceAbove&&e<i+this.spaceAbove?new un(r,0,i,this.spaceAbove,TI):this.mainBlock(i,r)}lineAt(e,n,i,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,i,r,s).join(o):o}forEachLine(e,n,i,r,s,o){e<=s+this.length&&n>=s&&o(this.lineAt(0,de.ByPos,i,r,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,i=!1,r){return r&&r.from<=n&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class _t extends bk{constructor(e,n,i){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,n){return new un(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,i){let r=i[0];return i.length==1&&(r instanceof _t||r instanceof Ke&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Ke?r=new _t(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):ut.of(i)}updateHeight(e,n=0,i=!1,r){return r&&r.from<=n&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Ke extends ut{constructor(e){super(e,0)}heightMetrics(e,n){let i=e.doc.lineAt(n).number,r=e.doc.lineAt(n+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,n,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(n,r);if(n.lineWrapping){let u=r+(e<n.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),c=n.doc.lineAt(u),h=l+c.length*a,f=Math.max(i,e-h/2);return new un(c.from,c.length,f,h,0)}else{let u=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:c,length:h}=n.doc.line(s+u);return new un(c,h,i+l*u,l,0)}}lineAt(e,n,i,r,s){if(n==de.ByHeight)return this.blockAt(e,i,r,s);if(n==de.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(e);return new un(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s),u=i.doc.lineAt(e),c=l+u.length*a,h=u.number-o,f=r+l*h+a*(u.from-s-h);return new un(u.from,u.length,Math.max(r,Math.min(f,r+this.height-c)),c,0)}forEachLine(e,n,i,r,s,o){e=Math.max(e,s),n=Math.min(n,s+this.length);let{firstLine:l,perLine:a,perChar:u}=this.heightMetrics(i,s);for(let c=e,h=r;c<=n;){let f=i.doc.lineAt(c);if(c==e){let p=f.number-l;h+=a*p+u*(e-s-p)}let d=a+u*f.length;o(new un(f.from,f.length,h,d,0)),h+=d,c=f.to+1}}replace(e,n,i){let r=this.length-n;if(r>0){let s=i[i.length-1];s instanceof Ke?i[i.length-1]=new Ke(s.length+r):i.push(null,new Ke(r-1))}if(e>0){let s=i[0];s instanceof Ke?i[0]=new Ke(e+s.length):i.unshift(new Ke(e-1),null)}return ut.of(i)}decomposeLeft(e,n){n.push(new Ke(e-1),null)}decomposeRight(e,n){n.push(null,new Ke(this.length-e-1))}updateHeight(e,n=0,i=!1,r){let s=n+this.length;if(r&&r.from<=n+this.length&&r.more){let o=[],l=Math.max(n,r.from),a=-1;for(r.from>n&&o.push(new Ke(r.from-n-1).updateHeight(e,n));l<=s&&r.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let h=r.heights[r.index++],f=0;h<0&&(f=-h,h=r.heights[r.index++]),a==-1?a=h:Math.abs(h-a)>=eu&&(a=-2);let d=new _t(c,h,f);d.outdated=!1,o.push(d),l+=c+1}l<=s&&o.push(null,new Ke(s-l).updateHeight(e,l));let u=ut.of(o);return(a<0||Math.abs(u.height-this.height)>=eu||Math.abs(a-this.heightMetrics(e,n).perLine)>=eu)&&(Fs=!0),qu(this,u)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class MI extends ut{constructor(e,n,i){super(e.length+n+i.length,e.height+i.height,n|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,n,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,n,i,r):this.right.blockAt(e,n,s,r+this.left.length+this.break)}lineAt(e,n,i,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=n==de.ByHeight?e<o:e<l,u=a?this.left.lineAt(e,n,i,r,s):this.right.lineAt(e,n,i,o,l);if(this.break||(a?u.to<l:u.from>l))return u;let c=n==de.ByPosNoHeight?de.ByPosNoHeight:de.ByPos;return a?u.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,r,s).join(u)}forEachLine(e,n,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,n,i,r,s,o),n>=a&&this.right.forEachLine(e,n,i,l,a,o);else{let u=this.lineAt(a,de.ByPos,i,r,s);e<u.from&&this.left.forEachLine(e,u.from-1,i,r,s,o),u.to>=e&&u.from<=n&&o(u),n>u.to&&this.right.forEachLine(u.to+1,n,i,l,a,o)}}replace(e,n,i){let r=this.left.length+this.break;if(n<r)return this.balanced(this.left.replace(e,n,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,n-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&Ay(s,o-1),n<this.length){let l=s.length;this.decomposeRight(n,s),Ay(s,l)}return ut.of(s)}decomposeLeft(e,n){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,n);n.push(this.left),this.break&&(i++,e>=i&&n.push(null)),e>i&&this.right.decomposeLeft(e-i,n)}decomposeRight(e,n){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,n);e<i&&this.left.decomposeRight(e,n),this.break&&e<r&&n.push(null),n.push(this.right)}balanced(e,n){return e.size>2*n.size||n.size>2*e.size?ut.of(this.break?[e,null,n]:[e,n]):(this.left=qu(this.left,e),this.right=qu(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,i=!1,r){let{left:s,right:o}=this,l=n+s.length+this.break,a=null;return r&&r.from<=n+s.length&&r.more?a=s=s.updateHeight(e,n,i,r):s.updateHeight(e,n,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Ay(t,e){let n,i;t[e]==null&&(n=t[e-1])instanceof Ke&&(i=t[e+1])instanceof Ke&&t.splice(e-1,3,new Ke(n.length+1+i.length))}const OI=5;class _m{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let i=Math.min(n,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof _t?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new _t(i-this.pos,-1,0)),this.writtenTo=i,n>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,i){if(e<n||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=n-e;i.block?this.addBlock(new bk(o,r,i)):(o||s||r>=OI)&&this.addLineDeco(r,s,o)}else n>e&&this.span(e,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:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new _t(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let i=new Ke(n-e);return this.oracle.doc.lineAt(e).to==n&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof _t)return e;let n=new _t(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=n,this.writtenTo=this.pos=this.pos+i}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof _t)&&!this.isCovered?this.nodes.push(new _t(0,-1,0)):(this.writtenTo<this.pos||n==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof _t&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,n,i,r){let s=new _m(i,e);return ue.spans(n,i,r,s,0),s.finish(i)}}function PI(t,e,n){let i=new RI;return ue.compare(t,e,n,i,0),i.changes}class RI{constructor(){this.changes=[]}compareRange(){}comparePoint(e,n,i,r){(e<n||i&&i.heightRelevant||r&&r.heightRelevant)&&xs(e,n,this.changes,5)}}function II(t,e){let n=t.getBoundingClientRect(),i=t.ownerDocument,r=i.defaultView||window,s=Math.max(0,n.left),o=Math.min(r.innerWidth,n.right),l=Math.max(0,n.top),a=Math.min(r.innerHeight,n.bottom);for(let u=t.parentNode;u&&u!=i.body;)if(u.nodeType==1){let c=u,h=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&h.overflow!="visible"){let f=c.getBoundingClientRect();s=Math.max(s,f.left),o=Math.min(o,f.right),l=Math.max(l,f.top),a=Math.min(u==t.parentNode?r.innerHeight:a,f.bottom)}u=h.position=="absolute"||h.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,a)-(n.top+e)}}function DI(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left<n.innerWidth&&e.right>0&&e.top<n.innerHeight&&e.bottom>0}function BI(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class $h{constructor(e,n,i,r){this.from=e,this.to=n,this.size=i,this.displaySize=r}static same(e,n){if(e.length!=n.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=n[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,n){return Me.replace({widget:new LI(this.displaySize*(n?e.scaleY:e.scaleX),n)}).range(this.from,this.to)}}class LI extends zl{constructor(e,n){super(),this.size=e,this.vertical=n}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}}class Ty{constructor(e,n){this.view=e,this.state=n,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=My,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Te.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=n.facet(bm).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new _I(i),this.stateDeco=Oy(n),this.heightMap=ut.empty().applyChanges(this.stateDeco,oe.empty,this.heightOracle.setDoc(n.doc),[new Ht(0,0,0,n.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Me.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let i=0;i<=1;i++){let r=i?n.head:n.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Sa(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?My:new Am(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(Mo(e,this.scaler))})}update(e,n=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Oy(this.state);let r=e.changedRanges,s=Ht.extendWithRanges(r,PI(i,this.stateDeco,e?e.changes:ze.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);_y(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Fs)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.head<a.from||n.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,n));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(_R)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,i=window.getComputedStyle(n),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?Te.RTL:Te.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:b,scaleY:C}=LS(n,l);(b>.005&&Math.abs(this.scaleX-b)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=b,this.scaleY=C,u|=16,o=a=!0)}let h=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=h||this.paddingBottom!=f)&&(this.paddingTop=h,this.paddingBottom=f,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let d=zS(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=VS(this.scrollParent||e.win);let g=(this.printing?BI:II)(n,this.paddingTop),S=g.top-this.pixelViewport.top,m=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!DI(e.dom))return 0;let v=l.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),a){let b=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(b)&&(o=!0),o||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:C,charWidth:N,textHeight:M}=e.docView.measureTextSize();o=C>0&&r.refresh(s,C,N,M,Math.max(5,v/N),b),o&&(e.docView.minWidth=0,u|=16)}S>0&&m>0?c=Math.max(S,m):S<0&&m<0&&(c=Math.min(S,m)),_y();for(let C of this.viewports){let N=C.from==this.viewport.from?b:e.docView.measureVisibleLineHeights(C);this.heightMap=(o?ut.empty().applyChanges(this.stateDeco,oe.empty,this.heightOracle,[new Ht(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new AI(C.from,N))}Fs&&(u|=2)}let x=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return x&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Sa(r.lineAt(o-i*1e3,de.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,de.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(u<a.from||u>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),h=r.lineAt(u,de.ByPos,s,0,0),f;n.y=="center"?f=(h.top+h.bottom)/2-c/2:n.y=="start"||n.y=="nearest"&&u<a.from?f=h.top:f=h.bottom-c,a=new Sa(r.lineAt(f-1e3/2,de.ByHeight,s,0,0).from,r.lineAt(f+c+1e3/2,de.ByHeight,s,0,0).to)}}return a}mapViewport(e,n){let i=n.mapPos(e.from,-1),r=n.mapPos(e.to,1);return new Sa(this.heightMap.lineAt(i,de.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,de.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:n},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,de.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(n,de.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(n==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,n){if(!e.length||n.empty)return e;let i=[];for(let r of e)n.touchesRange(r.from,r.to)||i.push(new $h(n.mapPos(r.from),n.mapPos(r.to),r.size,r.displaySize));return i}ensureLineGaps(e,n){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=Te.LTR&&!i)return[];let l=[],a=(c,h,f,d)=>{if(h-c<s)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let m of g)if(m>c&&m<h){a(c,m-10,f,d),a(m+10,h,f,d);return}let S=$I(e,m=>m.from>=f.from&&m.to<=f.to&&Math.abs(m.from-c)<s&&Math.abs(m.to-h)<s&&!g.some(y=>m.from<y&&m.to>y));if(!S){if(h<f.to&&n&&i&&n.visibleRanges.some(v=>v.from<=h&&v.to>=h)){let v=n.moveToLineBoundary(V.cursor(h),!1,!0).head;v>c&&(h=v)}let m=this.gapSize(f,c,h,d),y=i||m<2e6?m:2e6;S=new $h(c,h,m,y)}l.push(S)},u=c=>{if(c.length<o||c.type!=qt.Text)return;let h=zI(c.from,c.to,this.stateDeco);if(h.total<o)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let g=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,S,m;if(f!=null){let y=ba(h,f),v=((this.visibleBottom-this.visibleTop)/2+g)/c.height;S=y-v,m=y+v}else S=(this.visibleTop-c.top-g)/c.height,m=(this.visibleBottom-c.top+g)/c.height;d=ka(h,S),p=ka(h,m)}else{let g=h.total*this.heightOracle.charWidth,S=r*this.heightOracle.charWidth,m=0;if(g>2e6)for(let C of e)C.from>=c.from&&C.from<c.to&&C.size!=C.displaySize&&C.from*this.heightOracle.charWidth+m<this.pixelViewport.left&&(m=C.size-C.displaySize);let y=this.pixelViewport.left+m,v=this.pixelViewport.right+m,x,b;if(f!=null){let C=ba(h,f),N=((v-y)/2+S)/g;x=C-N,b=C+N}else x=(y-S)/g,b=(v+S)/g;d=ka(h,x),p=ka(h,b)}d>c.from&&a(c.from,d,c,h),p<c.to&&a(p,c.to,c,h)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(u):u(c);return l}gapSize(e,n,i,r){let s=ba(r,i)-ba(r,n);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){$h.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Me.set(e.map(n=>n.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let i=[];ue.spans(n,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s<i.length&&!(r&8);s++){let o=this.visibleRanges[s],l=i[s];(o.from!=l.from||o.to!=l.to)&&(r|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(r|=8))}return this.visibleRanges=i,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Mo(this.heightMap.lineAt(e,de.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(n=>n.top<=e&&n.bottom>=e)||Mo(this.heightMap.lineAt(this.scaler.fromDOM(e),de.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Mo(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}}class Sa{constructor(e,n){this.from=e,this.to=n}}function zI(t,e,n){let i=[],r=t,s=0;return ue.spans(n,t,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function ka({total:t,ranges:e},n){if(n<=0)return e[0].from;if(n>=1)return e[e.length-1].to;let i=Math.floor(t*n);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function ba(t,e){let n=0;for(let{from:i,to:r}of t.ranges){if(e<=r){n+=e-i;break}n+=r-i}return n/t.total}function $I(t,e){for(let n of t)if(e(n))return n}const My={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function Oy(t){let e=t.facet(Rc).filter(i=>typeof i!="function"),n=t.facet(Cm).filter(i=>typeof i!="function");return n.length&&e.push(ue.join(n)),e}class Am{constructor(e,n,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let u=n.lineAt(l,de.ByPos,e,0,0).top,c=n.lineAt(a,de.ByPos,e,0,0).bottom;return r+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(n.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let n=0,i=0,r=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let n=0,i=0,r=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}eq(e){return e instanceof Am?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((n,i)=>n.from==e.viewports[i].from&&n.to==e.viewports[i].to):!1}}function Mo(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),i=e.toDOM(t.bottom);return new un(t.from,t.length,n,i-n,Array.isArray(t._content)?t._content.map(r=>Mo(r,e)):t._content)}const Ca=ee.define({combine:t=>t.join(" ")}),Ld=ee.define({combine:t=>t.indexOf(!0)>-1}),zd=ji.newName(),Ck=ji.newName(),Ek=ji.newName(),Nk={"&light":"."+Ck,"&dark":"."+Ek};function $d(t,e,n){return new ji(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return t;if(!n||!n[r])throw new RangeError(`Unsupported selector: ${r}`);return n[r]}):t+" "+i}})}const jI=$d("."+zd,{"&":{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":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"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"}},Nk),FI={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},jh=q.ie&&q.ie_version<=11;class VI{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new mR,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(n=>{for(let i of n)this.queue.push(i);(q.ie&&q.ie_version<=11||q.ios&&e.composing)&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.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 WI(e),e.state.facet(Yn)&&(e.contentDOM.editContext=this.editContext.editContext)),jh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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 n;((n=this.view.docView)===null||n===void 0?void 0:n.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(n=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,i)=>n!=e[i]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Yn)?i.root.activeElement!=this.dom:!Vo(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(q.ie&&q.ie_version<=11||q.android&&q.chrome)&&!i.state.selection.main.empty&&r.focusNode&&Ho(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=bl(e.root);if(!n)return!1;let i=q.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&HI(this.view,n)||n;if(!i||this.selectionRange.eq(i))return!1;let r=Vo(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&yR(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,n){this.selectionRange.set(e.node,e.offset,n.node,n.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,n=null;for(let i=this.dom;i;)if(i.nodeType==1)!n&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:n||(n=this.scrollTargets.slice(0,e)),n&&n.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!n&&(n=this.scrollTargets.slice(0,e)),n){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=n)i.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,FI),jh&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),jh&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,n){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ss(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.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 n=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),n==-1?{from:n,to:i}=o:(n=Math.min(o.from,n),i=Math.max(o.to,i)))}return{from:n,to:i,typeOver:r}}readChange(){let{from:e,to:n,typeOver:i}=this.processRecords(),r=this.selectionChanged&&Vo(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new oI(this.view,e,n,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let i=this.view.state,r=dk(this.view,n);return this.view.state==i&&(n.domChanged||n.newSel&&!Ku(this.view.state.selection,n.newSel.main))&&this.view.update([]),r}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let i=Py(n,e.previousSibling||e.target.previousSibling,-1),r=Py(n,e.nextSibling||e.target.nextSibling,1);return{from:i?n.posAfter(i):n.posAtStart,to:r?n.posBefore(r):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.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(Yn)!=e.state.facet(Yn)&&(e.view.contentDOM.editContext=e.state.facet(Yn)?this.editContext.editContext:null))}destroy(){var e,n,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.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 Py(t,e,n){for(;e;){let i=Oe.get(e);if(i&&i.parent==t)return i;let r=e.parentNode;e=r!=t.dom?r:n>0?e.nextSibling:e.previousSibling}return null}function Ry(t,e){let n=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return Ho(o.node,o.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}function HI(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return Ry(t,r)}let n=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),n?Ry(t,n):null}class WI{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let u=a-l>i.text.length;l==this.from&&s<this.from?l=s:a==this.to&&s>this.to&&(a=s);let c=pk(e.state.sliceDoc(l,a),i.text,(u?r.from:r.to)-l,u?"end":null);if(!c){let f=V.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Ku(f,r)||e.dispatch({selection:f,userEvent:"select"});return}let h={from:c.from+l,to:c.toA+l,insert:oe.of(i.text.slice(c.from,c.toB).split(`
65
+ `))};if((q.mac||q.android)&&h.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(h={from:l,to:a,insert:oe.of([i.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let f=this.to-this.from+(h.to-h.from+h.insert.length);Nm(e,h,V.single(this.toEditorPos(i.selectionStart,f),this.toEditorPos(i.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(n.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=e.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}n.updateCharacterBounds(i.rangeStart,r)},this.handlers.textformatupdate=i=>{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(a<u){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;r.push(Me.mark({attributes:{style:c}}).range(a,u))}}}e.dispatch({effects:rk.of(Me.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)n.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let r=bl(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,u)=>{if(i)return;let c=u.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(u)){r=this.pendingContextChange=null,n+=c,this.to+=c;return}else r=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=c,this.to+=c;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+u.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=c}n+=c}),r&&!i&&this.revertPending(e.state),!i}update(e){let n=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),r=this.toContextPos(n.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to<e.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class J{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(e={}){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.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),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||gR(e.parent)||document,this.viewState=new Ty(this,e.state||ae.create(e)),e.scrollTo&&e.scrollTo.is(va)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(rs).map(r=>new Ih(r));for(let r of this.plugins)r.update(this);this.observer=new VI(this),this.inputState=new cI(this),this.inputState.ensureHandlers(this.plugins),this.docView=new gy(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(...e){let n=e.length==1&&e[0]instanceof je?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,i=!1,r,s=this.state;for(let f of e){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,l=0,a=null;e.some(f=>f.annotation(xk))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Sk(s,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(ae.phrases)!=this.state.facet(ae.phrases))return this.setState(s);r=Hu.create(this,s,e),r.flags|=l;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(h&&(h=h.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection,{x:p,y:g}=this.state.facet(J.cursorScrollMargin);h=new ks(d.empty?d:V.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",g,p)}for(let d of f.effects)d.is(va)&&(h=d.value.clip(this.state))}this.viewState.update(r,h),this.bidiCache=Yu.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),n=this.docView.update(r),this.state.facet(To)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Ca)!=r.state.facet(Ca)&&(this.viewState.mustMeasureContent=!0),(n||i||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!r.empty)for(let f of this.state.facet(Rd))try{f(r)}catch(d){Mt(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!dk(this,c)&&u.force&&Ss(this.contentDOM,u.key,u.keyCode)})}setState(e){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=e;return}this.updateState=2;let n=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Ty(this,e),this.plugins=e.facet(rs).map(i=>new Ih(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new gy(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(rs),i=e.state.facet(rs);if(n!=i){let r=[];for(let s of i){let o=n.indexOf(s);if(o<0)r.push(new Ih(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);n!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let n=e.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(i){Mt(this.state,i,"doc view update listener")}}}measure(e=!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,e&&this.observer.forceFlush();let n=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(VS(i||this.win))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!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=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(d=>{try{return d.read(this)}catch(p){return Mt(this.state,p),Iy}}),h=Hu.create(this,this.state,[]),f=!1;h.flags|=a,n?n.flags|=a:n=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),f=this.docView.update(h),f&&this.docViewUpdate());for(let d=0;d<u.length;d++)if(c[d]!=Iy)try{let p=u[d];p.write&&p.write(c[d],this)}catch(p){Mt(this.state,p)}if(f&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=((s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o)/this.scaleY;if((p>1||p<-1)&&!(q.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+p,i?s<0?i.scrollTop=i.scrollHeight:i.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(Rd))l(n)}get themeClasses(){return zd+" "+(this.state.facet(Ld)?Ek:Ck)+" "+this.state.facet(Ca)}updateAttrs(){let e=Dy(this,sk,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Yn)?"true":"false",class:"cm-content",style:`${q.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Dy(this,bm,n);let i=this.observer.ignore(()=>{let r=cy(this.contentDOM,this.contentAttrs,n),s=cy(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=n,i}showAnnouncements(e){let n=!0;for(let i of e)for(let r of i.effects)if(r.is(J.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(To);let e=this.state.facet(J.cspNonce);ji.mount(this.root,this.styleModules.concat(jI).reverse(),e?{nonce:e}: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(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===e.key){this.measureRequests[n]=e;return}}this.measureRequests.push(e)}}plugin(e){let n=this.pluginMap.get(e);return(n===void 0||n&&n.plugin!=e)&&this.pluginMap.set(e,n=this.plugins.find(i=>i.plugin==e)||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(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,i){return zh(this,e,yy(this,e,n,i))}moveByGroup(e,n){return zh(this,e,yy(this,e,n,i=>eI(this,e.head,i)))}visualLineSide(e,n){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[n?i.length-1:0];return V.cursor(s.side(n,r)+e.from,s.forward(!n,r)?1:-1)}moveToLineBoundary(e,n,i=!0){return ZR(this,e,n,i)}moveVertically(e,n,i){return zh(this,e,tI(this,e,n,i))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let i=Dd(this,e,n);return i&&i.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),Dd(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let i=this.state.doc.lineAt(e),r=this.bidiSpans(i),s=r[Rn.find(r,e-i.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==Te.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(nk)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>UI)return YS(e.length);let n=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||qS(s.isolates,i=dy(this,e))))return s.order;i||(i=dy(this,e));let r=CR(e.text,n,i);return this.bidiCache.push(new Yu(e.from,e.to,n,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||q.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{FS(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var i,r,s,o;return va.of(new ks(typeof e=="number"?V.cursor(e):e,(i=n.y)!==null&&i!==void 0?i:"nearest",(r=n.x)!==null&&r!==void 0?r:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return va.of(new ks(V.cursor(i.from),"start","start",i.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return $n.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return $n.define(()=>({}),{eventObservers:e})}static theme(e,n){let i=ji.newName(),r=[Ca.of(i),To.of($d(`.${i}`,e))];return n&&n.dark&&r.push(Ld.of(!0)),r}static baseTheme(e){return Bl.lowest(To.of($d("."+zd,e,Nk)))}static findFromDOM(e){var n;let i=e.querySelector(".cm-content"),r=i&&Oe.get(i)||Oe.get(e);return((n=r==null?void 0:r.root)===null||n===void 0?void 0:n.view)||null}}J.styleModule=To;J.inputHandler=ek;J.clipboardInputFilter=Sm;J.clipboardOutputFilter=km;J.scrollHandler=ik;J.focusChangeEffect=tk;J.perLineTextDirection=nk;J.exceptionSink=ZS;J.updateListener=Rd;J.editable=Yn;J.mouseSelectionStyle=JS;J.dragMovesSelection=GS;J.clickAddsSelectionRange=XS;J.decorations=Rc;J.blockWrappers=ok;J.outerDecorations=Cm;J.atomicRanges=Fl;J.bidiIsolatedRanges=lk;J.cursorScrollMargin=ee.define({combine:t=>{let e=5,n=5;for(let i of t)typeof i=="number"?e=n=i:{x:e,y:n}=i;return{x:e,y:n}}});J.scrollMargins=ak;J.darkTheme=Ld;J.cspNonce=ee.define({combine:t=>t.length?t[0]:""});J.contentAttributes=bm;J.editorAttributes=sk;J.lineWrapping=J.contentAttributes.of({class:"cm-lineWrapping"});J.announce=me.define();const UI=4096,Iy={};class Yu{constructor(e,n,i,r,s,o){this.from=e,this.to=n,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:Te.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!n.touchesRange(o.from,o.to)&&i.push(new Yu(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Dy(t,e,n){for(let i=t.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(t):s;o&&vm(o,n)}return n}const KI=q.mac?"mac":q.windows?"win":q.linux?"linux":"key";function qI(t,e){const n=t.split(/-(?!$)/);let i=n[n.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;a<n.length-1;++a){const u=n[a];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))s=!0;else if(/^s(hift)?$/i.test(u))o=!0;else if(/^mod$/i.test(u))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function Ea(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n!==!1&&e.shiftKey&&(t="Shift-"+t),t}const YI=Bl.default(J.domEventHandlers({keydown(t,e){return JI(QI(e.state),t,e,"editor")}})),Tm=ee.define({enables:YI}),By=new WeakMap;function QI(t){let e=t.facet(Tm),n=By.get(e);return n||By.set(e,n=GI(e.reduce((i,r)=>i.concat(r),[]))),n}let ki=null;const XI=4e3;function GI(t,e=KI){let n=Object.create(null),i=Object.create(null),r=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,u,c)=>{var h,f;let d=n[o]||(n[o]=Object.create(null)),p=l.split(/ (?!$)/).map(m=>qI(m,e));for(let m=1;m<p.length;m++){let y=p.slice(0,m).join(" ");r(y,!0),d[y]||(d[y]={preventDefault:!0,stopPropagation:!1,run:[v=>{let x=ki={view:v,prefix:y,scope:o};return setTimeout(()=>{ki==x&&(ki=null)},XI),!0}]})}let g=p.join(" ");r(g,!1);let S=d[g]||(d[g]={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())||[]});a&&S.run.push(a),u&&(S.preventDefault=!0),c&&(S.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=n[u]||(n[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:h}=o;for(let f in c)c[f].run.push(d=>h(d,jd))}let a=o[e]||o.key;if(a)for(let u of l)s(u,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return n}let jd=null;function JI(t,e,n,i){jd=e;let r=uR(e),s=sr(r,0),o=Hr(s)==r.length&&r!=" ",l="",a=!1,u=!1,c=!1;ki&&ki.view==n&&ki.scope==i&&(l=ki.prefix+" ",gk.indexOf(e.keyCode)<0&&(u=!0,ki=null));let h=new Set,f=S=>{if(S){for(let m of S.run)if(!h.has(m)&&(h.add(m),m(n)))return S.stopPropagation&&(c=!0),!0;S.preventDefault&&(S.stopPropagation&&(c=!0),u=!0)}return!1},d=t[i],p,g;return d&&(f(d[l+Ea(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(q.windows&&e.ctrlKey&&e.altKey)&&!(q.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Fi[e.keyCode])&&p!=r?(f(d[l+Ea(p,e,!0)])||e.shiftKey&&(g=Sl[e.keyCode])!=r&&g!=p&&f(d[l+Ea(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&f(d[l+Ea(r,e,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),jd=null,a}const Na="-10000px";class ZI{constructor(e,n,i,r){this.facet=n,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=i(o,s))}update(e,n){var i;let r=e.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=n?[]:null;for(let a=0;a<s.length;a++){let u=s[a],c=-1;if(u){for(let h=0;h<this.tooltips.length;h++){let f=this.tooltips[h];f&&f.create==u.create&&(c=h)}if(c<0)o[a]=this.createTooltipView(u,a?o[a-1]:null),l&&(l[a]=!!u.above);else{let h=o[a]=this.tooltipViews[c];l&&(l[a]=n[c]),h.update&&h.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(i=a.destroy)===null||i===void 0||i.call(a));return n&&(l.forEach((a,u)=>n[u]=a),n.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}}function eD(t={}){return tu.of(t)}function tD(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const tu=ee.define({combine:t=>{var e,n,i;return{position:q.ios?"absolute":((e=t.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(r=>r.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((i=t.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||tD}}}),Ly=new WeakMap,_k=$n.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(tu);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new ZI(t,Ak,(n,i)=>this.createTooltip(n,i),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,i=t.state.facet(tu);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),i=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",n.dom.appendChild(r)}return n.dom.style.position=this.position,n.dom.style.top=Na,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(t=i.destroy)===null||t===void 0||t.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(q.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=Em(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(tu).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:n,space:i,scaleX:r,scaleY:s}=t,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],u=this.manager.tooltipViews[l],{dom:c}=u,h=t.pos[l],f=t.size[l];if(!h||a.clip!==!1&&(h.bottom<=Math.max(n.top,i.top)||h.top>=Math.min(n.bottom,i.bottom)||h.right<Math.max(n.left,i.left)-.1||h.left>Math.min(n.right,i.right)+.1)){c.style.top=Na;continue}let d=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=f.right-f.left,S=(e=Ly.get(u))!==null&&e!==void 0?e:f.bottom-f.top,m=u.offset||iD,y=this.view.textDirection==Te.LTR,v=f.width>i.right-i.left?y?i.left:i.right-f.width:y?Math.max(i.left,Math.min(h.left-(d?14:0)+m.x,i.right-g)):Math.min(Math.max(i.left,h.left-g+(d?14:0)-m.x),i.right-g),x=this.above[l];!a.strictSide&&(x?h.top-S-p-m.y<i.top:h.bottom+S+p+m.y>i.bottom)&&x==i.bottom-h.bottom>h.top-i.top&&(x=this.above[l]=!x);let b=(x?h.top-i.top:i.bottom-h.bottom)-p;if(b<S&&u.resize!==!1){if(b<this.view.defaultLineHeight){c.style.top=Na;continue}Ly.set(u,S),c.style.height=(S=b)/s+"px"}else c.style.height&&(c.style.height="");let C=x?h.top-S-p-m.y:h.bottom+p+m.y,N=v+g;if(u.overlap!==!0)for(let M of o)M.left<N&&M.right>v&&M.top<C+S&&M.bottom>C&&(C=x?M.top-S-2-p:M.bottom+p+2);if(this.position=="absolute"?(c.style.top=(C-t.parent.top)/s+"px",zy(c,(v-t.parent.left)/r)):(c.style.top=C/s+"px",zy(c,v/r)),d){let M=h.left+(y?m.x:-m.x)-(v+14-7);d.style.left=M/r+"px"}u.overlap!==!0&&o.push({left:v,top:C,right:N,bottom:C+S}),c.classList.toggle("cm-tooltip-above",x),c.classList.toggle("cm-tooltip-below",!x),u.positioned&&u.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=Na}},{eventObservers:{scroll(){this.maybeMeasure()}}});function zy(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const nD=J.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),iD={x:0,y:0},Ak=ee.define({enables:[_k,nD]});function Tk(t,e){let n=t.plugin(_k);if(!n)return null;let i=n.manager.tooltips.indexOf(e);return i<0?null:n.manager.tooltipViews[i]}class Vs extends $i{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Vs.prototype.elementClass="";Vs.prototype.toDOM=void 0;Vs.prototype.mapMode=At.TrackBefore;Vs.prototype.startSide=Vs.prototype.endSide=-1;Vs.prototype.point=!0;const Mk=1024;let rD=0;class Fh{constructor(e,n){this.from=e,this.to=n}}class re{constructor(e={}){this.id=rD++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=bt.match(e)),n=>{let i=e(n);return i===void 0?null:[this,i]}}}re.closedBy=new re({deserialize:t=>t.split(" ")});re.openedBy=new re({deserialize:t=>t.split(" ")});re.group=new re({deserialize:t=>t.split(" ")});re.isolate=new re({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});re.contextHash=new re({perNode:!0});re.lookAhead=new re({perNode:!0});re.mounted=new re({perNode:!0});class Uo{constructor(e,n,i,r=!1){this.tree=e,this.overlay=n,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[re.mounted.id]}}const sD=Object.create(null);class bt{constructor(e,n,i,r=0){this.name=e,this.props=n,this.id=i,this.flags=r}static define(e){let n=e.props&&e.props.length?Object.create(null):sD,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new bt(e.name||"",n,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),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 r}prop(e){return this.props[e.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(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(re.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let i in e)for(let r of i.split(" "))n[r]=e[i];return i=>{for(let r=i.prop(re.group),s=-1;s<(r?r.length:0);s++){let o=n[s<0?i.name:r[s]];if(o)return o}}}}bt.none=new bt("",Object.create(null),0,8);class Mm{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);if(o){r||(r=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in r&&(l=a.combine(r[a.id],l)),r[a.id]=l}}n.push(r?new bt(i.name,r,i.id,i.flags):i)}return new Mm(n)}}const _a=new WeakMap,$y=new WeakMap;var _e;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(_e||(_e={}));class Ie{constructor(e,n,i,r,s){if(this.type=e,this.children=n,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Uo.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let i of this.children){let r=i.toString();r&&(n&&(n+=","),n+=r)}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(e=0){return new Vd(this.topNode,e)}cursorAt(e,n=0,i=0){let r=_a.get(this)||this.topNode,s=new Vd(r);return s.moveTo(e,n),_a.set(this,s._tree),s}get topNode(){return new Yt(this,0,0,null)}resolve(e,n=0){let i=El(_a.get(this)||this.topNode,e,n,!1);return _a.set(this,i),i}resolveInner(e,n=0){let i=El($y.get(this)||this.topNode,e,n,!0);return $y.set(this,i),i}resolveStack(e,n=0){return aD(this,e,n)}iterate(e){let{enter:n,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&_e.IncludeAnonymous)>0;for(let a=this.cursor(o|_e.IncludeAnonymous);;){let u=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||n(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Rm(bt.none,this.children,this.positions,0,this.children.length,0,this.length,(n,i,r)=>new Ie(this.type,n,i,r,this.propValues),e.makeTree||((n,i,r)=>new Ie(bt.none,n,i,r)))}static build(e){return uD(e)}}Ie.empty=new Ie(bt.none,[],[],0);class Om{constructor(e,n){this.buffer=e,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 Om(this.buffer,this.index)}}class Hi{constructor(e,n,i){this.buffer=e,this.length=n,this.set=i}get type(){return bt.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],i=this.buffer[e+3],r=this.set.types[n],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,n,i,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=n&&!(Ok(s,r,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,n,i){let r=this.buffer,s=new Uint16Array(n-e),o=0;for(let l=e,a=0;l<n;){s[a++]=r[l++],s[a++]=r[l++]-i;let u=s[a++]=r[l++]-i;s[a++]=r[l++]-e,o=Math.max(o,u)}return new Hi(s,o,this.set)}}function Ok(t,e,n,i){switch(t){case-2:return n<e;case-1:return i>=e&&n<e;case 0:return n<e&&i>e;case 1:return n<=e&&i>e;case 2:return i>e;case 4:return!0}}function El(t,e,n,i){for(var r;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let o=!i&&t instanceof Yt&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=i?0:_e.IgnoreOverlays;if(i)for(let o=t,l=o.parent;l;o=l,l=o.parent)o instanceof Yt&&o.index<0&&((r=l.enter(e,n,s))===null||r===void 0?void 0:r.from)!=o.from&&(t=l);for(;;){let o=t.enter(e,n,s);if(!o)return t;t=o}}class Pk{cursor(e=0){return new Vd(this,e)}getChild(e,n=null,i=null){let r=jy(this,e,n,i);return r.length?r[0]:null}getChildren(e,n=null,i=null){return jy(this,e,n,i)}resolve(e,n=0){return El(this,e,n,!1)}resolveInner(e,n=0){return El(this,e,n,!0)}matchContext(e){return Fd(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),i=this;for(;n;){let r=n.lastChild;if(!r||r.to!=n.to)break;r.type.isError&&r.from==r.to?(i=n,n=r.prevSibling):n=r}return i}get node(){return this}get next(){return this.parent}}class Yt extends Pk{constructor(e,n,i,r){super(),this._tree=e,this.from=n,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,i,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,u=n>0?l.length:-1;e!=u;e+=n){let c=l[e],h=a[e]+o.from,f;if(!(!(s&_e.EnterBracketed&&c instanceof Ie&&(f=Uo.get(c))&&!f.overlay&&f.bracketed&&i>=h&&i<=h+c.length)&&!Ok(r,i,h,h+c.length))){if(c instanceof Hi){if(s&_e.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,n,i-h,r);if(d>-1)return new Ni(new oD(o,c,e,h),null,d)}else if(s&_e.IncludeAnonymous||!c.type.isAnonymous||Pm(c)){let d;if(!(s&_e.IgnoreMounts)&&(d=Uo.get(c))&&!d.overlay)return new Yt(d.tree,h,e,o);let p=new Yt(c,h,e,o);return s&_e.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,i,r,s)}}}if(s&_e.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=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(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,i=0){let r;if(!(i&_e.IgnoreOverlays)&&(r=Uo.get(this._tree))&&r.overlay){let s=e-this.from,o=i&_e.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((n>0||o?l<=s:l<s)&&(n<0||o?a>=s:a>s))return new Yt(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}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 jy(t,e,n,i){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=r.type.is(n),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function Fd(t,e,n=e.length-1){for(let i=t;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[n]&&e[n]!=i.name)return!1;n--}}return!0}class oD{constructor(e,n,i,r){this.parent=e,this.buffer=n,this.index=i,this.start=r}}class Ni extends Pk{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(e,n,i){super(),this.context=e,this._parent=n,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,n,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.context.start,i);return s<0?null:new Ni(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,i=0){if(i&_e.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new Ni(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Ni(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Ni(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),n.push(0)}return new Ie(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Rk(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>n.from||o.to<n.to)&&(n=o,e=s)}let i=n instanceof Yt&&n.index<0?null:n.parent,r=t.slice();return i?r[e]=i:r.splice(e,1),new lD(r,n)}class lD{constructor(e,n){this.heads=e,this.node=n}get next(){return Rk(this.heads)}}function aD(t,e,n){let i=t.resolveInner(e,n),r=null;for(let s=i instanceof Yt?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,n)),s=o}else{let o=Uo.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new Yt(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(El(l,e,n,!1))}}return r?Rk(r):i}class Vd{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~_e.EnterBracketed,e instanceof Yt)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.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,n){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=n||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof Yt?(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,n,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,i=this.mode){return this.buffer?i&_e.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&_e.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&_e.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:n}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(n.findChild(r,this.index,-1,0,4))}else{let r=n.buffer[this.index+3];if(r<(i<0?n.buffer.length:n.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<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 n,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:i}=r)}else({index:n,_parent:i}=this._tree);for(;i;{index:n,_parent:i}=i)if(n>-1)for(let s=n+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&_e.IncludeAnonymous||l instanceof Hi||!l.type.isAnonymous||Pm(l))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;n=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)n=new Ni(this.buffer,n,this.stack[r]);return this.bufferNode=new Ni(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&n&&n(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return Fd(this.node.parent,e);let{buffer:n}=this.buffer,{types:i}=n.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return Fd(this._tree,e,r);let o=i[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function Pm(t){return t.children.some(e=>e instanceof Hi||!e.type.isAnonymous||Pm(e))}function uD(t){var e;let{buffer:n,nodeSet:i,maxBufferLength:r=Mk,reused:s=[],minRepeatType:o=i.types.length}=t,l=Array.isArray(n)?new Om(n,n.length):n,a=i.types,u=0,c=0;function h(b,C,N,M,_,P){let{id:B,start:L,end:F,size:w}=l,E=c,T=u;if(w<0)if(l.next(),w==-1){let I=s[B];N.push(I),M.push(L-b);return}else if(w==-3){u=B;return}else if(w==-4){c=B;return}else throw new RangeError(`Unrecognized record size: ${w}`);let z=a[B],R,A,D=L-b;if(F-L<=r&&(A=S(l.pos-C,_))){let I=new Uint16Array(A.size-A.skip),$=l.pos-A.size,U=I.length;for(;l.pos>$;)U=m(A.start,I,U);R=new Hi(I,F-A.start,i),D=A.start-b}else{let I=l.pos-w;l.next();let $=[],U=[],W=B>=o?B:-1,Q=0,te=F;for(;l.pos>I;)W>=0&&l.id==W&&l.size>=0?(l.end<=te-r&&(p($,U,L,Q,l.end,te,W,E,T),Q=$.length,te=l.end),l.next()):P>2500?f(L,I,$,U):h(L,I,$,U,W,P+1);if(W>=0&&Q>0&&Q<$.length&&p($,U,L,Q,L,te,W,E,T),$.reverse(),U.reverse(),W>-1&&Q>0){let ne=d(z,T);R=Rm(z,$,U,0,$.length,0,F-L,ne,ne)}else R=g(z,$,U,F-L,E-F,T)}N.push(R),M.push(D)}function f(b,C,N,M){let _=[],P=0,B=-1;for(;l.pos>C;){let{id:L,start:F,end:w,size:E}=l;if(E>4)l.next();else{if(B>-1&&F<B)break;B<0&&(B=w-r),_.push(L,F,w),P++,l.next()}}if(P){let L=new Uint16Array(P*4),F=_[_.length-2];for(let w=_.length-3,E=0;w>=0;w-=3)L[E++]=_[w],L[E++]=_[w+1]-F,L[E++]=_[w+2]-F,L[E++]=E;N.push(new Hi(L,_[2]-F,i)),M.push(F-b)}}function d(b,C){return(N,M,_)=>{let P=0,B=N.length-1,L,F;if(B>=0&&(L=N[B])instanceof Ie){if(!B&&L.type==b&&L.length==_)return L;(F=L.prop(re.lookAhead))&&(P=M[B]+L.length+F)}return g(b,N,M,_,P,C)}}function p(b,C,N,M,_,P,B,L,F){let w=[],E=[];for(;b.length>M;)w.push(b.pop()),E.push(C.pop()+N-_);b.push(g(i.types[B],w,E,P-_,L-P,F)),C.push(_-N)}function g(b,C,N,M,_,P,B){if(P){let L=[re.contextHash,P];B=B?[L].concat(B):[L]}if(_>25){let L=[re.lookAhead,_];B=B?[L].concat(B):[L]}return new Ie(b,C,N,M,B)}function S(b,C){let N=l.fork(),M=0,_=0,P=0,B=N.end-r,L={size:0,start:0,skip:0};e:for(let F=N.pos-b;N.pos>F;){let w=N.size;if(N.id==C&&w>=0){L.size=M,L.start=_,L.skip=P,P+=4,M+=4,N.next();continue}let E=N.pos-w;if(w<0||E<F||N.start<B)break;let T=N.id>=o?4:0,z=N.start;for(N.next();N.pos>E;){if(N.size<0)if(N.size==-3||N.size==-4)T+=4;else break e;else N.id>=o&&(T+=4);N.next()}_=z,M+=w,P+=T}return(C<0||M==b)&&(L.size=M,L.start=_,L.skip=P),L.size>4?L:void 0}function m(b,C,N){let{id:M,start:_,end:P,size:B}=l;if(l.next(),B>=0&&M<o){let L=N;if(B>4){let F=l.pos-(B-4);for(;l.pos>F;)N=m(b,C,N)}C[--N]=L,C[--N]=P-b,C[--N]=_-b,C[--N]=M}else B==-3?u=M:B==-4&&(c=M);return N}let y=[],v=[];for(;l.pos>0;)h(t.start||0,t.bufferStart||0,y,v,-1,0);let x=(e=t.length)!==null&&e!==void 0?e:y.length?v[0]+y[0].length:0;return new Ie(a[t.topID],y.reverse(),v.reverse(),x)}const Fy=new WeakMap;function nu(t,e){if(!t.isAnonymous||e instanceof Hi||e.type!=t)return 1;let n=Fy.get(e);if(n==null){n=1;for(let i of e.children){if(i.type!=t||!(i instanceof Ie)){n=1;break}n+=nu(t,i)}Fy.set(e,n)}return n}function Rm(t,e,n,i,r,s,o,l,a){let u=0;for(let p=i;p<r;p++)u+=nu(t,e[p]);let c=Math.ceil(u*1.5/8),h=[],f=[];function d(p,g,S,m,y){for(let v=S;v<m;){let x=v,b=g[v],C=nu(t,p[v]);for(v++;v<m;v++){let N=nu(t,p[v]);if(C+N>=c)break;C+=N}if(v==x+1){if(C>c){let N=p[x];d(N.children,N.positions,0,N.children.length,g[x]+y);continue}h.push(p[x])}else{let N=g[v-1]+p[v-1].length-b;h.push(Rm(t,p,g,x,v,b,N,null,a))}f.push(b+y-s)}}return d(e,n,i,r,0),(l||a)(h,f,o)}class yr{constructor(e,n,i,r,s=!1,o=!1){this.from=e,this.to=n,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],i=!1){let r=[new yr(0,e.length,e,0,!1,i)];for(let s of n)s.to>e.length&&r.push(s);return r}static applyChanges(e,n,i=128){if(!n.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l<n.length?n[l]:null,h=c?c.fromA:1e9;if(h-a>=i)for(;o&&o.from<h;){let f=o;if(a>=f.from||h<=f.to||u){let d=Math.max(f.from,a)-u,p=Math.min(f.to,h)-u;f=d>=p?null:new yr(d,p,f.tree,f.offset+u,l>0,!!c)}if(f&&r.push(f),o.to>h)break;o=s<e.length?e[s++]:null}if(!c)break;a=c.toA,u=c.toA-c.toB}return r}}class Ik{startParse(e,n,i){return typeof e=="string"&&(e=new cD(e)),i=i?i.length?i.map(r=>new Fh(r.from,r.to)):[new Fh(0,0)]:[new Fh(0,e.length)],this.createParse(e,n||[],i)}parse(e,n,i){let r=this.startParse(e,n,i);for(;;){let s=r.advance();if(s)return s}}}class cD{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new re({perNode:!0});var Vy={};class Qu{constructor(e,n,i,r,s,o,l,a,u,c=0,h){this.p=e,this.stack=n,this.state=i,this.reducePos=r,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,i=0){let r=e.parser.context;return new Qu(e,[],n,i,i,0,[],0,r?new Hy(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let i=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=s.dynamicPrecedence(r);if(l&&(this.score+=l),i==0){r<s.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r<s.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(r,this.reducePos);return}let a=this.stack.length-(i-1)*3-(e&262144?6:0),u=a?this.stack[a-2]:this.p.ranges[0].from;r<s.minRepeatTerm&&u==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-u;c>=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,f=this.bufferBase+this.buffer.length-h;if(r<s.minRepeatTerm||e&131072){let d=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,u,d,f+4,!0)}if(e&262144)this.state=this.stack[a];else{let d=this.stack[a-3];this.state=s.getGoto(d,r,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(r,u)}storeNode(e,n,i,r=4,s=!1){if(e==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==i)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,n,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)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,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,n,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(n,i),n<=this.p.parser.maxNode&&this.buffer.push(n,i,r,4);else{let s=e,{parser:o}=this.p;this.pos=r;let l=o.stateFlag(s,1);!l&&(r>i||n<=o.maxNode)&&(this.reducePos=r),this.pushState(s,l?i:Math.min(i,this.reducePos)),this.shiftContext(n,i),n<=o.maxNode&&this.buffer.push(n,i,r,4)}}apply(e,n,i,r){e&65536?this.reduce(e):this.shift(e,n,i,r)}useNode(e,n){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(n&&e.buffer[n-4]==0&&(n-=4);n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let i=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new Qu(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,i?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new hD(this);;){let i=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(i==0)return!1;if(!(i&65536))return!0;n.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let s=0,o;s<n.length;s+=2)(o=n[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&r.push(n[s],o);if(this.stack.length<120)for(let s=0;r.length<8&&s<n.length;s+=2){let o=n[s+1];r.some((l,a)=>a&1&&l==o)||r.push(n[s],o)}n=r}let i=[];for(let r=0;r<n.length&&i.length<4;r+=2){let s=n[r+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[r],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if(!(n&65536))return!1;if(!e.validAction(this.state,n)){let i=n>>19,r=n&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!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:e}=this.p,n=[],i=(r,s)=>{if(!n.includes(r))return n.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,s+1);if(l!=null)return l}})};return i(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:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new Hy(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Hy{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class hD{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class Xu{constructor(e,n,i){this.stack=e,this.pos=n,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Xu(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.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 Xu(this.stack,this.pos,this.index)}}function Aa(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let i=0,r=0;i<t.length;){let s=0;for(;;){let o=t.charCodeAt(i++),l=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}n?n[r++]=s:n=new e(s)}return n}class iu{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Wy=new iu;class fD{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Wy,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;s<i.from;){if(!r)return null;let o=this.ranges[--r];s-=i.from-o.to,i=o}for(;n<0?s>i.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,i,r;if(n>=0&&n<this.chunk.length)i=this.pos+e,r=this.chunk.charCodeAt(n);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(i=s,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,n=0){let i=n?this.resolveOffset(n,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>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,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=Wy,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,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let i="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return i}}class bs{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:i}=n.p;dD(this.data,e,n,this.id,i.data,i.tokenPrecTable)}}bs.prototype.contextual=bs.prototype.fallback=bs.prototype.extend=!1;bs.prototype.fallback=bs.prototype.extend=!1;function dD(t,e,n,i,r,s){let o=0,l=1<<i,{dialect:a}=n.p.parser;e:for(;l&t[o];){let u=t[o+1];for(let d=o+3;d<u;d+=2)if((t[d+1]&l)>0){let p=t[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||pD(p,e.token.value,r,s))){e.acceptToken(p);break}}let c=e.next,h=0,f=t[o+2];if(e.next<0&&f>h&&t[u+f*3-3]==65535){o=t[u+f*3-1];continue e}for(;h<f;){let d=h+f>>1,p=u+d+(d<<1),g=t[p],S=t[p+1]||65536;if(c<g)f=d;else if(c>=S)h=d+1;else{o=t[p+2],e.advance();continue e}}break}}function Uy(t,e,n){for(let i=e,r;(r=t[i])!=65535;i++)if(r==n)return i-e;return-1}function pD(t,e,n,i){let r=Uy(n,i,e);return r<0||Uy(n,i,t)<r}const Et=typeof process<"u"&&Vy&&/\bparse\b/.test(Vy.LOG);let Vh=null;function Ky(t,e,n){let i=t.cursor(_e.IncludeAnonymous);for(i.moveTo(e);;)if(!(n<0?i.childBefore(e):i.childAfter(e)))for(;;){if((n<0?i.to<e:i.from>e)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(t.length,Math.max(i.from+1,e+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:t.length}}class mD{constructor(e,n){this.fragments=e,this.nodeSet=n,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?Ky(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Ky(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 n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let i=this.trees[n],r=this.index[n];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[r],o=this.start[n]+i.positions[r];if(o>e)return this.nextStart=o,null;if(s instanceof Ie){if(o==e){if(o<this.safeFrom)return null;let l=o+s.length;if(l<=this.safeTo){let a=s.prop(re.lookAhead);if(!a||l+a<this.fragment.to)return s}}this.index[n]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class gD{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new iu)}getActions(e){let n=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;u<s.length;u++){if(!(1<<u&o))continue;let c=s[u],h=this.tokens[u];if(!(i&&!c.fallback)&&((c.contextual||h.start!=e.pos||h.mask!=o||h.context!=l)&&(this.updateCachedToken(h,c,e),h.mask=o,h.context=l),h.lookAhead>h.end+25&&(a=Math.max(h.lookAhead,a)),h.value!=0)){let f=n;if(h.extended>-1&&(n=this.addActions(e,h.extended,h.end,n)),n=this.addActions(e,h.value,h.end,n),!c.extend&&(i=h,n>f))break}}for(;this.actions.length>n;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new iu,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,n=this.addActions(e,i.value,i.end,n)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new iu,{pos:i,p:r}=e;return n.start=i,n.end=Math.min(i+1,r.stream.end),n.value=i==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,i){let r=this.stream.clipPos(i.pos);if(n.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let l=s.specializers[o](this.stream.read(e.start,e.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,i,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=n,this.actions[r++]=i,r}addActions(e,n,i,r){let{state:s}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let u=o.stateSlot(s,a?2:1);;u+=3){if(l[u]==65535)if(l[u+1]==1)u=qn(l,u+2);else{r==0&&l[u+1]==2&&(r=this.putAction(qn(l,u+2),n,i,r));break}l[u]==n&&(r=this.putAction(qn(l,u+1),n,i,r))}return r}}class yD{constructor(e,n,i,r){this.parser=e,this.input=n,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 fD(n,r),this.tokens=new gD(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[Qu.start(this,e.top[0],s)],this.fragments=i.length&&this.stream.end-s>e.bufferLength*4?new mD(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>n)i.push(l);else{if(this.advanceStack(l,i,e))continue;{r||(r=[],s=[]),r.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!i.length){let o=r&&wD(r);if(o)return Et&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Et&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return Et&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>n)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let l=i[o];for(let a=o+1;a<i.length;a++){let u=i[a];if(l.sameState(u)||l.buffer.length>500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].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,n,i){let r=e.pos,{parser:s}=this,o=Et?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let h=this.fragments.nodeAt(r);h;){let f=this.parser.nodeSet.types[h.type.id]==h.type?s.getGoto(e.state,h.type.id):-1;if(f>-1&&h.length&&(!u||(h.prop(re.contextHash)||0)==c))return e.useNode(h,f),Et&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(h.type.id)})`),!0;if(!(h instanceof Ie)||h.children.length==0||h.positions[0]>0)break;let d=h.children[0];if(d instanceof Ie&&h.positions[0]==0)h=d;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),Et&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;u<a.length;){let c=a[u++],h=a[u++],f=a[u++],d=u==a.length||!i,p=d?e:e.split(),g=this.tokens.mainToken;if(p.apply(c,h,g?g.start:p.pos,f),Et&&console.log(o+this.stackID(p)+` (via ${c&65536?`reduce of ${s.getName(c&65535)}`:"shift"} for ${s.getName(h)} @ ${r}${p==e?"":", split"})`),d)return!0;p.pos>r?n.push(p):i.push(p)}return!1}advanceFully(e,n){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return qy(e,n),!0}}runRecovery(e,n,i){let r=null,s=!1;for(let o=0;o<e.length;o++){let l=e[o],a=n[o<<1],u=n[(o<<1)+1],c=Et?this.stackID(l)+" -> ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),Et&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let h=l.split(),f=c;for(let d=0;d<10&&h.forceReduce()&&(Et&&console.log(f+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,i));d++)Et&&(f=this.stackID(h)+" -> ");for(let d of l.recoverByInsert(a))Et&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),Et&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),qy(l,i)):(!r||r.score<h.score)&&(r=h)}return r}stackToTree(e){return e.close(),Ie.build({buffer:Xu.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 n=(Vh||(Vh=new WeakMap)).get(e);return n||Vh.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function qy(t,e){for(let n=0;n<e.length;n++){let i=e[n];if(i.pos==t.pos&&i.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class vD{constructor(e,n,i){this.source=e,this.flags=n,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}class Gu extends Ik{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let l=0;l<e.repeatNodeCount;l++)n.push("");let i=Object.keys(e.topRules).map(l=>e.topRules[l][1]),r=[];for(let l=0;l<n.length;l++)r.push([]);function s(l,a,u){r[l].push([a,a.deserialize(String(u))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=re[a]);for(let u=1;u<l.length;){let c=l[u++];if(c>=0)s(c,a,l[u++]);else{let h=l[u+-c];for(let f=-c;f>0;f--)s(l[u++],a,h);u++}}}this.nodeSet=new Mm(n.map((l,a)=>bt.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:r[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Mk;let o=Aa(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(Yy),this.states=Aa(e.states,Uint32Array),this.data=Aa(e.stateData),this.goto=Aa(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new bs(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,i){let r=new yD(this,e,n,i);for(let s of this.wrappers)r=s(r,e,n,i);return r}getGoto(e,n,i=!1){let r=this.goto;if(n>=r[0])return-1;for(let s=r[n+1];;){let o=r[s++],l=o&1,a=r[s++];if(l&&i)return a;for(let u=s+(o>>1);s<u;s++)if(r[s]==e)return a;if(l)return-1}}hasAction(e,n){let i=this.data;for(let r=0;r<2;r++)for(let s=this.stateSlot(e,r?2:1),o;;s+=3){if((o=i[s])==65535)if(i[s+1]==1)o=i[s=qn(i,s+2)];else{if(i[s+1]==2)return qn(i,s+2);break}if(o==n||o==0)return qn(i,s+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,i=>i==n?!0:null)}allActions(e,n){let i=this.stateSlot(e,4),r=i?n(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=qn(this.data,s+2);else break;r=n(qn(this.data,s+1))}return r}nextStates(e){let n=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=qn(this.data,i+2);else break;if(!(this.data[i+2]&1)){let r=this.data[i+1];n.some((s,o)=>o&1&&s==r)||n.push(this.data[i],r)}}return n}configure(e){let n=Object.assign(Object.create(Gu.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=i}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(l=>l.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return n.specializers[r]=Yy(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),i=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;s<n.length;s++)if(!i[s])for(let o=this.dialects[n[s]],l;(l=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[l]=1;return new vD(e,i,r)}static deserialize(e){return new Gu(e)}}function qn(t,e){return t[e]|t[e+1]<<16}function wD(t){let e=null;for(let n of t){let i=n.p.stoppedAt;(n.pos==n.p.stream.end||i!=null&&n.pos>i)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function Yy(t){if(t.external){let e=t.extend?1:0;return(n,i)=>t.external(n,i)<<1|e}return t.get}let xD=0;class jt{constructor(e,n,i,r){this.name=e,this.set=n,this.base=i,this.modified=r,this.id=xD++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let i=typeof e=="string"?e:"?";if(e instanceof jt&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let r=new jt(i,[],null,[]);if(r.set.push(r),n)for(let s of n.set)r.set.push(s);return r}static defineModifier(e){let n=new Ju(e);return i=>i.modified.indexOf(n)>-1?i:Ju.get(i.base||i,i.modified.concat(n).sort((r,s)=>r.id-s.id))}}let SD=0;class Ju{constructor(e){this.name=e,this.instances=[],this.id=SD++}static get(e,n){if(!n.length)return e;let i=n[0].instances.find(l=>l.base==e&&kD(n,l.modified));if(i)return i;let r=[],s=new jt(e.name,r,e,n);for(let l of n)l.instances.push(s);let o=bD(n);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(Ju.get(l,a));return s}}function kD(t,e){return t.length==e.length&&t.every((n,i)=>n==e[i])}function bD(t){let e=[[]];for(let n=0;n<t.length;n++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(t[n]));return e.sort((n,i)=>i.length-n.length)}function Dk(t){let e=Object.create(null);for(let n in t){let i=t[n];Array.isArray(i)||(i=[i]);for(let r of n.split(" "))if(r){let s=[],o=2,l=r;for(let h=0;;){if(l=="..."&&h>0&&h+3==r.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+r);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),h+=f[0].length,h==r.length)break;let d=r[h++];if(h==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);l=r.slice(h)}let a=s.length-1,u=s[a];if(!u)throw new RangeError("Invalid path: "+r);let c=new Nl(i,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return Bk.add(e)}const Bk=new re({combine(t,e){let n,i,r;for(;t||e;){if(!t||e&&t.depth>=e.depth?(r=e,e=e.next):(r=t,t=t.next),n&&n.mode==r.mode&&!r.context&&!n.context)continue;let s=new Nl(r.tags,r.mode,r.context);n?n.next=s:i=s,n=s}return i}});class Nl{constructor(e,n,i,r){this.tags=e,this.mode=n,this.context=i,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}}Nl.empty=new Nl([],2,null);function Lk(t,e){let n=Object.create(null);for(let s of t)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:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let u=n[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:i}}function CD(t,e){let n=null;for(let i of t){let r=i.style(e);r&&(n=n?n+" "+r:r)}return n}function ED(t,e,n,i=0,r=t.length){let s=new ND(i,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),i,r,"",s.highlighters),s.flush(r)}class ND{constructor(e,n,i){this.at=e,this.highlighters=n,this.span=i,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,i,r,s){let{type:o,from:l,to:a}=e;if(l>=i||a<=n)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let u=r,c=_D(e)||Nl.empty,h=CD(s,c.tags);if(h&&(u&&(u+=" "),u+=h,c.mode==1&&(r+=(r?" ":"")+h)),this.startSpan(Math.max(n,l),u),c.opaque)return;let f=e.tree&&e.tree.prop(re.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+l,1),p=this.highlighters.filter(S=>!S.scope||S.scope(f.tree.type)),g=e.firstChild();for(let S=0,m=l;;S++){let y=S<f.overlay.length?f.overlay[S]:null,v=y?y.from+l:a,x=Math.max(n,m),b=Math.min(i,v);if(x<b&&g)for(;e.from<b&&(this.highlightRange(e,x,b,r,s),this.startSpan(Math.min(b,e.to),u),!(e.to>=v||!e.nextSibling())););if(!y||v>i)break;m=y.to+l,m>n&&(this.highlightRange(d.cursor(),Math.max(n,y.from+l),Math.min(i,m),"",p),this.startSpan(Math.min(i,m),u))}g&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=n)){if(e.from>=i)break;this.highlightRange(e,n,i,r,s),this.startSpan(Math.min(i,e.to),u)}while(e.nextSibling());e.parent()}}}function _D(t){let e=t.type.prop(Bk);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const K=jt.define,Ta=K(),gi=K(),Qy=K(gi),Xy=K(gi),yi=K(),Ma=K(yi),Hh=K(yi),_n=K(),tr=K(_n),En=K(),Nn=K(),Hd=K(),go=K(Hd),Oa=K(),X={comment:Ta,lineComment:K(Ta),blockComment:K(Ta),docComment:K(Ta),name:gi,variableName:K(gi),typeName:Qy,tagName:K(Qy),propertyName:Xy,attributeName:K(Xy),className:K(gi),labelName:K(gi),namespace:K(gi),macroName:K(gi),literal:yi,string:Ma,docString:K(Ma),character:K(Ma),attributeValue:K(Ma),number:Hh,integer:K(Hh),float:K(Hh),bool:K(yi),regexp:K(yi),escape:K(yi),color:K(yi),url:K(yi),keyword:En,self:K(En),null:K(En),atom:K(En),unit:K(En),modifier:K(En),operatorKeyword:K(En),controlKeyword:K(En),definitionKeyword:K(En),moduleKeyword:K(En),operator:Nn,derefOperator:K(Nn),arithmeticOperator:K(Nn),logicOperator:K(Nn),bitwiseOperator:K(Nn),compareOperator:K(Nn),updateOperator:K(Nn),definitionOperator:K(Nn),typeOperator:K(Nn),controlOperator:K(Nn),punctuation:Hd,separator:K(Hd),bracket:go,angleBracket:K(go),squareBracket:K(go),paren:K(go),brace:K(go),content:_n,heading:tr,heading1:K(tr),heading2:K(tr),heading3:K(tr),heading4:K(tr),heading5:K(tr),heading6:K(tr),contentSeparator:K(_n),list:K(_n),quote:K(_n),emphasis:K(_n),strong:K(_n),link:K(_n),monospace:K(_n),strikethrough:K(_n),inserted:K(),deleted:K(),changed:K(),invalid:K(),meta:Oa,documentMeta:K(Oa),annotation:K(Oa),processingInstruction:K(Oa),definition:jt.defineModifier("definition"),constant:jt.defineModifier("constant"),function:jt.defineModifier("function"),standard:jt.defineModifier("standard"),local:jt.defineModifier("local"),special:jt.defineModifier("special")};for(let t in X){let e=X[t];e instanceof jt&&(e.name=t)}Lk([{tag:X.link,class:"tok-link"},{tag:X.heading,class:"tok-heading"},{tag:X.emphasis,class:"tok-emphasis"},{tag:X.strong,class:"tok-strong"},{tag:X.keyword,class:"tok-keyword"},{tag:X.atom,class:"tok-atom"},{tag:X.bool,class:"tok-bool"},{tag:X.url,class:"tok-url"},{tag:X.labelName,class:"tok-labelName"},{tag:X.inserted,class:"tok-inserted"},{tag:X.deleted,class:"tok-deleted"},{tag:X.literal,class:"tok-literal"},{tag:X.string,class:"tok-string"},{tag:X.number,class:"tok-number"},{tag:[X.regexp,X.escape,X.special(X.string)],class:"tok-string2"},{tag:X.variableName,class:"tok-variableName"},{tag:X.local(X.variableName),class:"tok-variableName tok-local"},{tag:X.definition(X.variableName),class:"tok-variableName tok-definition"},{tag:X.special(X.variableName),class:"tok-variableName2"},{tag:X.definition(X.propertyName),class:"tok-propertyName tok-definition"},{tag:X.typeName,class:"tok-typeName"},{tag:X.namespace,class:"tok-namespace"},{tag:X.className,class:"tok-className"},{tag:X.macroName,class:"tok-macroName"},{tag:X.propertyName,class:"tok-propertyName"},{tag:X.operator,class:"tok-operator"},{tag:X.comment,class:"tok-comment"},{tag:X.meta,class:"tok-meta"},{tag:X.invalid,class:"tok-invalid"},{tag:X.punctuation,class:"tok-punctuation"}]);const AD=Dk({String:X.string,Number:X.number,"True False":X.bool,PropertyName:X.propertyName,Null:X.null,", :":X.separator,"[ ]":X.squareBracket,"{ }":X.brace}),TD=Gu.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:[AD],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});var Wh;const ss=new re;function MD(t){return ee.define({combine:t?e=>e.concat(t):void 0})}const OD=new re;class hn{constructor(e,n,i=[],r=""){this.data=e,this.name=r,ae.prototype.hasOwnProperty("tree")||Object.defineProperty(ae.prototype,"tree",{get(){return Gt(this)}}),this.parser=n,this.extension=[Ws.of(this),ae.languageData.of((s,o,l)=>{let a=Gy(s,o,l),u=a.type.prop(ss);if(!u)return[];let c=s.facet(u),h=a.type.prop(OD);if(h){let f=a.resolve(o-a.from,l);for(let d of h)if(d.test(f,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(e,n,i=-1){return Gy(e,n,i).type.prop(ss)==this.data}findRegions(e){let n=e.facet(Ws);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(ss)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(re.mounted);if(l){if(l.tree.prop(ss)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<s.children.length;a++){let u=s.children[a];u instanceof Ie&&r(u,s.positions[a]+o)}};return r(Gt(e),0),i}get allowsNesting(){return!0}}hn.setState=me.define();function Gy(t,e,n){let i=t.facet(Ws),r=Gt(t).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,n,_e.ExcludeBuffers|_e.EnterBracketed))s.type.isTop&&(r=s);return r}class Zu extends hn{constructor(e,n,i){super(e,n,[],i),this.parser=n}static define(e){let n=MD(e.languageData);return new Zu(n,e.parser.configure({props:[ss.add(i=>i.isTop?n:void 0)]}),e.name)}configure(e,n){return new Zu(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Gt(t){let e=t.field(hn.state,!1);return e?e.tree:Ie.empty}class PD{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,n){let i=this.cursorPos-this.string.length;return e<i||n>=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-i,n-i)}}let yo=null;class ec{constructor(e,n,i=[],r,s,o,l,a){this.parser=e,this.state=n,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,n,i){return new ec(e,n,[],Ie.empty,0,i,[],null)}startParse(){return this.parser.startParse(new PD(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Ie.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}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 r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(yr.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,n;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(yr.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=yo;yo=this;try{return e()}finally{yo=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Jy(e,n.from,n.to);return e}changes(e,n){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,h,f)=>a.push({fromA:u,toA:c,fromB:h,toB:f})),i=yr.applyChanges(i,a),r=Ie.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),h=e.mapPos(u.to,-1);c<h&&l.push({from:c,to:h})}}}return new ec(this.parser,n,i,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let n=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=Jy(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends Ik{createParse(n,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=yo;if(a){for(let u of r)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Ie(bt.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return yo}}function Jy(t,e,n){return yr.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class Hs{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,i)||n.takeTree(),new Hs(n)}static init(e){let n=Math.min(3e3,e.doc.length),i=ec.create(e.facet(Ws).parser,e,{from:0,to:n});return i.work(20,n)||i.takeTree(),new Hs(i)}}hn.state=ui.define({create:Hs.init,update(t,e){for(let n of e.effects)if(n.is(hn.setState))return n.value;return e.startState.facet(Ws)!=e.state.facet(Ws)?Hs.init(e.state):t.apply(e)}});let zk=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(zk=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Uh=typeof navigator<"u"&&(!((Wh=navigator.scheduling)===null||Wh===void 0)&&Wh.isInputPending)?()=>navigator.scheduling.isInputPending():null,RD=$n.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(hn.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(hn.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=zk(this.work))}work(e){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:i,viewport:{to:r}}=this.view,s=i.field(hn.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Uh?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>Uh&&Uh()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:hn.setState.of(new Hs(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Mt(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ws=ee.define({combine(t){return t.length?t[0]:null},enables:t=>[hn.state,RD,J.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class ID{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const DD=ee.define(),Im=ee.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function tc(t){let e=t.facet(Im);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function nc(t,e){let n="",i=t.tabSize,r=t.facet(Im)[0];if(r==" "){for(;e>=i;)n+=" ",e-=i;r=" "}for(let s=0;s<e;s++)n+=r;return n}function $k(t,e){t instanceof ae&&(t=new Lc(t));for(let i of t.state.facet(DD)){let r=i(t,e);if(r!==void 0)return r}let n=Gt(t.state);return n.length>=e?BD(t,n,e):null}class Lc{constructor(e,n={}){this.state=e,this.options=n,this.unit=tc(e)}lineAt(e,n=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(n<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,n=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,n);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,n=1){let{text:i,from:r}=this.lineAt(e,n),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,n=e.length){return Oc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:i,from:r}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const jk=new re;function BD(t,e,n){let i=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let s=[];for(let o=r;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return Fk(i,t,n)}function Fk(t,e,n){for(let i=t;i;i=i.next){let r=zD(i.node);if(r)return r(Dm.create(e,n,i))}return 0}function LD(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function zD(t){let e=t.type.prop(jk);if(e)return e;let n=t.firstChild,i;if(n&&(i=n.type.prop(re.closedBy))){let r=t.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>VD(o,!0,1,void 0,s&&!LD(o)?r.from:void 0)}return t.parent==null?$D:null}function $D(){return 0}class Dm extends Lc{constructor(e,n,i){super(e.state,e.options),this.base=e,this.pos=n,this.context=i}get node(){return this.context.node}static create(e,n,i){return new Dm(e,n,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(n.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(jD(i,e))break;n=this.state.doc.lineAt(i.from)}return this.lineIndent(n.from)}continue(){return Fk(this.context.next,this.base,this.pos)}}function jD(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function FD(t){let e=t.node,n=e.childAfter(e.from),i=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=n.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}l=a.to}}function VD(t,e,n,i,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==t.pos+o,a=FD(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function Zy({except:t,units:e=1}={}){return n=>{let i=t&&t.test(n.textAfter);return n.baseIndent+(i?0:e*n.unit)}}const HD=new re;function WD(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}class zc{constructor(e,n){this.specs=e;let i;function r(l){let a=ji.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const s=typeof n.all=="string"?n.all:n.all?r(n.all):void 0,o=n.scope;this.scope=o instanceof hn?l=>l.prop(ss)==o.data:o?l=>l==o:void 0,this.style=Lk(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new ji(i):null,this.themeType=n.themeType}static define(e,n){return new zc(e,n||{})}}const Wd=ee.define(),UD=ee.define({combine(t){return t.length?[t[0]]:null}});function Kh(t){let e=t.facet(Wd);return e.length?e:t.facet(UD)}function KD(t,e){let n=[YD],i;return t instanceof zc&&(t.module&&n.push(J.styleModule.of(t.module)),i=t.themeType),i?n.push(Wd.computeN([J.darkTheme],r=>r.facet(J.darkTheme)==(i=="dark")?[t]:[])):n.push(Wd.of(t)),n}class qD{constructor(e){this.markCache=Object.create(null),this.tree=Gt(e.state),this.decorations=this.buildDeco(e,Kh(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=Gt(e.state),i=Kh(e.state),r=i!=Kh(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length<s.to&&!r&&n.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||r)&&(this.tree=n,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Me.none;let i=new wl;for(let{from:r,to:s}of e.visibleRanges)ED(this.tree,n,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=Me.mark({class:a})))},r,s);return i.finish()}}const YD=Bl.high($n.fromClass(qD,{decorations:t=>t.decorations})),QD=1e4,XD="()[]{}",GD=new re;function Ud(t,e,n){let i=t.prop(e<0?re.openedBy:re.closedBy);if(i)return i;if(t.name.length==1){let r=n.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[n[r+e]]}return null}function Kd(t){let e=t.type.prop(GD);return e?e(t.node):t}function os(t,e,n,i={}){let r=i.maxScanDistance||QD,s=i.brackets||XD,o=Gt(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=Ud(a.type,n,s);if(u&&a.from<a.to){let c=Kd(a);if(c&&(n>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return JD(t,e,n,a,c,u,s)}}return ZD(t,e,n,o,l.type,r,s)}function JD(t,e,n,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},u=0,c=l==null?void 0:l.cursor();if(c&&(n<0?c.childBefore(i.from):c.childAfter(i.to)))do if(n<0?c.to<=i.from:c.from>=i.to){if(u==0&&s.indexOf(c.type.name)>-1&&c.from<c.to){let h=Kd(c);return{start:a,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(Ud(c.type,n,o))u++;else if(Ud(c.type,-n,o)){if(u==0){let h=Kd(c);return{start:a,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}u--}}while(n<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function ZD(t,e,n,i,r,s,o){if(n<0?!e:e==t.doc.length)return null;let l=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=n>0)return null;let u={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),h=0;for(let f=0;!c.next().done&&f<=s;){let d=c.value;n<0&&(f+=d.length);let p=e+f*n;for(let g=n>0?0:d.length-1,S=n>0?d.length:-1;g!=S;g+=n){let m=o.indexOf(d[g]);if(!(m<0||i.resolveInner(p+g,1).type!=r))if(m%2==0==n>0)h++;else{if(h==1)return{start:u,end:{from:p+g,to:p+g+1},matched:m>>1==a>>1};h--}}n>0&&(f+=d.length)}return c.done?{start:u,matched:!1}:null}const e3=Object.create(null),ev=[bt.none],tv=[],nv=Object.create(null),t3=Object.create(null);for(let[t,e]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"]])t3[t]=n3(e3,e);function qh(t,e){tv.indexOf(t)>-1||(tv.push(t),console.warn(e))}function n3(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||X[u];c?typeof c=="function"?a.length?a=a.map(c):qh(u,`Modifier ${u} used at start of tag`):a.length?qh(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:qh(u,`Unknown highlighting tag ${u}`)}for(let u of a)n.push(u)}if(!n.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+n.map(l=>l.id),s=nv[r];if(s)return s.id;let o=nv[r]=bt.define({id:ev.length,name:i,props:[Dk({[i]:n})]});return ev.push(o),o.id}Te.RTL,Te.LTR;const i3=Zu.define({name:"json",parser:TD.configure({props:[jk.add({Object:Zy({except:/^\s*\}/}),Array:Zy({except:/^\s*\]/})}),HD.add({"Object Array":WD})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function r3(){return new ID(i3)}class Vk{constructor(e,n,i,r){this.state=e,this.pos=n,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=Gt(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),i=Math.max(n.from,this.pos-250),r=n.text.slice(i-n.from,this.pos-n.from),s=r.search(Hk(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function iv(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function s3(t){let e=Object.create(null),n=Object.create(null);for(let{label:r}of t){e[r[0]]=!0;for(let s=1;s<r.length;s++)n[r[s]]=!0}let i=iv(e)+iv(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function o3(t){let e=t.map(r=>typeof r=="string"?{label:r}:r),[n,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:s3(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:n}:null}}class rv{constructor(e,n,i,r){this.completion=e,this.source=n,this.match=i,this.score=r}}function vr(t){return t.selection.main.from}function Hk(t,e){var n;let{source:i}=t,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?t:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const Wk=Fn.define();function l3(t,e,n,i){let{main:r}=t.selection,s=n-r.from,o=i-r.from;return{...t.changeByRange(l=>{if(l!=r&&n!=i&&t.sliceDoc(l.from+s,l.from+o)!=t.sliceDoc(n,i))return{range:l};let a=t.toText(e);return{changes:{from:l.from+s,to:i==r.from?l.to:l.from+o,insert:a},range:V.cursor(l.from+s+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const sv=new WeakMap;function a3(t){if(!Array.isArray(t))return t;let e=sv.get(t);return e||sv.set(t,e=o3(t)),e}const ic=me.define(),_l=me.define();class u3{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let i=sr(e,n),r=Hr(i);this.chars.push(i);let s=e.slice(n,n+r),o=s.toUpperCase();this.folded.push(sr(o==s?s.toLowerCase():o,0)),n+=r}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:i,any:r,precise:s,byWord:o}=this;if(n.length==1){let y=sr(e,0),v=Hr(y),x=v==e.length?0:-100;if(y!=n[0])if(y==i[0])x+=-200;else return null;return this.ret(x,[0,v])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=n.length,u=0;if(l<0){for(let y=0,v=Math.min(e.length,200);y<v&&u<a;){let x=sr(e,y);(x==n[u]||x==i[u])&&(r[u++]=y),y+=Hr(x)}if(u<a)return null}let c=0,h=0,f=!1,d=0,p=-1,g=-1,S=/[a-z]/.test(e),m=!0;for(let y=0,v=Math.min(e.length,200),x=0;y<v&&h<a;){let b=sr(e,y);l<0&&(c<a&&b==n[c]&&(s[c++]=y),d<a&&(b==n[d]||b==i[d]?(d==0&&(p=y),g=y+1,d++):d=0));let C,N=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(C=KP(b))!=C.toLowerCase()?1:C!=C.toUpperCase()?2:0;(!y||N==1&&S||x==0&&N!=0)&&(n[h]==b||i[h]==b&&(f=!0)?o[h++]=y:o.length&&(m=!1)),x=N,y+=Hr(b)}return h==a&&o[0]==0&&m?this.result(-100+(f?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,g]):h==a?this.result(-100+(f?-200:0)+-700+(m?0:-1100),o,e):n.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,n,i){let r=[],s=0;for(let o of n){let l=o+(this.astral?Hr(sr(i,o)):1);s&&r[s-1]==o?r[s-1]=l:(r[s++]=o,r[s++]=l)}return this.ret(e-i.length,r)}}class c3{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let n=e.slice(0,this.pattern.length),i=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,n.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const Ve=ee.define({combine(t){return PS(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:h3,filterStrict:!1,compareCompletions:(e,n)=>(e.sortText||e.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>i=>ov(e(i),n(i)),optionClass:(e,n)=>i=>ov(e(i),n(i)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function ov(t,e){return t?e?t+" "+e:t:e}function h3(t,e,n,i,r,s){let o=t.textDirection==Te.RTL,l=o,a=!1,u="top",c,h,f=e.left-r.left,d=r.right-e.right,p=i.right-i.left,g=i.bottom-i.top;if(l&&f<Math.min(p,d)?l=!1:!l&&d<Math.min(p,f)&&(l=!0),p<=(l?f:d))c=Math.max(r.top,Math.min(n.top,r.bottom-g))-e.top,h=Math.min(400,l?f:d);else{a=!0,h=Math.min(400,(o?e.right:r.right-e.left)-30);let y=r.bottom-e.bottom;y>=g||y>e.top?c=n.bottom-e.top:(u="bottom",c=e.bottom-n.top)}let S=(e.bottom-e.top)/s.offsetHeight,m=(e.right-e.left)/s.offsetWidth;return{style:`${u}: ${c/S}px; max-width: ${h/m}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const Bm=me.define();function f3(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),n.type&&i.classList.add(...n.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(n,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let l=n.displayLabel||n.label,a=0;for(let u=0;u<s.length;){let c=s[u++],h=s[u++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(l.slice(c,h))),f.className="cm-completionMatchedText",a=h}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(n){if(!n.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=n.detail,i},position:80}),e.sort((n,i)=>n.position-i.position).map(n=>n.render)}function Yh(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let r=Math.floor(e/n);return{from:r*n,to:(r+1)*n}}let i=Math.ceil((t-e)/n);return{from:t-i*n,to:t-(i-1)*n}}class d3{constructor(e,n,i){this.view=e,this.stateField=n,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let r=e.state.field(n),{options:s,selected:o}=r.open,l=e.state.facet(Ve);this.optionContent=f3(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=Yh(s.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:u}=e.state.field(n).open;for(let c=a.target,h;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(h=/-(\d+)$/.exec(c.id))&&+h[1]<u.length){this.applyCompletion(e,u[+h[1]]),a.preventDefault();return}if(a.target==this.list){let c=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;c!=null&&(e.dispatch({effects:Bm.of(c)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let u=e.state.field(this.stateField,!1);u&&u.tooltip&&e.state.facet(Ve).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:_l.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:l}=i.open;(!r.open||r.open.options!=s)&&(this.range=Yh(s.length,o,e.state.facet(Ve).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),l!=((n=r.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of n.split(" "))i&&this.dom.classList.add(i);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=Yh(n.options.length,n.selected,this.view.state.facet(Ve).maxRenderedOptions),this.showOptions(n.options,e.id));let i=this.updateSelectedOption(n.selected);if(i){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:s}=r;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(r);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,r)}).catch(l=>Mt(this.view.state,l,"completion info")):(this.addInfoPane(o,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,n){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),n=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return n&&m3(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(s.bottom,n.bottom)-10||r.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(Ve).positionInfo(this.view,n,r,i,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,n,i){const r=document.createElement("ul");r.id=n,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",o=>{o.target==r&&o.preventDefault()});let s=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:u}=l;if(u){let f=typeof u=="string"?u:u.name;if(f!=s&&(o>i.from||i.from==0))if(s=f,typeof u!="string"&&u.header)r.appendChild(u.header(u));else{let d=r.appendChild(document.createElement("completion-section"));d.textContent=f}}const c=r.appendChild(document.createElement("li"));c.id=n+"-"+o,c.setAttribute("role","option");let h=this.optionClass(l);h&&(c.className=h);for(let f of this.optionContent){let d=f(l,this.view.state,this.view,a);d&&c.appendChild(d)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function p3(t,e){return n=>new d3(n,t,e)}function m3(t,e){let n=t.getBoundingClientRect(),i=e.getBoundingClientRect(),r=n.height/t.offsetHeight;i.top<n.top?t.scrollTop-=(n.top-i.top)/r:i.bottom>n.bottom&&(t.scrollTop+=(i.bottom-n.bottom)/r)}function lv(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function g3(t,e){let n=[],i=null,r=null,s=c=>{n.push(c);let{section:h}=c.completion;if(h){i||(i=[]);let f=typeof h=="string"?h:h.name;i.some(d=>d.name==f)||i.push(typeof h=="string"?{name:f}:h)}},o=e.facet(Ve);for(let c of t)if(c.hasResult()){let h=c.result.getMatch;if(c.result.filter===!1)for(let f of c.result.options)s(new rv(f,c.source,h?h(f):[],1e9-n.length));else{let f=e.sliceDoc(c.from,c.to),d,p=o.filterStrict?new c3(f):new u3(f);for(let g of c.result.options)if(d=p.match(g.label)){let S=g.displayLabel?h?h(g,d.matched):[]:d.matched,m=d.score+(g.boost||0);if(s(new rv(g,c.source,S,m)),typeof g.section=="object"&&g.section.rank==="dynamic"){let{name:y}=g.section;r||(r=Object.create(null)),r[y]=Math.max(m,r[y]||-1e9)}}}}if(i){let c=Object.create(null),h=0,f=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?r[p.name]-r[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of i.sort(f))h-=1e5,c[d.name]=h;for(let d of n){let{section:p}=d.completion;p&&(d.score+=c[typeof p=="string"?p:p.name])}}let l=[],a=null,u=o.compareCompletions;for(let c of n.sort((h,f)=>f.score-h.score||u(h.completion,f.completion))){let h=c.completion;!a||a.label!=h.label||a.detail!=h.detail||a.type!=null&&h.type!=null&&a.type!=h.type||a.apply!=h.apply||a.boost!=h.boost?l.push(c):lv(c.completion)>lv(a)&&(l[l.length-1]=c),a=c.completion}return l}class ls{constructor(e,n,i,r,s,o){this.options=e,this.attrs=n,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new ls(this.options,av(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,i,r,s,o){if(r&&!o&&e.some(u=>u.isPending))return r.setDisabled();let l=g3(e,n);if(!l.length)return r&&e.some(u=>u.isPending)?r.setDisabled():null;let a=n.facet(Ve).selectOnOpen?0:-1;if(r&&r.selected!=a&&r.selected!=-1){let u=r.options[r.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==u){a=c;break}}return new ls(l,av(i,a),{pos:e.reduce((u,c)=>c.hasResult()?Math.min(u,c.from):u,1e8),create:k3,above:s.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new ls(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new ls(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class rc{constructor(e,n,i){this.active=e,this.id=n,this.open=i}static start(){return new rc(x3,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,i=n.facet(Ve),s=(i.override||n.languageDataAt("autocomplete",vr(n)).map(a3)).map(a=>(this.active.find(c=>c.source==a)||new Wt(a,this.active.some(c=>c.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((a,u)=>a==this.active[u])&&(s=this.active);let o=this.open,l=e.effects.some(a=>a.is(Lm));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!y3(s,this.active)||l?o=ls.build(s,n,this.id,o,i,l):o&&o.disabled&&!s.some(a=>a.isPending)&&(o=null),!o&&s.every(a=>!a.isPending)&&s.some(a=>a.hasResult())&&(s=s.map(a=>a.hasResult()?new Wt(a.source,0):a));for(let a of e.effects)a.is(Bm)&&(o=o&&o.setSelected(a.value,this.id));return s==this.active&&o==this.open?this:new rc(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?v3:w3}}function y3(t,e){if(t==e)return!0;for(let n=0,i=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;i<e.length&&!e[i].hasResult();)i++;let r=n==t.length,s=i==e.length;if(r||s)return r==s;if(t[n++].result!=e[i++].result)return!1}}const v3={"aria-autocomplete":"list"},w3={};function av(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const x3=[];function Uk(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(Wk);if(i&&e.activateOnCompletion(i))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Wt{constructor(e,n,i=!1){this.source=e,this.state=n,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let i=Uk(e,n),r=this;(i&8||i&16&&this.touches(e))&&(r=new Wt(r.source,0)),i&4&&r.state==0&&(r=new Wt(this.source,1)),r=r.updateFor(e,i);for(let s of e.effects)if(s.is(ic))r=new Wt(r.source,1,s.value);else if(s.is(_l))r=new Wt(r.source,0);else if(s.is(Lm))for(let o of s.value)o.source==r.source&&(r=o);return r}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(vr(e.state))}}class Cs extends Wt{constructor(e,n,i,r,s,o){super(e,3,n),this.limit=i,this.result=r,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,n){var i;if(!(n&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=vr(e.state);if(l>o||!r||n&2&&(vr(e.startState)==this.from||l<this.limit))return new Wt(this.source,n&4?1:0);let a=e.changes.mapPos(this.limit);return S3(r.validFor,e.state,s,o)?new Cs(this.source,this.explicit,a,r,s,o):r.update&&(r=r.update(r,s,o,new Vk(e.state,l,!1)))?new Cs(this.source,this.explicit,a,r,r.from,(i=r.to)!==null&&i!==void 0?i:vr(e.state)):new Wt(this.source,1,this.explicit)}map(e){if(e.empty)return this;let n=this.result.map?this.result.map(this.result,e):this.result;return n?new Cs(this.source,this.explicit,e.mapPos(this.limit),n,e.mapPos(this.from),e.mapPos(this.to,1)):new Wt(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function S3(t,e,n,i){if(!t)return!1;let r=e.sliceDoc(n,i);return typeof t=="function"?t(r,n,i,e):Hk(t,!0).test(r)}const Lm=me.define({map(t,e){return t.map(n=>n.map(e))}}),mt=ui.define({create(){return rc.start()},update(t,e){return t.update(e)},provide:t=>[Ak.from(t,e=>e.tooltip),J.contentAttributes.from(t,e=>e.attrs)]});function zm(t,e){const n=e.completion.apply||e.completion.label;let i=t.state.field(mt).active.find(r=>r.source==e.source);return i instanceof Cs?(typeof n=="string"?t.dispatch({...l3(t.state,n,i.from,i.to),annotations:Wk.of(e.completion)}):n(t,e.completion,i.from,i.to),!0):!1}const k3=p3(mt,zm);function Pa(t,e="option"){return n=>{let i=n.state.field(mt,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(Ve).interactionDelay)return!1;let r=1,s;e=="page"&&(s=Tk(n,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+r*(t?1:-1):t?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),n.dispatch({effects:Bm.of(l)}),!0}}const b3=t=>{let e=t.state.field(mt,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(Ve).interactionDelay?!1:zm(t,e.open.options[e.open.selected])},Qh=t=>t.state.field(mt,!1)?(t.dispatch({effects:ic.of(!0)}),!0):!1,C3=t=>{let e=t.state.field(mt,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:_l.of(null)}),!0)};class E3{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const N3=50,_3=1e3,A3=$n.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(mt).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(mt),n=t.state.facet(Ve);if(!t.selectionSet&&!t.docChanged&&t.startState.field(mt)==e)return;let i=t.transactions.some(s=>{let o=Uk(s,n);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(i||o.context.abortOnDocChange&&t.docChanged||o.updates.length+t.transactions.length>N3&&Date.now()-o.time>_3){for(let l of o.context.abortListeners)try{l()}catch(a){Mt(this.view.state,a)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(s=>s.effects.some(o=>o.is(ic)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of t.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(mt);for(let n of e.active)n.isPending&&!this.running.some(i=>i.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ve).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=vr(e),i=new Vk(e,n,t.explicit,this.view),r=new E3(t,i);this.running.push(r),Promise.resolve(t.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:_l.of(null)}),Mt(this.view.state,s)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ve).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(Ve),i=this.view.state.field(mt);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(s.done===void 0)continue;if(this.running.splice(r--,1),s.done){let l=vr(s.updates.length?s.updates[0].startState:this.view.state),a=Math.min(l,s.done.from+(s.active.explicit?0:1)),u=new Cs(s.active.source,s.active.explicit,a,s.done,s.done.from,(t=s.done.to)!==null&&t!==void 0?t:l);for(let c of s.updates)u=u.update(c,n);if(u.hasResult()){e.push(u);continue}}let o=i.active.find(l=>l.source==s.active.source);if(o&&o.isPending)if(s.done==null){let l=new Wt(s.active.source,0);for(let a of s.updates)l=l.update(a,n);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Lm.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(mt,!1);if(e&&e.tooltip&&this.view.state.facet(Ve).closeOnBlur){let n=e.open&&Tk(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:_l.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:ic.of(!1)}),20),this.composing=0}}}),T3=typeof navigator=="object"&&/Win/.test(navigator.platform),M3=Bl.highest(J.domEventHandlers({keydown(t,e){let n=e.state.field(mt,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(T3&&t.altKey)||t.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(o=>o.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&zm(e,i),!1}})),O3=J.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Kk=new class extends $i{};Kk.startSide=1;Kk.endSide=-1;function P3(t={}){return[M3,mt,Ve.of(t),A3,I3,O3]}const R3=[{key:"Ctrl-Space",run:Qh},{mac:"Alt-`",run:Qh},{mac:"Alt-i",run:Qh},{key:"Escape",run:C3},{key:"ArrowDown",run:Pa(!0)},{key:"ArrowUp",run:Pa(!1)},{key:"PageDown",run:Pa(!0,"page")},{key:"PageUp",run:Pa(!1,"page")},{key:"Enter",run:b3}],I3=Bl.highest(Tm.computeN([Ve],t=>t.facet(Ve).defaultKeymap?[R3]:[])),D3=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),i=jm(t.state,n.from);return i.line?B3(t):i.block?z3(t):!1};function $m(t,e){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=t(e,n);return r?(i(n.update(r)),!0):!1}}const B3=$m(F3,0),L3=$m(qk,0),z3=$m((t,e)=>qk(t,e,j3(e)),0);function jm(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const vo=50;function $3(t,{open:e,close:n},i,r){let s=t.sliceDoc(i-vo,i),o=t.sliceDoc(r,r+vo),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,u=s.length-l;if(s.slice(u-e.length,u)==e&&o.slice(a,a+n.length)==n)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let c,h;r-i<=2*vo?c=h=t.sliceDoc(i,r):(c=t.sliceDoc(i,i+vo),h=t.sliceDoc(r-vo,r));let f=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(h)[0].length,p=h.length-d-n.length;return c.slice(f,f+e.length)==e&&h.slice(p,p+n.length)==n?{open:{pos:i+f+e.length,margin:/\s/.test(c.charAt(f+e.length))?1:0},close:{pos:r-d-n.length,margin:/\s/.test(h.charAt(p-1))?1:0}}:null}function j3(t){let e=[];for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),r=n.to<=i.to?i:t.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function qk(t,e,n=e.selection.ranges){let i=n.map(s=>jm(e,s.from).block);if(!i.every(s=>s))return null;let r=n.map((s,o)=>$3(e,i[o],s.from,s.to));if(t!=2&&!r.every(s=>s))return{changes:e.changes(n.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(t!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=i[o],{open:u,close:c}=l;s.push({from:u.pos-a.open.length,to:u.pos+u.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:s}}return null}function F3(t,e,n=e.selection.ranges){let i=[],r=-1;e:for(let{from:s,to:o}of n){let l=i.length,a=1e9,u;for(let c=s;c<=o;){let h=e.doc.lineAt(c);if(u==null&&(u=jm(e,h.from).line,!u))continue e;if(h.from>r&&(s==o||o>h.from)){r=h.from;let f=/^\s*/.exec(h.text)[0].length,d=f==h.length,p=h.text.slice(f,f+u.length)==u?f:-1;f<h.text.length&&f<a&&(a=f),i.push({line:h,comment:p,token:u,indent:f,empty:d,single:!1})}c=h.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}if(t!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:u,empty:c,single:h}of i)(h||!c)&&s.push({from:l.from+u,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,s.push({from:u,to:c})}return{changes:s}}return null}const qd=Fn.define(),V3=Fn.define(),H3=ee.define(),Yk=ee.define({combine(t){return PS(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(i,r)=>e(i,r)||n(i,r)})}}),Qk=ui.define({create(){return In.empty},update(t,e){let n=e.state.facet(Yk),i=e.annotation(qd);if(i){let a=wt.fromTransaction(e,i.selection),u=i.side,c=u==0?t.undone:t.done;return a?c=sc(c,c.length,n.minDepth,a):c=Jk(c,e.startState.selection),new In(u==0?i.rest:c,u==0?c:i.rest)}let r=e.annotation(V3);if((r=="full"||r=="before")&&(t=t.isolate()),e.annotation(je.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=wt.fromTransaction(e),o=e.annotation(je.time),l=e.annotation(je.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),(r=="full"||r=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new In(t.done.map(wt.fromJSON),t.undone.map(wt.fromJSON))}});function W3(t={}){return[Qk,Yk.of(t),J.domEventHandlers({beforeinput(e,n){let i=e.inputType=="historyUndo"?Xk:e.inputType=="historyRedo"?Yd:null;return i?(e.preventDefault(),i(n)):!1}})]}function $c(t,e){return function({state:n,dispatch:i}){if(!e&&n.readOnly)return!1;let r=n.field(Qk,!1);if(!r)return!1;let s=r.pop(t,n,e);return s?(i(s),!0):!1}}const Xk=$c(0,!1),Yd=$c(1,!1),U3=$c(0,!0),K3=$c(1,!0);class wt{constructor(e,n,i,r,s){this.changes=e,this.effects=n,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new wt(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new wt(e.changes&&ze.fromJSON(e.changes),[],e.mapped&&zn.fromJSON(e.mapped),e.startSelection&&V.fromJSON(e.startSelection),e.selectionsAfter.map(V.fromJSON))}static fromTransaction(e,n){let i=Ut;for(let r of e.startState.facet(H3)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new wt(e.changes.invert(e.startState.doc),i,void 0,n||e.startState.selection,Ut)}static selection(e){return new wt(void 0,Ut,void 0,void 0,e)}}function sc(t,e,n,i){let r=e+1>n+20?e-n-1:0,s=t.slice(r,e);return s.push(i),s}function q3(t,e){let n=[],i=!1;return t.iterChangedRanges((r,s)=>n.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<n.length;){let u=n[a++],c=n[a++];l>=u&&o<=c&&(i=!0)}}),i}function Y3(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,i)=>n.empty!=e.ranges[i].empty).length===0}function Gk(t,e){return t.length?e.length?t.concat(e):t:e}const Ut=[],Q3=200;function Jk(t,e){if(t.length){let n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Q3));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),sc(t,t.length-1,1e9,n.setSelAfter(i)))}else return[wt.selection([e])]}function X3(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Xh(t,e){if(!t.length)return t;let n=t.length,i=Ut;for(;n;){let r=G3(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=t.slice(0,n);return s[n-1]=r,s}else e=r.mapped,n--,i=r.selectionsAfter}return i.length?[wt.selection(i)]:Ut}function G3(t,e,n){let i=Gk(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):Ut,n);if(!t.changes)return wt.selection(i);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new wt(r,me.mapEffects(t.effects,e),o,t.startSelection.map(s),i)}const J3=/^(input\.type|delete)($|\.)/;class In{constructor(e,n,i=0,r=void 0){this.done=e,this.undone=n,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new In(this.done,this.undone):this}addChanges(e,n,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||J3.test(i))&&(!l.selectionsAfter.length&&n-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,q3(l.changes,e.changes))||i=="input.type.compose")?o=sc(o,o.length-1,r.minDepth,new wt(e.changes.compose(l.changes),Gk(me.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,Ut)):o=sc(o,o.length,r.minDepth,e),new In(o,Ut,n,i)}addSelection(e,n,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Ut;return s.length>0&&n-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&Y3(s[s.length-1],e)?this:new In(Jk(this.done,e),this.undone,n,i)}addMapping(e){return new In(Xh(this.done,e),Xh(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):n.selection);if(i&&s.selectionsAfter.length)return n.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:qd.of({side:e,rest:X3(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Ut:r.slice(0,r.length-1);return s.mapped&&(l=Xh(l,s.mapped)),n.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:qd.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}In.empty=new In(Ut,Ut);const Z3=[{key:"Mod-z",run:Xk,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Yd,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Yd,preventDefault:!0},{key:"Mod-u",run:U3,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:K3,preventDefault:!0}];function Qs(t,e){return V.create(t.ranges.map(e),t.mainIndex)}function vn(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function wn({state:t,dispatch:e},n){let i=Qs(t.selection,n);return i.eq(t.selection,!0)?!1:(e(vn(t,i)),!0)}function jc(t,e){return V.cursor(e?t.to:t.from)}function Zk(t,e){return wn(t,n=>n.empty?t.moveByChar(n,e):jc(n,e))}function st(t){return t.textDirectionAt(t.state.selection.main.head)==Te.LTR}const eb=t=>Zk(t,!st(t)),tb=t=>Zk(t,st(t));function nb(t,e){return wn(t,n=>n.empty?t.moveByGroup(n,e):jc(n,e))}const eB=t=>nb(t,!st(t)),tB=t=>nb(t,st(t));function nB(t,e,n){if(e.type.prop(n))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Fc(t,e,n){let i=Gt(t).resolveInner(e.head),r=n?re.closedBy:re.openedBy;for(let a=e.head;;){let u=n?i.childAfter(a):i.childBefore(a);if(!u)break;nB(t,u,r)?i=u:a=n?u.to:u.from}let s=i.type.prop(r),o,l;return s&&(o=n?os(t,i.from,1):os(t,i.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?i.to:i.from,V.cursor(l,n?-1:1)}const iB=t=>wn(t,e=>Fc(t.state,e,!st(t))),rB=t=>wn(t,e=>Fc(t.state,e,st(t)));function ib(t,e){return wn(t,n=>{if(!n.empty)return jc(n,e);let i=t.moveVertically(n,e);return i.head!=n.head?i:t.moveToLineBoundary(n,e)})}const rb=t=>ib(t,!1),sb=t=>ib(t,!0);function ob(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,i=0,r;if(e){for(let s of t.state.facet(J.scrollMargins)){let o=s(t);o!=null&&o.top&&(n=Math.max(o==null?void 0:o.top,n)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}r=t.scrollDOM.clientHeight-n-i}else r=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:i,selfScroll:e,height:Math.max(t.defaultLineHeight,r-5)}}function lb(t,e){let n=ob(t),{state:i}=t,r=Qs(i.selection,o=>o.empty?t.moveVertically(o,e,n.height):jc(o,e));if(r.eq(i.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(i.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+n.marginTop,u=l.bottom-n.marginBottom;o&&o.top>a&&o.bottom<u&&(s=J.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return t.dispatch(vn(i,r),{effects:s}),!0}const uv=t=>lb(t,!1),Qd=t=>lb(t,!0);function qi(t,e,n){let i=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?i.to:i.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==i.from&&i.length){let s=/^\s*/.exec(t.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=V.cursor(i.from+s))}return r}const sB=t=>wn(t,e=>qi(t,e,!0)),oB=t=>wn(t,e=>qi(t,e,!1)),lB=t=>wn(t,e=>qi(t,e,!st(t))),aB=t=>wn(t,e=>qi(t,e,st(t))),uB=t=>wn(t,e=>V.cursor(t.lineBlockAt(e.head).from,1)),cB=t=>wn(t,e=>V.cursor(t.lineBlockAt(e.head).to,-1));function hB(t,e,n){let i=!1,r=Qs(t.selection,s=>{let o=os(t,s.head,-1)||os(t,s.head,1)||s.head>0&&os(t,s.head-1,1)||s.head<t.doc.length&&os(t,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return V.cursor(l)});return i?(e(vn(t,r)),!0):!1}const fB=({state:t,dispatch:e})=>hB(t,e);function Jt(t,e,n){let i=Qs(t.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=e&&(r=V.range(r.head,r.anchor));let s=n(r);return V.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(t.state.selection)?!1:(t.dispatch(vn(t.state,i)),!0)}function ab(t,e){return Jt(t,e,n=>t.moveByChar(n,e))}const ub=t=>ab(t,!st(t)),cb=t=>ab(t,st(t));function hb(t,e){return Jt(t,e,n=>t.moveByGroup(n,e))}const dB=t=>hb(t,!st(t)),pB=t=>hb(t,st(t)),mB=t=>{let e=!st(t);return Jt(t,e,n=>Fc(t.state,n,e))},gB=t=>{let e=st(t);return Jt(t,e,n=>Fc(t.state,n,e))};function fb(t,e){return Jt(t,e,n=>t.moveVertically(n,e))}const db=t=>fb(t,!1),pb=t=>fb(t,!0);function mb(t,e){return Jt(t,e,n=>t.moveVertically(n,e,ob(t).height))}const cv=t=>mb(t,!1),hv=t=>mb(t,!0),yB=t=>Jt(t,!0,e=>qi(t,e,!0)),vB=t=>Jt(t,!1,e=>qi(t,e,!1)),wB=t=>{let e=!st(t);return Jt(t,e,n=>qi(t,n,e))},xB=t=>{let e=st(t);return Jt(t,e,n=>qi(t,n,e))},SB=t=>Jt(t,!1,e=>V.cursor(t.lineBlockAt(e.head).from)),kB=t=>Jt(t,!0,e=>V.cursor(t.lineBlockAt(e.head).to)),fv=({state:t,dispatch:e})=>(e(vn(t,{anchor:0})),!0),dv=({state:t,dispatch:e})=>(e(vn(t,{anchor:t.doc.length})),!0),pv=({state:t,dispatch:e})=>(e(vn(t,{anchor:t.selection.main.anchor,head:0})),!0),mv=({state:t,dispatch:e})=>(e(vn(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),bB=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),CB=({state:t,dispatch:e})=>{let n=Vc(t).map(({from:i,to:r})=>V.undirectionalRange(i,Math.min(r+1,t.doc.length)));return e(t.update({selection:V.create(n),userEvent:"select"})),!0},EB=({state:t,dispatch:e})=>{let n=Qs(t.selection,i=>{let r=Gt(t),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.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:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return V.undirectionalRange(l.from,l.to)}return i});return n.eq(t.selection)?!1:(e(vn(t,n)),!0)};function gb(t,e){let{state:n}=t,i=n.selection,r=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to<t.state.doc.length:o.from>0)for(let l=s;;){let a=t.moveVertically(l,e);if(a.head<o.from||a.head>o.to){r.some(u=>u.head==a.head)||r.push(a);break}else{if(a.head==l.head)break;l=a}}}return r.length==i.ranges.length?!1:(t.dispatch(vn(n,V.create(r,r.length-1))),!0)}const NB=t=>gb(t,!1),_B=t=>gb(t,!0),AB=({state:t,dispatch:e})=>{let n=t.selection,i=null;return n.ranges.length>1?i=V.create([n.main]):n.main.empty||(i=V.create([V.cursor(n.main.head)])),i?(e(vn(t,i)),!0):!1};function Vl(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:i}=t,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(n="delete.backward",a=Ra(t,a,!1)):a>o&&(n="delete.forward",a=Ra(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Ra(t,o,!1),l=Ra(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:V.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(t.dispatch(i.update(r,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?J.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Ra(t,e,n){if(t instanceof J)for(let i of t.state.facet(J.atomicRanges).map(r=>r(t)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=n?s:r)});return e}const yb=(t,e,n)=>Vl(t,i=>{let r=i.from,{state:s}=t,o=s.doc.lineAt(r),l,a;if(n&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(l[l.length-1]==" ")return r-1;let u=Oc(l,s.tabSize),c=u%tc(s)||tc(s);for(let h=0;h<c&&l[l.length-1-h]==" ";h++)r--;a=r}else a=nt(o.text,r-o.from,e,e)+o.from,a==r&&o.number!=(e?s.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=nt(o.text,a-o.from,!1,!1)+o.from);return a}),Xd=t=>yb(t,!1,!0),vb=t=>yb(t,!0,!1),wb=(t,e)=>Vl(t,n=>{let i=n.head,{state:r}=t,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==n.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=nt(s.text,i-s.from,e)+s.from,u=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||i!=n.head)&&(l=c),i=a}return i}),xb=t=>wb(t,!1),TB=t=>wb(t,!0),MB=t=>Vl(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),OB=t=>Vl(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),PB=t=>Vl(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),RB=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:oe.of(["",""])},range:V.cursor(i.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},IB=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>{if(!i.empty||i.from==0||i.from==t.doc.length)return{range:i};let r=i.from,s=t.doc.lineAt(r),o=r==s.from?r-1:nt(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:nt(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(r,l).append(t.doc.slice(o,r))},range:V.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Vc(t){let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),s=t.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=t.doc.lineAt(i.to-1)),n>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return e}function Sb(t,e,n){if(t.readOnly)return!1;let i=[],r=[];for(let s of Vc(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),l=o.length+1;if(n){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let a of s.ranges)r.push(V.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let a of s.ranges)r.push(V.range(a.anchor-l,a.head-l))}}return i.length?(e(t.update({changes:i,scrollIntoView:!0,selection:V.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const DB=({state:t,dispatch:e})=>Sb(t,e,!1),BB=({state:t,dispatch:e})=>Sb(t,e,!0);function kb(t,e,n){if(t.readOnly)return!1;let i=[];for(let s of Vc(t))n?i.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):i.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let r=t.changes(i);return e(t.update({changes:r,selection:t.selection.map(r,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const LB=({state:t,dispatch:e})=>kb(t,e,!1),zB=({state:t,dispatch:e})=>kb(t,e,!0),$B=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Vc(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=Qs(e.selection,r=>{let s;if(t.lineWrapping){let o=t.lineBlockAt(r.head),l=t.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(r,!0,s)}).map(n);return t.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function jB(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Gt(t).resolveInner(e),i=n.childBefore(e),r=n.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(re.closedBy))&&s.indexOf(r.name)>-1&&t.doc.lineAt(i.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}const gv=bb(!1),FB=bb(!0);function bb(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!t&&s==o&&jB(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Lc(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=$k(u,s);for(c==null&&(c=Oc(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let h=["",nc(e,c)];return a&&h.push(nc(e,u.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:oe.of(h)},range:V.cursor(s+1+h[1].length)}});return n(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Fm(t,e){let n=-1;return t.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let l=t.doc.lineAt(o);l.number>n&&(i.empty||i.to>l.from)&&(e(l,r,i),n=l.number),o=l.to+1}let s=t.changes(r);return{changes:r,range:V.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const VB=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),i=new Lc(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),r=Fm(t,(s,o,l)=>{let a=$k(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=nc(t,a);(u!=c||l.from<s.from+u.length)&&(n[s.from]=a,o.push({from:s.from,to:s.from+u.length,insert:c}))});return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0},HB=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Fm(t,(n,i)=>{i.push({from:n.from,insert:t.facet(Im)})}),{userEvent:"input.indent"})),!0),WB=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Fm(t,(n,i)=>{let r=/^\s*/.exec(n.text)[0];if(!r)return;let s=Oc(r,t.tabSize),o=0,l=nc(t,Math.max(0,s-tc(t)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:n.from+o,to:n.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),UB=t=>(t.setTabFocusMode(),!0),KB=[{key:"Ctrl-b",run:eb,shift:ub,preventDefault:!0},{key:"Ctrl-f",run:tb,shift:cb},{key:"Ctrl-p",run:rb,shift:db},{key:"Ctrl-n",run:sb,shift:pb},{key:"Ctrl-a",run:uB,shift:SB},{key:"Ctrl-e",run:cB,shift:kB},{key:"Ctrl-d",run:vb},{key:"Ctrl-h",run:Xd},{key:"Ctrl-k",run:MB},{key:"Ctrl-Alt-h",run:xb},{key:"Ctrl-o",run:RB},{key:"Ctrl-t",run:IB},{key:"Ctrl-v",run:Qd}],qB=[{key:"ArrowLeft",run:eb,shift:ub,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:eB,shift:dB,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:lB,shift:wB,preventDefault:!0},{key:"ArrowRight",run:tb,shift:cb,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:tB,shift:pB,preventDefault:!0},{mac:"Cmd-ArrowRight",run:aB,shift:xB,preventDefault:!0},{key:"ArrowUp",run:rb,shift:db,preventDefault:!0},{mac:"Cmd-ArrowUp",run:fv,shift:pv},{mac:"Ctrl-ArrowUp",run:uv,shift:cv},{key:"ArrowDown",run:sb,shift:pb,preventDefault:!0},{mac:"Cmd-ArrowDown",run:dv,shift:mv},{mac:"Ctrl-ArrowDown",run:Qd,shift:hv},{key:"PageUp",run:uv,shift:cv},{key:"PageDown",run:Qd,shift:hv},{key:"Home",run:oB,shift:vB,preventDefault:!0},{key:"Mod-Home",run:fv,shift:pv},{key:"End",run:sB,shift:yB,preventDefault:!0},{key:"Mod-End",run:dv,shift:mv},{key:"Enter",run:gv,shift:gv},{key:"Mod-a",run:bB},{key:"Backspace",run:Xd,shift:Xd,preventDefault:!0},{key:"Delete",run:vb,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:xb,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:TB,preventDefault:!0},{mac:"Mod-Backspace",run:OB,preventDefault:!0},{mac:"Mod-Delete",run:PB,preventDefault:!0}].concat(KB.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),YB=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:iB,shift:mB},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:rB,shift:gB},{key:"Alt-ArrowUp",run:DB},{key:"Shift-Alt-ArrowUp",run:LB},{key:"Alt-ArrowDown",run:BB},{key:"Shift-Alt-ArrowDown",run:zB},{key:"Mod-Alt-ArrowUp",run:NB},{key:"Mod-Alt-ArrowDown",run:_B},{key:"Escape",run:AB},{key:"Mod-Enter",run:FB},{key:"Alt-l",mac:"Ctrl-l",run:CB},{key:"Mod-i",run:EB,preventDefault:!0},{key:"Mod-[",run:WB},{key:"Mod-]",run:HB},{key:"Mod-Alt-\\",run:VB},{key:"Shift-Mod-k",run:$B},{key:"Shift-Mod-\\",run:fB},{key:"Mod-/",run:D3},{key:"Alt-A",mac:"Ctrl-A",run:L3},{key:"Ctrl-m",mac:"Shift-Alt-m",run:UB}].concat(qB);function Cb({title:t,onClose:e,children:n,headerExtra:i}){return O.useEffect(()=>{const r=s=>{s.key==="Escape"&&e()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e]),k.jsx("div",{className:"modal__backdrop",onClick:e,children:k.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-label":t,onClick:r=>r.stopPropagation(),children:[k.jsxs("div",{className:"modal__header",children:[k.jsx("span",{className:"modal__title",children:t}),i,k.jsx("button",{type:"button",className:"modal__close",onClick:e,"aria-label":"Close",children:"×"})]}),k.jsx("div",{className:"modal__body",children:n})]})})}const yv={response_body:"Response → Body Attribute",response_raw:"Response → Raw Body",response_header:"Response → Header"};function vv({ancestorNodes:t,nodeLabels:e,initialType:n,initialTag:i,onConfirm:r,onDelete:s,onCancel:o}){var x;const l=Ye(b=>b.runResult),[a,u]=O.useState((i==null?void 0:i.type)??n),c=i?t.some(b=>b.id===i.sourceNodeId):!0,[h,f]=O.useState(i?c?i.sourceNodeId:"":((x=t[0])==null?void 0:x.id)??""),[d,p]=O.useState((i==null?void 0:i.jsonPath)??""),[g,S]=O.useState((i==null?void 0:i.headerName)??""),m=!!h&&(a!=="response_header"||g.trim().length>0);function y(){if(!h)return"Select a request first.";const b=l==null?void 0:l.steps.find(N=>N.nodeId===h);if(!b||!b.response)return"No prior run captured for this node yet — run the chain once to preview.";if(a==="response_header"){const N=Ww(b.response.headers,g);return N===void 0?`(no "${g}" header in the last response)`:N}const C=a==="response_raw"?b.response.body:Hw(b.response.body,d);return JSON.stringify(C,null,2)??"undefined"}function v(){if(!m)return;const b={id:(i==null?void 0:i.id)??Tu(),type:a,sourceNodeId:h,jsonPath:a==="response_body"&&d.trim()||void 0,headerName:a==="response_header"?g.trim():void 0};r(b)}return k.jsxs(Cb,{title:i?"Edit mapping":"Insert response mapping",onClose:o,children:[k.jsxs("label",{className:"tag-config-modal__field",children:["Map",k.jsx("select",{value:a,onChange:b=>u(b.target.value),children:Object.keys(yv).map(b=>k.jsx("option",{value:b,children:yv[b]},b))})]}),k.jsxs("label",{className:"tag-config-modal__field",children:["Request",t.length===0?k.jsx("p",{className:"node-inspector__hint",children:"No upstream nodes reachable from here yet — connect this node from another on the canvas first."}):k.jsxs("select",{value:h,onChange:b=>f(b.target.value),children:[k.jsx("option",{value:"",disabled:!0,children:i&&!c?"-- Original request no longer exists — pick a new one --":"-- Select request --"}),t.map(b=>k.jsx("option",{value:b.id,children:e.get(b.id)},b.id))]})]}),a==="response_body"&&k.jsxs("label",{className:"tag-config-modal__field",children:["Filter (JSONPath)",k.jsx("input",{type:"text",placeholder:"e.g. $.items[0].id (blank = whole body)",value:d,onChange:b=>p(b.target.value)})]}),a==="response_header"&&k.jsxs("label",{className:"tag-config-modal__field",children:["Header name",k.jsx("input",{type:"text",placeholder:"e.g. x-trace-id",value:g,onChange:b=>S(b.target.value)})]}),k.jsxs("div",{className:"tag-config-modal__preview",children:[k.jsx("span",{className:"tag-config-modal__preview-label",children:"Live Preview"}),k.jsx("pre",{children:y()})]}),k.jsxs("div",{className:"tag-config-modal__actions",children:[i&&s&&k.jsx("button",{type:"button",className:"tag-config-modal__delete",onClick:s,children:"Remove mapping"}),k.jsx("button",{type:"button",onClick:o,children:"Cancel"}),k.jsx("button",{type:"button",disabled:!m,onClick:v,children:i?"Save":"Insert"})]})]})}const QB=zc.define([{tag:X.propertyName,color:"var(--color-get)"},{tag:X.string,color:"var(--color-post)"},{tag:[X.number,X.bool],color:"var(--color-put)"},{tag:X.null,color:"var(--color-popup)"},{tag:[X.separator,X.squareBracket,X.brace],color:"var(--color-text-muted)"}]),Ia=Fn.define(),Eb=me.define();function XB(t,e,n){const i=e.has(t.sourceNodeId)?n.get(t.sourceNodeId):"(missing)";return t.type==="response_header"?`${i} → header ${t.headerName??""}`:t.type==="response_raw"?`${i} → raw body`:`${i} → ${t.jsonPath||"body"}`}class wv extends zl{constructor(e,n,i,r){super(),this.tagId=e,this.label=n,this.broken=i,this.onClick=r}eq(e){return e.tagId===this.tagId&&e.label===this.label&&e.broken===this.broken}toDOM(){const e=document.createElement("span");return e.className=this.broken?"tag-chip tag-chip--broken":"tag-chip",e.textContent=this.label,this.onClick?(e.title=this.broken?"This mapping's source node no longer exists — click to fix or remove it":"Click to edit this mapping",e.addEventListener("mousedown",n=>n.preventDefault()),e.addEventListener("click",n=>{n.stopPropagation(),this.onClick(this.tagId)})):(e.title="Unrecognized tag reference — no mapping is configured for this",e.style.cursor="default"),e}ignoreEvent(){return!0}}function xv(t,e){const n=[];for(const i of t.matchAll(Rl())){const r=i[1],s=e.tags[r],o=i.index??0,l=o+i[0].length;if(!s){n.push(Me.replace({widget:new wv(r,"Unrecognized tag",!0,null)}).range(o,l));continue}const a=!e.nodesById.has(s.sourceNodeId),u=XB(s,e.nodesById,e.nodeLabels);n.push(Me.replace({widget:new wv(r,u,a,e.onClickChip)}).range(o,l))}return Me.set(n)}function GB(t){return $n.fromClass(class{constructor(e){Km(this,"decorations");this.decorations=xv(e.state.doc.toString(),t.current)}update(e){const n=e.transactions.some(i=>i.effects.some(r=>r.is(Eb)));(e.docChanged||n)&&(this.decorations=xv(e.state.doc.toString(),t.current))}},{decorations:e=>e.decorations})}function JB(t){return e=>{const n=e.matchBefore(/\{\{\w*/);return!n||Gt(e.state).resolveInner(n.from,-1).name!=="String"?null:{from:n.from,to:n.to,filter:!1,options:[{label:"Response → Map from...",apply:(r,s,o,l)=>t("response_body",o,l)}]}}}function ZB(t){return[r3(),KD(QB),W3(),Tm.of([...YB,...Z3]),P3({override:[JB(t)]}),J.lineWrapping,J.theme({},{dark:!0}),eD({parent:document.body})]}function eL({rawBody:t,onChange:e,ancestorNodes:n,nodeLabels:i,readOnly:r=!1}){const s=O.useRef(null),o=O.useRef(null),l=O.useRef(null),a=O.useRef({rawBody:t,onChange:e});a.current={rawBody:t,onChange:e};const u=O.useRef(new Ll),[c,h]=O.useState(null),[f,d]=O.useState(null),p=new Map(n.map(x=>[x.id,x]));l.current={tags:t.tags,nodesById:p,nodeLabels:i,onClickChip:x=>d(x)},O.useEffect(()=>{if(!s.current)return;const x=J.updateListener.of(M=>{if(!M.docChanged||M.transactions.some(L=>L.annotation(Ia)))return;const _=M.state.doc.toString(),P=new Set([..._.matchAll(Rl())].map(L=>L[1])),B=Object.fromEntries(Object.entries(a.current.rawBody.tags).filter(([L])=>P.has(L)));a.current.onChange({template:_,tags:B})}),b=GB(l),C=[...ZB((M,_,P)=>h({type:M,from:_,to:P})),b,J.atomicRanges.of(M=>{var _;return((_=M.plugin(b))==null?void 0:_.decorations)??Me.none}),x,u.current.of([ae.readOnly.of(r),J.editable.of(!r)])],N=new J({doc:a.current.rawBody.template,extensions:C,parent:s.current});return o.current=N,()=>N.destroy()},[]),O.useEffect(()=>{const x=o.current;x&&x.state.doc.toString()!==t.template&&x.dispatch({changes:{from:0,to:x.state.doc.length,insert:t.template},annotations:Ia.of(!0)})},[t.template]),O.useEffect(()=>{var x;(x=o.current)==null||x.dispatch({effects:u.current.reconfigure([ae.readOnly.of(r),J.editable.of(!r)])})},[r]),O.useEffect(()=>{var x;(x=o.current)==null||x.dispatch({effects:Eb.of()})},[t.tags]);function g(x){const b=o.current;if(!b||!c)return;const C=b.state.doc.length,N=Math.min(c.from,C),M=Math.min(Math.max(c.to,N),C);b.dispatch({changes:{from:N,to:M,insert:Vw(x.id)},annotations:Ia.of(!0)}),e({template:b.state.doc.toString(),tags:{...t.tags,[x.id]:x}}),h(null)}function S(x,b){const C=new RegExp(`\\{\\{enlace:${b}\\}\\}`).exec(x);return C?{from:C.index,to:C.index+C[0].length}:null}function m(x){e({template:t.template,tags:{...t.tags,[x.id]:x}}),d(null)}function y(){const x=o.current;if(!x||!f)return;const b=S(x.state.doc.toString(),f);b&&x.dispatch({changes:{from:b.from,to:b.to,insert:""},annotations:Ia.of(!0)});const C={...t.tags};delete C[f],e({template:x.state.doc.toString(),tags:C}),d(null)}const v=f?t.tags[f]:void 0;return k.jsxs("div",{className:"raw-body-editor",children:[k.jsxs("div",{className:"raw-body-editor__hint",children:["Type ",k.jsx("code",{children:"{{"})," inside a string to map a value from an upstream response."]}),k.jsx("div",{className:`raw-body-editor__codemirror${r?" raw-body-editor__codemirror--readonly":""}`,ref:s}),c&&k.jsx(vv,{ancestorNodes:n,nodeLabels:i,initialType:c.type,onConfirm:g,onCancel:()=>h(null)}),v&&k.jsx(vv,{ancestorNodes:n,nodeLabels:i,initialType:v.type,initialTag:v,onConfirm:m,onDelete:y,onCancel:()=>d(null)})]})}function tL({onCollapse:t}){const{nodes:e,connections:n,operations:i,selectedNodeId:r,credentials:s,isRunning:o,setCredential:l,setFieldValue:a,mergeFieldValues:u,setBodyMode:c,setRawBody:h}=Ye(),f=e.find(w=>w.id===r),d=i.find(w=>w.id===(f==null?void 0:f.operationId)),p=O.useMemo(()=>new Map(i.map(w=>[w.id,w])),[i]),g=O.useMemo(()=>d?dS(d):[],[d]),S=O.useMemo(()=>g.filter(w=>!w.path.startsWith("body.")),[g]),m=O.useMemo(()=>g.filter(w=>w.path.startsWith("body.")),[g]),[y,v]=O.useState(null),[x,b]=O.useState(null),C=O.useMemo(()=>{if(!f)return[];const w=CN(e,n,f.id);return e.filter(E=>w.has(E.id))},[e,n,f]),N=O.useMemo(()=>hS(e,p),[e,p]),M=k.jsx("button",{type:"button",className:"pane-collapse-btn",onClick:t,title:"Hide inspector","aria-label":"Hide inspector",children:"›"});if(!f||!d)return k.jsxs("aside",{className:"node-inspector node-inspector--empty",children:[k.jsxs("div",{className:"node-inspector__topbar",children:[k.jsx("span",{children:"Inspector"}),M]}),k.jsx("p",{children:"Select a node to configure it."})]});const _=f.bodyMode??"form";function P(){!f||!d||(v(null),h(f.id,LP(d,f.fieldValues)),c(f.id,"raw"))}function B(){if(!f||!d)return;if(v(null),!f.rawBody){c(f.id,"form");return}const w=zP(f.rawBody,d);if(w.parseError){v(`Can't switch to Form view — the Raw JSON isn't valid: ${w.parseError}`);return}if(w.lossy){b(w.fieldValues);return}u(f.id,w.fieldValues),c(f.id,"form")}function L(){!f||!x||(u(f.id,x),c(f.id,"form"),b(null))}function F(w){const E=f.fieldValues[w.path],T=(E==null?void 0:E.source)==="mapped",z=!w.supported,R=T?C.find(I=>I.id===E.fromNodeId):void 0,A=R?i.find(I=>I.id===R.operationId):void 0,D=A?OP(A):[];return k.jsxs("div",{className:`node-inspector__field${z?" node-inspector__field--disabled":""}`,title:w.reason,children:[k.jsxs("label",{children:[w.path,w.required?" *":"",w.type?` (${w.type})`:"",z?" (unsupported)":""]}),k.jsx("div",{className:"node-inspector__field-row",children:k.jsxs("select",{disabled:z,value:T?"mapped":"static",onChange:I=>{I.target.value==="static"?a(f.id,w.path,{source:"static",value:""}):C[0]&&a(f.id,w.path,{source:"mapped",fromNodeId:C[0].id,fromResponseFieldPath:""})},children:[k.jsx("option",{value:"static",children:"Static value"}),k.jsx("option",{value:"mapped",disabled:C.length===0,children:"Map from..."})]})}),!T&&k.jsx("div",{className:"node-inspector__field-row",children:w.type==="array"?k.jsx("textarea",{rows:3,disabled:z,placeholder:w.reason,title:w.reason,value:(E==null?void 0:E.source)==="static"?typeof E.value=="string"?E.value:JSON.stringify(E.value,null,2):"",onChange:I=>a(f.id,w.path,{source:"static",value:Th(I.target.value,w.type)})}):w.enum?k.jsxs("select",{disabled:z,value:(E==null?void 0:E.source)==="static"?String(E.value??""):"",onChange:I=>a(f.id,w.path,{source:"static",value:Th(I.target.value,w.type)}),children:[k.jsx("option",{value:"",children:"Select..."}),w.enum.map(I=>k.jsx("option",{value:String(I),children:String(I)},String(I)))]}):k.jsx("input",{type:"text",disabled:z,value:(E==null?void 0:E.source)==="static"?String(E.value??""):"",onChange:I=>a(f.id,w.path,{source:"static",value:Th(I.target.value,w.type)})})}),T&&k.jsxs("div",{className:"node-inspector__field-row node-inspector__field-row--mapped",children:[k.jsx("select",{disabled:z,value:E.fromNodeId,onChange:I=>a(f.id,w.path,{...E,fromNodeId:I.target.value}),children:C.map(I=>k.jsx("option",{value:I.id,children:N.get(I.id)},I.id))}),k.jsxs("select",{disabled:z,value:E.fromResponseFieldPath,onChange:I=>a(f.id,w.path,{...E,fromResponseFieldPath:I.target.value}),children:[k.jsx("option",{value:"",children:"Select field..."}),D.map(I=>{const $=I.supported&&!PP(w.type,I.type),U=!I.supported||$,W=I.supported?$?`Type mismatch: "${w.path}" expects ${w.type}, this field is ${I.type}.`:void 0:I.reason;return k.jsxs("option",{value:I.path,disabled:U,title:W,children:[I.path,I.supported?$?" (type mismatch)":"":" (unsupported)"]},I.path)})]})]})]},w.path)}return k.jsxs("aside",{className:"node-inspector",children:[k.jsxs("div",{className:"node-inspector__topbar",children:[k.jsx("span",{children:"Inspector"}),M]}),o&&k.jsx("p",{className:"node-inspector__banner",children:"Workflow is running — editing is locked until it finishes."}),k.jsxs("fieldset",{className:"node-inspector__fieldset",disabled:o,children:[k.jsx("h2",{children:d.id}),k.jsxs("label",{className:"node-inspector__field",children:["Credential",k.jsxs("select",{value:f.credentialId??"",onChange:w=>l(f.id,w.target.value||null),children:[k.jsx("option",{value:"",children:"None"}),s.map(w=>k.jsx("option",{value:w.id,children:w.name},w.id))]})]}),k.jsx("h3",{children:"Request fields"}),C.length===0&&(S.length>0||_==="form")&&k.jsx("p",{className:"node-inspector__hint",children:'Connect this node from another on the canvas (drag box to box) to enable "Map from...".'}),S.map(F),d.requestBodySchema&&k.jsxs("div",{className:"node-inspector__body",children:[k.jsxs("div",{className:"node-inspector__body-header",children:[k.jsx("span",{className:"node-inspector__body-title",children:"Body"}),k.jsxs("label",{className:"body-mode-switch",children:[k.jsx("span",{className:"body-mode-switch__label",children:_==="raw"?"Raw JSON":"Form"}),k.jsx("input",{type:"checkbox",checked:_==="raw",onChange:w=>w.target.checked?P():B(),"aria-label":_==="raw"?"Switch to Form view":"Switch to Raw JSON view"}),k.jsx("span",{className:"body-mode-switch__track",children:k.jsx("span",{className:"body-mode-switch__thumb"})})]})]}),_==="form"&&ud(d.requestBodySchema)?k.jsxs("p",{className:"node-inspector__banner",children:["This body has a shape the form can't fully represent (arrays of objects or polymorphic fields)."," ",k.jsx("button",{type:"button",onClick:P,children:"Switch to Raw JSON"})]}):_==="form"&&k.jsx("p",{className:"node-inspector__hint",children:"Switch to Raw JSON to write the body directly and map values into any nested field."}),y&&k.jsx("p",{className:"node-inspector__error",children:y}),_==="form"?m.map(F):f.rawBody?k.jsx(eL,{rawBody:f.rawBody,onChange:w=>h(f.id,w),ancestorNodes:C,nodeLabels:N,readOnly:o}):null]})]}),x&&k.jsxs(Cb,{title:"Switch to Form view?",onClose:()=>b(null),children:[k.jsx("p",{children:"Switching to Form view may lose custom JSON structure — continue?"}),k.jsxs("div",{className:"tag-config-modal__actions",children:[k.jsx("button",{type:"button",onClick:()=>b(null),children:"Cancel"}),k.jsx("button",{type:"button",onClick:L,children:"Switch anyway"})]})]})]})}function Nb(t,e){if(!e||e.length===0)return t;try{const n=new URL(t);for(const i of e)n.searchParams.has(i)&&n.searchParams.set(i,"[redacted]");return n.toString()}catch{return t}}function _b(t){return{...t,url:Nb(t.url,t.redactQueryParams),headers:Object.fromEntries(Object.entries(t.headers).map(([e,n])=>e.toLowerCase()==="authorization"?[e,"[redacted]"]:[e,n]))}}function nL(t){if(t==null)return null;if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Ab({headers:t}){const e=Object.entries(t);return k.jsxs("details",{className:"debug-headers",children:[k.jsxs("summary",{className:"debug-headers__summary",children:["Headers (",e.length,")"]}),e.length===0?k.jsx("p",{className:"debug-headers__empty",children:"None"}):k.jsx("table",{className:"debug-headers__table",children:k.jsx("tbody",{children:e.map(([n,i])=>k.jsxs("tr",{children:[k.jsx("th",{children:n}),k.jsx("td",{children:i})]},n))})})]})}function Tb({value:t}){const e=nL(t);return k.jsxs("div",{className:"debug-body",children:[k.jsx("div",{className:"debug-body__label",children:"Body"}),e===null?k.jsx("p",{className:"debug-body__empty",children:"No body"}):k.jsx("pre",{className:"debug-body__pre",children:e})]})}function iL({request:t}){return k.jsxs("div",{className:"debug-step__panel",children:[k.jsxs("div",{className:"debug-step__panel-title",children:["Request",t.credentials==="include"&&k.jsx("span",{className:"debug-step__credentials-chip",children:"credentials: include"})]}),k.jsx(Ab,{headers:t.headers}),k.jsx(Tb,{value:t.body})]})}function rL({response:t,error:e}){return t?k.jsxs("div",{className:"debug-step__panel",children:[k.jsxs("div",{className:"debug-step__panel-title",children:["Response",k.jsx("span",{className:`status-badge ${t.status<400?"status-badge--ok":"status-badge--error"}`,children:t.status})]}),k.jsx(Ab,{headers:t.headers}),k.jsx(Tb,{value:t.body})]}):k.jsxs("div",{className:"debug-step__panel",children:[k.jsx("div",{className:"debug-step__panel-title",children:"Response"}),k.jsx("p",{className:"debug-step__panel-empty",children:e??"No response"})]})}const sL={pending:"○","in-flight":"●",paused:"⏸",completed:"✓",failed:"!",skipped:"–"};function oL({status:t}){return k.jsx("span",{className:`debugger-row__status-icon debugger-row__status-icon--${t}`,"aria-label":t,children:sL[t]})}function lL({node:t,operation:e,status:n,step:i,previewRequest:r,onStepThis:s}){const o=(e==null?void 0:e.method)??"get",l=(e==null?void 0:e.path)??t.operationId,a=Ye(d=>d.continueExecution),u=Ye(d=>d.stopExecution),c=!!i||!!r,h=k.jsxs(k.Fragment,{children:[k.jsx(oL,{status:n}),k.jsx("span",{className:`method-badge method-badge--${o}`,children:o.toUpperCase()}),k.jsx("span",{className:"debug-step__url",children:l}),(i==null?void 0:i.response)&&k.jsx("span",{className:`status-badge ${i.error?"status-badge--error":"status-badge--ok"}`,children:i.response.status}),(i==null?void 0:i.error)&&k.jsx("span",{className:"debug-step__error",children:i.error})]}),f=n==="paused"&&k.jsxs("span",{className:"debugger-row__controls",onClick:d=>d.stopPropagation(),children:[k.jsx("button",{type:"button",className:"btn btn--icon btn--execute",onClick:a,title:"Continue","aria-label":"Continue",children:"▶"}),k.jsx("button",{type:"button",className:"btn btn--icon btn--secondary",onClick:s,title:"Step this node","aria-label":"Step",children:"⏭"}),k.jsx("button",{type:"button",className:"btn btn--icon btn--stop",onClick:u,title:"Stop","aria-label":"Stop",children:"■"})]});return c?k.jsxs("details",{className:"debugger-row",children:[k.jsxs("summary",{className:"debugger-row__summary",children:[k.jsx("span",{className:"debugger-row__chevron","aria-hidden":"true",children:"▶"}),h,f]}),k.jsxs("div",{className:"debugger-row__detail",children:[k.jsx("div",{className:`debugger-row__detail-label${i?"":" debugger-row__detail-label--preview"}`,children:i?"Request":"Preview — resolved, not yet sent"}),k.jsx("pre",{className:"debugger-row__json",children:JSON.stringify(_b(i?i.request:r),null,2)}),i&&k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"debugger-row__detail-label",children:"Response"}),i.response?k.jsx("pre",{className:"debugger-row__json",children:JSON.stringify(i.response,null,2)}):k.jsx("p",{className:"debugger-row__detail-empty",children:i.error??"No response"})]})]})]}):k.jsx("div",{className:"debugger-row debugger-row--plain",children:k.jsxs("div",{className:"debugger-row__summary",children:[h,f]})})}function aL(){const{nodes:t,connections:e,operations:n,armedBreakpoints:i,stepStatusByNodeId:r,previewRequestByNodeId:s,runResult:o,stepNode:l}=Ye(),a=O.useMemo(()=>new Map(n.map(h=>[h.id,h])),[n]),u=O.useMemo(()=>new Map(((o==null?void 0:o.steps)??[]).map(h=>[h.nodeId,h])),[o]),c=O.useMemo(()=>{try{return EN(t,e)}catch(h){if(h instanceof Uw)return t;throw h}},[t,e]);return i.size===0?k.jsx("div",{className:"debug-pane__body",children:k.jsx("p",{className:"debug-pane__status",children:"Arm a breakpoint on a connector to start debugging."})}):k.jsx("div",{className:"debug-pane__body",children:c.map(h=>k.jsx(lL,{node:h,operation:a.get(h.operationId),status:r[h.id]??"pending",step:u.get(h.id),previewRequest:s[h.id],onStepThis:()=>l(h.id)},h.id))})}function uL(t,e){const n=new Map;for(const s of t){const o=e[s.id]??"pending";n.set(o,(n.get(o)??0)+1)}const i=["in-flight","paused","completed","failed","skipped","pending"],r={pending:"pending","in-flight":"in flight",paused:"paused",completed:"completed",failed:"failed",skipped:"skipped"};return i.filter(s=>n.has(s)).map(s=>`${n.get(s)} ${r[s]}`).join(" · ")}function cL(){const{runResult:t,isRunning:e,error:n}=Ye();return k.jsxs("div",{className:"debug-pane__body",children:[e&&k.jsx("p",{className:"debug-pane__status debug-pane__status--running",children:"Running…"}),!e&&n&&k.jsx("p",{className:"debug-pane__status debug-pane__status--error",children:n}),!e&&!n&&!t&&k.jsx("p",{className:"debug-pane__status",children:"Run the workflow to see each step's request and response."}),!n&&(t==null?void 0:t.steps.map(i=>{var s;const r=!i.error;return k.jsxs("details",{className:"debug-step",children:[k.jsxs("summary",{className:"debug-step__summary",children:[k.jsx("span",{className:"debug-step__chevron","aria-hidden":"true",children:"▶"}),k.jsx("span",{className:`method-badge method-badge--${i.request.method.toLowerCase()}`,children:i.request.method}),k.jsx("span",{className:"debug-step__url",children:Nb(i.request.url,i.request.redactQueryParams)}),k.jsx("span",{className:`status-badge ${r?"status-badge--ok":"status-badge--error"}`,children:((s=i.response)==null?void 0:s.status)??"ERROR"}),i.error&&k.jsx("span",{className:"debug-step__error",children:i.error})]}),k.jsxs("div",{className:"debug-step__panels",children:[k.jsx(iL,{request:_b(i.request)}),k.jsx(rL,{response:i.response,error:i.error})]})]},i.nodeId)}))]})}function hL({collapsed:t,onToggleCollapsed:e}){const n=Ye(c=>c.runResult),i=Ye(c=>c.nodes),r=Ye(c=>c.stepStatusByNodeId),s=Ye(c=>c.armedBreakpoints),[o,l]=O.useState("run-output"),a=Object.values(r).some(c=>c==="paused"),u=O.useRef(!1);return O.useEffect(()=>{a&&!u.current&&l("debugger"),u.current=a},[a]),k.jsxs("div",{className:`debug-pane${t?" debug-pane--collapsed":""}`,children:[k.jsxs("div",{className:"debug-pane__header",children:[k.jsx("button",{type:"button",className:"debug-pane__toggle",onClick:e,"aria-label":t?"Show run output":"Hide run output",children:k.jsx("span",{className:"debug-pane__toggle-chevron","aria-hidden":"true",children:t?"▲":"▼"})}),k.jsxs("div",{className:"debug-pane__tabs",role:"tablist",children:[k.jsx("button",{type:"button",role:"tab","aria-selected":o==="run-output",className:`debug-pane__tab${o==="run-output"?" debug-pane__tab--active":""}`,onClick:()=>l("run-output"),children:"Run output"}),k.jsx("button",{type:"button",role:"tab","aria-selected":o==="debugger",className:`debug-pane__tab${o==="debugger"?" debug-pane__tab--active":""}`,onClick:()=>l("debugger"),children:"Debugger"})]}),o==="run-output"&&n&&k.jsxs("span",{className:"debug-pane__count",children:[n.steps.length," call(s)"]}),o==="debugger"&&s.size>0&&k.jsx("span",{className:"debug-pane__count",children:uL(i,r)})]}),!t&&(o==="run-output"?k.jsx(cL,{}):k.jsx(aL,{}))]})}const oc={bearer:"Bearer token",basic:"Basic auth",apiKey:"API key",oauth2_clientCredentials:"OAuth2 (client credentials)",oauth2_password:"OAuth2 (password) · Legacy",popup_login:"Popup login (session cookie)"};function Gd(t,e){switch(t){case"bearer":return{name:e,type:t,token:""};case"basic":return{name:e,type:t,username:"",password:""};case"apiKey":return{name:e,type:t,paramName:"",in:"header",key:""};case"oauth2_clientCredentials":return{name:e,type:t,tokenUrl:"",clientId:"",clientSecret:"",scope:""};case"oauth2_password":return{name:e,type:t,tokenUrl:"",username:"",password:"",clientId:"",clientSecret:"",scope:""};case"popup_login":return{name:e,type:t,loginUrl:""}}}function fL(t){if(!t.name)return!1;switch(t.type){case"bearer":return!!t.token;case"basic":return!!(t.username&&t.password);case"apiKey":return!!(t.paramName&&t.key);case"oauth2_clientCredentials":return!!(t.tokenUrl&&t.clientId&&t.clientSecret);case"oauth2_password":return!!(t.tokenUrl&&t.username&&t.password);case"popup_login":return!!t.loginUrl}}function wo(t){return t?`••••${t.slice(-4)}`:""}function Mb(t){window.open(t,"_blank","width=520,height=680")}function dL(t){const{id:e,...n}=t;return n}function pL(t){switch(t.type){case"bearer":return wo(t.token);case"basic":return`${t.username} / ${wo(t.password)}`;case"apiKey":return`${t.paramName} (${t.in}) · ${wo(t.key)}`;case"oauth2_clientCredentials":return`${t.clientId} · ${wo(t.clientSecret)}`;case"oauth2_password":return`${t.username} · ${wo(t.password)}`;case"popup_login":return"Session cookie — no stored secret, relies on your browser being logged in"}}function mL({credential:t,usageCount:e,onEdit:n,onDelete:i}){return k.jsxs("li",{className:`credential-card credential-card--${t.type}`,children:[k.jsxs("div",{className:"credential-card__header",children:[k.jsx("span",{className:`credential-badge credential-badge--${t.type}`,children:oc[t.type]}),k.jsxs("div",{className:"credential-card__actions",children:[t.type==="popup_login"&&k.jsx("button",{type:"button",className:"credential-card__login",onClick:()=>Mb(t.loginUrl),"aria-label":`Log in for ${t.name}`,title:"Opens the login page in a popup — complete login there, then re-run your nodes.",children:"Log in"}),k.jsx("button",{type:"button",className:"credential-card__edit",onClick:()=>n(t),"aria-label":`Edit ${t.name}`,children:"Edit"}),k.jsx("button",{type:"button",className:"credential-card__delete",onClick:()=>i(t.id),"aria-label":`Delete ${t.name}`,children:"Delete"})]})]}),k.jsx("div",{className:"credential-card__name",children:t.name}),k.jsx("div",{className:"credential-card__preview",children:pL(t)}),t.fromSecurityScheme&&k.jsxs("div",{className:"credential-card__source",children:["From spec: ",k.jsx("code",{children:t.fromSecurityScheme})]}),e>0&&k.jsxs("div",{className:"credential-card__usage",children:["Used by ",e," node",e===1?"":"s"," — deleting clears it from"," ",e===1?"that node":"those nodes","."]})]})}function gL({draft:t,setDraft:e}){return k.jsxs("label",{className:"credentials-panel__field",children:["Token",k.jsx("input",{placeholder:"bearer token",type:"password",value:t.token,onChange:n=>e({...t,token:n.target.value})})]})}function yL({draft:t,setDraft:e}){return k.jsxs(k.Fragment,{children:[k.jsxs("label",{className:"credentials-panel__field",children:["Username",k.jsx("input",{placeholder:"username",value:t.username,onChange:n=>e({...t,username:n.target.value})})]}),k.jsxs("label",{className:"credentials-panel__field",children:["Password",k.jsx("input",{placeholder:"password",type:"password",value:t.password,onChange:n=>e({...t,password:n.target.value})})]})]})}function vL({draft:t,setDraft:e}){return k.jsxs(k.Fragment,{children:[k.jsxs("label",{className:"credentials-panel__field",children:["Header/query param name",k.jsx("input",{placeholder:"e.g. X-API-Key",value:t.paramName,onChange:n=>e({...t,paramName:n.target.value})})]}),k.jsxs("label",{className:"credentials-panel__field",children:["Sent in",k.jsxs("select",{value:t.in,onChange:n=>e({...t,in:n.target.value}),children:[k.jsx("option",{value:"header",children:"Header"}),k.jsx("option",{value:"query",children:"Query param"})]})]}),k.jsxs("label",{className:"credentials-panel__field",children:["Key value",k.jsx("input",{placeholder:"key value",type:"password",value:t.key,onChange:n=>e({...t,key:n.target.value})})]})]})}function wL({draft:t,setDraft:e}){return k.jsxs(k.Fragment,{children:[k.jsx("p",{className:"credentials-panel__warning",children:"Only use test/sandbox credentials here. This value is visible to anyone with access to this browser, per Enlace's pre-prod trust model."}),k.jsxs("label",{className:"credentials-panel__field",children:["Token URL",k.jsx("input",{placeholder:"https://auth.example.com/oauth/token",value:t.tokenUrl,onChange:n=>e({...t,tokenUrl:n.target.value})})]}),k.jsxs("label",{className:"credentials-panel__field",children:["Client ID",k.jsx("input",{placeholder:"client id",value:t.clientId,onChange:n=>e({...t,clientId:n.target.value})})]}),k.jsxs("label",{className:"credentials-panel__field",children:["Client secret",k.jsx("input",{placeholder:"client secret",type:"password",value:t.clientSecret,onChange:n=>e({...t,clientSecret:n.target.value})})]}),k.jsxs("label",{className:"credentials-panel__field",children:["Scope (optional)",k.jsx("input",{placeholder:"scope",value:t.scope??"",onChange:n=>e({...t,scope:n.target.value})})]})]})}function xL({draft:t,setDraft:e}){return k.jsxs(k.Fragment,{children:[k.jsx("p",{className:"credentials-panel__warning",children:"Legacy grant type — deprecated in general OAuth2 guidance. Only use test/sandbox credentials here. This value is visible to anyone with access to this browser, per Enlace's pre-prod trust model."}),k.jsxs("label",{className:"credentials-panel__field",children:["Token URL",k.jsx("input",{placeholder:"https://auth.example.com/oauth/token",value:t.tokenUrl,onChange:n=>e({...t,tokenUrl:n.target.value})})]}),k.jsxs("label",{className:"credentials-panel__field",children:["Username",k.jsx("input",{placeholder:"resource owner username",value:t.username,onChange:n=>e({...t,username:n.target.value})})]}),k.jsxs("label",{className:"credentials-panel__field",children:["Password",k.jsx("input",{placeholder:"resource owner password",type:"password",value:t.password,onChange:n=>e({...t,password:n.target.value})})]}),k.jsxs("label",{className:"credentials-panel__field",children:["Client ID (optional)",k.jsx("input",{placeholder:"client id",value:t.clientId??"",onChange:n=>e({...t,clientId:n.target.value})})]}),k.jsxs("label",{className:"credentials-panel__field",children:["Client secret (optional)",k.jsx("input",{placeholder:"client secret",type:"password",value:t.clientSecret??"",onChange:n=>e({...t,clientSecret:n.target.value})})]}),k.jsxs("label",{className:"credentials-panel__field",children:["Scope (optional)",k.jsx("input",{placeholder:"scope",value:t.scope??"",onChange:n=>e({...t,scope:n.target.value})})]})]})}function SL({draft:t,setDraft:e}){return k.jsxs(k.Fragment,{children:[k.jsxs("label",{className:"credentials-panel__field",children:["Login URL",k.jsx("input",{placeholder:"https://your-app.example.com/auth/login",value:t.loginUrl,onChange:n=>e({...t,loginUrl:n.target.value})})]}),k.jsx("button",{type:"button",className:"btn btn--secondary credentials-panel__login-btn",disabled:!t.loginUrl,onClick:()=>Mb(t.loginUrl),children:"Log in…"}),k.jsx("p",{className:"credentials-panel__hint",children:`This credential doesn't add anything to your requests itself — no header, no query param. It's a trigger: click "Log in…" above to complete a real login for the target (e.g. a GitHub/Google/SSO-style login backed by your app's own session) in a popup Enlace never sees. Once you're logged in, this browser already holds the session cookie, and future requests carry it automatically — as long as the target's server allows credentialed requests from this origin; that's the target's own CORS setting, not something Enlace can change.`})]})}function kL({draft:t,setDraft:e,editingId:n,onCancel:i,onSave:r}){const s=O.useRef(null);return O.useEffect(()=>{var o;(o=s.current)==null||o.focus()},[]),k.jsxs("div",{className:"credentials-drawer__form",children:[t.fromSecurityScheme&&k.jsx("p",{className:"credentials-panel__spec-banner",children:n?k.jsxs(k.Fragment,{children:["Originally configured from the spec's ",k.jsxs("code",{children:["securitySchemes.",t.fromSecurityScheme]}),"."]}):k.jsxs(k.Fragment,{children:["This credential is declared in the spec's ",k.jsxs("code",{children:["securitySchemes.",t.fromSecurityScheme]})," — fill in the secret value(s) below."]})}),k.jsxs("label",{className:"credentials-panel__field",children:["Name",k.jsx("input",{ref:s,placeholder:"name",value:t.name,onChange:o=>e({...t,name:o.target.value})})]}),k.jsxs("label",{className:"credentials-panel__field",children:["Type",k.jsx("select",{value:t.type,onChange:o=>e(Gd(o.target.value,t.name)),children:Object.keys(oc).map(o=>k.jsx("option",{value:o,children:oc[o]},o))})]}),t.type==="bearer"&&k.jsx(gL,{draft:t,setDraft:e}),t.type==="basic"&&k.jsx(yL,{draft:t,setDraft:e}),t.type==="apiKey"&&k.jsx(vL,{draft:t,setDraft:e}),t.type==="oauth2_clientCredentials"&&k.jsx(wL,{draft:t,setDraft:e}),t.type==="oauth2_password"&&k.jsx(xL,{draft:t,setDraft:e}),t.type==="popup_login"&&k.jsx(SL,{draft:t,setDraft:e}),k.jsxs("div",{className:"credentials-drawer__form-actions",children:[k.jsx("button",{type:"button",className:"btn btn--secondary",onClick:i,children:"Cancel"}),k.jsx("button",{type:"button",className:"btn btn--authorize",disabled:!fL(t),onClick:r,children:n?"Save changes":"Save"})]})]})}function bL({entries:t,onConfigure:e}){return t.length===0?null:k.jsxs("div",{className:"credentials-drawer__declared",children:[k.jsx("h3",{children:"Declared in spec"}),k.jsx("ul",{className:"credentials-drawer__declared-list",children:t.map(n=>k.jsxs("li",{className:"declared-credential",children:[k.jsxs("div",{className:"declared-credential__info",children:[k.jsx("div",{className:"declared-credential__name",children:k.jsx("code",{children:n.schemeName})}),k.jsxs("div",{className:"declared-credential__type",children:[oc[n.template.type],n.description?` — ${n.description}`:""]})]}),k.jsx("button",{type:"button",className:"btn btn--secondary",onClick:()=>e(n),children:"Configure"})]},n.schemeName))})]})}function CL(){const{credentials:t,declaredCredentials:e,nodes:n,addCredential:i,updateCredential:r,removeCredential:s}=Ye(),[o,l]=O.useState(!1),[a,u]=O.useState(!1),[c,h]=O.useState(null),[f,d]=O.useState(()=>Gd("bearer","")),p=()=>{u(!1),h(null),d(Gd("bearer",""))},g=()=>{l(!1),p()},S=b=>{d(b.template),u(!0)},m=b=>{d(dL(b)),h(b.id),u(!0)},y=()=>{c?r(c,f):i(f),p()};O.useEffect(()=>{if(!o)return;const b=C=>{C.key==="Escape"&&g()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[o]);const v=new Set(t.map(b=>b.fromSecurityScheme).filter(Boolean)),x=e.filter(b=>!v.has(b.schemeName));return k.jsxs(k.Fragment,{children:[k.jsxs("button",{type:"button",className:"credentials-trigger",onClick:()=>l(!0),children:[k.jsx("span",{className:"credentials-trigger__count",children:t.length}),"credential",t.length===1?"":"s"]}),o&&k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"credentials-drawer__backdrop",onClick:g}),k.jsxs("aside",{className:"credentials-drawer",children:[k.jsxs("div",{className:"credentials-drawer__header",children:[k.jsx("h2",{children:"Credentials"}),k.jsx("button",{type:"button",className:"pane-collapse-btn",onClick:g,title:"Close","aria-label":"Close credentials",children:"✕"})]}),k.jsxs("div",{className:"credentials-drawer__body",children:[t.length===0&&!a&&k.jsx("p",{className:"credentials-drawer__empty",children:`No credentials yet. Add one, then attach it to a node from the inspector's "Credential" dropdown.`}),t.length>0&&k.jsx("ul",{className:"credentials-drawer__list",children:t.map(b=>k.jsx(mL,{credential:b,usageCount:n.filter(C=>C.credentialId===b.id).length,onEdit:m,onDelete:s},b.id))}),!a&&k.jsx(bL,{entries:x,onConfigure:S}),a?k.jsx(kL,{draft:f,setDraft:d,editingId:c,onCancel:p,onSave:y}):k.jsx("button",{type:"button",className:"credentials-drawer__add-btn",onClick:()=>u(!0),children:"+ New credential"})]})]})]})]})}function EL(){const{operations:t,loadOperations:e,run:n,isRunning:i,nodes:r,stepStatusByNodeId:s,selectedNodeId:o,activeControl:l,continueExecution:a,stepNode:u,stopExecution:c}=Ye(),[h,f]=O.useState(!0),[d,p]=O.useState(!0);O.useEffect(()=>{e()},[e]);const g=r.filter(m=>s[m.id]==="paused").map(m=>m.id),S=g.includes(o??"")?o:g[0];return k.jsxs("div",{className:"app",children:[k.jsxs("header",{className:"app__header",children:[k.jsxs("h1",{className:"app__title",children:[k.jsx("img",{src:"./favicon.svg",alt:"",className:"app__logo"}),"Enlace"]}),k.jsx(CL,{}),!l&&k.jsxs(k.Fragment,{children:[k.jsx("button",{type:"button",className:"btn btn--execute",onClick:()=>n(),disabled:i,children:i?"Running…":"Run"}),k.jsx("button",{type:"button",className:"btn btn--secondary",onClick:()=>n({useBreakpoints:!0}),disabled:i,title:"Run, honoring any breakpoints armed on the canvas",children:"Debug"})]}),l&&k.jsxs("div",{className:"app__run-controls",children:[k.jsx("button",{type:"button",className:"btn btn--icon btn--execute",onClick:a,disabled:g.length===0,title:"Continue — release every node currently paused","aria-label":"Continue",children:"▶"}),k.jsx("button",{type:"button",className:"btn btn--icon btn--secondary",onClick:()=>S&&u(S),disabled:!S,title:g.length>1?"Step — release just the selected paused node (or the first paused node, if none is selected)":"Step — release the paused node","aria-label":"Step",children:"⏭"}),k.jsx("button",{type:"button",className:"btn btn--icon btn--stop",onClick:c,title:"Stop — nothing new fires; anything already in flight still completes","aria-label":"Stop",children:"■"})]})]}),k.jsxs("div",{className:`app__body${h?"":" app__body--inspector-collapsed"}`,children:[k.jsx(RN,{operations:t}),k.jsx(NP,{}),h?k.jsx(tL,{onCollapse:()=>f(!1)}):k.jsx("button",{type:"button",className:"pane-strip pane-strip--right",onClick:()=>f(!0),title:"Show inspector","aria-label":"Show inspector",children:"‹"})]}),k.jsx(hL,{collapsed:!d,onToggleCollapsed:()=>p(m=>!m)})]})}Gh.createRoot(document.getElementById("root")).render(k.jsx(j.StrictMode,{children:k.jsx(EL,{})}));