static.saga-statemachine-designer.bundle.js Maven / Gradle / Ivy
Show all versions of seata-console Show documentation
/*! For license information please see bundle.js.LICENSE.txt */
(()=>{var e={235:(e,t,n)=>{e.exports=n(302),e.exports.Collection=n(48)},48:e=>{"use strict";e.exports.extend=function(e,t,n,o){var r=n.inverse;return Object.defineProperty(e,"remove",{value:function(e){var n=this.indexOf(e);return-1!==n&&(this.splice(n,1),t.unset(e,r,o)),e}}),Object.defineProperty(e,"contains",{value:function(e){return-1!==this.indexOf(e)}}),Object.defineProperty(e,"add",{value:function(e,n){var i=this.indexOf(e);if(void 0===n){if(-1!==i)return;n=this.length}-1!==i&&this.splice(i,1),this.splice(n,0,e),-1===i&&t.set(e,r,o)}}),Object.defineProperty(e,"__refs_collection",{value:!0}),e},e.exports.isExtended=function(e){return!0===e.__refs_collection}},302:(e,t,n)=>{"use strict";var o=n(48);function r(e,t,n){var r=o.extend(n[t.name]||[],e,t,n);Object.defineProperty(n,t.name,{enumerable:t.enumerable,value:r}),r.length&&r.forEach((function(o){e.set(o,t.inverse,n)}))}function i(e,t){if(!(this instanceof i))return new i(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}i.prototype.bind=function(e,t){if("string"==typeof t){if(!this.props[t])throw new Error("no property <"+t+"> in ref");t=this.props[t]}t.collection?r(this,t,e):function(e,t,n){var o=t.inverse,r=n[t.name];Object.defineProperty(n,t.name,{configurable:t.configurable,enumerable:t.enumerable,get:function(){return r},set:function(t){if(t!==r){var i=r;r=null,i&&e.unset(i,o,n),r=t,e.set(r,o,n)}}})}(this,t,e)},i.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return o.isExtended(n)||r(this,t,e),n},i.prototype.ensureBound=function(e,t){(function(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)})(e,t)||this.bind(e,t)},i.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},i.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)},e.exports=i},720:e=>{"use strict";var t=/,?([a-z]),?/gi,n=parseFloat,o=Math,r=o.PI,i=o.min,s=o.max,a=o.pow,l=o.abs,c=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/gi,u=/(-?\d*\.?\d*(?:e[-+]?\d+)?)[\s]*,?[\s]*/gi,h=Array.isArray||function(e){return e instanceof Array};function p(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function f(e){if("function"==typeof e||Object(e)!==e)return e;var t=new e.constructor;for(var n in e)p(e,n)&&(t[n]=f(e[n]));return t}function d(e){var t=d.ps=d.ps||{};return t[e]?t[e].sleep=100:t[e]={sleep:100},setTimeout((function(){for(var n in t)p(t,n)&&n!=e&&(t[n].sleep--,!t[n].sleep&&delete t[n])})),t[e]}function g(e,t,n,o){return 1===arguments.length&&(t=e.y,n=e.width,o=e.height,e=e.x),{x:e,y:t,width:n,height:o,x2:e+n,y2:t+o}}function m(){return this.join(",").replace(t,"$1")}function y(e){var t=f(e);return t.toString=m,t}function v(e,t,n,o,r,i,s,l,c){var u=1-c,h=a(u,3),p=a(u,2),f=c*c*c,d=h*t+3*p*c*o+3*u*c*c*i+f*l;return{x:k(h*e+3*p*c*n+3*u*c*c*r+f*s),y:k(d)}}function b(e){var t=M.apply(null,e);return g(t.x0,t.y0,t.x1-t.x0,t.y1-t.y0)}function x(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function w(e,t,n,o,r){return e*(e*(-3*t+9*n-9*o+3*r)+6*t-12*n+6*o)-3*t+3*n}function O(e,t,n,r,i,s,a,l,c){null==c&&(c=1);for(var u=(c=c>1?1:c<0?0:c)/2,h=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],p=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],f=0,d=0;d<12;d++){var g=u*h[d]+u,m=w(g,e,n,i,a),y=w(g,t,r,s,l),v=m*m+y*y;f+=p[d]*o.sqrt(v)}return u*f}function _(e,t,n,o,r,a,l,c){if(!(s(e,n)s(r,l)||s(t,o)s(a,c))){var u=(e*o-t*n)*(a-c)-(t-o)*(r*c-a*l),h=(e-n)*(a-c)-(t-o)*(r-l);if(h){var p=k(((e*o-t*n)*(r-l)-(e-n)*(r*c-a*l))/h),f=k(u/h),d=+p.toFixed(2),g=+f.toFixed(2);if(!(d<+i(e,n).toFixed(2)||d>+s(e,n).toFixed(2)||d<+i(r,l).toFixed(2)||d>+s(r,l).toFixed(2)||g<+i(t,o).toFixed(2)||g>+s(t,o).toFixed(2)||g<+i(a,c).toFixed(2)||g>+s(a,c).toFixed(2)))return{x:p,y:f}}}}function k(e){return Math.round(1e11*e)/1e11}function S(e,t,n){if(o=b(e),r=b(t),o=g(o),!(x(r=g(r),o.x,o.y)||x(r,o.x2,o.y)||x(r,o.x,o.y2)||x(r,o.x2,o.y2)||x(o,r.x,r.y)||x(o,r.x2,r.y)||x(o,r.x,r.y2)||x(o,r.x2,r.y2)||(o.xr.x||r.xo.x)&&(o.yr.y||r.yo.y)))return n?0:[];for(var o,r,i=O.apply(0,e),s=O.apply(0,t),a=C(e)?1:~~(i/5)||1,c=C(t)?1:~~(s/5)||1,u=[],h=[],p={},f=n?0:[],d=0;d=0&&R<=1&&j>=0&&j<=1&&(n?f++:f.push({x:M.x,y:M.y,t1:R,t2:j}))}}return f}function E(e){var t=d(e);if(t.abs)return y(t.abs);if(h(e)&&h(e&&e[0])||(e=function(e){if(!e)return null;var t=d(e);if(t.arr)return f(t.arr);var n={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},o=[];return h(e)&&h(e[0])&&(o=f(e)),o.length||String(e).replace(c,(function(e,t,r){var i=[],s=t.toLowerCase();for(r.replace(u,(function(e,t){t&&i.push(+t)})),"m"==s&&i.length>2&&(o.push([t].concat(i.splice(0,2))),s="l",t="m"==t?"l":"L");i.length>=n[s]&&(o.push([t].concat(i.splice(0,n[s]))),n[s]););})),o.toString=d.toString,t.arr=f(o),o}(e)),!e||!e.length)return[["M",0,0]];var n,o=[],r=0,i=0,s=0,a=0,l=0;"M"==e[0][0]&&(s=r=+e[0][1],a=i=+e[0][2],l++,o[0]=["M",r,i]);for(var p,g,v=l,b=e.length;v=1e3&&delete o[r.shift()],r.push(n),o[n]=g.apply(0,t),o[n])});if(f)P=f[0],A=f[1],E=f[2],C=f[3];else{e=(d=b(e,t,-y)).x,t=d.y;var x=(e-(u=(d=b(u,h,-y)).x))/2,w=(t-(h=d.y))/2,O=x*x/(n*n)+w*w/(i*i);O>1&&(n*=O=o.sqrt(O),i*=O);var _=n*n,k=i*i,S=(a==c?-1:1)*o.sqrt(l((_*k-_*w*w-k*x*x)/(_*w*w+k*x*x))),E=S*n*w/i+(e+u)/2,C=S*-i*x/n+(t+h)/2,P=o.asin(((t-C)/i).toFixed(9)),A=o.asin(((h-C)/i).toFixed(9));(P=eA&&(P-=2*r),!c&&A>P&&(A-=2*r)}var M=A-P;if(l(M)>m){var R=A,j=u,B=h;A=P+m*(c&&A>P?1:-1),v=T(u=E+n*o.cos(A),h=C+i*o.sin(A),n,i,s,0,c,j,B,[A,R,E,C])}M=A-P;var D=o.cos(P),L=o.sin(P),$=o.cos(A),I=o.sin(A),N=o.tan(M/4),q=4/3*n*N,F=4/3*i*N,Q=[e,t],H=[e+q*L,t-F*D],z=[u+q*I,h-F*$],V=[u,h];if(H[0]=2*Q[0]-H[0],H[1]=2*Q[1]-H[1],f)return[H,z,V].concat(v);for(var W=[],X=0,G=(v=[H,z,V].concat(v).join().split(",")).length;X7){e[t].shift();for(var n=e[t];n.length;)a[t]="A",e.splice(t++,0,["C"].concat(n.splice(0,6)));e.splice(t,1),h=o.length}},a=[],l="",c="",u=0,h=o.length;u{var n;!function(){"use strict";var o={}.hasOwnProperty;function r(){for(var e="",t=0;t{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e,t,o,r,i,s,a,l,c={},u=[],h=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,p=Array.isArray;function f(e,t){for(var n in t)e[n]=t[n];return e}function d(e){var t=e.parentNode;t&&t.removeChild(e)}function g(t,n,o){var r,i,s,a={};for(s in n)"key"==s?r=n[s]:"ref"==s?i=n[s]:a[s]=n[s];if(arguments.length>2&&(a.children=arguments.length>3?e.call(arguments,2):o),"function"==typeof t&&null!=t.defaultProps)for(s in t.defaultProps)void 0===a[s]&&(a[s]=t.defaultProps[s]);return m(t,a,r,i,null)}function m(e,n,r,i,s){var a={type:e,props:n,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==s?++o:s,__i:-1,__u:0};return null==s&&null!=t.vnode&&t.vnode(a),a}function y(e){return e.children}function v(e,t){this.props=e,this.context=t}function b(e,t){if(null==t)return e.__?b(e.__,e.__i+1):null;for(var n;tn&&r.sort(a));O.__r=0}function _(e,t,n,o,r,i,s,a,l,h,p){var f,d,g,m,y,v=o&&o.__k||u,b=t.length;for(n.__d=l,k(n,t,v),l=n.__d,f=0;f0?m(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)?(r.__=e,r.__b=e.__b+1,a=C(r,n,s=o+h,u),r.__i=a,i=null,-1!==a&&(u--,(i=n[a])&&(i.__u|=131072)),null==i||null===i.__v?(-1==a&&h--,"function"!=typeof r.type&&(r.__u|=65536)):a!==s&&(a===s+1?h++:a>s?u>l-s?h+=a-s:h--:h=a(null!=l&&0==(131072&l.__u)?1:0))for(;s>=0||a=0){if((l=t[s])&&0==(131072&l.__u)&&r==l.key&&i===l.type)return s;s--}if(a2&&(l.children=arguments.length>3?e.call(arguments,2):o),m(t.type,l,r||t.key,i||t.ref,null)}function F(e,t){var n={__c:t="__cC"+l++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var n,o;return this.getChildContext||(n=[],(o={})[t]=this,this.getChildContext=function(){return o},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&n.some((function(e){e.__e=!0,w(e)}))},this.sub=function(e){n.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n.splice(n.indexOf(e),1),t&&t.call(e)}}),e.children}};return n.Provider.__=n.Consumer.contextType=n}e=u.slice,t={__e:function(e,t,n,o){for(var r,i,s;t=t.__;)if((r=t.__c)&&!r.__)try{if((i=r.constructor)&&null!=i.getDerivedStateFromError&&(r.setState(i.getDerivedStateFromError(e)),s=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,o||{}),s=r.__d),s)return r.__E=r}catch(t){e=t}throw e}},o=0,v.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=f({},this.state),"function"==typeof e&&(e=e(f({},n),this.props)),e&&f(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),w(this))},v.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),w(this))},v.prototype.render=y,r=[],s="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,a=function(e,t){return e.__v.__b-t.__v.__b},O.__r=0,l=0;var Q,H,z,V,W=0,X=[],G=[],U=t.__b,Y=t.__r,Z=t.diffed,K=t.__c,J=t.unmount;function ee(e,n){t.__h&&t.__h(H,e,W||n),W=0;var o=H.__H||(H.__H={__:[],__h:[]});return e>=o.__.length&&o.__.push({__V:G}),o.__[e]}function te(e){return W=1,ne(ge,e)}function ne(e,t,n){var o=ee(Q++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):ge(void 0,t),function(e){var t=o.__N?o.__N[0]:o.__[0],n=o.t(t,e);t!==n&&(o.__N=[n,o.__[1]],o.__c.setState({}))}],o.__c=H,!H.u)){var r=function(e,t,n){if(!o.__c.__H)return!0;var r=o.__c.__H.__.filter((function(e){return e.__c}));if(r.every((function(e){return!e.__N})))return!i||i.call(this,e,t,n);var s=!1;return r.forEach((function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(s=!0)}})),!(!s&&o.__c.props===e)&&(!i||i.call(this,e,t,n))};H.u=!0;var i=H.shouldComponentUpdate,s=H.componentWillUpdate;H.componentWillUpdate=function(e,t,n){if(this.__e){var o=i;i=void 0,r(e,t,n),i=o}s&&s.call(this,e,t,n)},H.shouldComponentUpdate=r}return o.__N||o.__}function oe(e,n){var o=ee(Q++,3);!t.__s&&de(o.__H,n)&&(o.__=e,o.i=n,H.__H.__h.push(o))}function re(e,n){var o=ee(Q++,4);!t.__s&&de(o.__H,n)&&(o.__=e,o.i=n,H.__h.push(o))}function ie(e){return W=5,se((function(){return{current:e}}),[])}function se(e,t){var n=ee(Q++,7);return de(n.__H,t)?(n.__V=e(),n.i=t,n.__h=e,n.__V):n.__}function ae(e,t){return W=8,se((function(){return e}),t)}function le(e){var t=H.context[e.__c],n=ee(Q++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(H)),t.props.value):e.__}function ce(){for(var e;e=X.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(pe),e.__H.__h.forEach(fe),e.__H.__h=[]}catch(n){e.__H.__h=[],t.__e(n,e.__v)}}t.__b=function(e){H=null,U&&U(e)},t.__r=function(e){Y&&Y(e),Q=0;var t=(H=e.__c).__H;t&&(z===H?(t.__h=[],H.__h=[],t.__.forEach((function(e){e.__N&&(e.__=e.__N),e.__V=G,e.__N=e.i=void 0}))):(t.__h.forEach(pe),t.__h.forEach(fe),t.__h=[],Q=0)),z=H},t.diffed=function(e){Z&&Z(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(1!==X.push(n)&&V===t.requestAnimationFrame||((V=t.requestAnimationFrame)||he)(ce)),n.__H.__.forEach((function(e){e.i&&(e.__H=e.i),e.__V!==G&&(e.__=e.__V),e.i=void 0,e.__V=G}))),z=H=null},t.__c=function(e,n){n.some((function(e){try{e.__h.forEach(pe),e.__h=e.__h.filter((function(e){return!e.__||fe(e)}))}catch(o){n.some((function(e){e.__h&&(e.__h=[])})),n=[],t.__e(o,e.__v)}})),K&&K(e,n)},t.unmount=function(e){J&&J(e);var n,o=e.__c;o&&o.__H&&(o.__H.__.forEach((function(e){try{pe(e)}catch(e){n=e}})),o.__H=void 0,n&&t.__e(n,o.__v))};var ue="function"==typeof requestAnimationFrame;function he(e){var t,n=function(){clearTimeout(o),ue&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,100);ue&&(t=requestAnimationFrame(n))}function pe(e){var t=H,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),H=t}function fe(e){var t=H;e.__c=e.__(),H=t}function de(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function ge(e,t){return"function"==typeof t?t(e):t}function me(e){return Array.prototype.concat.apply([],e)}const ye=Object.prototype.toString,ve=Object.prototype.hasOwnProperty;function be(e){return void 0===e}function xe(e){return void 0!==e}function we(e){return null==e}function Oe(e){return"[object Array]"===ye.call(e)}function _e(e){return"[object Object]"===ye.call(e)}function ke(e){return"[object Number]"===ye.call(e)}function Se(e){const t=ye.call(e);return"[object Function]"===t||"[object AsyncFunction]"===t||"[object GeneratorFunction]"===t||"[object AsyncGeneratorFunction]"===t||"[object Proxy]"===t}function Ee(e){return"[object String]"===ye.call(e)}function Ce(e,t){return ve.call(e,t)}function Pe(e,t){const n=He(t);let o;return Te(e,(function(e,t){if(n(e,t))return o=e,!1})),o}function Ae(e,t){const n=He(t);let o=[];return Te(e,(function(e,t){n(e,t)&&o.push(e)})),o}function Te(e,t){let n,o;if(be(e))return;const r=Oe(e)?Ve:ze;for(let i in e)if(Ce(e,i)&&(n=e[i],o=t(n,r(i)),!1===o))return n}function Me(e,t,n){return Te(e,(function(e,o){n=t(n,e,o)})),n}function Re(e,t){return!!Me(e,(function(e,n,o){return e&&t(n,o)}),!0)}function je(e,t){return!!Pe(e,t)}function Be(e,t){let n=[];return Te(e,(function(e,o){n.push(t(e,o))})),n}function De(e){return e&&Object.keys(e)||[]}function Le(e){return Be(e,(e=>e))}function $e(e,t,n={}){return t=Qe(t),Te(e,(function(e){let o=t(e)||"_",r=n[o];r||(r=n[o]=[]),r.push(e)})),n}function Ie(e,...t){e=Qe(e);let n={};return Te(t,(t=>$e(t,e,n))),Be(n,(function(e,t){return e[0]}))}const Ne=Ie;function qe(e,t){t=Qe(t);let n=[];return Te(e,(function(e,o){let r=t(e,o),i={d:r,v:e};for(var s=0;se.v))}function Fe(e){return function(t){return Re(e,(function(e,n){return t[n]===e}))}}function Qe(e){return Se(e)?e:t=>t[e]}function He(e){return Se(e)?e:t=>t===e}function ze(e){return e}function Ve(e){return Number(e)}function We(e,t){let n,o,r,i;function s(n){let s=Date.now(),c=n?0:i+t-s;if(c>0)return a(c);e.apply(r,o),l()}function a(e){n=setTimeout(s,e)}function l(){n&&clearTimeout(n),n=i=o=r=void 0}function c(...e){i=Date.now(),o=e,r=this,n||a(t)}return c.flush=function(){n&&s(!0),l()},c.cancel=l,c}function Xe(e,t){return e.bind(t)}function Ge(e,...t){return Object.assign(e,...t)}function Ue(e,t){let n={},o=Object(e);return Te(t,(function(t){t in o&&(n[t]=e[t])})),n}function Ye(e,t){for(var n in t)e[n]=t[n];return e}function Ze(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var o in t)if("__source"!==o&&e[o]!==t[o])return!0;return!1}function Ke(e){this.props=e}(Ke.prototype=new v).isPureReactComponent=!0,Ke.prototype.shouldComponentUpdate=function(e,t){return Ze(this.props,e)||Ze(this.state,t)};var Je=t.__b;t.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Je&&Je(e)};var et="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function tt(e){function t(t){var n=Ye({},t);return delete n.ref,e(n,t.ref||null)}return t.$$typeof=et,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var nt=function(e,t){return null==e?null:E(E(e).map(t))},ot={map:nt,forEach:nt,count:function(e){return e?E(e).length:0},only:function(e){var t=E(e);if(1!==t.length)throw"Children.only";return t[0]},toArray:E},rt=t.__e;t.__e=function(e,t,n,o){if(e.then)for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t);rt(e,t,n,o)};var it=t.unmount;function st(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(e){"function"==typeof e.__c&&e.__c()})),e.__c.__H=null),null!=(e=Ye({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return st(e,t,n)}))),e}function at(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return at(e,t,n)})),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function lt(){this.__u=0,this.t=null,this.__b=null}function ct(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ut(){this.u=null,this.o=null}t.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),it&&it(e)},(lt.prototype=new v).__c=function(e,t){var n=t.__c,o=this;null==o.t&&(o.t=[]),o.t.push(n);var r=ct(o.__v),i=!1,s=function(){i||(i=!0,n.__R=null,r?r(a):a())};n.__R=s;var a=function(){if(! --o.__u){if(o.state.__a){var e=o.state.__a;o.__v.__k[0]=at(e,e.__c.__P,e.__c.__O)}var t;for(o.setState({__a:o.__b=null});t=o.t.pop();)t.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(s,s)},lt.prototype.componentWillUnmount=function(){this.t=[]},lt.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=st(this.__b,n,o.__O=o.__P)}this.__b=null}var r=t.__a&&g(y,null,e.fallback);return r&&(r.__u&=-33),[g(y,null,t.__a?null:e.children),r]};var ht=function(e,t,n){if(++n[1]===n[0]&&e.o.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.o.size))for(n=e.u;n;){for(;n.length>3;)n.pop()();if(n[1]>>1,1),t.i.removeChild(e)}}),I(g(pt,{context:t.context},e.__v),t.l)}function dt(e,t){var n=g(ft,{__v:e,i:t});return n.containerInfo=t,n}(ut.prototype=new v).__a=function(e){var t=this,n=ct(t.__v),o=t.o.get(e);return o[0]++,function(r){var i=function(){t.props.revealOrder?(o.push(r),ht(t,e,o)):r()};n?n(i):i()}},ut.prototype.render=function(e){this.u=null,this.o=new Map;var t=E(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.o.set(t[n],this.u=[1,0,this.u]);return e.children},ut.prototype.componentDidUpdate=ut.prototype.componentDidMount=function(){var e=this;this.o.forEach((function(t,n){ht(e,n,t)}))};var gt="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,mt=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,yt=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,vt=/[A-Z0-9]/g,bt="undefined"!=typeof document,xt=function(e){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(e)};v.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(e){Object.defineProperty(v.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})}));var wt=t.event;function Ot(){}function _t(){return this.cancelBubble}function kt(){return this.defaultPrevented}t.event=function(e){return wt&&(e=wt(e)),e.persist=Ot,e.isPropagationStopped=_t,e.isDefaultPrevented=kt,e.nativeEvent=e};var St,Et={enumerable:!1,configurable:!0,get:function(){return this.class}},Ct=t.vnode;t.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,o={};for(var r in t){var i=t[r];if(!("value"===r&&"defaultValue"in t&&null==i||bt&&"children"===r&&"noscript"===n||"class"===r||"className"===r)){var s=r.toLowerCase();"defaultValue"===r&&"value"in t&&null==t.value?r="value":"download"===r&&!0===i?i="":"ondoubleclick"===s?r="ondblclick":"onchange"!==s||"input"!==n&&"textarea"!==n||xt(t.type)?"onfocus"===s?r="onfocusin":"onblur"===s?r="onfocusout":yt.test(r)?r=s:-1===n.indexOf("-")&&mt.test(r)?r=r.replace(vt,"-$&").toLowerCase():null===i&&(i=void 0):s=r="oninput","oninput"===s&&o[r=s]&&(r="oninputCapture"),o[r]=i}}"select"==n&&o.multiple&&Array.isArray(o.value)&&(o.value=E(t.children).forEach((function(e){e.props.selected=-1!=o.value.indexOf(e.props.value)}))),"select"==n&&null!=o.defaultValue&&(o.value=E(t.children).forEach((function(e){e.props.selected=o.multiple?-1!=o.defaultValue.indexOf(e.props.value):o.defaultValue==e.props.value}))),t.class&&!t.className?(o.class=t.class,Object.defineProperty(o,"className",Et)):(t.className&&!t.class||t.class&&t.className)&&(o.class=o.className=t.className),e.props=o}(e),e.$$typeof=gt,Ct&&Ct(e)};var Pt=t.__r;t.__r=function(e){Pt&&Pt(e),St=e.__c};var At=t.diffed;t.diffed=function(e){At&&At(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value),St=null};var Tt={ReactCurrentDispatcher:{current:{readContext:function(e){return St.__n[e.__c].props.value}}}};function Mt(e){return!!e&&e.$$typeof===gt}function Rt(e){e()}function jt(e){var t,n,o=e.v,r=e.__;try{var i=o();return!((t=r)===(n=i)&&(0!==t||1/t==1/n)||t!=t&&n!=n)}catch(e){return!0}}var Bt={useState:te,useId:function(){var e=ee(Q++,11);if(!e.__){for(var t=H.__v;null!==t&&!t.__m&&null!==t.__;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__},useReducer:ne,useEffect:oe,useLayoutEffect:re,useInsertionEffect:re,useTransition:function(){return[!1,Rt]},useDeferredValue:function(e){return e},useSyncExternalStore:function(e,t){var n=t(),o=te({h:{__:n,v:t}}),r=o[0].h,i=o[1];return re((function(){r.__=n,r.v=t,jt(r)&&i({h:r})}),[e,n,t]),oe((function(){return jt(r)&&i({h:r}),e((function(){jt(r)&&i({h:r})}))}),[e]),n},startTransition:Rt,useRef:ie,useImperativeHandle:function(e,t,n){W=6,re((function(){return"function"==typeof e?(e(t()),function(){return e(null)}):e?(e.current=t(),function(){return e.current=null}):void 0}),null==n?n:n.concat(e))},useMemo:se,useCallback:ae,useContext:le,useDebugValue:function(e,n){t.useDebugValue&&t.useDebugValue(n?n(e):e)},version:"17.0.2",Children:ot,render:function(e,t,n){return null==t.__k&&(t.textContent=""),I(e,t),"function"==typeof n&&n(),e?e.__c:null},hydrate:function(e,t,n){return N(e,t),"function"==typeof n&&n(),e?e.__c:null},unmountComponentAtNode:function(e){return!!e.__k&&(I(null,e),!0)},createPortal:dt,createElement:g,createContext:F,createFactory:function(e){return g.bind(null,e)},cloneElement:function(e){return Mt(e)?q.apply(null,arguments):e},createRef:function(){return{current:null}},Fragment:y,isValidElement:Mt,isElement:Mt,isFragment:function(e){return Mt(e)&&e.type===y},findDOMNode:function(e){return e&&(e.base||1===e.nodeType&&e)||null},Component:v,PureComponent:Ke,memo:function(e,t){function n(e){var n=this.props.ref,o=n==e.ref;return!o&&n&&(n.call?n(null):n.current=null),t?!t(this.props,e)||!o:Ze(this.props,e)}function o(t){return this.shouldComponentUpdate=n,g(e,t)}return o.displayName="Memo("+(e.displayName||e.name)+")",o.prototype.isReactComponent=!0,o.__f=!0,o},forwardRef:tt,flushSync:function(e,t){return e(t)},unstable_batchedUpdates:function(e,t){return e(t)},StrictMode:y,Suspense:lt,SuspenseList:ut,lazy:function(e){var t,n,o;function r(r){if(t||(t=e()).then((function(e){n=e.default||e}),(function(e){o=e})),o)throw o;if(!n)throw t;return g(n,r)}return r.displayName="Lazy",r.__f=!0,r},__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Tt},Dt=0;function Lt(e,n,o,r,i,s){var a,l,c={};for(l in n)"ref"==l?a=n[l]:c[l]=n[l];var u={type:e,props:c,key:o,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--Dt,__i:-1,__u:0,__source:i,__self:s};if("function"==typeof e&&(a=e.defaultProps))for(l in a)void 0===c[l]&&(c[l]=a[l]);return t.vnode&&t.vnode(u),u}Array.isArray;var $t=n(967),It=n.n($t);function Nt(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}const qt=Object.prototype.toString,Ft=Object.prototype.hasOwnProperty;function Qt(e,t){return Ft.call(e,t)}function Ht(e,t){let n,o;if(void 0===e)return;const r=(i=e,"[object Array]"===qt.call(i)?Vt:zt);var i;for(let i in e)if(Qt(e,i)&&(n=e[i],o=t(n,r(i)),!1===o))return n}function zt(e){return e}function Vt(e){return Number(e)}function Wt(e,...t){const n=e.style;return Ht(t,(function(e){e&&Ht(e,(function(e,t){n[t]=e}))})),e}function Xt(e,t,n){return 2==arguments.length?e.getAttribute(t):null===n?e.removeAttribute(t):(e.setAttribute(t,n),e)}const Gt=Object.prototype.toString;function Ut(e){return new Yt(e)}function Yt(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function Zt(e){for(var t;e.childNodes.length;)t=e.childNodes[0],e.removeChild(t);return e}function Kt(e,t){return e&&"function"==typeof e.matches&&e.matches(t)}function Jt(e,t,n){for(var o=n?e:e.parentNode;o&&o.nodeType!==document.DOCUMENT_NODE&&o.nodeType!==document.DOCUMENT_FRAGMENT_NODE;){if(Kt(o,t))return o;o=o.parentNode}return Kt(o,t)?o:null}Yt.prototype.add=function(e){return this.list.add(e),this},Yt.prototype.remove=function(e){return"[object RegExp]"==Gt.call(e)?this.removeMatching(e):(this.list.remove(e),this)},Yt.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n
a',fn=!sn.getElementsByTagName("link").length,sn=void 0);var dn={legend:[1,""],tr:[2,"","
"],col:[2,"","
"],_default:fn?[1,"X",""]:[0,"",""]};dn.td=dn.th=[3,"","
"],dn.option=dn.optgroup=[1,'"],dn.thead=dn.tbody=dn.colgroup=dn.caption=dn.tfoot=[1,"","
"],dn.polyline=dn.ellipse=dn.polygon=dn.circle=dn.text=dn.line=dn.path=dn.rect=dn.g=[1,'"];var gn=function(e,t){if("string"!=typeof e)throw new TypeError("String expected");t||(t=document);var n=/<([\w:]+)/.exec(e);if(!n)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var o=n[1];if("body"==o)return(l=t.createElement("html")).innerHTML=e,l.removeChild(l.lastChild);var r=Object.prototype.hasOwnProperty.call(dn,o)?dn[o]:dn._default,i=r[0],s=r[1],a=r[2],l=t.createElement("div");for(l.innerHTML=s+e+a;i--;)l=l.lastChild;if(l.firstChild==l.lastChild)return l.removeChild(l.firstChild);for(var c=t.createDocumentFragment();l.firstChild;)c.appendChild(l.removeChild(l.firstChild));return c};function mn(e,t){return(t=t||document).querySelector(e)}function yn(e,t){return(t=t||document).querySelectorAll(e)}function vn(e){e.parentNode&&e.parentNode.removeChild(e)}const bn=1024;let xn=0;class wn{constructor(e,t){this.from=e,this.to=t}}class On{constructor(e={}){this.id=xn++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=Sn.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}On.closedBy=new On({deserialize:e=>e.split(" ")}),On.openedBy=new On({deserialize:e=>e.split(" ")}),On.group=new On({deserialize:e=>e.split(" ")}),On.isolate=new On({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),On.contextHash=new On({perNode:!0}),On.lookAhead=new On({perNode:!0}),On.mounted=new On({perNode:!0});class _n{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[On.mounted.id]}}const kn=Object.create(null);class Sn{constructor(e,t,n,o=0){this.name=e,this.props=t,this.id=n,this.flags=o}static define(e){let t=e.props&&e.props.length?Object.create(null):kn,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),o=new Sn(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(o)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return o}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(On.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let o of n.split(" "))t[o]=e[n];return e=>{for(let n=e.prop(On.group),o=-1;o<(n?n.length:0);o++){let r=t[o<0?e.name:n[o]];if(r)return r}}}}Sn.none=new Sn("",Object.create(null),0,8);class En{constructor(e){this.types=e;for(let t=0;t=t){let s=new Ln(i.tree,i.overlay[0].from+e.from,-1,e);(r||(r=[o])).push(Bn(s,t,n,!1))}}return r?Fn(r):o}(this,e,t)}iterate(e){let{enter:t,leave:n,from:o=0,to:r=this.length}=e,i=e.mode||0,s=(i&An.IncludeAnonymous)>0;for(let e=this.cursor(i|An.IncludeAnonymous);;){let i=!1;if(e.from<=r&&e.to>=o&&(!s&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;i=!0}for(;i&&n&&(s||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;i=!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 t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Xn(Sn.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,n)=>new Tn(this.type,e,t,n,this.propValues)),e.makeTree||((e,t,n)=>new Tn(Sn.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:o,maxBufferLength:r=bn,reused:i=[],minRepeatType:s=o.types.length}=e,a=Array.isArray(n)?new Mn(n,n.length):n,l=o.types,c=0,u=0;function h(e,t,n,m,y,v){let{id:b,start:x,end:w,size:O}=a,_=u;for(;O<0;){if(a.next(),-1==O){let t=i[b];return n.push(t),void m.push(x-e)}if(-3==O)return void(c=b);if(-4==O)return void(u=b);throw new RangeError(`Unrecognized record size: ${O}`)}let k,S,E=l[b],C=x-e;if(w-x<=r&&(S=function(e,t){let n=a.fork(),o=0,i=0,l=0,c=n.end-r,u={size:0,start:0,skip:0};e:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=o,u.start=i,u.skip=l,l+=4,o+=4,n.next();continue}let a=n.pos-e;if(e<0||a=s?4:0,p=n.start;for(n.next();n.pos>a;){if(n.size<0){if(-3!=n.size)break e;h+=4}else n.id>=s&&(h+=4);n.next()}i=p,o+=e,l+=h}return(t<0||o==e)&&(u.size=o,u.start=i,u.skip=l),u.size>4?u:void 0}(a.pos-t,y))){let t=new Uint16Array(S.size-S.skip),n=a.pos-S.size,r=t.length;for(;a.pos>n;)r=g(S.start,t,r);k=new Rn(t,w-S.start,o),C=S.start-e}else{let e=a.pos-O;a.next();let t=[],n=[],o=b>=s?b:-1,i=0,l=w;for(;a.pos>e;)o>=0&&a.id==o&&a.size>=0?(a.end<=l-r&&(f(t,n,x,i,a.end,l,o,_),i=t.length,l=a.end),a.next()):v>2500?p(x,e,t,n):h(x,e,t,n,o,v+1);if(o>=0&&i>0&&i-1&&i>0){let e=function(e){return(t,n,o)=>{let r,i,s=0,a=t.length-1;if(a>=0&&(r=t[a])instanceof Tn){if(!a&&r.type==e&&r.length==o)return r;(i=r.prop(On.lookAhead))&&(s=n[a]+r.length+i)}return d(e,t,n,o,s)}}(E);k=Xn(E,t,n,0,t.length,0,w-x,e,e)}else k=d(E,t,n,w-x,_-w)}n.push(k),m.push(C)}function p(e,t,n,i){let s=[],l=0,c=-1;for(;a.pos>t;){let{id:e,start:t,end:n,size:o}=a;if(o>4)a.next();else{if(c>-1&&t=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;n.push(new Rn(t,s[2]-r,o)),i.push(r-e)}}function f(e,t,n,r,i,s,a,l){let c=[],u=[];for(;e.length>r;)c.push(e.pop()),u.push(t.pop()+n-i);e.push(d(o.types[a],c,u,s-i,l-s)),t.push(i-n)}function d(e,t,n,o,r=0,i){if(c){let e=[On.contextHash,c];i=i?[e].concat(i):[e]}if(r>25){let e=[On.lookAhead,r];i=i?[e].concat(i):[e]}return new Tn(e,t,n,o,i)}function g(e,t,n){let{id:o,start:r,end:i,size:l}=a;if(a.next(),l>=0&&o4){let o=a.pos-(l-4);for(;a.pos>o;)n=g(e,t,n)}t[--n]=s,t[--n]=i-e,t[--n]=r-e,t[--n]=o}else-3==l?c=o:-4==l&&(u=o);return n}let m=[],y=[];for(;a.pos>0;)h(e.start||0,e.bufferStart||0,m,y,-1,0);let v=null!==(t=e.length)&&void 0!==t?t:m.length?y[0]+m[0].length:0;return new Tn(l[e.topID],m.reverse(),y.reverse(),v)}(e)}}Tn.empty=new Tn(Sn.none,[],[],0);class Mn{constructor(e,t){this.buffer=e,this.index=t}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 Mn(this.buffer,this.index)}}class Rn{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Sn.none}toString(){let e=[];for(let t=0;t0));a=i[a+3]);return s}slice(e,t,n){let o=this.buffer,r=new Uint16Array(t-e),i=0;for(let s=e,a=0;s=t&&nt;case 1:return n<=t&&o>t;case 2:return o>t;case 4:return!0}}function Bn(e,t,n,o){for(var r;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to0?s.length:-1;e!=l;e+=t){let l=s[e],c=a[e]+i.from;if(jn(o,n,c,c+l.length))if(l instanceof Rn){if(r&An.ExcludeBuffers)continue;let s=l.findChild(0,l.buffer.length,t,n-c,o);if(s>-1)return new qn(new Nn(i,l,e,c),null,s)}else if(r&An.IncludeAnonymous||!l.type.isAnonymous||zn(l)){let s;if(!(r&An.IgnoreMounts)&&(s=_n.get(l))&&!s.overlay)return new Ln(s.tree,c,e,i);let a=new Ln(l,c,e,i);return r&An.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?l.children.length-1:0,t,n,o)}}if(r&An.IncludeAnonymous||!i.type.isAnonymous)return null;if(e=i.index>=0?i.index+t:t<0?-1:i._parent._tree.children.length,i=i._parent,!i)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)}enter(e,t,n=0){let o;if(!(n&An.IgnoreOverlays)&&(o=_n.get(this._tree))&&o.overlay){let n=e-this.from;for(let{from:e,to:r}of o.overlay)if((t>0?e<=n:e=n:r>n))return new Ln(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}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 $n(e,t,n,o){let r=e.cursor(),i=[];if(!r.firstChild())return i;if(null!=n)for(let e=!1;!e;)if(e=r.type.is(n),!r.nextSibling())return i;for(;;){if(null!=o&&r.type.is(o))return i;if(r.type.is(t)&&i.push(r.node),!r.nextSibling())return null==o?i:[]}}function In(e,t,n=t.length-1){for(let o=e.parent;n>=0;o=o.parent){if(!o)return!1;if(!o.type.isAnonymous){if(t[n]&&t[n]!=o.name)return!1;n--}}return!0}class Nn{constructor(e,t,n,o){this.parent=e,this.buffer=t,this.index=n,this.start=o}}class qn extends Dn{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,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:o}=this.context,r=o.findChild(this.index+4,o.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new qn(this.context,this,r)}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)}enter(e,t,n=0){if(n&An.ExcludeBuffers)return null;let{buffer:o}=this.context,r=o.findChild(this.index+4,o.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new qn(this.context,this,r)}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,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new qn(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new qn(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,o=this.index+4,r=n.buffer[this.index+3];if(r>o){let i=n.buffer[this.index+1];e.push(n.slice(o,r,i)),t.push(0)}return new Tn(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Fn(e){if(!e.length)return null;let t=0,n=e[0];for(let o=1;on.from||r.to0){if(this.index-1)for(let o=t+e,r=e<0?-1:n._tree.children.length;o!=r;o+=e){let e=n._tree.children[o];if(this.mode&An.IncludeAnonymous||e instanceof Rn||!e.type.isAnonymous||zn(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let i=e;i;i=i._parent)if(i.index==o){if(o==this.index)return i;t=i,n=r+1;break e}o=this.stack[--r]}for(let e=n;e=0;r--){if(r<0)return In(this.node,e,o);let i=n[t.buffer[this.stack[r]]];if(!i.isAnonymous){if(e[o]&&e[o]!=i.name)return!1;o--}}return!0}}function zn(e){return e.children.some((e=>e instanceof Rn||!e.type.isAnonymous||zn(e)))}const Vn=new WeakMap;function Wn(e,t){if(!e.isAnonymous||t instanceof Rn||t.type!=e)return 1;let n=Vn.get(t);if(null==n){n=1;for(let o of t.children){if(o.type!=e||!(o instanceof Tn)){n=1;break}n+=Wn(e,o)}Vn.set(t,n)}return n}function Xn(e,t,n,o,r,i,s,a,l){let c=0;for(let n=o;n=u)break;d+=t}if(c==r+1){if(d>u){let e=n[r];t(e.children,e.positions,0,e.children.length,o[r]+a);continue}h.push(n[r])}else{let t=o[c-1]+n[c-1].length-f;h.push(Xn(e,n,o,r,c,f,t,null,l))}p.push(f+a-i)}}(t,n,o,r,0),(a||l)(h,p,s)}class Gn{constructor(e,t,n,o,r=!1,i=!1){this.from=e,this.to=t,this.tree=n,this.offset=o,this.open=(r?1:0)|(i?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let o=[new Gn(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&o.push(n);return o}static applyChanges(e,t,n=128){if(!t.length)return e;let o=[],r=1,i=e.length?e[0]:null;for(let s=0,a=0,l=0;;s++){let c=s=n)for(;i&&i.from=t.from||u<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,u)-l;t=e>=n?null:new Gn(e,n,t.tree,t.offset+l,s>0,!!c)}if(t&&o.push(t),i.to>u)break;i=rnew wn(e.from,e.to))):[new wn(0,0)]:[new wn(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let o=this.startParse(e,t,n);for(;;){let e=o.advance();if(e)return e}}}class Yn{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}class Zn{constructor(e,t,n,o,r){this.parser=e,this.parse=t,this.overlay=n,this.target=o,this.from=r}}function Kn(e){if(!e.length||e.some((e=>e.from>=e.to)))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class Jn{constructor(e,t,n,o,r,i,s){this.parser=e,this.predicate=t,this.mounts=n,this.index=o,this.start=r,this.target=i,this.prev=s,this.depth=0,this.ranges=[]}}const eo=new On({perNode:!0});class to{constructor(e,t,n,o,r){this.nest=t,this.input=n,this.fragments=o,this.ranges=r,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),null!=this.stoppedAt)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return null!=this.stoppedAt&&(e=new Tn(e.type,e.children,e.positions,e.length,e.propValues.concat([[eo,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[On.mounted.id]=new _n(t,e.overlay,e.parser),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t=this.stoppedAt)a=!1;else if(e.hasNode(o)){if(t){let e=t.mounts.find((e=>e.frag.from<=o.from&&e.frag.to>=o.to&&e.mount.overlay));if(e)for(let n of e.mount.overlay){let r=n.from+e.pos,i=n.to+e.pos;r>=o.from&&i<=o.to&&!t.ranges.some((e=>e.fromr))&&t.ranges.push({from:r,to:i})}}a=!1}else if(n&&(i=no(n.ranges,o.from,o.to)))a=2!=i;else if(!o.type.isAnonymous&&(r=this.nest(o,this.input))&&(o.fromnew wn(e.from-o.from,e.to-o.from))):null,o.tree,e.length?e[0].from:o.from)),r.overlay?e.length&&(n={ranges:e,depth:0,prev:n}):a=!1}}else t&&(s=t.predicate(o))&&(!0===s&&(s=new wn(o.from,o.to)),s.fromnew wn(e.from-t.start,e.to-t.start))),t.target,e[0].from))),t=t.prev}n&&! --n.depth&&(n=n.prev)}}}}function no(e,t,n){for(let o of e){if(o.from>=n)break;if(o.to>t)return o.from<=t&&o.to>=n?2:1}return 0}function oo(e,t,n,o,r,i){if(t=e&&t.enter(n,1,An.IgnoreOverlays|An.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(!(t.children.length&&0==t.positions[0]&&t.children[0]instanceof Tn))break;t=t.children[0]}return!1}}class so{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let n=this.curFrag=e[0];this.curTo=null!==(t=n.tree.prop(eo))&&void 0!==t?t:n.to,this.inner=new io(n.tree,-n.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=null!==(e=t.tree.prop(eo))&&void 0!==e?e:t.to,this.inner=new io(t.tree,-t.offset)}}findMounts(e,t){var n;let o=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let r=null===(n=e.tree)||void 0===n?void 0:n.prop(On.mounted);if(r&&r.parser==t)for(let t=this.fragI;t=e.to)break;n.tree==this.curFrag.tree&&o.push({frag:n,pos:e.from-n.offset,mount:r})}}}return o}}function ao(e,t){let n=null,o=t;for(let r=1,i=0;r=a)break;e.to<=s||(n||(o=n=t.slice()),e.froma&&n.splice(i+1,0,new wn(a,e.to))):e.to>a?n[i--]=new wn(a,e.to):n.splice(i--,1))}}return o}function lo(e,t,n,o){let r=0,i=0,s=!1,a=!1,l=-1e9,c=[];for(;;){let u=r==e.length?1e9:s?e[r].to:e[r].from,h=i==t.length?1e9:a?t[i].to:t[i].from;if(s!=a){let e=Math.max(l,n),t=Math.min(u,h,o);enew wn(e.from+o,e.to+o))),a,l);for(let t=0,o=a;;t++){let a=t==s.length,c=a?l:s[t].from;if(c>o&&n.push(new Gn(o,c,r.tree,-e,i.from>=o||i.openStart,i.to<=c||i.openEnd)),a)break;o=s[t].to}}else n.push(new Gn(a,l,r.tree,-e,i.from>=e||i.openStart,i.to<=s||i.openEnd))}return n}class uo{constructor(e,t,n,o,r,i,s,a,l,c=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=o,this.pos=r,this.score=i,this.buffer=s,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=u}toString(){return`[${this.stack.filter(((e,t)=>t%3==0)).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let o=e.parser.context;return new uo(e,[],t,n,n,0,[],0,o?new ho(o,o.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,o=65535&e,{parser:r}=this.p,i=r.dynamicPrecedence(o);if(i&&(this.score+=i),0==n)return this.pushState(r.getGoto(this.state,o,!0),this.reducePos),o=2e3&&!(null===(t=this.p.parser.nodeSet.types[o])||void 0===t?void 0:t.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=l):this.p.lastBigReductionSizes;)this.stack.pop();this.reduceContext(o,a)}storeNode(e,t,n,o=4,r=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]0&&0==e.buffer[o-4]&&e.buffer[o-1]>-1){if(t==n)return;if(e.buffer[o-2]>=t)return void(e.buffer[o-2]=n)}}if(r&&this.pos!=n){let r=this.buffer.length;if(r>0&&0!=this.buffer[r-4])for(;r>0&&this.buffer[r-2]>n;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,o>4&&(o-=4);this.buffer[r]=e,this.buffer[r+1]=t,this.buffer[r+2]=n,this.buffer[r+3]=o}else this.buffer.push(e,t,n,o)}shift(e,t,n,o){if(131072&e)this.pushState(65535&e,this.pos);else if(0==(262144&e)){let r=e,{parser:i}=this.p;(o>this.pos||t<=i.maxNode)&&(this.pos=o,i.stateFlag(r,1)||(this.reducePos=o)),this.pushState(r,n),this.shiftContext(t,n),t<=i.maxNode&&this.buffer.push(t,n,o,4)}else this.pos=o,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,o,4)}apply(e,t,n,o){65536&e?this.reduce(e):this.shift(e,t,n,o)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let o=this.pos;this.reducePos=this.pos=o+e.length,this.pushState(t,o),this.buffer.push(n,o,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,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),o=e.bufferBase+t;for(;e&&o==e.bufferBase;)e=e.parent;return new uo(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,o,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new po(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if(0==(65536&n))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let o,r=0;r1&t&&e==o))||n.push(t[e],o)}t=n}let n=[];for(let e=0;e>19,o=65535&t,r=this.stack.length-3*n;if(r<0||e.getGoto(this.stack[r],o,!1)<0){let e=this.findForcedReduction();if(null==e)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(o,r)=>{if(!t.includes(o))return t.push(o),e.allActions(o,(t=>{if(393216&t);else if(65536&t){let n=(t>>19)-r;if(n>1){let o=65535&t,r=this.stack.length-3*n;if(r>=0&&e.getGoto(this.stack[r],o,!1)>=0)return n<<19|65536|o}}else{let e=n(t,r+1);if(null!=e)return e}}))};return n(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(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!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 t=0;tthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class ho{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class po{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,n=e>>19;0==n?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(n-1);let o=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=o}}class fo{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new fo(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(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,0==this.index&&this.maybeNext()}fork(){return new fo(this.stack,this.pos,this.index)}}function go(e,t=Uint16Array){if("string"!=typeof e)return e;let n=null;for(let o=0,r=0;o=92&&t--,t>=34&&t--;let r=t-32;if(r>=46&&(r-=46,n=!0),i+=r,n)break;i*=46}n?n[r++]=i:n=new t(i)}return n}class mo{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const yo=new mo;class vo{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=yo,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,o=this.rangeIndex,r=this.pos+e;for(;rn.to:r>=n.to;){if(o==this.ranges.length-1)return null;let e=this.ranges[++o];r+=e.from-n.to,n=e}return r}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t,n,o=this.chunkOff+e;if(o>=0&&o=this.chunk2Pos&&to.to&&(this.chunk2=this.chunk2.slice(0,o.to-t)),n=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),n}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(null==n||n=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=yo,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let o of this.ranges){if(o.from>=t)break;o.to>e&&(n+=this.input.read(Math.max(o.from,e),Math.min(o.to,t)))}return n}}class bo{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;!function(e,t,n,o,r,i){let s=0,a=1<0){let n=e[o];if(l.allows(n)&&(-1==t.token.value||t.token.value==n||Oo(n,t.token.value,r,i))){t.acceptToken(n);break}}let o=t.next,c=0,u=e[s+2];if(!(t.next<0&&u>c&&65535==e[n+3*u-3])){for(;c>1,i=n+r+(r<<1),a=e[i],l=e[i+1]||65536;if(o=l)){s=e[i+2],t.advance();continue e}c=r+1}}break}s=e[n+3*u-1]}}(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}bo.prototype.contextual=bo.prototype.fallback=bo.prototype.extend=!1,bo.prototype.fallback=bo.prototype.extend=!1;class xo{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function wo(e,t,n){for(let o,r=t;65535!=(o=e[r]);r++)if(o==n)return r-t;return-1}function Oo(e,t,n,o){let r=wo(n,o,t);return r<0||wo(n,o,e)t)&&!o.type.isError)return n<0?Math.max(0,Math.min(o.to-1,t-25)):Math.min(e.length,Math.max(o.from+1,t+25));if(n<0?o.prevSibling():o.nextSibling())break;if(!o.parent())return n<0?0:e.length}}class Eo{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?So(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?So(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(ee)return this.nextStart=i,null;if(r instanceof Tn){if(i==e){if(i=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(i),this.index.push(0))}else this.index[t]++,this.nextStart=i+r.length}}}class Co{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map((e=>new mo))}getActions(e){let t=0,n=null,{parser:o}=e.p,{tokenizers:r}=o,i=o.stateSlot(e.state,3),s=e.curContext?e.curContext.hash:0,a=0;for(let o=0;oc.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let o=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!l.extend&&(n=c,t>o))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),n||e.pos!=this.stream.end||(n=new mo,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new mo,{pos:n,p:o}=e;return t.start=n,t.end=Math.min(n+1,o.stream.end),t.value=n==o.stream.end?o.parser.eofTerm:0,t}updateCachedToken(e,t,n){let o=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(o,e),n),e.value>-1){let{parser:t}=n.p;for(let o=0;o=0&&n.p.parser.dialect.allows(r>>1)){0==(1&r)?e.value=r>>1:e.extended=r>>1;break}}}else e.value=0,e.end=this.stream.clipPos(o+1)}putAction(e,t,n,o){for(let t=0;t4*e.bufferLength?new Eo(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,o=this.minStackPos,r=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let i=0;io)r.push(s);else{if(this.advanceStack(s,r,n))continue;{e||(e=[],t=[]),e.push(s);let n=this.tokens.getMainToken(s);t.push(n.value,n.end)}}break}}if(!r.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.scorethis.stoppedAt?e[0]:this.runRecovery(e,t,r);if(n)return _o&&console.log("Force-finish "+this.stackID(n)),this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(r.length>e)for(r.sort(((e,t)=>t.score-e.score));r.length>e;)r.pop();r.some((e=>e.reducePos>o))&&this.recovering--}else if(r.length>1){e:for(let e=0;e500&&o.buffer.length>500){if(!((t.score-o.score||t.buffer.length-o.buffer.length)>0)){r.splice(e--,1);continue e}r.splice(n--,1)}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let e=1;e ":"";if(null!=this.stoppedAt&&o>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let s=this.fragments.nodeAt(o);s;){let o=this.parser.nodeSet.types[s.type.id]==s.type?r.getGoto(e.state,s.type.id):-1;if(o>-1&&s.length&&(!t||(s.prop(On.contextHash)||0)==n))return e.useNode(s,o),_o&&console.log(i+this.stackID(e)+` (via reuse of ${r.getName(s.type.id)})`),!0;if(!(s instanceof Tn)||0==s.children.length||s.positions[0]>0)break;let a=s.children[0];if(!(a instanceof Tn&&0==s.positions[0]))break;s=a}}let s=r.stateSlot(e.state,4);if(s>0)return e.reduce(s),_o&&console.log(i+this.stackID(e)+` (via always-reduce ${r.getName(65535&s)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let s=0;so?t.push(p):n.push(p)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return Ao(e,t),!0}}runRecovery(e,t,n){let o=null,r=!1;for(let i=0;i ":"";if(s.deadEnd){if(r)continue;if(r=!0,s.restart(),_o&&console.log(c+this.stackID(s)+" (restarted)"),this.advanceFully(s,n))continue}let u=s.split(),h=c;for(let e=0;u.forceReduce()&&e<10&&(_o&&console.log(h+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,n));e++)_o&&(h=this.stackID(u)+" -> ");for(let e of s.recoverByInsert(a))_o&&console.log(c+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,n);this.stream.end>s.pos?(l==s.pos&&(l++,a=0),s.recoverByDelete(a,l),_o&&console.log(c+this.stackID(s)+` (via recover-delete ${this.parser.getName(a)})`),Ao(s,n)):(!o||o.scoree;class Ro{constructor(e){this.start=e.start,this.shift=e.shift||Mo,this.reduce=e.reduce||Mo,this.reuse=e.reuse||Mo,this.hash=e.hash||(()=>0),this.strict=!1!==e.strict}}class jo extends Un{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let n=0;ne.topRules[t][1])),o=[];for(let e=0;e=0)r(o,e,t[n++]);else{let i=t[n+-o];for(let s=-o;s>0;s--)r(t[n++],e,i);n++}}}this.nodeSet=new En(t.map(((t,r)=>Sn.define({name:r>=this.minRepeatTerm?void 0:t,id:r,props:o[r],top:n.indexOf(r)>-1,error:0==r,skipped:e.skippedNodes&&e.skippedNodes.indexOf(r)>-1})))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=bn;let i=go(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e"number"==typeof e?new bo(i,e):e)),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,t,n){let o=new Po(this,e,t,n);for(let r of this.wrappers)o=r(o,e,t,n);return o}getGoto(e,t,n=!1){let o=this.goto;if(t>=o[0])return-1;for(let r=o[t+1];;){let t=o[r++],i=1&t,s=o[r++];if(i&&n)return s;for(let n=r+(t>>1);r0}validAction(e,t){return!!this.allActions(e,(e=>e==t||null))}allActions(e,t){let n=this.stateSlot(e,4),o=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==o;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=Bo(this.data,n+2)}o=t(Bo(this.data,n+1))}return o}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=Bo(this.data,n+2)}if(0==(1&this.data[n+2])){let e=this.data[n+1];t.some(((t,n)=>1&n&&t==e))||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(jo.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map((t=>{let n=e.tokenizers.find((e=>e.from==t));return n?n.to:t}))),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map(((n,o)=>{let r=e.specializers.find((e=>e.from==n.external));if(!r)return n;let i=Object.assign(Object.assign({},n),{external:r.to});return t.specializers[o]=Do(i),i}))),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}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 t=this.dynamicPrecedences;return null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map((()=>!1));if(e)for(let o of e.split(" ")){let e=t.indexOf(o);e>=0&&(n[e]=!0)}let o=null;for(let e=0;ee.external(n,o)<<1|t}return e.get}let Lo=0;class $o{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=Lo++}static define(e){if(null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let t=new $o([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new No;return t=>t.modified.indexOf(e)>-1?t:No.get(t.base||t,t.modified.concat(e).sort(((e,t)=>e.id-t.id)))}}let Io=0;class No{constructor(){this.instances=[],this.id=Io++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find((n=>n.base==e&&function(e,t){return e.length==t.length&&e.every(((e,n)=>e==t[n]))}(t,n.modified)));if(n)return n;let o=[],r=new $o(o,e,t);for(let e of t)e.instances.push(r);let i=function(e){let t=[[]];for(let n=0;nt.length-e.length))}(t);for(let t of e.set)if(!t.modified.length)for(let e of i)o.push(No.get(t,e));return r}}function qo(e){let t=Object.create(null);for(let n in e){let o=e[n];Array.isArray(o)||(o=[o]);for(let e of n.split(" "))if(e){let n=[],r=2,i=e;for(let t=0;;){if("..."==i&&t>0&&t+3==e.length){r=1;break}let o=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(i);if(!o)throw new RangeError("Invalid path: "+e);if(n.push("*"==o[0]?"":'"'==o[0][0]?JSON.parse(o[0]):o[0]),t+=o[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){r=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);i=e.slice(t)}let s=n.length-1,a=n[s];if(!a)throw new RangeError("Invalid path: "+e);let l=new Qo(o,r,s>0?n.slice(0,s):null);t[a]=l.sort(t[a])}}return Fo.add(t)}const Fo=new On;class Qo{constructor(e,t,n,o){this.tags=e,this.mode=t,this.context=n,this.next=o}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth{let t=r;for(let o of e)for(let e of o.set){let o=n[e.id];if(o){t=t?t+" "+o:o;break}}return t},scope:o}}function zo(e,t,n,o=0,r=e.length){let i=new Vo(o,Array.isArray(t)?t:[t],n);i.highlightRange(e.cursor(),o,r,"",i.highlighters),i.flush(r)}Qo.empty=new Qo([],2,null);class Vo{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,o,r){let{type:i,from:s,to:a}=e;if(s>=n||a<=t)return;i.isTop&&(r=this.highlighters.filter((e=>!e.scope||e.scope(i))));let l=o,c=function(e){let t=e.type.prop(Fo);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||Qo.empty,u=function(e,t){let n=null;for(let o of e){let e=o.style(t);e&&(n=n?n+" "+e:e)}return n}(r,c.tags);if(u&&(l&&(l+=" "),l+=u,1==c.mode&&(o+=(o?" ":"")+u)),this.startSpan(Math.max(t,s),l),c.opaque)return;let h=e.tree&&e.tree.prop(On.mounted);if(h&&h.overlay){let i=e.node.enter(h.overlay[0].from+s,1),c=this.highlighters.filter((e=>!e.scope||e.scope(h.tree.type))),u=e.firstChild();for(let p=0,f=s;;p++){let d=p=g)&&e.nextSibling()););if(!d||g>n)break;f=d.to+s,f>t&&(this.highlightRange(i.cursor(),Math.max(t,d.from+s),Math.min(n,f),"",c),this.startSpan(Math.min(n,f),l))}u&&e.parent()}else if(e.firstChild()){h&&(o="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,o,r),this.startSpan(Math.min(n,e.to),l)}}while(e.nextSibling());e.parent()}}}const Wo=$o.define,Xo=Wo(),Go=Wo(),Uo=Wo(Go),Yo=Wo(Go),Zo=Wo(),Ko=Wo(Zo),Jo=Wo(Zo),er=Wo(),tr=Wo(er),nr=Wo(),or=Wo(),rr=Wo(),ir=Wo(rr),sr=Wo(),ar={comment:Xo,lineComment:Wo(Xo),blockComment:Wo(Xo),docComment:Wo(Xo),name:Go,variableName:Wo(Go),typeName:Uo,tagName:Wo(Uo),propertyName:Yo,attributeName:Wo(Yo),className:Wo(Go),labelName:Wo(Go),namespace:Wo(Go),macroName:Wo(Go),literal:Zo,string:Ko,docString:Wo(Ko),character:Wo(Ko),attributeValue:Wo(Ko),number:Jo,integer:Wo(Jo),float:Wo(Jo),bool:Wo(Zo),regexp:Wo(Zo),escape:Wo(Zo),color:Wo(Zo),url:Wo(Zo),keyword:nr,self:Wo(nr),null:Wo(nr),atom:Wo(nr),unit:Wo(nr),modifier:Wo(nr),operatorKeyword:Wo(nr),controlKeyword:Wo(nr),definitionKeyword:Wo(nr),moduleKeyword:Wo(nr),operator:or,derefOperator:Wo(or),arithmeticOperator:Wo(or),logicOperator:Wo(or),bitwiseOperator:Wo(or),compareOperator:Wo(or),updateOperator:Wo(or),definitionOperator:Wo(or),typeOperator:Wo(or),controlOperator:Wo(or),punctuation:rr,separator:Wo(rr),bracket:ir,angleBracket:Wo(ir),squareBracket:Wo(ir),paren:Wo(ir),brace:Wo(ir),content:er,heading:tr,heading1:Wo(tr),heading2:Wo(tr),heading3:Wo(tr),heading4:Wo(tr),heading5:Wo(tr),heading6:Wo(tr),contentSeparator:Wo(er),list:Wo(er),quote:Wo(er),emphasis:Wo(er),strong:Wo(er),link:Wo(er),monospace:Wo(er),strikethrough:Wo(er),inserted:Wo(),deleted:Wo(),changed:Wo(),invalid:Wo(),meta:sr,documentMeta:Wo(sr),annotation:Wo(sr),processingInstruction:Wo(sr),definition:$o.defineModifier(),constant:$o.defineModifier(),function:$o.defineModifier(),standard:$o.defineModifier(),local:$o.defineModifier(),special:$o.defineModifier()};Ho([{tag:ar.link,class:"tok-link"},{tag:ar.heading,class:"tok-heading"},{tag:ar.emphasis,class:"tok-emphasis"},{tag:ar.strong,class:"tok-strong"},{tag:ar.keyword,class:"tok-keyword"},{tag:ar.atom,class:"tok-atom"},{tag:ar.bool,class:"tok-bool"},{tag:ar.url,class:"tok-url"},{tag:ar.labelName,class:"tok-labelName"},{tag:ar.inserted,class:"tok-inserted"},{tag:ar.deleted,class:"tok-deleted"},{tag:ar.literal,class:"tok-literal"},{tag:ar.string,class:"tok-string"},{tag:ar.number,class:"tok-number"},{tag:[ar.regexp,ar.escape,ar.special(ar.string)],class:"tok-string2"},{tag:ar.variableName,class:"tok-variableName"},{tag:ar.local(ar.variableName),class:"tok-variableName tok-local"},{tag:ar.definition(ar.variableName),class:"tok-variableName tok-definition"},{tag:ar.special(ar.variableName),class:"tok-variableName2"},{tag:ar.definition(ar.propertyName),class:"tok-propertyName tok-definition"},{tag:ar.typeName,class:"tok-typeName"},{tag:ar.namespace,class:"tok-namespace"},{tag:ar.className,class:"tok-className"},{tag:ar.macroName,class:"tok-macroName"},{tag:ar.propertyName,class:"tok-propertyName"},{tag:ar.operator,class:"tok-operator"},{tag:ar.comment,class:"tok-comment"},{tag:ar.meta,class:"tok-meta"},{tag:ar.invalid,class:"tok-invalid"},{tag:ar.punctuation,class:"tok-punctuation"}]);class lr{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,t,n){[e,t]=yr(this,e,t);let o=[];return this.decompose(0,e,o,2),n.length&&n.decompose(0,n.length,o,3),this.decompose(t,this.length,o,1),ur.from(o,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=yr(this,e,t);let n=[];return this.decompose(e,t,n,0),ur.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),o=new fr(this),r=new fr(e);for(let e=t,i=t;;){if(o.next(e),r.next(e),e=0,o.lineBreak!=r.lineBreak||o.done!=r.done||o.value!=r.value)return!1;if(i+=o.value.length,o.done||i>=n)return!0}}iter(e=1){return new fr(this,e)}iterRange(e,t=this.length){return new dr(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let o=this.line(e).from;n=this.iterRange(o,Math.max(o,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new gr(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new cr(e):ur.from(cr.split(e,[])):lr.empty}}class cr extends lr{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,o){for(let r=0;;r++){let i=this.text[r],s=o+i.length;if((t?n:s)>=e)return new mr(o,s,n,i);o=s+1,n++}}decompose(e,t,n,o){let r=e<=0&&t>=this.length?this:new cr(pr(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&o){let e=n.pop(),t=hr(r.text,e.text.slice(),0,r.length);if(t.length<=32)n.push(new cr(t,e.length+r.length));else{let e=t.length>>1;n.push(new cr(t.slice(0,e)),new cr(t.slice(e)))}}else n.push(r)}replace(e,t,n){if(!(n instanceof cr))return super.replace(e,t,n);[e,t]=yr(this,e,t);let o=hr(this.text,hr(n.text,pr(this.text,0,e)),t),r=this.length+n.length-(t-e);return o.length<=32?new cr(o,r):ur.from(cr.split(o,[]),r)}sliceString(e,t=this.length,n="\n"){[e,t]=yr(this,e,t);let o="";for(let r=0,i=0;r<=t&&ie&&i&&(o+=n),er&&(o+=s.slice(Math.max(0,e-r),t-r)),r=a+1}return o}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],o=-1;for(let r of e)n.push(r),o+=r.length+1,32==n.length&&(t.push(new cr(n,o)),n=[],o=-1);return o>-1&&t.push(new cr(n,o)),t}}class ur extends lr{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,o){for(let r=0;;r++){let i=this.children[r],s=o+i.length,a=n+i.lines-1;if((t?a:s)>=e)return i.lineInner(e,t,n,o);o=s+1,n=a+1}}decompose(e,t,n,o){for(let r=0,i=0;i<=t&&r=i){let r=o&((i<=e?1:0)|(a>=t?2:0));i>=e&&a<=t&&!r?n.push(s):s.decompose(e-i,t-i,n,r)}i=a+1}}replace(e,t,n){if([e,t]=yr(this,e,t),n.lines=r&&t<=s){let a=i.replace(e-r,t-r,n),l=this.lines-i.lines+a.lines;if(a.lines>4&&a.lines>l>>6){let r=this.children.slice();return r[o]=a,new ur(r,this.length-(t-e)+n.length)}return super.replace(r,s,a)}r=s+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=yr(this,e,t);let o="";for(let r=0,i=0;re&&r&&(o+=n),ei&&(o+=s.sliceString(e-i,t-i,n)),i=a+1}return o}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof ur))return 0;let n=0,[o,r,i,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;o+=t,r+=t){if(o==i||r==s)return n;let a=this.children[o],l=e.children[r];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce(((e,t)=>e+t.length+1),-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new cr(n,t)}let o=Math.max(32,n>>5),r=o<<1,i=o>>1,s=[],a=0,l=-1,c=[];function u(e){let t;if(e.lines>r&&e instanceof ur)for(let t of e.children)u(t);else e.lines>i&&(a>i||!a)?(h(),s.push(e)):e instanceof cr&&a&&(t=c[c.length-1])instanceof cr&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new cr(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>o&&h(),a+=e.lines,l+=e.length+1,c.push(e))}function h(){0!=a&&(s.push(1==c.length?c[0]:ur.from(c,l)),l=-1,a=c.length=0)}for(let t of e)u(t);return h(),1==s.length?s[0]:new ur(s,t)}}function hr(e,t,n=0,o=1e9){for(let r=0,i=0,s=!0;i=n&&(l>o&&(a=a.slice(0,o-r)),r0?1:(e instanceof cr?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,o=this.nodes[n],r=this.offsets[n],i=r>>1,s=o instanceof cr?o.text.length:o.children.length;if(i==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(o instanceof cr){let r=o.text[i+(t<0?-1:0)];if(this.offsets[n]+=t,r.length>Math.max(0,e))return this.value=0==e?r:t>0?r.slice(e):r.slice(0,r.length-e),this;e-=r.length}else{let r=o.children[i+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof cr?r.text.length:r.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class dr{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new fr(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:o}=this.cursor.next(e);return this.pos+=(o.length+e)*t,this.value=o.length<=n?o:t<0?o.slice(o.length-n):o.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class gr{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:o}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=o,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(lr.prototype[Symbol.iterator]=function(){return this.iter()},fr.prototype[Symbol.iterator]=dr.prototype[Symbol.iterator]=gr.prototype[Symbol.iterator]=function(){return this});class mr{constructor(e,t,n,o){this.from=e,this.to=t,this.number=n,this.text=o}get length(){return this.to-this.from}}function yr(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}let vr="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((e=>e?parseInt(e,36):1));for(let e=1;ee)return vr[t-1]<=e;return!1}function xr(e){return e>=127462&&e<=127487}const wr=8205;function Or(e,t,n=!0,o=!0){return(n?_r:kr)(e,t,o)}function _r(e,t,n){if(t==e.length)return t;t&&Sr(e.charCodeAt(t))&&Er(e.charCodeAt(t-1))&&t--;let o=Cr(e,t);for(t+=Ar(o);t=0&&xr(Cr(e,o));)n++,o-=2;if(n%2==0)break;t+=2}}}return t}function kr(e,t,n){for(;t>0;){let o=_r(e,t-2,n);if(o=56320&&e<57344}function Er(e){return e>=55296&&e<56320}function Cr(e,t){let n=e.charCodeAt(t);if(!Er(n)||t+1==e.length)return n;let o=e.charCodeAt(t+1);return Sr(o)?o-56320+(n-55296<<10)+65536:n}function Pr(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function Ar(e){return e<65536?1:2}const Tr=/\r\n?|\n/;var Mr=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(Mr||(Mr={}));class Rr{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-o);r+=s}else{if(n!=Mr.Simple&&l>=e&&(n==Mr.TrackDel&&oe||n==Mr.TrackBefore&&oe))return null;if(l>e||l==e&&t<0&&!s)return e==o||t<0?r:r+a;r+=a}o=l}if(e>o)throw new RangeError(`Position ${e} is out of range for changeset of length ${o}`);return r}touchesRange(e,t=e){for(let n=0,o=0;n=0&&o<=t&&r>=e)return!(ot)||"cover";o=r}return!1}toString(){let e="";for(let t=0;t=0?":"+o:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some((e=>"number"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Rr(e)}static create(e){return new Rr(e)}}class jr extends Rr{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Lr(this,((t,n,o,r,i)=>e=e.replace(o,o+(n-t),i)),!1),e}mapDesc(e,t=!1){return $r(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let o=0,r=0;o=0){t[o]=s,t[o+1]=i;let a=o>>1;for(;n.length0&&Dr(n,t,r.text),r.forward(e),s+=e}let l=e[i++];for(;s>1].toJSON()))}return e}static of(e,t,n){let o=[],r=[],i=0,s=null;function a(e=!1){if(!e&&!o.length)return;is||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let u=c?"string"==typeof c?lr.of(c.split(n||Tr)):c:lr.empty,h=u.length;if(e==s&&0==h)return;ei&&Br(o,e-i,-1),Br(o,s-e,h),Dr(r,o,u),i=s}}(e),a(!s),s}static empty(e){return new jr(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let o=0;ot&&"string"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)t.push(r[0],0);else{for(;n.length=0&&n<=0&&n==e[r+1]?e[r]+=t:0==t&&0==e[r]?e[r+1]+=n:o?(e[r]+=t,e[r+1]+=n):e.push(t,n)}function Dr(e,t,n){if(0==n.length)return;let o=t.length-2>>1;if(o>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(r,c,i,u,h),r=c,i=u}}}function $r(e,t,n,o=!1){let r=[],i=o?[]:null,s=new Nr(e),a=new Nr(t);for(let e=-1;;)if(-1==s.ins&&-1==a.ins){let e=Math.min(s.len,a.len);Br(r,e,-1),s.forward(e),a.forward(e)}else if(a.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(a.len=0&&e=0)){if(s.done&&a.done)return i?jr.createSet(r,i):Rr.create(r);throw new Error("Mismatched change set lengths")}{let t=0,n=s.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.lent||s.ins>=0&&s.len>t)&&(e||o.length>n),i.forward2(t),s.forward(t)}}else Br(o,0,s.ins,e),r&&Dr(r,o,s.text),s.next()}}class Nr{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?lr.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?lr.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class qr{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,o;return this.empty?n=o=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),o=e.mapPos(this.to,-1)),n==this.from&&o==this.to?this:new qr(n,o,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return Fr.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Fr.range(this.anchor,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return Fr.range(e.anchor,e.head)}static create(e,t,n){return new qr(e,t,n)}}class Fr{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:Fr.create(this.ranges.map((n=>n.map(e,t))),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;ne.toJSON())),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Fr(e.ranges.map((e=>qr.fromJSON(e))),e.main)}static single(e,t=e){return new Fr([Fr.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,o=0;oe?8:0)|r)}static normalized(e,t=0){let n=e[t];e.sort(((e,t)=>e.from-t.from)),t=e.indexOf(n);for(let n=1;no.head?Fr.range(s,i):Fr.range(i,s))}}return new Fr(e,t)}}function Qr(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let Hr=0;class zr{constructor(e,t,n,o,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=o,this.id=Hr++,this.default=e([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(e={}){return new zr(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:Vr),!!e.static,e.enables)}of(e){return new Wr([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Wr(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Wr(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],(n=>t(n.field(e))))}}function Vr(e,t){return e==t||e.length==t.length&&e.every(((e,n)=>e===t[n]))}class Wr{constructor(e,t,n,o){this.dependencies=e,this.facet=t,this.type=n,this.value=o,this.id=Hr++}dynamicSlot(e){var t;let n=this.value,o=this.facet.compareInput,r=this.id,i=e[r]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:0==(1&(null!==(t=e[n.id])&&void 0!==t?t:1))&&c.push(e[n.id]);return{create:e=>(e.values[i]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||Gr(e,c)){let t=n(e);if(s?!Xr(t,e.values[i],o):!o(t,e.values[i]))return e.values[i]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[r];if(null!=l){let r=ii(t,l);if(this.dependencies.every((n=>n instanceof zr?t.facet(n)===e.facet(n):!(n instanceof Zr)||t.field(n,!1)==e.field(n,!1)))||(s?Xr(a=n(e),r,o):o(a=n(e),r)))return e.values[i]=r,0}else a=n(e);return e.values[i]=a,1}}}}function Xr(e,t,n){if(e.length!=t.length)return!1;for(let o=0;oe[t.id])),r=n.map((e=>e.type)),i=o.filter((e=>!(1&e))),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;te===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Yr).find((e=>e.field==this));return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let o=e.values[t],r=this.updateF(o,n);return this.compareF(o,r)?0:(e.values[t]=r,1)},reconfigure:(e,n)=>null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}init(e){return[this,Yr.of({field:this,create:e})]}get extension(){return this}}function Kr(e){return t=>new ei(t,e)}const Jr={highest:Kr(0),high:Kr(1),default:Kr(2),low:Kr(3),lowest:Kr(4)};class ei{constructor(e,t){this.inner=e,this.prec=t}}class ti{of(e){return new ni(this,e)}reconfigure(e){return ti.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ni{constructor(e,t){this.compartment=e,this.inner=t}}class oi{constructor(e,t,n,o,r,i){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=o,this.staticValues=r,this.facets=i,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,n){let o=[],r=Object.create(null),i=new Map;for(let n of function(e,t,n){let o=[[],[],[],[],[]],r=new Map;return function e(i,s){let a=r.get(i);if(null!=a){if(a<=s)return;let e=o[a].indexOf(i);e>-1&&o[a].splice(e,1),i instanceof ni&&n.delete(i.compartment)}if(r.set(i,s),Array.isArray(i))for(let t of i)e(t,s);else if(i instanceof ni){if(n.has(i.compartment))throw new RangeError("Duplicate use of compartment in extensions");let o=t.get(i.compartment)||i.inner;n.set(i.compartment,o),e(o,s)}else if(i instanceof ei)e(i.inner,i.prec);else if(i instanceof Zr)o[s].push(i),i.provides&&e(i.provides,s);else if(i instanceof Wr)o[s].push(i),i.facet.extensions&&e(i.facet.extensions,2);else{let t=i.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${i}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);e(t,s)}}(e,2),o.reduce(((e,t)=>e.concat(t)))}(e,t,i))n instanceof Zr?o.push(n):(r[n.facet.id]||(r[n.facet.id]=[])).push(n);let s=Object.create(null),a=[],l=[];for(let e of o)s[e.id]=l.length<<1,l.push((t=>e.slot(t)));let c=null==n?void 0:n.config.facets;for(let e in r){let t=r[e],o=t[0].facet,i=c&&c[e]||[];if(t.every((e=>0==e.type)))if(s[o.id]=a.length<<1|1,Vr(i,t))a.push(n.facet(o));else{let e=o.combine(t.map((e=>e.value)));a.push(n&&o.compare(e,n.facet(o))?n.facet(o):e)}else{for(let e of t)0==e.type?(s[e.id]=a.length<<1|1,a.push(e.value)):(s[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));s[o.id]=l.length<<1,l.push((e=>Ur(e,o,t)))}}let u=l.map((e=>e(s)));return new oi(e,i,u,s,a,r)}}function ri(e,t){if(1&t)return 2;let n=t>>1,o=e.status[n];if(4==o)throw new Error("Cyclic dependency between fields and/or facets");if(2&o)return o;e.status[n]=4;let r=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|r}function ii(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const si=zr.define(),ai=zr.define({combine:e=>e.some((e=>e)),static:!0}),li=zr.define({combine:e=>e.length?e[0]:void 0,static:!0}),ci=zr.define(),ui=zr.define(),hi=zr.define(),pi=zr.define({combine:e=>!!e.length&&e[0]});class fi{constructor(e,t){this.type=e,this.value=t}static define(){return new di}}class di{of(e){return new fi(this,e)}}class gi{constructor(e){this.map=e}of(e){return new mi(this,e)}}class mi{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new mi(this.type,t)}is(e){return this.type==e}static define(e={}){return new gi(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let o of e){let e=o.map(t);e&&n.push(e)}return n}}mi.reconfigure=mi.define(),mi.appendConfig=mi.define();class yi{constructor(e,t,n,o,r,i){this.startState=e,this.changes=t,this.selection=n,this.effects=o,this.annotations=r,this.scrollIntoView=i,this._doc=null,this._state=null,n&&Qr(n,t.newLength),r.some((e=>e.type==yi.time))||(this.annotations=r.concat(yi.time.of(Date.now())))}static create(e,t,n,o,r,i){return new yi(e,t,n,o,r,i)}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 t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(yi.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function vi(e,t){let n=[];for(let o=0,r=0;;){let i,s;if(o=e[o]))i=e[o++],s=e[o++];else{if(!(r=0;r--){let i=n[r](e);i&&Object.keys(i).length&&(o=bi(o,xi(t,i,e.changes.newLength),!0))}return o==e?e:yi.create(t,e.changes,e.selection,o.effects,o.annotations,o.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let o of t.facet(ci)){let t=o(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:vi(n,t))}if(!0!==n){let o,r;if(!1===n)r=e.changes.invertedDesc,o=jr.empty(t.doc.length);else{let t=e.changes.filter(n);o=t.changes,r=t.filtered.mapDesc(t.changes).invertedDesc}e=yi.create(t,o,e.selection&&e.selection.map(r),mi.mapEffects(e.effects,r),e.annotations,e.scrollIntoView)}let o=t.facet(ui);for(let n=o.length-1;n>=0;n--){let r=o[n](e);e=r instanceof yi?r:Array.isArray(r)&&1==r.length&&r[0]instanceof yi?r[0]:wi(t,_i(r),!1)}return e}(r):r)}yi.time=fi.define(),yi.userEvent=fi.define(),yi.addToHistory=fi.define(),yi.remote=fi.define();const Oi=[];function _i(e){return null==e?Oi:Array.isArray(e)?e:[e]}var ki=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(ki||(ki={}));const Si=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Ei;try{Ei=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}class Ci{constructor(e,t,n,o,r,i){this.config=e,this.doc=t,this.selection=n,this.values=o,this.status=e.statusTemplate.slice(),this.computeSlot=r,i&&(i._state=this);for(let e=0;er.set(t,e))),n=null),r.set(t.value.compartment,t.value.extension)):t.is(mi.reconfigure)?(n=null,o=t.value):t.is(mi.appendConfig)&&(n=null,o=_i(o).concat(t.value));n?t=e.startState.values.slice():(n=oi.resolve(o,r,this),t=new Ci(n,this.doc,this.selection,n.dynamicSlots.map((()=>null)),((e,t)=>t.reconfigure(e,this)),null).values);let i=e.startState.facet(ai)?e.newSelection:e.newSelection.asSingle();new Ci(n,e.newDoc,i,t,((t,n)=>n.update(t,e)),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:e},range:Fr.cursor(t.from+e.length)})))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),o=this.changes(n.changes),r=[n.range],i=_i(n.effects);for(let n=1;nr.spec.fromJSON(i,e))))}return Ci.create({doc:e.doc,selection:Fr.fromJSON(e.selection),extensions:t.extensions?o.concat([t.extensions]):o})}static create(e={}){let t=oi.resolve(e.extensions||[],new Map),n=e.doc instanceof lr?e.doc:lr.of((e.doc||"").split(t.staticFacet(Ci.lineSeparator)||Tr)),o=e.selection?e.selection instanceof Fr?e.selection:Fr.single(e.selection.anchor,e.selection.head):Fr.single(0);return Qr(o,n.length),t.staticFacet(ai)||(o=o.asSingle()),new Ci(t,n,o,t.dynamicSlots.map((()=>null)),((e,t)=>t.create(e)),null)}get tabSize(){return this.facet(Ci.tabSize)}get lineBreak(){return this.facet(Ci.lineSeparator)||"\n"}get readOnly(){return this.facet(pi)}phrase(e,...t){for(let t of this.facet(Ci.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,((e,n)=>{if("$"==n)return"$";let o=+(n||1);return!o||o>t.length?e:t[o-1]}))),e}languageDataAt(e,t,n=-1){let o=[];for(let r of this.facet(si))for(let i of r(this,t,n))Object.prototype.hasOwnProperty.call(i,e)&&o.push(i[e]);return o}charCategorizer(e){return t=this.languageDataAt("wordChars",e).join(""),e=>{if(!/\S/.test(e))return ki.Space;if(function(e){if(Ei)return Ei.test(e);for(let t=0;t""&&(n.toUpperCase()!=n.toLowerCase()||Si.test(n)))return!0}return!1}(e))return ki.Word;for(let n=0;n-1)return ki.Word;return ki.Other};var t}wordAt(e){let{text:t,from:n,length:o}=this.doc.lineAt(e),r=this.charCategorizer(e),i=e-n,s=e-n;for(;i>0;){let e=Or(t,i,!1);if(r(t.slice(e,i))!=ki.Word)break;i=e}for(;se.length?e[0]:4}),Ci.lineSeparator=li,Ci.readOnly=pi,Ci.phrases=zr.define({compare(e,t){let n=Object.keys(e),o=Object.keys(t);return n.length==o.length&&n.every((n=>e[n]==t[n]))}}),Ci.languageData=si,Ci.changeFilter=ci,Ci.transactionFilter=ui,Ci.transactionExtender=hi,ti.reconfigure=mi.define();class Ai{eq(e){return this==e}range(e,t=e){return Ti.create(e,t,this)}}Ai.prototype.startSide=Ai.prototype.endSide=0,Ai.prototype.point=!1,Ai.prototype.mapMode=Mr.TrackDel;class Ti{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new Ti(e,t,n)}}function Mi(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class Ri{constructor(e,t,n,o){this.from=e,this.to=t,this.value=n,this.maxPoint=o}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,o=0){let r=n?this.to:this.from;for(let i=o,s=r.length;;){if(i==s)return i;let o=i+s>>1,a=r[o]-e||(n?this.value[o].endSide:this.value[o].startSide)-t;if(o==i)return a>=0?i:s;a>=0?s=o:i=o+1}}between(e,t,n,o){for(let r=this.findIndex(t,-1e9,!0),i=this.findIndex(n,1e9,!1,r);rc||l==c&&u.startSide>0&&u.endSide<=0)continue;(c-l||u.endSide-u.startSide)<0||(i<0&&(i=l),u.point&&(s=Math.max(s,c-l)),n.push(u),o.push(l-i),r.push(c-i))}return{mapped:n.length?new Ri(o,r,n,s):null,pos:i}}}class ji{constructor(e,t,n,o){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=o}static create(e,t,n,o){return new ji(e,t,n,o)}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 t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:o=0,filterTo:r=this.length}=e,i=e.filter;if(0==t.length&&!i)return this;if(n&&(t=t.slice().sort(Mi)),this.isEmpty)return t.length?ji.of(t):this;let s=new Li(this,null,-1).goto(0),a=0,l=[],c=new Bi;for(;s.value||a=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndexthis.chunkEnd(s.chunkIndex)||rs.to||r=r&&e<=r+i.length&&!1===i.between(r,e-r,t-r,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return $i.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return $i.from(e).goto(t)}static compare(e,t,n,o,r=-1){let i=e.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r)),s=t.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r)),a=Di(i,s,n),l=new Ni(i,a,r),c=new Ni(s,a,r);n.iterGaps(((e,t,n)=>qi(l,e,c,t,n,o))),n.empty&&0==n.length&&qi(l,0,c,0,0,o)}static eq(e,t,n=0,o){null==o&&(o=999999999);let r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0)),i=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0));if(r.length!=i.length)return!1;if(!r.length)return!0;let s=Di(r,i),a=new Ni(r,s,0).goto(n),l=new Ni(i,s,0).goto(n);for(;;){if(a.to!=l.to||!Fi(a.active,l.active)||a.point&&(!l.point||!a.point.eq(l.point)))return!1;if(a.to>o)return!0;a.next(),l.next()}}static spans(e,t,n,o,r=-1){let i=new Ni(e,null,r).goto(t),s=t,a=i.openStart;for(;;){let e=Math.min(i.to,n);if(i.point){let n=i.activeForPoint(i.to),r=i.pointFroms&&(o.span(s,e,i.active,a),a=i.openEnd(e));if(i.to>n)return a+(i.point&&i.to>n?1:0);s=i.to,i.next()}}static of(e,t=!1){let n=new Bi;for(let o of e instanceof Ti?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n0)return e.slice().sort(Mi);t=o}return e}(e):e)n.add(o.from,o.to,o.value);return n.finish()}static join(e){if(!e.length)return ji.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let o=e[n];o!=ji.empty;o=o.nextLayer)t=new ji(o.chunkPos,o.chunk,t,Math.max(o.maxPoint,t.maxPoint));return t}}ji.empty=new ji([],[],null,-1),ji.empty.nextLayer=ji.empty;class Bi{finishChunk(e){this.chunks.push(new Ri(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,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Bi)).add(e,t,n)}addInner(e,t,n){let o=e-this.lastTo||n.startSide-this.last.endSide;if(o<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(o<0||(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),0))}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(ji.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=ji.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Di(e,t,n){let o=new Map;for(let t of e)for(let e=0;e=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=n&&o.push(new Li(i,t,n,r));return 1==o.length?o[0]:new $i(o)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)Ii(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Ii(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)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(),Ii(this.heap,0)}}}function Ii(e,t){for(let n=e[t];;){let o=1+(t<<1);if(o>=e.length)break;let r=e[o];if(o+1=0&&(r=e[o+1],o++),n.compare(r)<0)break;e[o]=n,e[t]=r,t=o}}class Ni{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=$i.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Qi(this.active,e),Qi(this.activeTo,e),Qi(this.activeRank,e),this.minActive=zi(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:o,rank:r}=this.cursor;for(;t0;)t++;Hi(this.active,t,n),Hi(this.activeTo,t,o),Hi(this.activeRank,t,r),e&&Hi(e,t,this.cursor.from),this.minActive=zi(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let o=this.minActive;if(o>-1&&(this.activeTo[o]-this.cursor.from||this.active[o].endSide-this.cursor.startSide)<0){if(this.activeTo[o]>e){this.to=this.activeTo[o],this.endSide=this.active[o].endSide;break}this.removeActive(o),n&&Qi(n,o)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from=0&&n[t]=0&&!(this.activeRank[n]e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function qi(e,t,n,o,r,i){e.goto(t),n.goto(o);let s=o+r,a=o,l=o-t;for(;;){let t=e.to+l-n.to||e.endSide-n.endSide,o=t<0?e.to+l:n.to,r=Math.min(o,s);if(e.point||n.point?e.point&&n.point&&(e.point==n.point||e.point.eq(n.point))&&Fi(e.activeForPoint(e.to),n.activeForPoint(n.to))||i.comparePoint(a,r,e.point,n.point):r>a&&!Fi(e.active,n.active)&&i.compareRange(a,r,e.active,n.active),o>s)break;a=o,t<=0&&e.next(),t>=0&&n.next()}}function Fi(e,t){if(e.length!=t.length)return!1;for(let n=0;n=t;n--)e[n+1]=e[n];e[t]=n}function zi(e,t){let n=-1,o=1e9;for(let r=0;re.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),s,i);else if(s&&"object"==typeof s){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");r(o(n),s,a,c)}else null!=s&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+s+";")}(a.length||c)&&i.push((!n||l||s?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)r(o(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=Gi[Wi]||1;return Gi[Wi]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let o=e[Xi],r=n&&n.nonce;o?r&&o.setNonce(r):o=new Zi(e,r),o.mount(Array.isArray(t)?t:[t])}}let Yi=new Map;class Zi{constructor(e,t){let n=e.ownerDocument||e,o=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&o.CSSStyleSheet){let t=Yi.get(n);if(t)return e.adoptedStyleSheets=[t.sheet,...e.adoptedStyleSheets],e[Xi]=t;this.sheet=new o.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],Yi.set(n,this)}else{this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);let o=e.head||e;o.insertBefore(this.styleTag,o.firstChild)}this.modules=[],e[Xi]=this}mount(e){let t=this.sheet,n=0,o=0;for(let r=0;r-1&&(this.modules.splice(s,1),o--,s=-1),-1==s){if(this.modules.splice(o++,0,i),t)for(let e=0;e",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},es="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),ts="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ns=0;ns<10;ns++)Ki[48+ns]=Ki[96+ns]=String(ns);for(ns=1;ns<=24;ns++)Ki[ns+111]="F"+ns;for(ns=65;ns<=90;ns++)Ki[ns]=String.fromCharCode(ns+32),Ji[ns]=String.fromCharCode(ns);for(var os in Ki)Ji.hasOwnProperty(os)||(Ji[os]=Ki[os]);function rs(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function is(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function ss(e,t){if(!t.anchorNode)return!1;try{return is(e,t.anchorNode)}catch(e){return!1}}function as(e){return 3==e.nodeType?bs(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function ls(e,t,n,o){return!!n&&(us(e,t,n,o,-1)||us(e,t,n,o,1))}function cs(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function us(e,t,n,o,r){for(;;){if(e==n&&t==o)return!0;if(t==(r<0?0:hs(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=cs(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(r<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=r<0?hs(e):0}}}function hs(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ps(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function fs(e){return{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function ds(e,t){let n=t.width/e.offsetWidth,o=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(o>.995&&o<1.005||!isFinite(o)||Math.abs(t.height-e.offsetHeight)<1)&&(o=1),{scaleX:n,scaleY:o}}class gs{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?hs(t):0),n,Math.min(e.focusOffset,n?hs(n):0))}set(e,t,n,o){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=o}}let ms,ys=null;function vs(e){if(e.setActive)return e.setActive();if(ys)return e.focus(ys);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==ys?{get preventScroll(){return ys={preventScroll:!0},!0}}:void 0),!ys){ys=!1;for(let e=0;eMath.max(1,e.scrollHeight-e.clientHeight-4)}class _s{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new _s(e.parentNode,cs(e),t)}static after(e,t){return new _s(e.parentNode,cs(e)+1,t)}}const ks=[];class Ss{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(2&this.flags){let n,o=this.dom,r=null;for(let i of this.children){if(7&i.flags){if(!i.dom&&(n=r?r.nextSibling:o.firstChild)){let e=Ss.get(n);(!e||!e.parent&&e.canReuseDOM(i))&&i.reuseDOM(n)}i.sync(e,t),i.flags&=-8}if(n=r?r.nextSibling:o.firstChild,t&&!t.written&&t.node==o&&n!=i.dom&&(t.written=!0),i.dom.parentNode==o)for(;n&&n!=i.dom;)n=Es(n);else o.insertBefore(i.dom,n);r=i.dom}for(n=r?r.nextSibling:o.firstChild,n&&t&&t.node==o&&(t.written=!0);n;)n=Es(n)}else if(1&this.flags)for(let n of this.children)7&n.flags&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let o=0==hs(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==this.dom)break;0==o&&t.firstChild!=t.lastChild&&(o=e==t.firstChild?-1:1),e=t}n=o<0?e:e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!Ss.get(n);)n=n.nextSibling;if(!n)return this.length;for(let e=0,t=0;;e++){let o=this.children[e];if(o.dom==n)return t;t+=o.length+o.breakAfter}}domBoundsAround(e,t,n=0){let o=-1,r=-1,i=-1,s=-1;for(let a=0,l=n,c=n;at)return n.domBoundsAround(e,t,l);if(u>=e&&-1==o&&(o=a,r=l),l>t&&n.dom.parentNode==this.dom){i=a,s=c;break}c=u,l=u+n.breakAfter}return{from:r,to:s<0?n+this.length:s,startDOM:(o?this.children[o-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:i=0?this.children[i].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),1&t.flags)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,7&this.flags&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=ks){this.markDirty();for(let o=e;othis.pos||e==this.pos&&(t>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function Ps(e,t,n,o,r,i,s,a,l){let{children:c}=e,u=c.length?c[t]:null,h=i.length?i[i.length-1]:null,p=h?h.breakAfter:s;if(!(t==o&&u&&!s&&!p&&i.length<2&&u.merge(n,r,i.length?h:null,0==n,a,l))){if(o0&&(!s&&i.length&&u.merge(n,u.length,i[0],!1,a,0)?u.breakAfter=i.shift().breakAfter:(n2);var Fs={mac:qs||/Mac/.test(Ts.platform),windows:/Win/.test(Ts.platform),linux:/Linux|X11/.test(Ts.platform),ie:Ds,ie_version:js?Ms.documentMode||6:Bs?+Bs[1]:Rs?+Rs[1]:0,gecko:Ls,gecko_version:Ls?+(/Firefox\/(\d+)/.exec(Ts.userAgent)||[0,0])[1]:0,chrome:!!$s,chrome_version:$s?+$s[1]:0,ios:qs,android:/Android\b/.test(Ts.userAgent),webkit:Is,safari:Ns,webkit_version:Is?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=Ms.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class Qs extends Ss{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){3==e.nodeType&&this.createDOM(e)}merge(e,t,n){return!(8&this.flags||n&&(!(n instanceof Qs)||this.length-(t-e)+n.length>256||8&n.flags)||(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),0))}split(e){let t=new Qs(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=8&this.flags,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new _s(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return function(e,t,n){let o=e.nodeValue.length;t>o&&(t=o);let r=t,i=t,s=0;0==t&&n<0||t==o&&n>=0?Fs.chrome||Fs.gecko||(t?(r--,s=1):i=0)?0:a.length-1];return Fs.safari&&!s&&0==l.width&&(l=Array.prototype.find.call(a,(e=>e.width))||l),s?ps(l,s<0):l||null}(this.dom,e,t)}}class Hs extends Ss{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let e of t)e.setParent(this)}setAttrs(e){if(ws(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!(8&(this.flags|e.flags))}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,o,r,i){return!(n&&(!(n instanceof Hs&&n.mark.eq(this.mark))||e&&r<=0||te&&t.push(n=e&&(o=r),n=s,r++}let i=this.length-e;return this.length=e,o>-1&&(this.children.length=o,this.markDirty()),new Hs(this.mark,t,i)}domAtPos(e){return Ws(this,e)}coordsAt(e,t){return Gs(this,e,t)}}class zs extends Ss{static create(e,t,n){return new zs(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=zs.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,o,r,i){return!(n&&(!(n instanceof zs&&this.widget.compare(n.widget))||e>0&&r<=0||t0)?_s.before(this.dom):_s.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let o=this.dom.getClientRects(),r=null;if(!o.length)return null;let i=this.side?this.side<0:e>0;for(let t=i?o.length-1:0;r=o[t],!(e>0?0==t:t==o.length-1||r.top0?_s.before(this.dom):_s.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return lr.empty}get isHidden(){return!0}}function Ws(e,t){let n=e.dom,{children:o}=e,r=0;for(let e=0;re&&t0;e--){let t=o[e-1];if(t.dom.parentNode==n)return t.domAtPos(t.length)}for(let e=r;e0&&t instanceof Hs&&r.length&&(o=r[r.length-1])instanceof Hs&&o.mark.eq(t.mark)?Xs(o,t.children[0],n-1):(r.push(t),t.setParent(e)),e.length+=t.length}function Gs(e,t,n){let o=null,r=-1,i=null,s=-1;!function e(t,a){for(let l=0,c=0;l=a&&(u.children.length?e(u,a-c):(!i||i.isHidden&&n>0)&&(h>a||c==h&&u.getSide()>0)?(i=u,s=a-c):(c-1?1:0)!=r.length-(n&&r.indexOf(n)>-1?1:0))return!1;for(let i of o)if(i!=n&&(-1==r.indexOf(i)||e[i]!==t[i]))return!1;return!0}function Ks(e,t,n){let o=!1;if(t)for(let r in t)n&&r in n||(o=!0,"style"==r?e.style.cssText="":e.removeAttribute(r));if(n)for(let r in n)t&&t[r]==n[r]||(o=!0,"style"==r?e.style.cssText=n[r]:e.setAttribute(r,n[r]));return o}function Js(e){let t=Object.create(null);for(let n=0;n0&&0==this.children[n-1].length;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Zs(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Xs(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Us(t,this.attrs||{})),n&&(this.attrs=Us({class:n},this.attrs||{}))}domAtPos(e){return Ws(this,e)}reuseDOM(e){"DIV"==e.nodeName&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?4&this.flags&&(ws(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(Ks(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let o=this.dom.lastChild;for(;o&&Ss.get(o)instanceof Hs;)o=o.lastChild;if(!(o&&this.length&&("BR"==o.nodeName||0!=(null===(n=Ss.get(o))||void 0===n?void 0:n.isEditable)||Fs.ios&&this.children.some((e=>e instanceof Qs))))){let e=document.createElement("BR");e.cmIgnore=!0,this.dom.appendChild(e)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let e,t=0;for(let n of this.children){if(!(n instanceof Qs)||/[^ -~]/.test(n.text))return null;let o=as(n.dom);if(1!=o.length)return null;t+=o[0].width,e=o[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(e,t){let n=Gs(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:e}=this.parent.view.viewState,t=n.bottom-n.top;if(Math.abs(t-e.lineHeight)<2&&e.textHeight=t){if(r instanceof ea)return r;if(i>t)break}o=i+r.breakAfter}return null}}class ta extends Ss{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,o,r,i){return!(n&&(!(n instanceof ta&&this.widget.compare(n.widget))||e>0&&r<=0||t0)}}class na{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var oa=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(oa||(oa={}));class ra extends Ai{constructor(e,t,n,o){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=o}get heightRelevant(){return!1}static mark(e){return new ia(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new aa(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,o=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:r,end:i}=la(e,o);t=(r?o?-3e8:-1:5e8)-1,n=1+(i?o?2e8:1:-6e8)}return new aa(e,t,n,o,e.widget||null,!0)}static line(e){return new sa(e)}static set(e,t=!1){return ji.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}ra.none=ji.empty;class ia extends ra{constructor(e){let{start:t,end:n}=la(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof ia&&this.tagName==e.tagName&&(this.class||(null===(t=this.attrs)||void 0===t?void 0:t.class))==(e.class||(null===(n=e.attrs)||void 0===n?void 0:n.class))&&Zs(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}ia.prototype.point=!1;class sa extends ra{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof sa&&this.spec.class==e.spec.class&&Zs(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}sa.prototype.mapMode=Mr.TrackBefore,sa.prototype.point=!0;class aa extends ra{constructor(e,t,n,o,r,i){super(t,n,r,e),this.block=o,this.isReplace=i,this.mapMode=o?t<=0?Mr.TrackBefore:Mr.TrackAfter:Mr.TrackDel}get type(){return this.startSide!=this.endSide?oa.WidgetRange:this.startSide<=0?oa.WidgetBefore:oa.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof aa&&function(e,t){return e==t||!!(e&&t&&e.compare(t))}(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function la(e,t=!1){let{inclusiveStart:n,inclusiveEnd:o}=e;return null==n&&(n=e.inclusive),null==o&&(o=e.inclusive),{start:null!=n?n:t,end:null!=o?o:t}}function ca(e,t,n,o=0){let r=n.length-1;r>=0&&n[r]+o>=e?n[r]=Math.max(n[r],t):n.push(e,t)}aa.prototype.point=!0;class ua{constructor(e,t,n,o){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=o,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof ta&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new ea),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ha(new Vs(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||e&&this.content.length&&this.content[this.content.length-1]instanceof ta||this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:o}=this.cursor.next(this.skip);if(this.skip=0,o)throw new Error("Ran out of text content when drawing inline views");if(n){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}this.text=t,this.textOff=0}let o=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(ha(new Qs(this.text.slice(this.textOff,this.textOff+o)),t),n),this.atCursorPos=!0,this.textOff+=o,e-=o,n=0}}span(e,t,n,o){this.buildText(t-e,n,o),this.pos=t,this.openStart<0&&(this.openStart=o)}point(e,t,n,o,r,i){if(this.disallowBlockEffectsFor[i]&&n instanceof aa){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let s=t-e;if(n instanceof aa)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new ta(n.widget||new pa("div"),s,n));else{let i=zs.create(n.widget||new pa("span"),s,s?0:n.startSide),a=this.atCursorPos&&!i.isEditable&&r<=o.length&&(e0),l=!i.isEditable&&(eo.length||n.startSide<=0),c=this.getLine();2!=this.pendingBuffer||a||i.isEditable||(this.pendingBuffer=0),this.flushBuffer(o),a&&(c.append(ha(new Vs(1),o),r),r=o.length+Math.max(0,r-o.length)),c.append(ha(i,o),r),this.atCursorPos=l,this.pendingBuffer=l?eo.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=o.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);s&&(this.textOff+s<=this.text.length?this.textOff+=s:(this.skip+=s-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,n,o,r){let i=new ua(e,t,n,r);return i.openEnd=ji.spans(o,t,n,i),i.openStart<0&&(i.openStart=i.openEnd),i.finish(i.openEnd),i}}function ha(e,t){for(let n of t)e=new Hs(n,[e],e.length);return e}class pa extends na{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}}var fa=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(fa||(fa={}));const da=fa.LTR,ga=fa.RTL;function ma(e){let t=[];for(let n=0;n=t){if(s.level==n)return i;(r<0||(0!=o?o<0?s.fromt:e[r].level>s.level))&&(r=i)}}if(r<0)throw new RangeError("Index out of range");return r}}function ka(e,t){if(e.length!=t.length)return!1;for(let n=0;nl&&s.push(new _a(l,d.from,p)),Ca(e,d.direction==da!=!(p%2)?o+1:o,r,d.inner,d.from,d.to,s),l=d.to),f=d.to}else{if(f==n||(t?Sa[f]!=a:Sa[f]==a))break;f++}h?Ea(e,l,f,o+1,r,h,s):lt;){let n=!0,u=!1;if(!c||l>i[c-1].to){let e=Sa[l-1];e!=a&&(n=!1,u=16==e)}let h=n||1!=a?null:[],p=n?o:o+1,f=l;e:for(;;)if(c&&f==i[c-1].to){if(u)break e;let d=i[--c];if(!n)for(let e=d.from,n=c;;){if(e==t)break e;if(!n||i[n-1].to!=e){if(Sa[e-1]==a)break e;break}e=i[--n].from}h?h.push(d):(d.to=0;e-=3)if(xa[e+1]==-n){let t=xa[e+2],n=2&t?r:4&t?1&t?i:r:0;n&&(Sa[s]=Sa[xa[e]]=n),a=e;break}}else{if(189==xa.length)break;xa[a++]=s,xa[a++]=t,xa[a++]=l}else if(2==(o=Sa[s])||1==o){let e=o==r;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=xa[t+2];if(2&n)break;if(e)xa[t+2]|=2;else{if(4&n)break;xa[t+2]|=4}}}}}(e,r,i,o,a),function(e,t,n,o){for(let r=0,i=o;r<=n.length;r++){let s=r?n[r-1].to:e,a=rl;)t==i&&(t=n[--o].from,i=o?n[o-1].to:e),Sa[--t]=u;l=s}else i=s,l++}}}(r,i,o,a),Ea(e,r,i,t,n,o,s)}function Pa(e){return[new _a(0,e,0)]}let Aa="";function Ta(e,t,n,o,r){var i;let s=o.head-e.from,a=_a.find(t,s,null!==(i=o.bidiLevel)&&void 0!==i?i:-1,o.assoc),l=t[a],c=l.side(r,n);if(s==c){let e=a+=r?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],s=l.side(!r,n),c=l.side(r,n)}let u=Or(e.text,s,l.forward(r,n));(ul.to)&&(u=c),Aa=e.text.slice(Math.min(s,u),Math.max(s,u));let h=a==(r?t.length-1:0)?null:t[a+(r?1:-1)];return h&&u==c&&h.level+(r?0:1)e.some((e=>e))}),qa=zr.define({combine:e=>e.some((e=>e))});class Fa{constructor(e,t="nearest",n="nearest",o=5,r=5,i=!1){this.range=e,this.y=t,this.x=n,this.yMargin=o,this.xMargin=r,this.isSnapshot=i}map(e){return e.empty?this:new Fa(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 Fa(Fr.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Qa=mi.define({map:(e,t)=>e.map(t)});function Ha(e,t,n){let o=e.facet(Da);o.length?o[0](t):window.onerror?window.onerror(String(t),n,void 0,void 0,t):n?console.error(n+":",t):console.error(t)}const za=zr.define({combine:e=>!e.length||e[0]});let Va=0;const Wa=zr.define();class Xa{constructor(e,t,n,o,r){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=o,this.extension=r(this)}static define(e,t){const{eventHandlers:n,eventObservers:o,provide:r,decorations:i}=t||{};return new Xa(Va++,e,n,o,(e=>{let t=[Wa.of(e)];return i&&t.push(Za.of((t=>{let n=t.plugin(e);return n?i(n):ra.none}))),r&&t.push(r(e)),t}))}static fromClass(e,t){return Xa.define((t=>new e(t)),t)}}class Ga{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(Ha(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Ha(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){Ha(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Ua=zr.define(),Ya=zr.define(),Za=zr.define(),Ka=zr.define(),Ja=zr.define(),el=zr.define();function tl(e,t){let n=e.state.facet(el);if(!n.length)return n;let o=n.map((t=>t instanceof Function?t(e):t)),r=[];return ji.spans(o,t.from,t.to,{point(){},span(e,n,o,i){let s=e-t.from,a=n-t.from,l=r;for(let e=o.length-1;e>=0;e--,i--){let n,r=o[e].spec.bidiIsolate;if(null==r&&(r=Ma(t.text,s,a)),i>0&&l.length&&(n=l[l.length-1]).to==s&&n.direction==r)n.to=a,l=n.inner;else{let e={from:s,to:a,direction:r,inner:[]};l.push(e),l=e.inner}}}}),r}const nl=zr.define();function ol(e){let t=0,n=0,o=0,r=0;for(let i of e.state.facet(nl)){let s=i(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(o=Math.max(o,s.top)),null!=s.bottom&&(r=Math.max(r,s.bottom)))}return{left:t,right:n,top:o,bottom:r}}const rl=zr.define();class il{constructor(e,t,n,o){this.fromA=e,this.toA=t,this.fromB=n,this.toB=o}join(e){return new il(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 t=e.length,n=this;for(;t>0;t--){let o=e[t-1];if(!(o.fromA>n.toA)){if(o.toAc)break;r+=2}if(!a)return n;new il(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),i=a.toA,s=a.toB}}}class sl{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=jr.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let o=[];this.changes.iterChangedRanges(((e,t,n,r)=>o.push(new il(e,t,n,r)))),this.changedRanges=o}static create(e,t,n){return new sl(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((e=>e.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class al extends Ss{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new ea],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new il(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every((({fromA:e,toA:t})=>tthis.minWidthTo))?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let o=-1;this.view.inputState.composing>=0&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?o=this.domChanged.newSel.head:function(e,t){let n=!1;return t&&e.iterChangedRanges(((e,o)=>{et.from&&(n=!0)})),n}(e.changes,this.hasComposition)||e.selectionSet||(o=e.state.selection.main.head));let r=o>-1?function(e,t,n){let o=cl(e,n);if(!o)return null;let{node:r,from:i,to:s}=o,a=r.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(o.from,o.to)!=a)return null;let l=t.invertedDesc,c=new il(l.mapPos(i),l.mapPos(s),i,s),u=[];for(let t=r.parentNode;;t=t.parentNode){let n=Ss.get(t);if(n instanceof Hs)u.push({node:t,deco:n.mark});else{if(n instanceof ea||"DIV"==t.nodeName&&t.parentNode==e.contentDOM)return{range:c,text:r,marks:u,line:t};if(t==e.contentDOM)return null;u.push({node:t,deco:new ia({inclusive:!0,attributes:Js(t),tagName:t.tagName.toLowerCase()})})}}}(this.view,e.changes,o):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:t,to:o}=this.hasComposition;n=new il(t,o,e.changes.mapPos(t,-1),e.changes.mapPos(o,1)).addToSet(n.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(Fs.ie||Fs.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=function(e,t,n){let o=new hl;return ji.compare(e,t,n,o),o.changes}(this.decorations,this.updateDeco(),e.changes);return n=il.extendWithRanges(n,i),!!(7&this.flags||0!=n.length)&&(this.updateInner(n,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:o}=this.view;o.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let e=Fs.chrome||Fs.ios?{node:o.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,e),this.flags&=-8,e&&(e.written||o.selectionRange.focusNode!=e.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((e=>e.flags&=-9));let r=[];if(this.view.viewport.from||this.view.viewport.to=0?o[e]:null;if(!t)break;let i,s,a,l,{fromA:c,toA:u,fromB:h,toB:p}=t;if(n&&n.range.fromBh){let e=ua.build(this.view.state.doc,h,n.range.fromB,this.decorations,this.dynamicDecorationMap),t=ua.build(this.view.state.doc,n.range.toB,p,this.decorations,this.dynamicDecorationMap);s=e.breakAtStart,a=e.openStart,l=t.openEnd;let o=this.compositionView(n);t.breakAtStart?o.breakAfter=1:t.content.length&&o.merge(o.length,o.length,t.content[0],!1,t.openStart,0)&&(o.breakAfter=t.content[0].breakAfter,t.content.shift()),e.content.length&&o.merge(0,0,e.content[e.content.length-1],!0,0,e.openEnd)&&e.content.pop(),i=e.content.concat(o).concat(t.content)}else({content:i,breakAtStart:s,openStart:a,openEnd:l}=ua.build(this.view.state.doc,h,p,this.decorations,this.dynamicDecorationMap));let{i:f,off:d}=r.findPos(u,1),{i:g,off:m}=r.findPos(c,-1);Ps(this,g,m,f,d,i,s,a,l)}n&&this.fixCompositionDOM(n)}compositionView(e){let t=new Qs(e.text.nodeValue);t.flags|=8;for(let{deco:n}of e.marks)t=new Hs(n,[t],t.length);let n=new ea;return n.append(t,0),n}fixCompositionDOM(e){let t=(e,t)=>{t.flags|=8|(t.children.some((e=>7&e.flags))?1:0),this.markedForComposition.add(t);let n=Ss.get(e);n&&n!=t&&(n.dom=null),t.setDOM(e)},n=this.childPos(e.range.fromB,1),o=this.children[n.i];t(e.line,o);for(let r=e.marks.length-1;r>=-1;r--)n=o.childPos(n.off,1),o=o.children[n.i],t(r>=0?e.marks[r].node:e.text,o)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let n=this.view.root.activeElement,o=n==this.dom,r=!o&&ss(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(o||t||r))return;let i=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(s.anchor)),l=s.empty?a:this.moveToLine(this.domAtPos(s.head));if(Fs.gecko&&s.empty&&!this.hasComposition&&1==(c=a).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable)){let e=document.createTextNode("");this.view.observer.ignore((()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null))),a=l=new _s(e,0),i=!0}var c;let u=this.view.observer.selectionRange;!i&&u.focusNode&&(ls(a.node,a.offset,u.anchorNode,u.anchorOffset)&&ls(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,s))||(this.view.observer.ignore((()=>{Fs.android&&Fs.chrome&&this.dom.contains(u.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let e=rs(this.view.root);if(e)if(s.empty){if(Fs.gecko){let e=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(ts.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())})),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new _s(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new _s(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&ls(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=rs(e.root),{anchorNode:o,anchorOffset:r}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let i=ea.find(this,t.head);if(!i)return;let s=i.posAtStart;if(t.head==s||t.head==s+i.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(o,r)}moveToLine(e){let t,n=this.dom;if(e.node!=n)return e;for(let o=e.offset;!t&&o=0;o--){let e=Ss.get(n.childNodes[o]);e instanceof ea&&(t=e.domAtPos(e.length))}return t?new _s(t.node,t.offset,!0):e}nearest(e){for(let t=e;t;){let e=Ss.get(t);if(e&&e.rootView==this)return e;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t=0;i--){let s=this.children[i],a=r-s.breakAfter,l=a-s.length;if(ae||s.covers(1))&&(!n||s instanceof ea&&!(n instanceof ea&&t>=0))&&(n=s,o=l),r=l}return n?n.coordsAt(e-o,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),o=this.children[t];if(!(o instanceof ea))return null;for(;o.children.length;){let{i:e,off:t}=o.childPos(n,1);for(;;e++){if(e==o.children.length)return null;if((o=o.children[e]).length)break}n=t}if(!(o instanceof Qs))return null;let r=Or(o.text,n);if(r==n)return null;let i=bs(o.dom,n,r).getClientRects();for(let e=0;eMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==fa.LTR;for(let e=0,l=0;lo)break;if(e>=n){let n=c.dom.getBoundingClientRect();if(t.push(n.height),i){let t=c.dom.lastChild,o=t?as(t):[];if(o.length){let t=o[o.length-1],i=a?t.right-n.left:n.right-t.left;i>s&&(s=i,this.minWidth=r,this.minWidthFrom=e,this.minWidthTo=u)}}}e=u+c.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return"rtl"==getComputedStyle(this.children[t].dom).direction?fa.RTL:fa.LTR}measureTextSize(){for(let e of this.children)if(e instanceof ea){let t=e.measureTextSize();if(t)return t}let e,t,n,o=document.createElement("div");return o.className="cm-line",o.style.width="99999px",o.style.position="absolute",o.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(o);let r=as(o.firstChild)[0];e=o.getBoundingClientRect().height,t=r?r.width/27:7,n=r?r.height:e,o.remove()})),{lineHeight:e,charWidth:t,textHeight:n}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Cs(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,o=0;;o++){let r=o==t.viewports.length?null:t.viewports[o],i=r?r.from-1:this.length;if(i>n){let o=(t.lineBlockAt(i).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(ra.replace({widget:new ll(o),block:!0,inclusive:!0,isBlockGap:!0}).range(n,i))}if(!r)break;n=r.to+1}return ra.set(e)}updateDeco(){let e=this.view.state.facet(Za).map(((e,t)=>(this.dynamicDecorationMap[t]="function"==typeof e)?e(this.view):e)),t=!1,n=this.view.state.facet(Ka).map(((e,n)=>{let o="function"==typeof e;return o&&(t=!0),o?e(this.view):e}));n.length&&(this.dynamicDecorationMap[e.length]=t,e.push(ji.join(n)));for(let t=e.length;tn.anchor?-1:1);if(!o)return;!n.empty&&(t=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(o={left:Math.min(o.left,t.left),top:Math.min(o.top,t.top),right:Math.max(o.right,t.right),bottom:Math.max(o.bottom,t.bottom)});let r=ol(this.view),i={left:o.left-r.left,top:o.top-r.top,right:o.right+r.right,bottom:o.bottom+r.bottom},{offsetWidth:s,offsetHeight:a}=this.view.scrollDOM;!function(e,t,n,o,r,i,s,a){let l=e.ownerDocument,c=l.defaultView||window;for(let u=e,h=!1;u&&!h;)if(1==u.nodeType){let e,p=u==l.body,f=1,d=1;if(p)e=fs(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(h=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:f,scaleY:d}=ds(u,t)),e={left:t.left,right:t.left+u.clientWidth*f,top:t.top,bottom:t.top+u.clientHeight*d}}let g=0,m=0;if("nearest"==r)t.top0&&t.bottom>e.bottom+m&&(m=t.bottom-e.bottom+m+s)):t.bottom>e.bottom&&(m=t.bottom-e.bottom+s,n<0&&t.top-m0&&t.right>e.right+g&&(g=t.right-e.right+g+i)):t.right>e.right&&(g=t.right-e.right+i,n<0&&t.left0))break;n=n.childNodes[o-1],o=hs(n)}if(n>=0)for(let o=e,r=t;;){if(3==o.nodeType)return{node:o,offset:r};if(!(1==o.nodeType&&r=0))break;o=o.childNodes[r],r=0}return null}let hl=class{constructor(){this.changes=[]}compareRange(e,t){ca(e,t,this.changes)}comparePoint(e,t){ca(e,t,this.changes)}};function pl(e,t){return t.left>e?t.left-e:Math.max(0,e-t.right)}function fl(e,t){return t.top>e?t.top-e:Math.max(0,e-t.bottom)}function dl(e,t){return e.topt.top+1}function gl(e,t){return te.bottom?{top:e.top,left:e.left,right:e.right,bottom:t}:e}function yl(e,t,n){let o,r,i,s,a,l,c,u,h=!1;for(let p=e.firstChild;p;p=p.nextSibling){let e=as(p);for(let f=0;fm||s==m&&i>g){o=p,r=d,i=g,s=m;let a=m?n0?f0)}0==g?n>d.bottom&&(!c||c.bottomd.top)&&(l=p,u=d):c&&dl(c,d)?c=ml(c,d.bottom):u&&dl(u,d)&&(u=gl(u,d.top))}}if(c&&c.bottom>=n?(o=a,r=c):u&&u.top<=n&&(o=l,r=u),!o)return{node:e,offset:0};let p=Math.max(r.left,Math.min(r.right,t));return 3==o.nodeType?vl(o,p,n):h&&"false"!=o.contentEditable?yl(o,p,n):{node:e,offset:Array.prototype.indexOf.call(e.childNodes,o)+(t>=(r.left+r.right)/2?1:0)}}function vl(e,t,n){let o=e.nodeValue.length,r=-1,i=1e9,s=0;for(let a=0;an?c.top-n:n-c.bottom)-1;if(c.left-1<=t&&c.right+1>=t&&u=(c.left+c.right)/2,o=n;if((Fs.chrome||Fs.gecko)&&bs(e,a).getBoundingClientRect().left==c.right&&(o=!n),u<=0)return{node:e,offset:a+(o?1:0)};r=a+(o?1:0),i=u}}}return{node:e,offset:r>-1?r:s>0?e.nodeValue.length:0}}function bl(e,t,n,o=-1){var r,i;let s,a=e.contentDOM.getBoundingClientRect(),l=a.top+e.viewState.paddingTop,{docHeight:c}=e.viewState,{x:u,y:h}=t,p=h-l;if(p<0)return 0;if(p>c)return e.state.doc.length;for(let t=e.viewState.heightOracle.textHeight/2,r=!1;s=e.elementAtHeight(p),s.type!=oa.Text;)for(;p=o>0?s.bottom+t:s.top-t,!(p>=0&&p<=c);){if(r)return n?null:0;r=!0,o=-o}h=l+p;let f=s.from;if(fe.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:n?null:xl(e,a,s,u,h);let d=e.dom.ownerDocument,g=e.root.elementFromPoint?e.root:d,m=g.elementFromPoint(u,h);m&&!e.contentDOM.contains(m)&&(m=null),m||(u=Math.max(a.left+1,Math.min(a.right-1,u)),m=g.elementFromPoint(u,h),m&&!e.contentDOM.contains(m)&&(m=null));let y,v=-1;if(m&&0!=(null===(r=e.docView.nearest(m))||void 0===r?void 0:r.isEditable))if(d.caretPositionFromPoint){let e=d.caretPositionFromPoint(u,h);e&&({offsetNode:y,offset:v}=e)}else if(d.caretRangeFromPoint){let t=d.caretRangeFromPoint(u,h);t&&(({startContainer:y,startOffset:v}=t),(!e.contentDOM.contains(y)||Fs.safari&&function(e,t,n){let o;if(3!=e.nodeType||t!=(o=e.nodeValue.length))return!1;for(let t=e.nextSibling;t;t=t.nextSibling)if(1!=t.nodeType||"BR"!=t.nodeName)return!1;return bs(e,o-1,o).getBoundingClientRect().left>n}(y,v,u)||Fs.chrome&&function(e,t,n){if(0!=t)return!1;for(let t=e;;){let e=t.parentNode;if(!e||1!=e.nodeType||e.firstChild!=t)return!1;if(e.classList.contains("cm-line"))break;t=e}return n-(1==e.nodeType?e.getBoundingClientRect():bs(e,0,Math.max(e.nodeValue.length,1)).getBoundingClientRect()).left>5}(y,v,u))&&(y=void 0))}if(!y||!e.docView.dom.contains(y)){let t=ea.find(e.docView,f);if(!t)return p>s.top+s.height/2?s.to:s.from;({node:y,offset:v}=yl(t.dom,u,h))}let b=e.docView.nearest(y);if(!b)return null;if(b.isWidget&&1==(null===(i=b.dom)||void 0===i?void 0:i.nodeType)){let e=b.dom.getBoundingClientRect();return t.y1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;i+=Math.floor((r-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let s=e.state.sliceDoc(n.from,n.to);return n.from+function(e,t,n,o){for(let o=0,r=0;;){if(r>=t)return o;if(o==e.length)break;r+=9==e.charCodeAt(o)?n-r%n:1,o=Or(e,o)}return e.length}(s,i,e.state.tabSize)}function wl(e,t,n,o){let r=e.state.doc.lineAt(t.head),i=e.bidiSpans(r),s=e.textDirectionAt(r.from);for(let a=t,l=null;;){let t=Ta(r,i,s,a,n),c=Aa;if(!t){if(r.number==(n?e.state.doc.lines:1))return a;c="\n",r=e.state.doc.line(r.number+(n?1:-1)),i=e.bidiSpans(r),t=e.visualLineSide(r,!n)}if(l){if(!l(c))return a}else{if(!o)return t;l=o(c)}a=t}}function Ol(e,t,n){for(;;){let o=0;for(let r of e)r.between(t-1,t+1,((e,r,i)=>{if(t>e&&tt(e))),n.from,t.head>n.from?-1:1);return o==n.from?n:Fr.cursor(o,onull)),Fs.gecko&&function(e){Zl.has(e)||(Zl.add(e),e.addEventListener("copy",(()=>{})),e.addEventListener("cut",(()=>{})))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,o=t.target;o!=e.contentDOM;o=o.parentNode)if(!o||11==o.nodeType||(n=Ss.get(o))&&n.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=El(e),n=this.handlers,o=this.view.contentDOM;for(let e in t)if("scroll"!=e){let r=!t[e].handlers.length,i=n[e];i&&r!=!i.handlers.length&&(o.removeEventListener(e,this.handleEvent),i=null),i||o.addEventListener(e,this.handleEvent,{passive:r})}for(let e in n)"scroll"==e||t[e]||o.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&Date.now()t.keyCode==e.keyCode)))&&!e.ctrlKey||Pl.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,xs(this.view.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&(this.composing>0||!!(Fs.safari&&!Fs.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}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 Sl(e,t){return(n,o)=>{try{return t.call(e,o,n)}catch(e){Ha(n.state,e)}}}function El(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec;if(e&&e.domEventHandlers)for(let o in e.domEventHandlers){let r=e.domEventHandlers[o];r&&n(o).handlers.push(Sl(t.value,r))}if(e&&e.domEventObservers)for(let o in e.domEventObservers){let r=e.domEventObservers[o];r&&n(o).observers.push(Sl(t.value,r))}}for(let e in Rl)n(e).handlers.push(Rl[e]);for(let e in jl)n(e).observers.push(jl[e]);return t}const Cl=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Pl="dthko",Al=[16,17,18,20,91,92,224,225];function Tl(e){return.7*Math.max(0,e)+8}class Ml{constructor(e,t,n,o){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=function(e){let t=e.ownerDocument;for(let n=e.parentNode;n&&n!=t.body;)if(1==n.nodeType){if(n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)return n;n=n.assignedSlot||n.parentNode}else{if(11!=n.nodeType)break;n=n.host}return null}(e.contentDOM),this.atoms=e.state.facet(Ja).map((t=>t(e)));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Ci.allowMultipleSelections)&&function(e,t){let n=e.state.facet(Ra);return n.length?n[0](t):Fs.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let o=rs(e.root);if(!o||0==o.rangeCount)return!0;let r=o.getRangeAt(0).getClientRects();for(let e=0;e=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=Vl(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){var t;if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&function(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,o=0,r=(null===(t=this.scrollParent)||void 0===t?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},i=ol(this.view);e.clientX-i.left<=r.left+6?n=-Tl(r.left-e.clientX):e.clientX+i.right>=r.right-6&&(n=Tl(e.clientX-r.right)),e.clientY-i.top<=r.top+6?o=-Tl(r.top-e.clientY):e.clientY+i.bottom>=r.bottom-6&&(o=Tl(e.clientY-r.bottom)),this.setScrollSpeed(n,o)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;nthis.select(this.lastEvent)),20)}}const Rl=Object.create(null),jl=Object.create(null),Bl=Fs.ie&&Fs.ie_version<15||Fs.ios&&Fs.webkit_version<604;function Dl(e,t){let n,{state:o}=e,r=1,i=o.toText(t),s=i.lines==o.selection.ranges.length;if(null!=Xl&&o.selection.ranges.every((e=>e.empty))&&Xl==i.toString()){let e=-1;n=o.changeByRange((n=>{let a=o.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=o.toText((s?i.line(r++).text:t)+o.lineBreak);return{changes:{from:a.from,insert:l},range:Fr.cursor(n.from+l.length)}}))}else n=s?o.changeByRange((e=>{let t=i.line(r++);return{changes:{from:e.from,to:e.to,insert:t.text},range:Fr.cursor(e.from+t.length)}})):o.replaceSelection(i);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function Ll(e,t,n,o){if(1==o)return Fr.cursor(t,n);if(2==o)return function(e,t,n=1){let o=e.charCategorizer(t),r=e.doc.lineAt(t),i=t-r.from;if(0==r.length)return Fr.cursor(t);0==i?n=1:i==r.length&&(n=-1);let s=i,a=i;n<0?s=Or(r.text,i,!1):a=Or(r.text,i);let l=o(r.text.slice(s,a));for(;s>0;){let e=Or(r.text,s,!1);if(o(r.text.slice(e,s))!=l)break;s=e}for(;a{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},Rl.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&(e.inputState.lastEscPress=Date.now()),!1),jl.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},jl.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},Rl.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let o of e.state.facet(Ba))if(n=o(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=ql(e,t),o=Vl(t),r=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),r=r.map(e.changes))},get(t,i,s){let a,l=ql(e,t),c=Ll(e,l.pos,l.bias,o);if(n.pos!=l.pos&&!i){let t=Ll(e,n.pos,n.bias,o),r=Math.min(t.from,c.from),i=Math.max(t.to,c.to);c=r1&&(a=function(e,t){for(let n=0;n=t)return Fr.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(r,l.pos))?a:s?r.addRange(c):Fr.create([c])}}}(e,t)),n){let o=!e.hasFocus;e.inputState.startMouseSelection(new Ml(e,t,n,o)),o&&e.observer.ignore((()=>vs(e.contentDOM)));let r=e.inputState.mouseSelection;if(r)return r.start(t),!1===r.dragging}return!1};let $l=(e,t)=>e>=t.top&&e<=t.bottom,Il=(e,t,n)=>$l(t,n)&&e>=n.left&&e<=n.right;function Nl(e,t,n,o){let r=ea.find(e.docView,t);if(!r)return 1;let i=t-r.posAtStart;if(0==i)return 1;if(i==r.length)return-1;let s=r.coordsAt(i,-1);if(s&&Il(n,o,s))return-1;let a=r.coordsAt(i,1);return a&&Il(n,o,a)?1:s&&$l(o,s)?-1:1}function ql(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:n,bias:Nl(e,n,t.clientX,t.clientY)}}const Fl=Fs.ie&&Fs.ie_version<=11;let Ql=null,Hl=0,zl=0;function Vl(e){if(!Fl)return e.detail;let t=Ql,n=zl;return Ql=e,zl=Date.now(),Hl=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Hl+1)%3:1}function Wl(e,t,n,o){if(!n)return;let r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:i}=e.inputState,s=o&&i&&function(e,t){let n=e.state.facet(ja);return n.length?n[0](t):Fs.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:i.from,to:i.to}:null,a={from:r,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}Rl.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let o=e.docView.nearest(t.target);if(o&&o.isWidget){let e=o.posAtStart,t=e+o.length;(e>=n.to||t<=n.from)&&(n=Fr.range(e,t))}}let{inputState:o}=e;return o.mouseSelection&&(o.mouseSelection.dragging=!0),o.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",e.state.sliceDoc(n.from,n.to)),t.dataTransfer.effectAllowed="copyMove"),!1},Rl.dragend=e=>(e.inputState.draggedContent=null,!1),Rl.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let o=Array(n.length),r=0,i=()=>{++r==n.length&&Wl(e,t,o.filter((e=>null!=e)).join(e.state.lineBreak),!1)};for(let e=0;e{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(o[e]=t.result),i()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return Wl(e,t,n,!0),!0}return!1},Rl.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=Bl?null:t.clipboardData;return n?(Dl(e,n.getData("text/plain")||n.getData("text/uri-text")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout((()=>{e.focus(),n.remove(),Dl(e,n.value)}),50)}(e),!1)};let Xl=null;Rl.copy=Rl.cut=(e,t)=>{let{text:n,ranges:o,linewise:r}=function(e){let t=[],n=[],o=!1;for(let o of e.selection.ranges)o.empty||(t.push(e.sliceDoc(o.from,o.to)),n.push(o));if(!t.length){let r=-1;for(let{from:o}of e.selection.ranges){let i=e.doc.lineAt(o);i.number>r&&(t.push(i.text),n.push({from:i.from,to:Math.min(e.doc.length,i.to+1)})),r=i.number}o=!0}return{text:t.join(e.lineBreak),ranges:n,linewise:o}}(e.state);if(!n&&!r)return!1;Xl=r?n:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:o,scrollIntoView:!0,userEvent:"delete.cut"});let i=Bl?null:t.clipboardData;return i?(i.clearData(),i.setData("text/plain",n),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let o=n.appendChild(document.createElement("textarea"));o.style.cssText="position: fixed; left: -10000px; top: 10px",o.value=t,o.focus(),o.selectionEnd=t.length,o.selectionStart=0,setTimeout((()=>{o.remove(),e.focus()}),50)}(e,n),!1)};const Gl=fi.define();function Ul(e,t){let n=[];for(let o of e.facet(Ia)){let r=o(e,t);r&&n.push(r)}return n?e.update({effects:n,annotations:Gl.of(!0)}):null}function Yl(e){setTimeout((()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Ul(e.state,t);n?e.dispatch(n):e.update([])}}),10)}jl.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),Yl(e)},jl.blur=e=>{e.observer.clearSelectionRange(),Yl(e)},jl.compositionstart=jl.compositionupdate=e=>{null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0)},jl.compositionend=e=>{e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Fs.chrome&&Fs.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then((()=>e.observer.flush())):setTimeout((()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])}),50)},jl.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},Rl.beforeinput=(e,t)=>{var n;let o;if(Fs.chrome&&Fs.android&&(o=Cl.find((e=>e.inputType==t.inputType)))&&(e.observer.delayAndroidKey(o.key,o.keyCode),"Backspace"==o.key||"Delete"==o.key)){let t=(null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0;setTimeout((()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())}),100)}return!1};const Zl=new Set,Kl=["pre-wrap","normal","pre-line","break-spaces"];class Jl{constructor(e){this.lineWrapping=e,this.doc=lr.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Kl.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=s;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=o,this.lineLength=r,a){this.heightSamples={};for(let e=0;e0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>oc&&(e.heightChanged=!0),this.height=t)}replace(e,t,n){return rc.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,o){let r=this,i=n.doc;for(let s=o.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:u}=o[s],h=r.lineAt(a,nc.ByPosNoHeight,n.setDoc(t),0,0),p=h.to>=l?h:r.lineAt(l,nc.ByPosNoHeight,n,0,0);for(u+=p.to-l,l=p.to;s>0&&h.from<=o[s-1].toA;)a=o[s-1].fromA,c=o[s-1].fromB,s--,a2*r){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),n+=1+r.break,o-=r.size}else{if(!(r>2*o))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,r-=t.size}}else if(o=r&&i(this.blockAt(0,n,o,r))}updateHeight(e,t=0,n=!1,o){return o&&o.from<=t&&o.more&&this.setHeight(e,o.heights[o.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class sc extends ic{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,o){return new tc(o,this.length,n,this.height,this.breaks)}replace(e,t,n){let o=n[0];return 1==n.length&&(o instanceof sc||o instanceof ac&&4&o.flags)&&Math.abs(this.length-o.length)<10?(o instanceof ac?o=new sc(o.length,this.height):o.height=this.height,this.outdated||(o.outdated=!1),o):rc.of(n)}updateHeight(e,t=0,n=!1,o){return o&&o.from<=t&&o.more?this.setHeight(e,o.heights[o.index++]):(n||this.outdated)&&this.setHeight(e,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 ac extends rc{constructor(e){super(e,0)}heightMetrics(e,t){let n,o=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-o+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);n=t/i,this.length>i+1&&(s=(this.height-t)/(this.length-i-1))}else n=this.height/i;return{firstLine:o,lastLine:r,perLine:n,perChar:s}}blockAt(e,t,n,o){let{firstLine:r,lastLine:i,perLine:s,perChar:a}=this.heightMetrics(t,o);if(t.lineWrapping){let r=o+Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length),i=t.doc.lineAt(r),l=s+i.length*a,c=Math.max(n,e-l/2);return new tc(i.from,i.length,c,l,0)}{let o=Math.max(0,Math.min(i-r,Math.floor((e-n)/s))),{from:a,length:l}=t.doc.line(r+o);return new tc(a,l,n+s*o,s,0)}}lineAt(e,t,n,o,r){if(t==nc.ByHeight)return this.blockAt(e,n,o,r);if(t==nc.ByPosNoHeight){let{from:t,to:o}=n.doc.lineAt(e);return new tc(t,o-t,0,0,0)}let{firstLine:i,perLine:s,perChar:a}=this.heightMetrics(n,r),l=n.doc.lineAt(e),c=s+l.length*a,u=l.number-i,h=o+s*u+a*(l.from-r-u);return new tc(l.from,l.length,Math.max(o,Math.min(h,o+this.height-c)),c,0)}forEachLine(e,t,n,o,r,i){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(n,r);for(let c=e,u=o;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-s;u+=a*n+l*(e-r-n)}let o=a+l*t.length;i(new tc(t.from,t.length,u,o,0)),u+=o,c=t.to+1}}replace(e,t,n){let o=this.length-t;if(o>0){let e=n[n.length-1];e instanceof ac?n[n.length-1]=new ac(e.length+o):n.push(null,new ac(o-1))}if(e>0){let t=n[0];t instanceof ac?n[0]=new ac(e+t.length):n.unshift(new ac(e-1),null)}return rc.of(n)}decomposeLeft(e,t){t.push(new ac(e-1),null)}decomposeRight(e,t){t.push(null,new ac(this.length-e-1))}updateHeight(e,t=0,n=!1,o){let r=t+this.length;if(o&&o.from<=t+this.length&&o.more){let n=[],i=Math.max(t,o.from),s=-1;for(o.from>t&&n.push(new ac(o.from-t-1).updateHeight(e,t));i<=r&&o.more;){let t=e.doc.lineAt(i).length;n.length&&n.push(null);let r=o.heights[o.index++];-1==s?s=r:Math.abs(r-s)>=oc&&(s=-2);let a=new sc(t,r);a.outdated=!1,n.push(a),i+=t+1}i<=r&&n.push(null,new ac(r-i).updateHeight(e,i));let a=rc.of(n);return(s<0||Math.abs(a.height-this.height)>=oc||Math.abs(s-this.heightMetrics(e,t).perLine)>=oc)&&(e.heightChanged=!0),a}return(n||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class lc extends rc{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,o){let r=n+this.left.height;return es))return l;let c=t==nc.ByPosNoHeight?nc.ByPosNoHeight:nc.ByPos;return a?l.join(this.right.lineAt(s,c,n,i,s)):this.left.lineAt(s,c,n,o,r).join(l)}forEachLine(e,t,n,o,r,i){let s=o+this.left.height,a=r+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,n,s,a,i);else{let l=this.lineAt(a,nc.ByPos,n,o,r);e=e&&l.from<=t&&i(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,i)}}replace(e,t,n){let o=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-o,t-o,n));let r=[];e>0&&this.decomposeLeft(e,r);let i=r.length;for(let e of n)r.push(e);if(e>0&&cc(r,i-1),t=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,o=n+this.break;if(e>=o)return this.right.decomposeRight(e-o,t);e2*t.size||t.size>2*e.size?rc.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,o){let{left:r,right:i}=this,s=t+r.length+this.break,a=null;return o&&o.from<=t+r.length&&o.more?a=r=r.updateHeight(e,t,n,o):r.updateHeight(e,t,n),o&&o.from<=s+i.length&&o.more?a=i=i.updateHeight(e,s,n,o):i.updateHeight(e,s,n),a?this.balanced(r,i):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cc(e,t){let n,o;null==e[t]&&(n=e[t-1])instanceof ac&&(o=e[t+1])instanceof ac&&e.splice(t-1,3,new ac(n.length+1+o.length))}class uc{constructor(e,t){this.pos=e,this.oracle=t,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,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof sc?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new sc(e-this.pos,-1)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e=5)&&this.addLineDeco(o,r,i)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new sc(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new ac(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof sc)return e;let t=new sc(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let o=this.ensureLine();o.length+=n,o.collapsed+=n,o.widgetHeight=Math.max(o.widgetHeight,e),o.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof sc||this.isCovered?(this.writtenTon.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=o.overflow){let o=n.getBoundingClientRect();i=Math.max(i,o.left),s=Math.min(s,o.right),a=Math.max(a,o.top),l=t==e.parentNode?o.bottom:Math.min(l,o.bottom)}t="absolute"==o.position||"fixed"==o.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:i-n.left,right:Math.max(i,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function fc(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class dc{constructor(e,t,n){this.from=e,this.to=t,this.size=n}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n"function"!=typeof e&&"cm-lineWrapping"==e.class));this.heightOracle=new Jl(t),this.stateDeco=e.facet(Za).filter((e=>"function"!=typeof e)),this.heightMap=rc.empty().applyChanges(this.stateDeco,lr.empty,this.heightOracle.setDoc(e.doc),[new il(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ra.set(this.lineGaps.map((e=>e.draw(this,!1)))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let o=n?t.head:t.anchor;if(!e.some((({from:e,to:t})=>o>=e&&o<=t))){let{from:t,to:n}=this.lineBlockAt(o);e.push(new yc(t,n))}}this.viewports=e.sort(((e,t)=>e.from-t.from)),this.scaler=this.heightMap.height<=7e6?wc:new Oc(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(e=>{this.viewportLines.push(1==this.scaler.scale?e:_c(e,this.scaler))}))}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(Za).filter((e=>"function"!=typeof e));let o=e.changedRanges,r=il.extendWithRanges(o,function(e,t,n){let o=new hc;return ji.compare(e,t,n,o,0),o.changes}(n,this.stateDeco,e?e.changes:jr.empty(this.state.doc.length))),i=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=i&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=!e.changes.empty||2&e.flags||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),l&&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(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(qa)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),o=this.heightOracle,r=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?fa.RTL:fa.LTR;let i=this.heightOracle.mustRefreshForWrapping(r),s=t.getBoundingClientRect(),a=i||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let l=0,c=0;if(s.width&&s.height){let{scaleX:e,scaleY:n}=ds(t,s);this.scaleX==e&&this.scaleY==n||(this.scaleX=e,this.scaleY=n,l|=8,i=a=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,h=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==h||(this.paddingTop=u,this.paddingBottom=h,l|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(o.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=8);let p=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=p&&(this.scrollAnchorHeight=-1,this.scrollTop=p),this.scrolledToBottom=Os(e.scrollDOM);let f=(this.printing?fc:pc)(t,this.paddingTop),d=f.top-this.pixelViewport.top,g=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let y=s.width;if(this.contentDOMWidth==y&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=8),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(t)&&(i=!0),i||o.lineWrapping&&Math.abs(y-this.contentDOMWidth)>o.charWidth){let{lineHeight:n,charWidth:s,textHeight:a}=e.docView.measureTextSize();i=n>0&&o.refresh(r,n,s,a,y/s,t),i&&(e.docView.minWidth=0,l|=8)}d>0&&g>0?c=Math.max(d,g):d<0&&g<0&&(c=Math.min(d,g)),o.heightChanged=!1;for(let n of this.viewports){let r=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(i?rc.empty().applyChanges(this.stateDeco,lr.empty,this.heightOracle,[new il(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,i,new ec(n.from,r))}o.heightChanged&&(l|=2)}let v=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return v&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&l||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(i?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),o=this.heightMap,r=this.heightOracle,{visibleTop:i,visibleBottom:s}=this,a=new yc(o.lineAt(i-1e3*n,nc.ByHeight,r,0,0).from,o.lineAt(s+1e3*(1-n),nc.ByHeight,r,0,0).to);if(t){let{head:e}=t.range;if(ea.to){let n,i=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=o.lineAt(e,nc.ByPos,r,0,0);n="center"==t.y?(s.top+s.bottom)/2-i/2:"start"==t.y||"nearest"==t.y&&e=s+Math.max(10,Math.min(n,250)))&&o>i-2e3&&r>1,i=o<<1;if(this.defaultTextDirection!=fa.LTR&&!n)return[];let s=[],a=(o,i,l,c)=>{if(i-oo&&ee.from>=l.from&&e.to<=l.to&&Math.abs(e.from-o)e.fromt))));if(!p){if(ie.from<=i&&e.to>=i))){let e=t.moveToLineBoundary(Fr.cursor(i),!1,!0).head;e>o&&(i=e)}p=new dc(o,i,this.gapSize(l,o,i,c))}s.push(p)};for(let e of this.viewportLines){if(e.lengthe.from&&a(e.from,r,e,t),se.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];ji.spans(e,this.viewport.from,this.viewport.to,{span(e,n){t.push({from:e,to:n})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some(((e,n)=>e.from!=t[n].from||e.to!=t[n].to));return this.visibleRanges=t,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find((t=>t.from<=e&&t.to>=e))||_c(this.heightMap.lineAt(e,nc.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return _c(this.heightMap.lineAt(this.scaler.fromDOM(e),nc.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return _c(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 yc{constructor(e,t){this.from=e,this.to=t}}function vc(e,t,n){let o=[],r=e,i=0;return ji.spans(n,e,t,{span(){},point(e,t){e>r&&(o.push({from:r,to:e}),i+=e-r),r=t}},20),r=1)return t[t.length-1].to;let o=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:r}=t[e],i=r-n;if(o<=i)return n+o;o-=i}}function xc(e,t){let n=0;for(let{from:o,to:r}of e.ranges){if(t<=r){n+=t-o;break}n+=r-o}return n/e.total}const wc={toDOM:e=>e,fromDOM:e=>e,scale:1};class Oc{constructor(e,t,n){let o=0,r=0,i=0;this.viewports=n.map((({from:n,to:r})=>{let i=t.lineAt(n,nc.ByPos,e,0,0).top,s=t.lineAt(r,nc.ByPos,e,0,0).bottom;return o+=s-i,{from:n,to:r,top:i,bottom:s,domTop:0,domBottom:0}})),this.scale=(7e6-o)/(t.height-o);for(let e of this.viewports)e.domTop=i+(e.top-r)*this.scale,i=e.domBottom=e.domTop+(e.bottom-e.top),r=e.bottom}toDOM(e){for(let t=0,n=0,o=0;;t++){let r=t_c(e,t))):e._content)}const kc=zr.define({combine:e=>e.join(" ")}),Sc=zr.define({combine:e=>e.indexOf(!0)>-1}),Ec=Ui.newName(),Cc=Ui.newName(),Pc=Ui.newName(),Ac={"&light":"."+Cc,"&dark":"."+Pc};function Tc(e,t,n){return new Ui(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,(t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]})):e+" "+t})}const Mc=Tc("."+Ec,{"&":{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},".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":{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:"#444"},".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",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&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},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".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"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,\')',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"}},Ac),Rc="";class jc{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(Ci.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Rc}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let o=e;;){this.findPointBefore(n,o);let e=this.text.length;this.readNode(o);let r=o.nextSibling;if(r==t)break;let i=Ss.get(o),s=Ss.get(r);(i&&s?i.breakAfter:(i?i.breakAfter:Dc(o))||Dc(r)&&("BR"!=o.nodeName||o.cmIgnore)&&this.text.length>e)&&this.lineBreak(),o=r}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let r,i=-1,s=1;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(r=o.exec(t))&&(i=r.index,s=r[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=i+s}}readNode(e){if(e.cmIgnore)return;let t=Ss.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Bc(e,n.node,n.offset)?t:0))}}function Bc(e,t,n){for(;;){if(!t||n-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let t=r||i?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}=e.observer.selectionRange;return n&&(t.push(new Lc(n,o)),r==n&&i==o||t.push(new Lc(r,i))),t}(e),n=new jc(t,e.state);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,o=2==e.length?e[1].pos:n;return n>-1&&o>-1?Fr.single(n+t,o+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=r&&r.node==t.focusNode&&r.offset==t.focusOffset||!is(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),o=i&&i.node==t.anchorNode&&i.offset==t.anchorOffset||!is(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if(Fs.ios&&e.state.selection.main.empty&&n!=o&&(s.from>0||s.toDate.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:o,to:s}=t.bounds,a=r.from,l=null;(8===i||Fs.android&&t.text.length0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;return"end"==o&&(n-=s+Math.max(0,i-Math.min(s,a))-i),s=s?i-n:0,a=i+(a-s),s=i):a=a?i-n:0,s=i+(s-a),a=i),{from:i,toA:s,toB:a}}(e.state.doc.sliceString(o,s,Rc),t.text,a-o,l);c&&(Fs.chrome&&13==i&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==Rc+Rc&&c.toB--,n={from:o+c.from,to:o+c.toA,insert:lr.of(t.text.slice(c.from,c.toB).split(Rc))})}else o&&(!e.hasFocus&&e.state.facet(za)||o.main.eq(r))&&(o=null);if(!n&&!o)return!1;if(!n&&t.typeOver&&!r.empty&&o&&o.main.empty?n={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,r.to)}:n&&n.from>=r.from&&n.to<=r.to&&(n.from!=r.from||n.to!=r.to)&&r.to-r.from-(n.to-n.from)<=4?n={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,r.to))}:(Fs.mac||Fs.android)&&n&&n.from==n.to&&n.from==r.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(o&&2==n.insert.length&&(o=Fr.single(o.main.anchor-1,o.main.head-1)),n={from:r.from,to:r.to,insert:lr.of([" "])}):Fs.chrome&&n&&n.from==n.to&&n.from==r.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(o&&(o=Fr.single(o.main.anchor-1,o.main.head-1)),n={from:r.from,to:r.to,insert:lr.of([" "])}),n){if(Fs.ios&&e.inputState.flushIOSKey())return!0;if(Fs.android&&(n.from==r.from&&n.to==r.to&&1==n.insert.length&&2==n.insert.lines&&xs(e.contentDOM,"Enter",13)||(n.from==r.from-1&&n.to==r.to&&0==n.insert.length||8==i&&n.insert.lengthr.head)&&xs(e.contentDOM,"Backspace",8)||n.from==r.from&&n.to==r.to+1&&0==n.insert.length&&xs(e.contentDOM,"Delete",46)))return!0;let t,s=n.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>t||(t=function(e,t,n){let o,r=e.state,i=r.selection.main;if(t.from>=i.from&&t.to<=i.to&&t.to-t.from>=(i.to-i.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=i.fromt.to?r.sliceDoc(t.to,i.to):"";o=r.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+s))}else{let s=r.changes(t),a=n&&n.main.to<=s.newLength?n.main:void 0;if(r.selection.ranges.length>1&&e.inputState.composing>=0&&t.to<=i.to&&t.to>=i.to-10){let l,c=e.state.sliceDoc(t.from,t.to),u=n&&cl(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(i.head);let h=i.to-t.to,p=i.to-i.from;o=r.changeByRange((n=>{if(n.from==i.from&&n.to==i.to)return{changes:s,range:a||n.map(s)};let o=n.to-h,u=o-c.length;if(n.to-n.from!=p||e.state.sliceDoc(u,o)!=c||n.to>=l.from&&n.from<=l.to)return{range:n};let f=r.changes({from:u,to:o,insert:t.insert}),d=n.to-i.to;return{changes:f,range:a?Fr.range(Math.max(0,a.anchor+d),Math.max(0,a.head+d)):n.map(f)}}))}else o={changes:s,selection:a&&r.selection.replaceRange(a)}}let s="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=".compose",e.inputState.compositionFirstChange&&(s+=".start",e.inputState.compositionFirstChange=!1)),r.update(o,{userEvent:s,scrollIntoView:!0})}(e,n,o));return e.state.facet($a).some((t=>t(e,n.from,n.to,s,a)))||e.dispatch(a()),!0}if(o&&!o.main.eq(r)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin),e.dispatch({selection:o,scrollIntoView:t,userEvent:n}),!0}return!1}const Nc={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},qc=Fs.ie&&Fs.ie_version<=11;class Fc{constructor(e){this.view=e,this.active=!1,this.selectionRange=new gs,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.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver((t=>{for(let e of t)this.queue.push(e);(Fs.ie&&Fs.ie_version<=11||Fs.ios&&e.composing)&&t.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),qc&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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((e=>{e.length>0&&e[e.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.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some(((t,n)=>t!=e[n])))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,o=this.selectionRange;if(n.state.facet(za)?n.root.activeElement!=this.dom:!ss(n.dom,o))return;let r=o.anchorNode&&n.docView.nearest(o.anchorNode);r&&r.ignoreEvent(e)?t||(this.selectionChanged=!1):(Fs.ie&&Fs.ie_version<=11||Fs.android&&Fs.chrome)&&!n.state.selection.main.empty&&o.focusNode&&ls(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Fs.safari&&11==e.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e){let t=null;function n(e){e.preventDefault(),e.stopImmediatePropagation(),t=e.getTargetRanges()[0]}if(e.contentDOM.addEventListener("beforeinput",n,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",n,!0),!t)return null;let o=t.startContainer,r=t.startOffset,i=t.endContainer,s=t.endOffset,a=e.docView.domAtPos(e.state.selection.main.anchor);return ls(a.node,a.offset,i,s)&&([o,r,i,s]=[i,s,o,r]),{anchorNode:o,anchorOffset:r,focusNode:i,focusOffset:s}}(this.view)||rs(e.root);if(!t||this.selectionRange.eq(t))return!1;let n=ss(this.dom,t);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&xs(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange