/*! dmn-js - 17.7.0 | generated for dokuwiki-plugin-bpmnio | SEE LICENSE IN LICENSE */ (()=>{var kb=Object.create;var kc=Object.defineProperty;var Cb=Object.getOwnPropertyDescriptor;var Sb=Object.getOwnPropertyNames;var Eb=Object.getPrototypeOf,Ab=Object.prototype.hasOwnProperty;var _b=(n,e,t)=>e in n?kc(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Tb=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Mb=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Sb(e))!Ab.call(n,r)&&r!==t&&kc(n,r,{get:()=>e[r],enumerable:!(i=Cb(e,r))||i.enumerable});return n};var Rb=(n,e,t)=>(t=n!=null?kb(Eb(n)):{},Mb(e||!n||!n.__esModule?kc(t,"default",{value:n,enumerable:!0}):t,n));var L=(n,e,t)=>_b(n,typeof e!="symbol"?e+"":e,t);var Ng=Tb((VF,$g)=>{"use strict";/*! * escape-html * Copyright(c) 2012-2013 TJ Holowaychuk * Copyright(c) 2015 Andreas Lubbe * Copyright(c) 2015 Tiancheng "Timothy" Gu * MIT Licensed */var OC=/["'&<>]/;$g.exports=kC;function kC(n){var e=""+n,t=OC.exec(e);if(!t)return e;var i,r="",s=0,o=0;for(s=t.index;se===n}function Db(n){return n}function Bb(n){return Number(n)}function Gi(n,e){let t,i,r,s;function o(f){let h=Date.now(),d=f?0:s+e-h;if(d>0)return a(d);n.apply(r,i),l()}function a(f){t=setTimeout(o,f)}function l(){t&&clearTimeout(t),t=s=i=r=void 0}function c(){t&&o(!0),l()}function u(...f){s=Date.now(),i=f,r=this,t||a(e)}return u.flush=c,u.cancel=l,u}function Wd(n,e){let t=!1;return function(...i){t||(n(...i),t=!0,setTimeout(()=>{t=!1},e))}}function Ft(n,e){return n.bind(e)}function D(n,...e){return Object.assign(n,...e)}function Hd(n,e,t){let i=n;return B(e,function(r,s){if(typeof r!="number"&&typeof r!="string")throw new Error("illegal key type: "+typeof r+". Key should be of type number or string.");if(r==="constructor")throw new Error("illegal key: constructor");if(r==="__proto__")throw new Error("illegal key: __proto__");let o=e[s+1],a=i[r];ht(o)&&ha(a)&&(a=i[r]=isNaN(+o)?{}:[]),fa(o)?fa(t)?delete i[r]:i[r]=t:i=a}),n}function Xd(n,e){let t={},i=Object(n);return B(e,function(r){r in i&&(t[r]=n[r])}),t}var da="__fn",Ud=1e3,Ib=Array.prototype.slice;function ye(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}ye.prototype.on=function(n,e,t,i){if(n=_e(n)?n:[n],Ie(e)&&(i=t,t=e,e=Ud),!Ce(e))throw new Error("priority must be a number");var r=t;i&&(r=Ft(t,i),r[da]=t[da]||t);var s=this;n.forEach(function(o){s._addListener(o,{priority:e,callback:r,next:null})})};ye.prototype.once=function(n,e,t,i){var r=this;if(Ie(e)&&(i=t,t=e,e=Ud),!Ce(e))throw new Error("priority must be a number");function s(){s.__isTomb=!0;var o=t.apply(i,arguments);return r.off(n,s),o}s[da]=t,this.on(n,e,s)};ye.prototype.off=function(n,e){n=_e(n)?n:[n];var t=this;n.forEach(function(i){t._removeListener(i,e)})};ye.prototype.createEvent=function(n){var e=new As;return e.init(n),e};ye.prototype.fire=function(n,e){var t,i,r,s;if(s=Ib.call(arguments),typeof n=="object"&&(e=n,n=e.type),!n)throw new Error("no event type specified");if(i=this._listeners[n],!!i){e instanceof As?t=e:t=this.createEvent(e),s[0]=t;var o=t.type;n!==o&&(t.type=n);try{r=this._invokeListeners(t,s,i)}finally{n!==o&&(t.type=o)}return r===void 0&&t.defaultPrevented&&(r=!1),r}};ye.prototype.handleError=function(n){return this.fire("error",{error:n})===!1};ye.prototype._destroy=function(){this._listeners={}};ye.prototype._invokeListeners=function(n,e,t){for(var i;t&&!n.cancelBubble;)i=this._invokeListener(n,e,t),t=t.next;return i};ye.prototype._invokeListener=function(n,e,t){var i;if(t.callback.__isTomb)return i;try{i=Lb(t.callback,e),i!==void 0&&(n.returnValue=i,n.stopPropagation()),i===!1&&n.preventDefault()}catch(r){if(!this.handleError(r))throw console.error("unhandled error in event listener",r),r}return i};ye.prototype._addListener=function(n,e){var t=this._getListeners(n),i;if(!t){this._setListeners(n,e);return}for(;t;){if(t.priority or , got "+n);return n=(r?r+":":"")+i,{name:n,prefix:r,localName:i}}function pt(n){this.ns=n,this.name=n.name,this.allTypes=[],this.allTypesByName={},this.properties=[],this.propertiesByName={}}pt.prototype.build=function(){return Xd(this,["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"])};pt.prototype.addProperty=function(n,e,t){typeof e=="boolean"&&(t=e,e=void 0),this.addNamedProperty(n,t!==!1);var i=this.properties;e!==void 0?i.splice(e,0,n):i.push(n)};pt.prototype.replaceProperty=function(n,e,t){var i=n.ns,r=this.properties,s=this.propertiesByName,o=n.name!==e.name;if(n.isId){if(!e.isId)throw new Error("property <"+e.ns.name+"> must be id property to refine <"+n.ns.name+">");this.setIdProperty(e,!1)}if(n.isBody){if(!e.isBody)throw new Error("property <"+e.ns.name+"> must be body property to refine <"+n.ns.name+">");this.setBodyProperty(e,!1)}var a=r.indexOf(n);if(a===-1)throw new Error("property <"+i.name+"> not found in property list");r.splice(a,1),this.addProperty(e,t?void 0:a,o),s[i.name]=s[i.localName]=e};pt.prototype.redefineProperty=function(n,e,t){var i=n.ns.prefix,r=e.split("#"),s=Te(r[0],i),o=Te(r[1],s.prefix).name,a=this.propertiesByName[o];if(a)this.replaceProperty(a,n,t);else throw new Error("refined property <"+o+"> not found");delete n.redefines};pt.prototype.addNamedProperty=function(n,e){var t=n.ns,i=this.propertiesByName;e&&(this.assertNotDefined(n,t.name),this.assertNotDefined(n,t.localName)),i[t.name]=i[t.localName]=n};pt.prototype.removeNamedProperty=function(n){var e=n.ns,t=this.propertiesByName;delete t[e.name],delete t[e.localName]};pt.prototype.setBodyProperty=function(n,e){if(e&&this.bodyProperty)throw new Error("body property defined multiple times (<"+this.bodyProperty.ns.name+">, <"+n.ns.name+">)");this.bodyProperty=n};pt.prototype.setIdProperty=function(n,e){if(e&&this.idProperty)throw new Error("id property defined multiple times (<"+this.idProperty.ns.name+">, <"+n.ns.name+">)");this.idProperty=n};pt.prototype.assertNotTrait=function(n){if((n.extends||[]).length)throw new Error(`cannot create <${n.name}> extending <${n.extends}>`)};pt.prototype.assertNotDefined=function(n,e){var t=n.name,i=this.propertiesByName[t];if(i)throw new Error("property <"+t+"> already defined; override of <"+i.definedBy.ns.name+"#"+i.ns.name+"> by <"+n.definedBy.ns.name+"#"+n.ns.name+"> not allowed without redefines")};pt.prototype.hasProperty=function(n){return this.propertiesByName[n]};pt.prototype.addTrait=function(n,e){e&&this.assertNotTrait(n);var t=this.allTypesByName,i=this.allTypes,r=n.name;r in t||(B(n.properties,Ft(function(s){s=D({},s,{name:s.ns.localName,inherited:e}),Object.defineProperty(s,"definedBy",{value:n});var o=s.replaces,a=s.redefines;o||a?this.redefineProperty(s,o||a,o):(s.isBody&&this.setBodyProperty(s),s.isId&&this.setIdProperty(s),this.addProperty(s))},this)),i.push(n),t[r]=n)};function zn(n,e){this.packageMap={},this.typeMap={},this.packages=[],this.properties=e,B(n,Ft(this.registerPackage,this))}zn.prototype.getPackage=function(n){return this.packageMap[n]};zn.prototype.getPackages=function(){return this.packages};zn.prototype.registerPackage=function(n){n=D({},n);var e=this.packageMap;Yd(e,n,"prefix"),Yd(e,n,"uri"),B(n.types,Ft(function(t){this.registerType(t,n)},this)),e[n.uri]=e[n.prefix]=n,this.packages.push(n)};zn.prototype.registerType=function(n,e){n=D({},n,{superClass:(n.superClass||[]).slice(),extends:(n.extends||[]).slice(),properties:(n.properties||[]).slice(),meta:D(n.meta||{})});var t=Te(n.name,e.prefix),i=t.name,r={};B(n.properties,Ft(function(s){var o=Te(s.name,t.prefix),a=o.name;Ec(s.type)||(s.type=Te(s.type,o.prefix).name),D(s,{ns:o,name:a}),r[a]=s},this)),D(n,{ns:t,name:i,propertiesByName:r}),B(n.extends,Ft(function(s){var o=Te(s,t.prefix),a=this.typeMap[o.name];a.traits=a.traits||[],a.traits.push(i)},this)),this.definePackage(n,e),this.typeMap[i]=n};zn.prototype.mapTypes=function(n,e,t){var i=Ec(n.name)?{name:n.name}:this.typeMap[n.name],r=this;function s(l,c){var u=Te(l,Ec(l)?"":n.prefix);r.mapTypes(u,e,c)}function o(l){return s(l,!0)}function a(l){return s(l,!1)}if(!i)throw new Error("unknown type <"+n.name+">");B(i.superClass,t?o:a),e(i,!t),B(i.traits,o)};zn.prototype.getEffectiveDescriptor=function(n){var e=Te(n),t=new pt(e);this.mapTypes(e,function(r,s){t.addTrait(r,s)});var i=t.build();return this.definePackage(i,i.allTypes[i.allTypes.length-1].$pkg),i};zn.prototype.definePackage=function(n,e){this.properties.define(n,"$pkg",{value:e})};function Yd(n,e,t){var i=e[t];if(i in n)throw new Error("package with "+t+" <"+i+"> already defined")}function pi(n){this.model=n}pi.prototype.set=function(n,e,t){if(!tt(e)||!e.length)throw new TypeError("property name must be a non-empty string");var i=this.getProperty(n,e),r=i&&i.name;Nb(t)?i?delete n[r]:delete n.$attrs[Ac(e)]:i?r in n?n[r]=t:Jd(n,i,t):n.$attrs[Ac(e)]=t};pi.prototype.get=function(n,e){var t=this.getProperty(n,e);if(!t)return n.$attrs[Ac(e)];var i=t.name;return!n[i]&&t.isMany&&Jd(n,t,[]),n[i]};pi.prototype.define=function(n,e,t){if(!t.writable){var i=t.value;t=D({},t,{get:function(){return i}}),delete t.value}Object.defineProperty(n,e,t)};pi.prototype.defineDescriptor=function(n,e){this.define(n,"$descriptor",{value:e})};pi.prototype.defineModel=function(n,e){this.define(n,"$model",{value:e})};pi.prototype.getProperty=function(n,e){var t=this.model,i=t.getPropertyDescriptor(n,e);if(i)return i;if(e.includes(":"))return null;let r=t.config.strict;if(typeof r!="undefined"){let s=new TypeError(`unknown property <${e}> on <${n.$type}>`);if(r)throw s;typeof console!="undefined"&&console.warn(s)}return null};function Nb(n){return typeof n=="undefined"}function Jd(n,e,t){Object.defineProperty(n,e.name,{enumerable:!e.isReference,writable:!0,value:t,configurable:!0})}function Ac(n){return n.replace(/^:/,"")}function nt(n,e={}){this.properties=new pi(this),this.factory=new Kd(this,this.properties),this.registry=new zn(n,this.properties),this.typeCache={},this.config=e}nt.prototype.create=function(n,e){var t=this.getType(n);if(!t)throw new Error("unknown type <"+n+">");return new t(e)};nt.prototype.getType=function(n){var e=this.typeCache,t=tt(n)?n:n.ns.name,i=e[t];return i||(n=this.registry.getEffectiveDescriptor(t),i=e[t]=this.factory.createType(n)),i};nt.prototype.createAny=function(n,e,t){var i=Te(n),r={$type:n,$instanceOf:function(o){return o===this.$type},get:function(o){return this[o]},set:function(o,a){Hd(this,[o],a)}},s={name:n,isGeneric:!0,ns:{prefix:i.prefix,localName:i.localName,uri:e}};return this.properties.defineDescriptor(r,s),this.properties.defineModel(r,this),this.properties.define(r,"get",{enumerable:!1,writable:!0}),this.properties.define(r,"set",{enumerable:!1,writable:!0}),this.properties.define(r,"$parent",{enumerable:!1,writable:!0}),this.properties.define(r,"$instanceOf",{enumerable:!1,writable:!0}),B(t,function(o,a){dt(o)&&o.value!==void 0?r[o.name]=o.value:r[a]=o}),r};nt.prototype.getPackage=function(n){return this.registry.getPackage(n)};nt.prototype.getPackages=function(){return this.registry.getPackages()};nt.prototype.getElementDescriptor=function(n){return n.$descriptor};nt.prototype.hasType=function(n,e){e===void 0&&(e=n,n=this);var t=n.$model.getElementDescriptor(n);return e in t.allTypesByName};nt.prototype.getPropertyDescriptor=function(n,e){return this.getElementDescriptor(n).propertiesByName[e]};nt.prototype.getTypeDescriptor=function(n){return this.registry.typeMap[n]};var Zd=String.fromCharCode,qb=Object.prototype.hasOwnProperty,Fb=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/ig,_s={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};Object.keys(_s).forEach(function(n){_s[n.toUpperCase()]=_s[n]});function jb(n,e,t,i){return i?qb.call(_s,i)?_s[i]:"&"+i+";":Zd(e||parseInt(t,16))}function mi(n){return n.length>3&&n.indexOf("&")!==-1?n.replace(Fb,jb):n}var ep="non-whitespace outside of root node";function Ji(n){return new Error(n)}function tp(n){return"missing namespace for prefix <"+n+">"}function ma(n){return{get:n,enumerable:!0}}function Vb(n){var e={},t;for(t in n)e[t]=n[t];return e}function Mc(n){return n+"$uri"}function Qb(n){var e={},t,i;for(t in n)i=n[t],e[i]=i,e[Mc(i)]=t;return e}function np(){return{line:0,column:0}}function zb(n){throw n}function Rc(n){if(!this)return new Rc(n);var e=n&&n.proxy,t,i,r,s,o=zb,a,l,c,u,f=np,h=!1,d=!1,p=null,m=!1,y;function g(b){b instanceof Error||(b=Ji(b)),p=b,o(b,f)}function k(b){a&&(b instanceof Error||(b=Ji(b)),a(b,f))}this.on=function(b,C){if(typeof C!="function")throw Ji("required args ");switch(b){case"openTag":i=C;break;case"text":t=C;break;case"closeTag":r=C;break;case"error":o=C;break;case"warn":a=C;break;case"cdata":s=C;break;case"attention":u=C;break;case"question":c=C;break;case"comment":l=C;break;default:throw Ji("unsupported event: "+b)}return this},this.ns=function(b){if(typeof b=="undefined"&&(b={}),typeof b!="object")throw Ji("required args ");var C={},O;for(O in b)C[O]=b[O];return d=!0,y=C,this},this.parse=function(b){if(typeof b!="string")throw Ji("required args ");return p=null,x(b),f=np,m=!1,p},this.stop=function(){m=!0};function x(b){var C=d?[]:null,O=d?Qb(y):null,w,v=[],A=0,S=!1,M=!1,_=0,P=0,j,oe,ee,Y,Zt,ct,Ae,ut,qe,et="",Nt=0,ft;function Fn(){if(ft!==null)return ft;var jn,fi,en,hi=d&&O.xmlns,xn=d&&h?[]:null,de=Nt,Be=et,di=Be.length,jd,Vn,bn,tn,ne,Ki={},Vd={},qt,W,te;e:for(;de8)){for((W<65||W>122||W>90&&W<97)&&W!==95&&W!==58&&(k("illegal first char attribute name"),qt=!0),te=de+1;te96&&W<123||W>64&&W<91||W>47&&W<59||W===46||W===45||W===95)){if(W===32||W<14&&W>8){k("missing attribute value"),de=te;continue e}if(W===61)break;k("illegal attribute name char"),qt=!0}if(ne=Be.substring(de,te),ne==="xmlns:xmlns"&&(k("illegal declaration of xmlns"),qt=!0),W=Be.charCodeAt(te+1),W===34)te=Be.indexOf('"',de=te+2),te===-1&&(te=Be.indexOf("'",de),te!==-1&&(k("attribute value quote missmatch"),qt=!0));else if(W===39)te=Be.indexOf("'",de=te+2),te===-1&&(te=Be.indexOf('"',de),te!==-1&&(k("attribute value quote missmatch"),qt=!0));else for(k("missing attribute value quotes"),qt=!0,te=te+1;te8));te++);for(te===-1&&(k("missing closing quotes"),te=di,qt=!0),qt||(bn=Be.substring(de,te)),de=te;te+18));te++)de===te&&(k("illegal character after attribute end"),qt=!0);if(de=te+1,qt)continue e;if(ne in Vd){k("attribute <"+ne+"> already defined");continue}if(Vd[ne]=!0,!d){Ki[ne]=bn;continue}if(h){if(Vn=ne==="xmlns"?"xmlns":ne.charCodeAt(0)===120&&ne.substr(0,6)==="xmlns:"?ne.substr(6):null,Vn!==null){if(jn=mi(bn),fi=Mc(Vn),tn=y[jn],!tn){if(Vn==="xmlns"||fi in O&&O[fi]!==jn)do tn="ns"+A++;while(typeof O[tn]!="undefined");else tn=Vn;y[jn]=tn}O[Vn]!==tn&&(jd||(O=Vb(O),jd=!0),O[Vn]=tn,Vn==="xmlns"&&(O[Mc(tn)]=jn,hi=tn),O[fi]=jn),Ki[ne]=bn;continue}xn.push(ne,bn);continue}if(W=ne.indexOf(":"),W===-1){Ki[ne]=bn;continue}if(!(en=O[ne.substring(0,W)])){k(tp(ne.substring(0,W)));continue}ne=hi===en?ne.substr(W+1):en+ne.substr(W),Ki[ne]=bn}if(h)for(de=0,di=xn.length;de=hi&&(de=jn.exec(b),!(!de||(xn=de[0].length+de.index,xn>_)));)fi+=1,hi=xn;return _==-1?(en=xn,Be=b.substring(P)):P===0?Be=b.substring(P,_):(en=_-hi,Be=P==-1?b.substring(_):b.substring(_,P+1)),{data:Be,line:fi,column:en}}for(f=ua,e&&(qe=Object.create({},{name:ma(function(){return Ae}),originalName:ma(function(){return ut}),attrs:ma(Fn),ns:ma(function(){return O})}));P!==-1;){if(b.charCodeAt(P)===60?_=P:_=b.indexOf("<",P),_===-1){if(v.length)return g("unexpected end of file");if(P===0)return g("missing start tag");P",_),P===-1)return g("unclosed cdata");if(s&&(s(b.substring(_+9,P),f),m))return;P+=3;continue}if(ee===45&&b.charCodeAt(_+3)===45){if(P=b.indexOf("-->",_),P===-1)return g("unclosed comment");if(l&&(l(b.substring(_+4,P),mi,f),m))return;P+=3;continue}}if(Y===63){if(P=b.indexOf("?>",_),P===-1)return g("unclosed question");if(c&&(c(b.substring(_,P+2),f),m))return;P+=2;continue}for(j=_+1;;j++){if(Zt=b.charCodeAt(j),isNaN(Zt))return P=-1,g("unclosed tag");if(Zt===34)ee=b.indexOf('"',j+1),j=ee!==-1?ee:j;else if(Zt===39)ee=b.indexOf("'",j+1),j=ee!==-1?ee:j;else if(Zt===62){P=j;break}}if(Y===33){if(u&&(u(b.substring(_,P+1),mi,f),m))return;P+=1;continue}if(ft={},Y===47){if(S=!1,M=!0,!v.length)return g("missing open tag");if(j=Ae=v.pop(),ee=_+2+j.length,b.substring(_+2,ee)!==j)return g("closing tag mismatch");for(;ee8&&Y<14))return g("close tag")}else{if(b.charCodeAt(P-1)===47?(j=Ae=b.substring(_+1,P-1),S=!0,M=!0):(j=Ae=b.substring(_+1,P),S=!0,M=!1),!(Y>96&&Y<123||Y>64&&Y<91||Y===95||Y===58))return g("illegal first char nodeName");for(ee=1,oe=j.length;ee96&&Y<123||Y>64&&Y<91||Y>47&&Y<59||Y===45||Y===95||Y==46)){if(Y===32||Y<14&&Y>8){Ae=j.substring(0,ee),ft=null;break}return g("invalid nodeName")}M||v.push(Ae)}if(d){if(w=O,S&&(M||C.push(w),ft===null&&(h=j.indexOf("xmlns",ee)!==-1)&&(Nt=ee,et=j,Fn(),h=!1)),ut=Ae,Y=Ae.indexOf(":"),Y!==-1){if(ct=O[Ae.substring(0,Y)],!ct)return g("missing namespace on <"+ut+">");Ae=Ae.substr(Y+1)}else ct=O.xmlns;ct&&(Ae=ct+":"+Ae)}if(S&&(Nt=ee,et=j,i&&(e?i(qe,mi,M,f):i(Ae,Fn,mi,M,f),m)))return;if(M){if(r&&(r(e?qe:Ae,mi,S,f),m))return;d&&(S?O=w:O=C.pop())}P+=1}}}function ip(n){return n.xml&&n.xml.tagAlias==="lowerCase"}var Pc={xsi:"http://www.w3.org/2001/XMLSchema-instance",xml:"http://www.w3.org/XML/1998/namespace"},rp="property";function sp(n){return n.xml&&n.xml.serialize}function Wb(n){let e=sp(n);return e!==rp&&(e||null)}function Hb(n){return n.charAt(0).toUpperCase()+n.slice(1)}function op(n,e){return ip(e)?n.prefix+":"+Hb(n.localName):n.name}function Xb(n,e){var t=n.name,i=n.localName,r=e&&e.xml&&e.xml.typePrefix;return r&&i.indexOf(r)===0?n.prefix+":"+i.slice(r.length):t}function Ub(n,e,t){let i=Te(n,e.xmlns),r=`${e[i.prefix]||i.prefix}:${i.localName}`,s=Te(r);var o=t.getPackage(s.prefix);return Xb(s,o)}function Wn(n){return new Error(n)}function wn(n){return n.$descriptor}function Yb(n){D(this,n),this.elementsById={},this.references=[],this.warnings=[],this.addReference=function(e){this.references.push(e)},this.addElement=function(e){if(!e)throw Wn("expected element");var t=this.elementsById,i=wn(e),r=i.idProperty,s;if(r&&(s=e.get(r.name),s)){if(!/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i.test(s))throw new Error("illegal ID <"+s+">");if(t[s])throw Wn("duplicate ID <"+s+">");t[s]=e}},this.addWarning=function(e){this.warnings.push(e)}}function Ts(){}Ts.prototype.handleEnd=function(){};Ts.prototype.handleText=function(){};Ts.prototype.handleNode=function(){};function Dc(){}Dc.prototype=Object.create(Ts.prototype);Dc.prototype.handleNode=function(){return this};function er(){}er.prototype=Object.create(Ts.prototype);er.prototype.handleText=function(n){this.body=(this.body||"")+n};function Ms(n,e){this.property=n,this.context=e}Ms.prototype=Object.create(er.prototype);Ms.prototype.handleNode=function(n){if(this.element)throw Wn("expected no sub nodes");return this.element=this.createReference(n),this};Ms.prototype.handleEnd=function(){this.element.id=this.body};Ms.prototype.createReference=function(n){return{property:this.property.ns.name,id:""}};function Bc(n,e){this.element=e,this.propertyDesc=n}Bc.prototype=Object.create(er.prototype);Bc.prototype.handleEnd=function(){var n=this.body||"",e=this.element,t=this.propertyDesc;n=pa(t.type,n),t.isMany?e.get(t.name).push(n):e.set(t.name,n)};function ga(){}ga.prototype=Object.create(er.prototype);ga.prototype.handleNode=function(n){var e=this,t=this.element;return t?e=this.handleChild(n):(t=this.element=this.createElement(n),this.context.addElement(t)),e};function Fe(n,e,t){this.model=n,this.type=n.getType(e),this.context=t}Fe.prototype=Object.create(ga.prototype);Fe.prototype.addReference=function(n){this.context.addReference(n)};Fe.prototype.handleText=function(n){var e=this.element,t=wn(e),i=t.bodyProperty;if(!i)throw Wn("unexpected body text <"+n+">");er.prototype.handleText.call(this,n)};Fe.prototype.handleEnd=function(){var n=this.body,e=this.element,t=wn(e),i=t.bodyProperty;i&&n!==void 0&&(n=pa(i.type,n),e.set(i.name,n))};Fe.prototype.createElement=function(n){var e=n.attributes,t=this.type,i=wn(t),r=this.context,s=new t({}),o=this.model,a;return B(e,function(l,c){var u=i.propertiesByName[c],f;u&&u.isReference?u.isMany?(f=l.split(" "),B(f,function(h){r.addReference({element:s,property:u.ns.name,id:h})})):r.addReference({element:s,property:u.ns.name,id:l}):(u?l=pa(u.type,l):c==="xmlns"?c=":"+c:(a=Te(c,i.ns.prefix),o.getPackage(a.prefix)&&r.addWarning({message:"unknown attribute <"+c+">",element:s,property:c,value:l})),s.set(c,l))}),s};Fe.prototype.getPropertyForNode=function(n){var e=n.name,t=Te(e),i=this.type,r=this.model,s=wn(i),o=t.name,a=s.propertiesByName[o];if(a&&!a.isAttr){let c=Wb(a);if(c){let u=n.attributes[c];if(u){let f=Ub(u,n.ns,r),h=r.getType(f);return D({},a,{effectiveType:wn(h).name})}}return a}var l=r.getPackage(t.prefix);if(l){let c=op(t,l),u=r.getType(c);if(a=we(s.properties,function(f){return!f.isVirtual&&!f.isReference&&!f.isAttribute&&u.hasType(f.type)}),a)return D({},a,{effectiveType:wn(u).name})}else if(a=we(s.properties,function(c){return!c.isReference&&!c.isAttribute&&c.type==="Element"}),a)return a;throw Wn("unrecognized element <"+t.name+">")};Fe.prototype.toString=function(){return"ElementDescriptor["+wn(this.type).name+"]"};Fe.prototype.valueHandler=function(n,e){return new Bc(n,e)};Fe.prototype.referenceHandler=function(n){return new Ms(n,this.context)};Fe.prototype.handler=function(n){return n==="Element"?new Zi(this.model,n,this.context):new Fe(this.model,n,this.context)};Fe.prototype.handleChild=function(n){var e,t,i,r;if(e=this.getPropertyForNode(n),i=this.element,t=e.effectiveType||e.type,Tc(t))return this.valueHandler(e,i);e.isReference?r=this.referenceHandler(e).handleNode(n):r=this.handler(t).handleNode(n);var s=r.element;return s!==void 0&&(e.isMany?i.get(e.name).push(s):i.set(e.name,s),e.isReference?(D(s,{element:i}),this.context.addReference(s)):s.$parent=i),r};function Ic(n,e,t){Fe.call(this,n,e,t)}Ic.prototype=Object.create(Fe.prototype);Ic.prototype.createElement=function(n){var e=n.name,t=Te(e),i=this.model,r=this.type,s=i.getPackage(t.prefix),o=s&&op(t,s)||e;if(!r.hasType(o))throw Wn("unexpected element <"+n.originalName+">");return Fe.prototype.createElement.call(this,n)};function Zi(n,e,t){this.model=n,this.context=t}Zi.prototype=Object.create(ga.prototype);Zi.prototype.createElement=function(n){var e=n.name,t=Te(e),i=t.prefix,r=n.ns[i+"$uri"],s=n.attributes;return this.model.createAny(e,r,s)};Zi.prototype.handleChild=function(n){var e=new Zi(this.model,"Element",this.context).handleNode(n),t=this.element,i=e.element,r;return i!==void 0&&(r=t.$children=t.$children||[],r.push(i),i.$parent=t),e};Zi.prototype.handleEnd=function(){this.body&&(this.element.$body=this.body)};function ya(n){n instanceof nt&&(n={model:n}),D(this,{lax:!1},n)}ya.prototype.fromXML=function(n,e,t){var i=e.rootHandler;e instanceof Fe?(i=e,e={}):typeof e=="string"?(i=this.handler(e),e={}):typeof i=="string"&&(i=this.handler(i));var r=this.model,s=this.lax,o=new Yb(D({},e,{rootHandler:i})),a=new Rc({proxy:!0}),l=Kb();i.context=o,l.push(i);function c(C,O,w){var v=O(),A=v.line,S=v.column,M=v.data;M.charAt(0)==="<"&&M.indexOf(" ")!==-1&&(M=M.slice(0,M.indexOf(" "))+">");var _="unparsable content "+(M?M+" ":"")+`detected line: `+A+` column: `+S+` nested error: `+C.message;if(w)return o.addWarning({message:_,error:C}),!0;throw Wn(_)}function u(C,O){return c(C,O,!0)}function f(){var C=o.elementsById,O=o.references,w,v;for(w=0;v=O[w];w++){var A=v.element,S=C[v.id],M=wn(A).propertiesByName[v.property];if(S||o.addWarning({message:"unresolved reference <"+v.id+">",element:v.element,property:v.property,value:v.id}),M.isMany){var _=A.get(M.name),P=_.indexOf(v);P===-1&&(P=_.length),S?_[P]=S:_.splice(P,1)}else A.set(M.name,S)}}function h(){l.pop().handleEnd()}var d=/^<\?xml /i,p=/ encoding="([^"]+)"/i,m=/^utf-8$/i;function y(C){if(d.test(C)){var O=p.exec(C),w=O&&O[1];!w||m.test(w)||o.addWarning({message:"unsupported document encoding <"+w+">, falling back to UTF-8"})}}function g(C,O){var w=l.peek();try{l.push(w.handleNode(C))}catch(v){c(v,O,s)&&l.push(new Dc)}}function k(C,O){try{l.peek().handleText(C)}catch(w){u(w,O)}}function x(C,O){C.trim()&&k(C,O)}var b=r.getPackages().reduce(function(C,O){return C[O.uri]=O.prefix,C},Object.entries(Pc).reduce(function(C,[O,w]){return C[w]=O,C},r.config&&r.config.nsMap||{}));return a.ns(b).on("openTag",function(C,O,w,v){var A=C.attrs||{},S=Object.keys(A).reduce(function(_,P){var j=O(A[P]);return _[P]=j,_},{}),M={name:C.name,originalName:C.originalName,attributes:S,ns:C.ns};g(M,v)}).on("question",y).on("closeTag",h).on("cdata",k).on("text",function(C,O,w){x(O(C),w)}).on("error",c).on("warn",u),new Promise(function(C,O){var w;try{a.parse(n),f()}catch(_){w=_}var v=i.element;!w&&!v&&(w=Wn("failed to parse document as <"+i.type.$descriptor.name+">"));var A=o.warnings,S=o.references,M=o.elementsById;return w?(w.warnings=A,O(w)):C({rootElement:v,elementsById:M,references:S,warnings:A})})};ya.prototype.handler=function(n){return new Ic(this.model,n)};function Kb(){var n=[];return Object.defineProperty(n,"peek",{value:function(){return this[this.length-1]}}),n}var Gb=` `,Jb=/<|>|'|"|&|\n\r|\n/g,ap=/<|>|&/g;function nn(n){this.prefixMap={},this.uriMap={},this.used={},this.wellknown=[],this.custom=[],this.parent=n,this.defaultPrefixMap=n&&n.defaultPrefixMap||{}}nn.prototype.mapDefaultPrefixes=function(n){this.defaultPrefixMap=n};nn.prototype.defaultUriByPrefix=function(n){return this.defaultPrefixMap[n]};nn.prototype.byUri=function(n){return this.uriMap[n]||this.parent&&this.parent.byUri(n)};nn.prototype.add=function(n,e){this.uriMap[n.uri]=n,e?this.wellknown.push(n):this.custom.push(n),this.mapPrefix(n.prefix,n.uri)};nn.prototype.uriByPrefix=function(n){return this.prefixMap[n||"xmlns"]||this.parent&&this.parent.uriByPrefix(n)};nn.prototype.mapPrefix=function(n,e){this.prefixMap[n||"xmlns"]=e};nn.prototype.getNSKey=function(n){return n.prefix!==void 0?n.uri+"|"+n.prefix:n.uri};nn.prototype.logUsed=function(n){var e=n.uri,t=this.getNSKey(n);this.used[t]=this.byUri(e),this.parent&&this.parent.logUsed(n)};nn.prototype.getUsed=function(n){var e=[].concat(this.wellknown,this.custom);return e.filter(t=>{var i=this.getNSKey(t);return this.used[i]})};function Zb(n){return n.charAt(0).toLowerCase()+n.slice(1)}function e1(n,e){return ip(e)?Zb(n):n}function lp(n,e){n.super_=e,n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}})}function cp(n){return tt(n)?n:(n.prefix?n.prefix+":":"")+n.localName}function t1(n){return n.getUsed().filter(function(e){return e.prefix!=="xml"}).map(function(e){var t="xmlns"+(e.prefix?":"+e.prefix:"");return{name:t,value:e.uri}})}function n1(n,e){return e.isGeneric?D({localName:e.ns.localName},n):D({localName:e1(e.ns.localName,e.$pkg)},n)}function i1(n,e){return D({localName:e.ns.localName},n)}function r1(n){var e=n.$descriptor;return Qn(e.properties,function(t){var i=t.name;if(t.isVirtual||!Ss(n,i))return!1;var r=n[i];return r===t.default||r===null?!1:t.isMany?r.length:!0})}var s1={"\n":"#10","\n\r":"#10",'"':"#34","'":"#39","<":"#60",">":"#62","&":"#38"},o1={"<":"lt",">":"gt","&":"amp"};function up(n,e,t){return n=tt(n)?n:""+n,n.replace(e,function(i){return"&"+t[i]+";"})}function a1(n){return up(n,Jb,s1)}function l1(n){return up(n,ap,o1)}function c1(n){return Qn(n,function(e){return e.isAttr})}function u1(n){return Qn(n,function(e){return!e.isAttr})}function Lc(n){this.tagName=n}Lc.prototype.build=function(n){return this.element=n,this};Lc.prototype.serializeTo=function(n){n.appendIndent().append("<"+this.tagName+">"+this.element.id+"").appendNewLine()};function gi(){}gi.prototype.serializeValue=gi.prototype.serializeTo=function(n){n.append(this.escape?l1(this.value):this.value)};gi.prototype.build=function(n,e){return this.value=e,n.type==="String"&&e.search(ap)!==-1&&(this.escape=!0),this};function $c(n){this.tagName=n}lp($c,gi);$c.prototype.serializeTo=function(n){n.appendIndent().append("<"+this.tagName+">"),this.serializeValue(n),n.append("").appendNewLine()};function ae(n,e){this.body=[],this.attrs=[],this.parent=n,this.propertyDescriptor=e}ae.prototype.build=function(n){this.element=n;var e=n.$descriptor,t=this.propertyDescriptor,i,r,s=e.isGeneric;return s?i=this.parseGenericNsAttributes(n):i=this.parseNsAttributes(n),t?this.ns=this.nsPropertyTagName(t):this.ns=this.nsTagName(e),this.tagName=this.addTagName(this.ns),s?this.parseGenericContainments(n):(r=r1(n),this.parseAttributes(c1(r)),this.parseContainments(u1(r))),this.parseGenericAttributes(n,i),this};ae.prototype.nsTagName=function(n){var e=this.logNamespaceUsed(n.ns);return n1(e,n)};ae.prototype.nsPropertyTagName=function(n){var e=this.logNamespaceUsed(n.ns);return i1(e,n)};ae.prototype.isLocalNs=function(n){return n.uri===this.ns.uri};ae.prototype.nsAttributeName=function(n){var e;if(tt(n)?e=Te(n):e=n.ns,n.inherited)return{localName:e.localName};var t=this.logNamespaceUsed(e);return this.getNamespaces().logUsed(t),this.isLocalNs(t)?{localName:e.localName}:D({localName:e.localName},t)};ae.prototype.parseGenericNsAttributes=function(n){return Object.entries(n).filter(([e,t])=>!e.startsWith("$")&&this.parseNsAttribute(n,e,t)).map(([e,t])=>({name:e,value:t}))};ae.prototype.parseGenericContainments=function(n){var e=n.$body;e&&this.body.push(new gi().build({type:"String"},e));var t=n.$children;t&&B(t,i=>{this.body.push(new ae(this).build(i))})};ae.prototype.parseNsAttribute=function(n,e,t){var i=n.$model,r=Te(e),s;if(r.prefix==="xmlns"&&(s={prefix:r.localName,uri:t}),!r.prefix&&r.localName==="xmlns"&&(s={uri:t}),!s)return{name:e,value:t};if(i&&i.getPackage(t))this.logNamespace(s,!0,!0);else{var o=this.logNamespaceUsed(s,!0);this.getNamespaces().logUsed(o)}};ae.prototype.parseNsAttributes=function(n){var e=this,t=n.$attrs,i=[];return B(t,function(r,s){var o=e.parseNsAttribute(n,s,r);o&&i.push(o)}),i};ae.prototype.parseGenericAttributes=function(n,e){var t=this;B(e,function(i){try{t.addAttribute(t.nsAttributeName(i.name),i.value)}catch(r){typeof console!="undefined"&&console.warn(`missing namespace information for <${i.name}=${i.value}> on`,n,r)}})};ae.prototype.parseContainments=function(n){var e=this,t=this.body,i=this.element;B(n,function(r){var s=i.get(r.name),o=r.isReference,a=r.isMany;if(a||(s=[s]),r.isBody)t.push(new gi().build(r,s[0]));else if(Tc(r.type))B(s,function(c){t.push(new $c(e.addTagName(e.nsPropertyTagName(r))).build(r,c))});else if(o)B(s,function(c){t.push(new Lc(e.addTagName(e.nsPropertyTagName(r))).build(c))});else{var l=sp(r);B(s,function(c){var u;l?l===rp?u=new ae(e,r):u=new va(e,r,l):u=new ae(e),t.push(u.build(c))})}})};ae.prototype.getNamespaces=function(n){var e=this.namespaces,t=this.parent,i;return e||(i=t&&t.getNamespaces(),n||!i?this.namespaces=e=new nn(i):e=i),e};ae.prototype.logNamespace=function(n,e,t){var i=this.getNamespaces(t),r=n.uri,s=n.prefix,o=i.byUri(r);return(!o||t)&&i.add(n,e),i.mapPrefix(s,r),n};ae.prototype.logNamespaceUsed=function(n,e){var t=this.getNamespaces(e),i=n.prefix,r=n.uri,s,o,a;if(!i&&!r)return{localName:n.localName};if(a=t.defaultUriByPrefix(i),r=r||a||t.uriByPrefix(i),!r)throw new Error("no namespace uri given for prefix <"+i+">");if(n=t.byUri(r),!n&&!i&&(n=this.logNamespace({uri:r},a===r,!0)),!n){for(s=i,o=1;t.uriByPrefix(s);)s=i+"_"+o++;n=this.logNamespace({prefix:s,uri:r},a===r)}return i&&t.mapPrefix(i,r),n};ae.prototype.parseAttributes=function(n){var e=this,t=this.element;B(n,function(i){var r=t.get(i.name);if(i.isReference)if(!i.isMany)r=r.id;else{var s=[];B(r,function(o){s.push(o.id)}),r=s.join(" ")}e.addAttribute(e.nsAttributeName(i),r)})};ae.prototype.addTagName=function(n){var e=this.logNamespaceUsed(n);return this.getNamespaces().logUsed(e),cp(n)};ae.prototype.addAttribute=function(n,e){var t=this.attrs;tt(e)&&(e=a1(e));var i=Qd(t,function(s){return s.name.localName===n.localName&&s.name.uri===n.uri&&s.name.prefix===n.prefix}),r={name:n,value:e};i!==-1?t.splice(i,1,r):t.push(r)};ae.prototype.serializeAttributes=function(n){var e=this.attrs,t=this.namespaces;t&&(e=t1(t).concat(e)),B(e,function(i){n.append(" ").append(cp(i.name)).append('="').append(i.value).append('"')})};ae.prototype.serializeTo=function(n){var e=this.body[0],t=e&&e.constructor!==gi;n.appendIndent().append("<"+this.tagName),this.serializeAttributes(n),n.append(e?">":" />"),e&&(t&&n.appendNewLine().indent(),B(this.body,function(i){i.serializeTo(n)}),t&&n.unindent().appendIndent(),n.append("")),n.appendNewLine()};function va(n,e,t){ae.call(this,n,e),this.serialization=t}lp(va,ae);va.prototype.parseNsAttributes=function(n){var e=ae.prototype.parseNsAttributes.call(this,n).filter(o=>o.name!==this.serialization),t=n.$descriptor;if(t.name===this.propertyDescriptor.type)return e;var i=this.typeNs=this.nsTagName(t);this.getNamespaces().logUsed(this.typeNs);var r=n.$model.getPackage(i.uri),s=r.xml&&r.xml.typePrefix||"";return this.addAttribute(this.nsAttributeName(this.serialization),(i.prefix?i.prefix+":":"")+s+t.ns.localName),e};va.prototype.isLocalNs=function(n){return n.uri===(this.typeNs||this.ns).uri};function f1(){this.value="",this.write=function(n){this.value+=n}}function h1(n,e){var t=[""];this.append=function(i){return n.write(i),this},this.appendNewLine=function(){return e&&n.write(` `),this},this.appendIndent=function(){return e&&n.write(t.join(" ")),this},this.indent=function(){return t.push(""),this},this.unindent=function(){return t.pop(),this}}function fp(n){n=D({format:!1,preamble:!0},n||{});function e(t,i){var r=i||new f1,s=new h1(r,n.format);n.preamble&&s.append(Gb);var o=new ae,a=t.$model;if(o.getNamespaces().mapDefaultPrefixes(d1(a)),o.build(t).serializeTo(s),!i)return r.value}return{toXML:e}}function d1(n){let e=n.config&&n.config.nsMap||{},t={};for(let i in Pc)t[i]=Pc[i];for(let i in e){let r=e[i];t[r]=i}for(let i of n.getPackages())t[i.prefix]=i.uri;return t}function xa(n,e){nt.call(this,n,e)}xa.prototype=Object.create(nt.prototype);xa.prototype.fromXML=function(n,e,t){tt(e)||(t=e,e="dmn:Definitions");var i=new ya(D({model:this,lax:!0},t)),r=i.handler(e);return i.fromXML(n,r)};xa.prototype.toXML=function(n,e){var t=new fp(e);return new Promise(function(i,r){try{var s=t.toXML(n);return i({xml:s})}catch(o){return r(o)}})};var p1="DC",m1="dc",g1="http://www.omg.org/spec/DMN/20180521/DC/",y1=[{name:"Dimension",properties:[{name:"width",isAttr:!0,type:"Real"},{name:"height",isAttr:!0,type:"Real"}]},{name:"Bounds",properties:[{name:"height",isAttr:!0,type:"Real"},{name:"width",isAttr:!0,type:"Real"},{name:"x",isAttr:!0,type:"Real"},{name:"y",isAttr:!0,type:"Real"}]},{name:"Point",properties:[{name:"x",isAttr:!0,type:"Real"},{name:"y",isAttr:!0,type:"Real"}]},{name:"Color",properties:[{name:"red",type:"UML_Standard_Profile.mdzip:eee_1045467100323_917313_65"},{name:"green",type:"UML_Standard_Profile.mdzip:eee_1045467100323_917313_65"},{name:"blue",type:"UML_Standard_Profile.mdzip:eee_1045467100323_917313_65"}]}],v1=[],x1=[{name:"AlignmentKind",literalValues:[{name:"start"},{name:"center"},{name:"end"}]}],b1={name:p1,prefix:m1,uri:g1,types:y1,associations:v1,enumerations:x1},w1="DI",O1="di",k1="http://www.omg.org/spec/DMN/20180521/DI/",C1=[{name:"DiagramElement",isAbstract:!0,properties:[{name:"extension",type:"Extension"},{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"style",isReference:!0,type:"Style",xml:{serialize:"property"}},{name:"sharedStyle",isReference:!0,isVirtual:!0,type:"Style"}]},{name:"Diagram",superClass:["DiagramElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"documentation",isAttr:!0,type:"String"},{name:"resolution",isAttr:!0,type:"Real"}]},{name:"Shape",isAbstract:!0,properties:[{name:"bounds",type:"dc:Bounds"}],superClass:["DiagramElement"]},{name:"Edge",isAbstract:!0,properties:[{name:"waypoint",type:"dc:Point",isMany:!0,xml:{serialize:"property"}}],superClass:["DiagramElement"]},{name:"Style",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"}]},{name:"Extension",properties:[{name:"values",isMany:!0,type:"Element"}]}],S1=[],E1=[],A1={tagAlias:"lowerCase"},_1={name:w1,prefix:O1,uri:k1,types:C1,associations:S1,enumerations:E1,xml:A1},T1="DMN",M1="dmn",R1="https://www.omg.org/spec/DMN/20191111/MODEL/",P1=[{name:"AuthorityRequirement",superClass:["DMNElement"],properties:[{name:"requiredAuthority",type:"DMNElementReference",xml:{serialize:"property"}},{name:"requiredDecision",type:"DMNElementReference",xml:{serialize:"property"}},{name:"requiredInput",type:"DMNElementReference",xml:{serialize:"property"}}]},{name:"ItemDefinition",superClass:["NamedElement"],properties:[{name:"typeRef",type:"String"},{name:"allowedValues",type:"UnaryTests",xml:{serialize:"property"}},{name:"typeLanguage",type:"String",isAttr:!0},{name:"itemComponent",type:"ItemDefinition",isMany:!0,xml:{serialize:"property"}},{name:"functionItem",type:"FunctionItem"},{name:"isCollection",isAttr:!0,type:"Boolean"}]},{name:"Definitions",superClass:["NamedElement"],properties:[{name:"import",type:"Import",isMany:!0},{name:"itemDefinition",type:"ItemDefinition",isMany:!0},{name:"drgElement",type:"DRGElement",isMany:!0},{name:"artifact",type:"Artifact",isMany:!0},{name:"elementCollection",type:"ElementCollection",isMany:!0},{name:"businessContextElement",type:"BusinessContextElement",isMany:!0},{name:"namespace",type:"String",isAttr:!0},{name:"expressionLanguage",type:"String",isAttr:!0},{name:"typeLanguage",type:"String",isAttr:!0},{name:"exporter",isAttr:!0,type:"String"},{name:"exporterVersion",isAttr:!0,type:"String"},{name:"dmnDI",type:"dmndi:DMNDI"}]},{name:"KnowledgeSource",superClass:["DRGElement"],properties:[{name:"authorityRequirement",type:"AuthorityRequirement",isMany:!0},{name:"type",type:"String"},{name:"owner",type:"DMNElementReference",xml:{serialize:"property"}},{name:"locationURI",type:"String",isAttr:!0}]},{name:"DecisionRule",superClass:["DMNElement"],properties:[{name:"inputEntry",type:"UnaryTests",isMany:!0,xml:{serialize:"property"}},{name:"outputEntry",type:"LiteralExpression",isMany:!0,xml:{serialize:"property"}},{name:"annotationEntry",type:"RuleAnnotation",isMany:!0,xml:{serialize:"property"}}]},{name:"Expression",isAbstract:!0,superClass:["DMNElement"],properties:[{name:"typeRef",isAttr:!0,type:"String"}]},{name:"InformationItem",superClass:["NamedElement"],properties:[{name:"typeRef",isAttr:!0,type:"String"}]},{name:"Decision",superClass:["DRGElement"],properties:[{name:"question",type:"String",xml:{serialize:"property"}},{name:"allowedAnswers",type:"String",xml:{serialize:"property"}},{name:"variable",type:"InformationItem",xml:{serialize:"property"}},{name:"informationRequirement",type:"InformationRequirement",isMany:!0},{name:"knowledgeRequirement",type:"KnowledgeRequirement",isMany:!0},{name:"authorityRequirement",type:"AuthorityRequirement",isMany:!0},{name:"supportedObjective",isMany:!0,type:"DMNElementReference",xml:{serialize:"property"}},{name:"impactedPerformanceIndicator",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"decisionMaker",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"decisionOwner",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"usingProcess",isMany:!0,type:"DMNElementReference",xml:{serialize:"property"}},{name:"usingTask",isMany:!0,type:"DMNElementReference",xml:{serialize:"property"}},{name:"decisionLogic",type:"Expression"}]},{name:"Invocation",superClass:["Expression"],properties:[{name:"calledFunction",type:"Expression"},{name:"binding",type:"Binding",isMany:!0}]},{name:"OrganisationalUnit",superClass:["BusinessContextElement"],properties:[{name:"decisionMade",type:"Decision",isReference:!0,isMany:!0},{name:"decisionOwned",type:"Decision",isReference:!0,isMany:!0}]},{name:"Import",superClass:["NamedElement"],properties:[{name:"importType",type:"String",isAttr:!0},{name:"locationURI",type:"String",isAttr:!0},{name:"namespace",type:"String",isAttr:!0}]},{name:"InformationRequirement",superClass:["DMNElement"],properties:[{name:"requiredDecision",type:"DMNElementReference",xml:{serialize:"property"}},{name:"requiredInput",type:"DMNElementReference",xml:{serialize:"property"}}]},{name:"ElementCollection",superClass:["NamedElement"],properties:[{name:"drgElement",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}}]},{name:"DRGElement",isAbstract:!0,superClass:["NamedElement"],properties:[]},{name:"InputData",superClass:["DRGElement"],properties:[{name:"variable",type:"InformationItem",xml:{serialize:"property"}}]},{name:"DMNElement",isAbstract:!0,properties:[{name:"description",type:"String"},{name:"extensionElements",type:"ExtensionElements"},{name:"id",type:"String",isAttr:!0,isId:!0},{name:"extensionAttribute",type:"ExtensionAttribute",isMany:!0},{name:"label",isAttr:!0,type:"String"}]},{name:"InputClause",superClass:["DMNElement"],properties:[{name:"inputExpression",type:"LiteralExpression",xml:{serialize:"property"}},{name:"inputValues",type:"UnaryTests",xml:{serialize:"property"}}]},{name:"DecisionTable",superClass:["Expression"],properties:[{name:"input",type:"InputClause",isMany:!0,xml:{serialize:"property"}},{name:"output",type:"OutputClause",isMany:!0,xml:{serialize:"property"}},{name:"annotation",type:"RuleAnnotationClause",isMany:!0,xml:{serialize:"property"}},{name:"rule",type:"DecisionRule",isMany:!0,xml:{serialize:"property"}},{name:"hitPolicy",type:"HitPolicy",isAttr:!0,default:"UNIQUE"},{name:"aggregation",type:"BuiltinAggregator",isAttr:!0},{name:"preferredOrientation",type:"DecisionTableOrientation",isAttr:!0},{name:"outputLabel",isAttr:!0,type:"String"}]},{name:"LiteralExpression",superClass:["Expression"],properties:[{name:"expressionLanguage",type:"String",isAttr:!0},{name:"text",type:"String"},{name:"importedValues",type:"ImportedValues"}]},{name:"Binding",properties:[{name:"parameter",type:"InformationItem",xml:{serialize:"property"}},{name:"bindingFormula",type:"Expression"}]},{name:"KnowledgeRequirement",superClass:["DMNElement"],properties:[{name:"requiredKnowledge",type:"DMNElementReference",xml:{serialize:"property"}}]},{name:"BusinessKnowledgeModel",superClass:["Invocable"],properties:[{name:"encapsulatedLogic",type:"FunctionDefinition",xml:{serialize:"property"}},{name:"knowledgeRequirement",type:"KnowledgeRequirement",isMany:!0},{name:"authorityRequirement",type:"AuthorityRequirement",isMany:!0}]},{name:"BusinessContextElement",isAbstract:!0,superClass:["NamedElement"],properties:[{name:"URI",type:"String",isAttr:!0}]},{name:"PerformanceIndicator",superClass:["BusinessContextElement"],properties:[{name:"impactingDecision",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}}]},{name:"FunctionDefinition",superClass:["Expression"],properties:[{name:"formalParameter",type:"InformationItem",isMany:!0,xml:{serialize:"property"}},{name:"body",type:"Expression"},{name:"kind",type:"FunctionKind",isAttr:!0}]},{name:"Context",superClass:["Expression"],properties:[{name:"contextEntry",type:"ContextEntry",isMany:!0}]},{name:"ContextEntry",superClass:["DMNElement"],properties:[{name:"variable",type:"InformationItem",xml:{serialize:"property"}},{name:"value",type:"Expression"}]},{name:"List",superClass:["Expression"],properties:[{name:"elements",isMany:!0,type:"Expression"}]},{name:"Relation",superClass:["Expression"],properties:[{name:"column",type:"InformationItem",isMany:!0,xml:{serialize:"property"}},{name:"row",type:"List",isMany:!0,xml:{serialize:"property"}}]},{name:"OutputClause",superClass:["DMNElement"],properties:[{name:"outputValues",type:"UnaryTests",xml:{serialize:"property"}},{name:"defaultOutputEntry",type:"LiteralExpression",xml:{serialize:"property"}},{name:"name",isAttr:!0,type:"String"},{name:"typeRef",isAttr:!0,type:"String"}]},{name:"UnaryTests",superClass:["Expression"],properties:[{name:"text",type:"String"},{name:"expressionLanguage",type:"String",isAttr:!0}]},{name:"NamedElement",isAbstract:!0,superClass:["DMNElement"],properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"ImportedValues",superClass:["Import"],properties:[{name:"importedElement",type:"String"},{name:"expressionLanguage",type:"String",isAttr:!0}]},{name:"DecisionService",superClass:["Invocable"],properties:[{name:"outputDecision",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"encapsulatedDecision",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"inputDecision",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"inputData",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}}]},{name:"ExtensionElements",properties:[{name:"values",type:"Element",isMany:!0}]},{name:"ExtensionAttribute",properties:[{name:"value",type:"Element"},{name:"valueRef",type:"Element",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Element",isAbstract:!0,properties:[{name:"extensionAttribute",type:"ExtensionAttribute",isAttr:!0,isReference:!0},{name:"elements",type:"ExtensionElements",isAttr:!0,isReference:!0}]},{name:"Artifact",isAbstract:!0,superClass:["DMNElement"],properties:[]},{name:"Association",superClass:["Artifact"],properties:[{name:"sourceRef",type:"DMNElementReference",xml:{serialize:"property"}},{name:"targetRef",type:"DMNElementReference",xml:{serialize:"property"}},{name:"associationDirection",type:"AssociationDirection",isAttr:!0}]},{name:"TextAnnotation",superClass:["Artifact"],properties:[{name:"text",type:"String"},{name:"textFormat",isAttr:!0,type:"String",default:"text/plain"}]},{name:"RuleAnnotationClause",properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"RuleAnnotation",properties:[{name:"text",type:"String"}]},{name:"Invocable",isAbstract:!0,superClass:["DRGElement"],properties:[{name:"variable",type:"InformationItem",xml:{serialize:"property"}}]},{name:"Group",superClass:["Artifact"],properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"FunctionItem",superClass:["DMNElement"],properties:[{name:"parameters",isMany:!0,type:"InformationItem",xml:{serialize:"property"}},{name:"outputTypeRef",isAttr:!0,type:"String"}]},{name:"DMNElementReference",properties:[{isAttr:!0,name:"href",type:"String"}]}],D1=[{name:"HitPolicy",literalValues:[{name:"UNIQUE"},{name:"FIRST"},{name:"PRIORITY"},{name:"ANY"},{name:"COLLECT"},{name:"RULE ORDER"},{name:"OUTPUT ORDER"}]},{name:"BuiltinAggregator",literalValues:[{name:"SUM"},{name:"COUNT"},{name:"MIN"},{name:"MAX"}]},{name:"DecisionTableOrientation",literalValues:[{name:"Rule-as-Row"},{name:"Rule-as-Column"},{name:"CrossTable"}]},{name:"AssociationDirection",literalValues:[{name:"None"},{name:"One"},{name:"Both"}]},{name:"FunctionKind",literalValues:[{name:"FEEL"},{name:"Java"},{name:"PMML"}]}],B1=[],I1={tagAlias:"lowerCase"},L1={name:T1,prefix:M1,uri:R1,types:P1,enumerations:D1,associations:B1,xml:I1},$1="DMNDI",N1="dmndi",q1="https://www.omg.org/spec/DMN/20191111/DMNDI/",F1=[{name:"DMNDI",properties:[{name:"diagrams",type:"DMNDiagram",isMany:!0},{name:"styles",type:"DMNStyle",isMany:!0}]},{name:"DMNStyle",superClass:["di:Style"],properties:[{name:"fillColor",type:"dc:Color",isAttr:!0},{name:"strokeColor",type:"dc:Color",isAttr:!0},{name:"fontColor",type:"dc:Color",isAttr:!0},{name:"fontSize",isAttr:!0,type:"Real"},{name:"fontFamily",isAttr:!0,type:"String"},{name:"fontItalic",isAttr:!0,type:"Boolean"},{name:"fontBold",isAttr:!0,type:"Boolean"},{name:"fontUnderline",isAttr:!0,type:"Boolean"},{name:"fontStrikeThrough",isAttr:!0,type:"Boolean"},{name:"labelHorizontalAlignment",type:"dc:AlignmentKind",isAttr:!0},{name:"labelVerticalAlignment",type:"dc:AlignmentKind",isAttr:!0}]},{name:"DMNDiagram",superClass:["di:Diagram"],properties:[{name:"dmnElementRef",type:"dmn:DMNElement",isAttr:!0,isReference:!0},{name:"size",type:"Size"},{name:"localStyle",type:"DMNStyle",isVirtual:!0},{name:"sharedStyle",type:"DMNStyle",isVirtual:!0,isReference:!0,redefines:"di:DiagramElement#sharedStyle"},{name:"diagramElements",type:"DMNDiagramElement",isMany:!0}]},{name:"DMNDiagramElement",isAbstract:!0,superClass:["di:DiagramElement"],properties:[{name:"dmnElementRef",type:"dmn:DMNElement",isAttr:!0,isReference:!0},{name:"sharedStyle",type:"DMNStyle",isVirtual:!0,isReference:!0,redefines:"di:DiagramElement#sharedStyle"},{name:"localStyle",type:"DMNStyle",isVirtual:!0},{name:"label",type:"DMNLabel"}]},{name:"DMNLabel",superClass:["di:Shape"],properties:[{name:"text",type:"Text"}]},{name:"DMNShape",superClass:["di:Shape","DMNDiagramElement"],properties:[{name:"isListedInputData",isAttr:!0,type:"Boolean"},{name:"decisionServiceDividerLine",type:"DMNDecisionServiceDividerLine"},{name:"isCollapsed",isAttr:!0,type:"Boolean"}]},{name:"DMNEdge",superClass:["di:Edge","DMNDiagramElement"],properties:[{name:"sourceElement",type:"DMNDiagramElement",isAttr:!0,isReference:!0},{name:"targetElement",type:"DMNDiagramElement",isAttr:!0,isReference:!0}]},{name:"DMNDecisionServiceDividerLine",superClass:["di:Edge"]},{name:"Text",properties:[{name:"text",isBody:!0,type:"String"}]},{name:"Size",superClass:["dc:Dimension"]}],j1=[],V1=[],Q1={name:$1,prefix:N1,uri:q1,types:F1,associations:j1,enumerations:V1},z1="bpmn.io DI for DMN",W1="http://bpmn.io/schema/dmn/biodi/2.0",H1="biodi",X1={tagAlias:"lowerCase"},U1=[{name:"DecisionTable",isAbstract:!0,extends:["dmn:DecisionTable"],properties:[{name:"annotationsWidth",isAttr:!0,type:"Integer"}]},{name:"OutputClause",isAbstract:!0,extends:["dmn:OutputClause"],properties:[{name:"width",isAttr:!0,type:"Integer"}]},{name:"InputClause",isAbstract:!0,extends:["dmn:InputClause"],properties:[{name:"width",isAttr:!0,type:"Integer"}]}],Y1={name:z1,uri:W1,prefix:H1,xml:X1,types:U1},K1={dc:b1,di:_1,dmn:L1,dmndi:Q1,biodi:Y1};function hp(n,e){var t=D({},K1,n);return new xa(t,e)}var Oe={legend:[1,"
","
"],tr:[2,"","
"],col:[2,"","
"],_default:[0,"",""]};Oe.td=Oe.th=[3,"","
"];Oe.option=Oe.optgroup=[1,'"];Oe.thead=Oe.tbody=Oe.colgroup=Oe.caption=Oe.tfoot=[1,"","
"];Oe.polyline=Oe.ellipse=Oe.polygon=Oe.circle=Oe.text=Oe.line=Oe.path=Oe.rect=Oe.g=[1,'',""];function le(n,e=globalThis.document){var c;if(typeof n!="string")throw new TypeError("String expected");let t=/^$/s.exec(n);if(t)return e.createComment(t[1]);let i=(c=/<([\w:]+)/.exec(n))==null?void 0:c[1];if(!i)return e.createTextNode(n);if(n=n.trim(),i==="body"){let u=e.createElement("html");u.innerHTML=n;let{lastChild:f}=u;return f.remove(),f}let[r,s,o]=Object.hasOwn(Oe,i)?Oe[i]:Oe._default,a=e.createElement("div");for(a.innerHTML=s+n+o;r--;)a=a.lastChild;if(a.firstChild===a.lastChild){let{firstChild:u}=a;return u.remove(),u}let l=e.createDocumentFragment();return l.append(...a.childNodes),l}function G1(n,e){return e.forEach(function(t){t&&typeof t!="string"&&!Array.isArray(t)&&Object.keys(t).forEach(function(i){if(i!=="default"&&!(i in n)){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}})}),Object.freeze(n)}function yi(n,...e){let t=n.style;return B(e,function(i){i&&B(i,function(r,s){t[s]=r})}),n}function tr(n,e,t){return arguments.length==2?n.getAttribute(e):t===null?n.removeAttribute(e):(n.setAttribute(e,t),n)}var J1=Object.prototype.toString;function vi(n){return new Hn(n)}function Hn(n){if(!n||!n.nodeType)throw new Error("A DOM element reference is required");this.el=n,this.list=n.classList}Hn.prototype.add=function(n){return this.list.add(n),this};Hn.prototype.remove=function(n){return J1.call(n)=="[object RegExp]"?this.removeMatching(n):(this.list.remove(n),this)};Hn.prototype.removeMatching=function(n){let e=this.array();for(let t=0;t=1&&Ie(arguments[e-1])){var t=arguments[e-1];console.warn(new Error("Passing callbacks to "+sw(n.name)+" is deprecated and will be removed in a future major release. Please switch to promises: https://bpmn.io/l/moving-to-promises.html"));var i=Array.prototype.slice.call(arguments,0,-1);n.apply(this,i).then(function(r){var s=Object.keys(r)[0];return t(null,r[s])},function(r){return t(r,r.warnings)})}else return n.apply(this,arguments)}}function sw(n){return n.replace("bound ","")}var ow={width:"100%",height:"100%",position:"relative"},Rs=class{constructor(e={}){L(this,"_viewsChanged",()=>{this._emit("views.changed",{views:this._views,activeView:this._activeView})});this._eventBus=new ye,this._viewsChanged=Gi(this._viewsChanged,0),this._views=[],this._viewers={},this.open=nr(this.open.bind(this)),this.importXML=nr(this.importXML.bind(this)),this.saveXML=nr(this.saveXML.bind(this)),this._init(e)}importXML(e,t){var i=this;return t=t||{open:!0},new Promise(function(s,o){var a=i._activeView;i._clear().then(()=>{e=i._emit("import.parse.start",{xml:e})||e;var l;i._moddle.fromXML(e,"dmn:Definitions").then(c=>{var u=c.rootElement,f=c.references,h=c.elementsById;if(l=c.warnings,u=i._emit("import.parse.complete",r({error:null,definitions:u,elementsById:h,references:f,warnings:l}))||u,i._setDefinitions(u),!t.open){i._emit("import.done",{error:null,warnings:l}),s({warnings:l});return}var d=i._getInitialView(i._views,a);if(!d){var p=new Error("no displayable contents");return i._emit("import.done",{error:p,warnings:l}),p.warnings=l,o(p)}i.open(d).then(m=>({warnings:m.warnings})).catch(m=>({error:m,warnings:m.warnings})).then(m=>{var y=[].concat(l,m.warnings);i._emit("import.done",{error:m.error,warnings:y}),m.error?(m.error.warnings=y,o(m.error)):s({warnings:y})})}).catch(c=>(l=c.warnings,c=aw(c,e)||lw(c)||c,i._emit("import.parse.complete",r({error:c,warnings:l})),i._emit("import.done",{error:c,warnings:l}),c.warnings=l,o(c)))}).catch(l=>(i._emit("import.done",{error:l,warnings:[]}),l.warnings=[],o(l)))});function r(s){var o=i._eventBus.createEvent(s);return Object.defineProperty(o,"context",{enumerable:!0,get:function(){return console.warn(new Error("import.parse.complete is deprecated and will be removed in future library versions")),{warnings:s.warnings,references:s.references,elementsById:s.elementsById}}}),o}}getDefinitions(){return this._definitions}getActiveView(){return this._activeView}getActiveViewer(){var e=this.getActiveView();return e&&this._getViewer(e)}getView(e){return this._views.filter(function(t){return t.element===e})[0]}getViews(){return this._views}saveXML(e){var t=this;e=e||{};var i=this._definitions;return new Promise(function(r,s){if(!i){s(new Error("no definitions loaded"));return}i=t._emit("saveXML.start",{definitions:i})||i,t._moddle.toXML(i,e).then(function(o){var a=o.xml;return a=t._emit("saveXML.serialized",{xml:a})||a,{xml:a}}).catch(o=>({error:o})).then(o=>{t._emit("saveXML.done",o),o.error?s(o.error):r({xml:o.xml})})})}on(...e){this._eventBus.on(...e)}off(...e){this._eventBus.off(...e)}once(...e){this._eventBus.once(...e)}attachTo(e){e.get&&e.constructor.prototype.jquery&&(e=e.get(0)),typeof e=="string"&&(e=jt(e)),e.appendChild(this._container),this._emit("attach",{})}detach(){this._emit("detach",{}),Le(this._container)}destroy(){Object.keys(this._viewers).forEach(e=>{var t=this._viewers[e];xp(t,"destroy")}),Le(this._container)}_init(e){this._options=e,this._moddle=this._createModdle(e),this._viewers={},this._views=[];let t=le('
'),i=D({},ow,e);D(t.style,{width:yp(i.width),height:yp(i.height),position:i.position}),this._container=t,e.container&&this.attachTo(e.container)}_clear(){return this._switchView(null)}open(e){return this._switchView(e)}_setDefinitions(e){this._definitions=e,this._updateViews()}_updateViews(){var e=this._definitions;if(!e){this._views=[],this._switchView(null);return}var t=this._getViewProviders(),i=[e,...e.drgElement||[]],r=this._views,s=[];for(var o of i){var a=we(t,function(d){return typeof d.opens=="string"?d.opens===o.$type:d.opens(o)});if(a){var l={element:o,id:o.id,name:o.name,type:a.id};s.push(l)}}var c=this._activeView,u;if(c&&(u=we(s,function(d){return ka(c,d)})||this._getInitialView(s),!u)){this._switchView(null);return}var f=!ka(c,u)||vp(c,u),h=r.length!==s.length||!Es(s,function(d){return we(r,function(p){return ka(p,d)&&!vp(p,d)})});this._activeView=u,this._views=s,(f||h)&&this._viewsChanged()}_getInitialView(e,t){var i;return t&&(i=we(e,function(r){return ka(r,t)})||we(e,function(r){return r.type===t})),i||e[0]}_switchView(e){var t=this;return new Promise(function(i,r){var s=(u,f)=>{t._viewsChanged(),u?r(u):i(f)},o=t.getActiveView(),a,l=e&&t._getViewer(e),c=e&&e.element;if(o&&(a=t._getViewer(o),a!==l&&(xp(a,"clear"),a.detach())),t._activeView=e,l){a!==l&&l.attachTo(t._container),t._emit("import.render.start",{view:e,element:c}),l.open(c).then(u=>{t._emit("import.render.complete",{view:e,error:null,warnings:u.warnings}),s(null,u)}).catch(u=>{t._emit("import.render.complete",{view:e,error:u,warnings:u.warnings}),s(u,null)});return}s()})}_getViewer(e){var t=e.type,i=this._viewers[t];return i||(i=this._viewers[t]=this._createViewer(e.type),this._emit("viewer.created",{type:t,viewer:i})),i}_createViewer(e){var t=we(this._getViewProviders(),function(o){return o.id===e});if(!t)throw new Error("no provider for view type <"+e+">");var i=t.constructor,r=this._options[e]||{},s=this._options.common||{};return new i({...s,...r,additionalModules:[...r.additionalModules||[],{_parent:["value",this],moddle:["value",this._moddle]}]})}_emit(...e){return this._eventBus.fire(...e)}_createModdle(e){return new hp(e.moddleExtensions)}_getViewProviders(){return[]}};function yp(n){return n+(Ce(n)?"px":"")}function aw(n,e){if(n.message!=="failed to parse document as ")return null;var t=e.indexOf('"http://www.omg.org/spec/DMN/20151101/dmn.xsd"')!==-1&&"1.1"||e.indexOf('"http://www.omg.org/spec/DMN/20180521/MODEL/"')!==-1&&"1.2";return t?(n=new Error("unsupported DMN "+t+" file detected; only DMN 1.3 files can be opened"),console.error("Cannot open what looks like a DMN "+t+" diagram. Please refer to https://bpmn.io/l/dmn-compatibility.html to learn how to make the toolkit compatible with older DMN files",n),n):null}function lw(n){var e=/unparsable content <([^>]+)> detected([\s\S]*)$/,t=e.exec(n.message);return t?(n.message="unparsable content <"+t[1]+"> detected; this may indicate an invalid DMN 1.3 diagram file"+t[2],n):null}function ka(n,e){return ht(n)?ht(e)?n.element===e.element||n.id===e.id:!1:!ht(e)}function vp(n,e){return!n||!e||n.name!==e.name}function xp(n,e){Ie(n[e])&&n[e]()}var cw=/^class[ {]/;function uw(n){return cw.test(n.toString())}function qc(n){return Array.isArray(n)}function Nc(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Ca(...n){n.length===1&&qc(n[0])&&(n=n[0]),n=[...n];let e=n.pop();return e.$inject=n,e}var fw=/constructor\s*[^(]*\(\s*([^)]*)\)/m,hw=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,dw=/\/\*([^*]*)\*\//m;function pw(n){if(typeof n!="function")throw new Error(`Cannot annotate "${n}". Expected a function!`);let e=n.toString().match(uw(n)?fw:hw);if(!e)return[];let t=e[1]||e[2];return t&&t.split(",").map(i=>{let r=i.match(dw);return(r&&r[1]||i).trim()})||[]}function xi(n,e){let t=e||{get:function(x,b){if(i.push(x),b===!1)return null;throw a(`No provider for "${x}"!`)}},i=[],r=this._providers=Object.create(t._providers||null),s=this._instances=Object.create(null),o=s.injector=this,a=function(x){let b=i.join(" -> ");return i.length=0,new Error(b?`${x} (Resolving: ${b})`:x)};function l(x,b){if(!r[x]&&x.includes(".")){let C=x.split("."),O=l(C.shift());for(;C.length;)O=O[C.shift()];return O}if(Nc(s,x))return s[x];if(Nc(r,x)){if(i.indexOf(x)!==-1)throw i.push(x),a("Cannot resolve circular dependency!");return i.push(x),s[x]=r[x][0](r[x][1]),i.pop(),s[x]}return t.get(x,b)}function c(x,b){if(typeof b=="undefined"&&(b={}),typeof x!="function")if(qc(x))x=Ca(x.slice());else throw a(`Cannot invoke "${x}". Expected a function!`);let O=(x.$inject||pw(x)).map(w=>Nc(b,w)?b[w]:l(w));return{fn:x,dependencies:O}}function u(x){let{fn:b,dependencies:C}=c(x),O=Function.prototype.bind.call(b,null,...C);return new O}function f(x,b,C){let{fn:O,dependencies:w}=c(x,C);return O.apply(b,w)}function h(x){return Ca(b=>x.get(b))}function d(x,b){if(b&&b.length){let C=Object.create(null),O=Object.create(null),w=[],v=[],A=[],S,M,_,P;for(let j in r)S=r[j],b.indexOf(j)!==-1&&(S[2]==="private"?(M=w.indexOf(S[3]),M===-1?(_=S[3].createChild([],b),P=h(_),w.push(S[3]),v.push(_),A.push(P),C[j]=[P,j,"private",_]):C[j]=[A[M],j,"private",v[M]]):C[j]=[S[2],S[1]],O[j]=!0),(S[2]==="factory"||S[2]==="type")&&S[1].$scope&&b.forEach(oe=>{S[1].$scope.indexOf(oe)!==-1&&(C[j]=[S[2],S[1]],O[oe]=!0)});b.forEach(j=>{if(!O[j])throw new Error('No provider for "'+j+'". Cannot use provider from the parent!')}),x.unshift(C)}return new xi(x,o)}let p={factory:f,type:u,value:function(x){return x}};function m(x,b){let C=x.__init__||[];return function(){C.forEach(O=>{typeof O=="string"?b.get(O):b.invoke(O)})}}function y(x){let b=x.__exports__;if(b){let C=x.__modules__,O=Object.keys(x).reduce((M,_)=>(_!=="__exports__"&&_!=="__modules__"&&_!=="__init__"&&_!=="__depends__"&&(M[_]=x[_]),M),Object.create(null)),w=(C||[]).concat(O),v=d(w),A=Ca(function(M){return v.get(M)});b.forEach(function(M){r[M]=[A,M,"private",v]});let S=(x.__init__||[]).slice();return S.unshift(function(){v.init()}),x=Object.assign({},x,{__init__:S}),m(x,v)}return Object.keys(x).forEach(function(C){if(C==="__init__"||C==="__depends__")return;let O=x[C];if(O[2]==="private"){r[C]=O;return}let w=O[0],v=O[1];r[C]=[p[w],mw(w,v),w]}),m(x,o)}function g(x,b){return x.indexOf(b)!==-1||(x=(b.__depends__||[]).reduce(g,x),x.indexOf(b)!==-1)?x:x.concat(b)}function k(x){let b=x.reduce(g,[]).map(y),C=!1;return function(){C||(C=!0,b.forEach(O=>O()))}}this.get=l,this.invoke=f,this.instantiate=u,this.createChild=d,this.init=k(n)}function mw(n,e){return n!=="value"&&qc(e)&&(e=Ca(e.slice())),e}function Vt(n,e){e&&(n.super_=e,n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}var gw=1e3;function it(n,e){var t=this;e=e||gw,n.on(["render.shape","render.connection"],e,function(i,r){var s=i.type,o=r.element,a=r.gfx,l=r.attrs;if(t.canRender(o))return s==="render.shape"?t.drawShape(a,o,l):t.drawConnection(a,o,l)}),n.on(["render.getShapePath","render.getConnectionPath"],e,function(i,r){if(t.canRender(r))return i.type==="render.getShapePath"?t.getShapePath(r):t.getConnectionPath(r)})}it.prototype.canRender=function(n){};it.prototype.drawShape=function(n,e){};it.prototype.drawConnection=function(n,e){};it.prototype.getShapePath=function(n){};it.prototype.getConnectionPath=function(n){};function yw(n,e){if(n.ownerDocument!==e.ownerDocument)try{return e.ownerDocument.importNode(n,!0)}catch{}return n}function kp(n,e){return e.appendChild(yw(n,e))}function ve(n,e){return kp(e,n),n}var Vc=2,Cp={"alignment-baseline":1,"baseline-shift":1,clip:1,"clip-path":1,"clip-rule":1,color:1,"color-interpolation":1,"color-interpolation-filters":1,"color-profile":1,"color-rendering":1,cursor:1,direction:1,display:1,"dominant-baseline":1,"enable-background":1,fill:1,"fill-opacity":1,"fill-rule":1,filter:1,"flood-color":1,"flood-opacity":1,font:1,"font-family":1,"font-size":Vc,"font-size-adjust":1,"font-stretch":1,"font-style":1,"font-variant":1,"font-weight":1,"glyph-orientation-horizontal":1,"glyph-orientation-vertical":1,"image-rendering":1,kerning:1,"letter-spacing":1,"lighting-color":1,marker:1,"marker-end":1,"marker-mid":1,"marker-start":1,mask:1,opacity:1,overflow:1,"pointer-events":1,"shape-rendering":1,"stop-color":1,"stop-opacity":1,stroke:1,"stroke-dasharray":1,"stroke-dashoffset":1,"stroke-linecap":1,"stroke-linejoin":1,"stroke-miterlimit":1,"stroke-opacity":1,"stroke-width":Vc,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function vw(n,e){return Cp[e]?n.style[e]:n.getAttributeNS(null,e)}function Sp(n,e,t){var i=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Cp[i];r?(r===Vc&&typeof t=="number"&&(t=String(t)+"px"),n.style[i]=t):n.setAttributeNS(null,e,t)}function xw(n,e){var t=Object.keys(e),i,r;for(i=0,r;r=t[i];i++)Sp(n,r,e[r])}function K(n,e,t){if(typeof e=="string")if(t!==void 0)Sp(n,e,t);else return vw(n,e);else xw(n,e);return n}var bw=Object.prototype.toString;function Qt(n){return new Xn(n)}function Xn(n){if(!n||!n.nodeType)throw new Error("A DOM element reference is required");this.el=n,this.list=n.classList}Xn.prototype.add=function(n){return this.list.add(n),this};Xn.prototype.remove=function(n){return bw.call(n)=="[object RegExp]"?this.removeMatching(n):(this.list.remove(n),this)};Xn.prototype.removeMatching=function(n){let e=this.array();for(let t=0;t"+n+"",e=!0);var t=Ow(n);if(!e)return t;for(var i=document.createDocumentFragment(),r=t.firstChild;r.firstChild;)i.appendChild(r.firstChild);return i}function Ow(n){var e;return e=new DOMParser,e.async=!1,e.parseFromString(n,"text/xml")}function ie(n,e){var t;return n=n.trim(),n.charAt(0)==="<"?(t=Ep(n).firstChild,t=document.importNode(t,!0)):t=document.createElementNS(zc.svg,n),e&&K(t,e),t}var Fc=null;function Qc(){return Fc===null&&(Fc=ie("svg")),Fc}function wp(n,e){var t,i,r=Object.keys(e);for(t=0;i=r[t];t++)n[i]=e[i];return n}function Ap(n,e,t,i,r,s){var o=Qc().createSVGMatrix();switch(arguments.length){case 0:return o;case 1:return wp(o,n);case 6:return wp(o,{a:n,b:e,c:t,d:i,e:r,f:s})}}function _p(n){return n?Qc().createSVGTransformFromMatrix(n):Qc().createSVGTransform()}var Op=/([&<>]{1})/g,kw=/([&<>\n\r"]{1})/g,Cw={"&":"&","<":"<",">":">",'"':"'"};function jc(n,e){function t(i,r){return Cw[r]||r}return n.replace(e,t)}function Tp(n,e){var t,i,r,s,o;switch(n.nodeType){case 3:e.push(jc(n.textContent,Op));break;case 1:if(e.push("<",n.tagName),n.hasAttributes())for(r=n.attributes,t=0,i=r.length;t"),o=n.childNodes,t=0,i=o.length;t")}else e.push("/>");break;case 8:e.push("");break;case 4:e.push("");break;default:throw new Error("unable to handle node "+n.nodeType)}return e}function Sw(n,e){var t=Ep(e);if(ww(n),!!e){Aw(t)||(t=t.documentElement);for(var i=_w(t.childNodes),r=0;rr||r===void 0)&&(r=l+f),(c+u>s||s===void 0)&&(s=c+u)}),{x:t,y:i,height:s-i,width:r-t}}function Rp(n){return"waypoints"in n?"connection":"x"in n?"shape":"root"}function Aa(n){return!!(n&&n.isFrame)}var Bw=1;function rn(n,e){it.call(this,n,Bw),this.CONNECTION_STYLE=e.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=e.style({fill:"white",stroke:"fuchsia",strokeWidth:2}),this.FRAME_STYLE=e.style(["no-fill"],{stroke:"fuchsia",strokeDasharray:4,strokeWidth:2})}Vt(rn,it);rn.prototype.canRender=function(){return!0};rn.prototype.drawShape=function(e,t,i){var r=ie("rect");return K(r,{x:0,y:0,width:t.width||0,height:t.height||0}),Aa(t)?K(r,D({},this.FRAME_STYLE,i||{})):K(r,D({},this.SHAPE_STYLE,i||{})),ve(e,r),r};rn.prototype.drawConnection=function(e,t,i){var r=ir(t.waypoints,D({},this.CONNECTION_STYLE,i||{}));return ve(e,r),r};rn.prototype.getShapePath=function(e){var t=e.x,i=e.y,r=e.width,s=e.height,o=[["M",t,i],["l",r,0],["l",0,s],["l",-r,0],["z"]];return Ea(o)};rn.prototype.getConnectionPath=function(e){var t=e.waypoints,i,r,s=[];for(i=0;r=t[i];i++)r=r.original||r,s.push([i===0?"M":"L",r.x,r.y]);return Ea(s)};rn.$inject=["eventBus","styles"];function Uc(){var n={"no-fill":{fill:"none"},"no-border":{strokeOpacity:0},"no-events":{pointerEvents:"none"}},e=this;this.cls=function(t,i,r){var s=this.style(i,r);return D(s,{class:t})},this.style=function(t,i){!_e(t)&&!i&&(i=t,t=[]);var r=wt(t,function(s,o){return D(s,n[o]||{})},{});return i?D(r,i):r},this.computeStyle=function(t,i,r){return _e(i)||(r=i,i=[]),e.style(i||[],D({},r,t||{}))}}var Pp={__init__:["defaultRenderer"],defaultRenderer:["type",rn],styles:["type",Uc]};function Dp(n,e){if(!n||!e)return-1;var t=n.indexOf(e);return t!==-1&&n.splice(t,1),t}function Bp(n,e,t){if(!(!n||!e)){typeof t!="number"&&(t=-1);var i=n.indexOf(e);if(i!==-1){if(i===t)return;if(t!==-1)n.splice(i,1);else return}t!==-1?n.splice(t,0,e):n.push(e)}}var Ds=Math,vR=Ds.PI,xR=Ds.min,bR=Ds.max,wR=Ds.pow,OR=Ds.abs;function Yc(n){return{top:n.y,right:n.x+(n.width||0),bottom:n.y+(n.height||0),left:n.x}}function _a(n,e){return Math.round(n*e)/e}function Ip(n){return Ce(n)?n+"px":n}function Iw(n){for(;n.parent;)n=n.parent;return n}function Lw(n){n=D({},{width:"100%",height:"100%"},n);let e=n.container||document.body,t=document.createElement("div");return t.setAttribute("class","djs-container djs-parent"),yi(t,{position:"relative",overflow:"hidden",width:Ip(n.width),height:Ip(n.height)}),e.appendChild(t),t}function Lp(n,e,t){let i=ie("g");Qt(i).add(e);let r=t!==void 0?t:n.childNodes.length-1;return n.insertBefore(i,n.childNodes[r]||null),i}var $w="base",$p=0,Nw=1,qw={shape:["x","y","width","height"],connection:["waypoints"]};function V(n,e,t,i){this._eventBus=e,this._elementRegistry=i,this._graphicsFactory=t,this._rootsIdx=0,this._layers={},this._planes=[],this._rootElement=null,this._focused=!1,this._init(n||{})}V.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"];V.prototype._init=function(n){let e=this._eventBus,t=this._container=Lw(n),i=this._svg=ie("svg");K(i,{width:"100%",height:"100%"}),tr(i,"tabindex",0),n.autoFocus&&e.on("element.hover",()=>{this.restoreFocus()}),e.on("element.mousedown",500,s=>{this.focus()}),i.addEventListener("focusin",()=>{this._setFocused(!0)}),i.addEventListener("focusout",()=>{this._setFocused(!1)}),i.addEventListener("mouseover",()=>{this._eventBus.fire("canvas.mouseover")}),i.addEventListener("mouseout",()=>{this._eventBus.fire("canvas.mouseout")}),ve(t,i);let r=this._viewport=Lp(i,"viewport");n.deferUpdate&&(this._viewboxChanged=Gi(Ft(this._viewboxChanged,this),300)),e.on("diagram.init",()=>{e.fire("canvas.init",{svg:i,viewport:r})}),e.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed","root.set"],()=>{delete this._cachedViewbox}),e.on("diagram.destroy",500,this._destroy,this),e.on("diagram.clear",500,this._clear,this)};V.prototype._destroy=function(){this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});let n=this._container.parentNode;n&&n.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._planes,delete this._rootElement,delete this._viewport};V.prototype._setFocused=function(n){n!=this._focused&&(this._focused=n,this._eventBus.fire("canvas.focus.changed",{focused:n}))};V.prototype._clear=function(){this._elementRegistry.getAll().forEach(e=>{let t=Rp(e);t==="root"?this.removeRootElement(e):this._removeElement(e,t)}),this._planes=[],this._rootElement=null,delete this._cachedViewbox};V.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)};V.prototype.restoreFocus=function(){document.activeElement===document.body&&this.focus()};V.prototype.isFocused=function(){return this._focused};V.prototype.getDefaultLayer=function(){return this.getLayer($w,$p)};V.prototype.getLayer=function(n,e){if(!n)throw new Error("must specify a name");let t=this._layers[n];if(t||(t=this._layers[n]=this._createLayer(n,e)),typeof e!="undefined"&&t.index!==e)throw new Error("layer <"+n+"> already created at index <"+e+">");return t.group};V.prototype._getChildIndex=function(n){return wt(this._layers,function(e,t){return t.visible&&n>=t.index&&e++,e},0)};V.prototype._createLayer=function(n,e){typeof e=="undefined"&&(e=Nw);let t=this._getChildIndex(e);return{group:Lp(this._viewport,"layer-"+n,t),index:e,visible:!0}};V.prototype.showLayer=function(n){if(!n)throw new Error("must specify a name");let e=this._layers[n];if(!e)throw new Error("layer <"+n+"> does not exist");let t=this._viewport,i=e.group,r=e.index;if(e.visible)return i;let s=this._getChildIndex(r);return t.insertBefore(i,t.childNodes[s]||null),e.visible=!0,i};V.prototype.hideLayer=function(n){if(!n)throw new Error("must specify a name");let e=this._layers[n];if(!e)throw new Error("layer <"+n+"> does not exist");let t=e.group;return e.visible&&(bi(t),e.visible=!1),t};V.prototype._removeLayer=function(n){let e=this._layers[n];e&&(delete this._layers[n],bi(e.group))};V.prototype.getActiveLayer=function(){let n=this._findPlaneForRoot(this.getRootElement());return n?n.layer:null};V.prototype.findRoot=function(n){return typeof n=="string"&&(n=this._elementRegistry.get(n)),n?(this._findPlaneForRoot(Iw(n))||{}).rootElement:void 0};V.prototype.getRootElements=function(){return this._planes.map(function(n){return n.rootElement})};V.prototype._findPlaneForRoot=function(n){return we(this._planes,function(e){return e.rootElement===n})};V.prototype.getContainer=function(){return this._container};V.prototype._updateMarker=function(n,e,t){let i;n.id||(n=this._elementRegistry.get(n)),n.markers=n.markers||new Set,i=this._elementRegistry._elements[n.id],i&&(B([i.gfx,i.secondaryGfx],function(r){r&&(t?(n.markers.add(e),Qt(r).add(e)):(n.markers.delete(e),Qt(r).remove(e)))}),this._eventBus.fire("element.marker.update",{element:n,gfx:i.gfx,marker:e,add:!!t}))};V.prototype.addMarker=function(n,e){this._updateMarker(n,e,!0)};V.prototype.removeMarker=function(n,e){this._updateMarker(n,e,!1)};V.prototype.hasMarker=function(n,e){return n.id||(n=this._elementRegistry.get(n)),n.markers?n.markers.has(e):!1};V.prototype.toggleMarker=function(n,e){this.hasMarker(n,e)?this.removeMarker(n,e):this.addMarker(n,e)};V.prototype.getRootElement=function(){let n=this._rootElement;return n||this._planes.length?n:this.setRootElement(this.addRootElement(null))};V.prototype.addRootElement=function(n){let e=this._rootsIdx++;n||(n={id:"__implicitroot_"+e,children:[],isImplicit:!0});let t=n.layer="root-"+e;this._ensureValid("root",n);let i=this.getLayer(t,$p);return this.hideLayer(t),this._addRoot(n,i),this._planes.push({rootElement:n,layer:i}),n};V.prototype.removeRootElement=function(n){if(typeof n=="string"&&(n=this._elementRegistry.get(n)),!!this._findPlaneForRoot(n))return this._removeRoot(n),this._removeLayer(n.layer),this._planes=this._planes.filter(function(t){return t.rootElement!==n}),this._rootElement===n&&(this._rootElement=null),n};V.prototype.setRootElement=function(n){if(n===this._rootElement)return n;let e;if(!n)throw new Error("rootElement required");return e=this._findPlaneForRoot(n),e||(n=this.addRootElement(n)),this._setRoot(n),n};V.prototype._removeRoot=function(n){let e=this._elementRegistry,t=this._eventBus;t.fire("root.remove",{element:n}),t.fire("root.removed",{element:n}),e.remove(n)};V.prototype._addRoot=function(n,e){let t=this._elementRegistry,i=this._eventBus;i.fire("root.add",{element:n}),t.add(n,e),i.fire("root.added",{element:n,gfx:e})};V.prototype._setRoot=function(n,e){let t=this._rootElement;t&&(this._elementRegistry.updateGraphics(t,null,!0),this.hideLayer(t.layer)),n&&(e||(e=this._findPlaneForRoot(n).layer),this._elementRegistry.updateGraphics(n,this._svg,!0),this.showLayer(n.layer)),this._rootElement=n,this._eventBus.fire("root.set",{element:n})};V.prototype._ensureValid=function(n,e){if(!e.id)throw new Error("element must have an id");if(this._elementRegistry.get(e.id))throw new Error("element <"+e.id+"> already exists");let t=qw[n];if(!Es(t,function(r){return typeof e[r]!="undefined"}))throw new Error("must supply { "+t.join(", ")+" } with "+n)};V.prototype._setParent=function(n,e,t){Bp(e.children,n,t),n.parent=e};V.prototype._addElement=function(n,e,t,i){t=t||this.getRootElement();let r=this._eventBus,s=this._graphicsFactory;this._ensureValid(n,e),r.fire(n+".add",{element:e,parent:t}),this._setParent(e,t,i);let o=s.create(n,e,i);return this._elementRegistry.add(e,o),s.update(n,e,o),r.fire(n+".added",{element:e,gfx:o}),e};V.prototype.addShape=function(n,e,t){return this._addElement("shape",n,e,t)};V.prototype.addConnection=function(n,e,t){return this._addElement("connection",n,e,t)};V.prototype._removeElement=function(n,e){let t=this._elementRegistry,i=this._graphicsFactory,r=this._eventBus;if(n=t.get(n.id||n),!!n)return r.fire(e+".remove",{element:n}),i.remove(n),Dp(n.parent&&n.parent.children,n),n.parent=null,r.fire(e+".removed",{element:n}),t.remove(n),n};V.prototype.removeShape=function(n){return this._removeElement(n,"shape")};V.prototype.removeConnection=function(n){return this._removeElement(n,"connection")};V.prototype.getGraphics=function(n,e){return this._elementRegistry.getGraphics(n,e)};V.prototype._changeViewbox=function(n){this._eventBus.fire("canvas.viewbox.changing"),n.apply(this),this._cachedViewbox=null,this._viewboxChanged()};V.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})};V.prototype.viewbox=function(n){if(n===void 0&&this._cachedViewbox)return structuredClone(this._cachedViewbox);let e=this._viewport,t=this.getSize(),i,r,s,o,a,l,c;if(n)this._changeViewbox(function(){a=Math.min(t.width/n.width,t.height/n.height);let u=this._svg.createSVGMatrix().scale(a).translate(-n.x,-n.y);Ps(e,u)});else return s=this._rootElement?this.getActiveLayer():null,i=s&&s.getBBox()||{},o=Ps(e),r=o?o.matrix:Ap(),a=_a(r.a,1e3),l=_a(-r.e||0,1e3),c=_a(-r.f||0,1e3),n=this._cachedViewbox={x:l?l/a:0,y:c?c/a:0,width:t.width/a,height:t.height/a,scale:a,inner:{width:i.width||0,height:i.height||0,x:i.x||0,y:i.y||0},outer:t},n;return n};V.prototype.scroll=function(n){let e=this._viewport,t=e.getCTM();return n&&this._changeViewbox(function(){n=D({dx:0,dy:0},n||{}),t=this._svg.createSVGMatrix().translate(n.dx,n.dy).multiply(t),Np(e,t)}),{x:t.e,y:t.f}};V.prototype.scrollToElement=function(n,e){let t=100;typeof n=="string"&&(n=this._elementRegistry.get(n));let i=this.findRoot(n);if(i!==this.getRootElement()&&this.setRootElement(i),i===n)return;e||(e={}),typeof e=="number"&&(t=e),e={top:e.top||t,right:e.right||t,bottom:e.bottom||t,left:e.left||t};let r=wi(n),s=Yc(r),o=this.viewbox(),a=this.zoom(),l,c;o.y+=e.top/a,o.x+=e.left/a,o.width-=(e.right+e.left)/a,o.height-=(e.bottom+e.top)/a;let u=Yc(o);if(!(r.width=0&&i.y>=0&&i.x+i.width<=t.width&&i.y+i.height<=t.height&&!n?s={x:0,y:0,width:Math.max(i.width+i.x,t.width),height:Math.max(i.height+i.y,t.height)}:(r=Math.min(1,t.width/i.width,t.height/i.height),s={x:i.x+(n?i.width/2-t.width/r/2:0),y:i.y+(n?i.height/2-t.height/r/2:0),width:t.width/r,height:t.height/r}),this.viewbox(s),this.viewbox(!1).scale};V.prototype._setZoom=function(n,e){let t=this._svg,i=this._viewport,r=t.createSVGMatrix(),s=t.createSVGPoint(),o,a,l,c,u;l=i.getCTM();let f=l.a;return e?(o=D(s,e),a=o.matrixTransform(l.inverse()),c=r.translate(a.x,a.y).scale(1/f*n).translate(-a.x,-a.y),u=l.multiply(c)):u=r.scale(n),Np(this._viewport,u),u};V.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}};V.prototype.getAbsoluteBBox=function(n){let e=this.viewbox(),t;n.waypoints?t=this.getGraphics(n).getBBox():t=n;let i=t.x*e.scale-e.x*e.scale,r=t.y*e.scale-e.y*e.scale,s=t.width*e.scale,o=t.height*e.scale;return{x:i,y:r,width:s,height:o}};V.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var rr="data-element-id";function Xe(n){this._elements={},this._eventBus=n}Xe.$inject=["eventBus"];Xe.prototype.add=function(n,e,t){var i=n.id;this._validateId(i),K(e,rr,i),t&&K(t,rr,i),this._elements[i]={element:n,gfx:e,secondaryGfx:t}};Xe.prototype.remove=function(n){var e=this._elements,t=n.id||n,i=t&&e[t];i&&(K(i.gfx,rr,""),i.secondaryGfx&&K(i.secondaryGfx,rr,""),delete e[t])};Xe.prototype.updateId=function(n,e){this._validateId(e),typeof n=="string"&&(n=this.get(n)),this._eventBus.fire("element.updateId",{element:n,newId:e});var t=this.getGraphics(n),i=this.getGraphics(n,!0);this.remove(n),n.id=e,this.add(n,t,i)};Xe.prototype.updateGraphics=function(n,e,t){var i=n.id||n,r=this._elements[i];return t?r.secondaryGfx=e:r.gfx=e,e&&K(e,rr,i),e};Xe.prototype.get=function(n){var e;typeof n=="string"?e=n:e=n&&K(n,rr);var t=this._elements[e];return t&&t.element};Xe.prototype.filter=function(n){var e=[];return this.forEach(function(t,i){n(t,i)&&e.push(t)}),e};Xe.prototype.find=function(n){for(var e=this._elements,t=Object.keys(e),i=0;i in ref");e=this.props[e]}e.collection?qp(this,e,n):Qw(this,e,n)};Ue.prototype.ensureRefsCollection=function(n,e){var t=n[e.name];return jw(t)||qp(this,e,n),t};Ue.prototype.ensureBound=function(n,e){Vw(n,e)||this.bind(n,e)};Ue.prototype.unset=function(n,e,t){n&&(this.ensureBound(n,e),e.collection?this.ensureRefsCollection(n,e).remove(t):n[e.name]=void 0)};Ue.prototype.set=function(n,e,t){n&&(this.ensureBound(n,e),e.collection?this.ensureRefsCollection(n,e).add(t):n[e.name]=t)};var Kc=new Ue({name:"children",enumerable:!0,collection:!0},{name:"parent"}),jp=new Ue({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),Fp=new Ue({name:"attachers",collection:!0},{name:"host"}),Vp=new Ue({name:"outgoing",collection:!0},{name:"source"}),Qp=new Ue({name:"incoming",collection:!0},{name:"target"});function Bs(){Object.defineProperty(this,"businessObject",{writable:!0}),Object.defineProperty(this,"label",{get:function(){return this.labels[0]},set:function(n){var e=this.label,t=this.labels;!n&&e?t.remove(e):t.add(n,0)}}),Kc.bind(this,"parent"),jp.bind(this,"labels"),Vp.bind(this,"outgoing"),Qp.bind(this,"incoming")}function Is(){Bs.call(this),Kc.bind(this,"children"),Fp.bind(this,"host"),Fp.bind(this,"attachers")}Vt(Is,Bs);function zp(){Bs.call(this),Kc.bind(this,"children")}Vt(zp,Is);function Wp(){Is.call(this),jp.bind(this,"labelTarget")}Vt(Wp,Is);function Hp(){Bs.call(this),Vp.bind(this,"source"),Qp.bind(this,"target")}Vt(Hp,Bs);var zw={connection:Hp,shape:Is,label:Wp,root:zp};function Xp(n,e){var t=zw[n];if(!t)throw new Error("unknown type: <"+n+">");return D(new t,e)}function Un(){this._uid=12}Un.prototype.createRoot=function(n){return this.create("root",n)};Un.prototype.createLabel=function(n){return this.create("label",n)};Un.prototype.createShape=function(n){return this.create("shape",n)};Un.prototype.createConnection=function(n){return this.create("connection",n)};Un.prototype.create=function(n,e){return e=D({},e||{}),e.id||(e.id=n+"_"+this._uid++),Xp(n,e)};function Up(n){return n.childNodes[0]}function Yp(n){return n.parentNode.childNodes[1]}function Kp(n,e,t){var i=_p();i.setTranslate(e,t),Ps(n,i)}function Ye(n,e){this._eventBus=n,this._elementRegistry=e}Ye.$inject=["eventBus","elementRegistry"];Ye.prototype._getChildrenContainer=function(n){var e=this._elementRegistry.getGraphics(n),t;return n.parent?(t=Yp(e),t||(t=ie("g"),Qt(t).add("djs-children"),ve(e.parentNode,t))):t=e,t};Ye.prototype._clear=function(n){var e=Up(n);return wa(e),e};Ye.prototype._createContainer=function(n,e,t,i){var r=ie("g");Qt(r).add("djs-group"),typeof t!="undefined"?Gp(r,e,e.childNodes[t]):ve(e,r);var s=ie("g");Qt(s).add("djs-element"),Qt(s).add("djs-"+n),i&&Qt(s).add("djs-frame"),ve(r,s);var o=ie("g");return Qt(o).add("djs-visual"),ve(s,o),s};Ye.prototype.create=function(n,e,t){var i=this._getChildrenContainer(e.parent);return this._createContainer(n,i,t,Aa(e))};Ye.prototype.updateContainments=function(n){var e=this,t=this._elementRegistry,i;i=wt(n,function(r,s){return s.parent&&(r[s.parent.id]=s.parent),r},{}),B(i,function(r){var s=r.children;if(s){var o=e._getChildrenContainer(r);B(s.slice().reverse(),function(a){var l=t.getGraphics(a);Gp(l.parentNode,o)})}})};Ye.prototype.drawShape=function(n,e,t={}){var i=this._eventBus;return i.fire("render.shape",{gfx:n,element:e,attrs:t})};Ye.prototype.getShapePath=function(n){var e=this._eventBus;return e.fire("render.getShapePath",n)};Ye.prototype.drawConnection=function(n,e,t={}){var i=this._eventBus;return i.fire("render.connection",{gfx:n,element:e,attrs:t})};Ye.prototype.getConnectionPath=function(n){var e=this._eventBus;return e.fire("render.getConnectionPath",n)};Ye.prototype.update=function(n,e,t){if(e.parent){var i=this._clear(t);if(n==="shape")this.drawShape(i,e),Kp(t,e.x,e.y);else if(n==="connection")this.drawConnection(i,e);else throw new Error("unknown type: "+n);e.hidden?K(t,"display","none"):K(t,"display","block")}};Ye.prototype.remove=function(n){var e=this._elementRegistry.getGraphics(n);bi(e.parentNode)};function Gp(n,e,t){var i=t||e.firstChild;n!==i&&e.insertBefore(n,i)}var Jp={__depends__:[Pp],__init__:["canvas"],canvas:["type",V],elementRegistry:["type",Xe],elementFactory:["type",Un],eventBus:["type",ye],graphicsFactory:["type",Ye]};function Ww(n){var e=new xi(n);return e.init(),e}function Hw(n){n=n||{};var e={config:["value",n]},t=[e,Jp].concat(n.modules||[]);return Ww(t)}function kn(n,e){this._injector=e||Hw(n),this.get("eventBus").fire("diagram.init")}kn.prototype.get=function(n,e){return this._injector.get(n,e)};kn.prototype.invoke=function(n,e,t){return this._injector.invoke(n,e,t)};kn.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")};kn.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};function Q(n,e){var t=Ot(n);return t&&typeof t.$instanceOf=="function"&&t.$instanceOf(e)}function Ot(n){return n&&n.businessObject||n}function Zp(n){return Ot(n).name}function Ta(n){var e=Ot(n);if(Q(e,"dmn:Decision"))return e.get("decisionLogic");if(Q(e,"dmn:BusinessKnowledgeModel")){var t=e.get("encapsulatedLogic");return t&&t.get("body")}}var Xw="https://www.omg.org/spec/DMN/20191111/FEEL/";function em(n){for(let e=n;e;e=e.$parent){let t=e.get("expressionLanguage");if(t)return!!(t===Xw||/feel/i.test(t));if(Q(e,"dmn:FunctionDefinition"))return(e.get("kind")||"FEEL")==="FEEL"}return!0}var Uw=new Ue({name:"dmnElementRef",enumerable:!0},{name:"di",configurable:!0});function Gc(n,e){var t=[];function i(g){var k=g.gfx;if(k)throw new Error("already rendered "+g.id);return n.element(g)}function r(g){return n.root(g)}function s(g){try{var k=g.di&&i(g);return k}catch(x){y(x.message,{element:g,error:x})}}function o(g,k){var x=g.dmnDI;if(!x)throw new Error("no dmndi:DMNDI");var b=x.diagrams||[];if(k&&b.indexOf(k)===-1)throw new Error("diagram not part of dmndi:DMNDI");if(!k&&b&&b.length&&(k=b[0]),!k)throw new Error("no diagram to display");g.di=k,f(k),r(g),a(g.get("drgElement")),l(g.get("artifact")),m()}function a(g){B(g,function(k){s(k),u(k)})}function l(g){B(g,function(k){Q(k,"dmn:Association")?c(k):s(k)})}function c(g){p(function(){s(g)})}function u(g){B(["informationRequirement","knowledgeRequirement","authorityRequirement"],function(k){B(g[k],function(x){p(function(){s(x)})})})}function f(g){B(g.diagramElements,h)}function h(g){d(g)}function d(g){var k=g.dmnElementRef;k?k.di?y("multiple DI elements defined for element",{element:k}):(Uw.bind(k,"di"),k.di=g):y("no DMN element referenced in element",{element:g})}function p(g){t.push(g)}function m(){B(t,function(g){g()})}function y(g,k){n.error(g,k)}return{handleDefinitions:o}}function tm(n,e,t){var i=n.get("drdImporter"),r=n.get("eventBus"),s,o=[];function a(l){var c={root:function(f){return i.root(f)},element:function(f,h){return i.add(f,h)},error:function(f,h){o.push({message:f,context:h})}},u=new Gc(c);u.handleDefinitions(l)}r.fire("import.start",{definitions:e});try{a(e)}catch(l){s=l}r.fire("import.done",{error:s,warnings:o}),t(s,o)}var ru="$NO_OP",Yw="a runtime error occured! Use Inferno in development environment to find the error.",Da=Array.isArray;function su(n){var e=typeof n;return e==="string"||e==="number"}function Z(n){return Ba(n)||fe(n)}function Yn(n){return fe(n)||n===!1||Kw(n)||Ba(n)}function G(n){return typeof n=="function"}function sr(n){return typeof n=="string"}function tu(n){return typeof n=="number"}function fe(n){return n===null}function Kw(n){return n===!0}function Ba(n){return n===void 0}function Gw(n){throw n||(n=Yw),new Error("Inferno Error: "+n)}function Ns(n,e){var t={};if(n)for(var i in n)t[i]=n[i];if(e)for(var r in e)t[r]=e[r];return t}var Ls="$";function ou(n,e,t,i,r,s,o,a){return{childFlags:n,children:e,className:t,dom:null,flags:i,key:r===void 0?null:r,parentVNode:null,props:s===void 0?null:s,ref:o===void 0?null:o,type:a}}function E(n,e,t,i,r,s,o,a){var l=r===void 0?1:r,c=ou(l,i,t,n,o,s,a,e),u=Ct.createVNode;return typeof u=="function"&&u(c),l===0&&um(c,c.children),c}function F(n,e,t,i,r){(n&2)>0&&(n=e.prototype&&G(e.prototype.render)?4:8);var s=e.defaultProps;if(!Z(s)){t||(t={});for(var o in s)Ba(t[o])&&(t[o]=s[o])}if((n&8)>0){var a=e.defaultHooks;if(!Z(a))if(!r)r=a;else for(var l in a)Ba(r[l])&&(r[l]=a[l])}var c=ou(1,null,null,n,i,t,r,e),u=Ct.createVNode;return G(u)&&u(c),c}function xe(n,e){return ou(1,Z(n)?"":n,null,16,e,null,null,null)}function on(n){var e=n.props;if(e){var t=n.flags;t&481&&(e.children!==void 0&&Z(n.children)&&um(n,e.children),e.className!==void 0&&(n.className=e.className||null,e.className=void 0)),e.key!==void 0&&(n.key=e.key,e.key=void 0),e.ref!==void 0&&(t&8?n.ref=Ns(n.ref,e.ref):n.ref=e.ref,e.ref=void 0)}return n}function je(n){var e,t=n.flags;if(t&14){var i,r=n.props;if(!fe(r)){i={};for(var s in r)i[s]=r[s]}e=F(t,n.type,i,n.key,n.ref)}else t&481?e=E(t,n.type,n.className,n.children,n.childFlags,n.props,n.key,n.ref):t&16?e=xe(n.children,n.key):t&1024&&(e=n);return e}function lm(){return xe("",null)}function cm(n,e,t,i){for(var r=n.length;t0;o&&(s=vm(t),s&&pO(e,i,t));for(var a in t)nu(a,null,t[a],i,r,s,null);o&&ym(e,n,i,t,!0,s)}function bm(n,e,t,i){var r=new e(t,i);if(n.children=r,r.$V=n,r.$BS=!1,r.context=i,r.props===Me&&(r.props=t),r.$UN=!1,G(r.componentWillMount)){if(r.$BR=!0,r.componentWillMount(),r.$PSS){var s=r.state,o=r.$PS;if(fe(s))r.state=o;else for(var a in o)s[a]=o[a];r.$PSS=!1,r.$PS=null}r.$BR=!1}G(Ct.beforeRender)&&Ct.beforeRender(r);var l=js(r.render(t,r.state,i),n),c;return G(r.getChildContext)&&(c=r.getChildContext()),Z(c)?r.$CX=i:r.$CX=Ns(i,c),G(Ct.afterRender)&&Ct.afterRender(r),r.$LI=l,r}function js(n,e){return Yn(n)?n=lm():su(n)?n=xe(n,null):(n.dom&&(n=je(n)),n.flags&14&&(n.parentVNode=e)),n}function Ke(n,e,t,i){var r=n.flags;if(r&481)return wm(n,e,t,i);if(r&14)return vO(n,e,t,i,(r&4)>0);if(r&512||r&16)return iu(n,e);if(r&1024)return Ke(n.children,n.type,t,!1),n.dom=iu(lm(),e)}function iu(n,e){var t=n.dom=document.createTextNode(n.children);return fe(e)||Ia(e,t),t}function wm(n,e,t,i){var r=n.flags,s=n.children,o=n.props,a=n.className,l=n.ref,c=n.childFlags;i=i||(r&32)>0;var u=Zw(n.type,i);if(n.dom=u,!Z(a)&&a!==""&&(i?u.setAttribute("class",a):u.className=a),fe(e)||Ia(e,u),(c&1)===0){var f=i===!0&&n.type!=="foreignObject";c===2?Ke(s,u,t,f):c&12&&$s(s,u,t,f)}return fe(o)||xm(n,r,o,u,i),G(l)&&hu(u,l),u}function $s(n,e,t,i){for(var r=0,s=n.length;r0,e.nodeType!==1||e.tagName.toLowerCase()!==n.type){var c=wm(n,null,t,i);n.dom=c,au(e.parentNode,c,e)}else{n.dom=e;var u=e.firstChild,f=n.childFlags;if((f&1)===0){for(var h=null;u;)h=u.nextSibling,u.nodeType===8&&(u.data==="!"?e.replaceChild(document.createTextNode(""),u):e.removeChild(u)),u=h;if(u=e.firstChild,f===2)fe(u)?Ke(r,e,t,i):(h=u.nextSibling,qs(r,u,t,i),u=h);else if(f&12)for(var d=0,p=r.length;d0):r&481?OO(n,e,t,i):r&16?kO(n,e):r&512?n.dom=e:Gw()}function CO(n,e,t){var i=e.firstChild;if(!fe(i))for(Yn(n)||qs(n,i,Me,!1),i=e.firstChild;i=i.nextSibling;)e.removeChild(i);sn.length>0&&lu(sn),e.$V=n,G(t)&&t()}function du(n,e,t,i,r){ki(n),au(t,Ke(e,null,i,r),n.dom)}function Cn(n,e,t,i,r){var s=e.flags|0;n.flags!==s||s&2048?du(n,e,t,i,r):s&481?AO(n,e,t,i,r,s):s&14?_O(n,e,t,i,r,(s&4)>0):s&16?TO(n,e):s&512?e.dom=n.dom:EO(n,e,i)}function SO(n,e){n.textContent!==e.children&&(n.textContent=e.children)}function EO(n,e,t){var i=n.type,r=e.type,s=e.children;if(Cm(n.childFlags,e.childFlags,n.children,s,i,t,!1),e.dom=n.dom,i!==r&&!Yn(s)){var o=s.dom;i.removeChild(o),r.appendChild(o)}}function AO(n,e,t,i,r,s){var o=e.type;if(n.type!==o)du(n,e,t,i,r);else{var a=n.dom,l=n.props,c=e.props,u=!1,f=!1,h;if(e.dom=a,r=r||(s&32)>0,l!==c){var d=l||Me;if(h=c||Me,h!==Me){u=(s&448)>0,u&&(f=vm(h));for(var p in h){var m=d[p],y=h[p];m!==y&&nu(p,m,y,a,r,f,n)}}if(d!==Me)for(var g in d)!h.hasOwnProperty(g)&&!Z(d[g])&&nu(g,d[g],null,a,r,f,n)}var k=n.children,x=e.children,b=e.ref,C=n.className,O=e.className;s&4096?SO(a,x):Cm(n.childFlags,e.childFlags,k,x,a,i,r&&o!=="foreignObject"),u&&ym(s,e,a,h,!1,f),C!==O&&(Z(O)?a.removeAttribute("class"):r?a.setAttribute("class",O):a.className=O),G(b)&&n.ref!==b&&hu(a,b)}}function Cm(n,e,t,i,r,s,o){switch(n){case 2:switch(e){case 2:Cn(t,i,r,s,o);break;case 1:kt(t,r);break;default:kt(t,r),$s(i,r,s,o);break}break;case 1:switch(e){case 2:Ke(i,r,s,o);break;case 1:break;default:$s(i,r,s,o);break}break;default:if(e&12){var a=t.length,l=i.length;a===0?l>0&&$s(i,r,s,o):l===0?Pa(r,t):e===8&&n===8?RO(t,i,r,s,o,a,l):MO(t,i,r,s,o,a,l)}else e===1?Pa(r,t):e===2&&(Pa(r,t),Ke(i,r,s,o));break}}function Sm(n,e,t,i,r,s,o,a,l){var c=n.state,u=n.props;t.children=n;var f;if(!n.$UN){if(u!==i||i===Me){if(!l&&G(n.componentWillReceiveProps)){if(n.$BR=!0,n.componentWillReceiveProps(i,s),n.$UN)return;n.$BR=!1}n.$PSS&&(e=Ns(e,n.$PS),n.$PSS=!1,n.$PS=null)}var h=!!n.shouldComponentUpdate;if(a||!h||h&&n.shouldComponentUpdate(i,e,s)){G(n.componentWillUpdate)&&(n.$BS=!0,n.componentWillUpdate(i,e,s),n.$BS=!1),n.props=i,n.state=e,n.context=s,G(Ct.beforeRender)&&Ct.beforeRender(n),f=n.render(i,e,s),G(Ct.afterRender)&&Ct.afterRender(n);var d=f!==ru,p;if(G(n.getChildContext)&&(p=n.getChildContext()),Z(p)?p=s:p=Ns(s,p),n.$CX=p,d){var m=n.$LI,y=js(f,t);Cn(m,y,r,p,o),n.$LI=y,G(n.componentDidUpdate)&&n.componentDidUpdate(u,c)}}else n.props=i,n.state=e,n.context=s;t.dom=n.$LI.dom}}function _O(n,e,t,i,r,s){var o=e.type,a=n.key,l=e.key;if(n.type!==o||a!==l)du(n,e,t,i,r);else{var c=e.props||Me;if(s){var u=n.children;u.$UPD=!0,u.$V=e,Sm(u,u.state,e,c,t,i,r,!1,!1),u.$UPD=!1}else{var f=!0,h=n.props,d=e.ref,p=!Z(d),m=n.children;if(e.dom=n.dom,e.children=m,p&&G(d.onComponentShouldUpdate)&&(f=d.onComponentShouldUpdate(h,c)),f!==!1){p&&G(d.onComponentWillUpdate)&&d.onComponentWillUpdate(h,c);var y=o(c,i);y!==ru&&(y=js(y,e),Cn(m,y,t,i,r),e.children=y,e.dom=y.dom,p&&G(d.onComponentDidUpdate)&&d.onComponentDidUpdate(h,c))}else m.flags&14&&(m.parentVNode=e)}}}function TO(n,e){var t=e.children,i=n.dom;t!==n.children&&(i.nodeValue=t),e.dom=i}function MO(n,e,t,i,r,s,o){for(var a=s>o?o:s,l=0,c,u;lo)for(l=a;la||u>l)break e;f=n[u],h=e[u]}for(f=n[a],h=e[l];f.key===h.key;){if(h.dom&&(e[l]=h=je(h)),Cn(f,h,t,i,r),n[a]=h,a--,l--,u>a||u>l)break e;f=n[a],h=e[l]}}if(u>a){if(u<=l){d=l+1;for(var p=dl)for(;u<=a;)kt(n[u++],t);else{var m=u,y=u,g=a-u+1,k=l-u+1,x=[];for(c=0;cm;)kt(n[m++],t);O>u?C=!0:O=u,h.dom&&(e[u]=h=je(h)),Cn(f,h,t,i,r),w++;break}!b&&u>l&&kt(f,t)}else b||kt(f,t);else{var v={};for(c=y;c<=l;c++)v[e[c].key]=c;for(c=m;c<=a;c++)if(f=n[c],wm;)kt(n[m++],t);h=e[u],x[u-y]=c+1,O>u?C=!0:O=u,h.dom&&(e[u]=h=je(h)),Cn(f,h,t,i,r),w++}else b||kt(f,t);else b||kt(f,t)}if(b)Pa(t,n),$s(e,t,i,r);else if(C){var A=PO(x);for(u=A.length-1,c=k-1;c>=0;c--)x[c]===0?(O=c+y,h=e[O],h.dom&&(e[O]=h=je(h)),d=O+1,Ma(t,Ke(h,null,i,r),d=0;c--)x[c]===0&&(O=c+y,h=e[O],h.dom&&(e[O]=h=je(h)),d=O+1,Ma(t,Ke(h,null,i,r),d0&&(e[i]=t[s-1]),t[s]=i)}}for(s=t.length,o=t[s-1];s-- >0;)t[s]=o,o=e[o];return t}function or(n,e,t){if(n!==ru){var i=e.$V;if(Z(i)?Yn(n)||(n.dom&&(n=je(n)),fe(e.firstChild)?(Ke(n,e,Me,!1),e.$V=n):CO(n,e),i=n):Z(n)?(kt(i,e),e.$V=null):(n.dom&&(n=je(n)),Cn(i,n,e,Me,!1),i=e.$V=n),sn.length>0&&lu(sn),G(t)&&t(),G(Ct.renderComplete)&&Ct.renderComplete(i),i&&i.flags&14)return i.children}}function Em(n,e){return E(1024,e,null,n,0,null,Yn(n)?null:n.key,null)}var om=typeof Promise=="undefined"?null:Promise.resolve(),DO=typeof requestAnimationFrame=="undefined"?setTimeout:requestAnimationFrame.bind(window);function BO(n){return om?om.then(n):DO(n)}function am(n,e,t,i){G(e)&&(e=e(n.state,n.props,n.context));var r=n.$PS;if(Z(r))n.$PS=e;else for(var s in e)r[s]=e[s];if(!n.$PSS&&!n.$BR)if(!n.$UPD)n.$PSS=!0,n.$UPD=!0,Am(n,i,t),n.$UPD=!1;else{var o=n.$QU;fe(o)&&(o=n.$QU=[],BO(IO(n,o))),G(t)&&o.push(t)}else n.$PSS=!0,n.$BR&&G(t)&&sn.push(t.bind(n))}function IO(n,e){return function(){n.$QU=null,n.$UPD=!0,Am(n,!1,function(){for(var t=0,i=e.length;t0,e,!0),n.$UN)return;if((n.$LI.flags&1024)===0)for(var f=n.$LI.dom;!fe(l=l.parentVNode);)(l.flags&14)>0&&(l.dom=f);sn.length>0&&lu(sn)}else n.state=n.$PS,n.$PS=null;G(t)&&t.call(n)}}var z=(function(){function n(t,i){this.state=null,this.props=void 0,this.context=void 0,this.refs=void 0,this.$BR=!1,this.$BS=!0,this.$PSS=!1,this.$PS=null,this.$LI=null,this.$V=null,this.$UN=!1,this.$CX=null,this.$UPD=!0,this.$QU=null,this.props=t||Me,this.context=i||Me}var e=n.prototype;return e.forceUpdate=function(i){this.$UN||am(this,{},i,!0)},e.setState=function(i,r){if(!this.$UN)if(!this.$BS)am(this,i,r,!1);else return},e.render=function(i,r,s){},n})();z.defaultProps=void 0;var _m='';function pu(n){var e=''+_m+"",t=le(e);n.appendChild(t),Oa.bind(t,"click",function(i){FO(),i.preventDefault()})}var Kn=class extends z{constructor(e,t){super(e,t),this.node=null}componentDidMount(){pu(this.node)}render(){return E(1,"div",null,null,1,null,null,e=>this.node=e)}};function mu(n){return n.join(";")}var LO=mu(["z-index: 1001","position: fixed","top: 0","left: 0","right: 0","bottom: 0"]),$O=mu(["width: 100%","height: 100%","background: rgba(40,40,40,0.2)"]),NO=mu(["position: absolute","left: 50%","top: 40%","transform: translate(-50%)","width: 260px","padding: 10px","background: white","box-shadow: 0 1px 4px rgba(0,0,0,0.3)","font-family: Helvetica, Arial, sans-serif","font-size: 14px","display: flex","line-height: 1.3"]),qO='
'+_m+'Web-based tooling for BPMN, DMN and CMMN diagrams powered by bpmn.io.
',Vs;function FO(){Vs||(Vs=le(qO),On.bind(Vs,".backdrop","click",function(n){document.body.removeChild(Vs)})),document.body.appendChild(Vs)}function jO(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var gu={exports:{}},Tm;function VO(){if(Tm)return gu.exports;Tm=1;var n=gu.exports=function(e,t){if(t||(t=16),e===void 0&&(e=128),e<=0)return"0";for(var i=Math.log(Math.pow(2,e))/Math.log(t),r=2;i===1/0;r*=2)i=Math.log(Math.pow(2,e/r))/Math.log(t)*r;for(var s=i-Math.floor(i),o="",r=0;r=Math.pow(2,e)?n(e,t):o};return n.rack=function(e,t,i){var r=function(o){var a=0;do{if(a++>10)if(i)e+=i;else throw new Error("too many ID collisions, use more bits");var l=n(e,t)}while(Object.hasOwnProperty.call(s,l));return s[l]=o,l},s=r.hats={};return r.get=function(o){return r.hats[o]},r.set=function(o,a){return r.hats[o]=a,r},r.bits=e||128,r.base=t||16,r},gu.exports}var QO=VO(),zO=jO(QO);function an(n){if(!(this instanceof an))return new an(n);n=n||[128,36,1],this._seed=n.length?zO.rack(n[0],n[1],n[2]):n}an.prototype.next=function(n){return this._seed(n||!0)};an.prototype.nextPrefixed=function(n,e){var t;do t=n+this.next(!0);while(this.assigned(t));return this.claim(t,e),t};an.prototype.claim=function(n,e){this._seed.set(n,e||!0)};an.prototype.assigned=function(n){return this._seed.get(n)||!1};an.prototype.unclaim=function(n){delete this._seed.hats[n]};an.prototype.clear=function(){var n=this._seed.hats,e;for(e in n)this.unclaim(e)};var WO=new an,La="hsl(225, 10%, 15%)";function Qs(n,e,t,i,r,s){it.call(this,e);var o=WO.next(),a=i.computeStyle,l={},c=n&&n.defaultFillColor||"white",u=n&&n.defaultStrokeColor||La,f=n&&n.defaultLabelColor;function h(w,v,A){var S=w+"-"+Rm(v)+"-"+Rm(A)+"-"+o;return l[S]||p(S,w,v,A),"url(#"+S+")"}function d(w,v){var A=D({strokeWidth:1,strokeLinecap:"round",strokeDasharray:"none"},v.attrs),S=v.ref||{x:0,y:0},M=v.scale||1;A.strokeDasharray==="none"&&(A.strokeDasharray=[1e4,1]);var _=ie("marker");K(v.element,A),ve(_,v.element),K(_,{id:w,viewBox:"0 0 20 20",refX:S.x,refY:S.y,markerWidth:20*M,markerHeight:20*M,orient:"auto"});var P=jt("defs",s._svg);P||(P=ie("defs"),ve(s._svg,P)),ve(P,_),l[w]=_}function p(w,v,A,S){if(v==="association-start"){var M=ie("path");K(M,{d:"M 11 5 L 1 10 L 11 15"}),d(w,{element:M,attrs:{fill:"none",stroke:S,strokeWidth:1.5},ref:{x:1,y:10},scale:.5})}else if(v==="association-end"){var _=ie("path");K(_,{d:"M 1 5 L 11 10 L 1 15"}),d(w,{element:_,attrs:{fill:"none",stroke:S,strokeWidth:1.5},ref:{x:12,y:10},scale:.5})}else if(v==="information-requirement-end"){var P=ie("path");K(P,{d:"M 1 5 L 11 10 L 1 15 Z"}),d(w,{element:P,attrs:{fill:S,stroke:"none"},ref:{x:11,y:10},scale:1})}else if(v==="knowledge-requirement-end"){var j=ie("path");K(j,{d:"M 1 3 L 11 10 L 1 17"}),d(w,{element:j,attrs:{fill:"none",stroke:S,strokeWidth:2},ref:{x:11,y:10},scale:.8})}else if(v==="authority-requirement-end"){var oe=ie("circle");K(oe,{cx:3,cy:3,r:3}),d(w,{element:oe,attrs:{fill:S,stroke:"none"},ref:{x:3,y:3},scale:.9})}}function m(w,v,A,S,M,_){dt(M)&&(_=M,M=0),M=M||0,_=a(_,{stroke:La,strokeWidth:2,fill:"white"});var P=ie("rect");return K(P,{x:M,y:M,width:v-M*2,height:A-M*2,rx:S,ry:S}),K(P,_),ve(w,P),P}function y(w,v,A){var S=r.createText(v||"",A);return tr(S,"class","djs-label"),ve(w,S),S}function g(w,v,A,S){var M=Zp(v);return S=D({box:v,align:A,padding:5,style:{fill:Pm(v,f,u)}},S),y(w,M,S)}function k(w,v,A){A=a(A,["no-fill"],{strokeWidth:2,stroke:La});var S=ie("path");return K(S,{d:v}),K(S,A),ve(w,S),S}var x={"dmn:Decision":function(w,v){var A=m(w,v.width,v.height,0,{stroke:ln(v,u),fill:Gn(v,c)});return g(w,v,"center-middle"),A},"dmn:KnowledgeSource":function(w,v){var A=t.getScaledPath("KNOWLEDGE_SOURCE",{xScaleFactor:1.021,yScaleFactor:1,containerWidth:v.width,containerHeight:v.height,position:{mx:0,my:.075}}),S=k(w,A,{strokeWidth:2,fill:Gn(v,c),stroke:ln(v,u)});return g(w,v,"center-middle"),S},"dmn:BusinessKnowledgeModel":function(w,v){var A=t.getScaledPath("BUSINESS_KNOWLEDGE_MODEL",{xScaleFactor:1,yScaleFactor:1,containerWidth:v.width,containerHeight:v.height,position:{mx:0,my:.3}}),S=k(w,A,{strokeWidth:2,fill:Gn(v,c),stroke:ln(v,u)});return g(w,v,"center-middle"),S},"dmn:InputData":function(w,v){var A=m(w,v.width,v.height,22,{stroke:ln(v,u),fill:Gn(v,c)});return g(w,v,"center-middle"),A},"dmn:TextAnnotation":function(w,v){var A={fill:"none",stroke:"none"},S=m(w,v.width,v.height,0,0,A),M=t.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:v.width,containerHeight:v.height,position:{mx:0,my:0}});k(w,M,{stroke:ln(v,u)});var _=Mm(v).text||"";return y(w,_,{style:{fill:Pm(v,f,u)},box:v,align:"left-top",padding:5}),S},"dmn:Association":function(w,v){var A=Mm(v),S=Gn(v,c),M=ln(v,u),_={stroke:M,strokeDasharray:"0.5, 5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"};return(A.associationDirection==="One"||A.associationDirection==="Both")&&(_.markerEnd=h("association-end",S,M)),A.associationDirection==="Both"&&(_.markerStart=h("association-start",S,M)),O(w,v.waypoints,_)},"dmn:InformationRequirement":function(w,v){var A=Gn(v,c),S=ln(v,u),M={stroke:S,strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:h("information-requirement-end",A,S)};return O(w,v.waypoints,M)},"dmn:KnowledgeRequirement":function(w,v){var A=Gn(v,c),S=ln(v,u),M={stroke:S,strokeWidth:1,strokeDasharray:5,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:h("knowledge-requirement-end",A,S)};return O(w,v.waypoints,M)},"dmn:AuthorityRequirement":function(w,v){var A=Gn(v,c),S=ln(v,u),M={stroke:S,strokeWidth:1.5,strokeDasharray:5,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:h("authority-requirement-end",A,S)};return O(w,v.waypoints,M)}};function b(w,v){var A=x[v.type];return A?A(w,v):it.prototype.drawShape.apply(this,[w,v])}function C(w,v){var A=v.type,S=x[A];return S?S(w,v):it.prototype.drawConnection.apply(this,[w,v])}function O(w,v,A){A=a(A,["no-fill"],{stroke:La,strokeWidth:2,fill:"none"});var S=ir(v,A);return ve(w,S),S}this.canRender=function(w){return Q(w,"dmn:DMNElement")||Q(w,"dmn:InformationRequirement")||Q(w,"dmn:KnowledgeRequirement")||Q(w,"dmn:AuthorityRequirement")},this.drawShape=b,this.drawConnection=C}Vt(Qs,it);Qs.$inject=["config.drdRenderer","eventBus","pathMap","styles","textRenderer","canvas"];function Mm(n){return n.businessObject}function Rm(n){return n.replace(/[^0-9a-zA-z]+/g,"_")}function ln(n,e){return e}function Gn(n,e){return e}function Pm(n,e,t){return e||ln(n,t)}var HO=0,XO={width:150,height:50};function UO(n){var e=n.split("-");return{horizontal:e[0]||"center",vertical:e[1]||"top"}}function YO(n){return dt(n)?D({top:0,left:0,right:0,bottom:0},n):{top:n,left:n,right:n,bottom:n}}var yu=null;function KO(){return yu||(yu=document.createElement("canvas").getContext("2d")),yu}function GO(n){var e=[];return n.fontStyle&&e.push(n.fontStyle),n.fontVariant&&e.push(n.fontVariant),n.fontWeight&&e.push(n.fontWeight),n.fontStretch&&e.push(n.fontStretch),e.push(Bm(n.fontSize)||"12px"),e.push(n.fontFamily||"sans-serif"),e.join(" ")}function Bm(n){if(n!=null)return typeof n=="number"||/^-?\d+(\.\d+)?$/.test(n)?n+"px":n}function JO(n,e){var t=KO();if(!t)return{width:0,height:0};t.font=GO(e),"letterSpacing"in t&&(t.letterSpacing=Bm(e.letterSpacing)||"0px");var i=n==="",r=i?"dummy":n.replace(/\s+$/,""),s=t.measureText(r);return{width:i?0:s.width,height:"fontBoundingBoxAscent"in s?s.fontBoundingBoxAscent+s.fontBoundingBoxDescent:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent}}function ZO(n,e,t){for(var i=n.shift(),r=i,s;;){if(s=JO(r,t),s.width=r?s.width:0,r===" "||r===""||s.width1)for(;i=t.shift();)if(i.length+sy?g.width:y},0),d=s.top;r.vertical==="middle"&&(d+=(t.height-f)/2),d-=(a||c[0].height)/4;var p=ie("text");K(p,i),B(c,function(y){var g;switch(d+=a||y.height,r.horizontal){case"left":g=s.left;break;case"right":g=(o?h:u)-s.right-y.width;break;default:g=Math.max(((o?h:u)-y.width)/2+s.left,0)}var k=ie("tspan");K(k,{x:g,y:d}),k.textContent=y.text,ve(p,k)});var m={width:h,height:f};return{dimensions:m,element:p}};function ik(n){if("fontSize"in n&&"lineHeight"in n)return n.lineHeight*parseInt(n.fontSize,10)}var rk=12,sk=1.2,ok=30;function $a(n){var e=D({fontFamily:"Arial, sans-serif",fontSize:rk,fontWeight:"normal",lineHeight:sk},n&&n.defaultStyle||{}),t=parseInt(e.fontSize,10)-1,i=D({},e,{fontSize:t},n&&n.externalStyle||{}),r=new ar({style:e});this.getExternalLabelBounds=function(s,o){var a=r.getDimensions(o,{box:{width:90,height:30,x:s.width/2+s.x,y:s.height/2+s.y},style:i});return{x:Math.round(s.x+s.width/2-a.width/2),y:Math.round(s.y),width:Math.ceil(a.width),height:Math.ceil(a.height)}},this.getTextAnnotationBounds=function(s,o){var a=r.getDimensions(o,{box:s,style:e,align:"left-top",padding:5});return{x:s.x,y:s.y,width:s.width,height:Math.max(ok,Math.round(a.height))}},this.createText=function(s,o){return r.createText(s,o||{})},this.getDefaultStyle=function(){return e},this.getExternalStyle=function(){return i}}$a.$inject=["config.textRenderer"];function vu(){this.pathMap={KNOWLEDGE_SOURCE:{d:"m {mx},{my} l 0,{e.y0} c {e.x0},{e.y1} {e.x1},-{e.y2} {e.x2},-{e.y3} c {e.x3},-{e.y4} {e.x4},{e.y5} {e.x5},{e.y6} l 0,-{e.y7}z",width:100,height:65,widthElements:[29.8,48.4,67.2,12.2,19.8,30.8],heightElements:[55.3,19.7,4.2,6.7,2.3,1.6,6.2,54.6]},BUSINESS_KNOWLEDGE_MODEL:{d:"m {mx},{my} l {e.x0},-{e.y0} l {e.x1},0 l 0,{e.y1} l -{e.x2},{e.y2} l -{e.x3},0z",width:125,height:45,widthElements:[13.8,109.2,13.8,109.1],heightElements:[13.2,29.8,13.2]},TEXT_ANNOTATION:{d:"m {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0",width:10,height:30,widthElements:[10],heightElements:[30]}},this.getRawPath=function(e){return this.pathMap[e].d},this.getScaledPath=function(e,t){var i=this.pathMap[e],r,s;t.abspos?(r=t.abspos.x,s=t.abspos.y):(r=t.containerWidth*t.position.mx,s=t.containerHeight*t.position.my);var o={};if(t.position){for(var a=t.containerHeight/i.height*t.yScaleFactor,l=t.containerWidth/i.width*t.xScaleFactor,c=0;c");return r(M,A,S)}var f="svg, .djs-element";function h(v,A,S,M){var _=s[S]=function(P){r(S,P)};M&&(c[S]=M),_.$delegate=On.bind(v,f,A,_)}function d(v,A,S){var M=o(S);M&&On.unbind(v,A,M.$delegate)}function p(v){B(l,function(A,S){h(v,S,A)})}function m(v){B(l,function(A,S){d(v,S,A)})}n.on("canvas.destroy",function(v){m(v.svg)}),n.on("canvas.init",function(v){p(v.svg)}),n.on(["shape.added","connection.added"],function(v){var A=v.element,S=v.gfx;n.fire("interactionEvents.createHit",{element:A,gfx:S})}),n.on(["shape.changed","connection.changed"],Vm,function(v){var A=v.element,S=v.gfx;n.fire("interactionEvents.updateHit",{element:A,gfx:S})}),n.on("interactionEvents.createHit",Vm,function(v){var A=v.element,S=v.gfx;i.createDefaultHit(A,S)}),n.on("interactionEvents.updateHit",function(v){var A=v.element,S=v.gfx;i.updateDefaultHit(A,S)});var y=C("djs-hit djs-hit-stroke"),g=C("djs-hit djs-hit-click-stroke"),k=C("djs-hit djs-hit-all"),x=C("djs-hit djs-hit-no-move"),b={all:k,"click-stroke":g,stroke:y,"no-move":x};function C(v,A){return A=D({stroke:"white",strokeWidth:15},A||{}),t.cls(v,["no-fill","no-border"],A)}function O(v,A){var S=b[A];if(!S)throw new Error("invalid hit type <"+A+">");return K(v,S),v}function w(v,A){ve(v,A)}this.removeHits=function(v){var A=gp(".djs-hit",v);B(A,bi)},this.createDefaultHit=function(v,A){var S=v.waypoints,M=v.isFrame,_;return S?this.createWaypointsHit(A,S):(_=M?"stroke":"all",this.createBoxHit(A,_,{width:v.width,height:v.height}))},this.createWaypointsHit=function(v,A){var S=ir(A);return O(S,"stroke"),w(v,S),S},this.createBoxHit=function(v,A,S){S=D({x:0,y:0},S);var M=ie("rect");return O(M,A),K(M,S),w(v,M),M},this.updateDefaultHit=function(v,A){var S=jt(".djs-hit",A);if(S)return v.waypoints?Xc(S,v.waypoints):K(S,{width:v.width,height:v.height}),S},this.fire=r,this.triggerMouseEvent=u,this.mouseHandler=o,this.registerEvent=h,this.unregisterEvent=d}qa.$inject=["eventBus","elementRegistry","styles"];var Qm={__init__:["interactionEvents"],interactionEvents:["type",qa]};function Jn(n,e){this._eventBus=n,this._canvas=e,this._selectedElements=[];var t=this;n.on(["shape.remove","connection.remove"],function(i){var r=i.element;t.deselect(r)}),n.on(["diagram.clear","root.set"],function(i){t.select(null)})}Jn.$inject=["eventBus","canvas"];Jn.prototype.deselect=function(n){var e=this._selectedElements,t=e.indexOf(n);if(t!==-1){var i=e.slice();e.splice(t,1),this._eventBus.fire("selection.changed",{oldSelection:i,newSelection:e})}};Jn.prototype.get=function(){return this._selectedElements};Jn.prototype.isSelected=function(n){return this._selectedElements.indexOf(n)!==-1};Jn.prototype.select=function(n,e){var t=this._selectedElements,i=t.slice();_e(n)||(n=n?[n]:[]);var r=this._canvas,s=r.getRootElement();n=n.filter(function(o){var a=r.findRoot(o);return s===a}),e?B(n,function(o){t.indexOf(o)===-1&&t.push(o)}):this._selectedElements=t=n.slice(),this._eventBus.fire("selection.changed",{oldSelection:i,newSelection:t})};var zm="hover",Wm="selected";function Fa(n,e){this._canvas=n;function t(r,s){n.addMarker(r,s)}function i(r,s){n.removeMarker(r,s)}e.on("element.hover",function(r){t(r.element,zm)}),e.on("element.out",function(r){i(r.element,zm)}),e.on("selection.changed",function(r){function s(c){i(c,Wm)}function o(c){t(c,Wm)}var a=r.oldSelection,l=r.newSelection;B(a,function(c){l.indexOf(c)===-1&&s(c)}),B(l,function(c){a.indexOf(c)===-1&&o(c)})})}Fa.$inject=["canvas","eventBus"];function ja(n,e,t,i){n.on("create.end",500,function(r){var s=r.context,o=s.canExecute,a=s.elements,l=s.hints||{},c=l.autoSelect;if(o){if(c===!1)return;_e(c)?e.select(c):e.select(a.filter(dk))}}),n.on("connect.end",500,function(r){var s=r.context,o=s.connection;o&&e.select(o)}),n.on("shape.move.end",500,function(r){var s=r.previousSelection||[],o=i.get(r.context.shape.id),a=we(s,function(l){return o.id===l.id});a||e.select(o)}),n.on("element.click",function(r){if(lr(r)){var s=r.element;s===t.getRootElement()&&(s=null);var o=e.isSelected(s),a=e.get().length>1,l=jm(r);if(o&&a)return l?e.deselect(s):e.select(s);o?e.deselect(s):e.select(s,l)}})}ja.$inject=["eventBus","selection","canvas","elementRegistry"];function dk(n){return!n.hidden}var Hm={__init__:["selectionVisuals","selectionBehavior"],__depends__:[Qm],selection:["type",Jn],selectionVisuals:["type",Fa],selectionBehavior:["type",ja]};function Va(n){this._counter=0,this._prefix=(n?n+"-":"")+Math.floor(Math.random()*1e9)+"-"}Va.prototype.next=function(){return this._prefix+ ++this._counter};var pk=new Va("ov"),mk=500;function ke(n,e,t,i){this._eventBus=e,this._canvas=t,this._elementRegistry=i,this._ids=pk,this._overlayDefaults=D({show:null,scale:!0},n&&n.defaults),this._overlays={},this._overlayContainers=[],this._overlayRoot=gk(t.getContainer()),this._init()}ke.$inject=["config.overlays","eventBus","canvas","elementRegistry"];ke.prototype.get=function(n){if(tt(n)&&(n={id:n}),tt(n.element)&&(n.element=this._elementRegistry.get(n.element)),n.element){var e=this._getOverlayContainer(n.element,!0);return e?n.type?Qn(e.overlays,Cc({type:n.type})):e.overlays.slice():[]}else return n.type?Qn(this._overlays,Cc({type:n.type})):n.id?this._overlays[n.id]:null};ke.prototype.add=function(n,e,t){if(dt(e)&&(t=e,e=null),n.id||(n=this._elementRegistry.get(n)),!t.position)throw new Error("must specifiy overlay position");if(!t.html)throw new Error("must specifiy overlay html");if(!n)throw new Error("invalid element specified");var i=this._ids.next();return t=D({},this._overlayDefaults,t,{id:i,type:e,element:n,html:t.html}),this._addOverlay(t),i};ke.prototype.remove=function(n){var e=this.get(n)||[];_e(e)||(e=[e]);var t=this;B(e,function(i){var r=t._getOverlayContainer(i.element,!0);if(i&&(Le(i.html),Le(i.htmlContainer),delete i.htmlContainer,delete i.element,delete t._overlays[i.id]),r){var s=r.overlays.indexOf(i);s!==-1&&r.overlays.splice(s,1)}})};ke.prototype.isShown=function(){return this._overlayRoot.style.display!=="none"};ke.prototype.show=function(){Qa(this._overlayRoot)};ke.prototype.hide=function(){Qa(this._overlayRoot,!1)};ke.prototype.clear=function(){this._overlays={},this._overlayContainers=[],wa(this._overlayRoot)};ke.prototype._updateOverlayContainer=function(n){var e=n.element,t=n.html,i=e.x,r=e.y;if(e.waypoints){var s=wi(e);i=s.x,r=s.y}Xm(t,i,r),tr(n.html,"data-container-id",e.id)};ke.prototype._updateOverlay=function(n){var e=n.position,t=n.htmlContainer,i=n.element,r=e.left,s=e.top;if(e.right!==void 0){var o;i.waypoints?o=wi(i).width:o=i.width,r=e.right*-1+o}if(e.bottom!==void 0){var a;i.waypoints?a=wi(i).height:a=i.height,s=e.bottom*-1+a}Xm(t,r||0,s||0),this._updateOverlayVisibilty(n,this._canvas.viewbox())};ke.prototype._createOverlayContainer=function(n){var e=le('
');yi(e,{position:"absolute"}),this._overlayRoot.appendChild(e);var t={html:e,element:n,overlays:[]};return this._updateOverlayContainer(t),this._overlayContainers.push(t),t};ke.prototype._updateRoot=function(n){var e=n.scale||1,t="matrix("+[e,0,0,e,-1*n.x*e,-1*n.y*e].join(",")+")";Um(this._overlayRoot,t)};ke.prototype._getOverlayContainer=function(n,e){var t=we(this._overlayContainers,function(i){return i.element===n});return!t&&!e?this._createOverlayContainer(n):t};ke.prototype._addOverlay=function(n){var e=n.id,t=n.element,i=n.html,r,s;i.get&&i.constructor.prototype.jquery&&(i=i.get(0)),tt(i)&&(i=le(i)),s=this._getOverlayContainer(t),r=le('
'),yi(r,{position:"absolute"}),r.appendChild(i),n.type&&vi(r).add("djs-overlay-"+n.type);var o=this._canvas.findRoot(t),a=this._canvas.getRootElement();Qa(r,o===a),n.htmlContainer=r,s.overlays.push(n),s.html.appendChild(r),this._overlays[e]=n,this._updateOverlay(n),this._updateOverlayVisibilty(n,this._canvas.viewbox())};ke.prototype._updateOverlayVisibilty=function(n,e){var t=n.show,i=this._canvas.findRoot(n.element),r=t&&t.minZoom,s=t&&t.maxZoom,o=n.htmlContainer,a=this._canvas.getRootElement(),l=!0;(i!==a||t&&(ht(r)&&r>e.scale||ht(s)&&sr&&(o=(1/e.scale||1)*r)),ht(o)&&(a="scale("+o+","+o+")"),Um(s,a)};ke.prototype._updateOverlaysVisibilty=function(n){var e=this;B(this._overlays,function(t){e._updateOverlayVisibilty(t,n)})};ke.prototype._init=function(){var n=this._eventBus,e=this;function t(i){e._updateRoot(i),e._updateOverlaysVisibilty(i),e.show()}n.on("canvas.viewbox.changing",function(i){e.hide()}),n.on("canvas.viewbox.changed",function(i){t(i.viewbox)}),n.on(["shape.remove","connection.remove"],function(i){var r=i.element,s=e.get({element:r});B(s,function(l){e.remove(l.id)});var o=e._getOverlayContainer(r);if(o){Le(o.html);var a=e._overlayContainers.indexOf(o);a!==-1&&e._overlayContainers.splice(a,1)}}),n.on("element.changed",mk,function(i){var r=i.element,s=e._getOverlayContainer(r,!0);s&&(B(s.overlays,function(o){e._updateOverlay(o)}),e._updateOverlayContainer(s))}),n.on("element.marker.update",function(i){var r=e._getOverlayContainer(i.element,!0);r&&vi(r.html)[i.add?"add":"remove"](i.marker)}),n.on("root.set",function(){e._updateOverlaysVisibilty(e._canvas.viewbox())}),n.on("diagram.clear",this.clear,this)};function gk(n){var e=le('
');return yi(e,{position:"absolute",width:0,height:0}),n.insertBefore(e,n.firstChild),e}function Xm(n,e,t){yi(n,{left:e+"px",top:t+"px"})}function Qa(n,e){n.style.display=e===!1?"none":""}function Um(n,e){n.style["transform-origin"]="top left",["","-ms-","-webkit-"].forEach(function(t){n.style[t+"transform"]=e})}var za={__init__:["overlays"],overlays:["type",ke]};function cr(n,e,t){this._eventBus=n,this._canvas=e,this._translate=t,n.on("diagram.init",function(){this._init()},this),n.on("import.done",function(i){i.error||this.update()},this),this.HTML_MARKUP='
'}cr.$inject=["eventBus","canvas","translate"];cr.prototype._init=function(){var n=this._canvas,e=this._eventBus,t=n.getContainer(),i=this._container=le(this.HTML_MARKUP);t.appendChild(i),this.nameElement=jt(".dmn-definitions-name",this._container),this.idElement=jt(".dmn-definitions-id",this._container),On.bind(i,".dmn-definitions-name, .dmn-definitions-id","mousedown",function(r){r.stopPropagation()}),e.fire("definitionIdView.create",{html:i})};cr.prototype.update=function(){var n=this._canvas.getRootElement().businessObject;this.nameElement.textContent=n.name,this.idElement.textContent=n.id};function Wa(n,e){function t(i,r){var s=e.getContainer();vi(s).toggle(i,r)}n.on("palette.create",function(){t("with-palette",!0)}),n.on("palette.changed",function(i){t("with-palette-two-column",i.twoColumn)})}Wa.$inject=["eventBus","canvas"];var Ym={__depends__:[rt],__init__:["definitionPropertiesView","definitionPropertiesPaletteAdapter"],definitionPropertiesView:["type",cr],definitionPropertiesPaletteAdapter:["type",Wa]};var Km=[{className:"dmn-icon-decision-table",matches:function(n){var e=Ot(n);return Q(e,"dmn:Decision")&&Q(e.decisionLogic,"dmn:DecisionTable")},title:"Open decision table"},{className:"dmn-icon-literal-expression",matches:function(n){var e=Ta(n);return Q(e,"dmn:LiteralExpression")},title:"Open literal expression"}],ur=class{constructor(e,t,i,r,s){this._injector=e,this._eventBus=t,this._overlays=i,this._translate=s,this._config=r||{enabled:!0},t.on(["shape.added"],({element:o})=>{for(let l=0;l{s.fire("drillDown.click",{element:e})!==!1&&this.drillDown(e)})}drillDown(e){let t=this._injector.get("_parent",!1);if(!t)return!1;let i=t.getView(e.businessObject);return i?(t.open(i),!0):!1}};ur.$inject=["injector","eventBus","overlays","config.drillDown","translate"];var Gm={__depends__:[za,rt],__init__:["drillDown"],drillDown:["type",ur]};function Ve(n){this._container=this._createContainer(),pu(this._container),this._init(this._container,n)}Vt(Ve,kn);Ve.prototype.saveSVG=nr(function(n){var e=this;return new Promise(function(t){var i=e.get("canvas"),r=i.getActiveLayer(),s=jt("defs",i._svg),o=Mp(r),a=s&&s.outerHTML||"",l=r.getBBox(),c=` '+a+o+"";t({svg:c})})});Ve.prototype.getModules=function(){return this._modules};Ve.prototype.destroy=function(){kn.prototype.destroy.call(this),Le(this._container)};Ve.prototype.on=function(n,e,t,i){return this.get("eventBus").on(n,e,t,i)};Ve.prototype.off=function(n,e){this.get("eventBus").off(n,e)};Ve.prototype._init=function(n,e){var{additionalModules:t,canvas:i,...r}=e,s=e.modules||this.getModules(),o=[{drd:["value",this]}],a=[...o,...s,...t||[]],l={...r,canvas:{...i,container:n},modules:a};kn.call(this,l),e&&e.container&&this.attachTo(e.container)};Ve.prototype._emit=function(n,e){return this.get("eventBus").fire(n,e)};Ve.prototype._createContainer=function(){return le('
')};Ve.prototype.open=function(n){var e=this;return new Promise((t,i)=>{var r;try{return e._definitions&&e.clear(),e._definitions=n,tm(e,n,function(s,o){s?(s.warnings=o||[],i(s)):t({warnings:o||[]})})}catch(s){r=s}r?(r.warnings=r.warnings||[],i(r)):t({warnings:[]})})};Ve.prototype.attachTo=function(n){if(!n)throw new Error("parentNode required");this.detach();var e=this._container;n.appendChild(e),this._emit("attach",{}),this.get("canvas").resized()};Ve.prototype.detach=function(){var n=this._container,e=n.parentNode;e&&(this._emit("detach",{}),e.removeChild(n))};Ve.prototype._modules=[Nm,rt,Hm,za,Ym,Gm];var fr=class{constructor(e){D(this,e),En(this,"businessObject",{writable:!0})}},Ou=class extends fr{constructor(e){super(e),En(this,"rows",{enumerable:!0,value:this.rows||[]}),En(this,"cols",{enumerable:!0,value:this.cols||[]})}},ku=class extends fr{constructor(e){super(e),En(this,"root",{writable:!0}),En(this,"cells",{enumerable:!0,value:this.cells||[]})}},Cu=class extends fr{constructor(e){super(e),En(this,"root",{writable:!0}),En(this,"cells",{enumerable:!0,value:this.cells||[]})}},Su=class extends fr{constructor(e){super(e),En(this,"row",{writable:!0}),En(this,"col",{writable:!0})}},yk={root:Ou,row:ku,col:Cu,cell:Su};function Jm(n,e){let t=yk[n];if(!t)throw new Error("unknown type "+n);return new t(e)}function En(n,e,t){Object.defineProperty(n,e,t)}var zs=class{constructor(){this._uid=12}create(e,t={}){return t.id||(t.id=e+"_"+this._uid++),Jm(e,t)}createRoot(e){return this.create("root",e)}createRow(e){return this.create("row",e)}createCol(e){return this.create("col",e)}createCell(e){return this.create("cell",e)}};var hr=class{constructor(e){this._eventBus=e,this._elements={},e.on("table.clear",this.clear.bind(this))}add(e,t){let{id:i}=e;this._elements[i]=e}remove(e){let t=e.id||e;delete this._elements[t]}get(e){return this._elements[e]}getAll(){return Eu(this._elements)}forEach(e){Eu(this._elements).forEach(t=>e(t))}filter(e){return Eu(this._elements).filter(t=>e(t))}clear(){this._elements={}}updateId(e,t){this._validateId(t),typeof e=="string"&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t}),this.remove(e),e.id=t,this.add(e)}_validateId(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")}};hr.$inject=["eventBus"];function Eu(n){return Object.keys(n).map(function(e){return n[e]})}var dr=class{constructor(e){this._listeners={},e.on("elements.changed",({elements:t})=>{this.elementsChanged(t)}),e.on("root.remove",t=>{let i=t.root.id;this._listeners[i]&&e.once("root.add",r=>{let s=r.root.id;this.updateId(i,s)})}),e.on("element.updateId",({element:t,newId:i})=>{this.updateId(t.id,i)})}elementsChanged(e){let t={},i=e.length;for(let r=0;rF(2,l,null,c)),E(1,"div","tjs-table-container",E(1,"table","tjs-table",[s&&F(2,s,{rows:e,cols:t}),o&&F(2,o,{rows:e,cols:t}),a&&F(2,a,{rows:e,cols:t})],0),2,{onScroll:this.onScroll}),r&&r.map((l,c)=>F(2,l,null,c))],0)}};var pr=class{constructor(e,t,i,r,s){let{container:o}=i;this._container=o,r.on("root.added",()=>{or(F(2,Hs,{injector:s}),o)}),r.on("root.remove",()=>{or(null,o)})}getContainer(){return this._container}};pr.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var Ha={__init__:["changeSupport","components","renderer"],changeSupport:["type",dr],components:["type",Ws],renderer:["type",pr]};var mr=class{constructor(e,t){this._elementRegistry=e,this._eventBus=t,this._root=null,t.on("table.clear",()=>{this.setRoot(null)})}setRoot(e){if(this._root){let t=this._root;this._eventBus.fire("root.remove",{root:t}),this._root=null,this._eventBus.fire("root.removed",{root:t})}e&&this._eventBus.fire("root.add",{root:e}),this._root=e,e&&this._eventBus.fire("root.added",{root:e})}getRoot(){return this._root||this.setRoot({id:"__implicitroot",rows:[],cols:[]}),this._root}addRow(e,t){let i=this.getRoot();if(i.cols.length!=e.cells.length)throw new Error("number of cells is not equal to number of cols");return typeof t=="undefined"&&(t=i.rows.length),Xa(t,i.rows,e),e.root=i,this._elementRegistry.add(e),e.cells.forEach((r,s)=>{this._elementRegistry.add(r),r.row=e,r.col=i.cols[s],Xa(t,i.cols[s].cells,r)}),this._eventBus.fire("row.add",{row:e}),e}removeRow(e){let t=this.getRoot();typeof e=="string"&&(e=this._elementRegistry.get(e));let i=t.rows.indexOf(e);i!==-1&&(Ua(i,t.rows),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach((r,s)=>{this._elementRegistry.remove(r),r.col=void 0,Ua(i,t.cols[s].cells)}),this._eventBus.fire("row.remove",{row:e}))}addCol(e,t){let i=this.getRoot();if(this._elementRegistry.add(e),i.rows.length!=e.cells.length)throw new Error("number of cells is not equal to number of rows");return typeof t=="undefined"&&(t=i.cols.length),Xa(t,i.cols,e),e.root=i,e.cells.forEach((r,s)=>{this._elementRegistry.add(r),r.col=e,r.row=i.rows[s],Xa(t,i.rows[s].cells,r)}),this._eventBus.fire("col.add",{col:e}),e}removeCol(e){let t=this.getRoot();typeof e=="string"&&(e=this._elementRegistry.get(e));let i=t.cols.indexOf(e);i!==-1&&(Ua(i,t.cols),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach((r,s)=>{this._elementRegistry.remove(r),r.row=void 0,Ua(i,t.rows[s].cells)}),this._eventBus.fire("col.remove",{col:e}))}resized(){this._eventBus.fire("sheet.resized")}};mr.$inject=["elementRegistry","eventBus"];function Xa(n,e,t){return e.splice(n,0,t)}function Ua(n,e){return e.splice(n,1)}function Ya(n=!0){let e=typeof n=="number"?n:n?300:0;return e?t=>Wd(t,e):t=>t}Ya.$inject=["config.throttle"];var Zm={__depends__:[Ha],__init__:["elementFactory","sheet"],elementFactory:["type",zs],elementRegistry:["type",hr],eventBus:["type",ye],sheet:["type",mr],throttle:["factory",Ya]};var Xs=class{constructor(e={}){let{injector:t}=e;if(!t){let{modules:i,config:r}=this._init(e);t=xk(r,i)}this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("table.init"),this.get("eventBus").fire("diagram.init")}_init(e){let{modules:t,...i}=e;return{modules:t,config:i}}destroy(){let e=this.get("eventBus");e.fire("table.destroy"),e.fire("diagram.destroy")}clear(){let e=this.get("eventBus");e.fire("table.clear"),e.fire("diagram.clear")}};function xk(n,e){let t=[{config:["value",n]},Zm].concat(e||[]),i=new xi(t);return i.init(),i}var eg=Xs;function Ka(n){if(!n)return"";let e=n.id?` id="${n.id}"`:"";return`<${n.$type}${e} />`}function Au(n,e){function t(l,c,u){var f=l.gfx;if(f)throw new Error(`already rendered ${Ka(l)}`);return n.element(l,c,u)}function i(l){return n.table(l)}function r(l){l.id||(l.id="decision");let c=l.decisionLogic;if(c){if(!c.output)throw new Error(`missing output for ${Ka(c)}`);let u=i(c);c.input&&s(c.input,u,c),s(c.output,u,c),o(c.rule,u,c)}else throw new Error(`no table for ${Ka(l)}`)}function s(l,c,u){B(l,function(f){t(f,c,u)})}function o(l,c,u){B(l,function(f){t(f,c,u),a(f.inputEntry,f),a(f.outputEntry,f)})}function a(l,c,u){B(l,function(f){t(f,c,u)})}return{handleDecision:r}}function tg(n,e,t){let i=n.get("tableImporter"),r=n.get("eventBus"),s=n.get("sheet"),o=n.get("modeling",!1),a,l=[];function c(u){let f={create(d,p,m,y){return i.create(d,p,m,y)},table(d){return i.add(d)},element(d,p,m){return i.add(d,p,m)},error(d,p){l.push({message:d,context:p})}};new Au(f,{canAddMissingEntries:o}).handleDecision(u)}r.fire("import.render.start",{decision:e});try{c(e)}catch(u){a=u}r.fire("import.render.complete",{error:a,warnings:l}),r.fire("elements.changed",{elements:[s.getRoot()]}),t(a,l)}function bk(){return{elements:[],index:{}}}function ng(n,e){let{elements:t,index:i}=n;return i[e]?n:{elements:[...t,e],index:{...i,[e]:!0}}}function wk(n,e){return n.elements.join(e)}function gr(...n){let e=bk();return n.forEach(function(t){let i=typeof t;i==="string"&&t.length>0?e=ng(e,t):i==="object"&&t!==null&&Object.keys(t).forEach(function(r){t[r]&&(e=ng(e,r))})}),wk(e," ")}function zt(n){let e=n.constructor;return Ga(e,n)}function Ga(n,e){let t=n.$inject;if(!t)return;let{injector:i}=e.context,r=[...t,function(...s){for(let o in s){let a=t[o],l=s[o];e[a]=l}}];i.invoke(r)}function _u(n,...e){return function(...t){let i;return e.forEach(function(r){if(i=r.call(n,...t),typeof i!="undefined")return!1}),i}.bind(n)}function cn(n,e){Object.keys(e).forEach(function(t){if(t==="$inject"||t==="__init")return;let i=e[t];t==="constructor"&&i.call(n,n.props,n.context);let r=n[t];if(typeof r!="undefined"){if(typeof r!="function")throw new Error(`failed to mixin <${t}>: cannot combine with non-fn component value`);n[t]=_u(n,r,i)}else n[t]=i.bind(n)}),"$inject"in e&&Ga(e,n),"__init"in e&&e.__init.call(n,n.props,n.context)}var ig={getSelectionClasses(){let{selected:n,selectedSecondary:e,focussed:t}=this.state;return gr({selected:n,"selected-secondary":e,focussed:t})},selectionChanged(n){this.setState(n)},componentWillUpdate(n){n.elementId!==this.props.elementId&&this.updateSelectionSubscription(!1)},componentDidUpdate(n){n.elementId!==this.props.elementId&&this.updateSelectionSubscription(!0)},componentDidMount(){this.updateSelectionSubscription(!0)},componentWillUnmount(){this.updateSelectionSubscription(!1)},updateSelectionSubscription(n){let{elementId:e}=this.props;e&&e&&this.eventBus[n?"on":"off"](`selection.${e}.changed`,this.selectionChanged)}},Tu=ig;ig.$inject=["eventBus"];var Us=class extends z{constructor(e,t){super(e,t),cn(this,Tu),zt(this)}getRenderProps(...e){let{className:t,elementId:i,coords:r,...s}=this.props,o={className:gr(...e,this.getSelectionClasses(),t)};return i&&(o["data-element-id"]=i),r&&(o["data-coords"]=r),{...o,...s}}};var An=class extends Us{constructor(e,t){super(e,t),this.state={}}render(){let{children:e}=this.props,t=this.getRenderProps("cell");return on(E(1,"td",null,e,0,{...t}))}};var rg={slotFill(n,e){let{type:t,context:i,...r}=n,s=this.components.getComponent(t,i)||e;return s?on(F(2,s,{...i,...r})):null},slotFills(n){let{type:e,context:t,...i}=n;return this.components.getComponents(e,t).map(s=>on(F(2,s,{...t,...i})))}},Ci=rg;rg.$inject=["components"];var sg=400,yr=class extends z{constructor(t,i){super(t,i);L(this,"onElementsChanged",()=>{this.forceUpdate()});cn(this,Ci),zt(this)}componentDidMount(){this.changeSupport.onElementsChanged(this.getRoot(),this.onElementsChanged)}componentWillUnmount(){this.changeSupport.offElementsChanged(this.getRoot(),this.onElementsChanged)}getRoot(){return this.sheet.getRoot()}render(){let r=(this.getRoot().businessObject.get("annotationsWidth")||sg)+"px";return E(1,"th","annotation header",[this.slotFills({type:"cell-inner",context:{cellType:"annotations",col:this.sheet.getRoot(),minWidth:sg}}),this.translate("Annotations")],0,{style:{width:r}})}};yr.$inject=["changeSupport","sheet","translate"];function Mu(n){let{row:e}=n,{id:t,description:i}=e.businessObject;return F(2,An,{className:"annotation",elementId:t,children:i||"-"})}function Ja(n){n.onGetComponent("cell",({cellType:e})=>{if(e==="after-label-cells")return yr;if(e==="after-rule-cells")return Mu})}Ja.$inject=["components"];var og={__init__:["annotationsProvider"],annotationsProvider:["type",Ja]};function Ys(n,e){return D({id:n.id,type:n.$type,businessObject:n},e)}var vr=class{constructor(e,t,i){this._elementFactory=e,this._eventBus=t,this._sheet=i}add(e){let t;if(Q(e,"dmn:DecisionTable"))t=this._elementFactory.createRoot(Ys(e)),this._sheet.setRoot(t);else if(Q(e,"dmn:InputClause"))t=this._elementFactory.createCol(Ys(e)),this._sheet.addCol(t);else if(Q(e,"dmn:OutputClause"))t=this._elementFactory.createCol(Ys(e)),this._sheet.addCol(t);else if(Q(e,"dmn:DecisionRule")){e.inputEntry||(e.inputEntry=[]),e.outputEntry||(e.outputEntry=[]);let i=[...e.inputEntry,...e.outputEntry].map(r=>this._elementFactory.createCell(Ys(r)));t=this._elementFactory.createRow(D(Ys(e),{cells:i})),this._sheet.addRow(t)}return this._eventBus.fire("dmnElement.added",{element:t}),t}};vr.$inject=["elementFactory","eventBus","sheet"];var ag={__depends__:[rt],tableImporter:["type",vr]};var lg={__depends__:[ag,Ha]};var Ks=class extends z{constructor(t,i){super(t,i);L(this,"onElementsChanged",()=>{this.forceUpdate()});cn(this,Ci),this._sheet=i.injector.get("sheet"),this._changeSupport=i.changeSupport}componentWillMount(){let t=this._sheet.getRoot();this._changeSupport.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){let t=this._sheet.getRoot();this._changeSupport.offElementsChanged(t.id,this.onElementsChanged)}render(){let t=this._sheet.getRoot();if(!Q(t,"dmn:DMNElement"))return null;let i=Ot(t),r=i.input,s=i.output;return E(1,"thead",null,E(1,"tr",null,[E(1,"th","index-column"),this.slotFills({type:"cell",context:{cellType:"before-label-cells"}}),r&&r.map((o,a)=>{let l=o.width||"192px";return this.slotFill({type:"cell",context:{cellType:"input-header",input:o,index:a,inputsLength:r.length,width:l},key:o.id},Ok)}),s.map((o,a)=>this.slotFill({type:"cell",context:{cellType:"output-header",output:o,index:a,outputsLength:s.length},key:o.id},kk)),this.slotFills({type:"cell",context:{cellType:"after-label-cells"}})],0),2)}};function Ok(n,e){let{input:t,className:i,index:r}=n,{label:s,inputExpression:o,inputValues:a}=t,l=e.injector.get("translate"),c=(i||"")+" input-cell";return E(1,"th",c,[E(1,"div","clause",l(r===0?"When":"And"),0),s?E(1,"div","input-label",s,0,{title:l("Input label: ")+s}):E(1,"div","input-expression",o.text,0,{title:l("Input expression: ")+o.text}),E(1,"div","input-variable",a&&a.text||o.typeRef,0,{title:a&&a.text?l("Input values"):l("Input type")})],0,{"data-col-id":t.id},t.id)}function kk(n,e){let{output:t,className:i,index:r}=n,{label:s,name:o,outputValues:a,typeRef:l}=t,c=e.injector.get("translate"),u=(i||"")+" output-cell";return E(1,"th",u,[E(1,"div","clause",c(r===0?"Then":"And"),0),s?E(1,"div","output-label",s,0,{title:c("Output label")}):E(1,"div","output-name",o,0,{title:c("Output name")}),E(1,"div","output-variable",a&&a.text||l,0,{title:a&&a.text?c("Output values"):c("Output type")})],0,null,t.id)}function Za(n){n.onGetComponent("table.head",()=>Ks)}Za.$inject=["components"];var cg={__init__:["decisionTableHeadProvider"],decisionTableHeadProvider:["type",Za]};var xr=class extends z{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),zt(this)}render(){let e=this.sheet.getRoot();if(!Q(e,"dmn:DMNElement"))return null;let{name:t}=e.businessObject.$parent,i=this.components.getComponent("hit-policy")||Ck;return E(1,"div","decision-table-properties",[E(1,"div","decision-table-name",t,0,{title:this._translate("Decision name: ")+t}),E(1,"div","decision-table-header-separator"),F(2,i)],4)}};xr.$inject=["sheet","components"];function Ck(){return null}var Sk=500,br=class{constructor(e){e.onGetComponent("table.before",Sk,()=>xr)}};br.$inject=["components"];var ug={__init__:["decisionTableProperties"],decisionTableProperties:["type",br]};var Gs=class extends z{render(){let{row:e,rowIndex:t}=this.props,{components:i}=this.context,r=i.getComponents("cell-inner",{cellType:"rule-index",row:e,rowIndex:t});return E(1,"td","rule-index",[r&&r.map(s=>F(2,s,{row:e,rowIndex:t})),t+1],0,{"data-element-id":e.id,"data-row-id":e.id})}};var wr=class{constructor(e){e.onGetComponent("cell",({cellType:t})=>{if(t==="before-rule-cells")return Gs})}};wr.$inject=["components"];var fg={__init__:["decisionRuleIndices"],decisionRuleIndices:["type",wr]};var Ek=[{label:"FEEL",value:"feel"}],Or=class{constructor(e){this._injector=e;let t=e.get("config.expressionLanguages")||{};this._config={options:Ek,defaults:{editor:"feel"}},t.options&&(this._config.options=t.options);let i=this._getLegacyDefaults();D(this._config.defaults,i,t.defaults)}getDefault(e){let{defaults:t}=this._config,i=t[e]||t.editor;return this._getLanguageByValue(i)||this.getAll()[0]}getLabel(e){let t=this._getLanguageByValue(e);return t?t.label:e}getAll(){return this._config.options}_getLegacyDefaults(){let e={},t=this._injector,i=t.get("config.defaultInputExpressionLanguage"),r=t.get("config.defaultOutputExpressionLanguage");return i&&(e.inputCell=i),r&&(e.outputCell=r),e}_getLanguageByValue(e){return we(this.getAll(),t=>e===t.value)}};Or.$inject=["injector"];var Ru={__init__:["expressionLanguages"],expressionLanguages:["type",Or]};var kr=class{constructor(e){this._feelLanguageContext=e}getConfig(){return this._feelLanguageContext}};kr.$inject=["config.feelLanguageContext"];var Pu={__init__:["feelLanguageContext"],feelLanguageContext:["type",kr]};var Js=class extends z{render({rows:e,cols:t}){let{components:i}=this.context;return E(1,"tbody",null,e.map((r,s)=>{let o=i.getComponent("row",{rowType:"rule"});return o&&F(2,o,{row:r,rowIndex:s,cols:t},r.id)}),0)}};var Zs=class extends z{constructor(e,t){super(e,t),cn(this,Ci)}render(){let{row:e,rowIndex:t,cols:i}=this.props,{cells:r}=e;return E(1,"tr",null,[this.slotFills({type:"cell",context:{cellType:"before-rule-cells",row:e,rowIndex:t}}),r.map((s,o)=>this.slotFill({type:"cell",context:{cellType:"rule",cell:s,rowIndex:t,colIndex:o},key:s.id,row:e,col:i[o]})),this.slotFills({type:"cell",context:{cellType:"after-rule-cells",row:e,rowIndex:t}})],0)}};var eo=class extends z{render(){let{cell:e,row:t,col:i}=this.props;return Q(e,"dmn:UnaryTests")?F(2,An,{className:"input-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":i.id,children:e.businessObject.text}):F(2,An,{className:"output-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":i.id,children:e.businessObject.text})}};var Cr=class{constructor(e){e.onGetComponent("table.body",()=>Js),e.onGetComponent("row",({rowType:t})=>{if(t==="rule")return Zs}),e.onGetComponent("cell",({cellType:t})=>{if(t==="rule")return eo})}};Cr.$inject=["components"];var hg={__depends__:[Ru,Pu],__init__:["decisionRules"],decisionRules:["type",Cr]};var dg=[{label:"Unique",value:{hitPolicy:"UNIQUE",aggregation:void 0},explanation:"No overlap is possible and all rules are disjoint. Only a single rule can be matched"},{label:"First",value:{hitPolicy:"FIRST",aggregation:void 0},explanation:"Rules may overlap. The first matching rule will be chosen"},{label:"Priority",value:{hitPolicy:"PRIORITY",aggregation:void 0},explanation:"Rules may overlap. The one with the highest priority will be chosen"},{label:"Any",value:{hitPolicy:"ANY",aggregation:void 0},explanation:"Rules may overlap. Their output have to match"},{label:"Collect",value:{hitPolicy:"COLLECT",aggregation:void 0},explanation:"Collects the values of all matching rules"},{label:"Collect (Sum)",value:{hitPolicy:"COLLECT",aggregation:"SUM"},explanation:"Collects the values of all matching rules and sums up to a single value"},{label:"Collect (Min)",value:{hitPolicy:"COLLECT",aggregation:"MIN"},explanation:"Collects the values of all matching rules and uses the lowest value"},{label:"Collect (Max)",value:{hitPolicy:"COLLECT",aggregation:"MAX"},explanation:"Collects the values of all matching rules and uses the highest value"},{label:"Collect (Count)",value:{hitPolicy:"COLLECT",aggregation:"COUNT"},explanation:"Collects the values of all matching rules and counts the number of them"},{label:"Rule order",value:{hitPolicy:"RULE ORDER",aggregation:void 0},explanation:"Collects the values of all matching rules in rule order"},{label:"Output order",value:{hitPolicy:"OUTPUT ORDER",aggregation:void 0},explanation:"Collects the values of all matching rules in decreasing output priority order"}];var Sr=class extends z{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),zt(this)}getRoot(){return this.sheet.getRoot()}render(){let e=this.getRoot(),t=e.businessObject,{aggregation:i,hitPolicy:r}=t,s=we(dg,o=>Ak(o.value,{aggregation:i,hitPolicy:r}));return E(1,"div","hit-policy header",[E(1,"label","dms-label",this._translate("Hit policy:"),0),E(1,"span","hit-policy-value",this._translate(s.label),0)],4,{title:this._translate(s.explanation)})}};Sr.$inject=["sheet"];function Ak(n,e){return n.hitPolicy===e.hitPolicy&&n.aggregation===e.aggregation}function el(n){n.onGetComponent("hit-policy",()=>Sr)}el.$inject=["components"];var pg={__init__:["hitPolicyProvider"],hitPolicyProvider:["type",el]};var to=class extends z{constructor(t,i){super(t,i);L(this,"onClick",()=>{this._eventBus.fire("showDrd")});let{injector:r}=i;this._translate=r.get("translate"),this._eventBus=r.get("eventBus")}render(){return E(1,"div","view-drd",E(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,t=>this.node=t)}};var Er=class{constructor(e,t,i,r){this._injector=i,this._sheet=r,e.onGetComponent("table.before",()=>{if(this.canViewDrd())return to}),t.on("showDrd",()=>{let s=i.get("_parent",!1),o=r.getRoot(),a=mg(o);if(!a)return;let l=s.getView(a);s.open(l)})}canViewDrd(){let e=this._injector.get("_parent",!1);if(!e)return!1;let t=this._sheet.getRoot(),i=mg(t);return!!e.getView(i)}};Er.$inject=["components","eventBus","injector","sheet"];function mg(n){let{businessObject:e}=n;return e?e.$parent.$parent:void 0}var gg={__init__:["viewDrd"],viewDrd:["type",Er]};var Ar=class{constructor(e){e.onGetComponent("table.before",()=>Kn)}};Ar.$inject=["components"];var yg={__init__:["poweredBy"],poweredBy:["type",Ar]};var no=class n extends eg{constructor(e={}){let t=n._createContainer();super(D(e,{renderer:{container:t}})),this._container=t}open(e){var t=this;return new Promise((i,r)=>{var s;try{return t._decision&&t.clear(),t._decision=e,tg(t,e,function(o,a){o?(o.warnings=a||[],r(o)):i({warnings:a||[]})})}catch(o){s=o}s?(s.warnings=s.warnings||[],r(s)):i({warnings:[]})})}_init(e){let{modules:t,additionalModules:i,...r}=e,s=t||this.getModules(),o=i||[],a=[{decisionTable:["value",this]}];return{modules:[yg,...s,...o,...a],config:r}}on(e,t,i,r){return this.get("eventBus").on(e,t,i,r)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}attachTo(e){if(!e)throw new Error("parentNode required");this.detach();let t=this._container;e.appendChild(t),this._emit("attach",{})}detach(){let e=this._container;e.parentNode&&(this._emit("detach",{}),Le(e))}destroy(){super.destroy(),this.detach()}getModules(){return n._getModules()}static _getModules(){return[og,lg,rt,cg,ug,fg,hg,pg,gg]}static _createContainer(){return le('
')}};var _r=class{constructor(e){this._listeners={},e.on("elements.changed",({elements:t})=>{this.elementsChanged(t)}),e.on("element.updateId",({element:t,newId:i})=>{this.updateId(t.id,i)})}elementsChanged(e){let t={},i=e.length;for(let r=0;rF(2,t,null,i)),0)}};var Tr=class{constructor(e,t,i,r,s){let{container:o}=i;this._container=o,r.on("renderer.mount",()=>{or(F(2,ro,{injector:s}),o)}),r.on("renderer.unmount",()=>{or(null,o)})}getContainer(){return this._container}};Tr.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var vg={__init__:["changeSupport","components","renderer"],changeSupport:["type",_r],components:["type",io],eventBus:["type",ye],renderer:["type",Tr]};var Si=class{constructor(e={}){let{injector:t}=e;if(!t){let{modules:i,config:r}=this._init(e);t=Tk(r,i)}this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("viewer.init")}_init(e){let{modules:t,...i}=e;return{modules:t,config:i}}destroy(){this.get("eventBus").fire("viewer.destroy")}clear(){this.get("eventBus").fire("viewer.clear")}};function Tk(n,e){let t=[{config:["value",n]},vg].concat(e||[]),i=new xi(t);return i.init(),i}var Mr=class{constructor(e,t){this._eventBus=t,this._viewer=e}getDecision(){return this._viewer.getDecision()}updateId(e,t){var i=this.getDecision();if(e!==i)throw new Error("element !== decision");this._eventBus.fire("element.updateId",{element:e,newId:t}),e.id=t}};Mr.$inject=["viewer","eventBus"];var xg={__init__:["elementRegistry"],elementRegistry:["type",Mr]};var so=class extends z{constructor(e,t){super(e,t),this._viewer=t.injector.get("viewer")}render(){let{name:e}=this._viewer.getDecision();return E(1,"div","decision-properties",E(1,"h3","decision-name",e,0),2)}};var Mk=1500,Rr=class{constructor(e){e.onGetComponent("viewer",Mk,()=>so)}};Rr.$inject=["components"];var bg={__init__:["decisionProperties"],decisionProperties:["type",Rr]};var oo=class extends z{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._viewer=t.injector.get("viewer")}render(){let{decisionLogic:e,variable:t}=this._viewer.getDecision();return E(1,"div","literal-expression-properties",E(1,"table",null,[E(1,"tr",null,[E(1,"td",null,this._translate("Variable name:"),0),E(1,"td",null,E(1,"span",null,t.name||"-",0),2)],4),E(1,"tr",null,[E(1,"td",null,this._translate("Variable type:"),0),E(1,"td",null,E(1,"span",null,this._translate(t.typeRef||"")||"-",0),2)],4),E(1,"tr",null,[E(1,"td",null,this._translate("Expression language:"),0),E(1,"td",null,E(1,"span",null,e.expressionLanguage||"-",0),2)],4)],4),2)}};var Rk=500,Pr=class{constructor(e){e.onGetComponent("viewer",Rk,()=>oo)}};Pr.$inject=["components"];var wg={__depends__:[],__init__:["literalExpressionProperties"],literalExpressionProperties:["type",Pr]};var Pk=2e3,Dr=class{constructor(e){e.onGetComponent("viewer",Pk,()=>Kn)}};Dr.$inject=["components"];var Og={__init__:["poweredBy"],poweredBy:["type",Dr]};var ao=class extends z{constructor(e,t){super(e,t),this._viewer=t.injector.get("viewer")}render(){let{text:e}=this._viewer.getDecision().decisionLogic;return E(1,"div","textarea",E(1,"div","content",e,0),2)}};var Br=class{constructor(e){e.onGetComponent("viewer",()=>ao)}};Br.$inject=["components"];var kg={__init__:["textarea"],textarea:["type",Br]};var Ir=class extends z{constructor(t,i){super(t,i);L(this,"onClick",()=>{this._eventBus.fire("showDrd")});let{injector:r}=i;this._translate=r.get("translate"),this._eventBus=r.get("eventBus")}render(){return E(1,"div","view-drd",E(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,t=>this.node=t)}};Ir.$inject=["translate"];var Dk=2e3,Lr=class{constructor(e,t,i,r){this._injector=r,this._viewer=t,e.onGetComponent("viewer",Dk,()=>{if(this.canViewDrd())return Ir}),i.on("showDrd",()=>{let s=r.get("_parent",!1),o=this.getDefinitions(),a=s.getView(o);s.open(a)})}canViewDrd(){let e=this._injector.get("_parent",!1);if(!e)return;let t=this.getDefinitions();return!!e.getView(t)}getDefinitions(){return Bk(this._viewer.getDecision())}};Lr.$inject=["components","viewer","eventBus","injector"];function Bk(n){return n.$parent}var Cg={__init__:["viewDrd"],viewDrd:["type",Lr]};var lo=class n extends Si{constructor(e={}){let t=n._createContainer();super(D(e,{renderer:{container:t}})),this._container=t}open(e){var t=this;return new Promise(function(i,r){var s;try{t._decision&&(t.clear(),t.get("eventBus").fire("renderer.unmount")),t._decision=e,t.get("eventBus").fire("import",e),t.get("eventBus").fire("renderer.mount")}catch(o){s=o}s?(s.warnings=s.warnings||[],r(s)):i({warnings:[]})})}_init(e){let{modules:t,additionalModules:i,...r}=e,s=t||this.getModules(),o=i||[],a=[{viewer:["value",this]}];return{modules:[...s,...o,...a],config:r}}on(e,t,i,r){return this.get("eventBus").on(e,t,i,r)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}getDecision(){return this._decision}attachTo(e){if(!e)throw new Error("parentNode required");this.detach(),e.appendChild(this._container),this._emit("attach",{})}detach(){let e=this._container;e.parentNode&&(this._emit("detach",{}),Le(e))}destroy(){super.destroy(),this.detach()}getModules(){return n._getModules()}static _getModules(){return[xg,rt,bg,wg,Og,kg,Cg]}static _createContainer(){return le('
')}};var co=class{constructor(e){e.onGetComponent("viewer",()=>Ik),e.onGetComponent("viewer",()=>Lk),e.onGetComponent("viewer",()=>$k)}};L(co,"$inject",["components"]);function Ik(n,{injector:e}){let i=e.get("components").getComponents("header");return E(1,"div","dmn-boxed-expression-section dmn-boxed-expression-header",i&&i.map((r,s)=>F(2,r,null,s)),0)}function Lk(n,{injector:e}){let i=e.get("components").getComponents("body");return E(1,"div","dmn-boxed-expression-section dmn-boxed-expression-body",i&&i.map((r,s)=>F(2,r,null,s)),0)}function $k(n,{injector:e}){let i=e.get("components").getComponents("footer");return E(1,"div","dmn-boxed-expression-section dmn-boxed-expression-footer",i&&i.map((r,s)=>F(2,r,null,s)),0)}var uo=class{constructor(e){e.onGetComponent("viewer",()=>{let t=e.getComponents("table.before")||[];return()=>E(1,"div",null,t.map((i,r)=>F(2,i,null,r)),0)})}};L(uo,"$inject",["components"]);var Sg={__init__:["viewRenderer","tableJsSupport"],viewRenderer:["type",co],tableJsSupport:["type",uo]};var Nk=2e3,$r=class{constructor(e){e.onGetComponent("viewer",Nk,()=>Kn)}};$r.$inject=["components"];var Eg={__init__:["poweredBy"],poweredBy:["type",$r]};var fo=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(Q(t,"dmn:LiteralExpression"))return qk})}};L(fo,"$inject",["components"]);function qk({expression:n},e){let i=e.injector.get("literalExpression").getText(n);return E(1,"div","textarea",E(1,"div","content",i,0),2)}var Ei=class{getText(e){return e.get("text")}};var Ag={__init__:["literalExpressionComponent"],literalExpressionComponent:["type",fo],literalExpression:["type",Ei]};var ho=class{getParameters(e){return e.get("formalParameter")}getBody(e){return e.get("body")}getKind(e){return e.get("kind")||"FEEL"}};var po=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(Q(t,"dmn:FunctionDefinition"))return Fk})}};L(po,"$inject",["components"]);function Fk({expression:n},e){let t=e.injector.get("functionDefinition"),i=t.getKind(n),r=t.getParameters(n),s=t.getBody(n);return E(1,"div","function-definition",[F(2,Vk,{kind:i}),F(2,Qk,{parameters:r}),F(2,Wk,{expression:s})],4)}var jk={FEEL:"F",Java:"J",PMML:"P"};function Vk({kind:n},e){let t=e.injector.get("translate");return E(1,"div","function-definition-kind",jk[n],0,{title:t("Function kind: {kind}",{kind:n})})}function Qk({parameters:n}){return E(1,"div","function-definition-parameters",E(1,"div",null,[xe("("),n.reduce((e,t)=>e.concat(F(2,zk,{parameter:t}),", "),[]).slice(0,-1),xe(")")],0),2)}function zk({parameter:n}){let{name:e,typeRef:t}=n,i=e||"";return E(1,"span",null,t?`${i}: ${t}`:i,0)}function Wk({expression:n},e){let t=e.components.getComponent("expression",{expression:n});return E(1,"div","function-definition-body",F(2,t,{expression:n}),2)}var _g={__init__:["functionDefinitionComponent"],functionDefinition:["type",ho],functionDefinitionComponent:["type",po]};var Nr=class extends z{constructor(t,i){super(t,i);L(this,"onClick",()=>{this._eventBus.fire("showDrd")});let{injector:r}=i;this._translate=r.get("translate"),this._eventBus=r.get("eventBus")}render(){return E(1,"div","view-drd",E(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,t=>this.node=t)}};Nr.$inject=["translate"];var Hk=2e3,qr=class{constructor(e,t,i){this._injector=i,e.onGetComponent("viewer",Hk,()=>{if(this.canViewDrd())return Nr}),t.on("showDrd",()=>{let r=i.get("_parent",!1),s=r.getDefinitions(),o=r.getView(s);r.open(o)})}canViewDrd(){let e=this._injector.get("_parent",!1);if(!e)return;let t=e.getDefinitions();return!!e.getView(t)}};qr.$inject=["components","eventBus","injector"];var Tg={__init__:["viewDrd"],viewDrd:["type",qr]};function Du(n,e){let t=e.injector.get("viewer"),{name:i}=t.getRootElement();return E(1,"div","element-properties",E(1,"h2","element-name",i,0),2)}var Fr=class{constructor(e){e.onGetComponent("header",()=>Du)}};Fr.$inject=["components"];var Mg={__init__:["elementProperties"],elementProperties:["type",Fr]};var Xk=100,jr=class{constructor(e){e.onGetComponent("body",()=>Uk),e.onGetComponent("expression",Xk,()=>Kk)}};L(jr,"$inject",["components"]);function Uk(n,{injector:e}){let t=e.get("components"),r=e.get("viewer").getRootElement(),s=Yk(r),o=t.getComponent("expression",{expression:s});return F(2,o,{expression:s})}function Yk(n){if(Q(n,"dmn:Decision"))return n.get("decisionLogic");if(Q(n,"dmn:BusinessKnowledgeModel"))return n.get("encapsulatedLogic")}function Kk({expression:n}){return E(1,"div",null,E(1,"span",null,[xe("Expression of type "),n.$type,xe(" is not supported.")],0,{style:"color:red;"}),2)}var Rg={__init__:["elementLogic"],elementLogic:["type",jr]};var Ai=class{constructor(e){this._viewer=e}getName(){let e=this.getVariable(),t=this._getElement();return(e?e.get("name"):null)||t.get("name")}getType(){let e=this.getVariable();return e?e.get("typeRef"):"Any"}_getElement(){return this._viewer.getRootElement()}getVariable(){return this._getElement().get("variable")}};L(Ai,"$inject",["viewer"]);var Vr=class{constructor(e){e.onGetComponent("footer",()=>Gk)}};L(Vr,"$inject",["components"]);function Gk(n,e){let t=e.injector.get("elementVariable"),i=e.injector.get("translate"),r=t.getName(),s=t.getType();return E(1,"div","element-variable",[E(1,"h2",null,xe("Result"),2),E(1,"div","element-variable-name",[E(1,"span","element-variable-name-label",i("Variable name"),0),E(1,"span",null,r,0)],4),E(1,"div","element-variable-type",[E(1,"span","element-variable-type-label",i("Variable type"),0),E(1,"span",null,s,0)],4)],4)}var Pg={__init__:["elementVariableComponent"],elementVariable:["type",Ai],elementVariableComponent:["type",Vr]};var Qr=class n extends Si{constructor(e={}){let t=n._createContainer();super(D(e,{renderer:{container:t}})),this._container=t}open(e){let t=this.get("eventBus");return new Promise((i,r)=>{let s;try{this.getRootElement()&&(this.clear(),t.fire("renderer.unmount")),this._setRootElement(e),t.fire("import",e),t.fire("renderer.mount")}catch(o){s=o}s?(s.warnings=s.warnings||[],r(s)):i({warnings:[]})})}_init(e){let{modules:t,additionalModules:i,...r}=e,s=t||this.getModules(),o=i||[],a=[{viewer:["value",this]}];return{modules:[...s,...o,...a],config:r}}on(e,t,i,r){return this.get("eventBus").on(e,t,i,r)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}getRootElement(){return this._root}_setRootElement(e){this._root=e}attachTo(e){if(!e)throw new Error("parentNode required");this.detach(),e.appendChild(this._container),this._emit("attach",{})}detach(){let e=this._container;e.parentNode&&(this._emit("detach",{}),Le(e))}destroy(){super.destroy(),this.detach()}getModules(){return[Sg,rt,Eg,Tg,Mg,Rg,_g,Ag,Pg]}static _createContainer(){return le('
')}};function Bu(n){let e={variables:[],rootElement:hC(n)};for(let t=n;t;t=t.$parent)Jk(t,e);return e.variables}function Jk(n,e){zr(n,"dmn:Decision")?Zk(n,e):zr(n,"dmn:BusinessKnowledgeModel")?eC(n,e):zr(n,"dmn:Expression")&&cC(n,e)}function Zk(n,e){for(let t of n.get("informationRequirement"))tC(t,e);for(let t of n.get("knowledgeRequirement"))Bg(t,e)}function eC(n,e){for(let t of n.get("knowledgeRequirement"))Bg(t,e)}function tC(n,e){let t=n.get("requiredInput");t&&nC(t,e);let i=n.get("requiredDecision");i&&iC(i,e)}function nC(n,e){let t=Iu(n,e.rootElement);if(!t)return;let i=t.get("name");i&&e.variables.push({name:i,origin:t})}function iC(n,e){let t=Iu(n,e.rootElement);if(!t)return;let i=t.get("name");if(!i)return;let r={name:i,origin:t},s=t.get("decisionLogic");s&&rC(s,r,e),e.variables.push(r)}function rC(n,e,t){if(zr(n,"dmn:DecisionTable")){let i=n.get("output");sC(i,e,t)}}function sC(n,e,t){if(n.length===1){let r={...Dg(n[0]),name:e.name};Object.assign(e,r);return}let i=n.map(Dg);e.entries=i.filter(r=>!!r.name)}function Dg(n){let e={name:n.name};return n.typeRef&&(e.detail=n.typeRef),e}function Bg(n,e){let t=n.get("requiredKnowledge");t&&oC(t,e)}function oC(n,e){let t=Iu(n,e.rootElement);t&&zr(t,"dmn:BusinessKnowledgeModel")&&aC(t,e)}function aC(n,e){let t=n.get("name");if(!t)return;let i={name:t,origin:n},r=n.get("encapsulatedLogic");r&&lC(r,i),e.variables.push(i)}function lC(n,e,t){let r=n.get("formalParameter").map((s,o)=>{let a={name:s.get("name")||`param ${o+1}`,type:s.get("typeRef")};return a.type||delete a.type,a});Object.assign(e,{type:"function",params:r})}function cC(n,e){zr(n,"dmn:FunctionDefinition")&&uC(n,e)}function uC(n,e){let t=n.get("formalParameter");for(let i of t)fC(i,e)}function fC(n,e){let t=n.get("name");if(!t)return;let i={name:t,origin:n};n.get("typeRef")&&(i.detail=n.get("typeRef")),e.variables.push(i)}function hC(n){let e=n;for(;e.$parent;)e=e.$parent;return e}function Iu(n,e){let t=n.get("href");if(!t||!t.startsWith("#"))return;let i=t.slice(1);return e.get("drgElement").find(s=>s.get("id")===i)}function zr(n,e){return n.$instanceOf(e)}var tl=class{constructor(e){e.registerProvider(this)}getVariables(e,t){return e.concat(Bu(t))}};tl.$inject=["variableResolver"];var dC=["string","boolean","number","date","time","dateTime","dayTimeDuration","yearMonthDuration","Any"],mo=class{constructor(e){this._dataTypes=e||dC}getAll(){return this._dataTypes}};mo.$inject=["config.dataTypes"];var pC=1e3;function st(n){this._eventBus=n}st.$inject=["eventBus"];function mC(n,e){return function(t){return n.call(e||null,t.context,t.command,t)}}st.prototype.on=function(n,e,t,i,r,s){if((Ie(e)||Ce(e))&&(s=r,r=i,i=t,t=e,e=null),Ie(t)&&(s=r,r=i,i=t,t=pC),dt(r)&&(s=r,r=!1),!Ie(i))throw new Error("handlerFn must be a function");_e(n)||(n=[n]);var o=this._eventBus;B(n,function(a){var l=["commandStack",a,e].filter(function(c){return c}).join(".");o.on(l,t,r?mC(i,s):i,s)})};st.prototype.canExecute=_n("canExecute");st.prototype.preExecute=_n("preExecute");st.prototype.preExecuted=_n("preExecuted");st.prototype.execute=_n("execute");st.prototype.executed=_n("executed");st.prototype.postExecute=_n("postExecute");st.prototype.postExecuted=_n("postExecuted");st.prototype.revert=_n("revert");st.prototype.reverted=_n("reverted");function _n(n){return function(t,i,r,s,o){(Ie(t)||Ce(t))&&(o=s,s=r,r=i,i=t,t=null),this.on(t,n,i,r,s,o)}}var Ig="id",go=class extends st{constructor(e){super(e),this.executed("element.updateProperties",this.updateIds.bind(this))}updateIds({context:e}){let{element:t,oldProperties:i,properties:r}=e,s=Ot(t);if(this.shouldSkipUpdate(s,i,r))return;let o=yC(s);o.get("drgElement").forEach(c=>{vC(c,i.id,r.id)}),o.get("artifact").forEach(c=>{xC(c,i.id,r.id)})}shouldSkipUpdate(e,t,i){return!gC(t,i)||!Q(e,"dmn:DRGElement")&&!Q(e,"dmn:TextAnnotation")}};go.$inject=["eventBus"];function gC(n,e){return Ig in n&&Ig in e}function yC(n){let e=n;for(;!Q(e,"dmn:Definitions");)e=e.$parent;return e}function vC(n,e,t){B({authorityRequirement:()=>{n.authorityRequirement.forEach(r=>{let{requiredAuthority:s,requiredDecision:o,requiredInput:a}=r;s&&s.href===`#${e}`&&(s.href=`#${t}`),o&&o.href===`#${e}`&&(o.href=`#${t}`),a&&a.href===`#${e}`&&(a.href=`#${t}`)})},informationRequirement:()=>{n.informationRequirement.forEach(r=>{let{requiredDecision:s,requiredInput:o}=r;s&&s.href===`#${e}`&&(s.href=`#${t}`),o&&o.href===`#${e}`&&(o.href=`#${t}`)})},knowledgeRequirement:()=>{n.knowledgeRequirement.forEach(r=>{let{requiredKnowledge:s}=r;s&&s.href===`#${e}`&&(s.href=`#${t}`)})}},(r,s)=>{n[s]&&r()})}function xC(n,e,t){B({sourceRef:()=>{let{sourceRef:r}=n;r.href===`#${e}`&&(r.href=`#${t}`)},targetRef:()=>{let{targetRef:r}=n;r.href===`#${e}`&&(r.href=`#${t}`)}},(r,s)=>{n[s]&&r()})}var Lu="id",Wr=class{constructor(e,t){this._elementRegistry=e,this._moddle=t}execute(e){let{element:t,properties:i}=e,r=Ot(t),{changed:s,oldProperties:o}=this.updateProperties(r,i);return e.oldProperties=o,[...s,t]}revert(e){let{element:t,oldProperties:i}=e;var r=Ot(t),{changed:s}=this.updateProperties(r,i);return[...s,t]}updateProperties(e,t){let i=this._moddle.ids;return wt(t,(r,s,o)=>{let a=e.get(o);if(Lg(s)){if(!Lg(a))throw new Error(`non-existing property <${o}>: cannot update values`);let{changed:l,oldProperties:c}=this.updateProperties(a,s);return{changed:[...r.changed,...l,a],oldProperties:{...r.oldProperties,[o]:c}}}return o===Lu&&bC(e,s)&&(i.unclaim(e[Lu]),this._elementRegistry.updateId(e,s),i.claim(s,e)),e.set(o,s),{changed:r.changed,oldProperties:{...r.oldProperties,[o]:a}}},{changed:[],oldProperties:{}})}};Wr.$inject=["elementRegistry","moddle"];function bC(n,e){return n[Lu]!==e}function Lg(n){return ht(n)&&dt(n)}var yo=class{constructor(e,t,i){this._commandStack=e,this._viewer=t,this._eventBus=i,wC(this._getHandlers(),e)}_getHandlers(){return{"element.updateProperties":Wr}}updateProperties(e,t){let i={element:e,properties:t};this._commandStack.execute("element.updateProperties",i)}};yo.$inject=["commandStack","viewer","eventBus"];function wC(n,e){B(n,function(t,i){e.registerHandler(i,t)})}var Yg=Rb(Ng());function CC(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var $u,qg;function SC(){if(qg)return $u;qg=1,$u=n;function n(e,t){return e^t}return $u}var Nu,Fg;function EC(){if(Fg)return Nu;Fg=1;var n=/\b(Array|Date|Object|Math|JSON)\b/g;Nu=function(s,o){var a=i(e(s));return o&&typeof o=="string"&&(o=r(o)),o?t(s,a,o):a};function e(s){return s.replace(/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\//g,"").replace(n,"").match(/[a-zA-Z_]\w*/g)||[]}function t(s,o,a){var l=/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g;return s.replace(l,function(c){return c[c.length-1]=="("||~o.indexOf(c)?a(c):c})}function i(s){for(var o=[],a=0;a0?c:1;for(var f=this.node,h=this.closingTag,d=this._revisit;f;){if(n(o,h)&&f[s])f=f[s],h=!o;else if(f.nodeType==1&&!f[s]&&n(o,h)){if(h=o,!d)continue}else if(f[r])f=f[r],h=!o;else if(f=f.parentNode,h=o,!d)continue;if(!f||this.higher(f,this.root))break;if(l(f)&&this.selects(f,u)&&this.rejects(f,u)){if(--c)continue;return u||(this.node=f),this.closingTag=h,f}}return null}}return t.prototype.select=function(r){return r=this.compile(r),this._selects.push(r),this},t.prototype.selects=function(r,s){var o=this._selects,a=o.length;if(!a)return!0;for(var l=0;l0?this.next(r,s,!0):this.prev(r,Math.abs(s),!0):this.node},t.prototype.use=function(r){return r(this),this},qu}var _C=AC(),Vg=CC(_C),St=window.getSelection();function ju(n){St==null||St.removeAllRanges(),St==null||St.addRange(n)}function Qg(){return St}function TC(n){if(!(St!=null&&St.rangeCount))return null;var e=St.focusNode;return nl(e)&&(e=e.parentNode),n==e||n.contains(e)}function zg(n,e){var t=MC(n,e);ju(t)}function Wg(n){if(!TC(n))return null;var e=St.getRangeAt(0),t=e.startContainer,i=e.endContainer,r=e.startOffset,s=e.endOffset,o=Vg(n.firstChild,n),a=o.node,l,c=!1,u,f=0;function h(p,m){return arguments.length===1&&(m=p),p.parentNode===i&&m==i.childNodes[s]}function d(p,m){return arguments.length===1&&(m=p),p.parentNode===t&&m==t.childNodes[r]}for(;a&&(d(a)&&!c&&(u=f),!(h(a)||Fu(a)&&i===a));){if(c||(Fu(a)||l&&l.nextSibling==a&&(Hg(a)||Xg(a)))&&f++,nl(a)){if(t===a&&(u=f+r),i===a){f+=s;break}f+=a.textContent.length}if((nl(a)||c)&&(d(a,a.nextSibling)&&(u=f),h(a,a.nextSibling)))break;l=a,a=o.next(),c=o.closingTag}return{start:typeof u=="undefined"?f:u,end:f}}function MC(n,e){for(var t=e.start,i=e.end,r=document.createRange(),s=Vg(n.firstChild,n),o=s.node,a=!1,l=0,c;o;){if(l===t&&(a?r.setStartAfter(o):r.setStartBefore(o)),l===i)return a?r.setEndAfter(o):r.setEndBefore(o),r;if(a||(Fu(o)||o.previousSibling&&(Hg(o)||Xg(o)))&&l++,nl(o)){if(c=o.textContent.length,l<=t&&l+c>t&&r.setStart(o,t-l),l+c>i)return r.setEnd(o,i-l),r;l+=c}o=s.next(),a=s.closingTag}return l<=t&&(n.lastChild?r.setStartAfter(n.lastChild):r.setStart(n,0)),n.lastChild?r.setEndAfter(n.lastChild):r.setEnd(n,0),r}function nl(n){return n.nodeType===3}function Fu(n){return n.nodeType===1&&n.nodeName==="BR"}function Hg(n){return n.nodeType===1&&n.nodeName==="DIV"}function Xg(n){return n.nodeType===1&&n.nodeName==="P"}function Ug(n,e,t){var i=n.start,r=i,s=e.substring(i);t.lastIndexOf(s)===t.length-s.length&&(e=e.substring(0,e.length-s.length),t=t.substring(0,t.length-s.length));var o=RC(e,t);return o&&(o.type==="remove"?r=o.newStart:r=o.newEnd),PC(r)}function RC(n,e){var t,i,r,s=0,o,a,l=0;for(e.length>n.length?(i=e,o=n):(i=n,o=e);sn.length?{newStart:t.l_start,newEnd:t.l_end,type:"add"}:{newStart:t.s_start,newEnd:t.s_end,type:e.length{var i=this.props.onFocus;this.setState({focussed:!0}),typeof i=="function"&&i(t)});L(this,"onBlur",t=>{let{onBlur:i,onChange:r,value:s}=this.props;if(this.setState({focussed:!1}),typeof r=="function"&&this.node){let o=il(this.node);o!==s&&r(o)}typeof i=="function"&&i(t)});L(this,"onkeydown",t=>{if(t.which===13){if(t.preventDefault(),this.props.ctrlForNewline&&!IC(t)||this.props.singleLine)return;t.stopPropagation(),BC(),this.onInput(t)}});L(this,"onInput",t=>{var i=this.props.onInput;if(typeof i=="function"){var r=il(this.node);i(r)}});L(this,"onPaste",t=>{if(this.props.singleLine){let i=(t.clipboardData||window.clipboardData).getData("text");document.execCommand("insertText",!1,i.replace(/\n/g," ")),t.preventDefault()}});this.state={}}componentWillUpdate(t,i){var r=this.node,s=i.focussed&&Wg(r);this.selected=s&&{range:s,text:il(r)}}componentDidUpdate(){var t=this.selected;if(!t)return;let i=t.range,r=t.text,s=this.node,o=il(s),a=o!==r?Ug(i,r,o):i;zg(s,a)}getClassName(){let{className:t,placeholder:i,value:r}=this.props;return[t||"","content-editable",!r&&i?"placeholder":""].join(" ")}render(t){var{label:i,value:r,placeholder:s}=t;return r=(0,Yg.default)(r).replace(/\r?\n/g,"
")+"
",E(1,"div",this.getClassName(),null,1,{"aria-label":i,role:"textbox","aria-multiline":!this.props.singleLine,tabIndex:"0",contentEditable:"true",spellCheck:"false","data-placeholder":s||"",onInput:this.onInput,onkeypress:this.onkeypress,onPaste:this.onPaste,onFocus:this.onFocus,onBlur:this.onBlur,onkeydown:this.onkeydown,dangerouslySetInnerHTML:{__html:r}},null,o=>this.node=o)}};function DC(){return document.createElement("br")}function il(n){return n.innerText.replace(/\n$/,"")}function BC(){var n=Qg(),e=n.getRangeAt(0);if(e){var t=e.cloneRange(),i=DC();t.deleteContents(),t.insertNode(i),t.setStartAfter(i),t.setEndAfter(i),ju(t)}}function IC(n){return n.metaKey||n.ctrlKey}var xo=class extends z{constructor(t,i){super(t,i);L(this,"onFocus",t=>{this.setState({focussed:!0});var{onFocus:i}=this.props;typeof i=="function"&&i(t)});L(this,"onBlur",t=>{this.setState({focussed:!1});let{invalid:i}=this.state;i&&this.setState({changing:!1,invalid:!1});let{onBlur:r}=this.props;typeof r=="function"&&r(t)});this.state={changing:!1,focussed:!1};let{injector:r}=i,s=r.get("debounceInput");this.inputChanged=s(o=>{let{onChange:a}=this.props;typeof a=="function"&&a(o);let l=this.state.changing;this.setState({changing:l===o?!1:l})}),this.onInput=o=>{var a=this.props.validate||function(){},l=a(o);this.setState({changing:o,invalid:l}),l||this.inputChanged(o)}}getClassName(){var{className:t,value:i}=this.props,{changing:r,focussed:s,invalid:o}=this.state;return t+=" editable",s&&(t+=" focussed"),o&&(t+=" invalid"),!i&&!r&&(t+=" empty"),t}getDisplayValue(){var{value:t,placeholder:i}=this.props,{focussed:r,changing:s}=this.state;return typeof s=="string"&&(t=s),t||(t=r?"":i||""),t}getEditor(t={}){return F(2,vo,{className:t.className,ctrlForNewline:this.props.ctrlForNewline,label:this.props.label,onFocus:this.onFocus,onBlur:this.onBlur,onInput:this.onInput,value:this.getDisplayValue()})}};var Qu=[],Zg=[];(()=>{let n="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=0,t=0;e>1;if(n=Zg[i])e=i+1;else return!0;if(e==t)return!1}}function Kg(n){return n>=127462&&n<=127487}var Gg=8205;function ey(n,e,t=!0,i=!0){return(t?ty:$C)(n,e,i)}function ty(n,e,t){if(e==n.length)return e;e&&ny(n.charCodeAt(e))&&iy(n.charCodeAt(e-1))&&e--;let i=Vu(n,e);for(e+=Jg(i);e=0&&Kg(Vu(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function $C(n,e,t){for(;e>0;){let i=ty(n,e-2,t);if(i=56320&&n<57344}function iy(n){return n>=55296&&n<56320}function Jg(n){return n<65536?1:2}var J=class n{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,i){[e,t]=Kr(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),Xr.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Kr(this,e,t);let i=[];return this.decompose(e,t,i,0),Xr.from(i,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),i=this.length-this.scanIdentical(e,-1),r=new Mi(this),s=new Mi(e);for(let o=t,a=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(a+=r.value.length,r.done||a>=i)return!0}}iter(e=1){return new Mi(this,e)}iterRange(e,t=this.length){return new ll(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new cl(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?n.empty:e.length<=32?new mt(e):Xr.from(mt.split(e,[]))}},mt=class n extends J{constructor(e,t=NC(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],a=r+o.length;if((t?i:a)>=e)return new Wu(r,a,i,o);r=a+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new n(ry(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),a=al(s.text,o.text.slice(),0,s.length);if(a.length<=32)i.push(new n(a,o.length+s.length));else{let l=a.length>>1;i.push(new n(a.slice(0,l)),new n(a.slice(l)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof n))return super.replace(e,t,i);[e,t]=Kr(this,e,t);let r=al(this.text,al(i.text,ry(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new n(r,s):Xr.from(n.split(r,[]),s)}sliceString(e,t=this.length,i=` `){[e,t]=Kr(this,e,t);let r="";for(let s=0,o=0;s<=t&&oe&&o&&(r+=i),es&&(r+=a.slice(Math.max(0,e-s),t-s)),s=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new n(i,r)),i=[],r=-1);return r>-1&&t.push(new n(i,r)),t}},Xr=class n extends J{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.children[s],a=r+o.length,l=i+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,i,r);r=a+1,i=l+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s=o){let c=r&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!c?i.push(a):a.decompose(e-o,t-o,i,c)}o=l+1}}replace(e,t,i){if([e,t]=Kr(this,e,t),i.lines=s&&t<=a){let l=o.replace(e-s,t-s,i),c=this.lines-o.lines+l.lines;if(l.lines>4&&l.lines>c>>6){let u=this.children.slice();return u[r]=l,new n(u,this.length-(t-e)+i.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` `){[e,t]=Kr(this,e,t);let r="";for(let s=0,o=0;se&&s&&(r+=i),eo&&(r+=a.sliceString(e-o,t-o,i)),o=l+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof n))return 0;let i=0,[r,s,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==a)return i;let l=this.children[r],c=e.children[s];if(l!=c)return i+l.scanIdentical(c,t);i+=l.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new mt(d,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,a=[],l=0,c=-1,u=[];function f(d){let p;if(d.lines>s&&d instanceof n)for(let m of d.children)f(m);else d.lines>o&&(l>o||!l)?(h(),a.push(d)):d instanceof mt&&l&&(p=u[u.length-1])instanceof mt&&d.lines+p.lines<=32?(l+=d.lines,c+=d.length+1,u[u.length-1]=new mt(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>r&&h(),l+=d.lines,c+=d.length+1,u.push(d))}function h(){l!=0&&(a.push(u.length==1?u[0]:n.from(u,c)),c=-1,l=u.length=0)}for(let d of e)f(d);return h(),a.length==1?a[0]:new n(a,t)}};J.empty=new mt([""],0);function NC(n){let e=-1;for(let t of n)e+=t.length+1;return e}function al(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s=t&&(l>i&&(a=a.slice(0,i-r)),r0?1:(e instanceof mt?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,a=r instanceof mt?r.text.length:r.children.length;if(o==(t>0?a:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` `,this;e--}else if(r instanceof mt){let l=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=r.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof mt?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},ll=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Mi(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}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 i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},cl=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(J.prototype[Symbol.iterator]=function(){return this.iter()},Mi.prototype[Symbol.iterator]=ll.prototype[Symbol.iterator]=cl.prototype[Symbol.iterator]=function(){return this});var Wu=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function Kr(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function Re(n,e,t=!0,i=!0){return ey(n,e,t,i)}function qC(n){return n>=56320&&n<57344}function FC(n){return n>=55296&&n<56320}function At(n,e){let t=n.charCodeAt(e);if(!FC(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return qC(i)?(t-55296<<10)+(i-56320)+65536:t}function sf(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function un(n){return n<65536?1:2}var Hu=/\r\n?|\n/,Ee=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(Ee||(Ee={})),Tn=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return s+(e-r);s+=a}else{if(i!=Ee.Simple&&c>=e&&(i==Ee.TrackDel&&re||i==Ee.TrackBefore&&re))return null;if(c>e||c==e&&t<0&&!a)return e==r||t<0?s:s+l;s+=l}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i=0&&r<=t&&a>=e)return rt?"cover":!0;r=a}return!1}toString(){let e="";for(let t=0;t=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new n(e)}static create(e){return new n(e)}},Je=class n extends Tn{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 Xu(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return Uu(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r=0){t[r]=a,t[r+1]=o;let l=r>>1;for(;i.length0&&Zn(i,t,s.text),s.forward(u),a+=u}let c=e[o++];for(;a>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,a=null;function l(u=!1){if(!u&&!r.length)return;oh||f<0||h>t)throw new RangeError(`Invalid change range ${f} to ${h} (in doc of length ${t})`);let p=d?typeof d=="string"?J.of(d.split(i||Hu)):d:J.empty,m=p.length;if(f==h&&m==0)return;fo&&Qe(r,f-o,-1),Qe(r,h-f,m),Zn(s,r,p),o=h}}return c(e),l(!a),a}static empty(e){return new n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;ra&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length=0&&t<=0&&t==n[r+1]?n[r]+=e:r>=0&&e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Zn(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)a=n.sections[o++],l=n.sections[o++];e(r,c,s,u,f),r=c,s=u}}}function Uu(n,e,t,i=!1){let r=[],s=i?[]:null,o=new Ri(n),a=new Ri(e);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let c=Math.min(o.len,a.len);Qe(r,c,-1),o.forward(c),a.forward(c)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len=0&&l=0){let c=0,u=o.len;for(;u;)if(a.ins==-1){let f=Math.min(u,a.len);c+=f,u-=f,a.forward(f)}else if(a.ins==0&&a.lenl||o.ins>=0&&o.len>l)&&(a||i.length>c),s.forward2(l),o.forward(l)}}}}var Ri=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?J.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?J.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Hr=class n{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new n(i,r,this.flags)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return R.range(e,t,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return R.range(this.anchor,r,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return R.range(e.anchor,e.head)}static create(e,t,i){return new n(e,t,i)}},R=class n{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:n.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new n(e.ranges.map(t=>Hr.fromJSON(t)),e.main)}static single(e,t=e){return new n([n.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;rr.from-s.from),t=e.indexOf(i);for(let r=1;rs.head?n.range(l,a):n.range(a,l))}}return new n(e,t)}};function uy(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var of=0,N=class n{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=of++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new n(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:af),!!e.static,e.enables)}of(e){return new Ur([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ur(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ur(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function af(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var Ur=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=of++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,a=this.type==2,l=!1,c=!1,u=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?c=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&u.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,h){if(l&&h.docChanged||c&&(h.docChanged||h.selection)||Yu(f,u)){let d=i(f);if(a?!sy(d,f.values[o],r):!r(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,h)=>{let d,p=h.config.address[s];if(p!=null){let m=hl(h,p);if(this.dependencies.every(y=>y instanceof N?h.facet(y)===f.facet(y):y instanceof Ne?h.field(y,!1)==f.field(y,!1):!0)||(a?sy(d=i(f),m,r):r(d=i(f),m)))return f.values[o]=m,0}else d=i(f);return f.values[o]=d,1}}}};function sy(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[l.id]),r=t.map(l=>l.type),s=i.filter(l=>!(l&1)),o=n[e.id]>>1;function a(l){let c=[];for(let u=0;ui===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(rl).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>{let s=i.facet(rl),o=r.facet(rl),a;return(a=s.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(i.values[t]=a.create(i),1):r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,rl.of({field:this,create:e})]}get extension(){return this}},_i={lowest:4,low:3,default:2,high:1,highest:0};function bo(n){return e=>new ul(e,n)}var Rn={highest:bo(_i.highest),high:bo(_i.high),default:bo(_i.default),low:bo(_i.low),lowest:bo(_i.lowest)},ul=class{constructor(e,t){this.inner=e,this.prec=t}},Pi=class n{of(e){return new Oo(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Oo=class{constructor(e,t){this.compartment=e,this.inner=t}},fl=class n{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let h of VC(e,t,o))h instanceof Ne?r.push(h):(s[h.facet.id]||(s[h.facet.id]=[])).push(h);let a=Object.create(null),l=[],c=[];for(let h of r)a[h.id]=c.length<<1,c.push(d=>h.slot(d));let u=i==null?void 0:i.config.facets;for(let h in s){let d=s[h],p=d[0].facet,m=u&&u[h]||[];if(d.every(y=>y.type==0))if(a[p.id]=l.length<<1|1,af(m,d))l.push(i.facet(p));else{let y=p.combine(d.map(g=>g.value));l.push(i&&p.compare(y,i.facet(p))?i.facet(p):y)}else{for(let y of d)y.type==0?(a[y.id]=l.length<<1|1,l.push(y.value)):(a[y.id]=c.length<<1,c.push(g=>y.dynamicSlot(g)));a[p.id]=c.length<<1,c.push(y=>jC(y,p,d))}}let f=c.map(h=>h(a));return new n(e,o,f,a,l,s)}};function VC(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,a){let l=r.get(o);if(l!=null){if(l<=a)return;let c=i[l].indexOf(o);c>-1&&i[l].splice(c,1),o instanceof Oo&&t.delete(o.compartment)}if(r.set(o,a),Array.isArray(o))for(let c of o)s(c,a);else if(o instanceof Oo){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),s(c,a)}else if(o instanceof ul)s(o.inner,o.prec);else if(o instanceof Ne)i[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof Ur)i[a].push(o),o.facet.extensions&&s(o.facet.extensions,_i.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,a)}}return s(n,_i.default),i.reduce((o,a)=>o.concat(a))}function wo(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function hl(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var fy=N.define(),Ku=N.define({combine:n=>n.some(e=>e),static:!0}),hy=N.define({combine:n=>n.length?n[0]:void 0,static:!0}),dy=N.define(),py=N.define(),my=N.define(),gy=N.define({combine:n=>n.length?n[0]:!1}),gt=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Gu}},Gu=class{of(e){return new gt(this,e)}},Ju=class{constructor(e){this.map=e}of(e){return new U(this,e)}},U=class n{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new n(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ju(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}};U.reconfigure=U.define();U.appendConfig=U.define();var $e=class n{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&uy(i,t.newLength),s.some(a=>a.type==n.time)||(this.annotations=s.concat(n.time.of(Date.now())))}static create(e,t,i,r,s,o){return new n(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let 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(n.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};$e.time=gt.define();$e.userEvent=gt.define();$e.addToHistory=gt.define();$e.remote=gt.define();function QC(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i=n[i]))s=n[i++],o=n[i++];else if(r=0;r--){let s=i[r](n);s instanceof $e?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof $e?n=s[0]:n=vy(e,Yr(s),!1)}return n}function WC(n){let e=n.startState,t=e.facet(my),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=yy(i,Zu(e,s,n.changes.newLength),!0))}return i==n?n:$e.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var HC=[];function Yr(n){return n==null?HC:Array.isArray(n)?n:[n]}var Ge=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(Ge||(Ge={})),XC=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,ef;try{ef=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function UC(n){if(ef)return ef.test(n);for(let e=0;e"\x80"&&(t.toUpperCase()!=t.toLowerCase()||XC.test(t)))return!0}return!1}function YC(n){return e=>{if(!/\S/.test(e))return Ge.Space;if(UC(e))return Ge.Word;for(let t=0;t-1)return Ge.Word;return Ge.Other}}var he=class n{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;ar.set(c,l)),t=null),r.set(a.value.compartment,a.value.extension)):a.is(U.reconfigure)?(t=null,i=a.value):a.is(U.appendConfig)&&(t=null,i=Yr(i).concat(a.value));let s;t?s=e.startState.values.slice():(t=fl.resolve(i,r,this),s=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let o=e.startState.facet(Ku)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,o,s,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:R.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=Yr(i.effects);for(let a=1;ao.spec.fromJSON(a,l)))}}return n.create({doc:e.doc,selection:R.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=fl.resolve(e.extensions||[],new Map),i=e.doc instanceof J?e.doc:J.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||Hu)),r=e.selection?e.selection instanceof R?e.selection:R.single(e.selection.anchor,e.selection.head):R.single(0);return uy(r,i.length),t.staticFacet(Ku)||(r=r.asSingle()),new n(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||` `}get readOnly(){return this.facet(gy)}phrase(e,...t){for(let i of this.facet(n.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(fy))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return YC(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,a=e-i;for(;o>0;){let l=Re(t,o,!1);if(s(t.slice(l,o))!=Ge.Word)break;o=l}for(;an.length?n[0]:4});he.lineSeparator=hy;he.readOnly=gy;he.phrases=N.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});he.languageData=fy;he.changeFilter=dy;he.transactionFilter=py;he.transactionExtender=my;Pi.reconfigure=U.define();function ei(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],a=i[s];if(a===void 0)i[s]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](a,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var Et=class{eq(e){return this==e}range(e,t=e){return ko.create(e,t,this)}};Et.prototype.startSide=Et.prototype.endSide=0;Et.prototype.point=!1;Et.prototype.mapMode=Ee.TrackDel;function lf(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}var ko=class n{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new n(e,t,i)}};function tf(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var nf=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,a=s.length;;){if(o==a)return o;let l=o+a>>1,c=s[l]-e||(i?this.value[l].endSide:this.value[l].startSide)-t;if(l==o)return c>=0?o:a;c>=0?a=l:o=l+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);sd||h==d&&c.startSide>0&&c.endSide<=0)continue;(d-h||c.endSide-c.startSide)<0||(o<0&&(o=h),c.point&&(a=Math.max(a,d-h)),i.push(c),r.push(h-o),s.push(d-o))}return{mapped:i.length?new n(r,s,i,a):null,pos:o}}},re=class n{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new n(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let 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:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(tf)),this.isEmpty)return t.length?n.of(t):this;let a=new dl(this,null,-1).goto(0),l=0,c=[],u=new Mn;for(;a.value||l=0){let f=t[l++];u.addInner(f.from,f.to,f.value)||c.push(f)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||sa.to||s=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Co.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Co.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=oy(o,a,i),c=new Ti(o,l,s),u=new Ti(a,l,s);i.iterGaps((f,h,d)=>ay(c,f,u,h,d,r)),i.empty&&i.length==0&&ay(c,0,u,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),o=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let a=oy(s,o),l=new Ti(s,a,0).goto(i),c=new Ti(o,a,0).goto(i);for(;;){if(l.to!=c.to||!rf(l.active,c.active)||l.point&&(!c.point||!lf(l.point,c.point)))return!1;if(l.to>r)return!0;l.next(),c.next()}}static spans(e,t,i,r,s=-1){let o=new Ti(e,null,s).goto(t),a=t,l=o.openStart;for(;;){let c=Math.min(o.to,i);if(o.point){let u=o.activeForPoint(o.to),f=o.pointFroma&&(r.span(a,c,o.active,l),l=o.openEnd(c));if(o.to>i)return l+(o.point&&o.to>i?1:0);a=o.to,o.next()}}static of(e,t=!1){let i=new Mn;for(let r of e instanceof ko?[e]:t?KC(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return n.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=n.empty;r=r.nextLayer)t=new n(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}};re.empty=new re([],[],null,-1);function KC(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(tf);e=i}return n}re.empty.nextLayer=re.empty;var Mn=class n{finishChunk(e){this.chunks.push(new nf(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,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new n)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.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 i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(re.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=re.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function oy(n,e,t){let i=new Map;for(let s of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&r.push(new dl(o,t,i,s));return r.length==1?r[0]:new n(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)zu(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)zu(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),zu(this.heap,0)}}};function zu(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}var Ti=class{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Co.from(e,t,i)}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){sl(this.active,e),sl(this.activeTo,e),sl(this.activeRank,e),this.minActive=ly(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t0;)t++;ol(this.active,t,i),ol(this.activeTo,t,r),ol(this.activeRank,t,s),e&&ol(e,t,this.cursor.from),this.minActive=ly(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&sl(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[r]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}};function ay(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,a=i,l=i-e,c=!!s.boundChange;for(let u=!1;;){let f=n.to+l-t.to,h=f||n.endSide-t.endSide,d=h<0?n.to+l:t.to,p=Math.min(d,o);if(n.point||t.point?(n.point&&t.point&&lf(n.point,t.point)&&rf(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(a,p,n.point,t.point),u=!1):(u&&s.boundChange(a),p>a&&!rf(n.active,t.active)&&s.compareRange(a,p,n.active,t.active),c&&po)break;a=d,h<=0&&n.next(),h>=0&&t.next()}}function rf(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function ly(n,e){let t=-1,i=1e9;for(let r=0;r=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=Re(n,r)}return i===!0?-1:n.length}var by=typeof Symbol=="undefined"?"__\u037C":Symbol.for("\u037C"),cf=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),wy=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},_t=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,a,l,c){let u=[],f=/^@(\w+)\b/.exec(o[0]),h=f&&f[1]=="keyframes";if(f&&a==null)return l.push(o[0]+";");for(let d in a){let p=a[d];if(/&/.test(d))s(d.split(/,\s*/).map(m=>o.map(y=>m.replace(/&/,y))).reduce((m,y)=>m.concat(y)),p,l);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),p,u,h)}else p!=null&&u.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(u.length||h)&&l.push((i&&!f&&!c?o.map(i):o).join(", ")+" {"+u.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=wy[by]||1;return wy[by]=e+1,"\u037C"+e.toString(36)}static mount(e,t,i){let r=e[cf],s=i&&i.nonce;r?s&&r.setNonce(s):r=new uf(e,s),r.mount(Array.isArray(t)?t:[t],e)}},Oy=new Map,uf=class{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=Oy.get(i);if(s)return e[cf]=s;this.sheet=new r.CSSStyleSheet,Oy.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[cf]=this}mount(e,t){let i=this.sheet,r=0,s=0;for(let o=0;o-1&&(this.modules.splice(l,1),s--,l=-1),l==-1){if(this.modules.splice(s++,0,a),i)for(let c=0;c",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},GC=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),JC=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Se=0;Se<10;Se++)Pn[48+Se]=Pn[96+Se]=String(Se);var Se;for(Se=1;Se<=24;Se++)Pn[Se+111]="F"+Se;var Se;for(Se=65;Se<=90;Se++)Pn[Se]=String.fromCharCode(Se+32),Gr[Se]=String.fromCharCode(Se);var Se;for(pl in Pn)Gr.hasOwnProperty(pl)||(Gr[pl]=Pn[pl]);var pl;function ky(n){var e=GC&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||JC&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Gr:Pn)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function yt(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var r=t[i];typeof r=="string"?n.setAttribute(i,r):r!=null&&(n[i]=r)}e++}for(;e2),$={mac:Ay||/Mac/.test(Ze.platform),windows:/Win/.test(Ze.platform),linux:/Linux|X11/.test(Ze.platform),ie:Vl,ie_version:n0?gf.documentMode||6:vf?+vf[1]:yf?+yf[1]:0,gecko:Sy,gecko_version:Sy?+(/Firefox\/(\d+)/.exec(Ze.userAgent)||[0,0])[1]:0,chrome:!!ff,chrome_version:ff?+ff[1]:0,ios:Ay,android:/Android\b/.test(Ze.userAgent),webkit:Ey,webkit_version:Ey?+(/\bAppleWebKit\/(\d+)/.exec(Ze.userAgent)||[0,0])[1]:0,safari:xf,safari_version:xf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Ze.userAgent)||[0,0])[1]:0,tabSize:gf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function nh(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}var El=Object.create(null);function ih(n,e,t){if(n==e)return!0;n||(n=El),e||(e=El);let i=Object.keys(n),r=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function ZC(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function _y(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function eS(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new Li(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=i0(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Li(e,i,r,t,e.widget||null,!0)}static line(e){return new Lo(e)}static set(e,t=!1){return re.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};X.none=re.empty;var Io=class n extends X{constructor(e){let{start:t,end:i}=i0(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?nh(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||El}eq(e){return this==e||e instanceof n&&this.tagName==e.tagName&&ih(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};Io.prototype.point=!1;var Lo=class n extends X{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&ih(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)}};Lo.prototype.mapMode=Ee.TrackBefore;Lo.prototype.point=!0;var Li=class n extends X{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Ee.TrackBefore:Ee.TrackAfter:Ee.TrackDel}get type(){return this.startSide!=this.endSide?Pt.WidgetRange:this.startSide<=0?Pt.WidgetBefore:Pt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&tS(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)}};Li.prototype.point=!0;function i0(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t!=null?t:e,end:i!=null?i:e}}function tS(n,e){return n==e||!!(n&&e&&n.compare(e))}function ns(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}var Al=class n extends Et{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof n&&this.tagName==e.tagName&&ih(this.attributes,e.attributes)}static create(e){return new n(e.tagName,e.attributes||El)}static set(e,t=!1){return re.of(e,t)}};Al.prototype.startSide=Al.prototype.endSide=-1;function $o(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function bf(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Ao(n,e){if(!e.anchorNode)return!1;try{return bf(n,e.anchorNode)}catch{return!1}}function _o(n){return n.nodeType==3?qo(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function To(n,e,t,i){return t?Ty(n,e,t,i,-1)||Ty(n,e,t,i,1):!1}function ii(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function _l(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function Ty(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:In(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=ii(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?In(n):0}else return!1}}function In(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function No(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function nS(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function r0(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function iS(n,e,t,i,r,s,o,a){let l=n.ownerDocument,c=l.defaultView||window;for(let u=n,f=!1;u&&!f;)if(u.nodeType==1){let h,d=u==l.body,p=1,m=1;if(d)h=nS(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(f=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let k=u.getBoundingClientRect();({scaleX:p,scaleY:m}=r0(u,k)),h={left:k.left,right:k.left+u.clientWidth*p,top:k.top,bottom:k.top+u.clientHeight*m}}let y=0,g=0;if(r=="nearest")e.top0&&e.bottom>h.bottom+g&&(g=e.bottom-h.bottom+o)):e.bottom>h.bottom-o&&(g=e.bottom-h.bottom+o,t<0&&e.top-g0&&e.right>h.right+y&&(y=e.right-h.right+s)):e.right>h.right-s&&(y=e.right-h.right+s,t<0&&e.lefth.bottom||e.lefth.right)&&(e={left:Math.max(e.left,h.left),right:Math.min(e.right,h.right),top:Math.max(e.top,h.top),bottom:Math.min(e.bottom,h.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function s0(n,e=!0){let t=n.ownerDocument,i=null,r=null;for(let s=n.parentNode;s&&!(s==t.body||(!e||i)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),e&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:r}}var wf=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?In(t):0),i,Math.min(e.focusOffset,i?In(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},Bi=null;$.safari&&$.safari_version>=26&&(Bi=!1);function o0(n){if(n.setActive)return n.setActive();if(Bi)return n.focus(Bi);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(Bi==null?{get preventScroll(){return Bi={preventScroll:!0},!0}}:void 0),!Bi){Bi=!1;for(let t=0;tMath.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function l0(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=In(t)}else if(t.parentNode&&!_l(t))i=ii(t),t=t.parentNode;else return null}}function c0(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i=t){if(a.level==i)return o;(s<0||(r!=0?r<0?a.fromt:e[s].level>a.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function h0(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;m-=3)if(fn[m+1]==-d){let y=fn[m+2],g=y&2?r:y&4?y&1?s:r:0;g&&(se[f]=se[fn[m]]=g),a=m;break}}else{if(fn.length==189)break;fn[a++]=f,fn[a++]=h,fn[a++]=l}else if((p=se[f])==2||p==1){let m=p==r;l=m?0:1;for(let y=a-3;y>=0;y-=3){let g=fn[y+2];if(g&2)break;if(m)fn[y+2]|=2;else{if(g&4)break;fn[y+2]|=4}}}}}function fS(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,a=rl;)p==y&&(p=t[--m].from,y=m?t[m-1].to:n),se[--p]=d;l=u}else s=c,l++}}}function kf(n,e,t,i,r,s,o){let a=i%2?2:1;if(i%2==r%2)for(let l=e,c=0;ll&&o.push(new Rt(l,m.from,d));let y=m.direction==$i!=!(d%2);Cf(n,y?i+1:i,r,m.inner,m.from,m.to,o),l=m.to}p=m.to}else{if(p==t||(u?se[p]!=a:se[p]==a))break;p++}h?kf(n,l,p,i+1,r,h,o):le;){let u=!0,f=!1;if(!c||l>s[c-1].to){let m=se[l-1];m!=a&&(u=!1,f=m==16)}let h=!u&&a==1?[]:null,d=u?i:i+1,p=l;e:for(;;)if(c&&p==s[c-1].to){if(f)break e;let m=s[--c];if(!u)for(let y=m.from,g=c;;){if(y==e)break e;if(g&&s[g-1].to==y)y=s[--g].from;else{if(se[y-1]==a)break e;break}}if(h)h.push(m);else{m.tose.length;)se[se.length]=256;let i=[],r=e==$i?0:1;return Cf(n,r,r,t,0,n.length,i),i}function d0(n){return[new Rt(0,n,0)]}var p0="";function dS(n,e,t,i,r){var s;let o=i.head-n.from,a=Rt.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),l=e[a],c=l.side(r,t);if(o==c){let h=a+=r?1:-1;if(h<0||h>=e.length)return null;l=e[a=h],o=l.side(!r,t),c=l.side(r,t)}let u=Re(n.text,o,l.forward(r,t));(ul.to)&&(u=c),p0=n.text.slice(Math.min(o,u),Math.max(o,u));let f=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return f&&u==c&&f.level+(r?0:1)n.some(e=>e)}),mS=N.define({combine:n=>n.some(e=>e)}),O0=N.define(),Mo=class n{constructor(e,t,i,r,s,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new n(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 n(R.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},ml=U.define({map:(n,e)=>n.map(e)}),k0=U.define();function Pe(n,e,t){let i=n.facet(v0);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}var Dn=N.define({combine:n=>n.length?n[0]:!0}),gS=0,Zr=N.define({combine(n){return n.filter((e,t)=>{for(let i=0;i{let l=[];return o&&l.push(Ql.of(c=>{let u=c.plugin(a);return u?o(u):X.none})),s&&l.push(s(a)),l})}static fromClass(e,t){return n.define((i,r)=>new e(i,r),t)}},Ro=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(Pe(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Pe(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){Pe(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},C0=N.define(),ah=N.define(),Ql=N.define(),S0=N.define(),lh=N.define(),Fo=N.define(),E0=N.define();function Ry(n,e){let t=n.state.facet(E0);if(!t.length)return t;let i=t.map(s=>s instanceof Function?s(n):s),r=[];return re.spans(i,e.from,e.to,{point(){},span(s,o,a,l){let c=s-e.from,u=o-e.from,f=r;for(let h=a.length-1;h>=0;h--,l--){let d=a[h].spec.bidiIsolate,p;if(d==null&&(d=pS(e.text,c,u)),l>0&&f.length&&(p=f[f.length-1]).to==c&&p.direction==d)p.to=u,f=p.inner;else{let m={from:c,to:u,direction:d,inner:[]};f.push(m),f=m.inner}}}}),r}var A0=N.define();function ch(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(A0)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}var So=N.define(),Ht=class n{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new n(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,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toAr.push(new Ht(s,o,a,l))),this.changedRanges=r}static create(e,t,i){return new n(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},yS=[],pe=class{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return yS}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&ZC(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let r of this.children){if(r==e)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let i=ii(this.dom),r=this.length?e>0:t>0;return new hn(this.parent.dom,i+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof ss)return e;return null}static get(e){return e.cmTile}},rs=class extends pe{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,r,s=(e==null?void 0:e.node)==t?e:null,o=0;for(let a of this.children){if(a.sync(e),o+=a.length+a.breakAfter,r=i?i.nextSibling:t.firstChild,s&&r!=a.dom&&(s.written=!0),a.dom.parentNode==t)for(;r&&r!=a.dom;)r=Py(r);else t.insertBefore(a.dom,r);i=a.dom}for(r=i?i.nextSibling:t.firstChild,s&&r&&(s.written=!0);r;)r=Py(r);this.length=o}};function Py(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var ss=class extends rs{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=pe.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&s++,r=t.pop()}else{let o=i.children[r++];if(o instanceof Bn)t.push(r),i=o,r=0;else{let a=s+o.length,l=e(o,s);if(l!==void 0)return l;s=a+o.breakAfter}}}resolveBlock(e,t){let i,r=-1,s,o=-1;if(this.blockTiles((a,l)=>{let c=l+a.length;if(e>=l&&e<=c){if(a.isWidget()&&t>=-1&&t<=1){if(a.flags&32)return!0;a.flags&16&&(i=void 0)}(le||e==l&&(t>1?a.length:a.covers(-1)))&&(!s||!a.isWidget()&&s.isWidget())&&(s=a,o=e-l)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&t<0||!s?{tile:i,offset:r}:{tile:s,offset:o}}},Bn=class n extends rs{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new n(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}},os=class n extends rs{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let r=new n(t||document.createElement("div"),e);return(!t||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,i){let r=null,s=-1,o=null,a=-1;function l(u,f){for(let h=0,d=0;h=f&&(p.isComposite()?l(p,f-d):(!o||o.isHidden&&(t>0||i&&xS(o,p)))&&(m>f||p.flags&32)?(o=p,a=f-d):(di&&(e=i);let r=e,s=e,o=0;e==0&&t<0||e==i&&t>=0?$.chrome||$.gecko||(e?(r--,o=1):s=0)?0:a.length-1];return $.safari&&!o&&l.width==0&&(l=Array.prototype.find.call(a,c=>c.width)||l),o?No(l,o<0):l||null}static of(e,t){let i=new n(t||document.createTextNode(e),e);return t||(i.flags|=2),i}},Ni=class n extends pe{constructor(e,t,i,r){super(e,t,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(i)return No(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let a=this.flags&16?!0:this.flags&32?!1:e>0;for(let l=a?s.length-1:0;o=s[l],!(e>0?l==0:l==s.length-1||o.top0;)if(r.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!a.length)break;i&&i.leave(r),o=!!r.breakAfter,{tile:r,index:s}=a.pop(),s++}else{let l=r.children[s],c=l.breakAfter;(t>0?l.length<=e:l.length=0;a--){let l=t.marks[a],c=r.lastChild;if(c instanceof ot&&c.mark.eq(l.mark))c.dom!=l.dom&&c.setDOM(hf(l.dom)),r=c;else{if(this.cache.reused.get(l)){let f=pe.get(l.dom);f&&f.setDOM(hf(l.dom))}let u=ot.of(l.mark,l.dom);r.append(u),r=u}this.cache.reused.set(l,2)}let s=pe.get(e.text);s&&this.cache.reused.set(s,2);let o=new Ii(e.text,e.text.nodeValue);o.flags|=8,r.append(o)}addInlineWidget(e,t,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(t,i);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=_0);let r=os.start(e,t||((i=this.cache.find(os))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],a;if(t>0&&(a=r.lastChild)&&a instanceof ot&&a.mark.eq(o))r=a,t--;else{let l=ot.of(o,(i=this.cache.find(ot,c=>c.mark.eq(o)))===null||i===void 0?void 0:i.dom);r.append(l),r=l,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Dy(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!($.ios&&Dy(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(df,0,32)||new Ni(df.toDOM(),0,df,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=new Af(e.from,e.to,e.value,e.rank),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-t.rank||this.wrappers[i-1].to-t.to)<0;)i--;this.wrappers.splice(i,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let r=t.lastChild;if(i.fromo.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(as,void 0,1);return i&&(i.flags=t),i||new as(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},Tf=class{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let a=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,a)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}},Ml=[Ni,os,Ii,ot,as,Bn,ss];for(let n=0;n[]),this.index=Ml.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let a=s.length-1;a>=0;a--){let l=(a+o)%s.length,c=s[l];if((!t||t(c))&&!this.reused.has(c))return s.splice(l,1),l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let r=0,s=0,o=0;;){let a=or){let c=l-r;this.preserve(c,!o,!a),r=l,s+=c}if(!a)break;t&&a.fromA<=t.range.fromA&&a.toA>=t.range.toA?(this.forward(a.fromA,t.range.fromA,t.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(l-a);else{let c=l>0||a{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof ot&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof ot&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,r=this.builder,s=0,o=re.spans(this.decorations,e,t,{point:(a,l,c,u,f,h)=>{if(c instanceof Li){if(this.disallowBlockEffectsFor[h]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(l>this.view.state.doc.lineAt(a).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=u.length,f>u.length)r.continueWidget(l-a);else{let d=c.widget||(c.block?ri.block:ri.inline),p=bS(c),m=this.cache.findWidget(d,l-a,p)||Ni.of(d,this.view,l-a,p);c.block?(c.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(m)):(r.ensureLine(i),r.addInlineWidget(m,u,f))}i=null}else i=wS(i,c);l>a&&this.text.skip(l-a)},span:(a,l,c,u)=>{for(let f=a;fs,this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let s=pe.get(r);if(r==this.view.contentDOM)break;s instanceof ot?t.push(s):s!=null&&s.isLine()?i=s:s instanceof Bn||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new os(r,_0):i||t.push(ot.of(new Io({tagName:r.nodeName.toLowerCase(),attributes:eS(r)}),r)))}return{line:i,marks:t}}};function Dy(n,e){let t=i=>{for(let r of i.children)if((e?r.isText():r.length)||t(r))return!0;return!1};return t(n)}function bS(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}var _0={class:"cm-line"};function wS(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&nh(t,n),i&&(n.class+=" "+i)),n}function OS(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof ot&&e.push(i.mark)}return e}function hf(n){let e=pe.get(n);return e&&e.setDOM(n.cloneNode()),n}var ri=class extends Dt{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}};ri.inline=new ri("span");ri.block=new ri("div");var df=new class extends Dt{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},Rl=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=X.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new ss(e,e.contentDOM),this.updateInner([new Ht(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:u,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!MS(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?CS(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:u,to:f}=this.hasComposition;i=new Ht(u,f,e.changes.mapPos(u,-1),e.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,($.ie||$.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,a=this.blockWrappers;this.updateDeco();let l=AS(o,this.decorations,e.changes);l.length&&(i=Ht.extendWithRanges(i,l));let c=_S(a,this.blockWrappers,e.changes);return c.length&&(i=Ht.extendWithRanges(i,c)),s&&!i.some(u=>u.fromA<=s.range.fromA&&u.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,a=new Rf(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&pe.get(t.text)&&a.cache.reused.set(pe.get(t.text),2),this.tile=a.run(e,t),Pf(o,a.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=$.chrome||$.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ao(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||t||o))return;let a=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,c,u;if(l.empty?u=c=this.inlineDOMNearPos(l.anchor,l.assoc||1):(u=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),c=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),$.gecko&&l.empty&&!this.hasComposition&&kS(c)){let h=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(h,c.node.childNodes[c.offset]||null)),c=u=new hn(h,0),a=!0}let f=this.view.observer.selectionRange;(a||!f.focusNode||(!To(c.node,c.offset,f.anchorNode,f.anchorOffset)||!To(u.node,u.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,l))&&(this.view.observer.ignore(()=>{$.android&&$.chrome&&i.contains(f.focusNode)&&TS(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let h=$o(this.view.root);if(h)if(l.empty){if($.gecko){let d=SS(c.node,c.offset);if(d&&d!=3){let p=(d==1?l0:c0)(c.node,c.offset);p&&(c=new hn(p.node,p.offset))}}h.collapse(c.node,c.offset),l.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=l.bidiLevel)}else if(h.extend){h.collapse(c.node,c.offset);try{h.extend(u.node,u.offset)}catch{}}else{let d=document.createRange();l.anchor>l.head&&([c,u]=[u,c]),d.setEnd(u.node,u.offset),d.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,u)),this.impreciseAnchor=c.precise?null:new hn(f.anchorNode,f.anchorOffset),this.impreciseHead=u.precise?null:new hn(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&To(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,i=$o(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let a=o.posAtStart;if(t.head==a||t.head==a+o.length)return;let l=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!l||!c||l.bottom>c.top)return;let u=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(u.node,u.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(r,s)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[t];else{let o=In(e)==0?0:t==0?-1:1;for(;;){let a=e.parentNode;if(a==i.dom)break;o==0&&a.firstChild!=a.lastChild&&(e==a.firstChild?o=-1:o=1),e=a}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!pe.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let o=0,a=r;;o++){let l=i.children[o];if(l.dom==s)return a;a+=l.length+l.breakAfter}}else return i.isText()?e==i.dom?r+t:r+(t?i.length:0):r}domAtPos(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(e,t):i.domIn(r,t)}inlineDOMNearPos(e,t){let i,r=-1,s=!1,o,a=-1,l=!1;return this.tile.blockTiles((c,u)=>{if(c.isWidget()){if(c.flags&32&&u>=e)return!0;c.flags&16&&(s=!0)}else{let f=u+c.length;if(u<=e&&(i=c,r=e-u,s=f=e&&!o&&(o=c,a=e-u,l=u>e),u>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(s&&o?i=null:l&&i&&(o=null),i&&t<0||!o?i.domIn(r,t):o.domIn(a,t))}coordsAt(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof Po?null:i.coordsInWidget(r,t,!0):i.coordsIn(r,t)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(s,o){if(s.isComposite())for(let a of s.children){if(a.length>=o){let l=r(a,o);if(l)return l}if(o-=a.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==ue.LTR,c=0,u=(f,h,d)=>{for(let p=0;pr);p++){let m=f.children[p],y=h+m.length,g=m.dom.getBoundingClientRect(),{height:k}=g;if(d&&!p&&(c+=g.top-d.top),m instanceof Bn)y>i&&u(m,h,g);else if(h>=i&&(c>0&&t.push(-c),t.push(k+c),c=0,o)){let x=m.dom.lastChild,b=x?_o(x):[];if(b.length){let C=b[b.length-1],O=l?C.right-g.left:g.right-C.left;O>a&&(a=O,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=y)}}d&&p==f.children.length-1&&(c+=d.bottom-g.bottom),h=y+m.breakAfter}};return u(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?ue.RTL:ue.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let a=0,l;for(let c of o.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let u=_o(c.dom);if(u.length!=1)return;a+=u[0].width,l=u[0].height}if(a)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:a/o.length,textHeight:l}}});if(e)return e;let t=document.createElement("div"),i,r,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=_o(t.firstChild)[0];i=t.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>i){let a=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(X.replace({widget:new Po(a),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return X.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Ql).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(lh).map((s,o)=>{let a=typeof s=="function";return a&&(i=!0),a?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=i,t.push(re.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){var t;if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(O0))try{if(u(this.view,e.range,e))return!0}catch(f){Pe(this.view.state,f,"scroll handler")}let{range:i}=e,r=this.coordsAt(i.head,(t=i.assoc)!==null&&t!==void 0?t:i.empty?0:i.head>i.anchor?-1:1),s;if(!r)return;!i.empty&&(s=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let o=ch(this.view),a={left:r.left-o.left,top:r.top-o.top,right:r.right+o.right,bottom:r.bottom+o.bottom},{offsetWidth:l,offsetHeight:c}=this.view.scrollDOM;if(iS(this.view.scrollDOM,a,i.head1&&(r.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||r.bottomi.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Pf(this.tile)}};function Pf(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)Pf(i,e)}}function kS(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function T0(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=l0(t.focusNode,t.focusOffset),r=c0(t.focusNode,t.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let a=pe.get(r.node);if(!a||a.isText()&&a.text!=r.node.nodeValue)s=r;else if(n.docView.lastCompositionAfterCursor){let l=pe.get(i.node);!l||l.isText()&&l.text!=i.node.nodeValue||(s=r)}}if(n.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function CS(n,e,t){let i=T0(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,a=r.nodeValue;if(/[\n\r]/.test(a)||n.state.doc.sliceString(i.from,i.to)!=a)return null;let l=e.invertedDesc;return{range:new Ht(l.mapPos(s),l.mapPos(o),s,o),text:r}}function SS(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}var Po=class extends Dt{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function RS(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return R.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,a=s;t<0?o=Re(r.text,s,!1):a=Re(r.text,s);let l=i(r.text.slice(o,a));for(;o>0;){let c=Re(r.text,o,!1);if(i(r.text.slice(c,o))!=l)break;o=c}for(;an.defaultLineHeight*1.5){let a=n.viewState.heightOracle.textHeight,l=Math.floor((r-t.top-(n.defaultLineHeight-a)*.5)/a);s+=l*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+xy(o,s,n.state.tabSize)}function DS(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>e)break;if(!(s.toe)return s;(!r||s.type==Pt.Text&&(r.type!=s.type||(t<0?s.frome)))&&(r=s)}}return r||i}return i}function BS(n,e,t,i){let r=DS(n,e.head,e.assoc||-1),s=!i||r.type!=Pt.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),a=n.textDirectionAt(r.from),l=n.posAtCoords({x:t==(a==ue.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(l!=null)return R.cursor(l,t?-1:1)}return R.cursor(t?r.to:r.from,t?-1:1)}function By(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let a=e,l=null;;){let c=dS(r,s,o,a,t),u=p0;if(!c){if(r.number==(t?n.state.doc.lines:1))return a;u=` `,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),c=n.visualLineSide(r,!t)}if(l){if(!l(u))return a}else{if(!i)return c;l=i(u)}a=c}}function IS(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==Ge.Space&&(r=o),r==o}}function LS(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return R.cursor(r,e.assoc);let o=e.goalColumn,a,l=n.contentDOM.getBoundingClientRect(),c=n.coordsAtPos(r,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),u=n.documentTop;if(c)o==null&&(o=c.left-l.left),a=s<0?c.top:c.bottom;else{let p=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(l.right-l.left,n.defaultCharacterWidth*(r-p.from))),a=(s<0?p.top:p.bottom)+u}let f=l.left+o,h=n.viewState.heightOracle.textHeight>>1,d=i!=null?i:h;for(let p=0;;p+=h){let m=a+(d+p)*s,y=Bf(n,{x:f,y:m},!1,s);if(t?m>l.bottom:ma:k{if(e>s&&er(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:R.cursor(i,in.viewState.docHeight)return new Mt(n.state.doc.length,-1);if(c=n.elementAtHeight(l),i==null)break;if(c.type==Pt.Text){if(i<0?c.ton.viewport.to)break;let h=n.docView.coordsAt(i<0?c.from:c.to,i>0?-1:1);if(h&&(i<0?h.top<=l+s:h.bottom>=l+s))break}let f=n.viewState.heightOracle.textHeight/2;l=i>0?c.bottom+f:c.top-f}if(n.viewport.from>=c.to||n.viewport.to<=c.from){if(t)return null;if(c.type==Pt.Text){let f=PS(n,r,c,o,a);return new Mt(f,f==c.from?1:-1)}}if(c.type!=Pt.Text)return l<(c.top+c.bottom)/2?new Mt(c.from,1):new Mt(c.to,-1);let u=n.docView.lineAt(c.from,2);return(!u||u.length!=c.length)&&(u=n.docView.lineAt(c.from,-2)),new If(n,o,a,n.textDirectionAt(c.from)).scanTile(u,c.from)}var If=class{constructor(e,t,i,r){this.view=e,this.x=t,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from>1;t:if(s.has(p)){let y=i+Math.floor(Math.random()*d);for(let g=0;g1)){if(g.bottomthis.y)(!l||l.top>g.top)&&(l=g),k=-1;else{let x=g.left>this.x?this.x-g.left:g.right(d+d+p)/3)return this.y=a.bottom-1,this.scan(e,t);if(l&&l.top<(d+p+p)/3)return this.y=l.top+1,this.scan(e,t)}let h=(o?this.dirAt(e[c],1):this.baseDir)==ue.LTR;return{i:c,after:this.x>(f.left+f.right)/2==h}}scanText(e,t){let i=[];for(let s=0;s{let o=i[s]-t,a=i[s+1]-t;return qo(e.dom,o,a).getClientRects()});return r.after?new Mt(i[r.i+1],-1):new Mt(i[r.i],1)}scanTile(e,t){if(!e.length)return new Mt(t,1);if(e.children.length==1){let a=e.children[0];if(a.isText())return this.scanText(a,t);if(a.isComposite())return this.scanTile(a,t)}let i=[t];for(let a=0,l=t;a{let l=e.children[a];return l.flags&48?null:(l.dom.nodeType==1?l.dom:qo(l.dom,0,l.length)).getClientRects()}),s=e.children[r.i],o=i[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new Mt(i[r.i+1],-1):new Mt(o,1)}},Jr="\uFFFF",Lf=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(he.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Jr}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=pe.get(r),a=r.nextSibling;if(a==t){o!=null&&o.breakAfter&&!a&&i!=this.view.contentDOM&&this.lineBreak();break}let l=pe.get(a);(o&&l?o.breakAfter:(o?o.breakAfter:_l(r))||_l(a)&&(r.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!NS(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,a;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(a=r.exec(t))&&(s=a.index,o=a[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=o-1);i=s+o}}readNode(e){let t=pe.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+($S(e,i.node,i.offset)?t:0))}};function $S(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,a=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=R0(e.docView.tile,t,i,0))){let l=s||o?[]:FS(e),c=new Lf(l,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=jS(l,this.bounds.from)}else{let l=e.observer.selectionRange,c=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!bf(e.contentDOM,l.focusNode)?a.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),u=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!bf(e.contentDOM,l.anchorNode)?a.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),f=e.viewport;if(($.ios||$.chrome)&&a.main.empty&&c!=u&&(f.from>0||f.to-1&&a.ranges.length>1)this.newSel=a.replaceRange(R.range(u,c));else if(e.lineWrapping&&u==c&&!(a.main.empty&&a.main.head==c)&&e.inputState.lastTouchTime>Date.now()-100){let h=e.coordsAtPos(c,-1),d=0;h&&(d=e.inputState.lastTouchY<=h.bottom?-1:1),this.newSel=R.create([R.cursor(c,d)])}else this.newSel=R.single(u,c)}}};function R0(n,e,t,i){if(n.isComposite()){let r=-1,s=-1,o=-1,a=-1;for(let l=0,c=i,u=i;lt)return R0(f,e,t,c);if(h>=e&&r==-1&&(r=l,s=c),c>t&&f.dom.parentNode==n.dom){o=l,a=u;break}u=h,c=h+f.breakAfter}return{from:s,to:a<0?i+n.length:a,startDOM:(r?n.children[r-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o=0?n.children[o].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function P0(n,e){let t,{newSel:i}=e,{state:r}=n,s=r.selection.main,o=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:l}=e.bounds,c=s.from,u=null;(o===8||$.android&&e.text.length=a&&s.to<=l&&(e.typeOver||f!=e.text)&&f.slice(0,s.from-a)==e.text.slice(0,s.from-a)&&f.slice(s.to-a)==e.text.slice(h=e.text.length-(f.length-(s.to-a)))?t={from:s.from,to:s.to,insert:J.of(e.text.slice(s.from-a,h).split(Jr))}:(d=D0(f,e.text,c-a,u))&&($.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==Jr+Jr&&d.toB--,t={from:a+d.from,to:a+d.toA,insert:J.of(e.text.slice(d.from,d.toB).split(Jr))})}else i&&(!n.hasFocus&&r.facet(Dn)||Dl(i,s))&&(i=null);if(!t&&!i)return!1;if(($.mac||$.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=R.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:J.of([t.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).toDate.now()-50?t={from:s.from,to:s.to,insert:r.toText(n.inputState.insertingText)}:$.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==` `&&n.lineWrapping&&(i&&(i=R.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:J.of([" "])}),t)return uh(n,t,i,o);if(i&&!Dl(i,s)){let a=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(a=!0),l=n.inputState.lastSelectionOrigin,l=="select.pointer"&&(i=M0(r.facet(Fo).map(c=>c(n)),i))),n.dispatch({selection:i,scrollIntoView:a,userEvent:l}),!0}else return!1}function uh(n,e,t,i=-1){if($.ios&&n.inputState.flushIOSKey(e))return!0;let r=n.state.selection.main;if($.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&n.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&is(n.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.lengthr.head)&&is(n.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&is(n.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,a=()=>o||(o=qS(n,e,t));return n.state.facet(x0).some(l=>l(n,e.from,e.to,s,a))||n.dispatch(a()),!0}function qS(n,e,t){let i,r=n.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let l=e.fromf(n)),c,l);e.from==u&&(o=u)}if(o>-1)i={changes:e,selection:R.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=s.frome.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+c))}else{let l=r.changes(e),c=t&&t.main.to<=l.newLength?t.main:void 0;if(r.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let u=n.state.sliceDoc(e.from,e.to),f,h=t&&T0(n,t.main.head);if(h){let p=e.insert.length-(e.to-e.from);f={from:h.from,to:h.to-p}}else f=n.state.doc.lineAt(s.head);let d=s.to-e.to;i=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:l,range:c||p.map(l)};let m=p.to-d,y=m-u.length;if(n.state.sliceDoc(y,m)!=u||m>=f.from&&y<=f.to)return{range:p};let g=r.changes({from:y,to:m,insert:e.insert}),k=p.to-s.to;return{changes:g,range:c?R.range(Math.max(0,c.anchor+k),Math.max(0,c.head+k)):p.map(g)}})}else i={changes:l,selection:c&&r.selection.replaceRange(c)}}let a="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,a+=".compose",n.inputState.compositionFirstChange&&(a+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:a,scrollIntoView:!0})}function D0(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s0&&a>0&&n.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(i=="end"){let l=Math.max(0,s-Math.min(o,a));t-=o+l-s}if(o=o?s-t:0;s-=l,a=s+(a-o),o=s}else if(a=a?s-t:0;s-=l,o=s+(o-a),a=s}return{from:s,toA:o,toB:a}}function FS(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Pl(t,i)),(r!=t||s!=i)&&e.push(new Pl(r,s))),e}function jS(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?R.single(t+e,i+e):null}function Dl(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}var Nf=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,$.safari&&e.contentDOM.addEventListener("input",()=>null),$.gecko&&tE(e.contentDOM.ownerDocument)}handleEvent(e){!US(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=VS(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,a=i[s];a&&o!=!a.handlers.length&&(r.removeEventListener(s,this.handleEvent),a=null),a||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&I0.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),$.android&&$.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return $.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=B0.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||QS.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:$.safari&&!$.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function Iy(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){Pe(t.state,r)}}}function VS(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let a in s){let l=s[a];l&&t(a).handlers.push(Iy(i.value,l))}if(o)for(let a in o){let l=o[a];l&&t(a).observers.push(Iy(i.value,l))}}for(let i in Xt)t(i).handlers.push(Xt[i]);for(let i in at)t(i).observers.push(at[i]);return e}var B0=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],QS="dthko",I0=[16,17,18,20,91,92,224,225],gl=6;function yl(n){return Math.max(0,n)*.7+8}function zS(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var qf=class{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=s0(e.contentDOM),this.atoms=e.state.facet(Fo).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(he.allowMultipleSelections)&&WS(e,t),this.dragging=XS(e,t)&&N0(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&zS(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,r=0,s=0,o=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=ch(this.view);e.clientX-l.left<=r+gl?t=-yl(r-e.clientX):e.clientX+l.right>=o-gl&&(t=yl(e.clientX-o)),e.clientY-l.top<=s+gl?i=-yl(s-e.clientY):e.clientY+l.bottom>=a-gl&&(i=yl(e.clientY-a)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=M0(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function WS(n,e){let t=n.state.facet(m0);return t.length?t[0](e):$.mac?e.metaKey:e.ctrlKey}function HS(n,e){let t=n.state.facet(g0);return t.length?t[0](e):$.mac?!e.altKey:!e.ctrlKey}function XS(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=$o(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function US(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=pe.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}var Xt=Object.create(null),at=Object.create(null),L0=$.ie&&$.ie_version<15||$.ios&&$.webkit_version<604;function YS(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),$0(n,t.value)},50)}function zl(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function $0(n,e){e=zl(n.state,sh,e);let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(Ff!=null&&t.selection.ranges.every(l=>l.empty)&&Ff==s.toString()){let l=-1;i=t.changeByRange(c=>{let u=t.doc.lineAt(c.from);if(u.from==l)return{range:c};l=u.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:f},range:R.cursor(c.from+f.length)}})}else o?i=t.changeByRange(l=>{let c=s.line(r++);return{changes:{from:l.from,to:l.to,insert:c.text},range:R.cursor(l.from+c.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}at.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};at.wheel=at.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};Xt.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);at.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};at.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Xt.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(y0))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=GS(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new qf(n,e,t,i)),i&&n.observer.ignore(()=>{o0(n.contentDOM);let s=n.root.activeElement;s&&!s.contains(n.contentDOM)&&s.blur()});let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function Ly(n,e,t,i){if(i==1)return R.cursor(e,t);if(i==2)return RS(n.state,e,t);{let r=n.docView.lineAt(e,t),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,a=r?r.posAtEnd:s.to;return aDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(Ny+1)%3:1}function GS(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=N0(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,a){let l=n.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),c,u=Ly(n,l.pos,l.assoc,i);if(t.pos!=l.pos&&!o){let f=Ly(n,t.pos,t.assoc,i),h=Math.min(f.from,u.from),d=Math.max(f.to,u.to);u=h1&&(c=JS(r,l.pos))?c:a?r.addRange(u):R.create([u])}}}function JS(n,e){for(let t=0;t=e)return R.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}Xt.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=R.range(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",zl(n.state,oh,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Xt.dragend=n=>(n.inputState.draggedContent=null,!1);function Fy(n,e,t,i){if(t=zl(n.state,sh,t),!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&HS(n,e)?{from:s.from,to:s.to}:null,a={from:r,insert:t},l=n.state.changes(o?[o,a]:a);n.focus(),n.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Xt.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&Fy(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(i[o]=a.result),s()},a.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Fy(n,e,i,!0),!0}return!1};Xt.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=L0?null:e.clipboardData;return t?($0(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(YS(n),!1)};function ZS(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function eE(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:zl(n,oh,e.join(n.lineBreak)),ranges:t,linewise:i}}var Ff=null;Xt.copy=Xt.cut=(n,e)=>{if(!Ao(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:r}=eE(n.state);if(!t&&!r)return!1;Ff=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=L0?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(ZS(n,t),!1)};var q0=gt.define();function F0(n,e){let t=[];for(let i of n.facet(b0)){let r=i(n,e);r&&t.push(r)}return t.length?n.update({effects:t,annotations:q0.of(!0)}):null}function j0(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=F0(n.state,e);t?n.dispatch(t):n.update([])}},10)}at.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),j0(n)};at.blur=n=>{n.observer.clearSelectionRange(),j0(n)};at.compositionstart=at.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};at.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,$.chrome&&$.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};at.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Xt.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let a=o[0],l=n.posAtDOM(a.startContainer,a.startOffset),c=n.posAtDOM(a.endContainer,a.endOffset);return uh(n,{from:l,to:c,insert:n.state.toText(s)},null),!0}}let r;if($.chrome&&$.android&&(r=B0.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return $.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),$.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>at.compositionend(n,e),20),!1};var jy=new Set;function tE(n){jy.has(n)||(jy.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var Vy=["pre-wrap","normal","pre-line","break-spaces"],ls=!1;function Qy(){ls=!1}var jf=class{constructor(e){this.lineWrapping=e,this.doc=J.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Vy.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,l=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=a||Math.abs(i-this.charWidth)>.1;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,l){this.heightSamples={};for(let c=0;c0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Cl&&(ls=!0),this.height=e)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let a=r.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:f}=r[a],h=s.lineAt(l,ce.ByPosNoHeight,i.setDoc(t),0,0),d=h.to>=c?h:s.lineAt(c,ce.ByPosNoHeight,i,0,0);for(f+=d.to-c,c=d.to;a>0&&h.from<=r[a-1].toA;)l=r[a-1].fromA,u=r[a-1].fromB,a--,ls*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),i+=1+a.break,r-=a.size}else if(s>r*2){let a=e[i];a.break?e.splice(i,1,a.left,null,a.right):e.splice(i,1,a.left,a.right),i+=2+a.break,s-=a.size}else break;else if(r=s&&o(this.lineAt(0,ce.ByPos,i,r,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},Tt=class n extends Il{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new Wt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof n||r instanceof ni&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof ni?r=new n(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):vt.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},ni=class n extends vt{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*s);o=l/s,this.length>s+1&&(a=(this.height-l)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:a}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(t,r);if(t.lineWrapping){let c=r+(e0){let s=i[i.length-1];s instanceof n?i[i.length-1]=new n(s.length+r):i.push(null,new n(r-1))}if(e>0){let s=i[0];s instanceof n?i[0]=new n(e+s.length):i.unshift(new n(e-1),null)}return vt.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],a=Math.max(t,r.from),l=-1;for(r.from>t&&o.push(new n(r.from-t-1).updateHeight(e,t));a<=s&&r.more;){let u=e.doc.lineAt(a).length;o.length&&o.push(null);let f=r.heights[r.index++],h=0;f<0&&(h=-f,f=r.heights[r.index++]),l==-1?l=f:Math.abs(f-l)>=Cl&&(l=-2);let d=new Tt(u,f,h);d.outdated=!1,o.push(d),a+=u+1}a<=s&&o.push(null,new n(s-a).updateHeight(e,a));let c=vt.of(o);return(l<0||Math.abs(c.height-this.height)>=Cl||Math.abs(l-this.heightMetrics(e,t).perLine)>=Cl)&&(ls=!0),Bl(this,c)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Qf=class extends vt{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return ea))return c;let u=t==ce.ByPosNoHeight?ce.ByPosNoHeight:ce.ByPos;return l?c.join(this.right.lineAt(a,u,i,o,a)):this.left.lineAt(a,u,i,r,s).join(c)}forEachLine(e,t,i,r,s,o){let a=r+this.left.height,l=s+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,t,i,a,l,o);else{let c=this.lineAt(l,ce.ByPos,i,r,s);e=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,i,a,l,o)}}replace(e,t,i){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let a of i)s.push(a);if(e>0&&zy(s,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e2*t.size||t.size>2*e.size?vt.of(this.break?[e,null,t]:[e,t]):(this.left=Bl(this.left,e),this.right=Bl(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,a=t+s.length+this.break,l=null;return r&&r.from<=t+s.length&&r.more?l=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=a+o.length&&r.more?l=o=o.updateHeight(e,a,i,r):o.updateHeight(e,a,i),l?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function zy(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof ni&&(i=n[e+1])instanceof ni&&n.splice(e-1,3,new ni(t.length+1+i.length))}var iE=5,zf=class n{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 i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Tt?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Tt(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=iE)&&this.addLineDeco(r,s,o)}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 Tt(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new ni(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Tt)return e;let t=new Tt(0,-1,0);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,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Tt)&&!this.isCovered?this.nodes.push(new Tt(0,-1,0)):(this.writtenTou.clientHeight||u.scrollWidth>u.clientWidth)&&f.overflow!="visible"){let h=u.getBoundingClientRect();s=Math.max(s,h.left),o=Math.min(o,h.right),a=Math.max(a,h.top),l=Math.min(c==n.parentNode?r.innerHeight:l,h.bottom)}c=f.position=="absolute"||f.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function oE(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function aE(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Bo=class{constructor(e,t,i,r){this.from=e,this.to=t,this.size=i,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new jf(i),this.stateDeco=Hy(t),this.heightMap=vt.empty().applyChanges(this.stateDeco,J.empty,this.heightOracle.setDoc(t.doc),[new Ht(0,0,0,t.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=X.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new es(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Wy:new Xf(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Eo(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Hy(this.state);let r=e.changedRanges,s=Ht.extendWithRanges(r,rE(i,this.stateDeco,e?e.changes:Je.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Qy(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||ls)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let l=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(mS)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?ue.RTL:ue.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",a=t.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,u=0;if(a.width&&a.height){let{scaleX:C,scaleY:O}=r0(t,a);(C>.005&&Math.abs(this.scaleX-C)>.005||O>.005&&Math.abs(this.scaleY-O)>.005)&&(this.scaleX=C,this.scaleY=O,c|=16,o=l=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,h=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=h)&&(this.paddingTop=f,this.paddingBottom=h,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let d=s0(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=a0(this.scrollParent||e.win);let m=(this.printing?aE:sE)(t,this.paddingTop),y=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let k=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(k!=this.inView&&(this.inView=k,k&&(l=!0)),!this.inView&&!this.scrollTarget&&!oE(e.dom))return 0;let x=a.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let C=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(C)&&(o=!0),o||r.lineWrapping&&Math.abs(x-this.contentDOMWidth)>r.charWidth){let{lineHeight:O,charWidth:w,textHeight:v}=e.docView.measureTextSize();o=O>0&&r.refresh(s,O,w,v,Math.max(5,x/w),C),o&&(e.docView.minWidth=0,c|=16)}y>0&&g>0?u=Math.max(y,g):y<0&&g<0&&(u=Math.min(y,g)),Qy();for(let O of this.viewports){let w=O.from==this.viewport.from?C:e.docView.measureVisibleLineHeights(O);this.heightMap=(o?vt.empty().applyChanges(this.stateDeco,J.empty,this.heightOracle,[new Ht(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Vf(O.from,w))}ls&&(c|=2)}let b=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return b&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),c|=this.updateForViewport()),(c&2||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new es(r.lineAt(o-i*1e3,ce.ByHeight,s,0,0).from,r.lineAt(a+(1-i)*1e3,ce.ByHeight,s,0,0).to);if(t){let{head:c}=t.range;if(cl.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(c,ce.ByPos,s,0,0),h;t.y=="center"?h=(f.top+f.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c=a+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s>1,o=r<<1;if(this.defaultTextDirection!=ue.LTR&&!i)return[];let a=[],l=(u,f,h,d)=>{if(f-uu&&gg.from>=h.from&&g.to<=h.to&&Math.abs(g.from-u)g.fromk));if(!y){if(fx.from<=f&&x.to>=f)){let x=t.moveToLineBoundary(R.cursor(f),!1,!0).head;x>u&&(f=x)}let g=this.gapSize(h,u,f,d),k=i||g<2e6?g:2e6;y=new Bo(u,f,g,k)}a.push(y)},c=u=>{if(u.length2e6)for(let O of e)O.from>=u.from&&O.fromu.from&&l(u.from,d,u,f),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];re.spans(t,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Eo(this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Eo(this.heightMap.lineAt(this.scaler.fromDOM(e),ce.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Eo(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}},es=class{constructor(e,t){this.from=e,this.to=t}};function lE(n,e,t){let i=[],r=n,s=0;return re.spans(t,n,e,{span(){},point(o,a){o>r&&(i.push({from:r,to:o}),s+=o-r),r=a}},20),r=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],a=o-s;if(i<=a)return s+i;i-=a}}function xl(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function cE(n,e){for(let t of n)if(e(t))return t}var Wy={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function Hy(n){let e=n.facet(Ql).filter(i=>typeof i!="function"),t=n.facet(lh).filter(i=>typeof i!="function");return t.length&&e.push(re.join(t)),e}var Xf=class n{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:a,to:l})=>{let c=t.lineAt(a,ce.ByPos,e,0,0).top,u=t.lineAt(l,ce.ByPos,e,0,0).bottom;return r+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}};function Eo(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new Wt(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>Eo(r,e)):n._content)}var bl=N.define({combine:n=>n.join(" ")}),Uf=N.define({combine:n=>n.indexOf(!0)>-1}),Yf=_t.newName(),V0=_t.newName(),Q0=_t.newName(),z0={"&light":"."+V0,"&dark":"."+Q0};function Kf(n,e,t){return new _t(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}var uE=Kf("."+Yf,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},z0),fE={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},mf=$.ie&&$.ie_version<=11,Gf=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new wf,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);($.ie&&$.ie_version<=11||$.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&$.android&&e.constructor.EDIT_CONTEXT!==!1&&!($.chrome&&$.chrome_version<126)&&(this.editContext=new Jf(e),e.state.facet(Dn)&&(e.contentDOM.editContext=this.editContext.editContext)),mf&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){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:i}=this,r=this.selectionRange;if(i.state.facet(Dn)?i.root.activeElement!=this.dom:!Ao(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}($.ie&&$.ie_version<=11||$.android&&$.chrome)&&!i.state.selection.main.empty&&r.focusNode&&To(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=$o(e.root);if(!t)return!1;let i=$.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&hE(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let r=Ao(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&is(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&Ao(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new $f(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=P0(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!Dl(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Xy(t,e.previousSibling||e.target.previousSibling,-1),r=Xy(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Dn)!=e.state.facet(Dn)&&(e.view.contentDOM.editContext=e.state.facet(Dn)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function Xy(n,e,t){for(;e;){let i=pe.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Uy(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return To(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function hE(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return Uy(n,r)}let t=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?Uy(n,t):null}var Jf=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,a=this.toEditorPos(i.updateRangeStart),l=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:a,drifted:!1});let c=l-a>i.text.length;a==this.from&&sthis.to&&(l=s);let u=D0(e.state.sliceDoc(a,l),i.text,(c?r.from:r.to)-a,c?"end":null);if(!u){let h=R.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Dl(h,r)||e.dispatch({selection:h,userEvent:"select"});return}let f={from:u.from+a,to:u.toA+a,insert:J.of(i.text.slice(u.from,u.toB).split(` `))};if(($.mac||$.android)&&f.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:a,to:l,insert:J.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let h=this.to-this.from+(f.to-f.from+f.insert.length);uh(e,f,R.single(this.toEditorPos(i.selectionStart,h),this.toEditorPos(i.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),a=this.toEditorPos(i.rangeEnd);o{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,a=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(a)){let l=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(l{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let r=$o(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,a,l,c)=>{if(i)return;let u=c.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=u,this.to+=u;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=u,this.to+=u;else if(sthis.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),c.toString()),this.to+=u}t+=u}),r&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},q=class n{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||rS(e.parent)||document,this.viewState=new Ll(this,e.state||he.create(e)),e.scrollTo&&e.scrollTo.is(ml)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Zr).map(r=>new Ro(r));for(let r of this.plugins)r.update(this);this.observer=new Gf(this),this.inputState=new Nf(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Rl(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof $e?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let h of e){if(h.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=h.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,a=0,l=null;e.some(h=>h.annotation(q0))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=F0(s,o),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(u=null)):this.observer.clear(),s.facet(he.phrases)!=this.state.facet(he.phrases))return this.setState(s);r=Tl.create(this,s,e),r.flags|=a;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(f&&(f=f.map(h.changes)),h.scrollIntoView){let{main:d}=h.state.selection,{x:p,y:m}=this.state.facet(n.cursorScrollMargin);f=new Mo(d.empty?d:R.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of h.effects)d.is(ml)&&(f=d.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=$l.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(So)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(bl)!=r.state.facet(bl)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let h of this.state.facet(Sf))try{h(r)}catch(d){Pe(this.state,d,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!P0(this,u)&&c.force&&is(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Ll(this,e),this.plugins=e.facet(Zr).map(i=>new Ro(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Rl(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Zr),i=e.state.facet(Zr);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new Ro(s));else{let a=this.plugins[o];a.mustUpdate=e,r.push(a)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(a0(i||this.win))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let l=this.viewState.measure();if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(d=>{try{return d.read(this)}catch(p){return Pe(this.state,p),Yy}}),f=Tl.create(this,this.state,[]),h=!1;f.flags|=l,t?t.flags|=l:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),h=this.docView.update(f),h&&this.docViewUpdate());for(let d=0;d1||p<-1)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+p,i?i.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(Sf))a(t)}get themeClasses(){return Yf+" "+(this.state.facet(Uf)?Q0:V0)+" "+this.state.facet(bl)}updateAttrs(){let e=Ky(this,C0,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Dn)?"true":"false",class:"cm-content",style:`${$.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Ky(this,ah,t);let i=this.observer.ignore(()=>{let r=_y(this.contentDOM,this.contentAttrs,t),s=_y(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(So);let e=this.state.facet(n.cspNonce);_t.mount(this.root,this.styleModules.concat(uE).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ti.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return pf(this,e,By(this,e,t,i))}moveByGroup(e,t){return pf(this,e,By(this,e,t,i=>IS(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return R.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return BS(this,e,t,i)}moveVertically(e,t,i){return pf(this,e,LS(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=Bf(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Bf(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Rt.find(s,e-r.from,-1,t)];return No(i,o.dir==ue.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(w0)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>dE)return d0(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||h0(s.isolates,i=Ry(this,e))))return s.order;i||(i=Ry(this,e));let r=hS(e.text,t,i);return this.bidiCache.push(new $l(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||$.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{o0(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,r,s,o;return ml.of(new Mo(typeof e=="number"?R.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(r=t.x)!==null&&r!==void 0?r:"nearest",(s=t.yMargin)!==null&&s!==void 0?s:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return ml.of(new Mo(R.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return ze.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ze.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=_t.newName(),r=[bl.of(i),So.of(Kf(`.${i}`,e))];return t&&t.dark&&r.push(Uf.of(!0)),r}static baseTheme(e){return Rn.lowest(So.of(Kf("."+Yf,e,z0)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&pe.get(i)||pe.get(e);return((t=r==null?void 0:r.root)===null||t===void 0?void 0:t.view)||null}};q.styleModule=So;q.inputHandler=x0;q.clipboardInputFilter=sh;q.clipboardOutputFilter=oh;q.scrollHandler=O0;q.focusChangeEffect=b0;q.perLineTextDirection=w0;q.exceptionSink=v0;q.updateListener=Sf;q.editable=Dn;q.mouseSelectionStyle=y0;q.dragMovesSelection=g0;q.clickAddsSelectionRange=m0;q.decorations=Ql;q.blockWrappers=S0;q.outerDecorations=lh;q.atomicRanges=Fo;q.bidiIsolatedRanges=E0;q.cursorScrollMargin=N.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});q.scrollMargins=A0;q.darkTheme=Uf;q.cspNonce=N.define({combine:n=>n.length?n[0]:""});q.contentAttributes=ah;q.editorAttributes=C0;q.lineWrapping=q.contentAttributes.of({class:"cm-lineWrapping"});q.announce=U.define();var dE=4096,Yy={},$l=class n{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:ue.LTR;for(let s=Math.max(0,e.length-10);s=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&nh(o,t)}return t}var pE=$.mac?"mac":$.windows?"win":$.linux?"linux":"key";function mE(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,a;for(let l=0;li.concat(r),[]))),t}var ti=null,vE=4e3;function xE(n,e=pE){let t=Object.create(null),i=Object.create(null),r=(o,a)=>{let l=i[o];if(l==null)i[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,a,l,c,u)=>{var f,h;let d=t[o]||(t[o]=Object.create(null)),p=a.split(/ (?!$)/).map(g=>mE(g,e));for(let g=1;g{let b=ti={view:x,prefix:k,scope:o};return setTimeout(()=>{ti==b&&(ti=null)},vE),!0}]})}let m=p.join(" ");r(m,!1);let y=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((h=(f=d._any)===null||f===void 0?void 0:f.run)===null||h===void 0?void 0:h.slice())||[]});l&&y.run.push(l),c&&(y.preventDefault=!0),u&&(y.stopPropagation=!0)};for(let o of n){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of a){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let h in u)u[h].run.push(d=>f(d,Zf))}let l=o[e]||o.key;if(l)for(let c of a)s(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return t}var Zf=null;function bE(n,e,t,i){Zf=e;let r=ky(e),s=At(r,0),o=un(s)==r.length&&r!=" ",a="",l=!1,c=!1,u=!1;ti&&ti.view==t&&ti.scope==i&&(a=ti.prefix+" ",I0.indexOf(e.keyCode)<0&&(c=!0,ti=null));let f=new Set,h=y=>{if(y){for(let g of y.run)if(!f.has(g)&&(f.add(g),g(t)))return y.stopPropagation&&(u=!0),!0;y.preventDefault&&(y.stopPropagation&&(u=!0),c=!0)}return!1},d=n[i],p,m;return d&&(h(d[a+wl(r,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!($.windows&&e.ctrlKey&&e.altKey)&&!($.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Pn[e.keyCode])&&p!=r?(h(d[a+wl(p,e,!0)])||e.shiftKey&&(m=Gr[e.keyCode])!=r&&m!=p&&h(d[a+wl(m,e,!1)]))&&(l=!0):o&&e.shiftKey&&h(d[a+wl(r,e,!0)])&&(l=!0),!l&&h(d._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),Zf=null,l}var d3=/x/.unicode!=null?"gu":"g";var eh=class extends Dt{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?_o(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),r=No(t[0],i.direction!="rtl"),s=parseInt(i.lineHeight);return r.bottom-r.top>s*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+s}:r}ignoreEvent(){return!1}};function fh(n){let e=ze.fromClass(class{constructor(t){this.view=t,this.placeholder=n?X.set([X.widget({widget:new eh(n),side:1}).range(0)]):X.none}get decorations(){return this.view.state.doc.length?X.none:this.placeholder}},{decorations:t=>t.decorations});return typeof n=="string"?[e,q.contentAttributes.of({"aria-placeholder":n})]:e}var Ol="-10000px",Nl=class{constructor(e,t,i,r){this.facet=t,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=i(o,s))}update(e,t){var i;let r=e.state.facet(this.facet),s=r.filter(l=>l);if(r===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let o=[],a=t?[]:null;for(let l=0;lt[c]=l),t.length=a.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}};function W0(n={}){return Sl.of(n)}function wE(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}var Sl=N.define({combine:n=>{var e,t,i;return{position:$.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||wE}}}),Jy=new WeakMap,hh=ze.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Sl);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Nl(n,jo,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Sl);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.appendChild(r)}return t.dom.style.position=this.position,t.dom.style.top=Ol,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if($.safari){let o=s.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(n=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=ch(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let a=this.manager.tooltipViews[o];return a.getCoords?a.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Sl).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:t,space:i,scaleX:r,scaleY:s}=n,o=[];for(let a=0;a=Math.min(t.bottom,i.bottom)||f.rightMath.min(t.right,i.right)+.1)){u.style.top=Ol;continue}let d=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=h.right-h.left,y=(e=Jy.get(c))!==null&&e!==void 0?e:h.bottom-h.top,g=c.offset||kE,k=this.view.textDirection==ue.LTR,x=h.width>i.right-i.left?k?i.left:i.right-h.width:k?Math.max(i.left,Math.min(f.left-(d?14:0)+g.x,i.right-m)):Math.min(Math.max(i.left,f.left-m+(d?14:0)-g.x),i.right-m),b=this.above[a];!l.strictSide&&(b?f.top-y-p-g.yi.bottom)&&b==i.bottom-f.bottom>f.top-i.top&&(b=this.above[a]=!b);let C=(b?f.top-i.top:i.bottom-f.bottom)-p;if(Cx&&v.topO&&(O=b?v.top-y-2-p:v.bottom+p+2);if(this.position=="absolute"?(u.style.top=(O-n.parent.top)/s+"px",Zy(u,(x-n.parent.left)/r)):(u.style.top=O/s+"px",Zy(u,x/r)),d){let v=f.left+(k?g.x:-g.x)-(x+14-7);d.style.left=v/r+"px"}c.overlap!==!0&&o.push({left:x,top:O,right:w,bottom:O+y}),u.classList.toggle("cm-tooltip-above",b),u.classList.toggle("cm-tooltip-below",!b),c.positioned&&c.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Ol}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Zy(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}var OE=q.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),kE={x:0,y:0},jo=N.define({enables:[hh,OE]}),ql=N.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])}),Fl=class n{static create(e){return new n(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Nl(e,ql,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},CE=jo.compute([ql],n=>{let e=n.facet(ql);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Fl.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),th=class{constructor(e,t,i,r,s){this.view=e,this.source=t,this.field=i,this.setHover=r,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;ea.bottom||t.xa.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(r)).find(u=>u.from<=r&&u.to>=r),c=l&&l.dir==ue.RTL?-1:1;s=t.x{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Pe(e.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(hh),t=e?e.manager.tooltips.findIndex(i=>i.create==Fl.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:s}=this;if(r.length&&s&&!SE(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,a=(i=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!EE(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},kl=4;function SE(n,e){let{left:t,right:i,top:r,bottom:s}=n.getBoundingClientRect(),o;if(o=n.querySelector(".cm-tooltip-arrow")){let a=o.getBoundingClientRect();r=Math.min(a.top,r),s=Math.max(a.bottom,s)}return e.clientX>=t-kl&&e.clientX<=i+kl&&e.clientY>=r-kl&&e.clientY<=s+kl}function EE(n,e,t,i,r,s){let o=n.scrollDOM.getBoundingClientRect(),a=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.rightr||Math.min(o.bottom,a)=e&&l<=t}function H0(n,e={}){let t=U.define(),i=Ne.define({create(){return[]},update(r,s){if(r.length&&(e.hideOnChange&&(s.docChanged||s.selection)?r=[]:e.hideOn&&(r=r.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let a of r){let l=s.changes.mapPos(a.pos,-1,Ee.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),a);c.pos=l,c.end!=null&&(c.end=s.changes.mapPos(c.end)),o.push(c)}}r=o}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(AE)&&(r=[]);return r},provide:r=>ql.from(r)});return{active:i,extension:[i,ze.define(r=>new th(r,n,i,t,e.hoverTime||300)),CE]}}function dh(n,e){let t=n.plugin(hh);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}var AE=U.define();var e0=N.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});var _E=ze.fromClass(class{constructor(n){this.input=n.state.facet(jl),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(e0);this.top=new ts(n,!0,e.topContainer),this.bottom=new ts(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(e0);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new ts(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new ts(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(jl);if(t!=this.input){let i=t.filter(l=>l),r=[],s=[],o=[],a=[];for(let l of i){let c=this.specs.indexOf(l),u;c<0?(u=l(n.view),a.push(u)):(u=this.panels[c],u.update&&u.update(n)),r.push(u),(u.top?s:o).push(u)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>q.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),ts=class{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=t0(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=t0(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function t0(n){let e=n.nextSibling;return n.remove(),e}var jl=N.define({enables:_E});var dn=class extends Et{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};dn.prototype.elementClass="";dn.prototype.toDOM=void 0;dn.prototype.mapMode=Ee.TrackBefore;dn.prototype.startSide=dn.prototype.endSide=-1;dn.prototype.point=!0;var TE=0,Vo=class{constructor(e,t){this.from=e,this.to=t}},H=class{constructor(e={}){this.id=TE++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=We.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};H.closedBy=new H({deserialize:n=>n.split(" ")});H.openedBy=new H({deserialize:n=>n.split(" ")});H.group=new H({deserialize:n=>n.split(" ")});H.isolate=new H({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});H.contextHash=new H({perNode:!0});H.lookAhead=new H({perNode:!0});H.mounted=new H({perNode:!0});var qi=class{constructor(e,t,i,r=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[H.mounted.id]}},ME=Object.create(null),We=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):ME,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(H.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(H.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};We.none=new We("",Object.create(null),0,8);var Qo=class n{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(o|me.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=r&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&i&&(a||!l.type.isAnonymous)&&i(l),!l.nextSibling();){if(!l.parent())return;c=!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:bh(We.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(We.none,t,i,r)))}static build(e){return PE(e)}};be.empty=new be(We.none,[],[],0);var ph=class n{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 n(this.buffer,this.index)}},si=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return We.none}toString(){let e=[];for(let t=0;t0));l=o[l+3]);return a}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function zo(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?a.length:-1;e!=c;e+=t){let u=a[e],f=l[e]+o.from,h;if(!(!(s&me.EnterBracketed&&u instanceof be&&(h=qi.get(u))&&!h.overlay&&h.bracketed&&i>=f&&i<=f+u.length)&&!K0(r,i,f,f+u.length))){if(u instanceof si){if(s&me.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,t,i-f,r);if(d>-1)return new Wo(new gh(o,u,e,f),null,d)}else if(s&me.IncludeAnonymous||!u.type.isAnonymous||xh(u)){let d;if(!(s&me.IgnoreMounts)&&(d=qi.get(u))&&!d.overlay)return new n(d.tree,f,e,o);let p=new n(u,f,e,o);return s&me.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?u.children.length-1:0,t,i,r,s)}}}if(s&me.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let r;if(!(i&me.IgnoreOverlays)&&(r=qi.get(this._tree))&&r.overlay){let s=e-this.from,o=i&me.EnterBracketed&&r.bracketed;for(let{from:a,to:l}of r.overlay)if((t>0||o?a<=s:a=s:l>s))return new n(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function U0(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function mh(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var gh=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},Wo=class n extends Xl{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,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new n(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&me.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new n(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new n(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 n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new be(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function G0(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;st.from||o.to=e){let a=new pn(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(zo(a,e,t,!1))}}return r?G0(r):i}var Ho=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~me.EnterBracketed,e instanceof pn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof pn?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&me.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&me.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&me.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let a=i._tree.children[s];if(this.mode&me.IncludeAnonymous||a instanceof si||!a.type.isAnonymous||xh(a))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 o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r=0;s--){if(s<0)return mh(this._tree,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function xh(n){return n.children.some(e=>e instanceof si||!e.type.isAnonymous||xh(e))}function PE(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,a=Array.isArray(t)?new ph(t,t.length):t,l=i.types,c=0,u=0;function f(C,O,w,v,A,S){let{id:M,start:_,end:P,size:j}=a,oe=u,ee=c;if(j<0)if(a.next(),j==-1){let ut=s[M];w.push(ut),v.push(_-C);return}else if(j==-3){c=M;return}else if(j==-4){u=M;return}else throw new RangeError(`Unrecognized record size: ${j}`);let Y=l[M],Zt,ct,Ae=_-C;if(P-_<=r&&(ct=y(a.pos-O,A))){let ut=new Uint16Array(ct.size-ct.skip),qe=a.pos-ct.size,et=ut.length;for(;a.pos>qe;)et=g(ct.start,ut,et);Zt=new si(ut,P-ct.start,i),Ae=ct.start-C}else{let ut=a.pos-j;a.next();let qe=[],et=[],Nt=M>=o?M:-1,ft=0,Fn=P;for(;a.pos>ut;)Nt>=0&&a.id==Nt&&a.size>=0?(a.end<=Fn-r&&(p(qe,et,_,ft,a.end,Fn,Nt,oe,ee),ft=qe.length,Fn=a.end),a.next()):S>2500?h(_,ut,qe,et):f(_,ut,qe,et,Nt,S+1);if(Nt>=0&&ft>0&&ft-1&&ft>0){let ua=d(Y,ee);Zt=bh(Y,qe,et,0,qe.length,0,P-_,ua,ua)}else Zt=m(Y,qe,et,P-_,oe-P,ee)}w.push(Zt),v.push(Ae)}function h(C,O,w,v){let A=[],S=0,M=-1;for(;a.pos>O;){let{id:_,start:P,end:j,size:oe}=a;if(oe>4)a.next();else{if(M>-1&&P=0;j-=3)_[oe++]=A[j],_[oe++]=A[j+1]-P,_[oe++]=A[j+2]-P,_[oe++]=oe;w.push(new si(_,A[2]-P,i)),v.push(P-C)}}function d(C,O){return(w,v,A)=>{let S=0,M=w.length-1,_,P;if(M>=0&&(_=w[M])instanceof be){if(!M&&_.type==C&&_.length==A)return _;(P=_.prop(H.lookAhead))&&(S=v[M]+_.length+P)}return m(C,w,v,A,S,O)}}function p(C,O,w,v,A,S,M,_,P){let j=[],oe=[];for(;C.length>v;)j.push(C.pop()),oe.push(O.pop()+w-A);C.push(m(i.types[M],j,oe,S-A,_-S,P)),O.push(A-w)}function m(C,O,w,v,A,S,M){if(S){let _=[H.contextHash,S];M=M?[_].concat(M):[_]}if(A>25){let _=[H.lookAhead,A];M=M?[_].concat(M):[_]}return new be(C,O,w,v,M)}function y(C,O){let w=a.fork(),v=0,A=0,S=0,M=w.end-r,_={size:0,start:0,skip:0};e:for(let P=w.pos-C;w.pos>P;){let j=w.size;if(w.id==O&&j>=0){_.size=v,_.start=A,_.skip=S,S+=4,v+=4,w.next();continue}let oe=w.pos-j;if(j<0||oe=o?4:0,Y=w.start;for(w.next();w.pos>oe;){if(w.size<0)if(w.size==-3||w.size==-4)ee+=4;else break e;else w.id>=o&&(ee+=4);w.next()}A=Y,v+=j,S+=ee}return(O<0||v==C)&&(_.size=v,_.start=A,_.skip=S),_.size>4?_:void 0}function g(C,O,w){let{id:v,start:A,end:S,size:M}=a;if(a.next(),M>=0&&v4){let P=a.pos-(M-4);for(;a.pos>P;)w=g(C,O,w)}O[--w]=_,O[--w]=S-C,O[--w]=A-C,O[--w]=v}else M==-3?c=v:M==-4&&(u=v);return w}let k=[],x=[];for(;a.pos>0;)f(n.start||0,n.bufferStart||0,k,x,-1,0);let b=(e=n.length)!==null&&e!==void 0?e:k.length?x[0]+k[0].length:0;return new be(l[n.topID],k.reverse(),x.reverse(),b)}var Y0=new WeakMap;function Hl(n,e){if(!n.isAnonymous||e instanceof si||e.type!=n)return 1;let t=Y0.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof be)){t=1;break}t+=Hl(n,i)}Y0.set(e,t)}return t}function bh(n,e,t,i,r,s,o,a,l){let c=0;for(let p=i;p=u)break;O+=w}if(x==b+1){if(O>u){let w=p[b];d(w.children,w.positions,0,w.children.length,m[b]+k);continue}f.push(p[b])}else{let w=m[x-1]+p[x-1].length-C;f.push(bh(n,p,m,b,x,C,w,null,l))}h.push(C+k-s)}}return d(e,t,i,r,0),(a||l)(f,h,o)}var Fi=class n{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new n(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a=i)for(;o&&o.from=h.from||f<=h.to||c){let d=Math.max(h.from,l)-c,p=Math.min(h.to,f)-c;h=d>=p?null:new n(d,p,h.tree,h.offset+c,a>0,!!u)}if(h&&r.push(h),o.to>f)break;o=snew Vo(r.from,r.to)):[new Vo(0,0)]:[new Vo(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}},vh=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var x3=new H({perNode:!0});var DE=0,Ut=class n{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=DE++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof n&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let r=new n(i,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Gl(e);return i=>i.modified.indexOf(t)>-1?i:Gl.get(i.base||i,i.modified.concat(t).sort((r,s)=>r.id-s.id))}},BE=0,Gl=class n{constructor(e){this.name=e,this.instances=[],this.id=BE++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(a=>a.base==e&&IE(t,a.modified));if(i)return i;let r=[],s=new Ut(e.name,r,e,t);for(let a of t)a.instances.push(s);let o=LE(t);for(let a of e.set)if(!a.modified.length)for(let l of o)r.push(n.get(a,l));return s}};function IE(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function LE(n){let e=[[]];for(let t=0;ti.length-t.length)}function Jl(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,a=r;for(let f=0;;){if(a=="..."&&f>0&&f+3==r.length){o=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+r);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==r.length)break;let d=r[f++];if(f==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);a=r.slice(f)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+r);let u=new Vi(i,o,l>0?s.slice(0,l):null);e[c]=u.sort(e[c])}}return ev.add(e)}var ev=new H({combine(n,e){let t,i,r;for(;n||e;){if(!n||e&&n.depth>=e.depth?(r=e,e=e.next):(r=n,n=n.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let s=new Vi(r.tags,r.mode,r.context);t?t.next=s:i=s,t=s}return i}}),Vi=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=r;for(let a of s)for(let l of a.set){let c=t[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:i}}function $E(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function tv(n,e,t,i=0,r=n.length){let s=new Oh(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}var Oh=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,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,i,r,s){let{type:o,from:a,to:l}=e;if(a>=i||l<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let c=r,u=NE(e)||Vi.empty,f=$E(s,u.tags);if(f&&(c&&(c+=" "),c+=f,u.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,a),c),u.opaque)return;let h=e.tree&&e.tree.prop(H.mounted);if(h&&h.overlay){let d=e.node.enter(h.overlay[0].from+a,1),p=this.highlighters.filter(y=>!y.scope||y.scope(h.tree.type)),m=e.firstChild();for(let y=0,g=a;;y++){let k=y=x||!e.nextSibling())););if(!k||x>i)break;g=k.to+a,g>t&&(this.highlightRange(d.cursor(),Math.max(t,k.from+a),Math.min(i,g),"",p),this.startSpan(Math.min(i,g),c))}m&&e.parent()}else if(e.firstChild()){h&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),c)}while(e.nextSibling());e.parent()}}};function NE(n){let e=n.type.prop(ev);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var I=Ut.define,Ul=I(),oi=I(),J0=I(oi),Z0=I(oi),ai=I(),Yl=I(ai),wh=I(ai),yn=I(),ji=I(yn),mn=I(),gn=I(),kh=I(),Xo=I(kh),Kl=I(),T={comment:Ul,lineComment:I(Ul),blockComment:I(Ul),docComment:I(Ul),name:oi,variableName:I(oi),typeName:J0,tagName:I(J0),propertyName:Z0,attributeName:I(Z0),className:I(oi),labelName:I(oi),namespace:I(oi),macroName:I(oi),literal:ai,string:Yl,docString:I(Yl),character:I(Yl),attributeValue:I(Yl),number:wh,integer:I(wh),float:I(wh),bool:I(ai),regexp:I(ai),escape:I(ai),color:I(ai),url:I(ai),keyword:mn,self:I(mn),null:I(mn),atom:I(mn),unit:I(mn),modifier:I(mn),operatorKeyword:I(mn),controlKeyword:I(mn),definitionKeyword:I(mn),moduleKeyword:I(mn),operator:gn,derefOperator:I(gn),arithmeticOperator:I(gn),logicOperator:I(gn),bitwiseOperator:I(gn),compareOperator:I(gn),updateOperator:I(gn),definitionOperator:I(gn),typeOperator:I(gn),controlOperator:I(gn),punctuation:kh,separator:I(kh),bracket:Xo,angleBracket:I(Xo),squareBracket:I(Xo),paren:I(Xo),brace:I(Xo),content:yn,heading:ji,heading1:I(ji),heading2:I(ji),heading3:I(ji),heading4:I(ji),heading5:I(ji),heading6:I(ji),contentSeparator:I(yn),list:I(yn),quote:I(yn),emphasis:I(yn),strong:I(yn),link:I(yn),monospace:I(yn),strikethrough:I(yn),inserted:I(),deleted:I(),changed:I(),invalid:I(),meta:Kl,documentMeta:I(Kl),annotation:I(Kl),processingInstruction:I(Kl),definition:Ut.defineModifier("definition"),constant:Ut.defineModifier("constant"),function:Ut.defineModifier("function"),standard:Ut.defineModifier("standard"),local:Ut.defineModifier("local"),special:Ut.defineModifier("special")};for(let n in T){let e=T[n];e instanceof Ut&&(e.name=n)}var O3=Ch([{tag:T.link,class:"tok-link"},{tag:T.heading,class:"tok-heading"},{tag:T.emphasis,class:"tok-emphasis"},{tag:T.strong,class:"tok-strong"},{tag:T.keyword,class:"tok-keyword"},{tag:T.atom,class:"tok-atom"},{tag:T.bool,class:"tok-bool"},{tag:T.url,class:"tok-url"},{tag:T.labelName,class:"tok-labelName"},{tag:T.inserted,class:"tok-inserted"},{tag:T.deleted,class:"tok-deleted"},{tag:T.literal,class:"tok-literal"},{tag:T.string,class:"tok-string"},{tag:T.number,class:"tok-number"},{tag:[T.regexp,T.escape,T.special(T.string)],class:"tok-string2"},{tag:T.variableName,class:"tok-variableName"},{tag:T.local(T.variableName),class:"tok-variableName tok-local"},{tag:T.definition(T.variableName),class:"tok-variableName tok-definition"},{tag:T.special(T.variableName),class:"tok-variableName2"},{tag:T.definition(T.propertyName),class:"tok-propertyName tok-definition"},{tag:T.typeName,class:"tok-typeName"},{tag:T.namespace,class:"tok-namespace"},{tag:T.className,class:"tok-className"},{tag:T.macroName,class:"tok-macroName"},{tag:T.propertyName,class:"tok-propertyName"},{tag:T.operator,class:"tok-operator"},{tag:T.comment,class:"tok-comment"},{tag:T.meta,class:"tok-meta"},{tag:T.invalid,class:"tok-invalid"},{tag:T.punctuation,class:"tok-punctuation"}]);var Sh,fs=new H;function FE(n){return N.define({combine:n?e=>e.concat(n):void 0})}var jE=new H,xt=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,he.prototype.hasOwnProperty("tree")||Object.defineProperty(he.prototype,"tree",{get(){return ge(this)}}),this.parser=t,this.extension=[hs.of(this),he.languageData.of((s,o,a)=>{let l=nv(s,o,a),c=l.type.prop(fs);if(!c)return[];let u=s.facet(c),f=l.type.prop(jE);if(f){let h=l.resolve(o-l.from,a);for(let d of f)if(d.test(h,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(u)}}return u})].concat(i)}isActiveAt(e,t,i=-1){return nv(e,t,i).type.prop(fs)==this.data}findRegions(e){let t=e.facet(hs);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(fs)==this.data){i.push({from:o,to:o+s.length});return}let a=s.prop(H.mounted);if(a){if(a.tree.prop(fs)==this.data){if(a.overlay)for(let l of a.overlay)i.push({from:l.from+o,to:l.to+o});else i.push({from:o,to:o+s.length});return}else if(a.overlay){let l=i.length;if(r(a.tree,a.overlay[0].from+o),i.length>l)return}}for(let l=0;li.isTop?t:void 0)]}),e.name)}configure(e,t){return new n(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function ge(n){let e=n.field(xt.state,!1);return e?e.tree:be.empty}var Th=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},Uo=null,Mh=class n{constructor(e,t,i=[],r,s,o,a,l){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],be.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Th(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=be.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Fi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Uo;Uo=this;try{return e()}finally{Uo=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=iv(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,f,h)=>l.push({fromA:c,toA:u,fromB:f,toB:h})),i=Fi.applyChanges(i,l),r=be.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),f=e.mapPos(c.to,-1);ue.from&&(this.fragments=iv(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends us{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let l=Uo;if(l){for(let c of r)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new be(We.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Uo}};function iv(n,e,t){return Fi.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var Yo=class n{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Mh.create(e.facet(hs).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};xt.state=Ne.define({create:Yo.init,update(n,e){for(let t of e.effects)if(t.is(xt.setState))return t.value;return e.startState.facet(hs)!=e.state.facet(hs)?Yo.init(e.state):n.apply(e)}});var lv=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(lv=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Eh=typeof navigator!="undefined"&&(!((Sh=navigator.scheduling)===null||Sh===void 0)&&Sh.isInputPending)?()=>navigator.scheduling.isInputPending():null,VE=ze.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(xt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(xt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=lv(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,l=s.context.work(()=>Eh&&Eh()||Date.now()>o,r+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:xt.setState.of(new Yo(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Pe(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),hs=N.define({combine(n){return n.length?n[0]:null},enables:n=>[xt.state,VE,q.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),ec=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var QE=N.define(),ps=N.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Ko(n){let e=n.facet(ps);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function ms(n,e){let t="",i=n.tabSize,r=n.facet(ps)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s=e?zE(n,t,e):null}var Qi=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Ko(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return Di(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Lh=new H;function zE(n,e,t){let i=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o&&!(o.fromi.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return cv(i,n,t)}function cv(n,e,t){for(let i=n;i;i=i.next){let r=HE(i.node);if(r)return r(Rh.create(e,t,i))}return 0}function WE(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function HE(n){let e=n.type.prop(Lh);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(H.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>uv(o,!0,1,void 0,s&&!WE(o)?r.from:void 0)}return n.parent==null?XE:null}function XE(){return 0}var Rh=class n extends Qi{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new n(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(UE(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return cv(this.context.next,this.base,this.pos)}};function UE(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function YE(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==i)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+c}}a=l.to}}function $h({closing:n,align:e=!0,units:t=1}){return i=>uv(i,e,t,n)}function uv(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,a=i&&s.slice(o,o+i.length)==i||r==n.pos+o,l=e?YE(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*t)}function nc({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}var KE=200;function fv(){return he.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,r=t.lineAt(i);if(i>r.from+KE)return n;let s=t.sliceString(r.from,i);if(!e.some(c=>c.test(s)))return n;let{state:o}=n,a=-1,l=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==a)continue;a=u.from;let f=tc(o,u.from);if(f==null)continue;let h=/^\s*/.exec(u.text)[0],d=ms(o,f);h!=d&&l.push({from:u.from,to:u.from+h.length,insert:d})}return l.length?[n,{changes:l,sequential:!0}]:n})}var hv=new H;function ic(n){let e=n.firstChild,t=n.lastChild;return e&&e.toa.prop(fs)==o.data:o?a=>a==o:void 0,this.style=Ch(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=i?new _t(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},Ph=N.define(),dv=N.define({combine(n){return n.length?[n[0]]:null}});function Ah(n){let e=n.facet(Ph);return e.length?e:n.facet(dv)}function pv(n,e){let t=[GE],i;return n instanceof ds&&(n.module&&t.push(q.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(dv.of(n)):i?t.push(Ph.computeN([q.darkTheme],r=>r.facet(q.darkTheme)==(i=="dark")?[n]:[])):t.push(Ph.of(n)),t}var Dh=class{constructor(e){this.markCache=Object.create(null),this.tree=ge(e.state),this.decorations=this.buildDeco(e,Ah(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=ge(e.state),i=Ah(e.state),r=i!=Ah(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return X.none;let i=new Mn;for(let{from:r,to:s}of e.visibleRanges)tv(this.tree,t,(o,a,l)=>{i.add(o,a,this.markCache[l]||(this.markCache[l]=X.mark({class:l})))},r,s);return i.finish()}},GE=Rn.high(ze.fromClass(Dh,{decorations:n=>n.decorations})),M3=ds.define([{tag:T.meta,color:"#404740"},{tag:T.link,textDecoration:"underline"},{tag:T.heading,textDecoration:"underline",fontWeight:"bold"},{tag:T.emphasis,fontStyle:"italic"},{tag:T.strong,fontWeight:"bold"},{tag:T.strikethrough,textDecoration:"line-through"},{tag:T.keyword,color:"#708"},{tag:[T.atom,T.bool,T.url,T.contentSeparator,T.labelName],color:"#219"},{tag:[T.literal,T.inserted],color:"#164"},{tag:[T.string,T.deleted],color:"#a11"},{tag:[T.regexp,T.escape,T.special(T.string)],color:"#e40"},{tag:T.definition(T.variableName),color:"#00f"},{tag:T.local(T.variableName),color:"#30a"},{tag:[T.typeName,T.namespace],color:"#085"},{tag:T.className,color:"#167"},{tag:[T.special(T.variableName),T.macroName],color:"#256"},{tag:T.definition(T.propertyName),color:"#00c"},{tag:T.comment,color:"#940"},{tag:T.invalid,color:"#f00"}]),JE=q.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),mv=1e4,gv="()[]{}",yv=N.define({combine(n){return ei(n,{afterCursor:!0,brackets:gv,maxScanDistance:mv,renderMatch:tA})}}),ZE=X.mark({class:"cm-matchingBracket"}),eA=X.mark({class:"cm-nonmatchingBracket"});function tA(n){let e=[],t=n.matched?ZE:eA;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function rv(n){let e=[],t=n.facet(yv);for(let i of n.selection.ranges){if(!i.empty)continue;let r=Yt(n,i.head,-1,t)||i.head>0&&Yt(n,i.head-1,1,t)||t.afterCursor&&(Yt(n,i.head,1,t)||i.headn.decorations}),iA=[nA,JE];function vv(n={}){return[yv.of(n),iA]}var rA=new H;function Bh(n,e,t){let i=n.prop(e<0?H.openedBy:H.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function Ih(n){let e=n.type.prop(rA);return e?e(n.node):n}function Yt(n,e,t,i={}){let r=i.maxScanDistance||mv,s=i.brackets||gv,o=ge(n),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=Bh(l.type,t,s);if(c&&l.from0?e>=u.from&&eu.from&&e<=u.to))return sA(n,e,t,l,u,c,s)}}return oA(n,e,t,o,a.type,r,s)}function sA(n,e,t,i,r,s,o){let a=i.parent,l={from:r.from,to:r.to},c=0,u=a==null?void 0:a.cursor();if(u&&(t<0?u.childBefore(i.from):u.childAfter(i.to)))do if(t<0?u.to<=i.from:u.from>=i.to){if(c==0&&s.indexOf(u.type.name)>-1&&u.from0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},u=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let h=0;!u.next().done&&h<=s;){let d=u.value;t<0&&(h+=d.length);let p=e+h*t;for(let m=t>0?0:d.length-1,y=t>0?d.length:-1;m!=y;m+=t){let g=o.indexOf(d[m]);if(!(g<0||i.resolveInner(p+m,1).type!=r))if(g%2==0==t>0)f++;else{if(f==1)return{start:c,end:{from:p+m,to:p+m+1},matched:g>>1==l>>1};f--}}t>0&&(h+=d.length)}return u.done?{start:c,matched:!1}:null}var aA=Object.create(null),sv=[We.none];var ov=[],av=Object.create(null),lA=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])lA[n]=cA(aA,e);function _h(n,e){ov.indexOf(n)>-1||(ov.push(n),console.warn(e))}function cA(n,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=n[c]||T[c];u?typeof u=="function"?l.length?l=l.map(u):_h(c,`Modifier ${c} used at start of tag`):l.length?_h(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:_h(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(a=>a.id),s=av[r];if(s)return s.id;let o=av[r]=We.define({id:sv.length,name:i,props:[Jl({[i]:t})]});return sv.push(o),o.id}var R3={rtl:X.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:ue.RTL}),ltr:X.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:ue.LTR}),auto:X.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var sc=class{constructor(e,t,i,r){this.state=e,this.pos=t,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=ge(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),r=t.text.slice(i-t.from,this.pos-t.from),s=r.search(Av(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}};function xv(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function uA(n){let e=Object.create(null),t=Object.create(null);for(let{label:r}of n){e[r[0]]=!0;for(let s=1;stypeof r=="string"?{label:r}:r),[t,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:uA(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:t}:null}}var oc=class{constructor(e,t,i,r){this.completion=e,this.source=t,this.match=i,this.score=r}};function Wi(n){return n.selection.main.from}function Av(n,e){var t;let{source:i}=n,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?n:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}var Kh=gt.define();function fA(n,e,t,i){let{main:r}=n.selection,s=t-r.from,o=i-r.from;return{...n.changeByRange(a=>{if(a!=r&&t!=i&&n.sliceDoc(a.from+s,a.from+o)!=n.sliceDoc(t,i))return{range:a};let l=n.toText(e);return{changes:{from:a.from+s,to:i==r.from?a.to:a.from+o,insert:l},range:R.cursor(a.from+s+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}var bv=new WeakMap;function hA(n){if(!Array.isArray(n))return n;let e=bv.get(n);return e||bv.set(n,e=ys(n)),e}var ac=U.define(),Go=U.define(),jh=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(O=sf(C))!=O.toLowerCase()?1:O!=O.toUpperCase()?2:0;(!k||w==1&&y||b==0&&w!=0)&&(t[f]==C||i[f]==C&&(h=!0)?o[f++]=k:o.length&&(g=!1)),b=w,k+=un(C)}return f==l&&o[0]==0&&g?this.result(-100+(h?-200:0),o,e):d==l&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):d==l?this.ret(-900-e.length,[p,m]):f==l?this.result(-100+(h?-200:0)+-700+(g?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,i){let r=[],s=0;for(let o of t){let a=o+(this.astral?un(At(i,o)):1);s&&r[s-1]==o?r[s-1]=a:(r[s++]=o,r[s++]=a)}return this.ret(e-i.length,r)}},Vh=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:dA,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>wv(e(i),t(i)),optionClass:(e,t)=>i=>wv(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function wv(n,e){return n?e?n+" "+e:n:e}function dA(n,e,t,i,r,s){let o=n.textDirection==ue.RTL,a=o,l=!1,c="top",u,f,h=e.left-r.left,d=r.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(a&&h=m||k>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let y=(e.bottom-e.top)/s.offsetHeight,g=(e.right-e.left)/s.offsetWidth;return{style:`${c}: ${u/y}px; max-width: ${f/g}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}var Gh=U.define();function pA(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;cl&&o.appendChild(document.createTextNode(a.slice(l,u)));let h=o.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(a.slice(u,f))),h.className="cm-completionMatchedText",l=f}return lt.position-i.position).map(t=>t.render)}function Nh(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}var Qh=class{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:s,selected:o}=r.open,a=e.state.facet(De);this.optionContent=pA(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=Nh(s.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let u=l.target,f;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(f=/-(\d+)$/.exec(u.id))&&+f[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;u!=null&&(e.dispatch({effects:Gh.of(u)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(De).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Go.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:a}=i.open;(!r.open||r.open.options!=s)&&(this.range=Nh(s.length,o,e.state.facet(De).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),a!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=Nh(t.options.length,t.selected,this.view.state.facet(De).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:s}=r;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(r);if(!o)return;"then"in o?o.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,r)}).catch(a=>Pe(this.view.state,a,"completion info")):(this.addInfoPane(o,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&gA(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(s.bottom,t.bottom)-10||r.bottom{o.target==r&&o.preventDefault()});let s=null;for(let o=i.from;oi.from||i.from==0))if(s=h,typeof c!="string"&&c.header)r.appendChild(c.header(c));else{let d=r.appendChild(document.createElement("completion-section"));d.textContent=h}}let u=r.appendChild(document.createElement("li"));u.id=t+"-"+o,u.setAttribute("role","option");let f=this.optionClass(a);f&&(u.className=f);for(let h of this.optionContent){let d=h(a,this.view.state,this.view,l);d&&u.appendChild(d)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.tonew Qh(t,n,e)}function gA(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),r=t.height/n.offsetHeight;i.topt.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/r)}function Ov(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function yA(n,e){let t=[],i=null,r=null,s=u=>{t.push(u);let{section:f}=u.completion;if(f){i||(i=[]);let h=typeof f=="string"?f:f.name;i.some(d=>d.name==h)||i.push(typeof f=="string"?{name:h}:f)}},o=e.facet(De);for(let u of n)if(u.hasResult()){let f=u.result.getMatch;if(u.result.filter===!1)for(let h of u.result.options)s(new oc(h,u.source,f?f(h):[],1e9-t.length));else{let h=e.sliceDoc(u.from,u.to),d,p=o.filterStrict?new Vh(h):new jh(h);for(let m of u.result.options)if(d=p.match(m.label)){let y=m.displayLabel?f?f(m,d.matched):[]:d.matched,g=d.score+(m.boost||0);if(s(new oc(m,u.source,y,g)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:k}=m.section;r||(r=Object.create(null)),r[k]=Math.max(g,r[k]||-1e9)}}}}if(i){let u=Object.create(null),f=0,h=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?r[p.name]-r[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.nameh.score-f.score||c(f.completion,h.completion))){let f=u.completion;!l||l.label!=f.label||l.detail!=f.detail||l.type!=null&&f.type!=null&&l.type!=f.type||l.apply!=f.apply||l.boost!=f.boost?a.push(u):Ov(u.completion)>Ov(l)&&(a[a.length-1]=u),l=u.completion}return a}var zh=class n{constructor(e,t,i,r,s,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new n(this.options,kv(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,r,s,o){if(r&&!o&&e.some(c=>c.isPending))return r.setDisabled();let a=yA(e,t);if(!a.length)return r&&e.some(c=>c.isPending)?r.setDisabled():null;let l=t.facet(De).selectOnOpen?0:-1;if(r&&r.selected!=l&&r.selected!=-1){let c=r.options[r.selected].completion;for(let u=0;uu.hasResult()?Math.min(c,u.from):c,1e8),create:kA,above:s.aboveCursor},r?r.timestamp:Date.now(),l,!1)}map(e){return new n(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new n(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},Wh=class n{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new n(wA,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(De),s=(i.override||t.languageDataAt("autocomplete",Wi(t)).map(hA)).map(l=>(this.active.find(u=>u.source==l)||new Ln(l,this.active.some(u=>u.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((l,c)=>l==this.active[c])&&(s=this.active);let o=this.open,a=e.effects.some(l=>l.is(Jh));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!vA(s,this.active)||a?o=zh.build(s,t,this.id,o,i,a):o&&o.disabled&&!s.some(l=>l.isPending)&&(o=null),!o&&s.every(l=>!l.isPending)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new Ln(l.source,0):l));for(let l of e.effects)l.is(Gh)&&(o=o&&o.setSelected(l.value,this.id));return s==this.active&&o==this.open?this:new n(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?xA:bA}};function vA(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}var wA=[];function _v(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(Kh);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}var Ln=class n{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=_v(e,t),r=this;(i&8||i&16&&this.touches(e))&&(r=new n(r.source,0)),i&4&&r.state==0&&(r=new n(this.source,1)),r=r.updateFor(e,i);for(let s of e.effects)if(s.is(ac))r=new n(r.source,1,s.value);else if(s.is(Go))r=new n(r.source,0);else if(s.is(Jh))for(let o of s.value)o.source==r.source&&(r=o);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Wi(e.state))}},lc=class n extends Ln{constructor(e,t,i,r,s,o){super(e,3,t),this.limit=i,this.result=r,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),a=Wi(e.state);if(a>o||!r||t&2&&(Wi(e.startState)==this.from||at.map(e))}}),lt=Ne.define({create(){return Wh.start()},update(n,e){return n.update(e)},provide:n=>[jo.from(n,e=>e.tooltip),q.contentAttributes.from(n,e=>e.attrs)]});function Zh(n,e){let t=e.completion.apply||e.completion.label,i=n.state.field(lt).active.find(r=>r.source==e.source);return i instanceof lc?(typeof t=="string"?n.dispatch({...fA(n.state,t,i.from,i.to),annotations:Kh.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}var kA=mA(lt,Zh);function rc(n,e="option"){return t=>{let i=t.state.field(lt,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+r*(n?1:-1):n?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),t.dispatch({effects:Gh.of(a)}),!0}}var CA=n=>{let e=n.state.field(lt,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(lt,!1)?(n.dispatch({effects:ac.of(!0)}),!0):!1,SA=n=>{let e=n.state.field(lt,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Go.of(null)}),!0)},Hh=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},EA=50,AA=1e3,_A=ze.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(lt).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(lt),t=n.state.facet(De);if(!n.selectionSet&&!n.docChanged&&n.startState.field(lt)==e)return;let i=n.transactions.some(s=>{let o=_v(s,t);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;sEA&&Date.now()-o.time>AA){for(let a of o.context.abortListeners)try{a()}catch(l){Pe(this.view.state,l)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(s=>s.effects.some(o=>o.is(ac)))&&(this.pendingStart=!0);let r=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of n.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(lt);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(De).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=Wi(e),i=new sc(e,t,n.explicit,this.view),r=new Hh(n,i);this.running.push(r),Promise.resolve(n.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Go.of(null)}),Pe(this.view.state,s)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(De).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(De),i=this.view.state.field(lt);for(let r=0;ra.source==s.active.source);if(o&&o.isPending)if(s.done==null){let a=new Ln(s.active.source,0);for(let l of s.updates)a=a.update(l,t);a.isPending||e.push(a)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Jh.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(lt,!1);if(e&&e.tooltip&&this.view.state.facet(De).closeOnBlur){let t=e.open&&dh(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Go.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:ac.of(!1)}),20),this.composing=0}}}),TA=typeof navigator=="object"&&/Win/.test(navigator.platform),MA=Rn.highest(q.domEventHandlers({keydown(n,e){let t=e.state.field(lt,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(TA&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],r=t.active.find(o=>o.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(n.key)>-1&&Zh(e,i),!1}})),Tv=q.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Xh=class{constructor(e,t,i,r){this.field=e,this.line=t,this.from=i,this.to=r}},Uh=class n{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,Ee.TrackDel),i=e.mapPos(this.to,1,Ee.TrackDel);return t==null||i==null?null:new n(this.field,t,i)}},Yh=class n{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],r=[t],s=e.doc.lineAt(t),o=/^\s*/.exec(s.text)[0];for(let l of this.lines){if(i.length){let c=o,u=/^\t*/.exec(l)[0].length;for(let f=0;fnew Uh(l.field,r[l.line]+l.from,r[l.line]+l.to));return{text:i,ranges:a}}static parse(e){let t=[],i=[],r=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let a=s[1]?+s[1]:null,l=s[2]||s[3]||"",c=-1,u=l.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f=c&&h.field++}for(let f of r)if(f.line==i.length&&f.from>s.index){let h=s[2]?3+(s[1]||"").length:2;f.from-=h,f.to-=h}r.push(new Xh(c,i.length,s.index,s.index+u.length)),o=o.slice(0,s.index)+l+o.slice(s.index+s[0].length)}o=o.replace(/\\([{}])/g,(a,l,c)=>{for(let u of r)u.line==i.length&&u.from>c&&(u.from--,u.to--);return l}),i.push(o)}return new n(i,r)}},RA=X.widget({widget:new class extends Dt{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),PA=X.mark({class:"cm-snippetField"}),gs=class n{constructor(e,t){this.ranges=e,this.active=t,this.deco=X.set(e.map(i=>(i.from==i.to?RA:PA).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let r=i.map(e);if(!r)return null;t.push(r)}return new n(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}},Zo=U.define({map(n,e){return n&&n.map(e)}}),DA=U.define(),Jo=Ne.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(Zo))return t.value;if(t.is(DA)&&n)return new gs(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>q.decorations.from(n,e=>e?e.deco:X.none)});function ed(n,e){return R.create(n.filter(t=>t.field==e).map(t=>R.range(t.from,t.to)))}function BA(n){let e=Yh.parse(n);return(t,i,r,s)=>{let{text:o,ranges:a}=e.instantiate(t.state,r),{main:l}=t.state.selection,c={changes:{from:r,to:s==l.from?l.to:s,insert:J.of(o)},scrollIntoView:!0,annotations:i?[Kh.of(i),$e.userEvent.of("input.complete")]:void 0};if(a.length&&(c.selection=ed(a,0)),a.some(u=>u.field>0)){let u=new gs(a,0),f=c.effects=[Zo.of(u)];t.state.field(Jo,!1)===void 0&&f.push(U.appendConfig.of([Jo,qA,FA,Tv]))}t.dispatch(t.state.update(c))}}function Mv(n){return({state:e,dispatch:t})=>{let i=e.field(Jo,!1);if(!i||n<0&&i.active==0)return!1;let r=i.active+n,s=n>0&&!i.ranges.some(o=>o.field==r+n);return t(e.update({selection:ed(i.ranges,r),effects:Zo.of(s?null:new gs(i.ranges,r)),scrollIntoView:!0})),!0}}var IA=({state:n,dispatch:e})=>n.field(Jo,!1)?(e(n.update({effects:Zo.of(null)})),!0):!1,LA=Mv(1),$A=Mv(-1);var NA=[{key:"Tab",run:LA,shift:$A},{key:"Escape",run:IA}],Cv=N.define({combine(n){return n.length?n[0]:NA}}),qA=Rn.highest(cs.compute([Cv],n=>n.facet(Cv)));function Bt(n,e){return{...e,apply:BA(n)}}var FA=q.domEventHandlers({mousedown(n,e){let t=e.state.field(Jo,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let r=t.ranges.find(s=>s.from<=i&&s.to>=i);return!r||r.field==t.active?!1:(e.dispatch({selection:ed(t.ranges,r.field),effects:Zo.of(t.ranges.some(s=>s.field>r.field)?new gs(t.ranges,r.field):null),scrollIntoView:!0}),!0)}});var cc={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},zi=U.define({map(n,e){let t=e.mapPos(n,-1,Ee.TrackAfter);return t==null?void 0:t}}),td=new class extends Et{};td.startSide=1;td.endSide=-1;var Rv=Ne.define({create(){return re.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(zi)&&(n=n.update({add:[td.range(t.value,t.value+1)]}));return n}});function Pv(){return[zA,Rv]}var Fh="()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D";function jA(n){for(let e=0;e{if((QA?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&un(At(i,0))==1||e!=r.from||t!=r.to)return!1;let s=WA(n.state,i);return s?(n.dispatch(s),!0):!1});function WA(n,e){let t=VA(n,n.selection.main.head),i=t.brackets||cc.brackets;for(let r of i){let s=jA(At(r,0));if(e==r)return s==r?UA(n,r,i.indexOf(r+r+r)>-1,t):HA(n,r,s,t.before||cc.before);if(e==s&&Dv(n,n.selection.main.from))return XA(n,r,s)}return null}function Dv(n,e){let t=!1;return n.field(Rv).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function nd(n,e){let t=n.sliceString(e,e+2);return t.slice(0,un(At(t,0)))}function HA(n,e,t,i){let r=null,s=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:zi.of(o.to+e.length),range:R.range(o.anchor+e.length,o.head+e.length)};let a=nd(n.doc,o.head);return!a||/\s/.test(a)||i.indexOf(a)>-1?{changes:{insert:e+t,from:o.head},effects:zi.of(o.head+e.length),range:R.cursor(o.head+e.length)}:{range:r=o}});return r?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function XA(n,e,t){let i=null,r=n.changeByRange(s=>s.empty&&nd(n.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:R.cursor(s.head+t.length)}:i={range:s});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function UA(n,e,t,i){let r=i.stringPrefixes||cc.stringPrefixes,s=null,o=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:zi.of(a.to+e.length),range:R.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=nd(n.doc,l),u;if(c==e){if(Sv(n,l))return{changes:{insert:e+e,from:l},effects:zi.of(l+e.length),range:R.cursor(l+e.length)};if(Dv(n,l)){let h=t&&n.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+h.length,insert:h},range:R.cursor(l+h.length)}}}else{if(t&&n.sliceDoc(l-2*e.length,l)==e+e&&(u=Ev(n,l-2*e.length,r))>-1&&Sv(n,u))return{changes:{insert:e+e+e+e,from:l},effects:zi.of(l+e.length),range:R.cursor(l+e.length)};if(n.charCategorizer(l)(c)!=Ge.Word&&Ev(n,l,r)>-1&&!YA(n,l,e,r))return{changes:{insert:e+e,from:l},effects:zi.of(l+e.length),range:R.cursor(l+e.length)}}return{range:s=a}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Sv(n,e){let t=ge(n).resolveInner(e+1);return t.parent&&t.from==e}function YA(n,e,t,i){let r=ge(n).resolveInner(e,-1),s=i.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),l=a.indexOf(t);if(!l||l>-1&&i.indexOf(a.slice(0,l))>-1){let u=r.firstChild;for(;u&&u.from==r.from&&u.to-u.from>t.length+l;){if(n.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=r.to==e&&r.parent;if(!c)break;r=c}return!1}function Ev(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=Ge.Word)return e;for(let r of t){let s=e-r.length;if(n.sliceDoc(s,e)==r&&i(n.sliceDoc(s-1,s))!=Ge.Word)return s}return-1}function Bv(n={}){return[MA,lt,De.of(n),_A,GA,Tv]}var KA=[{key:"Ctrl-Space",run:qh},{mac:"Alt-`",run:qh},{mac:"Alt-i",run:qh},{key:"Escape",run:SA},{key:"ArrowDown",run:rc(!0)},{key:"ArrowUp",run:rc(!1)},{key:"PageDown",run:rc(!0,"page")},{key:"PageUp",run:rc(!1,"page")},{key:"Enter",run:CA}],GA=Rn.highest(cs.computeN([De],n=>n.facet(De).defaultKeymap?[KA]:[]));var JA=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=ld(n.state,t.from);return i.line?ZA(n):i.block?t2(n):!1};function ad(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var ZA=ad(r2,0);var e2=ad(zv,0);var t2=ad((n,e)=>zv(n,e,i2(e)),0);function ld(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}var ea=50;function n2(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-ea,i),o=n.sliceDoc(r,r+ea),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,c=s.length-a;if(s.slice(c-e.length,c)==e&&o.slice(l,l+t.length)==t)return{open:{pos:i-a,margin:a&&1},close:{pos:r+l,margin:l&&1}};let u,f;r-i<=2*ea?u=f=n.sliceDoc(i,r):(u=n.sliceDoc(i,i+ea),f=n.sliceDoc(r-ea,r));let h=/^\s*/.exec(u)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return u.slice(h,h+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+h+e.length,margin:/\s/.test(u.charAt(h+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function i2(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to);r.from>i.from&&r.from==t.to&&(r=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function zv(n,e,t=e.selection.ranges){let i=t.map(s=>ld(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>n2(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,a;or&&(s==o||o>f.from)){r=f.from;let h=/^\s*/.exec(f.text)[0].length,d=h==f.length,p=f.text.slice(h,h+c.length)==c?h:-1;hs.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:l,indent:c,empty:u,single:f}of i)(f||!u)&&s.push({from:a.from+c,insert:l+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:a,token:l}of i)if(a>=0){let c=o.from+a,u=c+l.length;o.text[u-o.from]==" "&&u++,s.push({from:c,to:u})}return{changes:s}}return null}var Iv=gt.define();var s2=N.define();var Hi=class n{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&Je.fromJSON(e.changes),[],e.mapped&&Tn.fromJSON(e.mapped),e.startSelection&&R.fromJSON(e.startSelection),e.selectionsAfter.map(R.fromJSON))}static fromTransaction(e,t){let i=It;for(let r of e.startState.facet(s2)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,It)}static selection(e){return new n(void 0,It,void 0,void 0,e)}};function rd(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function o2(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,a)=>{for(let l=0;l=c&&o<=u&&(i=!0)}}),i}function a2(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Wv(n,e){return n.length?e.length?n.concat(e):n:e}var It=[],l2=200;function c2(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-l2));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),rd(n,n.length-1,1e9,t.setSelAfter(i)))}else return[Hi.selection([e])]}function u2(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function id(n,e){if(!n.length)return n;let t=n.length,i=It;for(;t;){let r=f2(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[Hi.selection(i)]:It}function f2(n,e,t){let i=Wv(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):It,t);if(!n.changes)return Hi.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new Hi(r,U.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var h2=/^(input\.type|delete)($|\.)/,fc=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!i||h2.test(i))&&(!a.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):hc(t,e))}function He(n){return n.textDirectionAt(n.state.selection.main.head)==ue.LTR}var Xv=n=>Hv(n,!He(n)),Uv=n=>Hv(n,He(n));function Yv(n,e){return Gt(n,t=>t.empty?n.moveByGroup(t,e):hc(t,e))}var d2=n=>Yv(n,!He(n)),p2=n=>Yv(n,He(n));var H3=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function m2(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function dc(n,e,t){let i=ge(n).resolveInner(e.head),r=t?H.closedBy:H.openedBy;for(let l=e.head;;){let c=t?i.childAfter(l):i.childBefore(l);if(!c)break;m2(n,c,r)?i=c:l=t?c.to:c.from}let s=i.type.prop(r),o,a;return s&&(o=t?Yt(n,i.from,1):Yt(n,i.to,-1))&&o.matched?a=t?o.end.to:o.end.from:a=t?i.to:i.from,R.cursor(a,t?-1:1)}var g2=n=>Gt(n,e=>dc(n.state,e,!He(n))),y2=n=>Gt(n,e=>dc(n.state,e,He(n)));function Kv(n,e){return Gt(n,t=>{if(!t.empty)return hc(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var Gv=n=>Kv(n,!1),Jv=n=>Kv(n,!0);function Zv(n){let e=n.scrollDOM.clientHeighto.empty?n.moveVertically(o,e,t.height):hc(o,e));if(r.eq(i.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),a=n.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;o&&o.top>l&&o.bottomex(n,!1),sd=n=>ex(n,!0);function li(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=R.cursor(i.from+s))}return r}var v2=n=>Gt(n,e=>li(n,e,!0)),x2=n=>Gt(n,e=>li(n,e,!1)),b2=n=>Gt(n,e=>li(n,e,!He(n))),w2=n=>Gt(n,e=>li(n,e,He(n))),O2=n=>Gt(n,e=>R.cursor(n.lineBlockAt(e.head).from,1)),k2=n=>Gt(n,e=>R.cursor(n.lineBlockAt(e.head).to,-1));function C2(n,e,t){let i=!1,r=vs(n.selection,s=>{let o=Yt(n,s.head,-1)||Yt(n,s.head,1)||s.head>0&&Yt(n,s.head-1,1)||s.headC2(n,e,!1);function Lt(n,e){let t=vs(n.state.selection,i=>{let r=e(i);return R.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return t.eq(n.state.selection)?!1:(n.dispatch(Kt(n.state,t)),!0)}function tx(n,e){return Lt(n,t=>n.moveByChar(t,e))}var nx=n=>tx(n,!He(n)),ix=n=>tx(n,He(n));function rx(n,e){return Lt(n,t=>n.moveByGroup(t,e))}var E2=n=>rx(n,!He(n)),A2=n=>rx(n,He(n));var _2=n=>Lt(n,e=>dc(n.state,e,!He(n))),T2=n=>Lt(n,e=>dc(n.state,e,He(n)));function sx(n,e){return Lt(n,t=>n.moveVertically(t,e))}var ox=n=>sx(n,!1),ax=n=>sx(n,!0);function lx(n,e){return Lt(n,t=>n.moveVertically(t,e,Zv(n).height))}var $v=n=>lx(n,!1),Nv=n=>lx(n,!0),M2=n=>Lt(n,e=>li(n,e,!0)),R2=n=>Lt(n,e=>li(n,e,!1)),P2=n=>Lt(n,e=>li(n,e,!He(n))),D2=n=>Lt(n,e=>li(n,e,He(n))),B2=n=>Lt(n,e=>R.cursor(n.lineBlockAt(e.head).from)),I2=n=>Lt(n,e=>R.cursor(n.lineBlockAt(e.head).to)),qv=({state:n,dispatch:e})=>(e(Kt(n,{anchor:0})),!0),Fv=({state:n,dispatch:e})=>(e(Kt(n,{anchor:n.doc.length})),!0),jv=({state:n,dispatch:e})=>(e(Kt(n,{anchor:n.selection.main.anchor,head:0})),!0),Vv=({state:n,dispatch:e})=>(e(Kt(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),L2=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),$2=({state:n,dispatch:e})=>{let t=pc(n).map(({from:i,to:r})=>R.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:R.create(t),userEvent:"select"})),!0},N2=({state:n,dispatch:e})=>{let t=vs(n.selection,i=>{let r=ge(n),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:a}=o;if((a.from=i.to||a.to>i.to&&a.from<=i.from)&&o.next)return R.range(a.to,a.from)}return i});return t.eq(n.selection)?!1:(e(Kt(n,t)),!0)};function cx(n,e){let{state:t}=n,i=t.selection,r=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to0)for(let a=s;;){let l=n.moveVertically(a,e);if(l.heado.to){r.some(c=>c.head==l.head)||r.push(l);break}else{if(l.head==a.head)break;a=l}}}return r.length==i.ranges.length?!1:(n.dispatch(Kt(t,R.create(r,r.length-1))),!0)}var q2=n=>cx(n,!1),F2=n=>cx(n,!0),j2=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=R.create([t.main]):t.main.empty||(i=R.create([R.cursor(t.main.head)])),i?(e(Kt(n,i)),!0):!1};function ta(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let l=e(s);lo&&(t="delete.forward",l=uc(n,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=uc(n,o,!1),a=uc(n,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:R.cursor(o,or(n)))i.between(e,e,(r,s)=>{re&&(e=t?s:r)});return e}var ux=(n,e,t)=>ta(n,i=>{let r=i.from,{state:s}=n,o=s.doc.lineAt(r),a,l;if(t&&!e&&r>o.from&&rux(n,!1,!0);var fx=n=>ux(n,!0,!1),hx=(n,e)=>ta(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let a=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let l=Re(s.text,i-s.from,e)+s.from,c=s.text.slice(Math.min(i,l)-s.from,Math.max(i,l)-s.from),u=o(c);if(a!=null&&u!=a)break;(c!=" "||i!=t.head)&&(a=u),i=l}return i}),dx=n=>hx(n,!1),V2=n=>hx(n,!0);var Q2=n=>ta(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headta(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),W2=n=>ta(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:J.of(["",""])},range:R.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},X2=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:Re(s.text,r-s.from,!1)+s.from,a=r==s.to?r+1:Re(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:n.doc.slice(r,a).append(n.doc.slice(o,r))},range:R.cursor(a)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function pc(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function px(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of pc(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),a=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let l of s.ranges)r.push(R.range(Math.min(n.doc.length,l.anchor+a),Math.min(n.doc.length,l.head+a)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let l of s.ranges)r.push(R.range(l.anchor-a,l.head-a))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:R.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var U2=({state:n,dispatch:e})=>px(n,e,!1),Y2=({state:n,dispatch:e})=>px(n,e,!0);function mx(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of pc(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});let r=n.changes(i);return e(n.update({changes:r,selection:n.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var K2=({state:n,dispatch:e})=>mx(n,e,!1),G2=({state:n,dispatch:e})=>mx(n,e,!0),J2=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(pc(e).map(({from:r,to:s})=>(r>0?r--:s{let s;if(n.lineWrapping){let o=n.lineBlockAt(r.head),a=n.coordsAtPos(r.head,r.assoc||1);a&&(s=o.bottom+n.documentTop-a.bottom+n.defaultLineHeight/2)}return n.moveVertically(r,!0,s)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Z2(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ge(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(H.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var Qv=gx(!1),e_=gx(!0);function gx(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,a=e.doc.lineAt(s),l=!n&&s==o&&Z2(e,s);n&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let c=new Qi(e,{simulateBreak:s,simulateDoubleBreak:!!l}),u=tc(c,s);for(u==null&&(u=Di(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));oa.from&&s{let r=[];for(let o=i.from;o<=i.to;){let a=n.doc.lineAt(o);a.number>t&&(i.empty||i.to>a.from)&&(e(a,r,i),t=a.number),o=a.to+1}let s=n.changes(r);return{changes:r,range:R.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}var t_=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Qi(n,{overrideIndentation:s=>{let o=t[s];return o==null?-1:o}}),r=cd(n,(s,o,a)=>{let l=tc(i,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let c=/^\s*/.exec(s.text)[0],u=ms(n,l);(c!=u||a.fromn.readOnly?!1:(e(n.update(cd(n,(t,i)=>{i.push({from:t.from,insert:n.facet(ps)})}),{userEvent:"input.indent"})),!0),i_=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(cd(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Di(r,n.tabSize),o=0,a=ms(n,Math.max(0,s-Ko(n)));for(;o(n.setTabFocusMode(),!0);var s_=[{key:"Ctrl-b",run:Xv,shift:nx,preventDefault:!0},{key:"Ctrl-f",run:Uv,shift:ix},{key:"Ctrl-p",run:Gv,shift:ox},{key:"Ctrl-n",run:Jv,shift:ax},{key:"Ctrl-a",run:O2,shift:B2},{key:"Ctrl-e",run:k2,shift:I2},{key:"Ctrl-d",run:fx},{key:"Ctrl-h",run:od},{key:"Ctrl-k",run:Q2},{key:"Ctrl-Alt-h",run:dx},{key:"Ctrl-o",run:H2},{key:"Ctrl-t",run:X2},{key:"Ctrl-v",run:sd}],o_=[{key:"ArrowLeft",run:Xv,shift:nx,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:d2,shift:E2,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:b2,shift:P2,preventDefault:!0},{key:"ArrowRight",run:Uv,shift:ix,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:p2,shift:A2,preventDefault:!0},{mac:"Cmd-ArrowRight",run:w2,shift:D2,preventDefault:!0},{key:"ArrowUp",run:Gv,shift:ox,preventDefault:!0},{mac:"Cmd-ArrowUp",run:qv,shift:jv},{mac:"Ctrl-ArrowUp",run:Lv,shift:$v},{key:"ArrowDown",run:Jv,shift:ax,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Fv,shift:Vv},{mac:"Ctrl-ArrowDown",run:sd,shift:Nv},{key:"PageUp",run:Lv,shift:$v},{key:"PageDown",run:sd,shift:Nv},{key:"Home",run:x2,shift:R2,preventDefault:!0},{key:"Mod-Home",run:qv,shift:jv},{key:"End",run:v2,shift:M2,preventDefault:!0},{key:"Mod-End",run:Fv,shift:Vv},{key:"Enter",run:Qv,shift:Qv},{key:"Mod-a",run:L2},{key:"Backspace",run:od,shift:od,preventDefault:!0},{key:"Delete",run:fx,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:dx,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:V2,preventDefault:!0},{mac:"Mod-Backspace",run:z2,preventDefault:!0},{mac:"Mod-Delete",run:W2,preventDefault:!0}].concat(s_.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),yx=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:g2,shift:_2},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:y2,shift:T2},{key:"Alt-ArrowUp",run:U2},{key:"Shift-Alt-ArrowUp",run:K2},{key:"Alt-ArrowDown",run:Y2},{key:"Shift-Alt-ArrowDown",run:G2},{key:"Mod-Alt-ArrowUp",run:q2},{key:"Mod-Alt-ArrowDown",run:F2},{key:"Escape",run:j2},{key:"Mod-Enter",run:e_},{key:"Alt-l",mac:"Ctrl-l",run:$2},{key:"Mod-i",run:N2,preventDefault:!0},{key:"Mod-[",run:i_},{key:"Mod-]",run:n_},{key:"Mod-Alt-\\",run:t_},{key:"Shift-Mod-k",run:J2},{key:"Shift-Mod-\\",run:S2},{key:"Mod-/",run:JA},{key:"Alt-A",run:e2},{key:"Ctrl-m",mac:"Shift-Alt-m",run:r_}].concat(o_);var gc=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},Xi=class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=i.facet(vn).markerFilter;r&&(e=r(e,i));let s=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Mn,a=[],l=0,c=i.doc.iter(),u=0,f=i.doc.length;for(let d=0;;){let p=d==s.length?null:s[d];if(!p&&!a.length)break;let m,y;if(a.length)m=l,y=a.reduce((x,b)=>Math.min(x,b.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;y=p.to,a.push(p),d++}for(;dx.from||x.to==m))a.push(x),d++,y=Math.min(x.to,y);else{y=Math.min(x.from,y);break}}y=Math.min(y,f);let g=!1;if(a.some(x=>x.from==m&&(x.to==y||y==f))&&(g=m==y,!g&&y-m<10)){let x=m-(u+c.value.length);x>0&&(c.next(x),u=m);for(let b=m;;){if(b>=y){g=!0;break}if(!c.lineBreak&&u+c.value.length>b)break;b=u+c.value.length,u+=c.value.length,c.next()}}let k=v_(a);if(g)o.add(m,m,X.widget({widget:new ud(k),diagnostics:a.slice()}));else{let x=a.reduce((b,C)=>C.markClass?b+" "+C.markClass:b,"");o.add(m,y,X.mark({class:"cm-lintRange cm-lintRange-"+k+x,diagnostics:a.slice(),inclusiveEnd:a.some(b=>b.to>y)}))}if(l=y,l==f)break;for(let x=0;x{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new gc(r,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new gc(i.from,s,i.diagnostic)}}),i}function a_(n,e){let t=e.pos,i=e.end||t,r=n.state.facet(vn).hideOn(n,t,i);if(r!=null)return r;let s=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(na))||n.changes.touchesRange(s.from,Math.max(s.to,i)))}function l_(n,e){return n.field(Jt,!1)?e:e.concat(U.appendConfig.of(Sx))}function c_(n,e){return{effects:l_(n,[na.of(e)])}}var na=U.define(),bx=U.define(),wx=U.define(),Jt=Ne.define({create(){return new Xi(X.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,r=n.panel;if(n.selected){let s=e.changes.mapPos(n.selected.from,1);i=xs(t,n.selected.diagnostic,s)||xs(t,null,s)}!t.size&&r&&e.state.facet(vn).autoPanel&&(r=null),n=new Xi(t,r,i)}for(let t of e.effects)if(t.is(na)){let i=e.state.facet(vn).autoPanel?t.value.length?vc.open:null:n.panel;n=Xi.init(t.value,i,e.state)}else t.is(bx)?n=new Xi(n.diagnostics,t.value?vc.open:null,n.selected):t.is(wx)&&(n=new Xi(n.diagnostics,n.panel,t.value));return n},provide:n=>[jl.from(n,e=>e.panel),q.decorations.from(n,e=>e.diagnostics)]});var u_=X.mark({class:"cm-lintRange cm-lintRange-active"});function f_(n,e,t){let{diagnostics:i}=n.state.field(Jt),r,s=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:u})=>{if(e>=l&&e<=c&&(l==c||(e>l||t>0)&&(eCx(n,t,!1)))}var vx=n=>{let e=n.state.field(Jt,!1);return!e||!e.panel?!1:(n.dispatch({effects:bx.of(!1)}),!0)};var d_=ze.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(vn);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let n=Date.now();if(nPromise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(c_(this.view.state,i.reduce((r,s)=>r.concat(s))))},i=>{Pe(this.view.state,i)})}}update(n){let e=n.state.facet(vn);(n.docChanged||e!=n.startState.facet(vn)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function p_(n,e,t){let i=[],r=-1;for(let s of n)s.then(o=>{i.push(o),clearTimeout(r),i.length==n.length?e(i):r=setTimeout(()=>e(i),200)},t)}var vn=N.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...ei(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:xx,tooltipFilter:xx,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,r,s)=>e(i,r,s)||t(i,r,s):e:t,autoPanel:(e,t)=>e||t})}}});function xx(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function Ox(n,e={}){return[vn.of({source:n,config:e}),d_,Sx]}function kx(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;is.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function Cx(n,e,t){var i;let r=t?kx(e.actions):[];return yt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},yt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let p=xs(n.state.field(Jt).diagnostics,e);p&&s.apply(n,p.from,p.to)},{name:c}=s,u=r[o]?c.indexOf(r[o]):-1,f=u<0?c:[c.slice(0,u),yt("u",c.slice(u,u+1)),c.slice(u+1)],h=s.markClass?" "+s.markClass:"";return yt("button",{type:"button",class:"cm-diagnosticAction"+h,onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&yt("div",{class:"cm-diagnosticSource"},e.source))}var ud=class extends Dt{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return yt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},yc=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Cx(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},vc=class n{constructor(e){this.view=e,this.items=[];let t=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)vx(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=kx(s.actions);for(let a=0;a{for(let s=0;svx(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Jt).selected;if(!e)return-1;for(let t=0;t{for(let u of c.diagnostics){if(o.has(u))continue;o.add(u);let f=-1,h;for(let d=i;di&&(this.items.splice(i,f-i),r=!0)),t&&h.diagnostic==t.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),s=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),i++}});i({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.topl.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Jt),i=xs(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:wx.of(i)})}static open(e){return new n(e)}};function m_(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function mc(n){return m_(``,'width="6" height="3"')}var g_=q.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:mc("#d11")},".cm-lintRange-warning":{backgroundImage:mc("orange")},".cm-lintRange-info":{backgroundImage:mc("#999")},".cm-lintRange-hint":{backgroundImage:mc("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function y_(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function v_(n){let e="hint",t=1;for(let i of n){let r=y_(i.severity);r>t&&(t=r,e=i.severity)}return e}var Sx=[Jt,q.decorations.compute([Jt],n=>{let{selected:e,panel:t}=n.field(Jt);return!e||!t||e.from==e.to?X.none:X.set([u_.range(e.from,e.to)])}),H0(f_,{hideOn:a_}),g_];function Ex(n){return{all:n=n||new Map,on:function(e,t){var i=n.get(e);i?i.push(t):n.set(e,[t])},off:function(e,t){var i=n.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var i=n.get(e);i&&i.slice().map(function(r){r(t)}),(i=n.get("*"))&&i.slice().map(function(r){r(e,t)})}}}var dd=class n{constructor(e,t,i,r,s,o,a,l,c,u=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=r,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=f}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let r=e.parser.context;return new n(e,[],t,i,i,0,[],0,r?new xc(r,r.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 i=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSizel;)this.stack.pop();this.reduceContext(r,c)}storeNode(e,t,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==i)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,t,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>i;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,t,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=r;let a=o.stateFlag(s,1);!a&&(r>i||t<=o.maxNode)&&(this.reducePos=r),this.pushState(s,a?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,r,4)}else this.pos=r,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,r,4)}apply(e,t,i,r){e&65536?this.reduce(e):this.shift(e,t,i,r)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new n(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new pd(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}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 r=[];for(let s=0,o;sl&1&&a==o)||r.push(t[s],o)}t=r}let i=[];for(let r=0;r>19,r=t&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}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=[],i=(r,s)=>{if(!t.includes(r))return t.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;if(a>1){let l=o&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=i(o,s+1);if(a!=null)return a}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}},xc=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},pd=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},md=class n{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new n(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new n(this.stack,this.pos,this.index)}};function ia(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,r=0;i=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}t?t[r++]=s:t=new e(s)}return t}var bs=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},Ax=new bs,gd=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Ax,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 i=this.range,r=this.rangeIndex,s=this.pos+e;for(;si.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,r;if(t>=0&&t=this.chunk2Pos&&ia.to&&(this.chunk2=this.chunk2.slice(0,a.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=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=Ax,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 i="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return i}},ci=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;Px(this.data,e,t,this.id,i.data,i.tokenPrecTable)}};ci.prototype.contextual=ci.prototype.fallback=ci.prototype.extend=!1;var yd=class{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?ia(e):e}token(e,t){let i=e.pos,r=0;for(;;){let s=e.next<0,o=e.resolveOffset(1,1);if(Px(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,o==null)break;e.reset(o,e.token)}r&&(e.reset(i,e.token),e.acceptToken(this.elseToken,r))}};yd.prototype.contextual=ci.prototype.fallback=ci.prototype.extend=!1;var ws=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function Px(n,e,t,i,r,s){let o=0,a=1<0){let p=n[d];if(l.allows(p)&&(e.token.value==-1||e.token.value==p||b_(p,e.token.value,r,s))){e.acceptToken(p);break}}let u=e.next,f=0,h=n[o+2];if(e.next<0&&h>f&&n[c+h*3-3]==65535){o=n[c+h*3-1];continue e}for(;f>1,p=c+d+(d<<1),m=n[p],y=n[p+1]||65536;if(u=y)f=d+1;else{o=n[p+2],e.advance();continue e}}break}}function _x(n,e,t){for(let i=e,r;(r=n[i])!=65535;i++)if(r==t)return i-e;return-1}function b_(n,e,t,i){let r=_x(t,i,e);return r<0||_x(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}var vd=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Tx(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Tx(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=o,null;if(s instanceof be){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}},xd=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new bs)}getActions(e){let t=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;cf.end+25&&(l=Math.max(f.lookAhead,l)),f.value!=0)){let h=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!u.extend&&(i=f,t>h))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!i&&e.pos==this.stream.end&&(i=new bs,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new bs,{pos:i,p:r}=e;return t.start=i,t.end=Math.min(i+1,r.stream.end),t.value=i==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,i){let r=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o=0&&i.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,i,r){for(let s=0;se.bufferLength*4?new vd(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)i.push(a);else{if(this.advanceStack(a,i,e))continue;{r||(r=[],s=[]),r.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!i.length){let o=r&&w_(r);if(o)return bt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw bt&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return bt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((a,l)=>l.score-a.score);i.length>o;)i.pop();i.some(a=>a.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)i.splice(l--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,a)=>a.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let f=this.fragments.nodeAt(r);f;){let h=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(h>-1&&f.length&&(!c||(f.prop(H.contextHash)||0)==u))return e.useNode(f,h),bt&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof be)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof be&&f.positions[0]==0)f=d;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),bt&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;cr?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return Mx(e,t),!0}}runRecovery(e,t,i){let r=null,s=!1;for(let o=0;o ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),bt&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,i))))continue;let f=a.split(),h=u;for(let d=0;d<10&&f.forceReduce()&&(bt&&console.log(h+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)bt&&(h=this.stackID(f)+" -> ");for(let d of a.recoverByInsert(l))bt&&console.log(u+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),bt&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),Mx(a,i)):(!r||r.scoren,bc=class{constructor(e){this.start=e.start,this.shift=e.shift||hd,this.reduce=e.reduce||hd,this.reuse=e.reuse||hd,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},wc=class n extends us{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;ae.topRules[a][1]),r=[];for(let a=0;a=0)s(u,l,a[c++]);else{let f=a[c+-u];for(let h=-u;h>0;h--)s(a[c++],l,f);c++}}}this.nodeSet=new Qo(t.map((a,l)=>We.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:r[l],top:i.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let o=ia(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;atypeof a=="number"?new ci(o,a):a),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,i){let r=new bd(this,e,t,i);for(let s of this.wrappers)r=s(r,e,t,i);return r}getGoto(e,t,i=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let o=r[s++],a=o&1,l=r[s++];if(a&&i)return l;for(let c=s+(o>>1);s0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),r=i?t(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=$n(this.data,s+2);else break;r=t($n(this.data,s+1))}return r}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=$n(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];t.some((s,o)=>o&1&&s==r)||t.push(this.data[i],r)}}return t}configure(e){let t=Object.assign(Object.create(n.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(a=>a.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return t.specializers[r]=Rx(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(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 t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;si)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}var O_=121,Cd=122,qx=123,k_=124,Dx=128,C_=4,S_=131,E_=7,A_=8,__=9,T_=10,M_=139,Fx=19,R_=140,P_=23,D_=141,B_=27,I_=37,L_=41,$_=144,N_=145,q_=146,F_=147,j_=47,V_=68,jx=153,Vx=70,Qx=154,zx=72,Q_=155,z_=76,W_=160,H_=79,X_=80,U_=81,Y_=167,Wx=89,K_=90,G_=169,J_=97,Z_=171,eT=98,tT=100,nT=101,Sd=typeof process!="undefined"&&process.env&&/\bfparse(:dbg)?\b/.test(process.env.LOG),Ed=typeof process!="undefined"&&process.env&&/\bfparse:dbg\b/.test(process.env.LOG),Nn=typeof process!="undefined"&&process.env&&/\bcontext\b/.test(process.env.LOG),Hx=[9,11,12,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],iT=Xx(` \r`),Bx=42,rT=Xx("'./-+*^");function Xx(n){return Array.from(n).map(e=>e.charCodeAt(0))}function sT(n){return n===63||n>=65&&n<=90||n===95||n>=97&&n<=122||n>=192&&n<=214||n>=216&&n<=246||n>=248&&n<=767||n>=880&&n<=893||n>=895&&n<=8191||n>=8204&&n<=8205||n>=8304&&n<=8591||n>=11264&&n<=12271||n>=12289&&n<=55295||n>=63744&&n<=64975||n>=65008&&n<=65533||n>=55296&&n<=56319||n>=56320&&n<=57343}function oT(n){return rT.includes(n)}function aT(n){return n>=48&&n<=57||n===183||n>=768&&n<=879||n>=8255&&n<=8256}function lT(n){return Hx.includes(n)}function Ix(n,e){return e.concat(n.split(/\n/g).join(` `+e))}function cT(n,e=0){let t=n.peek(e);return t===Bx&&n.peek(e+1)===Bx?{offset:2,token:"**"}:oT(t)?{offset:1,token:String.fromCharCode(t)}:null}function Oc(n,e=0,t=!1){for(let i=!1,r=[],s=0;;s++){let o=n.peek(e+s);if(sT(o)||(i||t)&&aT(o))i||(i=!0),r.push(o);else return r.length?{token:String.fromCharCode(...r),offset:s}:null}}function Ux(n,e){for(let t=!1,i=0;;i++){let r=n.peek(e+i);if(lT(r))t||(t=!0);else return t?{token:" ",offset:i}:null}}function uT(n,e){let{keys:t,prefixes:i}=e.contextCache(),r=e.tokens;for(let s=0,o=[],a=null;;){let l=r.length+o.length>0,c=o.length>0,u=Oc(n,s,l)||l&&cT(n,s)||c&&Ux(n,s);if(!u)return a;let{token:f,offset:h}=u;if(s+=h,f===" ")continue;o=[...o,f];let d=[...r,...o].join(" ");if(t.has(d)){let p=o[0];a={token:p,offset:p.length,term:qx}}if(!i.has(d)){if(Lx.some(p=>p===d)){let p=o[0];a={token:p,offset:p.length,term:Cd}}if(!Lx.some(p=>p.startsWith(d)))return a}}}var fT={[Cd]:"identifier",[qx]:"nameIdentifier"},hT=new ws((n,e)=>{Ed&&console.log("%s: T ",n.pos);let t=uT(n,e.context),i=e.context.tokens,r=t||Oc(n,0,i.length>0);r&&(n.advance(r.offset),n.acceptToken(t?t.term:Cd),Sd&&console.log("%s: MATCH <%s> <%s>",n.pos,t?fT[t.term]:"identifier",r.token))},{contextual:!0}),dT=new ws((n,e)=>{Ed&&console.log("%s: T ",n.pos);let t=e.context.tokens,i=Oc(n,0,t.length>0);i&&(n.advance(i.offset),n.acceptToken(O_),Sd&&console.log("%s: MATCH <%s>",n.pos,i.token))}),pT=new ws((n,e)=>{Ed&&console.log("%s: T ",n.pos);let t,i=!1;for(t=0;;t++){let r=n.peek(t);if(!Hx.includes(r)){iT.includes(r)&&(i=!0);break}}if(i){let r=Oc(n,t+1);if(Ux(n,t+1)||r&&/^(then|else|return|satisfies)$/.test(r.token))return;Sd&&console.log("%s: MATCH ",n.pos),n.acceptToken(k_)}}),mT={[Q_]:"FunctionInvocation",[Qx]:"FilterExpression",[jx]:"PathExpression"},gT={[Z_]:"Context",[G_]:"FunctionDefinition",[S_]:"ForExpression",[Y_]:"List",[R_]:"IfExpression",[D_]:"QuantifiedExpression"},yT={[J_]:"Context",[K_]:"FunctionDefinition",[C_]:"ForExpression",[Wx]:"List",[Fx]:"IfExpression",[P_]:"QuantifiedExpression",[V_]:"PathExpression",[zx]:"FunctionInvocation",[Vx]:"FilterExpression",[L_]:"ArithmeticExpression"},ks=class n{constructor(e){this.fn=e}get(e){return this.fn(e)}static of(e){return new n(e)}},vT={"date and time":1,date:1,time:1,duration:1},Lx=Object.keys(vT);function xT(n){let e=[];for(let t=1;t<=n.length;t++)e.push(n.substring(0,t));return e}function Yx(n,e){let t=Ad(n),i=xT(t);e.keys.add(t);for(let r of i)e.prefixes.add(r);return e.originalMap.set(t,n),e}function $x(n){let e=Kx();for(let t of n.getKeys())Yx(t,e);return e}function Kx(n){return{keys:new Set(n==null?void 0:n.keys),prefixes:new Set(n==null?void 0:n.prefixes),originalMap:new Map(n==null?void 0:n.originalMap)}}var Od=class{constructor(e={}){this.value=e}getKeys(){return Object.keys(this.value)}get(e){let t=this.value[e],i=this.constructor;return i.isAtomic(t)?t:i.of(t)}set(e,t){let i=this.constructor;return new i({...this.value,[e]:t})}merge(e){let t=this.constructor;return new t(t.__merge(this.value,e))}static isAtomic(e){return e==null||e instanceof this||e instanceof ks||typeof e!="object"}static of(...e){let t=e.reduce((i,r)=>this.__merge(i,r),{});return new this(t)}static __unwrap(e){return e?e instanceof this?e.value:this.isAtomic(e)?{}:e:{}}static __merge(e,t){let i=Object.assign({},this.__unwrap(e));for(let[r,s]of Object.entries(this.__unwrap(t))){if(s instanceof ks){i[r]=s;continue}if(Ss(i,r)){i[r]=this.__merge(i[r],s);continue}i[r]=s}return i}},kd=class n{constructor({name:e="Expressions",tokens:t=[],children:i=[],parent:r=null,context:s,value:o,raw:a,__cache:l}){this.name=e,this.tokens=t,this.children=i,this.parent=r,this.context=s,this.value=o,this.raw=a,this.__cache=l}get root(){let e=this;for(;e.parent;)e=e.parent;return e}get cache(){let e=this.root;return e.__cache||(e.__cache=new WeakMap),e.__cache}enterScope(e){let t=this.of({name:e,parent:this});return Nn&&console.log("[%s] enter",t.path,t.context),t}exitScope(e){return this.parent?(Nn&&console.log(`[%s] exit %o %s`,this.path,this.context,Ix(e," ")),this.parent.pushChild(this)):(Nn&&console.log(`[%s] NO exit %o %s`,this.path,this.context,Ix(e," ")),this)}token(e){return Nn&&console.log("[%s] token <%s> + <%s>",this.path,this.tokens.join(" "),e),this.assign({tokens:[...this.tokens,e]})}literal(e){return Nn&&console.log("[%s] literal %o",this.path,e),this.pushChild(this.of({name:"Literal",value:e}))}computedValue(){for(let e=this;;e=Os(e.children)){if(!e)return null;if(!ha(e.value))return e.value}}contextCache(){let e=this.cache.get(this.context);return e||(e=$x(this.context),this.cache.set(this.context,e)),e}get path(){var e,t;return((t=(e=this.parent)==null?void 0:e.path)==null?void 0:t.concat(" > ",this.name))||this.name}get(e){let t=e&&Ad(e),i=this.contextCache().originalMap.get(t);if(typeof i=="undefined")return;let r=this.context.get(i);return r instanceof ks?r.get(this):r}resolveName(){let e=this.tokens.join(" "),t=[],i=this.assign({tokens:t}),r=this.of({name:"VariableName",parent:i,value:this.get(e),raw:e});return Nn&&console.log("[%s] resolve name <%s=%s>",r.path,e,this.get(e)),i.pushChild(r)}pushChild(e){if(!e)return this;let t=this.assign({children:[...this.children,e]});return e.parent=t,t}pushChildren(e){let t=this;for(let i of e)t=t.pushChild(i);return t}declareName(){if(this.tokens.length===0)throw Error("no tokens to declare name");let e=this.tokens.join(" ");return Nn&&console.log("[%s] declareName <%s>",this.path,e),this.assign({tokens:[]}).pushChild(this.of({name:"Name",value:e}))}define(e,t){if(typeof e!="string")return Nn&&console.log("[%s] no define <%s=%s>",this.path,e,t),this;Nn&&console.log("[%s] define <%s=%s>",this.path,e,t);let i=this.context,r=i.set(e,t),s=this.cache.get(i)||$x(i),o=Yx(e,Kx(s));return this.cache.set(r,o),this.assign({context:r})}assign(e={}){return n.of({...this,...e})}of(e={}){let t={context:this.context,parent:this.parent};return n.of({...t,...e})}static of(e){let{name:t,tokens:i=[],children:r=[],parent:s=null,context:o,value:a,raw:l,__cache:c}=e;if(!o)throw new Error("must provide ");return new n({name:t,tokens:[...i],children:[...r],context:o,parent:s,value:a,raw:l,__cache:c})}};function Ad(n){return n.replace(/\s*([./\-'+]|\*\*?)\s*/g," $1 ").replace(/\s{2,}/g," ").trim()}function Nx(n,e,t){var c;let i=n.children.filter(u=>u.name!==e),r=n.children.filter(u=>u.name===e),s=i[0],o=i[Math.max(1,i.length-1)],a=s==null?void 0:s.computedValue(),l=(c=o==null?void 0:o.computedValue())!=null?c:null;return n.assign({children:r}).enterScope(e).pushChildren(i).exitScope(t).define(a,l)}function _d(n={},e=Od){let t=kd.of({context:e.of(n)});return new bc({start:t,reduce(i,r,s,o){if(r===Fx){let[f,h]=i.children.slice(-2);i=i.assign({value:e.of(f==null?void 0:f.computedValue(),h==null?void 0:h.computedValue())})}if(r===Wx&&(i=i.assign({value:e.of(...i.children.map(f=>f==null?void 0:f.computedValue()))})),r===Vx){let[f,h]=i.children.slice(-2);i=i.assign({value:f==null?void 0:f.computedValue()})}if(r===zx){let[f,...h]=i.children;(f==null?void 0:f.raw)==="get value"?i=wT(i,h):i=i.assign({value:(f==null?void 0:f.computedValue())||e.of(void 0)})}let a=gT[r];if(a)return i.enterScope(a);let l=mT[r];if(l){let{children:f,context:h}=i,d=f.slice(0,-1),p=Os(f),m=null;return r===jx&&(m=e.of(p==null?void 0:p.computedValue())),r===Qx&&(m=e.of(h,p==null?void 0:p.computedValue()).set("item",p==null?void 0:p.computedValue())),i.assign({children:d}).enterScope(l).pushChild(p).assign({context:m||h})}let c=o.read(o.pos,s.pos);if(yT[r])return i.exitScope(c);if(r===eT){let f=i.children.filter(p=>p.name!=="ContextEntry"),h=f[0],d=Os(f);return Nx(i,"ContextEntry",c).assign({value:e.of(i.value).set(h==null?void 0:h.computedValue(),d==null?void 0:d.computedValue())})}if(r===E_||r===B_)return Nx(i,"InExpression",c);if(r===M_)return i.define("partial",ks.of(f=>{var h;return(h=Os(f.children))==null?void 0:h.computedValue()}));if(r===z_){let f=Os(i.children).computedValue();return i.define(f,1)}if(r===$_||r===N_||r===q_){let f=i.children.slice(0,-1),h=Os(i.children);return i.assign({children:f}).enterScope("ArithmeticExpression").pushChild(h)}if(r===F_)return i.enterScope("ArithmeticExpression");if(r===__||r===T_||r===nT)return i.token(c);if(r===X_)return i.literal(c.replace(/^"|"$/g,"").replace(/\\(["\\])/g,"$1"));if(r===U_)return i.literal(c==="true");if(r===H_)return i.literal(parseFloat(c));if(r===W_)return i.literal(null);if(r===j_)return i.resolveName();if(r===A_||r===tT)return i.declareName();if((r===Dx||r===I_)&&i.tokens.length>0)throw new Error("uncleared name");if(r===Dx){let f=i;for(;f.parent;)f=f.exitScope(c);return f}return i}})}var bT=_d({});function wT(n,e){if(!e.length)return n.assign({value:null});if(e[0].name==="Name"&&(e=OT(e,["m","key"])),e.length!==2)return n.assign({value:null});let[t,i]=e,r=i==null?void 0:i.computedValue(),s=t==null?void 0:t.computedValue();return!s||typeof s!="object"||typeof r!="string"?n.assign({value:null}):n.assign({value:[Ad(r),r].reduce((o,a)=>s.get(a)||o,null)})}function OT(n,e){let t={};for(let i=0;it[i])}function Os(n){return n[n.length-1]}var kT=Jl({StringLiteral:T.string,NumericLiteral:T.number,BooleanLiteral:T.bool,"AtLiteral!":T.special(T.string),CompareOp:T.compareOperator,ArithOp:T.arithmeticOperator,"for if then else some every satisfies between return":T.controlKeyword,"in instance of and or":T.operatorKeyword,function:T.definitionKeyword,as:T.keyword,"Type/...":T.typeName,Wildcard:T.special(T.variableName),null:T.null,LineComment:T.lineComment,BlockComment:T.blockComment,'VariableName! "?"':T.variableName,"DateTimeConstructor! SpecialFunctionName!":T.function(T.special(T.variableName)),"List Interval":T.list,Context:T.definition(T.literal),"Name!":T.definition(T.variableName),"Key/Name! ContextEntryType/Name!":T.definition(T.propertyName),"PathExpression/VariableName!":T.function(T.propertyName),"FormalParameter/ParameterName!":T.function(T.definition(T.variableName)),"( )":T.paren,"[ ]":T.squareBracket,"{ }":T.brace,".":T.derefOperator,", ;":T.separator,"..":T.punctuation}),CT={__proto__:null,for:10,in:32,return:36,if:40,then:42,else:44,some:48,every:50,satisfies:56,or:60,and:64,between:72,instance:86,of:89,days:101,time:103,duration:105,years:107,months:109,date:111,list:117,context:123,function:130,null:156,true:330,false:330,"?":170,external:186,not:211},Gx=wc.deserialize({version:14,states:"CjO`QYOOO`QYOOO$yQYOOOOQU'#Ce'#CeO%TQYO'#C`O&^QYO'#FQOOQQ'#Fe'#FeO&hQYO'#FeO`QYO'#DVOOQU'#En'#EnO(_Q^O'#D]OOQU'#D^'#D^OOQU'#D]'#D]OOQO'#Fm'#FmO*[QWO'#DvOOQQ'#D}'#D}OOQQ'#EO'#EOOOQQ'#EP'#EPO*aOWO'#ESO*[QWO'#EQOOQQ'#EQ'#EQOOQQ'#Fs'#FsOOQQ'#Fq'#FqOOQQ'#Fy'#FyOOQQ'#EU'#EUO`QYO'#EWOOQQ'#FS'#FSO*iQ^O'#FSO,`QYO'#EXO,gQWO'#EYOOQP'#F}'#F}O,lQXO'#EaOOQQ'#Fz'#FzOOQQ'#FR'#FRQOQWOOOOQQ'#FT'#FTOOQQ'#F^'#F^O`QYO'#CoOOQQ'#F_'#F_O%TQYO'#CsO,zQYO'#DwOOQQ'#Fr'#FrO-PQYO'#EROOQO'#ER'#ERO`QYO'#EVO`QYO'#EUOOQO'#F{'#F{Q-XQWOOO-^QYO'#DRO.TQWO'#FaOOQO'#DT'#DTO.`QYO'#FeO.gQWOOO/^QYO'#CdO/kQYO'#FVOOQQ'#Cc'#CcO/pQYO'#FUOOQQ'#Cb'#CbO/xQYO,58zO`QYO,59iOOQQ'#Fb'#FbOOQQ'#Fc'#FcOOQQ'#Fd'#FdO`QYO,59qO`QYO,59qO`QYO,59qOOQQ'#Fk'#FkO/}QYO,5:^OOQQ'#Fl'#FlO`QYO,5:`O`QYO,59eO`QYO,59gO`QYO,59iO1|QYO,59iO2TQYO,59rOOQQ,5:i,5:iO2YQYO,59qOOQU-E8l-E8lO3|QYO'#FnOOQQ,5:b,5:bOOQQ,5:n,5:nOOQQ,5:l,5:lO4TQYO,5:rOOQQ,5;n,5;nO4_QYO,5:qO4lQWO,5:sO4qQYO,5:tOOQP'#Ee'#EeO5hQXO'#EdOOQO'#Ec'#EcO5oQWO'#EbO5tQWO'#GOO5|QWO,5:{O6RQYO,59ZOOQQ'#Cw'#CwO6YQYO'#F`OOQQ'#Cv'#CvO6bQYO,59_O6gQYO,5:cO6lQYO,5:mO4WQYO,5:qO6qQYO,5:pO`QYO'#EwQ-XQWOOO`QYO'#EmO7hQWO,5;{O`QYOOOOQR'#Cf'#CfOOQQ'#Ej'#EjO8bQYO,59OO`QYO,5;qOOQQ'#FY'#FYO%TQYO'#EkO8rQYO,5;pO`QYO1G.fOOQQ'#F]'#F]O9iQYO1G/TO<`QYO1G/]OhQYO1G/zO>oQYO1G/PO?xQYO1G/ROARQYO1G/TO`QYO1G/TOOQQ1G/T1G/TOAiQYO1G/^OBWQ^O'#CdOCjQYO'#FpOOQO'#Dz'#DzOCtQWO'#DyOCyQWO'#FoOOQO'#Dx'#DxOOQO'#D{'#D{ODRQWO,5fAN>fO/}QYO'#EoO!!]QYO<ZP?RP?UP?Y?z@lAdAjAm$tAsAsPPPPPBk8gCcDZD^EU!kjOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR![SQ!YSR$k#dW!WSw#d$^W#v!p!x$|%TT&Q%j&`#UXOPQWYilu|}!]!a!b!c!e!g!h!i!j!k#Y#[#^#b#f#q#s#}$O$X$]$`$o${%S%V%a%d%i%k%v%w%}&_&c&k&m&n&qb!VSw!x#d$^$|%T%j&`U#`!V#a#tR#t!pU#`!V#a#tT$V!z$WR$j#bR#TwQ#RwR%]$^U!RQ#^#qQ#r!kR$e#[QrQQ$g#^R$q#qQ$z#sQ%q%SQ&P%iU&U%k&c&qQ&f&_T&l&k&nc$s#s%S%i%k&_&c&k&n&q!jkOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wQ#l!eU$r#s%S&kS%y%d&m]&O%i%k&_&c&n&q#T[OPQWilu|}!]!a!b!c!e!g!h!i!j!k!p#Y#[#^#b#f#q#s#}$O$X$]$`$o${%S%V%a%d%i%k%v%w&_&c&k&m&n&qR&T%jQ&R%jR&g&`Q&X%kR&p&qS&V%k&qR&i&c!k]OPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR#{!pQ#x!pR%m$|S#w!p$|T$R!x%T!keOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!jeOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wQ!rbT!{o$Y!kcOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kdOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!khOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kpOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR$U!xQ$S!xR%r%TQ%u%VR&Y%vQ!}oR%Y$YT!|o$YS!zo$YT$V!z$WRrQS#a!V#tR$h#aQ#e!YR$l#eQ$_#RR%^$_Q#]!RR$f#]!tYOPQWilu|}!]!a!b!c!e!g!h!i!j!k!p#Y#[#^#b#f#q#s#}$O$X$]$`$o${%S%V%a%d%v%w&kS!oY%}_%}%i%k&_&c&m&n&qQ%e$rS%z%e&]R&]&OQ&a&RR&h&aQ&d&VR&j&dQ$}#xR%n$}S$P!v#uR%R$PQ%U$SR%s%UQ$W!zR%W$WQ$Z!}R%Z$ZQ#Z!PR$d#ZQrOQ!PPR$c#YUTOP#YW!QQ!k#[#^Q!nWQ!tiQ!vlQ#PuQ#W|Q#X}Q#h!]Q#i!aQ#j!bQ#k!cQ#m!gQ#n!hQ#o!iQ#p!jQ#u!pQ$i#bQ$m#fQ$p#qQ%P#}Q%Q$OQ%X$XQ%[$]Q%_$`Q%b$oQ%l${S%t%V%vQ%x%aR&Z%w!kqOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kSOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR!ZSS!XS#dT#Qw$^R#b!WR#f![!kuOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kwOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR#SwV!SQ#^#q!V!aT!Q!t!v#P#W#X#h#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!X!bT!Q!t!v#P#W#X#h#i#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!Z!cT!Q!t!v#P#W#X#h#i#j#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!kWOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR&S%jT&W%k&q!_!eT!Q!n!t!v#P#W#X#h#i#j#k#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!_!gT!Q!n!t!v#P#W#X#h#i#j#k#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!k^OPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wQ!q^R!scR#y!pQ!wlR#z!p!kfOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!klOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kmOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR$T!x!koOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR#Oo",nodeNames:"\u26A0 LineComment BlockComment Expression ForExpression for InExpressions InExpression Name Identifier Identifier ArithOp ArithOp ArithOp ArithOp ArithOp in IterationContext return IfExpression if then else QuantifiedExpression some every InExpressions InExpression satisfies Disjunction or Conjunction and Comparison CompareOp CompareOp between PositiveUnaryTest ( PositiveUnaryTests ) ArithmeticExpression InstanceOfExpression instance of Type QualifiedName VariableName BacktickIdentifier SpecialType days time duration years months date > ListType list < ContextType context ContextEntryTypes ContextEntryType FunctionType function ArgumentTypes ArgumentType PathExpression ] FilterExpression [ FunctionInvocation SpecialFunctionName NamedParameters NamedParameter ParameterName PositionalParameters null NumericLiteral StringLiteral BooleanLiteral DateTimeLiteral DateTimeConstructor AtLiteral ? SimplePositiveUnaryTest Interval ParenthesizedExpression List FunctionDefinition FormalParameters FormalParameter external FunctionBody } { Context ContextEntry Key Name Identifier Expressions UnaryTests Wildcard not",maxTerm:173,context:bT,nodeProps:[["group",-17,4,19,23,29,31,33,41,42,68,70,72,85,86,88,89,90,97,"Expr",47,"Expr Expr",-5,78,79,80,81,82,"Expr Literal"],["closedBy",38,")",71,"]",96,"}"],["openedBy",40,"(",69,"[",95,"{"]],propSources:[kT],skippedNodes:[0,1,2],repeatNodeCount:14,tokenData:".v~RvXY#iYZ$^Z[#i]^$^pq#iqr$crs$nwx(Wxy(]yz(bz{(g{|(t|}(y}!O)O!O!P)]!P!Q*g!Q![,b![!],y!]!^-O!^!_-T!_!`$i!`!a-d!b!c-n!}#O-s#P#Q-x#Q#R(o#S#T-}#o#p.l#q#r.q$f$g#i#BY#BZ#i$IS$I_#i$I|$I}$^$I}$JO$^$JT$JU#i$KV$KW#i&FU&FV#i?HT?HU#i~#nY#r~XY#iZ[#ipq#i$f$g#i#BY#BZ#i$IS$I_#i$JT$JU#i$KV$KW#i&FU&FV#i?HT?HU#i~$cO#s~~$fP!_!`$i~$nOr~~$qXOY$nYZ%^Zr$nrs&zs#O$n#O#P'R#P;'S$n;'S;=`(Q<%lO$n~%aVOr%^rs%vs#O%^#O#P%{#P;'S%^;'S;=`&t<%lO%^~%{O$i~~&ORO;'S%^;'S;=`&X;=`O%^~&[WOr%^rs%vs#O%^#O#P%{#P;'S%^;'S;=`&t;=`<%l%^<%lO%^~&wP;=`<%l%^~'RO$i~$j~~'URO;'S$n;'S;=`'_;=`O$n~'bYOY$nYZ%^Zr$nrs&zs#O$n#O#P'R#P;'S$n;'S;=`(Q;=`<%l$n<%lO$n~(TP;=`<%l$n~(]O#{~~(bOv~~(gOx~~(lP^~z{(o~(tO_~~(yO[~~)OO$O~R)TPZP!`!a)WQ)]O$^Q~)bQ#z~!O!P)h!Q![)m~)mO#}~~)rR$h~!Q![)m!g!h){#X#Y){~*OR{|*X}!O*X!Q![*_~*[P!Q![*_~*dP$h~!Q![*_~*lQ]~z{*r!P!Q+y~*uTOz*rz{+U{;'S*r;'S;=`+s<%lO*r~+XVOz*rz{+U{!P*r!P!Q+n!Q;'S*r;'S;=`+s<%lO*r~+sOQ~~+vP;=`<%l*r~,OSP~OY+yZ;'S+y;'S;=`,[<%lO+y~,_P;=`<%l+y~,gS$h~!O!P,s!Q![,b!g!h){#X#Y){~,vP!Q![)m~-OO$[~~-TO$s~R-[P!]QsP!_!`-_P-dOsPR-kP!YQsP!_!`-_~-sO$l~~-xO!i~~-}O!g~~.QTO#S-}#S#T.a#T;'S-};'S;=`.f<%lO-}~.fO$Y~~.iP;=`<%l-}~.qO#S~~.vO#R~",tokenizers:[dT,hT,pT,0,1],topRules:{Expression:[0,3],Expressions:[1,102],UnaryTests:[2,103]},dialects:{camunda:2564},dynamicPrecedences:{31:-1,68:1,72:-1,74:-1},specialized:[{term:122,get:n=>CT[n]||-1}],tokenPrec:2567});function ST(n){let e=[];return n.iterate({enter:t=>{let i=t.node;if(!i.type.isError)return;let r=i.parent,s=Zx(i),o={from:i.from,to:i.to,severity:"error",type:"Syntax Error"};if(i.from!==i.to)o.message=`Unrecognized token in <${r.name}>`;else if(s)o.message=`Unrecognized token <${s.name}> in <${r.name}>`,o.to=s.to;else{let a=r.enterUnfinishedNodesBefore(i.to);o.message=`Incomplete <${(a||r).name}>`}e.push(o)}}),e}function Zx(n){return n?n.nextSibling||Zx(n.parent):null}var ET="first-item",AT={create(n){return{enter(e){if(e.name!=="FilterExpression")return;let t=n.readContent(e.from,e.to);if(Jx().test(t)){let{from:i,to:r}=e;n.report({from:i,to:r,message:"First item is accessed via [1]",severity:"warning",type:ET,actions:[{name:"fix",apply(s,o=i,a=r){n.updateContent(o,a,t.replace(Jx(),"[1]"))}}]})}}}}};function Jx(){return/\[\s*0\s*\]$/}var _T=[AT];function TT(n){let{readContent:e,syntaxTree:t,updateContent:i}=n,r=[],s={readContent:e,report:a=>{r.push(a)},updateContent:i},o=_T.map(a=>a.create(s));return t.iterate({enter:a=>{for(let l of o)l.enter&&l.enter(a)},leave:a=>{for(let l of o)l.leave&&l.leave(a)}}),r}function MT(n){return[...ST(n.syntaxTree),...TT(n)]}var eb=()=>n=>{if(n.state.doc.length===0)return[];let e=ge(n.state);return MT({syntaxTree:e,readContent:(i,r)=>n.state.sliceDoc(i,r),updateContent:(i,r,s)=>n.dispatch({changes:{from:i,to:r,insert:s}})}).map(i=>({...i,source:i.type}))};var Md=[Bt("function(${params}) ${body}",{label:"function",detail:"definition",type:"keyword"}),Bt("for ${var} in ${collection} return ${value}",{label:"for",detail:"expression",type:"keyword"}),Bt("every ${var} in ${collection} satisfies ${condition}",{label:"every",detail:"quantified expression",type:"keyword"}),Bt("some ${var} in ${collection} satisfies ${condition}",{label:"some",detail:"quantified expression",type:"keyword"}),Bt("if ${condition} then ${value} else ${other value}",{label:"if",detail:"block",type:"keyword"}),Bt("{ ${key}: ${value} }",{label:"context",detail:"block",type:"keyword"}),Bt("null",{label:"null",detail:"literal",type:"keyword"}),Bt("true",{label:"true",detail:"literal",type:"keyword"}),Bt("false",{label:"false",detail:"literal",type:"keyword"})];function Td(){return Td=Object.assign?Object.assign.bind():function(n){for(var e=1;e{let{state:i,pos:r}=t,s=rb(ge(i).resolveInner(r,-1),e);if(s){let[o,a]=s;if(tb.includes(a))return null}return n(t)}}function DT(n){return PT(ys(n.map(e=>Td({},e,{type:"text"}))))}function nb(n,e,t){return ib(n,e,t,-1)}function BT(n,e,t){return ib(n,e,t,1)}function ib(n,e,t,i){let r=n[i>0?"childAfter":"childBefore"](e);for(;r;){if(t.includes(r.name))return r;if(r.type.isError&&r.firstChild&&t.includes(r.firstChild.name))return r.firstChild;r=r[i>0?"nextSibling":"prevSibling"]}return null}function rb(n,e){for(Array.isArray(e)||(e=[e]);n;n=n.parent){let t=n.type,i=e.find(r=>r&&t.is(r));if(i)return[n,i];if(t.isTop)break}return null}function IT(n,e){let{nodes:t,before:i,after:r,keyword:s}=n;return o=>{let{state:a,pos:l}=o,c=rb(ge(a).resolveInner(l,-1),t);if(!c)return null;let[u]=c;return nb(u,l,[s,i])||BT(u,l,[s,r])||r&&!nb(u,l,[r])?null:e(o)}}var sb=Zl.define({parser:Gx.configure({props:[Lh.add({Context:$h({closing:"}"}),"List FilterExpression":$h({closing:"]"}),"ParenthesizedExpression FunctionInvocation":nc({except:/^\s*\)/}),"ForExpression QuantifiedExpression IfExpression":nc({except:/^\s*(then|else|return|satisfies)\b/}),FunctionDefinition:nc({except:/^\s*(\(|\))/})}),hv.add({Context:ic,List:ic,ParenthesizedExpression:ic,FunctionDefinition(n){let e=n.getChild(")");return e?{from:e.to,to:n.to}:null}})]}),languageData:{indentOnInput:/^\s*(\)|\}|\]|then|else|return|satisfies)$/,commentTokens:{line:"//",block:{open:"/*",close:"*/"}}}}),LT=sb.configure({top:"UnaryTests"},"FEEL unary tests"),$T=sb.configure({top:"Expression"},"FEEL expression");function ob(n={}){let e=n.dialect==="unaryTests"?LT:$T,t=n.parserDialect,i=_d(n.context),r=e.configure({contextTracker:i,dialect:t}),s=n.completions||[DT(Md),Rd].flat();return new ec(r,[...s.map(o=>r.data.of({autocomplete:o}))])}var NT=[{name:"not",type:"function",params:[{name:"negand"}],info:`

Returns the logical negation of the given value.

Function signature

not(negand: boolean): boolean

Examples

not(true)
// false

not(null)
// null
`},{name:"get value",type:"function",params:[{name:"context"},{name:"key"}],info:`

Returns the value of the context entry with the given key.

Function signature

get value(context: context, key: string): Any

Examples

get value({foo: 123}, "foo")
// 123

get value({a: 1}, "b")
// null
`},{name:"get entries",type:"function",params:[{name:"context"}],info:`

Returns the entries of the context as a list of key-value-pairs.

Function signature

get entries(context: context): list<context>

The return value is a list of contexts. Each context contains two entries for "key" and "value".

Examples

get entries({foo: 123})
// [{key: "foo", value: 123}]
`},{name:"context put",type:"function",params:[{name:"context"},{name:"keys"},{name:"value"}],info:`

Adds a new entry with the given value to the context. The path of the entry is defined by the keys. Returns a new context that includes the entry.

If keys contains the keys [k1, k2] then it adds the nested entry k1.k2 = value to the context.

If an entry for the same keys already exists in the context, it overrides the value.

If keys are empty, it returns null.

Function signature

context put(context: context, keys: list<string>, value: Any): context

Examples

context put({x:1}, ["y"], 2)
// {x:1, y:2}

context put({x:1, y: {z:0}}, ["y", "z"], 2)
// {x:1, y: {z:2}}

context put({x:1}, ["y", "z"], 2)
// {x:1, y: {z:2}}
`},{name:"string",type:"function",params:[{name:"from"}],info:`

Returns the given value as a string representation.

Function signature

string(from: Any): string

Examples

string(1.1)
// "1.1"

string(date("2012-12-25"))
// "2012-12-25"
`},{name:"number",type:"function",params:[{name:"from"}],info:`

Parses the given string to a number.

Returns null if the string is not a number.

Function signature

number(from: string): number

Examples

number("1500.5")
// 1500.5
`},{name:"number",type:"function",params:[{name:"from"},{name:"grouping separator"}],info:`

Parses the given string to a number using the specified grouping separator.

Returns null if the string is not a number.

Function signature

number(from: string, grouping separator: string): number

Examples

number("1,500", ",")
// 1500
`},{name:"number",type:"function",params:[{name:"from"},{name:"grouping separator"},{name:"decimal separator"}],info:`

Parses the given string to a number using the specified grouping and decimal separators.

Returns null if the string is not a number.

Function signature

number(from: string, grouping separator: string, decimal separator: string): number

Examples

number("1 500.5", " ", ".")
// 1500.5
`},{name:"context",type:"function",params:[{name:"entries"}],info:`

Constructs a context of the given list of key-value pairs. It is the reverse function to get entries().

Each key-value pair must be a context with two entries: key and value. The entry with name key must have a value of the type string.

It might override context entries if the keys are equal. The entries are overridden in the same order as the contexts in the given list.

Returns null if one of the entries is not a context or if a context doesn't contain the required entries.

Function signature

context(entries: list<context>): context

Examples

context([{"key":"a", "value":1}, {"key":"b", "value":2}])
// {a:1, b:2}
`},{name:"date",type:"function",params:[{name:"from"}],info:`

Returns a date from the given value.

Returns null if the string is not a valid calendar date. For example, "2024-06-31" is invalid because June has only 30 days.

Function signature

date(from: string): date

Parses the given string into a date.

date(from: date and time): date

Extracts the date component from the given date and time.

Examples

date("2018-04-29")
// date("2018-04-29")

date(date and time("2012-12-25T11:00:00"))
// date("2012-12-25")
`},{name:"date",type:"function",params:[{name:"year"},{name:"month"},{name:"day"}],info:`

Returns a date from the given components.

Returns null if the components don't represent a valid calendar date. For example, 2024,6,31 is invalid because June has only 30 days.

Function signature

date(year: number, month: number, day: number): date

Examples

date(2012, 12, 25)
// date("2012-12-25")
`},{name:"time",type:"function",params:[{name:"from"}],info:`

Returns a time from the given value.

Function signature

time(from: string): time

Parses the given string into a time.

time(from: date and time): time

Extracts the time component from the given date and time.

Examples

time("12:00:00")
// time("12:00:00")

time(date and time("2012-12-25T11:00:00"))
// time("11:00:00")
`},{name:"time",type:"function",params:[{name:"hour"},{name:"minute"},{name:"second"}],info:`

Returns a time from the given components.

Function signature

time(hour: number, minute: number, second: number): time

Examples

time(23, 59, 0)
// time("23:59:00")
`},{name:"time",type:"function",params:[{name:"hour"},{name:"minute"},{name:"second"},{name:"offset"}],info:`

Returns a time from the given components, including a timezone offset.

Function signature

time(hour: number, minute: number, second: number, offset: days and time duration): time

Examples

time(14, 30, 0, duration("PT1H"))
// time("14:30:00+01:00")
`},{name:"date and time",type:"function",params:[{name:"from"}],info:`

Parses the given string into a date and time. The function supports strings in the format YYYY-MM-DDThh:mm:ss with optional timezone information either as offset (e.g., +01:00 or Z), as IANA timezone ID (e.g., @Europe/Berlin), or as a combination of both (e.g., +01:00[Europe/Berlin]).

Returns null if the string is not a valid calendar date. For example, "2024-06-31T10:00:00" is invalid because June has only 30 days.

Function signature

date and time(from: string): date and time

Examples

date and time("2018-04-29T09:30:00")
// date and time("2018-04-29T09:30:00")

date and time("2018-04-29T09:30:00+02:00")
// date and time("2018-04-29T09:30:00+02:00")

date and time("2018-04-29T09:30:00@Europe/Berlin")
// date and time("2018-04-29T09:30:00@Europe/Berlin")

date and time("2018-04-29T09:30:00+02:00[Europe/Berlin]")
// date and time("2018-04-29T09:30:00@Europe/Berlin")
`},{name:"date and time",type:"function",params:[{name:"date"},{name:"time"}],info:`

Returns a date and time from the given components.

Function signature

date and time(date: date, time: time): date and time
date and time(date: date and time, time: time): date and time

Returns a date and time value that consists of the date component of date combined with time.

Examples

date and time(date("2012-12-24"),time("T23:59:00"))
// date and time("2012-12-24T23:59:00")

date and time(date and time("2012-12-25T11:00:00"),time("T23:59:00"))
// date and time("2012-12-25T23:59:00")
`},{name:"duration",type:"function",params:[{name:"from"}],info:`

Parses the given string into a duration. The duration is either a days and time duration or a years and months duration.

Function signature

duration(from: string): days and time duration
duration(from: string): years and months duration

Examples

duration("P5D")
// duration("P5D")

duration("P32Y")
// duration("P32Y")
`},{name:"years and months duration",type:"function",params:[{name:"from"},{name:"to"}],info:`

Returns the years and months duration between from and to.

Function signature

years and months duration(from: date, to: date): years and months duration

Examples

years and months duration(date("2011-12-22"), date("2013-08-24"))
// duration("P1Y8M")
`},{name:"from json",type:"function",params:[{name:"value"}],info:`

Parses a JSON string into a FEEL value. The function converts JSON primitives, objects, and arrays into their corresponding FEEL types.

Returns null if the string is not a valid JSON value.

Function signature

from json(value: string): Any

Examples

from json("{\\"a\\": 1, \\"b\\": 2}")
// {a: 1, b: 2}

from json("true")
// true

from json("\\"2023-06-14\\"")
// "2023-06-14"
`,engines:{camunda:">=8.9"}},{name:"to json",type:"function",params:[{name:"value"}],info:`

Converts a FEEL value into a JSON string. The function converts FEEL primitives, contexts, and lists into their corresponding JSON types. Temporal values are converted to their ISO 8601 string representation, including timezone information for date and time values (format: 2025-11-24T10:00:00+01:00[Europe/Berlin]).

Function signature

to json(value: Any): string

Examples

to json({a: 1, b: 2})
// "{\\"a\\":1,\\"b\\":2}"

to json(true)
// "true"

to json(@"2023-06-14")
// "\\"2023-06-14\\""

to json(@"2025-11-24T10:00:00@Europe/Berlin")
// "\\"2025-11-24T10:00:00+01:00[Europe/Berlin]\\""

to json(@"P3Y")
// "\\"P3Y\\""
`,engines:{camunda:">=8.9"}},{name:"list contains",type:"function",params:[{name:"list"},{name:"element"}],info:`

Returns true if the given list contains the element. Otherwise, returns false.

Function signature

list contains(list: list, element: Any): boolean

Examples

list contains([1,2,3], 2)
// true
`},{name:"count",type:"function",params:[{name:"list"}],info:`

Returns the number of elements of the given list.

Function signature

count(list: list): number

Examples

count([1,2,3])
// 3
`},{name:"min",type:"function",params:[{name:"list"}],info:`

Returns the minimum of the given list.

Function signature

min(list: list): Any

All elements in list should have the same type and be comparable.

The parameter list can be passed as a list or as a sequence of elements.

Examples

min([1,2,3])
// 1

min(1,2,3)
// 1
`},{name:"max",type:"function",params:[{name:"list"}],info:`

Returns the maximum of the given list.

Function signature

max(list: list): Any

All elements in list should have the same type and be comparable.

The parameter list can be passed as a list or as a sequence of elements.

Examples

max([1,2,3])
// 3

max(1,2,3)
// 3
`},{name:"sum",type:"function",params:[{name:"list"}],info:`

Returns the sum of the given list of numbers.

Function signature

sum(list: list<number>): number

The parameter list can be passed as a list or as a sequence of elements.

Examples

sum([1,2,3])
// 6

sum(1,2,3)
// 6
`},{name:"product",type:"function",params:[{name:"list"}],info:`

Returns the product of the given list of numbers.

Function signature

product(list: list<number>): number

The parameter list can be passed as a list or as a sequence of elements.

Examples

product([2, 3, 4])
// 24

product(2, 3, 4)
// 24
`},{name:"mean",type:"function",params:[{name:"list"}],info:`

Returns the arithmetic mean (i.e. average) of the given list of numbers.

Function signature

mean(list: list<number>): number

The parameter list can be passed as a list or as a sequence of elements.

Examples

mean([1,2,3])
// 2

mean(1,2,3)
// 2
`},{name:"median",type:"function",params:[{name:"list"}],info:`

Returns the median element of the given list of numbers.

Function signature

median(list: list<number>): number

The parameter list can be passed as a list or as a sequence of elements.

Examples

median(8, 2, 5, 3, 4)
// 4

median([6, 1, 2, 3])
// 2.5
`},{name:"stddev",type:"function",params:[{name:"list"}],info:`

Returns the standard deviation of the given list of numbers.

Function signature

stddev(list: list<number>): number

The parameter list can be passed as a list or as a sequence of elements.

Examples

stddev(2, 4, 7, 5)
// 2.0816659994661326

stddev([2, 4, 7, 5])
// 2.0816659994661326
`},{name:"mode",type:"function",params:[{name:"list"}],info:`

Returns the mode of the given list of numbers.

Function signature

mode(list: list<number>): number

The parameter list can be passed as a list or as a sequence of elements.

Examples

mode(6, 3, 9, 6, 6)
// [6]

mode([6, 1, 9, 6, 1])
// [1, 6]
`},{name:"all",type:"function",params:[{name:"list"}],info:`

Returns false if any element of the given list is false. Otherwise, returns true.

If the given list is empty, it returns true.

Function signature

all(list: list<boolean>): boolean

The parameter list can be passed as a list or as a sequence of elements.

Examples

all([true,false])
// false

all(false,null,true)
// false

:::info The function all() replaced the previous function and(). The previous function is deprecated and should not be used anymore. :::

`},{name:"any",type:"function",params:[{name:"list"}],info:`

Returns true if any element of the given list is true. Otherwise, returns false.

If the given list is empty, it returns false.

Function signature

any(list: list<boolean>): boolean

The parameter list can be passed as a list or as a sequence of elements.

Examples

any([false,true])
// true

any(false,null,true)
// true

:::info The function any() replaced the previous function or(). The previous function is deprecated and should not be used anymore. :::

`},{name:"sublist",type:"function",params:[{name:"list"},{name:"start position"}],info:`

Returns a partial list of the given value starting at start position.

Function signature

sublist(list: list, start position: number): list

The start position starts at the index 1. The last position is -1.

Examples

sublist([1,2,3], 2)
// [2,3]
`},{name:"sublist",type:"function",params:[{name:"list"},{name:"start position"},{name:"length"}],info:`

Returns a partial list of the given value starting at start position.

Function signature

sublist(list: list, start position: number, length: number): list

The start position starts at the index 1. The last position is -1.

Examples

sublist([1,2,3], 1, 2)
// [1,2]
`},{name:"append",type:"function",params:[{name:"list"},{name:"items"}],info:`

Returns the given list with all items appended.

Function signature

append(list: list, items: Any): list

The parameter items can be a single element or a sequence of elements.

Examples

append([1], 2, 3)
// [1,2,3]
`},{name:"concatenate",type:"function",params:[{name:"lists"}],info:`

Returns a list that includes all elements of the given lists.

Function signature

concatenate(lists: list): list

The parameter lists is a sequence of lists.

Examples

concatenate([1,2],[3])
// [1,2,3]

concatenate([1],[2],[3])
// [1,2,3]
`},{name:"insert before",type:"function",params:[{name:"list"},{name:"position"},{name:"newItem"}],info:`

Returns the given list with newItem inserted at position.

Function signature

insert before(list: list, position: number, newItem: Any): list

The position starts at the index 1. The last position is -1.

Examples

insert before([1,3],1,2)
// [2,1,3]
`},{name:"remove",type:"function",params:[{name:"list"},{name:"position"}],info:`

Returns the given list without the element at position.

Function signature

remove(list: list, position: number): list

The position starts at the index 1. The last position is -1.

Examples

remove([1,2,3], 2)
// [1,3]
`},{name:"reverse",type:"function",params:[{name:"list"}],info:`

Returns the given list in revered order.

Function signature

reverse(list: list): list

Examples

reverse([1,2,3])
// [3,2,1]
`},{name:"index of",type:"function",params:[{name:"list"},{name:"match"}],info:`

Returns an ascending list of positions containing match.

Function signature

index of(list: list, match: Any): list<number>

Examples

index of([1,2,3,2],2)
// [2,4]
`},{name:"union",type:"function",params:[{name:"list"}],info:`

Returns a list that includes all elements of the given lists without duplicates.

Function signature

union(list: list): list

The parameter list is a sequence of lists.

Examples

union([1,2],[2,3])
// [1,2,3]
`},{name:"distinct values",type:"function",params:[{name:"list"}],info:`

Returns the given list without duplicates.

Function signature

distinct values(list: list): list

Examples

distinct values([1,2,3,2,1])
// [1,2,3]
`},{name:"flatten",type:"function",params:[{name:"list"}],info:`

Returns a list that includes all elements of the given list without nested lists.

Function signature

flatten(list: list): list

Examples

flatten([[1,2],[[3]], 4])
// [1,2,3,4]
`},{name:"sort",type:"function",params:[{name:"list"},{name:"precedes"}],info:`

Returns the given list sorted by the precedes function.

Function signature

sort(list: list, precedes: function<(Any, Any) -> boolean>): list

Examples

sort(list: [3,1,4,5,2], precedes: function(x,y) x < y)
// [1,2,3,4,5]
`},{name:"string join",type:"function",params:[{name:"list"}],info:`

Joins a list of strings into a single string. This is similar to Java's joining function.

If an item of the list is null, the item is ignored for the result string. If an item is neither a string nor null, the function returns null instead of a string.

Function signature

string join(list: list<string>): string

Examples

string join(["a","b","c"])
// "abc"

string join(["a",null,"c"])
// "ac"

string join([])
// ""
`},{name:"string join",type:"function",params:[{name:"list"},{name:"delimiter"}],info:`

Joins a list of strings into a single string. This is similar to Java's joining function.

If an item of the list is null, the item is ignored for the result string. If an item is neither a string nor null, the function returns null instead of a string.

The resulting string contains a delimiter between each element.

Function signature

string join(list: list<string>, delimiter: string): string

Examples

string join(["a"], "X")
// "a"

string join(["a","b","c"], ", ")
// "a, b, c"
`},{name:"decimal",type:"function",params:[{name:"n"},{name:"scale"}],info:`

Rounds the given value at the given scale.

Function signature

decimal(n: number, scale: number): number

Examples

decimal(1/3, 2)
// .33

decimal(1.5, 0)
// 2
`},{name:"floor",type:"function",params:[{name:"n"}],info:`

Rounds the given value with rounding mode flooring.

Function signature

floor(n: number): number

Examples

floor(1.5)
// 1

floor(-1.5)
// -2
`},{name:"floor",type:"function",params:[{name:"n"},{name:"scale"}],info:`

Rounds the given value with rounding mode flooring at the given scale.

Function signature

floor(n: number, scale: number): number

Examples

floor(-1.56, 1)
// -1.6
`},{name:"ceiling",type:"function",params:[{name:"n"}],info:`

Rounds the given value with rounding mode ceiling.

Function signature

ceiling(n: number): number

Examples

ceiling(1.5)
// 2

ceiling(-1.5)
// -1
`},{name:"ceiling",type:"function",params:[{name:"n"},{name:"scale"}],info:`

Rounds the given value with rounding mode ceiling at the given scale.

Function signature

ceiling(n: number, scale: number): number

Examples

ceiling(-1.56, 1)
// -1.5
`},{name:"round up",type:"function",params:[{name:"n"},{name:"scale"}],info:`

Rounds the given value with the rounding mode round-up at the given scale.

Function signature

round up(n: number, scale: number): number

Examples

round up(5.5)
// 6

round up(-5.5)
// -6

round up(1.121, 2)
// 1.13

round up(-1.126, 2)
// -1.13
`},{name:"round down",type:"function",params:[{name:"n"},{name:"scale"}],info:`

Rounds the given value with the rounding mode round-down at the given scale.

Function signature

round down(n: number, scale: number): number

Examples

round down(5.5, 0)
// 5

round down (-5.5, 0)
// -5

round down (1.121, 2)
// 1.12

round down (-1.126, 2)
// -1.12
`},{name:"round half up",type:"function",params:[{name:"n"},{name:"scale"}],info:`

Rounds the given value with the rounding mode round-half-up at the given scale.

Function signature

round half up(n: number, scale: number): number

Examples

round half up(5.5, 0)
// 6

round half up(-5.5, 0)
// -6

round half up(1.121, 2)
// 1.12

round half up(-1.126, 2)
// -1.13
`},{name:"round half down",type:"function",params:[{name:"n"},{name:"scale"}],info:`

Rounds the given value with the rounding mode round-half-down at the given scale.

Function signature

round half down(n: number, scale: number): number

Examples

round half down (5.5, 0)
// 5

round half down (-5.5, 0)
// -5

round half down (1.121, 2)
// 1.12

round half down (-1.126, 2)
// -1.13
`},{name:"abs",type:"function",params:[{name:"number"}],info:`

Returns the absolute value of the given numeric value.

Function signature

abs(number: number): number

Examples

abs(10)
// 10

abs(-10)
// 10
`},{name:"modulo",type:"function",params:[{name:"dividend"},{name:"divisor"}],info:`

Returns the remainder of the division of dividend by divisor.

Function signature

modulo(dividend: number, divisor: number): number

Examples

modulo(12, 5)
// 2
`},{name:"sqrt",type:"function",params:[{name:"number"}],info:`

Returns the square root of the given value.

Function signature

sqrt(number: number): number

Examples

sqrt(16)
// 4
`},{name:"log",type:"function",params:[{name:"number"}],info:`

Returns the natural logarithm (base e) of the given value.

Function signature

log(number: number): number

Examples

log(10)
// 2.302585092994046
`},{name:"exp",type:"function",params:[{name:"number"}],info:`

Returns the Euler\u2019s number e raised to the power of the given number .

Function signature

exp(number: number): number

Examples

exp(5)
// 148.4131591025766
`},{name:"odd",type:"function",params:[{name:"number"}],info:`

Returns true if the given value is odd. Otherwise, returns false.

Function signature

odd(number: number): boolean

Examples

odd(5)
// true

odd(2)
// false
`},{name:"even",type:"function",params:[{name:"number"}],info:`

Returns true if the given is even. Otherwise, returns false.

Function signature

even(number: number): boolean

Examples

even(5)
// false

even(2)
// true
`},{name:"before",type:"function",params:[{name:"point1"},{name:"point2"}],info:`

Function signature

before(point1: Any, point2: Any): boolean

Examples

before(1, 10)
// true

before(10, 1)
// false
`},{name:"before",type:"function",params:[{name:"range"},{name:"point"}],info:`

Function signature

before(range: range, point: Any): boolean

Examples

before([1..5], 10)
// true
`},{name:"before",type:"function",params:[{name:"point"},{name:"range"}],info:`

Function signature

before(point: Any, range: range): boolean

Examples

before(1, [2..5])
// true
`},{name:"before",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

before(range1: range, range2: range): boolean

Examples

before([1..5], [6..10])
// true

before([1..5),[5..10])
// true
`},{name:"after",type:"function",params:[{name:"point1"},{name:"point2"}],info:`

Function signature

after(point1: Any, point2: Any): boolean

Examples

after(10, 1)
// true

after(1, 10)
// false
`},{name:"after",type:"function",params:[{name:"range"},{name:"point"}],info:`

Function signature

after(range: range, point: Any): boolean

Examples

after([1..5], 10)
// false
`},{name:"after",type:"function",params:[{name:"point"},{name:"range"}],info:`

Function signature

after(point: Any, range: range): boolean

Examples

after(12, [2..5])
// true
`},{name:"after",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

after(range1: range, range2: range): boolean

Examples

after([6..10], [1..5])
// true

after([5..10], [1..5))
// true
`},{name:"meets",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

meets(range1: range, range2: range): boolean

Examples

meets([1..5], [5..10])
// true

meets([1..3], [4..6])
// false

meets([1..3], [3..5])
// true

meets([1..5], (5..8])
// false
`},{name:"met by",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

met by(range1: range, range2: range): boolean

Examples

met by([5..10], [1..5])
// true

met by([3..4], [1..2])
// false

met by([3..5], [1..3])
// true

met by((5..8], [1..5))
// false

met by([5..10], [1..5))
// false
`},{name:"overlaps",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

overlaps(range1: range, range2: range): boolean

Examples

overlaps([5..10], [1..6])
// true

overlaps((3..7], [1..4])
// true

overlaps([1..3], (3..6])
// false

overlaps((5..8], [1..5))
// false

overlaps([4..10], [1..5))
// true
`},{name:"overlaps before",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

overlaps before(range1: range, range2: range): boolean

Examples

overlaps before([1..5], [4..10])
// true

overlaps before([3..4], [1..2])
// false

overlaps before([1..3], (3..5])
// false

overlaps before([1..5), (3..8])
// true

overlaps before([1..5), [5..10])
// false
`},{name:"overlaps after",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

overlaps after(range1: range, range2: range): boolean

Examples

overlaps after([4..10], [1..5])
// true

overlaps after([3..4], [1..2])
// false

overlaps after([3..5], [1..3))
// false

overlaps after((5..8], [1..5))
// false

overlaps after([4..10], [1..5))
// true
`},{name:"finishes",type:"function",params:[{name:"point"},{name:"range"}],info:`

Function signature

finishes(point: Any, range: range): boolean

Examples

finishes(5, [1..5])
// true

finishes(10, [1..7])
// false
`},{name:"finishes",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

finishes(range1: range, range2: range): boolean

Examples

finishes([3..5], [1..5])
// true

finishes((1..5], [1..5))
// false

finishes([5..10], [1..10))
// false
`},{name:"finished by",type:"function",params:[{name:"range"},{name:"point"}],info:`

Function signature

finished by(range: range, point: Any): boolean

Examples

finished by([5..10], 10)
// true

finished by([3..4], 2)
// false
`},{name:"finished by",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

finished by(range1: range, range2: range): boolean

Examples

finished by([1..5], [3..5])
// true

finished by((5..8], [1..5))
// false

finished by([5..10], (1..10))
// false
`},{name:"includes",type:"function",params:[{name:"range"},{name:"point"}],info:`

Function signature

includes(range: range, point: Any): boolean

Examples

includes([5..10], 6)
// true

includes([3..4], 5)
// false
`},{name:"includes",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

includes(range1: range, range2: range): boolean

Examples

includes([1..10], [4..6])
// true

includes((5..8], [1..5))
// false

includes([1..10], [1..5))
// true
`},{name:"during",type:"function",params:[{name:"point"},{name:"range"}],info:`

Function signature

during(point: Any, range: range): boolean

Examples

during(5, [1..10])
// true

during(12, [1..10])
// false

during(1, (1..10])
// false
`},{name:"during",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

during(range1: range, range2: range): boolean

Examples

during([4..6], [1..10))
// true

during((1..5], (1..10])
// true
`},{name:"starts",type:"function",params:[{name:"point"},{name:"range"}],info:`

Function signature

starts(point: Any, range: range): boolean

Examples

starts(1, [1..5])
// true

starts(1, (1..8])
// false
`},{name:"starts",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

starts(range1: range, range2: range): boolean

Examples

starts((1..5], [1..5])
// false

starts([1..10], [1..5])
// false

starts((1..5), (1..10))
// true
`},{name:"started by",type:"function",params:[{name:"range"},{name:"point"}],info:`

Function signature

started by(range: range, point: Any): boolean

Examples

started by([1..10], 1)
// true

started by((1..10], 1)
// false
`},{name:"started by",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

started by(range1: range, range2: range): boolean

Examples

started by([1..10], [1..5])
// true

started by((1..10], [1..5))
// false

started by([1..10], [1..10))
// true
`},{name:"coincides",type:"function",params:[{name:"point1"},{name:"point2"}],info:`

Function signature

coincides(point1: Any, point2: Any): boolean

Examples

coincides(5, 5)
// true

coincides(3, 4)
// false
`},{name:"coincides",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

Function signature

coincides(range1: range, range2: range): boolean

Examples

coincides([1..5], [1..5])
// true

coincides((1..5], [1..5))
// false

coincides([1..5], [2..6])
// false
`},{name:"substring",type:"function",params:[{name:"string"},{name:"start position"}],info:`

Returns a substring of the given value starting at start position.

Function signature

substring(string: string, start position: number): string

The start position starts at the index 1. The last position is -1.

Examples

substring("foobar", 3)
// "obar"

substring("foobar", -2)
// "ar"
`},{name:"substring",type:"function",params:[{name:"string"},{name:"start position"},{name:"length"}],info:`

Returns a substring of the given value, starting at start position with the given length. If length is greater than the remaining characters of the value, it returns all characters from start position until the end.

Function signature

substring(string: string, start position: number, length: number): string

The start position starts at the index 1. The last position is -1.

Examples

substring("foobar", 3, 3)
// "oba"

substring("foobar", -3, 2)
// "ba"

substring("foobar", 3, 10)
// "obar"
`},{name:"string length",type:"function",params:[{name:"string"}],info:`

Returns the number of characters in the given value.

Function signature

string length(string: string): number

Examples

string length("foo")
// 3
`},{name:"upper case",type:"function",params:[{name:"string"}],info:`

Returns the given value with all characters are uppercase.

Function signature

upper case(string: string): string

Examples

upper case("aBc4")
// "ABC4"
`},{name:"lower case",type:"function",params:[{name:"string"}],info:`

Returns the given value with all characters are lowercase.

Function signature

lower case(string: string): string

Examples

lower case("aBc4")
// "abc4"
`},{name:"substring before",type:"function",params:[{name:"string"},{name:"match"}],info:`

Returns a substring of the given value that contains all characters before match.

Function signature

substring before(string: string, match: string): string

Examples

substring before("foobar", "bar")
// "foo"
`},{name:"substring after",type:"function",params:[{name:"string"},{name:"match"}],info:`

Returns a substring of the given value that contains all characters after match.

Function signature

substring after(string: string, match: string): string

Examples

substring after("foobar", "ob")
// "ar"
`},{name:"contains",type:"function",params:[{name:"string"},{name:"match"}],info:`

Returns true if the given value contains the substring match. Otherwise, returns false.

Function signature

contains(string: string, match: string): boolean

Examples

contains("foobar", "of")
// false
`},{name:"starts with",type:"function",params:[{name:"string"},{name:"match"}],info:`

Returns true if the given value starts with the substring match. Otherwise, returns false.

Function signature

starts with(string: string, match: string): boolean

Examples

starts with("foobar", "fo")
// true
`},{name:"ends with",type:"function",params:[{name:"string"},{name:"match"}],info:`

Returns true if the given value ends with the substring match. Otherwise, returns false.

Function signature

ends with(string: string, match: string): boolean

Examples

ends with("foobar", "r")
// true
`},{name:"matches",type:"function",params:[{name:"input"},{name:"pattern"}],info:`

Returns true if the given value matches the pattern. Otherwise, returns false.

Function signature

matches(input: string, pattern: string): boolean

The pattern is a string that contains a regular expression.

Examples

matches("foobar", "^fo*bar")
// true
`},{name:"matches",type:"function",params:[{name:"input"},{name:"pattern"},{name:"flags"}],info:`

Returns true if the given value matches the pattern. Otherwise, returns false.

Function signature

matches(input: string, pattern: string, flags: string): boolean

The pattern is a string that contains a regular expression.

The flags can contain one or more of the following characters:

  • s (dot-all)
  • m (multi-line)
  • i (case insensitive)
  • x (comments)

Examples

matches("FooBar", "foo", "i")
// true
`},{name:"replace",type:"function",params:[{name:"input"},{name:"pattern"},{name:"replacement"}],info:`

Returns the resulting string after replacing all occurrences of pattern with replacement.

Function signature

replace(input: string, pattern: string, replacement: string): string

The pattern is a string that contains a regular expression.

The replacement can access the match groups by using $ and the number of the group, for example, $1 to access the first group.

Examples

replace("abcd", "(ab)|(a)", "[1=$1][2=$2]")
// "[1=ab][2=]cd"

replace("0123456789", "(\\d{3})(\\d{3})(\\d{4})", "($1) $2-$3")
// "(012) 345-6789"
`},{name:"replace",type:"function",params:[{name:"input"},{name:"pattern"},{name:"replacement"},{name:"flags"}],info:`

Returns the resulting string after replacing all occurrences of pattern with replacement.

Function signature

replace(input: string, pattern: string, replacement: string, flags: string): string

The pattern is a string that contains a regular expression.

The replacement can access the match groups by using $ and the number of the group, for example, $1 to access the first group.

The flags can contain one or more of the following characters:

  • s (dot-all)
  • m (multi-line)
  • i (case insensitive)
  • x (comments)

Examples

replace("How do you feel?", "Feel", "FEEL", "i")
// "How do you FEEL?"
`},{name:"split",type:"function",params:[{name:"string"},{name:"delimiter"}],info:`

Splits the given value into a list of substrings, breaking at each occurrence of the delimiter pattern.

Function signature

split(string: string, delimiter: string): list<string>

The delimiter is a string that contains a regular expression.

Examples

split("John Doe", "\\s" )
// ["John", "Doe"]

split("a;b;c;;", ";")
// ["a", "b", "c", "", ""]
`},{name:"now",type:"function",params:[],info:`

Returns the current date and time including the timezone.

Function signature

now(): date and time

Examples

now()
// date and time("2020-07-31T14:27:30@Europe/Berlin")
`},{name:"today",type:"function",params:[],info:`

Returns the current date.

Function signature

today(): date

Examples

today()
// date("2020-07-31")
`},{name:"day of week",type:"function",params:[{name:"date"}],info:`

Returns the day of the week according to the Gregorian calendar. Note that it always returns the English name of the day.

Function signature

day of week(date: date): string
day of week(date: date and time): string

Examples

day of week(date("2019-09-17"))
// "Tuesday"

day of week(date and time("2019-09-17T12:00:00"))
// "Tuesday"
`},{name:"day of year",type:"function",params:[{name:"date"}],info:`

Returns the Gregorian number of the day within the year.

Function signature

day of year(date: date): number
day of year(date: date and time): number

Examples

day of year(date("2019-09-17"))
// 260

day of year(date and time("2019-09-17T12:00:00"))
// 260
`},{name:"week of year",type:"function",params:[{name:"date"}],info:`

Returns the Gregorian number of the week within the year, according to ISO 8601.

Function signature

week of year(date: date): number
week of year(date: date and time): number

Examples

week of year(date("2019-09-17"))
// 38

week of year(date and time("2019-09-17T12:00:00"))
// 38
`},{name:"month of year",type:"function",params:[{name:"date"}],info:`

Returns the month of the year according to the Gregorian calendar. Note that it always returns the English name of the month.

Function signature

month of year(date: date): string
month of year(date: date and time): string

Examples

month of year(date("2019-09-17"))
// "September"

month of year(date and time("2019-09-17T12:00:00"))
// "September"
`},{name:"abs",type:"function",params:[{name:"n"}],info:`

Returns the absolute value of a given duration.

Function signature

abs(n: days and time duration): days and time duration
abs(n: years and months duration): years and months duration

Examples

abs(duration("-PT5H"))
// "duration("PT5H")"

abs(duration("PT5H"))
// "duration("PT5H")"

abs(duration("-P2M"))
// duration("P2M")
`}],qT=[{name:"is defined",type:"function",params:[{name:"value"}],info:`

Camunda Extension

Checks if a given value is not null. If the value is null then the function returns false. Otherwise, the function returns true.

The function requires one argument. Calling is defined() without an argument is invalid.

Function signature

is defined(value: Any): boolean

Examples

is defined(1)
// true

is defined(null)
// false

is defined(x)
// false - if no variable "x" exists

is defined(x.y)
// false - if no variable "x" exists or it doesn't have a property "y"

is defined()
// error - expected one argument

:::caution Breaking change

This function worked differently in previous versions. It returned true if the value was null. Since this version, the function returns false if the value is null.

:::

`},{name:"get or else",type:"function",params:[{name:"value"},{name:"default"}],info:`

Camunda Extension

Return the provided value parameter if not null, otherwise return the default parameter

Function signature

get or else(value: Any, default: Any): Any

Examples

get or else("this", "default")
// "this"

get or else(null, "default")
// "default"

get or else(null, null)
// null
`,engines:{camunda:">=8.3"}},{name:"assert",type:"function",params:[{name:"value"},{name:"condition"}],info:`

Camunda Extension

Verify that the given condition is met. If the condition is true, the function returns the value. Otherwise, the evaluation fails with an error.

Function signature

assert(value: Any, condition: Any)

Examples

assert(x, x != null)
// "value" - if x is "value"
// error - if x is null or doesn't exist

assert(x, x >= 0)
// 4 - if x is 4
// error - if x is less than zero
`,engines:{camunda:">=8.3"}},{name:"assert",type:"function",params:[{name:"value"},{name:"condition"},{name:"cause"}],info:`

Camunda Extension

Verify that the given condition is met. If the condition is true, the function returns the value. Otherwise, the evaluation fails with an error containing the given message.

Function signature

assert(value: Any, condition: Any, cause: String)

Examples

assert(x, x != null, "'x' should not be null")
// "value" - if x is "value"
// error('x' should not be null) - if x is null or doesn't exist

assert(x, x >= 0, "'x' should be positive")
// 4 - if x is 4
// error('x' should be positive) - if x is less than zero
`,engines:{camunda:">=8.3"}},{name:"get value",type:"function",params:[{name:"context"},{name:"keys"}],info:`

Camunda Extension

Returns the value of the context entry for a context path defined by the given keys.

If keys contains the keys [k1, k2] then it returns the value at the nested entry k1.k2 of the context.

If keys are empty or the nested entry defined by the keys doesn't exist in the context, it returns null.

Function signature

get value(context: context, keys: list<string>): Any

Examples

get value({x:1, y: {z:0}}, ["y", "z"])
// 0

get value({x: {y: {z:0}}}, ["x", "y"])
// {z:0}

get value({a: {b: 3}}, ["b"])
// null
`},{name:"context put",type:"function",params:[{name:"context"},{name:"key"},{name:"value"}],info:`

Adds a new entry with the given key and value to the context. Returns a new context that includes the entry.

If an entry for the same key already exists in the context, it overrides the value.

Function signature

context put(context: context, key: string, value: Any): context

Examples

context put({x:1}, "y", 2)
// {x:1, y:2}

:::info The function context put() replaced the previous function put() (Camunda Extension). The previous function is deprecated and should not be used anymore. :::

`},{name:"context merge",type:"function",params:[{name:"contexts"}],info:`

Union the given contexts. Returns a new context that includes all entries of the given contexts.

If an entry for the same key already exists in a context, it overrides the value. The entries are overridden in the same order as in the list of contexts.

Function signature

context merge(contexts: list<context>): context

Examples

context merge([{x:1}, {y:2}])
// {x:1, y:2}

context merge([{x:1, y: 0}, {y:2}])
// {x:1, y:2}

:::info The function context merge() replaced the previous function put all() (Camunda Extension). The previous function is deprecated and should not be used anymore. :::

`,engines:{camunda:">=8.2"}},{name:"date and time",type:"function",params:[{name:"date"},{name:"timezone"}],info:`

Camunda Extension

Returns the given date and time value at the given timezone.

If date has a different timezone than timezone then it adjusts the time to match the local time of timezone.

Function signature

date and time(date: date and time, timezone: string): date and time

Examples

date and time(@"2020-07-31T14:27:30@Europe/Berlin", "America/Los_Angeles")
// date and time("2020-07-31T05:27:30@America/Los_Angeles")

date and time(@"2020-07-31T14:27:30", "Z")
// date and time("2020-07-31T12:27:30Z")
`},{name:"duplicate values",type:"function",params:[{name:"list"}],info:`

Camunda Extension

Returns all duplicate values of the given list.

Function signature

duplicate values(list: list): list

Examples

duplicate values([1,2,3,2,1])
// [1,2]
`,engines:{camunda:">=8.3"}},{name:"string join",type:"function",params:[{name:"list"},{name:"delimiter"},{name:"prefix"},{name:"suffix"}],info:`

Camunda Extension

Joins a list of strings into a single string. This is similar to Java's joining function.

If an item of the list is null, the item is ignored for the result string. If an item is neither a string nor null, the function returns null instead of a string.

The resulting string starts with prefix, contains a delimiter between each element, and ends with suffix.

Function signature

string join(list: list<string>, delimiter: string, prefix: string, suffix: string): string

Examples

string join(["a","b","c"], ", ", "[", "]")
// "[a, b, c]"
`},{name:"is empty",type:"function",params:[{name:"list"}],info:`

Camunda Extension

Returns true if the given list is empty. Otherwise, returns false.

Function signature

is empty(list: list): boolean

Examples

is empty([])
// true

is empty([1,2,3])
// false
`,engines:{camunda:">=8.6"}},{name:"partition",type:"function",params:[{name:"list"},{name:"size"}],info:`

Camunda Extension

Returns consecutive sublists of a list, each of the same size (the final list may be smaller).

If size is less than 0, it returns null.

Function signature

partition(list: list, size: number): list

Examples

partition([1,2,3,4,5], 2)
// [[1,2], [3,4], [5]]

partition([], 2)
// []

partition([1,2], 0)
// null
`,engines:{camunda:">=8.7"}},{name:"fromAi",type:"function",params:[{name:"value"}],info:`

Camunda Extension

Returns the unmodified value parameter.

  • The purpose of this function is solely to tag the value as being generated by an AI integration.
  • The actual handling is not performed by the FEEL engine, but by a custom integration such as a connector or a job worker.

The main use case of this function is for tool definitions used by the AI Agent connector.

See the following function overloads for additional function parameters.

Function signature

fromAi(value: Any): Any

Examples

fromAi(toolCall.searchQuery)
// toolCall.searchQuery contents

fromAi(toolCall.userId)
// toolCall.userId contents
`,engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"}],info:`

Camunda Extension

Returns the unmodified value parameter.

In addition to the previous overload, it also accepts an optional description parameter to provide a textual description of the value. The description must be null or a string constant.

Function signature

fromAi(value: Any, description: string): Any

Examples

fromAi(toolCall.searchQuery, "The search query used to find the best match.")
// toolCall.searchQuery contents

fromAi(toolCall.searchQuery, null)
// toolCall.searchQuery contents
`,engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"},{name:"type"}],info:`

Camunda Extension

Returns the unmodified value parameter.

In addition to the previous overload, it also accepts an optional type parameter to provide type information about the value. The type must be null or a string constant.

Function signature

fromAi(value: Any, description: string, type: string): Any

Examples

fromAi(toolCall.searchQuery, "The search query used to find the best match.", "string")
// toolCall.searchQuery contents

fromAi(toolCall.userId, "The user's ID", "number")
// toolCall.userId contents

fromAi(toolCall.userId, null, "number")
// toolCall.userId contents

fromAi(value: toolCall.userId, type: "number")
// toolCall.userId contents
`,engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"},{name:"type"},{name:"schema"}],info:`

Camunda Extension

Returns the unmodified value parameter.

In addition to the previous overload, it also accepts an optional schema parameter to provide a (partial) JSON schema for the value.

  • The schema must be null or a context (map) containing only constant values. For example, function calls within the schema are not supported.
  • The schema is not validated by the FEEL engine but might be by a custom integration consuming the information.
  • From the engine side it is possible to specify both a type and a schema, and it depends on the integration as to which value takes precedence. The AI Agent connector will override any type specified in the schema if the type parameter is also provided.

Function signature

fromAi(value: Any, description: string, type: string, schema: context): Any

Examples

fromAi(toolCall.documentType, "The document type to provide", "string", {
  enum: ["invoice", "receipt", "contract"]
})
// toolCall.documentType contents

fromAi(value: toolCall.documentType, description: "The document type to provide", schema: {
  type: "string",
  enum: ["invoice", "receipt", "contract"]
})
// toolCall.documentType contents

fromAi(toolCall.tags, "Tags to apply to the blog post", "array", {
  items: {
    type: "string"
  }
})
// toolCall.tags contents
`,engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"},{name:"type"},{name:"schema"},{name:"options"}],info:`

Camunda Extension

Returns the unmodified value parameter.

In addition to the previous overload, it also accepts an optional options parameter to provide additional options for the integration handling the value definition.

  • The options parameter must be null or a context (map) containing only constant values. For example, function calls within options are not supported.

Function signature

fromAi(value: Any, description: string, type: string, schema: context, options: context): Any

Examples

fromAi(toolCall.documentType, "The document type to provide", "string", null, {
  required: false
})
// toolCall.documentType contents

fromAi(value: toolCall.documentType, options: {
  required: false
})
// toolCall.documentType contents
`,engines:{camunda:">=8.8"}},{name:"random number",type:"function",params:[],info:`

Camunda Extension

Returns a random number between 0 and 1.

Function signature

random number(): number

Examples

random number()
// 0.9701618132579795
`,engines:{camunda:">=8.2"}},{name:"extract",type:"function",params:[{name:"string"},{name:"pattern"}],info:`

Camunda Extension

Returns all matches of the pattern in the given string. Returns an empty list if the pattern doesn't match.

Function signature

extract(string: string, pattern: string): list<string>

The pattern is a string that contains a regular expression.

Examples

extract("references are 1234, 1256, 1378", "12[0-9]*")
// ["1234","1256"]
`},{name:"trim",type:"function",params:[{name:"string"}],info:`

Camunda Extension

Returns the given string without leading and trailing spaces.

Function signature

trim(string: string): string

Examples

trim("  hello world  ")
// "hello world"

trim("hello   world ")
// "hello   world"
`,engines:{camunda:">=8.6"}},{name:"uuid",type:"function",params:[],info:`

Camunda Extension

Returns a UUID (Universally Unique Identifier) with 36 characters.

Function signature

uuid(): string

Examples

uuid()
// "7793aab1-d761-4d38-916b-b7270e309894"
`,engines:{camunda:">=8.6"}},{name:"to base64",type:"function",params:[{name:"value"}],info:`

Camunda Extension

Returns the given string encoded in Base64 format.

Function signature

to base64(value: string): string

Examples

to base64("FEEL")
// "RkVFTA=="
`,engines:{camunda:">=8.6"}},{name:"is blank",type:"function",params:[{name:"string"}],info:`

Camunda Extension

Returns true if the given string is blank (empty or contains only whitespaces).

Function signature

is blank(string: string): boolean

Examples

is blank("")
// true

is blank(" ")
// true

is blank("hello world")
// false
`,engines:{camunda:">=8.8"}},{name:"last day of month",type:"function",params:[{name:"date"}],info:`

Camunda Extension

Takes the month of the given date or date-time value and returns the last day of this month.

Function signature

last day of month(date: date): date
last day of month(date: date and time): date

Examples

last day of month(date("2022-10-01"))
// date("2022-10-31"))

last day of month(date and time("2022-10-16T12:00:00"))
// date("2022-10-31"))
`,engines:{camunda:">=8.2"}}],ab=[...NT,...qT];var FT=[Ox(eb())],jT=q.theme({"& .cm-content":{padding:"0px"},"& .cm-line":{padding:"0px"},"&.cm-editor.cm-focused":{outline:"none"},"& .cm-completionInfo":{whiteSpace:"pre-wrap",overflow:"hidden",textOverflow:"ellipsis"},"&.cm-editor":{height:"100%"},"& .cm-completionInfo > *":{whiteSpace:"normal"},"& .cm-completionInfo ul":{margin:0,paddingLeft:"15px"},"& .cm-completionInfo pre":{marginBottom:0,whiteSpace:"pre-wrap"},"& .cm-completionInfo p":{marginTop:0},"& .cm-completionInfo p:not(:last-of-type)":{marginBottom:0}}),VT=q.baseTheme({"& .variableName":{color:"#10f"},"& .number":{color:"#164"},"& .string":{color:"#a11"},"& .bool":{color:"#219"},"& .function":{color:"#aa3731",fontWeight:"bold"},"& .control":{color:"#708"}}),QT=pv(ds.define([{tag:T.variableName,class:"variableName"},{tag:T.name,class:"variableName"},{tag:T.number,class:"number"},{tag:T.string,class:"string"},{tag:T.bool,class:"bool"},{tag:T.function(T.variableName),class:"function"},{tag:T.function(T.special(T.variableName)),class:"function"},{tag:T.controlKeyword,class:"control"},{tag:T.operatorKeyword,class:"control"}])),zT=[jT,VT,QT];function lb(n){return n&&n.from===n.to}function WT(n,e){let t=n.nextSibling;return lb(n)||t&&t.from===e&&lb(t)}function HT(n){return n&&n.parent&&n.parent.name==="VariableName"}function Pd(n){return n?n.name==="PathExpression"?!0:Pd(n.parent):!1}function XT({variables:n}){return e=>{let t=ge(e.state).resolve(e.pos,-1);if(!Pd(t))return null;let i=UT(t),r=t===i?e.pos:t.from,s=Dd(i,e),o=n;for(var a=0;af.name===s[a].name);if(!l||l.isList!=="optional"&&!!l.isList!==s[a].isList)return null;o=l.entries}if(!o)return null;let c=o.map(f=>({label:f.name,type:"variable",info:f.info,detail:f.detail}));return{from:r,options:c}}}function UT(n){for(;n;){if(n.name==="PathExpression")return n;n=n.parent}}function Dd(n,e){let t=[];for(let i=n.firstChild;i;i=i.nextSibling)i.name==="PathExpression"?t.push(...Dd(i,e)):i.name==="FilterExpression"?t.push(...YT(i,e)):t.push({name:ub(i,e),isList:!1});return t}function YT(n,e){let t=n.firstChild;if(t.name==="PathExpression"){let i=Dd(t,e),r=i[i.length-1];return r.isList=!0,i}return[{name:ub(t,e),isList:!0}]}function ub(n,e){return e.state.sliceDoc(n.from,n.to)}function KT({variables:n=[],builtins:e=[]}){let t=GT(n,e),i=/^[\w ]*$/;return t.length?r=>{let{pos:s,state:o}=r,a=ge(o).resolve(s,-1);if(WT(a,s))return r.explicit?{from:s,options:t,validFor:i}:null;if(!HT(a)||Pd(a))return null;let l=typeof r.matchBefore=="function"?r.matchBefore(/\w[\w ]*$/):null;return{from:l?l.from:a.from,options:t,validFor:i}}:r=>null}function GT(n,e){return[].concat(n.map(t=>cb(t)),e.map(t=>cb(t)))}function cb(n,e){return n.type==="function"?JT(n,e):{label:n.name,type:"variable",info:n.info,detail:n.detail,boost:e}}function JT(n,e){let{name:t,info:i,detail:r,params:s=[]}=n,o=s.map(({name:u,type:f},h)=>({name:u||`param ${h+1}`,type:f})),a=`${t}(${o.map(u=>"${"+u.name+"}").join(", ")})`,l=o.map(({name:u,type:f})=>f?`${u}: ${f}`:u).join(", "),c=`${t}(${l})`;return Bt(a,{label:c,type:"function",info:i,detail:r,boost:e})}function ZT({variables:n=[],builtins:e=[]}){return[XT({variables:n}),KT({variables:n,builtins:e}),ys(Md),...Rd]}function eM(n){return ob(n)}function tM(n){return n.slice().reverse().reduce((e,t)=>(e[t.name]=()=>{},e),{})}var fb=N.define(),hb=N.define(),db=N.define(),pb=N.define();function mb({dialect:n="expression",parserDialect:e,variables:t=[],builtins:i=[],completions:r=ZT({builtins:i,variables:t})}){let s=tM([...t,...i]);return[db.of(n),fb.of(i),hb.of(t),pb.of(e),eM({dialect:n,parserDialect:e,context:s,completions:r})]}function nM(n){let e=n.facet(fb)[0],t=n.facet(hb)[0],i=n.facet(db)[0],r=n.facet(pb)[0];return{builtins:e,variables:t,dialect:i,parserDialect:r}}var iM=ab.map(n=>({...n,info:()=>le(n.info)})),gb=new Pi,yb=new Pi;function qn({extensions:n=[],dialect:e="expression",parserDialect:t,container:i,contentAttributes:r={},tooltipContainer:s,onChange:o=()=>{},onKeyDown:a=()=>{},onLint:l=()=>{},placeholder:c="",readOnly:u=!1,value:f="",builtins:h=iM,variables:d=[]}){this._events=Ex();let p=q.updateListener.of(x=>{x.docChanged&&o(x.state.doc.toString())}),m=q.updateListener.of(x=>{let b=x.transactions.flatMap(O=>O.effects).filter(O=>O.is(na));if(!b.length)return;let C=b.flatMap(O=>O.value);this._events.emit("lint",{diagnostics:C})}),y=q.domEventObservers({keydown:a});typeof s=="string"&&(s=document.querySelector(s));let g=s?W0({tooltipSpace:function(){return s.getBoundingClientRect()}}):[],k=[Bv(),gb.of(mb({dialect:e,builtins:h,variables:d,parserDialect:t})),vv(),fv(),Pv(),q.contentAttributes.of(r),p,y,cs.of([...yx]),FT,m,g,yb.of(fh(c)),zT,...n];return u&&k.push(q.editable.of(!1)),this.on("lint",({diagnostics:x})=>l(x)),this._cmEditor=new q({state:he.create({doc:f,extensions:k}),parent:i}),this}qn.prototype.setValue=function(n){this._cmEditor.dispatch({changes:{from:0,to:this._cmEditor.state.doc.length,insert:n}})};qn.prototype.focus=function(n){let e=this._cmEditor;if(e.contentDOM.focus(),e.focus(),typeof n=="number"){let t=e.state.doc.length;e.dispatch({selection:{anchor:n<=t?n:t}})}};qn.prototype.on=function(n,e){this._events.on(n,e)};qn.prototype.off=function(n,e){this._events.off(n,e)};qn.prototype.getSelection=function(){return this._cmEditor.state.selection};qn.prototype.setVariables=function(n){let e=nM(this._cmEditor.state);this._cmEditor.dispatch({effects:[gb.reconfigure(mb({...e,variables:n}))]})};qn.prototype.setPlaceholder=function(n){this._cmEditor.dispatch({effects:yb.reconfigure(fh(n))})};var sa=class extends z{constructor(t,i){var r;super(t,i);L(this,"handleMouseEvent",t=>{t.stopPropagation()});L(this,"handleKeyDownCapture",t=>{if(t.key==="Enter"){if(sM(this.node)){t.triggeredFromAutocomplete=!0;return}this.props.ctrlForNewline&&!rM(t)&&t.preventDefault(),this.props.singleLine&&t.preventDefault()}});L(this,"handleKeyDown",t=>{["Enter","Escape"].includes(t.key)&&t.triggeredFromAutocomplete&&t.stopPropagation()});L(this,"handleChange",t=>{let{onInput:i}=this.props;this.setState({value:t}),i&&i(t)});L(this,"handleBlur",()=>{let{onBlur:t,onChange:i}=this.props;i&&this.state.value!==this.props.value&&i(this.state.value),t&&t()});L(this,"setNode",t=>{this.node=t});this.node=null,this.editor=null,this.state={value:t.value},this._feelLanguageContext=(r=i.injector)==null?void 0:r.get("feelLanguageContext",!1)}_getFeelLanguageContext(){return this._feelLanguageContext&&this._feelLanguageContext.getConfig()}componentDidMount(){let t=this._getFeelLanguageContext();this.editor=new qn({contentAttributes:{"aria-label":this.props.label},parserDialect:t==null?void 0:t.parserDialect,builtins:t==null?void 0:t.builtins,dialect:this.props.feelLanguageDialect,container:this.node,onChange:this.handleChange,value:this.state.value,variables:this.props.variables||[],extensions:[q.lineWrapping]}),this.node.addEventListener("mousedown",this.handleMouseEvent),this.node.addEventListener("keydown",this.handleKeyDownCapture,!0),this.node.addEventListener("keydown",this.handleKeyDown),this.props.autoFocus&&this.editor.focus(this.state.value.length)}componentDidUpdate(t){let{value:i}=this.props;t.value!==i&&i!==this.state.value&&this.setState({value:i},()=>{this.editor.setValue(i)}),oM(t.variables,this.props.variables)||this.editor.setVariables(this.props.variables)}componentWillUnmount(){this.node.removeEventListener("mousedown",this.handleMouseEvent),this.node.removeEventListener("keydown",this.handleKeyDownCapture,!0),this.node.removeEventListener("keydown",this.handleKeyDown)}render(){return E(1,"div",["literal-expression",this.props.className||""].join(" "),null,1,{onClick:this.handleMouseEvent,onFocusIn:this.props.onFocus,onFocusOut:this.handleBlur},null,this.setNode)}};function rM(n){return n.metaKey||n.ctrlKey}function sM(n){return n.querySelector(".cm-tooltip-autocomplete")}function oM(n,e){return JSON.stringify(n)===JSON.stringify(e)}function $t(n,e){return function(t){return on(F(2,Bd,{...t,_component:n,_selectDependencies:e}))}}var Bd=class extends z{constructor(t,i){super(t,i);L(this,"onChange",({elements:t})=>{this.props._selectDependencies(this.props).some(r=>t.includes(r))&&this.forceUpdate()});this._eventBus=i.injector.get("eventBus")}componentDidMount(){this._subscribe()}componentWillUnmount(){this._unsubscribe()}_subscribe(){this._eventBus.on("elements.changed",this.onChange)}_unsubscribe(){this._eventBus.off("elements.changed",this.onChange)}render(){let t=this.props._component;return on(F(2,t,{...this.props}))}};var Id=class extends z{constructor(t,i){super(t,i);L(this,"editLiteralExpressionText",t=>{let i=this.getLiteralExpression();this._literalExpression.setText(i,t)});this._literalExpression=i.injector.get("literalExpression"),this._translate=i.injector.get("translate"),this._expressionLanguages=i.injector.get("expressionLanguages"),this._variableResolver=i.injector.get("variableResolver",!1)}getLiteralExpression(){return this.props.expression}getEditor(){return this.isFeel()?aM:Ld}isFeel(){let t=this.getLiteralExpression();return em(t)}_getVariables(){let t=this.getLiteralExpression();return this._variableResolver&&this._variableResolver.getVariables(t)}render(){let{text:t}=this.getLiteralExpression(),i=this.getEditor(),r=this._getVariables(),s=this._translate("Literal expression");return F(2,i,{label:s,className:"textarea editor",value:t,onChange:this.editLiteralExpressionText,variables:r})}};function aM(n){return on(F(2,sa,{...n,onChange:n.onChange}))}var Ld=class extends xo{render(){return E(1,"div",this.getClassName(),this.getEditor(),0)}},Q5=$t(Id,n=>[n.expression]);var oa=class extends Ei{constructor(e){super(),this._modeling=e}setText(e,t){this._modeling.updateProperties(e,{text:t})}};oa.$inject=["modeling"];function $d({label:n,onClick:e}){return E(1,"button","edit-button dmn-icon-edit",null,1,{"aria-label":n,type:"button",onClick:e})}var aj=$t(lM,n=>[n.expression]);function lM({expression:n},e){let t=e.injector.get("functionDefinition"),i=e.injector.get("contextMenu"),r=t.getKind(n),s=t.getParameters(n),o=t.getBody(n),a=c=>{let u=vb(c);i.open(u,{contextMenuType:"kind-editor",expression:n})},l=c=>{let u=vb(c);i.open(u,{contextMenuType:"formal-parameters-editor",expression:n})};return E(1,"div","function-definition",[F(2,uM,{kind:r,openEditor:a}),F(2,fM,{parameters:s,openEditor:l}),F(2,pM,{expression:o,parameters:s})],4)}var cM={FEEL:"F",Java:"J",PMML:"P"};function uM({kind:n,openEditor:e},t){let i=t.injector.get("translate");return E(1,"div","function-definition-kind",[cM[n],F(2,$d,{label:i("Edit function kind"),onClick:e})],0)}function fM({openEditor:n,parameters:e},t){let i=t.injector.get("translate");return E(1,"div","function-definition-parameters",[E(1,"div",null,[xe("("),e.reduce((r,s)=>r.concat(F(2,hM,{parameter:s}),", "),[]).slice(0,-1),xe(")")],0),F(2,$d,{label:i("Edit formal parameters"),onClick:n})],4)}var hM=$t(dM,n=>[n.parameter]);function dM({parameter:n}){let{name:e,typeRef:t}=n,i=e||"";return E(1,"span",null,t?`${i}: ${t}`:i,0)}var pM=$t(mM,n=>n.parameters);function mM({expression:n,parameters:e},t){let i=t.components.getComponent("expression",{expression:n});return E(1,"div","function-definition-body",F(2,i,{expression:n,parameters:e}),2)}function vb(n){let e=n.target.parentElement,t=e.getBoundingClientRect();return{x:t.x,y:t.y}}var ui=class extends z{constructor(t,i){super(t,i);L(this,"onChange",t=>{this.setState({value:t});let{onChange:i}=this.props;typeof i=="function"&&i(t)});L(this,"onInputClick",t=>{t.preventDefault(),t.stopPropagation(),this.setOptionsVisible(!this.state.optionsVisible),this.focusInput()});L(this,"onInput",t=>{let{value:i}=t.target;this.onChange(i)});L(this,"onOptionClick",(t,i)=>{i.preventDefault(),i.stopPropagation(),this.setOptionsVisible(!1),this.onChange(t),this.focusInput()});L(this,"onFocusChanged",t=>{this.checkClose(t.target)});L(this,"onGlobalClick",t=>{this.checkClose(t.target)});L(this,"onKeyDown",t=>{let{optionsVisible:i}=this.state;var r=t.which;(r===40||r===38)&&(t.stopPropagation(),t.preventDefault(),i?this.select(r===40?1:-1):this.setOptionsVisible(!0)),i&&(r===13||r===27)&&(t.stopPropagation(),t.preventDefault(),this.setOptionsVisible(!1))});L(this,"onKeyboard",t=>{let{optionsVisible:i}=this.state;if(i&&t===27)return this.setOptionsVisible(!1),!0});zt(this);let{value:r}=t;this.state={value:r,optionsVisible:!1},this._portalEl=null}componentDidMount(){document.addEventListener("mousedown",this.onGlobalClick),document.addEventListener("focusin",this.onFocusChanged),this.keyboard.addListener(this.onKeyboard)}componentWillUnmount(){document.removeEventListener("focusin",this.onFocusChanged),document.removeEventListener("mousedown",this.onGlobalClick),this.keyboard.removeListener(this.onKeyboard),this.removePortalEl()}componentWillReceiveProps(t){let{value:i}=t;this.setState({value:i})}componentWillUpdate(t,i){let{optionsVisible:r}=i;r?this._portalEl||this.addPortalEl():this._portalEl&&this.removePortalEl()}componentDidUpdate(){let{optionsVisible:t}=this.state;if(!t||!this.inputNode)return;let i=this.getOptionsBounds();D(this._portalEl.style,i)}getOptionsBounds(){let t=this.renderer.getContainer(),{top:i,left:r,bottom:s}=t.getBoundingClientRect(),{top:o,left:a,width:l,height:c,bottom:u}=this.inputNode.getBoundingClientRect(),f=o+c-i+t.scrollTop,h=a-r+t.scrollLeft,d={top:`${f}px`,left:`${h}px`,width:`${l}px`,"max-height":`calc(100% - ${f}px)`};if(s-u
'),this.renderer.getContainer().appendChild(this._portalEl),this._portalEl.addEventListener("mousedown",xb)}removePortalEl(){this._portalEl&&(this._portalEl.removeEventListener("mousedown",xb),Le(this._portalEl),this._portalEl=null)}focusInput(){let t=this.inputNode;t.focus(),"selectionStart"in t&&(t.selectionStart=1e5)}checkClose(t){this._portalEl&&!this._portalEl.contains(t)&&!this.parentNode.contains(t)&&this.setOptionsVisible(!1)}select(t){let{options:i}=this.props,{value:r}=this.state;if(!i)return;let s=i.filter(c=>c.value===r)[0],o=s?i.indexOf(s):-1,a=o===-1?t===1?0:i.length-1:(o+t)%i.length,l=i[a<0?i.length+a:a];this.onChange(l.value)}setOptionsVisible(t){this.setState({optionsVisible:t})}renderOptions(t,i){return E(1,"div","options",t.map(r=>E(1,"div",["option",i===r?"active":""].join(" "),r.label,0,{"data-value":r.value,onClick:s=>this.onOptionClick(r.value,s)})),0)}render(){let{className:t,label:i,id:r,options:s,noInput:o,title:a}=this.props,{optionsVisible:l,value:c}=this.state,u=s?s.filter(h=>h.value===c)[0]:!1,f=u?u.label:c;return E(1,"div",[t||"","dms-input-select"].join(" "),[o?E(1,"div","dms-input",f,0,{"aria-label":i,tabIndex:"0",onKeyDown:this.onKeyDown},null,h=>this.inputNode=h):E(64,"input","dms-input",null,1,{"aria-label":i,onInput:this.onInput,onKeyDown:this.onKeyDown,spellCheck:"false",type:"text",value:c,id:r},null,h=>this.inputNode=h),E(1,"span",["dms-input-select-icon",l?"dmn-icon-up":"dmn-icon-down"].join(" ")),l&&Em(this.renderOptions(s,u),this._portalEl)],0,{title:a,onClick:this.onInputClick},null,h=>this.parentNode=h)}};ui.$inject=["keyboard","renderer"];function xb(n){n.stopPropagation()}var Ui=class extends z{constructor(t,i){super(t,i);L(this,"onInput",t=>{let{onInput:i}=this.props,r=t.target.value;this.setState({value:r},()=>{typeof i=="function"&&i(r)})});L(this,"onChange",t=>{let{onChange:i}=this.props;typeof i=="function"&&i(t.target.value)});L(this,"onKeyDown",t=>{let{onKeyDown:i}=this.props;typeof i=="function"&&i(t)});L(this,"onKeyUp",t=>{let{onKeyUp:i}=this.props;typeof i=="function"&&i(t)});this.state={value:t.value}}componentDidUpdate(t){let{value:i}=this.props;i!==t.value&&i!==this.state.value&&this.setState({value:i})}render(){let{className:t,label:i,id:r,placeholder:s,type:o}=this.props,{value:a}=this.state;return E(64,"input",[t||"","dms-input"].join(" "),null,1,{"aria-label":i,placeholder:s||"",onChange:this.onChange,onInput:this.onInput,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,spellCheck:"false",type:o||"text",value:a,id:r})}};var Tj=$t(gM,n=>[n.context.expression]);function gM({context:{expression:n}},e){let t=e.injector.get("functionDefinition"),i=e.injector.get("translate"),r=t.getParameters(n),s=a=>{t.removeParameter(n,a)},o=()=>{t.addParameter(n)};return E(1,"div","context-menu-container formal-parameters",[E(1,"h3",null,i("Edit formal parameters"),0),r.length?E(1,"table",null,[E(1,"thead",null,E(1,"tr",null,[E(1,"th",null,xe("Name"),2),E(1,"th",null,xe("Type"),2)],4),2),E(1,"tbody",null,r.map((a,l)=>F(2,yM,{parameter:a,remove:()=>s(a)},l)),0)],4):null,E(1,"button","add-parameter",i("Add parameter"),0,{type:"button",onClick:o})],0)}var yM=$t(function({parameter:n,remove:e},t){let i=t.injector.get("dataTypes"),r=t.injector.get("translate"),s=t.injector.get("functionDefinition"),{name:o,typeRef:a}=n,l=f=>{s.updateParameter(n,{name:f})},c=f=>{s.updateParameter(n,{typeRef:f})},u=i.getAll().map(f=>({label:r(f),value:f}));return E(1,"tr","function-definition-parameter",[E(1,"td",null,F(2,Ui,{onChange:l,value:o}),2),E(1,"td",null,F(2,ui,{onChange:c,value:a,options:u}),2),E(1,"td",null,E(1,"button","dmn-icon-trash",null,1,{type:"button",onClick:e,"aria-label":r("Remove parameter")}),2)],4)},n=>[n.parameter]);var vM=$t(function(n,e){let{element:t}=n,i=e.injector.get("modeling"),r=e.injector.get("translate"),s=t.get("name"),o=a=>{i.updateProperties(t,{name:a})};return F(2,Ui,{label:r("Element name"),className:"element-name editor",value:s,onChange:o})},n=>[n.element]);function Nd(n,e){let i=e.injector.get("viewer").getRootElement();return E(1,"div","element-properties",F(2,vM,{element:i}),2)}var aa=class{constructor(e){e.onGetComponent("header",()=>Nd)}};aa.$inject=["components"];var xM=300;function qd(n){return function(t){if(n!==!1){var i=Ce(n)?n:xM;return Gi(t,i)}else return t}}qd.$inject=["config.debounceInput"];var la=class{constructor(e,t){this._eventBus=t,this._viewer=e}updateId(e,t){let i=this._viewer.getRootElement();if(e!==i)throw new Error("element !== rootElement");this._eventBus.fire("element.updateId",{element:e,newId:t}),e.id=t}};la.$inject=["viewer","eventBus"];var bb="is not a registered action",bM="is already registered",ca=class{constructor(e,t){this._actions={undo(){e.undo()},redo(){e.redo()}}}trigger(e,t){if(!this._actions[e])throw Fd(e,bb);return this._actions[e](t)}register(e,t){if(typeof e=="string")return this._registerAction(e,t);B(e,(i,r)=>{this._registerAction(r,i)},this)}_registerAction(e,t){if(this.isRegistered(e))throw Fd(e,bM);this._actions[e]=t}unregister(e){if(!this.isRegistered(e))throw Fd(e,bb);this._actions[e]=void 0}isRegistered(e){return!!this._actions[e]}};ca.$inject=["commandStack","eventBus"];function Fd(n,e){return new Error(n+" "+e)}function wb(n){return n.dmnDI&&n.dmnDI.diagrams&&n.dmnDI.diagrams[0]}var Yi=class extends Rs{_getViewProviders(){return[{id:"drd",constructor:Ve,opens(e){return Q(e,"dmn:Definitions")&&wb(e)}},{id:"decisionTable",constructor:no,opens(e){return Q(e,"dmn:Decision")&&Q(e.decisionLogic,"dmn:DecisionTable")}},{id:"literalExpression",constructor:lo,opens(e){return Q(e,"dmn:Decision")&&Q(e.decisionLogic,"dmn:LiteralExpression")}},{id:"boxedExpression",constructor:Qr,opens(e){return Q(e,"dmn:BusinessKnowledgeModel")&&Ta(e)}}]}};var Ob=globalThis;Ob.DmnJS=Yi;Ob.DmnJS.Viewer=Yi;var cV=Yi;})();