1/*! dmn-js - 17.8.1 | generated for dokuwiki-plugin-bpmnio | SEE LICENSE IN LICENSE */ 2(()=>{var qD=Object.create;var Ky=Object.defineProperty;var VD=Object.getOwnPropertyDescriptor;var HD=Object.getOwnPropertyNames;var zD=Object.getPrototypeOf,WD=Object.prototype.hasOwnProperty;var UD=(n,e,t)=>e in n?Ky(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Mw=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var QD=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of HD(e))!WD.call(n,r)&&r!==t&&Ky(n,r,{get:()=>e[r],enumerable:!(i=VD(e,r))||i.enumerable});return n};var Pw=(n,e,t)=>(t=n!=null?qD(zD(n)):{},QD(e||!n||!n.__esModule?Ky(t,"default",{value:n,enumerable:!0}):t,n));var M=(n,e,t)=>UD(n,typeof e!="symbol"?e+"":e,t);var hR=Mw((Qx,fR)=>{/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */(function(n,e){typeof Qx=="object"?fR.exports=e(n):typeof define=="function"&&define.amd?define([],e.bind(n,n)):e(n)})(typeof window!="undefined"?window:Qx,function(n){if(n.CSS&&n.CSS.escape)return n.CSS.escape;var e=function(t){if(arguments.length==0)throw new TypeError("`CSS.escape` requires an argument.");for(var i=String(t),r=i.length,o=-1,s,a="",l=i.charCodeAt(0);++o<r;){if(s=i.charCodeAt(o),s==0){a+="\uFFFD";continue}if(s>=1&&s<=31||s==127||o==0&&s>=48&&s<=57||o==1&&s>=48&&s<=57&&l==45){a+="\\"+s.toString(16)+" ";continue}if(o==0&&r==1&&s==45){a+="\\"+i.charAt(o);continue}if(s>=128||s==45||s==95||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122){a+=i.charAt(o);continue}a+="\\"+i.charAt(o)}return a};return n.CSS||(n.CSS={}),n.CSS.escape=e,e})});var AR=Mw((zde,TR)=>{"use strict";/*! 3 * escape-html 4 * Copyright(c) 2012-2013 TJ Holowaychuk 5 * Copyright(c) 2015 Andreas Lubbe 6 * Copyright(c) 2015 Tiancheng "Timothy" Gu 7 * MIT Licensed 8 */var R5=/["'&<>]/;TR.exports=T5;function T5(n){var e=""+n,t=R5.exec(e);if(!t)return e;var i,r="",o=0,s=0;for(o=t.index;o<e.length;o++){switch(e.charCodeAt(o)){case 34:i=""";break;case 38:i="&";break;case 39:i="'";break;case 60:i="<";break;case 62:i=">";break;default:continue}s!==o&&(r+=e.substring(s,o)),s=o+1,r+=i}return s!==o?r+e.substring(s,o):r}});function Dw(n){return Array.prototype.concat.apply([],n)}var zu=Object.prototype.toString,KD=Object.prototype.hasOwnProperty;function Hu(n){return n===void 0}function Me(n){return n!==void 0}function Yr(n){return n==null}function F(n){return zu.call(n)==="[object Array]"}function Pe(n){return zu.call(n)==="[object Object]"}function se(n){return zu.call(n)==="[object Number]"}function ge(n){let e=zu.call(n);return e==="[object Function]"||e==="[object AsyncFunction]"||e==="[object GeneratorFunction]"||e==="[object AsyncGeneratorFunction]"||e==="[object Proxy]"}function Ie(n){return zu.call(n)==="[object String]"}function Zr(n,e){return!Yr(n)&&KD.call(n,e)}function ye(n,e){let t=Xy(e),i;return k(n,function(r,o){if(t(r,o))return i=r,!1}),i}function Iw(n,e){let t=Xy(e),i=F(n)?-1:void 0;return k(n,function(r,o){if(t(r,o))return i=o,!1}),i}function Ee(n,e){let t=Xy(e),i=[];return k(n,function(r,o){t(r,o)&&i.push(r)}),i}function k(n,e){let t,i;if(Hu(n))return;let r=F(n)?XD:GD;for(let o in n)if(Zr(n,o)&&(t=n[o],i=e(t,r(o)),i===!1))return t}function st(n,e,t){return k(n,function(i,r){t=e(t,i,r)}),t}function kt(n,e){return!!st(n,function(t,i,r){return t&&e(i,r)},!0)}function zd(n,e){return!!ye(n,e)}function Vt(n,e){let t=[];return k(n,function(i,r){t.push(e(i,r))}),t}function di(n){return n&&Object.keys(n)||[]}function Lw(n){return di(n).length}function Wu(n){return Vt(n,e=>e)}function ur(n,e,t={}){return e=Gy(e),k(n,function(i){let r=e(i)||"_",o=t[r];o||(o=t[r]=[]),o.push(i)}),t}function Bw(n,...e){n=Gy(n);let t={};return k(e,r=>ur(r,n,t)),Vt(t,function(r,o){return r[0]})}function Fn(n,e){e=Gy(e);let t=[];return k(n,function(i,r){let o=e(i,r),s={d:o,v:i};for(var a=0;a<t.length;a++){let{d:l}=t[a];if(o<l){t.splice(a,0,s);return}}t.push(s)}),Vt(t,i=>i.v)}function la(n){return function(e){return kt(n,function(t,i){return e[i]===t})}}function Gy(n){return ge(n)?n:e=>e[n]}function Xy(n){return ge(n)?n:e=>e===n}function GD(n){return n}function XD(n){return Number(n)}function Mi(n,e){let t,i,r,o;function s(f){let h=Date.now(),d=f?0:o+e-h;if(d>0)return a(d);n.apply(r,i),l()}function a(f){t=setTimeout(s,f)}function l(){t&&clearTimeout(t),t=o=i=r=void 0}function c(){t&&s(!0),l()}function u(...f){o=Date.now(),i=f,r=this,t||a(e)}return u.flush=c,u.cancel=l,u}function Nw(n,e){let t=!1;return function(...i){t||(n(...i),t=!0,setTimeout(()=>{t=!1},e))}}function at(n,e){return n.bind(e)}function T(n,...e){return Object.assign(n,...e)}function $w(n,e,t){let i=n;return k(e,function(r,o){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 s=e[o+1],a=i[r];Me(s)&&Yr(a)&&(a=i[r]=isNaN(+s)?{}:[]),Hu(s)?Hu(t)?delete i[r]:i[r]=t:i=a}),n}function hn(n,e){let t={},i=Object(n);return k(e,function(r){r in i&&(t[r]=n[r])}),t}function Uu(n,e){let t={},i=Object(n);return k(i,function(r,o){e.indexOf(o)===-1&&(t[o]=r)}),t}var Wd="__fn",jw=1e3,YD=Array.prototype.slice;function ut(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}ut.prototype.on=function(n,e,t,i){if(n=F(n)?n:[n],ge(e)&&(i=t,t=e,e=jw),!se(e))throw new Error("priority must be a number");var r=t;i&&(r=at(t,i),r[Wd]=t[Wd]||t);var o=this;n.forEach(function(s){o._addListener(s,{priority:e,callback:r,next:null})})};ut.prototype.once=function(n,e,t,i){var r=this;if(ge(e)&&(i=t,t=e,e=jw),!se(e))throw new Error("priority must be a number");function o(){o.__isTomb=!0;var s=t.apply(i,arguments);return r.off(n,o),s}o[Wd]=t,this.on(n,e,o)};ut.prototype.off=function(n,e){n=F(n)?n:[n];var t=this;n.forEach(function(i){t._removeListener(i,e)})};ut.prototype.createEvent=function(n){var e=new Qu;return e.init(n),e};ut.prototype.fire=function(n,e){var t,i,r,o;if(o=YD.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 Qu?t=e:t=this.createEvent(e),o[0]=t;var s=t.type;n!==s&&(t.type=n);try{r=this._invokeListeners(t,o,i)}finally{n!==s&&(t.type=s)}return r===void 0&&t.defaultPrevented&&(r=!1),r}};ut.prototype.handleError=function(n){return this.fire("error",{error:n})===!1};ut.prototype._destroy=function(){this._listeners={}};ut.prototype._invokeListeners=function(n,e,t){for(var i;t&&!n.cancelBubble;)i=this._invokeListener(n,e,t),t=t.next;return i};ut.prototype._invokeListener=function(n,e,t){var i;if(t.callback.__isTomb)return i;try{i=ZD(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};ut.prototype._addListener=function(n,e){var t=this._getListeners(n),i;if(!t){this._setListeners(n,e);return}for(;t;){if(t.priority<e.priority){e.next=t,i?i.next=e:this._setListeners(n,e);return}i=t,t=t.next}i.next=e};ut.prototype._getListeners=function(n){return this._listeners[n]};ut.prototype._setListeners=function(n,e){this._listeners[n]=e};ut.prototype._removeListener=function(n,e){var t=this._getListeners(n),i,r,o;if(!e){this._setListeners(n,null);return}for(;t;)i=t.next,o=t.callback,(o===e||o[Wd]===e)&&(r?r.next=i:this._setListeners(n,i)),r=t,t=i};function Qu(){}Qu.prototype.stopPropagation=function(){this.cancelBubble=!0};Qu.prototype.preventDefault=function(){this.defaultPrevented=!0};Qu.prototype.init=function(n){T(this,n||{})};function ZD(n,e){return n.apply(null,e)}function Jy(){}Jy.prototype.get=function(n){return this.$model.properties.get(this,n)};Jy.prototype.set=function(n,e){this.$model.properties.set(this,n,e)};function qw(n,e){this.model=n,this.properties=e}qw.prototype.createType=function(n){var e=this.model,t=this.properties,i=Object.create(Jy.prototype);k(n.properties,function(s){!s.isMany&&s.default!==void 0&&(i[s.name]=s.default)}),t.defineModel(i,e),t.defineDescriptor(i,n);var r=n.ns.name;function o(s){t.define(this,"$type",{value:r,enumerable:!0}),t.define(this,"$attrs",{value:{}}),t.define(this,"$parent",{writable:!0}),k(s,at(function(a,l){this.set(l,a)},this))}return o.prototype=i,o.hasType=i.$instanceOf=this.model.hasType,t.defineModel(o,e),t.defineDescriptor(o,n),o};var JD={String:!0,Boolean:!0,Integer:!0,Real:!0,Element:!0},Vw={String:function(n){return n},Boolean:function(n){return n==="true"},Integer:function(n){return parseInt(n,10)},Real:function(n){return parseFloat(n)}};function Ud(n,e){var t=Vw[n];return t?t(e):e}function Yy(n){return!!JD[n]}function ev(n){return!!Vw[n]}function Rt(n,e){var t=n.split(/:/),i,r;if(t.length===1)i=n,r=e;else if(t.length===2)i=t[1],r=t[0];else throw new Error("expected <prefix:localName> or <localName>, got "+n);return n=(r?r+":":"")+i,{name:n,prefix:r,localName:i}}function Cn(n){this.ns=n,this.name=n.name,this.allTypes=[],this.allTypesByName={},this.properties=[],this.propertiesByName={}}Cn.prototype.build=function(){return hn(this,["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"])};Cn.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)};Cn.prototype.replaceProperty=function(n,e,t){var i=n.ns,r=this.properties,o=this.propertiesByName,s=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,s),o[i.name]=o[i.localName]=e};Cn.prototype.redefineProperty=function(n,e,t){var i=n.ns.prefix,r=e.split("#"),o=Rt(r[0],i),s=Rt(r[1],o.prefix).name,a=this.propertiesByName[s];if(a)this.replaceProperty(a,n,t);else throw new Error("refined property <"+s+"> not found");delete n.redefines};Cn.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};Cn.prototype.removeNamedProperty=function(n){var e=n.ns,t=this.propertiesByName;delete t[e.name],delete t[e.localName]};Cn.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};Cn.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};Cn.prototype.assertNotTrait=function(n){if((n.extends||[]).length)throw new Error(`cannot create <${n.name}> extending <${n.extends}>`)};Cn.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")};Cn.prototype.hasProperty=function(n){return this.propertiesByName[n]};Cn.prototype.addTrait=function(n,e){e&&this.assertNotTrait(n);var t=this.allTypesByName,i=this.allTypes,r=n.name;r in t||(k(n.properties,at(function(o){o=T({},o,{name:o.ns.localName,inherited:e}),Object.defineProperty(o,"definedBy",{value:n});var s=o.replaces,a=o.redefines;s||a?this.redefineProperty(o,s||a,s):(o.isBody&&this.setBodyProperty(o),o.isId&&this.setIdProperty(o),this.addProperty(o))},this)),i.push(n),t[r]=n)};function Jr(n,e){this.packageMap={},this.typeMap={},this.packages=[],this.properties=e,k(n,at(this.registerPackage,this))}Jr.prototype.getPackage=function(n){return this.packageMap[n]};Jr.prototype.getPackages=function(){return this.packages};Jr.prototype.registerPackage=function(n){n=T({},n);var e=this.packageMap;Fw(e,n,"prefix"),Fw(e,n,"uri"),k(n.types,at(function(t){this.registerType(t,n)},this)),e[n.uri]=e[n.prefix]=n,this.packages.push(n)};Jr.prototype.registerType=function(n,e){n=T({},n,{superClass:(n.superClass||[]).slice(),extends:(n.extends||[]).slice(),properties:(n.properties||[]).slice(),meta:T(n.meta||{})});var t=Rt(n.name,e.prefix),i=t.name,r={};k(n.properties,at(function(o){var s=Rt(o.name,t.prefix),a=s.name;Yy(o.type)||(o.type=Rt(o.type,s.prefix).name),T(o,{ns:s,name:a}),r[a]=o},this)),T(n,{ns:t,name:i,propertiesByName:r}),k(n.extends,at(function(o){var s=Rt(o,t.prefix),a=this.typeMap[s.name];a.traits=a.traits||[],a.traits.push(i)},this)),this.definePackage(n,e),this.typeMap[i]=n};Jr.prototype.mapTypes=function(n,e,t){var i=Yy(n.name)?{name:n.name}:this.typeMap[n.name],r=this;function o(l,c){var u=Rt(l,Yy(l)?"":n.prefix);r.mapTypes(u,e,c)}function s(l){return o(l,!0)}function a(l){return o(l,!1)}if(!i)throw new Error("unknown type <"+n.name+">");k(i.superClass,t?s:a),e(i,!t),k(i.traits,s)};Jr.prototype.getEffectiveDescriptor=function(n){var e=Rt(n),t=new Cn(e);this.mapTypes(e,function(r,o){t.addTrait(r,o)});var i=t.build();return this.definePackage(i,i.allTypes[i.allTypes.length-1].$pkg),i};Jr.prototype.definePackage=function(n,e){this.properties.define(n,"$pkg",{value:e})};function Fw(n,e,t){var i=e[t];if(i in n)throw new Error("package with "+t+" <"+i+"> already defined")}function es(n){this.model=n}es.prototype.set=function(n,e,t){if(!Ie(e)||!e.length)throw new TypeError("property name must be a non-empty string");var i=this.getProperty(n,e),r=i&&i.name;eI(t)?i?delete n[r]:delete n.$attrs[Zy(e)]:i?r in n?n[r]=t:Hw(n,i,t):n.$attrs[Zy(e)]=t};es.prototype.get=function(n,e){var t=this.getProperty(n,e);if(!t)return n.$attrs[Zy(e)];var i=t.name;return!n[i]&&t.isMany&&Hw(n,t,[]),n[i]};es.prototype.define=function(n,e,t){if(!t.writable){var i=t.value;t=T({},t,{get:function(){return i}}),delete t.value}Object.defineProperty(n,e,t)};es.prototype.defineDescriptor=function(n,e){this.define(n,"$descriptor",{value:e})};es.prototype.defineModel=function(n,e){this.define(n,"$model",{value:e})};es.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 o=new TypeError(`unknown property <${e}> on <${n.$type}>`);if(r)throw o;typeof console!="undefined"&&console.warn(o)}return null};function eI(n){return typeof n=="undefined"}function Hw(n,e,t){Object.defineProperty(n,e.name,{enumerable:!e.isReference,writable:!0,value:t,configurable:!0})}function Zy(n){return n.replace(/^:/,"")}function dn(n,e={}){this.properties=new es(this),this.factory=new qw(this,this.properties),this.registry=new Jr(n,this.properties),this.typeCache={},this.config=e}dn.prototype.create=function(n,e){var t=this.getType(n);if(!t)throw new Error("unknown type <"+n+">");return new t(e)};dn.prototype.getType=function(n){var e=this.typeCache,t=Ie(n)?n:n.ns.name,i=e[t];return i||(n=this.registry.getEffectiveDescriptor(t),i=e[t]=this.factory.createType(n)),i};dn.prototype.createAny=function(n,e,t){var i=Rt(n),r={$type:n,$instanceOf:function(s){return s===this.$type},get:function(s){return this[s]},set:function(s,a){$w(this,[s],a)}},o={name:n,isGeneric:!0,ns:{prefix:i.prefix,localName:i.localName,uri:e}};return this.properties.defineDescriptor(r,o),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}),k(t,function(s,a){Pe(s)&&s.value!==void 0?r[s.name]=s.value:r[a]=s}),r};dn.prototype.getPackage=function(n){return this.registry.getPackage(n)};dn.prototype.getPackages=function(){return this.registry.getPackages()};dn.prototype.getElementDescriptor=function(n){return n.$descriptor};dn.prototype.hasType=function(n,e){e===void 0&&(e=n,n=this);var t=n.$model.getElementDescriptor(n);return e in t.allTypesByName};dn.prototype.getPropertyDescriptor=function(n,e){return this.getElementDescriptor(n).propertiesByName[e]};dn.prototype.getTypeDescriptor=function(n){return this.registry.typeMap[n]};var zw=String.fromCharCode,tI=Object.prototype.hasOwnProperty,nI=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/ig,Ku={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};Object.keys(Ku).forEach(function(n){Ku[n.toUpperCase()]=Ku[n]});function iI(n,e,t,i){return i?tI.call(Ku,i)?Ku[i]:"&"+i+";":zw(e||parseInt(t,16))}function ts(n){return n.length>3&&n.indexOf("&")!==-1?n.replace(nI,iI):n}var Ww="non-whitespace outside of root node";function ca(n){return new Error(n)}function Uw(n){return"missing namespace for prefix <"+n+">"}function Qd(n){return{get:n,enumerable:!0}}function rI(n){var e={},t;for(t in n)e[t]=n[t];return e}function tv(n){return n+"$uri"}function oI(n){var e={},t,i;for(t in n)i=n[t],e[i]=i,e[tv(i)]=t;return e}function Qw(){return{line:0,column:0}}function sI(n){throw n}function nv(n){if(!this)return new nv(n);var e=n&&n.proxy,t,i,r,o,s=sI,a,l,c,u,f=Qw,h=!1,d=!1,p=null,m=!1,g;function b(x){x instanceof Error||(x=ca(x)),p=x,s(x,f)}function _(x){a&&(x instanceof Error||(x=ca(x)),a(x,f))}this.on=function(x,C){if(typeof C!="function")throw ca("required args <name, cb>");switch(x){case"openTag":i=C;break;case"text":t=C;break;case"closeTag":r=C;break;case"error":s=C;break;case"warn":a=C;break;case"cdata":o=C;break;case"attention":u=C;break;case"question":c=C;break;case"comment":l=C;break;default:throw ca("unsupported event: "+x)}return this},this.ns=function(x){if(typeof x=="undefined"&&(x={}),typeof x!="object")throw ca("required args <nsMap={}>");var C={},E;for(E in x)C[E]=x[E];return d=!0,g=C,this},this.parse=function(x){if(typeof x!="string")throw ca("required args <xml=string>");return p=null,v(x),f=Qw,m=!1,p},this.stop=function(){m=!0};function v(x){var C=d?[]:null,E=d?oI(g):null,S,w=[],R=0,A=!1,I=!1,D=0,N=0,W,Re,_e,ue,re,me,Ue,$e,Ct,Nt="",fn=0,ct;function Ti(){if(ct!==null)return ct;var fi,$n,jn,ar=d&&E.xmlns,lr=d&&h?[]:null,Je=fn,$t=Nt,Jo=$t.length,Tw,Xr,cr,Ai,Ae,aa={},Aw={},hi,oe,Oe;e:for(;Je<Jo;Je++)if(hi=!1,oe=$t.charCodeAt(Je),!(oe===32||oe<14&&oe>8)){for((oe<65||oe>122||oe>90&&oe<97)&&oe!==95&&oe!==58&&(_("illegal first char attribute name"),hi=!0),Oe=Je+1;Oe<Jo;Oe++)if(oe=$t.charCodeAt(Oe),!(oe>96&&oe<123||oe>64&&oe<91||oe>47&&oe<59||oe===46||oe===45||oe===95)){if(oe===32||oe<14&&oe>8){_("missing attribute value"),Je=Oe;continue e}if(oe===61)break;_("illegal attribute name char"),hi=!0}if(Ae=$t.substring(Je,Oe),Ae==="xmlns:xmlns"&&(_("illegal declaration of xmlns"),hi=!0),oe=$t.charCodeAt(Oe+1),oe===34)Oe=$t.indexOf('"',Je=Oe+2),Oe===-1&&(Oe=$t.indexOf("'",Je),Oe!==-1&&(_("attribute value quote missmatch"),hi=!0));else if(oe===39)Oe=$t.indexOf("'",Je=Oe+2),Oe===-1&&(Oe=$t.indexOf('"',Je),Oe!==-1&&(_("attribute value quote missmatch"),hi=!0));else for(_("missing attribute value quotes"),hi=!0,Oe=Oe+1;Oe<Jo&&(oe=$t.charCodeAt(Oe+1),!(oe===32||oe<14&&oe>8));Oe++);for(Oe===-1&&(_("missing closing quotes"),Oe=Jo,hi=!0),hi||(cr=$t.substring(Je,Oe)),Je=Oe;Oe+1<Jo&&(oe=$t.charCodeAt(Oe+1),!(oe===32||oe<14&&oe>8));Oe++)Je===Oe&&(_("illegal character after attribute end"),hi=!0);if(Je=Oe+1,hi)continue e;if(Ae in Aw){_("attribute <"+Ae+"> already defined");continue}if(Aw[Ae]=!0,!d){aa[Ae]=cr;continue}if(h){if(Xr=Ae==="xmlns"?"xmlns":Ae.charCodeAt(0)===120&&Ae.substr(0,6)==="xmlns:"?Ae.substr(6):null,Xr!==null){if(fi=ts(cr),$n=tv(Xr),Ai=g[fi],!Ai){if(Xr==="xmlns"||$n in E&&E[$n]!==fi)do Ai="ns"+R++;while(typeof E[Ai]!="undefined");else Ai=Xr;g[fi]=Ai}E[Xr]!==Ai&&(Tw||(E=rI(E),Tw=!0),E[Xr]=Ai,Xr==="xmlns"&&(E[tv(Ai)]=fi,ar=Ai),E[$n]=fi),aa[Ae]=cr;continue}lr.push(Ae,cr);continue}if(oe=Ae.indexOf(":"),oe===-1){aa[Ae]=cr;continue}if(!(jn=E[Ae.substring(0,oe)])){_(Uw(Ae.substring(0,oe)));continue}Ae=ar===jn?Ae.substr(oe+1):jn+Ae.substr(oe),aa[Ae]=cr}if(h)for(Je=0,Jo=lr.length;Je<Jo;Je++){if(Ae=lr[Je++],cr=lr[Je],oe=Ae.indexOf(":"),oe!==-1){if(!(jn=E[Ae.substring(0,oe)])){_(Uw(Ae.substring(0,oe)));continue}Ae=ar===jn?Ae.substr(oe+1):jn+Ae.substr(oe)}aa[Ae]=cr}return ct=aa}function Zo(){for(var fi=/(\r\n|\r|\n)/g,$n=0,jn=0,ar=0,lr=N,Je,$t;D>=ar&&(Je=fi.exec(x),!(!Je||(lr=Je[0].length+Je.index,lr>D)));)$n+=1,ar=lr;return D==-1?(jn=lr,$t=x.substring(N)):N===0?$t=x.substring(N,D):(jn=D-ar,$t=N==-1?x.substring(D):x.substring(D,N+1)),{data:$t,line:$n,column:jn}}for(f=Zo,e&&(Ct=Object.create({},{name:Qd(function(){return Ue}),originalName:Qd(function(){return $e}),attrs:Qd(Ti),ns:Qd(function(){return E})}));N!==-1;){if(x.charCodeAt(N)===60?D=N:D=x.indexOf("<",N),D===-1){if(w.length)return b("unexpected end of file");if(N===0)return b("missing start tag");N<x.length&&x.substring(N).trim()&&_(Ww);return}if(N!==D){if(w.length){if(t&&(t(x.substring(N,D),ts,f),m))return}else if(x.substring(N,D).trim()&&(_(Ww),m))return}if(ue=x.charCodeAt(D+1),ue===33){if(_e=x.charCodeAt(D+2),_e===91&&x.substr(D+3,6)==="CDATA["){if(N=x.indexOf("]]>",D),N===-1)return b("unclosed cdata");if(o&&(o(x.substring(D+9,N),f),m))return;N+=3;continue}if(_e===45&&x.charCodeAt(D+3)===45){if(N=x.indexOf("-->",D),N===-1)return b("unclosed comment");if(l&&(l(x.substring(D+4,N),ts,f),m))return;N+=3;continue}}if(ue===63){if(N=x.indexOf("?>",D),N===-1)return b("unclosed question");if(c&&(c(x.substring(D,N+2),f),m))return;N+=2;continue}for(W=D+1;;W++){if(re=x.charCodeAt(W),isNaN(re))return N=-1,b("unclosed tag");if(re===34)_e=x.indexOf('"',W+1),W=_e!==-1?_e:W;else if(re===39)_e=x.indexOf("'",W+1),W=_e!==-1?_e:W;else if(re===62){N=W;break}}if(ue===33){if(u&&(u(x.substring(D,N+1),ts,f),m))return;N+=1;continue}if(ct={},ue===47){if(A=!1,I=!0,!w.length)return b("missing open tag");if(W=Ue=w.pop(),_e=D+2+W.length,x.substring(D+2,_e)!==W)return b("closing tag mismatch");for(;_e<N;_e++)if(ue=x.charCodeAt(_e),!(ue===32||ue>8&&ue<14))return b("close tag")}else{if(x.charCodeAt(N-1)===47?(W=Ue=x.substring(D+1,N-1),A=!0,I=!0):(W=Ue=x.substring(D+1,N),A=!0,I=!1),!(ue>96&&ue<123||ue>64&&ue<91||ue===95||ue===58))return b("illegal first char nodeName");for(_e=1,Re=W.length;_e<Re;_e++)if(ue=W.charCodeAt(_e),!(ue>96&&ue<123||ue>64&&ue<91||ue>47&&ue<59||ue===45||ue===95||ue==46)){if(ue===32||ue<14&&ue>8){Ue=W.substring(0,_e),ct=null;break}return b("invalid nodeName")}I||w.push(Ue)}if(d){if(S=E,A&&(I||C.push(S),ct===null&&(h=W.indexOf("xmlns",_e)!==-1)&&(fn=_e,Nt=W,Ti(),h=!1)),$e=Ue,ue=Ue.indexOf(":"),ue!==-1){if(me=E[Ue.substring(0,ue)],!me)return b("missing namespace on <"+$e+">");Ue=Ue.substr(ue+1)}else me=E.xmlns;me&&(Ue=me+":"+Ue)}if(A&&(fn=_e,Nt=W,i&&(e?i(Ct,ts,I,f):i(Ue,Ti,ts,I,f),m)))return;if(I){if(r&&(r(e?Ct:Ue,ts,A,f),m))return;d&&(A?E=S:E=C.pop())}N+=1}}}function Kw(n){return n.xml&&n.xml.tagAlias==="lowerCase"}var iv={xsi:"http://www.w3.org/2001/XMLSchema-instance",xml:"http://www.w3.org/XML/1998/namespace"},Gw="property";function Xw(n){return n.xml&&n.xml.serialize}function aI(n){let e=Xw(n);return e!==Gw&&(e||null)}function lI(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Yw(n,e){return Kw(e)?n.prefix+":"+lI(n.localName):n.name}function cI(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 uI(n,e,t){let i=Rt(n,e.xmlns),r=`${e[i.prefix]||i.prefix}:${i.localName}`,o=Rt(r);var s=t.getPackage(o.prefix);return cI(o,s)}function eo(n){return new Error(n)}function fr(n){return n.$descriptor}function fI(n){T(this,n),this.elementsById={},this.references=[],this.warnings=[],this.addReference=function(e){this.references.push(e)},this.addElement=function(e){if(!e)throw eo("expected element");var t=this.elementsById,i=fr(e),r=i.idProperty,o;if(r&&(o=e.get(r.name),o)){if(!/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i.test(o))throw new Error("illegal ID <"+o+">");if(t[o])throw eo("duplicate ID <"+o+">");t[o]=e}},this.addWarning=function(e){this.warnings.push(e)}}function Gu(){}Gu.prototype.handleEnd=function(){};Gu.prototype.handleText=function(){};Gu.prototype.handleNode=function(){};function rv(){}rv.prototype=Object.create(Gu.prototype);rv.prototype.handleNode=function(){return this};function fa(){}fa.prototype=Object.create(Gu.prototype);fa.prototype.handleText=function(n){this.body=(this.body||"")+n};function Xu(n,e){this.property=n,this.context=e}Xu.prototype=Object.create(fa.prototype);Xu.prototype.handleNode=function(n){if(this.element)throw eo("expected no sub nodes");return this.element=this.createReference(n),this};Xu.prototype.handleEnd=function(){this.element.id=this.body};Xu.prototype.createReference=function(n){return{property:this.property.ns.name,id:""}};function ov(n,e){this.element=e,this.propertyDesc=n}ov.prototype=Object.create(fa.prototype);ov.prototype.handleEnd=function(){var n=this.body||"",e=this.element,t=this.propertyDesc;n=Ud(t.type,n),t.isMany?e.get(t.name).push(n):e.set(t.name,n)};function Kd(){}Kd.prototype=Object.create(fa.prototype);Kd.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 Ht(n,e,t){this.model=n,this.type=n.getType(e),this.context=t}Ht.prototype=Object.create(Kd.prototype);Ht.prototype.addReference=function(n){this.context.addReference(n)};Ht.prototype.handleText=function(n){var e=this.element,t=fr(e),i=t.bodyProperty;if(!i)throw eo("unexpected body text <"+n+">");fa.prototype.handleText.call(this,n)};Ht.prototype.handleEnd=function(){var n=this.body,e=this.element,t=fr(e),i=t.bodyProperty;i&&n!==void 0&&(n=Ud(i.type,n),e.set(i.name,n))};Ht.prototype.createElement=function(n){var e=n.attributes,t=this.type,i=fr(t),r=this.context,o=new t({}),s=this.model,a;return k(e,function(l,c){var u=i.propertiesByName[c],f;u&&u.isReference?u.isMany?(f=l.split(" "),k(f,function(h){r.addReference({element:o,property:u.ns.name,id:h})})):r.addReference({element:o,property:u.ns.name,id:l}):(u?l=Ud(u.type,l):c==="xmlns"?c=":"+c:(a=Rt(c,i.ns.prefix),s.getPackage(a.prefix)&&r.addWarning({message:"unknown attribute <"+c+">",element:o,property:c,value:l})),o.set(c,l))}),o};Ht.prototype.getPropertyForNode=function(n){var e=n.name,t=Rt(e),i=this.type,r=this.model,o=fr(i),s=t.name,a=o.propertiesByName[s];if(a&&!a.isAttr){let c=aI(a);if(c){let u=n.attributes[c];if(u){let f=uI(u,n.ns,r),h=r.getType(f);return T({},a,{effectiveType:fr(h).name})}}return a}var l=r.getPackage(t.prefix);if(l){let c=Yw(t,l),u=r.getType(c);if(a=ye(o.properties,function(f){return!f.isVirtual&&!f.isReference&&!f.isAttribute&&u.hasType(f.type)}),a)return T({},a,{effectiveType:fr(u).name})}else if(a=ye(o.properties,function(c){return!c.isReference&&!c.isAttribute&&c.type==="Element"}),a)return a;throw eo("unrecognized element <"+t.name+">")};Ht.prototype.toString=function(){return"ElementDescriptor["+fr(this.type).name+"]"};Ht.prototype.valueHandler=function(n,e){return new ov(n,e)};Ht.prototype.referenceHandler=function(n){return new Xu(n,this.context)};Ht.prototype.handler=function(n){return n==="Element"?new ua(this.model,n,this.context):new Ht(this.model,n,this.context)};Ht.prototype.handleChild=function(n){var e,t,i,r;if(e=this.getPropertyForNode(n),i=this.element,t=e.effectiveType||e.type,ev(t))return this.valueHandler(e,i);e.isReference?r=this.referenceHandler(e).handleNode(n):r=this.handler(t).handleNode(n);var o=r.element;return o!==void 0&&(e.isMany?i.get(e.name).push(o):i.set(e.name,o),e.isReference?(T(o,{element:i}),this.context.addReference(o)):o.$parent=i),r};function sv(n,e,t){Ht.call(this,n,e,t)}sv.prototype=Object.create(Ht.prototype);sv.prototype.createElement=function(n){var e=n.name,t=Rt(e),i=this.model,r=this.type,o=i.getPackage(t.prefix),s=o&&Yw(t,o)||e;if(!r.hasType(s))throw eo("unexpected element <"+n.originalName+">");return Ht.prototype.createElement.call(this,n)};function ua(n,e,t){this.model=n,this.context=t}ua.prototype=Object.create(Kd.prototype);ua.prototype.createElement=function(n){var e=n.name,t=Rt(e),i=t.prefix,r=n.ns[i+"$uri"],o=n.attributes;return this.model.createAny(e,r,o)};ua.prototype.handleChild=function(n){var e=new ua(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};ua.prototype.handleEnd=function(){this.body&&(this.element.$body=this.body)};function Gd(n){n instanceof dn&&(n={model:n}),T(this,{lax:!1},n)}Gd.prototype.fromXML=function(n,e,t){var i=e.rootHandler;e instanceof Ht?(i=e,e={}):typeof e=="string"?(i=this.handler(e),e={}):typeof i=="string"&&(i=this.handler(i));var r=this.model,o=this.lax,s=new fI(T({},e,{rootHandler:i})),a=new nv({proxy:!0}),l=hI();i.context=s,l.push(i);function c(C,E,S){var w=E(),R=w.line,A=w.column,I=w.data;I.charAt(0)==="<"&&I.indexOf(" ")!==-1&&(I=I.slice(0,I.indexOf(" "))+">");var D="unparsable content "+(I?I+" ":"")+`detected 9 line: `+R+` 10 column: `+A+` 11 nested error: `+C.message;if(S)return s.addWarning({message:D,error:C}),!0;throw eo(D)}function u(C,E){return c(C,E,!0)}function f(){var C=s.elementsById,E=s.references,S,w;for(S=0;w=E[S];S++){var R=w.element,A=C[w.id],I=fr(R).propertiesByName[w.property];if(A||s.addWarning({message:"unresolved reference <"+w.id+">",element:w.element,property:w.property,value:w.id}),I.isMany){var D=R.get(I.name),N=D.indexOf(w);N===-1&&(N=D.length),A?D[N]=A:D.splice(N,1)}else R.set(I.name,A)}}function h(){l.pop().handleEnd()}var d=/^<\?xml /i,p=/ encoding="([^"]+)"/i,m=/^utf-8$/i;function g(C){if(d.test(C)){var E=p.exec(C),S=E&&E[1];!S||m.test(S)||s.addWarning({message:"unsupported document encoding <"+S+">, falling back to UTF-8"})}}function b(C,E){var S=l.peek();try{l.push(S.handleNode(C))}catch(w){c(w,E,o)&&l.push(new rv)}}function _(C,E){try{l.peek().handleText(C)}catch(S){u(S,E)}}function v(C,E){C.trim()&&_(C,E)}var x=r.getPackages().reduce(function(C,E){return C[E.uri]=E.prefix,C},Object.entries(iv).reduce(function(C,[E,S]){return C[S]=E,C},r.config&&r.config.nsMap||{}));return a.ns(x).on("openTag",function(C,E,S,w){var R=C.attrs||{},A=Object.keys(R).reduce(function(D,N){var W=E(R[N]);return D[N]=W,D},{}),I={name:C.name,originalName:C.originalName,attributes:A,ns:C.ns};b(I,w)}).on("question",g).on("closeTag",h).on("cdata",_).on("text",function(C,E,S){v(E(C),S)}).on("error",c).on("warn",u),new Promise(function(C,E){var S;try{a.parse(n),f()}catch(D){S=D}var w=i.element;!S&&!w&&(S=eo("failed to parse document as <"+i.type.$descriptor.name+">"));var R=s.warnings,A=s.references,I=s.elementsById;return S?(S.warnings=R,E(S)):C({rootElement:w,elementsById:I,references:A,warnings:R})})};Gd.prototype.handler=function(n){return new sv(this.model,n)};function hI(){var n=[];return Object.defineProperty(n,"peek",{value:function(){return this[this.length-1]}}),n}var dI=`<?xml version="1.0" encoding="UTF-8"?> 12`,pI=/<|>|'|"|&|\n\r|\n/g,Zw=/<|>|&/g;function Pi(n){this.prefixMap={},this.uriMap={},this.used={},this.wellknown=[],this.custom=[],this.parent=n,this.defaultPrefixMap=n&&n.defaultPrefixMap||{}}Pi.prototype.mapDefaultPrefixes=function(n){this.defaultPrefixMap=n};Pi.prototype.defaultUriByPrefix=function(n){return this.defaultPrefixMap[n]};Pi.prototype.byUri=function(n){return this.uriMap[n]||this.parent&&this.parent.byUri(n)};Pi.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)};Pi.prototype.uriByPrefix=function(n){return this.prefixMap[n||"xmlns"]||this.parent&&this.parent.uriByPrefix(n)};Pi.prototype.mapPrefix=function(n,e){this.prefixMap[n||"xmlns"]=e};Pi.prototype.getNSKey=function(n){return n.prefix!==void 0?n.uri+"|"+n.prefix:n.uri};Pi.prototype.logUsed=function(n){var e=n.uri,t=this.getNSKey(n);this.used[t]=this.byUri(e),this.parent&&this.parent.logUsed(n)};Pi.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 mI(n){return n.charAt(0).toLowerCase()+n.slice(1)}function gI(n,e){return Kw(e)?mI(n):n}function Jw(n,e){n.super_=e,n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}})}function e1(n){return Ie(n)?n:(n.prefix?n.prefix+":":"")+n.localName}function yI(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 vI(n,e){return e.isGeneric?T({localName:e.ns.localName},n):T({localName:gI(e.ns.localName,e.$pkg)},n)}function xI(n,e){return T({localName:e.ns.localName},n)}function bI(n){var e=n.$descriptor;return Ee(e.properties,function(t){var i=t.name;if(t.isVirtual||!Zr(n,i))return!1;var r=n[i];return r===t.default||r===null?!1:t.isMany?r.length:!0})}var _I={"\n":"#10","\n\r":"#10",'"':"#34","'":"#39","<":"#60",">":"#62","&":"#38"},wI={"<":"lt",">":"gt","&":"amp"};function t1(n,e,t){return n=Ie(n)?n:""+n,n.replace(e,function(i){return"&"+t[i]+";"})}function CI(n){return t1(n,pI,_I)}function EI(n){return t1(n,Zw,wI)}function SI(n){return Ee(n,function(e){return e.isAttr})}function OI(n){return Ee(n,function(e){return!e.isAttr})}function av(n){this.tagName=n}av.prototype.build=function(n){return this.element=n,this};av.prototype.serializeTo=function(n){n.appendIndent().append("<"+this.tagName+">"+this.element.id+"</"+this.tagName+">").appendNewLine()};function ns(){}ns.prototype.serializeValue=ns.prototype.serializeTo=function(n){n.append(this.escape?EI(this.value):this.value)};ns.prototype.build=function(n,e){return this.value=e,n.type==="String"&&e.search(Zw)!==-1&&(this.escape=!0),this};function lv(n){this.tagName=n}Jw(lv,ns);lv.prototype.serializeTo=function(n){n.appendIndent().append("<"+this.tagName+">"),this.serializeValue(n),n.append("</"+this.tagName+">").appendNewLine()};function je(n,e){this.body=[],this.attrs=[],this.parent=n,this.propertyDescriptor=e}je.prototype.build=function(n){this.element=n;var e=n.$descriptor,t=this.propertyDescriptor,i,r,o=e.isGeneric;return o?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),o?this.parseGenericContainments(n):(r=bI(n),this.parseAttributes(SI(r)),this.parseContainments(OI(r))),this.parseGenericAttributes(n,i),this};je.prototype.nsTagName=function(n){var e=this.logNamespaceUsed(n.ns);return vI(e,n)};je.prototype.nsPropertyTagName=function(n){var e=this.logNamespaceUsed(n.ns);return xI(e,n)};je.prototype.isLocalNs=function(n){return n.uri===this.ns.uri};je.prototype.nsAttributeName=function(n){var e;if(Ie(n)?e=Rt(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}:T({localName:e.localName},t)};je.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}))};je.prototype.parseGenericContainments=function(n){var e=n.$body;e&&this.body.push(new ns().build({type:"String"},e));var t=n.$children;t&&k(t,i=>{this.body.push(new je(this).build(i))})};je.prototype.parseNsAttribute=function(n,e,t){var i=n.$model,r=Rt(e),o;if(r.prefix==="xmlns"&&(o={prefix:r.localName,uri:t}),!r.prefix&&r.localName==="xmlns"&&(o={uri:t}),!o)return{name:e,value:t};if(i&&i.getPackage(t))this.logNamespace(o,!0,!0);else{var s=this.logNamespaceUsed(o,!0);this.getNamespaces().logUsed(s)}};je.prototype.parseNsAttributes=function(n){var e=this,t=n.$attrs,i=[];return k(t,function(r,o){var s=e.parseNsAttribute(n,o,r);s&&i.push(s)}),i};je.prototype.parseGenericAttributes=function(n,e){var t=this;k(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)}})};je.prototype.parseContainments=function(n){var e=this,t=this.body,i=this.element;k(n,function(r){var o=i.get(r.name),s=r.isReference,a=r.isMany;if(a||(o=[o]),r.isBody)t.push(new ns().build(r,o[0]));else if(ev(r.type))k(o,function(c){t.push(new lv(e.addTagName(e.nsPropertyTagName(r))).build(r,c))});else if(s)k(o,function(c){t.push(new av(e.addTagName(e.nsPropertyTagName(r))).build(c))});else{var l=Xw(r);k(o,function(c){var u;l?l===Gw?u=new je(e,r):u=new Xd(e,r,l):u=new je(e),t.push(u.build(c))})}})};je.prototype.getNamespaces=function(n){var e=this.namespaces,t=this.parent,i;return e||(i=t&&t.getNamespaces(),n||!i?this.namespaces=e=new Pi(i):e=i),e};je.prototype.logNamespace=function(n,e,t){var i=this.getNamespaces(t),r=n.uri,o=n.prefix,s=i.byUri(r);return(!s||t)&&i.add(n,e),i.mapPrefix(o,r),n};je.prototype.logNamespaceUsed=function(n,e){var t=this.getNamespaces(e),i=n.prefix,r=n.uri,o,s,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(o=i,s=1;t.uriByPrefix(o);)o=i+"_"+s++;n=this.logNamespace({prefix:o,uri:r},a===r)}return i&&t.mapPrefix(i,r),n};je.prototype.parseAttributes=function(n){var e=this,t=this.element;k(n,function(i){var r=t.get(i.name);if(i.isReference)if(!i.isMany)r=r.id;else{var o=[];k(r,function(s){o.push(s.id)}),r=o.join(" ")}e.addAttribute(e.nsAttributeName(i),r)})};je.prototype.addTagName=function(n){var e=this.logNamespaceUsed(n);return this.getNamespaces().logUsed(e),e1(n)};je.prototype.addAttribute=function(n,e){var t=this.attrs;Ie(e)&&(e=CI(e));var i=Iw(t,function(o){return o.name.localName===n.localName&&o.name.uri===n.uri&&o.name.prefix===n.prefix}),r={name:n,value:e};i!==-1?t.splice(i,1,r):t.push(r)};je.prototype.serializeAttributes=function(n){var e=this.attrs,t=this.namespaces;t&&(e=yI(t).concat(e)),k(e,function(i){n.append(" ").append(e1(i.name)).append('="').append(i.value).append('"')})};je.prototype.serializeTo=function(n){var e=this.body[0],t=e&&e.constructor!==ns;n.appendIndent().append("<"+this.tagName),this.serializeAttributes(n),n.append(e?">":" />"),e&&(t&&n.appendNewLine().indent(),k(this.body,function(i){i.serializeTo(n)}),t&&n.unindent().appendIndent(),n.append("</"+this.tagName+">")),n.appendNewLine()};function Xd(n,e,t){je.call(this,n,e),this.serialization=t}Jw(Xd,je);Xd.prototype.parseNsAttributes=function(n){var e=je.prototype.parseNsAttributes.call(this,n).filter(s=>s.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),o=r.xml&&r.xml.typePrefix||"";return this.addAttribute(this.nsAttributeName(this.serialization),(i.prefix?i.prefix+":":"")+o+t.ns.localName),e};Xd.prototype.isLocalNs=function(n){return n.uri===(this.typeNs||this.ns).uri};function kI(){this.value="",this.write=function(n){this.value+=n}}function RI(n,e){var t=[""];this.append=function(i){return n.write(i),this},this.appendNewLine=function(){return e&&n.write(` 13`),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 n1(n){n=T({format:!1,preamble:!0},n||{});function e(t,i){var r=i||new kI,o=new RI(r,n.format);n.preamble&&o.append(dI);var s=new je,a=t.$model;if(s.getNamespaces().mapDefaultPrefixes(TI(a)),s.build(t).serializeTo(o),!i)return r.value}return{toXML:e}}function TI(n){let e=n.config&&n.config.nsMap||{},t={};for(let i in iv)t[i]=iv[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 Yd(n,e){dn.call(this,n,e)}Yd.prototype=Object.create(dn.prototype);Yd.prototype.fromXML=function(n,e,t){Ie(e)||(t=e,e="dmn:Definitions");var i=new Gd(T({model:this,lax:!0},t)),r=i.handler(e);return i.fromXML(n,r)};Yd.prototype.toXML=function(n,e){var t=new n1(e);return new Promise(function(i,r){try{var o=t.toXML(n);return i({xml:o})}catch(s){return r(s)}})};var AI="DC",MI="dc",PI="http://www.omg.org/spec/DMN/20180521/DC/",DI=[{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"}]}],II=[],LI=[{name:"AlignmentKind",literalValues:[{name:"start"},{name:"center"},{name:"end"}]}],BI={name:AI,prefix:MI,uri:PI,types:DI,associations:II,enumerations:LI},NI="DI",$I="di",jI="http://www.omg.org/spec/DMN/20180521/DI/",FI=[{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"}]}],qI=[],VI=[],HI={tagAlias:"lowerCase"},zI={name:NI,prefix:$I,uri:jI,types:FI,associations:qI,enumerations:VI,xml:HI},WI="DMN",UI="dmn",QI="https://www.omg.org/spec/DMN/20191111/MODEL/",KI=[{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"}]}],GI=[{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"}]}],XI=[],YI={tagAlias:"lowerCase"},ZI={name:WI,prefix:UI,uri:QI,types:KI,enumerations:GI,associations:XI,xml:YI},JI="DMNDI",eL="dmndi",tL="https://www.omg.org/spec/DMN/20191111/DMNDI/",nL=[{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"]}],iL=[],rL=[],oL={name:JI,prefix:eL,uri:tL,types:nL,associations:iL,enumerations:rL},sL="bpmn.io DI for DMN",aL="http://bpmn.io/schema/dmn/biodi/2.0",lL="biodi",cL={tagAlias:"lowerCase"},uL=[{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"}]}],fL={name:sL,uri:aL,prefix:lL,xml:cL,types:uL},hL={dc:BI,di:zI,dmn:ZI,dmndi:oL,biodi:fL};function i1(n,e){var t=T({},hL,n);return new Yd(t,e)}var yt={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};yt.td=yt.th=[3,"<table><tbody><tr>","</tr></tbody></table>"];yt.option=yt.optgroup=[1,'<select multiple="multiple">',"</select>"];yt.thead=yt.tbody=yt.colgroup=yt.caption=yt.tfoot=[1,"<table>","</table>"];yt.polyline=yt.ellipse=yt.polygon=yt.circle=yt.text=yt.line=yt.path=yt.rect=yt.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];function te(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,o,s]=Object.hasOwn(yt,i)?yt[i]:yt._default,a=e.createElement("div");for(a.innerHTML=o+n+s;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 dL(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 is(n,...e){let t=n.style;return k(e,function(i){i&&k(i,function(r,o){t[o]=r})}),n}function et(n,e,t){return arguments.length==2?n.getAttribute(e):t===null?n.removeAttribute(e):(n.setAttribute(e,t),n)}var pL=Object.prototype.toString;function ee(n){return new to(n)}function to(n){if(!n||!n.nodeType)throw new Error("A DOM element reference is required");this.el=n,this.list=n.classList}to.prototype.add=function(n){return this.list.add(n),this};to.prototype.remove=function(n){return pL.call(n)=="[object RegExp]"?this.removeMatching(n):(this.list.remove(n),this)};to.prototype.removeMatching=function(n){let e=this.array();for(let t=0;t<e.length;t++)n.test(e[t])&&this.remove(e[t]);return this};to.prototype.toggle=function(n,e){return typeof e!="undefined"?e!==this.list.toggle(n,e)&&this.list.toggle(n):this.list.toggle(n),this};to.prototype.array=function(){return Array.from(this.list)};to.prototype.has=to.prototype.contains=function(n){return this.list.contains(n)};function no(n){for(var e;e=n.firstChild;)n.removeChild(e);return n}function De(n,e,t){var i=t?n:n.parentNode;return i&&typeof i.closest=="function"&&i.closest(e)||null}function mL(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Zd={},r1;function gL(){if(r1)return Zd;r1=1;var n,e,t;function i(){n=window.addEventListener?"addEventListener":"attachEvent",e=window.removeEventListener?"removeEventListener":"detachEvent",t=n!=="addEventListener"?"on":""}return Zd.bind=function(r,o,s,a){return n||i(),r[n](t+o,s,a||!1),s},Zd.unbind=function(r,o,s,a){return e||i(),r[e](t+o,s,a||!1),s},Zd}var o1=gL(),yL=mL(o1),q=dL({__proto__:null,default:yL},[o1]),s1=["focus","blur"];function vL(n,e,t,i,r){return s1.indexOf(t)!==-1&&(r=!0),q.bind(n,t,function(o){var s=o.target||o.srcElement;o.delegateTarget=De(s,e,!0),o.delegateTarget&&i.call(n,o)},r)}function xL(n,e,t,i){return s1.indexOf(e)!==-1&&(i=!0),q.unbind(n,e,t,i)}var _t={bind:vL,unbind:xL};function hr(n,e){return n&&typeof n.matches=="function"&&n.matches(e)||!1}function X(n,e){return e=e||document,e.querySelector(n)}function pn(n,e){return e=e||document,e.querySelectorAll(n)}function Qe(n){n.parentNode&&n.parentNode.removeChild(n)}function ha(n){return function(){if(!window.Promise)throw new Error("Promises is not supported in this environment. Please polyfill Promise.");var e=arguments.length;if(e>=1&&ge(arguments[e-1])){var t=arguments[e-1];console.warn(new Error("Passing callbacks to "+bL(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 o=Object.keys(r)[0];return t(null,r[o])},function(r){return t(r,r.warnings)})}else return n.apply(this,arguments)}}function bL(n){return n.replace("bound ","")}var _L={width:"100%",height:"100%",position:"relative"},rs=class{constructor(e={}){M(this,"_viewsChanged",()=>{this._emit("views.changed",{views:this._views,activeView:this._activeView})});this._eventBus=new ut,this._viewsChanged=Mi(this._viewsChanged,0),this._views=[],this._viewers={},this.open=ha(this.open.bind(this)),this.importXML=ha(this.importXML.bind(this)),this.saveXML=ha(this.saveXML.bind(this)),this._init(e)}importXML(e,t){var i=this;return t=t||{open:!0},new Promise(function(o,s){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}),o({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,s(p)}i.open(d).then(m=>({warnings:m.warnings})).catch(m=>({error:m,warnings:m.warnings})).then(m=>{var g=[].concat(l,m.warnings);i._emit("import.done",{error:m.error,warnings:g}),m.error?(m.error.warnings=g,s(m.error)):o({warnings:g})})}).catch(c=>(l=c.warnings,c=wL(c,e)||CL(c)||c,i._emit("import.parse.complete",r({error:c,warnings:l})),i._emit("import.done",{error:c,warnings:l}),c.warnings=l,s(c)))}).catch(l=>(i._emit("import.done",{error:l,warnings:[]}),l.warnings=[],s(l)))});function r(o){var s=i._eventBus.createEvent(o);return Object.defineProperty(s,"context",{enumerable:!0,get:function(){return console.warn(new Error("import.parse.complete <context> is deprecated and will be removed in future library versions")),{warnings:o.warnings,references:o.references,elementsById:o.elementsById}}}),s}}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,o){if(!i){o(new Error("no definitions loaded"));return}i=t._emit("saveXML.start",{definitions:i})||i,t._moddle.toXML(i,e).then(function(s){var a=s.xml;return a=t._emit("saveXML.serialized",{xml:a})||a,{xml:a}}).catch(s=>({error:s})).then(s=>{t._emit("saveXML.done",s),s.error?o(s.error):r({xml:s.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=X(e)),e.appendChild(this._container),this._emit("attach",{})}detach(){this._emit("detach",{}),Qe(this._container)}destroy(){Object.keys(this._viewers).forEach(e=>{var t=this._viewers[e];c1(t,"destroy")}),Qe(this._container)}_init(e){this._options=e,this._moddle=this._createModdle(e),this._viewers={},this._views=[];let t=te('<div class="dmn-js-parent"></div>'),i=T({},_L,e);T(t.style,{width:a1(i.width),height:a1(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,o=[];for(var s of i){var a=ye(t,function(d){return typeof d.opens=="string"?d.opens===s.$type:d.opens(s)});if(a){var l={element:s,id:s.id,name:s.name,type:a.id};o.push(l)}}var c=this._activeView,u;if(c&&(u=ye(o,function(d){return Jd(c,d)})||this._getInitialView(o),!u)){this._switchView(null);return}var f=!Jd(c,u)||l1(c,u),h=r.length!==o.length||!kt(o,function(d){return ye(r,function(p){return Jd(p,d)&&!l1(p,d)})});this._activeView=u,this._views=o,(f||h)&&this._viewsChanged()}_getInitialView(e,t){var i;return t&&(i=ye(e,function(r){return Jd(r,t)})||ye(e,function(r){return r.type===t})),i||e[0]}_switchView(e){var t=this;return new Promise(function(i,r){var o=(u,f)=>{t._viewsChanged(),u?r(u):i(f)},s=t.getActiveView(),a,l=e&&t._getViewer(e),c=e&&e.element;if(s&&(a=t._getViewer(s),a!==l&&(c1(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}),o(null,u)}).catch(u=>{t._emit("import.render.complete",{view:e,error:u,warnings:u.warnings}),o(u,null)});return}o()})}_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=ye(this._getViewProviders(),function(s){return s.id===e});if(!t)throw new Error("no provider for view type <"+e+">");var i=t.constructor,r=this._options[e]||{},o=this._options.common||{};return new i({...o,...r,additionalModules:[...r.additionalModules||[],{_parent:["value",this],moddle:["value",this._moddle]}]})}_emit(...e){return this._eventBus.fire(...e)}_createModdle(e){return new i1(e.moddleExtensions)}_getViewProviders(){return[]}};function a1(n){return n+(se(n)?"px":"")}function wL(n,e){if(n.message!=="failed to parse document as <dmn:Definitions>")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 CL(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 Jd(n,e){return Me(n)?Me(e)?n.element===e.element||n.id===e.id:!1:!Me(e)}function l1(n,e){return!n||!e||n.name!==e.name}function c1(n,e){ge(n[e])&&n[e]()}function EL(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var cv={exports:{}},u1;function SL(){if(u1)return cv.exports;u1=1;var n=cv.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 o=i-Math.floor(i),s="",r=0;r<Math.floor(i);r++){var a=Math.floor(Math.random()*t).toString(t);s=a+s}if(o){var l=Math.pow(t,o),a=Math.floor(Math.random()*l).toString(t);s=a+s}var c=parseInt(s,t);return c!==1/0&&c>=Math.pow(2,e)?n(e,t):s};return n.rack=function(e,t,i){var r=function(s){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(o,l));return o[l]=s,l},o=r.hats={};return r.get=function(s){return r.hats[s]},r.set=function(s,a){return r.hats[s]=a,r},r.bits=e||128,r.base=t||16,r},cv.exports}var OL=SL(),kL=EL(OL);function qn(n){if(!(this instanceof qn))return new qn(n);n=n||[128,36,1],this._seed=n.length?kL.rack(n[0],n[1],n[2]):n}qn.prototype.next=function(n){return this._seed(n||!0)};qn.prototype.nextPrefixed=function(n,e){var t;do t=n+this.next(!0);while(this.assigned(t));return this.claim(t,e),t};qn.prototype.claim=function(n,e){this._seed.set(n,e||!0)};qn.prototype.assigned=function(n){return this._seed.get(n)||!1};qn.prototype.unclaim=function(n){delete this._seed.hats[n]};qn.prototype.clear=function(){var n=this._seed.hats,e;for(e in n)this.unclaim(e)};function O(n,e){var t=Ke(n);return t&&typeof t.$instanceOf=="function"&&t.$instanceOf(e)}function ie(n){return O(n,"dmn:InputClause")}function Te(n){return O(n,"dmn:OutputClause")}function Ke(n){return n&&n.businessObject||n}function f1(n){return Ke(n).name}function Ge(n,e){return zd(e,function(t){return O(n,t)})}function dr(n){var e=Ke(n);if(O(e,"dmn:Decision"))return e.get("decisionLogic");if(O(e,"dmn:BusinessKnowledgeModel")){var t=e.get("encapsulatedLogic");return t&&t.get("body")}}var RL="https://www.omg.org/spec/DMN/20191111/FEEL/";function h1(n){for(let e=n;e;e=e.$parent){let t=e.get("expressionLanguage");if(t)return!!(t===RL||/feel/i.test(t));if(O(e,"dmn:FunctionDefinition"))return(e.get("kind")||"FEEL")==="FEEL"}return!0}var Yu=class extends rs{_init(e){super._init(e),this.on("import.parse.complete",t=>{t.error||this._collectIds(t.definitions,t.elementsById)}),this.on("destroy",()=>{this._moddle.ids.clear()}),this.on("viewer.created",({viewer:t})=>{t.on("elements.changed",({elements:i})=>{var r=i.some(function(o){return Ge(o,["dmn:Decision","dmn:Definitions","dmn:BusinessKnowledgeModel"])});r&&this._updateViews()})})}_collectIds(e,t){var i=e.$model,r=i.ids,o;r.clear();for(o in t)r.claim(o,t[o])}_createModdle(e){var t=super._createModdle(e);return t.ids=new qn([32,36,1]),t}};function fe(n,e){e&&(n.super_=e,n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}var TL=/^class[ {]/;function AL(n){return TL.test(n.toString())}function fv(n){return Array.isArray(n)}function uv(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function ep(...n){n.length===1&&fv(n[0])&&(n=n[0]),n=[...n];let e=n.pop();return e.$inject=n,e}var ML=/constructor\s*[^(]*\(\s*([^)]*)\)/m,PL=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,DL=/\/\*([^*]*)\*\//m;function IL(n){if(typeof n!="function")throw new Error(`Cannot annotate "${n}". Expected a function!`);let e=n.toString().match(AL(n)?ML:PL);if(!e)return[];let t=e[1]||e[2];return t&&t.split(",").map(i=>{let r=i.match(DL);return(r&&r[1]||i).trim()})||[]}function os(n,e){let t=e||{get:function(v,x){if(i.push(v),x===!1)return null;throw a(`No provider for "${v}"!`)}},i=[],r=this._providers=Object.create(t._providers||null),o=this._instances=Object.create(null),s=o.injector=this,a=function(v){let x=i.join(" -> ");return i.length=0,new Error(x?`${v} (Resolving: ${x})`:v)};function l(v,x){if(!r[v]&&v.includes(".")){let C=v.split("."),E=l(C.shift());for(;C.length;)E=E[C.shift()];return E}if(uv(o,v))return o[v];if(uv(r,v)){if(i.indexOf(v)!==-1)throw i.push(v),a("Cannot resolve circular dependency!");return i.push(v),o[v]=r[v][0](r[v][1]),i.pop(),o[v]}return t.get(v,x)}function c(v,x){if(typeof x=="undefined"&&(x={}),typeof v!="function")if(fv(v))v=ep(v.slice());else throw a(`Cannot invoke "${v}". Expected a function!`);let E=(v.$inject||IL(v)).map(S=>uv(x,S)?x[S]:l(S));return{fn:v,dependencies:E}}function u(v){let{fn:x,dependencies:C}=c(v),E=Function.prototype.bind.call(x,null,...C);return new E}function f(v,x,C){let{fn:E,dependencies:S}=c(v,C);return E.apply(x,S)}function h(v){return ep(x=>v.get(x))}function d(v,x){if(x&&x.length){let C=Object.create(null),E=Object.create(null),S=[],w=[],R=[],A,I,D,N;for(let W in r)A=r[W],x.indexOf(W)!==-1&&(A[2]==="private"?(I=S.indexOf(A[3]),I===-1?(D=A[3].createChild([],x),N=h(D),S.push(A[3]),w.push(D),R.push(N),C[W]=[N,W,"private",D]):C[W]=[R[I],W,"private",w[I]]):C[W]=[A[2],A[1]],E[W]=!0),(A[2]==="factory"||A[2]==="type")&&A[1].$scope&&x.forEach(Re=>{A[1].$scope.indexOf(Re)!==-1&&(C[W]=[A[2],A[1]],E[Re]=!0)});x.forEach(W=>{if(!E[W])throw new Error('No provider for "'+W+'". Cannot use provider from the parent!')}),v.unshift(C)}return new os(v,s)}let p={factory:f,type:u,value:function(v){return v}};function m(v,x){let C=v.__init__||[];return function(){C.forEach(E=>{typeof E=="string"?x.get(E):x.invoke(E)})}}function g(v){let x=v.__exports__;if(x){let C=v.__modules__,E=Object.keys(v).reduce((I,D)=>(D!=="__exports__"&&D!=="__modules__"&&D!=="__init__"&&D!=="__depends__"&&(I[D]=v[D]),I),Object.create(null)),S=(C||[]).concat(E),w=d(S),R=ep(function(I){return w.get(I)});x.forEach(function(I){r[I]=[R,I,"private",w]});let A=(v.__init__||[]).slice();return A.unshift(function(){w.init()}),v=Object.assign({},v,{__init__:A}),m(v,w)}return Object.keys(v).forEach(function(C){if(C==="__init__"||C==="__depends__")return;let E=v[C];if(E[2]==="private"){r[C]=E;return}let S=E[0],w=E[1];r[C]=[p[S],LL(S,w),S]}),m(v,s)}function b(v,x){return v.indexOf(x)!==-1||(v=(x.__depends__||[]).reduce(b,v),v.indexOf(x)!==-1)?v:v.concat(x)}function _(v){let x=v.reduce(b,[]).map(g),C=!1;return function(){C||(C=!0,x.forEach(E=>E()))}}this.get=l,this.invoke=f,this.instantiate=u,this.createChild=d,this.init=_(n)}function LL(n,e){return n!=="value"&&fv(e)&&(e=ep(e.slice())),e}var BL=1e3;function mn(n,e){var t=this;e=e||BL,n.on(["render.shape","render.connection"],e,function(i,r){var o=i.type,s=r.element,a=r.gfx,l=r.attrs;if(t.canRender(s))return o==="render.shape"?t.drawShape(a,s,l):t.drawConnection(a,s,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)})}mn.prototype.canRender=function(n){};mn.prototype.drawShape=function(n,e){};mn.prototype.drawConnection=function(n,e){};mn.prototype.getShapePath=function(n){};mn.prototype.getConnectionPath=function(n){};function NL(n,e){if(n.ownerDocument!==e.ownerDocument)try{return e.ownerDocument.importNode(n,!0)}catch{}return n}function g1(n,e){return e.appendChild(NL(n,e))}function K(n,e){return g1(e,n),n}var pv=2,y1={"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":pv,"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":pv,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function $L(n,e){return y1[e]?n.style[e]:n.getAttributeNS(null,e)}function v1(n,e,t){var i=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=y1[i];r?(r===pv&&typeof t=="number"&&(t=String(t)+"px"),n.style[i]=t):n.setAttributeNS(null,e,t)}function jL(n,e){var t=Object.keys(e),i,r;for(i=0,r;r=t[i];i++)v1(n,r,e[r])}function j(n,e,t){if(typeof e=="string")if(t!==void 0)v1(n,e,t);else return $L(n,e);else jL(n,e);return n}var FL=Object.prototype.toString;function ne(n){return new io(n)}function io(n){if(!n||!n.nodeType)throw new Error("A DOM element reference is required");this.el=n,this.list=n.classList}io.prototype.add=function(n){return this.list.add(n),this};io.prototype.remove=function(n){return FL.call(n)=="[object RegExp]"?this.removeMatching(n):(this.list.remove(n),this)};io.prototype.removeMatching=function(n){let e=this.array();for(let t=0;t<e.length;t++)n.test(e[t])&&this.remove(e[t]);return this};io.prototype.toggle=function(n,e){return typeof e!="undefined"?e!==this.list.toggle(n,e)&&this.list.toggle(n):this.list.toggle(n),this};io.prototype.array=function(){return Array.from(this.list)};io.prototype.has=io.prototype.contains=function(n){return this.list.contains(n)};function ss(n){for(var e;e=n.firstChild;)n.removeChild(e);return n}function gv(n){return n.cloneNode(!0)}var yv={svg:"http://www.w3.org/2000/svg"},d1='<svg xmlns="'+yv.svg+'"';function x1(n){var e=!1;n.substring(0,4)==="<svg"?n.indexOf(yv.svg)===-1&&(n=d1+n.substring(4)):(n=d1+">"+n+"</svg>",e=!0);var t=qL(n);if(!e)return t;for(var i=document.createDocumentFragment(),r=t.firstChild;r.firstChild;)i.appendChild(r.firstChild);return i}function qL(n){var e;return e=new DOMParser,e.async=!1,e.parseFromString(n,"text/xml")}function Q(n,e){var t;return n=n.trim(),n.charAt(0)==="<"?(t=x1(n).firstChild,t=document.importNode(t,!0)):t=document.createElementNS(yv.svg,n),e&&j(t,e),t}var hv=null;function mv(){return hv===null&&(hv=Q("svg")),hv}function p1(n,e){var t,i,r=Object.keys(e);for(t=0;i=r[t];t++)n[i]=e[i];return n}function b1(n,e,t,i,r,o){var s=mv().createSVGMatrix();switch(arguments.length){case 0:return s;case 1:return p1(s,n);case 6:return p1(s,{a:n,b:e,c:t,d:i,e:r,f:o})}}function da(n){return n?mv().createSVGTransformFromMatrix(n):mv().createSVGTransform()}var m1=/([&<>]{1})/g,VL=/([&<>\n\r"]{1})/g,HL={"&":"&","<":"<",">":">",'"':"'"};function dv(n,e){function t(i,r){return HL[r]||r}return n.replace(e,t)}function _1(n,e){var t,i,r,o,s;switch(n.nodeType){case 3:e.push(dv(n.textContent,m1));break;case 1:if(e.push("<",n.tagName),n.hasAttributes())for(r=n.attributes,t=0,i=r.length;t<i;++t)o=r.item(t),e.push(" ",o.name,'="',dv(o.value,VL),'"');if(n.hasChildNodes()){for(e.push(">"),s=n.childNodes,t=0,i=s.length;t<i;++t)_1(s.item(t),e);e.push("</",n.tagName,">")}else e.push("/>");break;case 8:e.push("<!--",dv(n.nodeValue,m1),"-->");break;case 4:e.push("<![CDATA[",n.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+n.nodeType)}return e}function zL(n,e){var t=x1(e);if(ss(n),!!e){UL(t)||(t=t.documentElement);for(var i=QL(t.childNodes),r=0;r<i.length;r++)g1(i[r],n)}}function WL(n){for(var e=n.firstChild,t=[];e;)_1(e,t),e=e.nextSibling;return t.join("")}function UL(n){return n.nodeName==="#document-fragment"}function w1(n,e){if(e!==void 0){try{zL(n,e)}catch(t){throw new Error("error parsing SVG: "+t.message)}return n}else return WL(n)}function QL(n){return Array.prototype.slice.call(n)}function Fe(n){var e=n.parentNode;return e&&e.removeChild(n),n}function KL(n,e){return e instanceof SVGMatrix?n.createSVGTransformFromMatrix(e):e}function GL(n,e){var t,i;for(n.clear(),t=0;i=e[t];t++)n.appendItem(KL(n,i))}function as(n,e){var t=n.transform.baseVal;return e&&(Array.isArray(e)||(e=[e]),GL(t,e)),t.consolidate()}function np(n){return n.flat().join(",").replace(/,?([A-Za-z]),?/g,"$1")}function XL(n){return["M",n.x,n.y]}function vv(n){return["L",n.x,n.y]}function YL(n,e,t){return["C",n.x,n.y,e.x,e.y,t.x,t.y]}function ZL(n,e){let t=n.length,i=[XL(n[0])];for(let r=1;r<t;r++){let o=n[r-1],s=n[r],a=n[r+1];if(!a||!e){i.push(vv(s));continue}let l=Math.min(e,xv(s.x-o.x,s.y-o.y),xv(a.x-s.x,a.y-s.y));if(!l){i.push(vv(s));continue}let c=tp(s,o,l),u=tp(s,o,l*.5),f=tp(s,a,l),h=tp(s,a,l*.5);i.push(vv(c)),i.push(YL(u,h,f))}return i}function tp(n,e,t){let i=e.x-n.x,r=e.y-n.y,o=xv(i,r),s=t/o;return{x:n.x+i*s,y:n.y+r*s}}function xv(n,e){return Math.sqrt(Math.pow(n,2)+Math.pow(e,2))}function ro(n,e,t){se(e)&&(t=e,e=null),e||(e={});let i=Q("path",e);return se(t)&&(i.dataset.cornerRadius=String(t)),bv(i,n)}function bv(n,e){let t=parseInt(n.dataset.cornerRadius,10)||0;return j(n,{d:np(ZL(e,t))}),n}function E1(n){return Ee(n,function(e){return!ye(n,function(t){return t!==e&&S1(e,t)})})}function S1(n,e){if(e){if(n===e)return e;if(n.parent)return S1(n.parent,e)}}function C1(n,e,t){var i=!t||n.indexOf(e)===-1;return i&&n.push(e),i}function _v(n,e,t){t=t||0,F(n)||(n=[n]),k(n,function(i,r){var o=e(i,r,t);F(o)&&o.length&&_v(o,e,t+1)})}function JL(n,e,t){var i=[],r=[];return _v(n,function(o,s,a){C1(i,o,e);var l=o.children;if((t===-1||a<t)&&l&&C1(r,l,e))return l}),i}function O1(n,e){return JL(n,!e,-1)}function k1(n,e,t){Hu(e)&&(e=!0),Pe(e)&&(t=e,e=!0),t=t||{};var i=Zu(t.allShapes),r=Zu(t.allConnections),o=Zu(t.enclosedElements),s=Zu(t.enclosedConnections),a=Zu(t.topLevel,e&&ur(n,function(u){return u.id}));function l(u){a[u.source.id]&&a[u.target.id]&&(a[u.id]=[u]),i[u.source.id]&&i[u.target.id]&&(s[u.id]=o[u.id]=u),r[u.id]=u}function c(u){if(o[u.id]=u,u.waypoints)s[u.id]=r[u.id]=u;else return i[u.id]=u,k(u.incoming,l),k(u.outgoing,l),u.children}return _v(n,c),{allShapes:i,allConnections:r,topLevel:a,enclosedConnections:s,enclosedElements:o}}function Tt(n,e){e=!!e,F(n)||(n=[n]);var t,i,r,o;return k(n,function(s){var a=s;s.waypoints&&!e&&(a=Tt(s.waypoints,!0));var l=a.x,c=a.y,u=a.height||0,f=a.width||0;(l<t||t===void 0)&&(t=l),(c<i||i===void 0)&&(i=c),(l+f>r||r===void 0)&&(r=l+f),(c+u>o||o===void 0)&&(o=c+u)}),{x:t,y:i,height:o-i,width:r-t}}function wv(n,e){var t={};return k(n,function(i){var r=i;r.waypoints&&(r=Tt(r)),!se(e.y)&&r.x>e.x&&(t[i.id]=i),!se(e.x)&&r.y>e.y&&(t[i.id]=i),r.x>e.x&&r.y>e.y&&(se(e.width)&&se(e.height)&&r.width+r.x<e.width+e.x&&r.height+r.y<e.height+e.y||!se(e.width)||!se(e.height))&&(t[i.id]=i)}),t}function ip(n){return"waypoints"in n?"connection":"x"in n?"shape":"root"}function rp(n){return!!(n&&n.isFrame)}function Zu(n,e){return T({},n||{},e||{})}var eB=1;function Di(n,e){mn.call(this,n,eB),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})}fe(Di,mn);Di.prototype.canRender=function(){return!0};Di.prototype.drawShape=function(e,t,i){var r=Q("rect");return j(r,{x:0,y:0,width:t.width||0,height:t.height||0}),rp(t)?j(r,T({},this.FRAME_STYLE,i||{})):j(r,T({},this.SHAPE_STYLE,i||{})),K(e,r),r};Di.prototype.drawConnection=function(e,t,i){var r=ro(t.waypoints,T({},this.CONNECTION_STYLE,i||{}));return K(e,r),r};Di.prototype.getShapePath=function(e){var t=e.x,i=e.y,r=e.width,o=e.height,s=[["M",t,i],["l",r,0],["l",0,o],["l",-r,0],["z"]];return np(s)};Di.prototype.getConnectionPath=function(e){var t=e.waypoints,i,r,o=[];for(i=0;r=t[i];i++)r=r.original||r,o.push([i===0?"M":"L",r.x,r.y]);return np(o)};Di.$inject=["eventBus","styles"];function Cv(){var n={"no-fill":{fill:"none"},"no-border":{strokeOpacity:0},"no-events":{pointerEvents:"none"}},e=this;this.cls=function(t,i,r){var o=this.style(i,r);return T(o,{class:t})},this.style=function(t,i){!F(t)&&!i&&(i=t,t=[]);var r=st(t,function(o,s){return T(o,n[s]||{})},{});return i?T(r,i):r},this.computeStyle=function(t,i,r){return F(i)||(r=i,i=[]),e.style(i||[],T({},r,t||{}))}}var R1={__init__:["defaultRenderer"],defaultRenderer:["type",Di],styles:["type",Cv]};function Vn(n,e){if(!n||!e)return-1;var t=n.indexOf(e);return t!==-1&&n.splice(t,1),t}function zt(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)}}function op(n,e){return!n||!e?-1:n.indexOf(e)}function pa(n,e){return!n||!e?-1:Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function sp(n,e,t,i){if(typeof i=="undefined"&&(i=5),!n||!e||!t)return!1;var r=(e.x-n.x)*(t.y-n.y)-(e.y-n.y)*(t.x-n.x),o=pa(n,e);return Math.abs(r/o)<=i}var tB=2;function pr(n,e){var t=Array.from(arguments).flat();let i={x:"v",y:"h"};for(let[r,o]of Object.entries(i))if(nB(r,t))return o;return!1}function nB(n,e){let t=e[0];return kt(e,function(i){return Math.abs(t[n]-i[n])<=tB})}function Ju(n,e){return{x:Math.round(n.x+(e.x-n.x)/2),y:Math.round(n.y+(e.y-n.y)/2)}}var iB=/,?([a-z]),?/gi,T1=parseFloat,ft=Math,oo=ft.PI,Ii=ft.min,Li=ft.max,A1=ft.pow,ao=ft.abs,rB=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/ig,oB=/(-?\d*\.?\d*(?:e[-+]?\d+)?)[\s]*,?[\s]*/ig,M1=Array.isArray||function(n){return n instanceof Array};function sB(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function aB(n,e){for(var t=0,i=n.length;t<i;t++)if(n[t]===e)return n.push(n.splice(t,1)[0])}function lB(n){function e(){var t=Array.prototype.slice.call(arguments,0),i=t.join("\u2400"),r=e.cache=e.cache||{},o=e.count=e.count||[];return sB(r,i)?(aB(o,i),r[i]):(o.length>=1e3&&delete r[o.shift()],o.push(i),r[i]=n(...arguments),r[i])}return e}function cB(n){if(!n)return null;var e={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=[];return String(n).replace(rB,function(i,r,o){var s=[],a=r.toLowerCase();for(o.replace(oB,function(l,c){c&&s.push(+c)}),a=="m"&&s.length>2&&(t.push([r,...s.splice(0,2)]),a="l",r=r=="m"?"l":"L");s.length>=e[a]&&(t.push([r,...s.splice(0,e[a])]),!!e[a]););}),t.toString=Sv,t}function uB(n){for(var e=0,t=n.length;e<t;e++){var i=n[e][0];if(typeof i=="string"&&i!==i.toUpperCase())return!1}return!0}function fB(n){for(var e=0,t=n.length;e<t;e++){var i=n[e][0];if(i!=="M"&&i!=="C")return!1}return!0}function Ev(n,e,t,i){return arguments.length===1&&(e=n.y,t=n.width,i=n.height,n=n.x),{x:n,y:e,width:t,height:i,x2:n+t,y2:e+i}}function Sv(){return this.join(",").replace(iB,"$1")}function hB(n){for(var e=new Array(n.length),t=0,i=n.length;t<i;t++)for(var r=n[t],o=e[t]=new Array(r.length),s=0,a=r.length;s<a;s++)o[s]=r[s];return e.toString=Sv,e}function P1(n,e,t,i,r,o,s,a,l){var c=1-l,u=A1(c,3),f=A1(c,2),h=l*l,d=h*l,p=u*n+f*3*l*t+c*3*l*l*r+d*s,m=u*e+f*3*l*i+c*3*l*l*o+d*a;return{x:lp(p),y:lp(m)}}function D1(n){var e=vB(...n);return Ev(e.x0,e.y0,e.x1-e.x0,e.y1-e.y0)}function so(n,e,t){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function dB(n,e){return n=Ev(n),e=Ev(e),so(e,n.x,n.y)||so(e,n.x2,n.y)||so(e,n.x,n.y2)||so(e,n.x2,n.y2)||so(n,e.x,e.y)||so(n,e.x2,e.y)||so(n,e.x,e.y2)||so(n,e.x2,e.y2)||(n.x<e.x2&&n.x>e.x||e.x<n.x2&&e.x>n.x)&&(n.y<e.y2&&n.y>e.y||e.y<n.y2&&e.y>n.y)}function I1(n,e,t,i,r){var o=-3*e+9*t-9*i+3*r,s=n*o+6*e-12*t+6*i;return n*s-3*e+3*t}function L1(n,e,t,i,r,o,s,a,l){l==null&&(l=1),l=l>1?1:l<0?0:l;for(var c=l/2,u=12,f=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],h=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],d=0,p=0;p<u;p++){var m=c*f[p]+c,g=I1(m,n,t,r,s),b=I1(m,e,i,o,a),_=g*g+b*b;d+=h[p]*ft.sqrt(_)}return c*d}function pB(n,e,t,i,r,o,s,a){if(!(Li(n,t)<Ii(r,s)||Ii(n,t)>Li(r,s)||Li(e,i)<Ii(o,a)||Ii(e,i)>Li(o,a))){var l=(n*i-e*t)*(r-s)-(n-t)*(r*a-o*s),c=(n*i-e*t)*(o-a)-(e-i)*(r*a-o*s),u=(n-t)*(o-a)-(e-i)*(r-s);if(u){var f=lp(l/u),h=lp(c/u),d=+f.toFixed(2),p=+h.toFixed(2);if(!(d<+Ii(n,t).toFixed(2)||d>+Li(n,t).toFixed(2)||d<+Ii(r,s).toFixed(2)||d>+Li(r,s).toFixed(2)||p<+Ii(e,i).toFixed(2)||p>+Li(e,i).toFixed(2)||p<+Ii(o,a).toFixed(2)||p>+Li(o,a).toFixed(2)))return{x:f,y:h}}}}function lp(n){return Math.round(n*1e11)/1e11}function mB(n,e,t){var i=D1(n),r=D1(e);if(!dB(i,r))return t?0:[];var o=L1(...n),s=L1(...e),a=B1(n)?1:~~(o/5)||1,l=B1(e)?1:~~(s/5)||1,c=new Array(a+1),u=new Array(l+1),f={},h=t?0:[],d,p;for(d=0;d<a+1;d++){var m=P1(...n,d/a);c[d]={x:m.x,y:m.y,t:d/a}}for(d=0;d<l+1;d++)m=P1(...e,d/l),u[d]={x:m.x,y:m.y,t:d/l};for(d=0;d<a;d++)for(p=0;p<l;p++){var g=c[d],b=c[d+1],_=u[p],v=u[p+1],x=ao(b.x-g.x)<.01?"y":"x",C=ao(v.x-_.x)<.01?"y":"x",E=pB(g.x,g.y,b.x,b.y,_.x,_.y,v.x,v.y),S;if(E){if(S=E.x.toFixed(9)+"#"+E.y.toFixed(9),f[S])continue;f[S]=!0;var w=g.t+ao((E[x]-g[x])/(b[x]-g[x]))*(b.t-g.t),R=_.t+ao((E[C]-_[C])/(v[C]-_[C]))*(v.t-_.t);w>=0&&w<=1&&R>=0&&R<=1&&(t?h++:h.push({x:E.x,y:E.y,t1:w,t2:R}))}}return h}function ef(n,e,t){n=$1(n),e=$1(e);for(var i,r,o,s,a,l,c,u,f,h,d=t?0:[],p=0,m=n.length;p<m;p++){var g=n[p];if(g[0]=="M")i=a=g[1],r=l=g[2];else{g[0]=="C"?(f=[i,r,...g.slice(1)],i=f[6],r=f[7]):(f=[i,r,i,r,a,l,a,l],i=a,r=l);for(var b=0,_=e.length;b<_;b++){var v=e[b];if(v[0]=="M")o=c=v[1],s=u=v[2];else{v[0]=="C"?(h=[o,s,...v.slice(1)],o=h[6],s=h[7]):(h=[o,s,o,s,c,u,c,u],o=c,s=u);var x=mB(f,h,t);if(t)d+=x;else{for(var C=0,E=x.length;C<E;C++)x[C].segment1=p,x[C].segment2=b,x[C].bez1=f,x[C].bez2=h;d=d.concat(x)}}}}}return d}function gB(n){return M1(n)&&M1(n[0])}function yB(n){if(uB(n))return n;var e=new Array(n.length),t=0,i=0,r=0,o=0,s=0,a;n[0][0]=="M"&&(t=+n[0][1],i=+n[0][2],r=t,o=i,s++,e[0]=["M",t,i]);for(var l,c,u=s,f=n.length;u<f;u++){if(c=n[u],a=c[0],e[u]=l=new Array(c.length),a!=a.toUpperCase())switch(l[0]=a.toUpperCase(),l[0]){case"A":l[1]=c[1],l[2]=c[2],l[3]=c[3],l[4]=c[4],l[5]=c[5],l[6]=+c[6]+t,l[7]=+c[7]+i;break;case"V":l[1]=+c[1]+i;break;case"H":l[1]=+c[1]+t;break;case"M":r=+c[1]+t,o=+c[2]+i;default:for(var h=1,d=c.length;h<d;h++)l[h]=+c[h]+(h%2?t:i)}else for(var p=0,m=c.length;p<m;p++)l[p]=c[p];switch(a=a.toUpperCase(),l[0]){case"Z":t=+r,i=+o;break;case"H":t=l[1];break;case"V":i=l[1];break;case"M":r=l[l.length-2],o=l[l.length-1];default:t=l[l.length-2],i=l[l.length-1]}}return e.toString=Sv,e}function B1(n){return n[0]===n[2]&&n[1]===n[3]&&n[4]===n[6]&&n[5]===n[7]}function ap(n,e,t,i){return[n,e,t,i,t,i]}function N1(n,e,t,i,r,o){var s=.3333333333333333,a=2/3;return[s*n+a*t,s*e+a*i,s*r+a*t,s*o+a*i,r,o]}function j1(n,e,t,i,r,o,s,a,l,c){var u=oo*120/180,f=oo/180*(+r||0),h=[],d,p=lB(function(Zo,fi,$n){var jn=Zo*ft.cos($n)-fi*ft.sin($n),ar=Zo*ft.sin($n)+fi*ft.cos($n);return{x:jn,y:ar}});if(c)S=c[0],w=c[1],C=c[2],E=c[3];else{d=p(n,e,-f),n=d.x,e=d.y,d=p(a,l,-f),a=d.x,l=d.y;var m=(n-a)/2,g=(e-l)/2,b=m*m/(t*t)+g*g/(i*i);b>1&&(b=ft.sqrt(b),t=b*t,i=b*i);var _=t*t,v=i*i,x=(o==s?-1:1)*ft.sqrt(ao((_*v-_*g*g-v*m*m)/(_*g*g+v*m*m))),C=x*t*g/i+(n+a)/2,E=x*-i*m/t+(e+l)/2,S=ft.asin(((e-E)/i).toFixed(9)),w=ft.asin(((l-E)/i).toFixed(9));S=n<C?oo-S:S,w=a<C?oo-w:w,S<0&&(S=oo*2+S),w<0&&(w=oo*2+w),s&&S>w&&(S=S-oo*2),!s&&w>S&&(w=w-oo*2)}var R=w-S;if(ao(R)>u){var A=w,I=a,D=l;w=S+u*(s&&w>S?1:-1),a=C+t*ft.cos(w),l=E+i*ft.sin(w),h=j1(a,l,t,i,r,0,s,I,D,[w,A,C,E])}R=w-S;var N=ft.cos(S),W=ft.sin(S),Re=ft.cos(w),_e=ft.sin(w),ue=ft.tan(R/4),re=4/3*t*ue,me=4/3*i*ue,Ue=[n,e],$e=[n+re*W,e-me*N],Ct=[a+re*_e,l-me*Re],Nt=[a,l];if($e[0]=2*Ue[0]-$e[0],$e[1]=2*Ue[1]-$e[1],c)return[$e,Ct,Nt].concat(h);h=[$e,Ct,Nt].concat(h).join().split(",");for(var fn=[],ct=0,Ti=h.length;ct<Ti;ct++)fn[ct]=ct%2?p(h[ct-1],h[ct],f).y:p(h[ct],h[ct+1],f).x;return fn}function vB(n,e,t,i,r,o,s,a){for(var l=[],c=[[],[]],u,f,h,d,p,m,g,b,_=0;_<2;++_){if(_==0?(f=6*n-12*t+6*r,u=-3*n+9*t-9*r+3*s,h=3*t-3*n):(f=6*e-12*i+6*o,u=-3*e+9*i-9*o+3*a,h=3*i-3*e),ao(u)<1e-12){if(ao(f)<1e-12)continue;d=-h/f,0<d&&d<1&&l.push(d);continue}g=f*f-4*h*u,b=ft.sqrt(g),!(g<0)&&(p=(-f+b)/(2*u),0<p&&p<1&&l.push(p),m=(-f-b)/(2*u),0<m&&m<1&&l.push(m))}for(var v=l.length,x=v,C;v--;)d=l[v],C=1-d,c[0][v]=C*C*C*n+3*C*C*d*t+3*C*d*d*r+d*d*d*s,c[1][v]=C*C*C*e+3*C*C*d*i+3*C*d*d*o+d*d*d*a;return c[0][x]=n,c[1][x]=e,c[0][x+1]=s,c[1][x+1]=a,c[0].length=c[1].length=x+2,{x0:Ii(...c[0]),y0:Ii(...c[1]),x1:Li(...c[0]),y1:Li(...c[1])}}function $1(n){if(gB(n)||(n=cB(n)),fB(n))return n;for(var e=hB(yB(n)),t={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i=function(h,d,p){var m,g;if(!h)return["C",d.x,d.y,d.x,d.y,d.x,d.y];switch(!(h[0]in{T:1,Q:1})&&(d.qx=d.qy=null),h[0]){case"M":d.X=h[1],d.Y=h[2];break;case"A":h=["C",...j1(d.x,d.y,...h.slice(1))];break;case"S":p=="C"||p=="S"?(m=d.x*2-d.bx,g=d.y*2-d.by):(m=d.x,g=d.y),h=["C",m,g,...h.slice(1)];break;case"T":p=="Q"||p=="T"?(d.qx=d.x*2-d.qx,d.qy=d.y*2-d.qy):(d.qx=d.x,d.qy=d.y),h=["C",...N1(d.x,d.y,d.qx,d.qy,h[1],h[2])];break;case"Q":d.qx=h[1],d.qy=h[2],h=["C",...N1(d.x,d.y,h[1],h[2],h[3],h[4])];break;case"L":h=["C",...ap(d.x,d.y,h[1],h[2])];break;case"H":h=["C",...ap(d.x,d.y,h[1],d.y)];break;case"V":h=["C",...ap(d.x,d.y,d.x,h[1])];break;case"Z":h=["C",...ap(d.x,d.y,d.X,d.Y)];break}return h},r=function(h,d){if(h[d].length>7){h[d].shift();for(var p=h[d];p.length;)o[d]="A",h.splice(d++,0,["C",...p.splice(0,6)]);h.splice(d,1),c=e.length}},o=[],s="",a="",l=0,c=e.length;l<c;l++){e[l]&&(s=e[l][0]),s!="C"&&(o[l]=s,l&&(a=o[l-1])),e[l]=i(e[l],t,a),o[l]!="A"&&s=="C"&&(o[l]="C"),r(e,l);var u=e[l],f=u.length;t.x=u[f-2],t.y=u[f-1],t.bx=T1(u[f-4])||t.x,t.by=T1(u[f-3])||t.y}return e}function Xe(n){return Pe(n)&&Zr(n,"waypoints")}function Bi(n){return Pe(n)&&Zr(n,"labelTarget")}function F1(n){return{x:Math.round(n.x),y:Math.round(n.y),width:Math.round(n.width),height:Math.round(n.height)}}function ma(n){return{x:Math.round(n.x),y:Math.round(n.y)}}function G(n){return{top:n.y,right:n.x+(n.width||0),bottom:n.y+(n.height||0),left:n.x}}function Ov(n){return{x:n.left,y:n.top,width:n.right-n.left,height:n.bottom-n.top}}function xB(n){return ma({x:n.x+(n.width||0)/2,y:n.y+(n.height||0)/2})}function bB(n){for(var e=n.waypoints,t=e.reduce(function(c,u,f){var h=e[f-1];if(h){var d=c[c.length-1],p=d&&d.endLength||0,m=wB(h,u);c.push({start:h,end:u,startLength:p,endLength:p+m,length:m})}return c},[]),i=t.reduce(function(c,u){return c+u.length},0),r=i/2,o=0,s=t[o];s.endLength<r;)s=t[++o];var a=(r-s.startLength)/s.length,l={x:s.start.x+(s.end.x-s.start.x)*a,y:s.start.y+(s.end.y-s.start.y)*a};return l}function le(n){return Xe(n)?bB(n):xB(n)}function vt(n,e,t){t=t||0,Pe(t)||(t={x:t,y:t});var i=G(n),r=G(e),o=i.bottom+t.y<=r.top,s=i.left-t.x>=r.right,a=i.top-t.y>=r.bottom,l=i.right+t.x<=r.left,c=o?"top":a?"bottom":null,u=l?"left":s?"right":null;return u&&c?c+"-"+u:u||c||"intersect"}function tf(n,e,t){var i=_B(n,e);return i.length===1||i.length===2&&pa(i[0],i[1])<1?ma(i[0]):i.length>1?(i=Fn(i,function(r){var o=Math.floor(r.t2*100)||1;return o=100-o,o=(o<10?"0":"")+o,r.segment2+"#"+o}),ma(i[t?0:i.length-1])):null}function _B(n,e){return ef(n,e)}function q1(n){n=n.slice();for(var e=0,t,i,r;n[e];)t=n[e],i=n[e-1],r=n[e+1],pa(t,r)===0||sp(i,r,t)?n.splice(e,1):e++;return n}function wB(n,e){return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function cp(n,e){return Math.round(n*e)/e}function V1(n){return se(n)?n+"px":n}function CB(n){for(;n.parent;)n=n.parent;return n}function EB(n){n=T({},{width:"100%",height:"100%"},n);let e=n.container||document.body,t=document.createElement("div");return t.setAttribute("class","djs-container djs-parent"),is(t,{position:"relative",overflow:"hidden",width:V1(n.width),height:V1(n.height)}),e.appendChild(t),t}function H1(n,e,t){let i=Q("g");ne(i).add(e);let r=t!==void 0?t:n.childNodes.length-1;return n.insertBefore(i,n.childNodes[r]||null),i}var SB="base",z1=0,OB=1,kB={shape:["x","y","width","height"],connection:["waypoints"]};function Y(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||{})}Y.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"];Y.prototype._init=function(n){let e=this._eventBus,t=this._container=EB(n),i=this._svg=Q("svg");j(i,{width:"100%",height:"100%"}),et(i,"tabindex",0),n.autoFocus&&e.on("element.hover",()=>{this.restoreFocus()}),e.on("element.mousedown",500,o=>{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")}),K(t,i);let r=this._viewport=H1(i,"viewport");n.deferUpdate&&(this._viewboxChanged=Mi(at(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)};Y.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};Y.prototype._setFocused=function(n){n!=this._focused&&(this._focused=n,this._eventBus.fire("canvas.focus.changed",{focused:n}))};Y.prototype._clear=function(){this._elementRegistry.getAll().forEach(e=>{let t=ip(e);t==="root"?this.removeRootElement(e):this._removeElement(e,t)}),this._planes=[],this._rootElement=null,delete this._cachedViewbox};Y.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)};Y.prototype.restoreFocus=function(){document.activeElement===document.body&&this.focus()};Y.prototype.isFocused=function(){return this._focused};Y.prototype.getDefaultLayer=function(){return this.getLayer(SB,z1)};Y.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};Y.prototype._getChildIndex=function(n){return st(this._layers,function(e,t){return t.visible&&n>=t.index&&e++,e},0)};Y.prototype._createLayer=function(n,e){typeof e=="undefined"&&(e=OB);let t=this._getChildIndex(e);return{group:H1(this._viewport,"layer-"+n,t),index:e,visible:!0}};Y.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 o=this._getChildIndex(r);return t.insertBefore(i,t.childNodes[o]||null),e.visible=!0,i};Y.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&&(Fe(t),e.visible=!1),t};Y.prototype._removeLayer=function(n){let e=this._layers[n];e&&(delete this._layers[n],Fe(e.group))};Y.prototype.getActiveLayer=function(){let n=this._findPlaneForRoot(this.getRootElement());return n?n.layer:null};Y.prototype.findRoot=function(n){return typeof n=="string"&&(n=this._elementRegistry.get(n)),n?(this._findPlaneForRoot(CB(n))||{}).rootElement:void 0};Y.prototype.getRootElements=function(){return this._planes.map(function(n){return n.rootElement})};Y.prototype._findPlaneForRoot=function(n){return ye(this._planes,function(e){return e.rootElement===n})};Y.prototype.getContainer=function(){return this._container};Y.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&&(k([i.gfx,i.secondaryGfx],function(r){r&&(t?(n.markers.add(e),ne(r).add(e)):(n.markers.delete(e),ne(r).remove(e)))}),this._eventBus.fire("element.marker.update",{element:n,gfx:i.gfx,marker:e,add:!!t}))};Y.prototype.addMarker=function(n,e){this._updateMarker(n,e,!0)};Y.prototype.removeMarker=function(n,e){this._updateMarker(n,e,!1)};Y.prototype.hasMarker=function(n,e){return n.id||(n=this._elementRegistry.get(n)),n.markers?n.markers.has(e):!1};Y.prototype.toggleMarker=function(n,e){this.hasMarker(n,e)?this.removeMarker(n,e):this.addMarker(n,e)};Y.prototype.getRootElement=function(){let n=this._rootElement;return n||this._planes.length?n:this.setRootElement(this.addRootElement(null))};Y.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,z1);return this.hideLayer(t),this._addRoot(n,i),this._planes.push({rootElement:n,layer:i}),n};Y.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};Y.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};Y.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)};Y.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})};Y.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})};Y.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=kB[n];if(!kt(t,function(r){return typeof e[r]!="undefined"}))throw new Error("must supply { "+t.join(", ")+" } with "+n)};Y.prototype._setParent=function(n,e,t){zt(e.children,n,t),n.parent=e};Y.prototype._addElement=function(n,e,t,i){t=t||this.getRootElement();let r=this._eventBus,o=this._graphicsFactory;this._ensureValid(n,e),r.fire(n+".add",{element:e,parent:t}),this._setParent(e,t,i);let s=o.create(n,e,i);return this._elementRegistry.add(e,s),o.update(n,e,s),r.fire(n+".added",{element:e,gfx:s}),e};Y.prototype.addShape=function(n,e,t){return this._addElement("shape",n,e,t)};Y.prototype.addConnection=function(n,e,t){return this._addElement("connection",n,e,t)};Y.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),Vn(n.parent&&n.parent.children,n),n.parent=null,r.fire(e+".removed",{element:n}),t.remove(n),n};Y.prototype.removeShape=function(n){return this._removeElement(n,"shape")};Y.prototype.removeConnection=function(n){return this._removeElement(n,"connection")};Y.prototype.getGraphics=function(n,e){return this._elementRegistry.getGraphics(n,e)};Y.prototype._changeViewbox=function(n){this._eventBus.fire("canvas.viewbox.changing"),n.apply(this),this._cachedViewbox=null,this._viewboxChanged()};Y.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})};Y.prototype.viewbox=function(n){if(n===void 0&&this._cachedViewbox)return structuredClone(this._cachedViewbox);let e=this._viewport,t=this.getSize(),i,r,o,s,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);as(e,u)});else return o=this._rootElement?this.getActiveLayer():null,i=o&&o.getBBox()||{},s=as(e),r=s?s.matrix:b1(),a=cp(r.a,1e3),l=cp(-r.e||0,1e3),c=cp(-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};Y.prototype.scroll=function(n){let e=this._viewport,t=e.getCTM();return n&&this._changeViewbox(function(){n=T({dx:0,dy:0},n||{}),t=this._svg.createSVGMatrix().translate(n.dx,n.dy).multiply(t),W1(e,t)}),{x:t.e,y:t.f}};Y.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=Tt(n),o=G(r),s=this.viewbox(),a=this.zoom(),l,c;s.y+=e.top/a,s.x+=e.left/a,s.width-=(e.right+e.left)/a,s.height-=(e.bottom+e.top)/a;let u=G(s);if(!(r.width<s.width&&r.height<s.height))l=r.x-s.x,c=r.y-s.y;else{let h=Math.max(0,o.right-u.right),d=Math.min(0,o.left-u.left),p=Math.max(0,o.bottom-u.bottom),m=Math.min(0,o.top-u.top);l=h||d,c=p||m}this.scroll({dx:-l*a,dy:-c*a})};Y.prototype.zoom=function(n,e){if(!n)return this.viewbox(n).scale;if(n==="fit-viewport")return this._fitViewport(e);let t,i;return this._changeViewbox(function(){typeof e!="object"&&(t=this.viewbox().outer,e={x:t.width/2,y:t.height/2}),i=this._setZoom(n,e)}),cp(i.a,1e3)};function W1(n,e){let t="matrix("+e.a+","+e.b+","+e.c+","+e.d+","+e.e+","+e.f+")";n.setAttribute("transform",t)}Y.prototype._fitViewport=function(n){let e=this.viewbox(),t=e.outer,i=e.inner,r,o;return i.x>=0&&i.y>=0&&i.x+i.width<=t.width&&i.y+i.height<=t.height&&!n?o={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),o={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(o),this.viewbox(!1).scale};Y.prototype._setZoom=function(n,e){let t=this._svg,i=this._viewport,r=t.createSVGMatrix(),o=t.createSVGPoint(),s,a,l,c,u;l=i.getCTM();let f=l.a;return e?(s=T(o,e),a=s.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),W1(this._viewport,u),u};Y.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}};Y.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,o=t.width*e.scale,s=t.height*e.scale;return{x:i,y:r,width:o,height:s}};Y.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var ga="data-element-id";function tn(n){this._elements={},this._eventBus=n}tn.$inject=["eventBus"];tn.prototype.add=function(n,e,t){var i=n.id;this._validateId(i),j(e,ga,i),t&&j(t,ga,i),this._elements[i]={element:n,gfx:e,secondaryGfx:t}};tn.prototype.remove=function(n){var e=this._elements,t=n.id||n,i=t&&e[t];i&&(j(i.gfx,ga,""),i.secondaryGfx&&j(i.secondaryGfx,ga,""),delete e[t])};tn.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)};tn.prototype.updateGraphics=function(n,e,t){var i=n.id||n,r=this._elements[i];return t?r.secondaryGfx=e:r.gfx=e,e&&j(e,ga,i),e};tn.prototype.get=function(n){var e;typeof n=="string"?e=n:e=n&&j(n,ga);var t=this._elements[e];return t&&t.element};tn.prototype.filter=function(n){var e=[];return this.forEach(function(t,i){n(t,i)&&e.push(t)}),e};tn.prototype.find=function(n){for(var e=this._elements,t=Object.keys(e),i=0;i<t.length;i++){var r=t[i],o=e[r],s=o.element,a=o.gfx;if(n(s,a))return s}};tn.prototype.getAll=function(){return this.filter(function(n){return n})};tn.prototype.forEach=function(n){var e=this._elements;Object.keys(e).forEach(function(t){var i=e[t],r=i.element,o=i.gfx;return n(r,o)})};tn.prototype.getGraphics=function(n,e){var t=n.id||n,i=this._elements[t];return i&&(e?i.secondaryGfx:i.gfx)};tn.prototype._validateId=function(n){if(!n)throw new Error("element must have an id");if(this._elements[n])throw new Error("element with id "+n+" already added")};function RB(n,e,t,i){var r=t.inverse;return Object.defineProperty(n,"remove",{value:function(o){var s=this.indexOf(o);return s!==-1&&(this.splice(s,1),e.unset(o,r,i)),o}}),Object.defineProperty(n,"contains",{value:function(o){return this.indexOf(o)!==-1}}),Object.defineProperty(n,"add",{value:function(o,s){var a=this.indexOf(o);if(typeof s=="undefined"){if(a!==-1)return;s=this.length}a!==-1&&this.splice(a,1),this.splice(s,0,o),a===-1&&e.set(o,r,i)}}),Object.defineProperty(n,"__refs_collection",{value:!0}),n}function TB(n){return n.__refs_collection===!0}function AB(n,e){return Object.prototype.hasOwnProperty.call(n,e.name||e)}function U1(n,e,t){var i=RB(t[e.name]||[],n,e,t);Object.defineProperty(t,e.name,{enumerable:e.enumerable,value:i}),i.length&&i.forEach(function(r){n.set(r,e.inverse,t)})}function MB(n,e,t){var i=e.inverse,r=t[e.name];Object.defineProperty(t,e.name,{configurable:e.configurable,enumerable:e.enumerable,get:function(){return r},set:function(o){if(o!==r){var s=r;r=null,s&&n.unset(s,i,t),r=o,n.set(r,i,t)}}})}function nn(n,e){if(!(this instanceof nn))return new nn(n,e);n.inverse=e,e.inverse=n,this.props={},this.props[n.name]=n,this.props[e.name]=e}nn.prototype.bind=function(n,e){if(typeof e=="string"){if(!this.props[e])throw new Error("no property <"+e+"> in ref");e=this.props[e]}e.collection?U1(this,e,n):MB(this,e,n)};nn.prototype.ensureRefsCollection=function(n,e){var t=n[e.name];return TB(t)||U1(this,e,n),t};nn.prototype.ensureBound=function(n,e){AB(n,e)||this.bind(n,e)};nn.prototype.unset=function(n,e,t){n&&(this.ensureBound(n,e),e.collection?this.ensureRefsCollection(n,e).remove(t):n[e.name]=void 0)};nn.prototype.set=function(n,e,t){n&&(this.ensureBound(n,e),e.collection?this.ensureRefsCollection(n,e).add(t):n[e.name]=t)};var kv=new nn({name:"children",enumerable:!0,collection:!0},{name:"parent"}),K1=new nn({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),Q1=new nn({name:"attachers",collection:!0},{name:"host"}),G1=new nn({name:"outgoing",collection:!0},{name:"source"}),X1=new nn({name:"incoming",collection:!0},{name:"target"});function ya(){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)}}),kv.bind(this,"parent"),K1.bind(this,"labels"),G1.bind(this,"outgoing"),X1.bind(this,"incoming")}function nf(){ya.call(this),kv.bind(this,"children"),Q1.bind(this,"host"),Q1.bind(this,"attachers")}fe(nf,ya);function Y1(){ya.call(this),kv.bind(this,"children")}fe(Y1,nf);function Z1(){nf.call(this),K1.bind(this,"labelTarget")}fe(Z1,nf);function J1(){ya.call(this),G1.bind(this,"source"),X1.bind(this,"target")}fe(J1,ya);var PB={connection:J1,shape:nf,label:Z1,root:Y1};function eC(n,e){var t=PB[n];if(!t)throw new Error("unknown type: <"+n+">");return T(new t,e)}function tC(n){return n instanceof ya}function Hn(){this._uid=12}Hn.prototype.createRoot=function(n){return this.create("root",n)};Hn.prototype.createLabel=function(n){return this.create("label",n)};Hn.prototype.createShape=function(n){return this.create("shape",n)};Hn.prototype.createConnection=function(n){return this.create("connection",n)};Hn.prototype.create=function(n,e){return e=T({},e||{}),e.id||(e.id=n+"_"+this._uid++),eC(n,e)};function ls(n){return n.childNodes[0]}function nC(n){return n.parentNode.childNodes[1]}function iC(n,e,t,i,r){var o=da();o.setTranslate(e,t);var s=da();s.setRotate(i||0,0,0);var a=da();a.setScale(r||1,r||1),as(n,[o,s,a])}function jt(n,e,t){var i=da();i.setTranslate(e,t),as(n,i)}function rC(n,e){var t=da();t.setRotate(e,0,0),as(n,t)}function rn(n,e){this._eventBus=n,this._elementRegistry=e}rn.$inject=["eventBus","elementRegistry"];rn.prototype._getChildrenContainer=function(n){var e=this._elementRegistry.getGraphics(n),t;return n.parent?(t=nC(e),t||(t=Q("g"),ne(t).add("djs-children"),K(e.parentNode,t))):t=e,t};rn.prototype._clear=function(n){var e=ls(n);return no(e),e};rn.prototype._createContainer=function(n,e,t,i){var r=Q("g");ne(r).add("djs-group"),typeof t!="undefined"?oC(r,e,e.childNodes[t]):K(e,r);var o=Q("g");ne(o).add("djs-element"),ne(o).add("djs-"+n),i&&ne(o).add("djs-frame"),K(r,o);var s=Q("g");return ne(s).add("djs-visual"),K(o,s),o};rn.prototype.create=function(n,e,t){var i=this._getChildrenContainer(e.parent);return this._createContainer(n,i,t,rp(e))};rn.prototype.updateContainments=function(n){var e=this,t=this._elementRegistry,i;i=st(n,function(r,o){return o.parent&&(r[o.parent.id]=o.parent),r},{}),k(i,function(r){var o=r.children;if(o){var s=e._getChildrenContainer(r);k(o.slice().reverse(),function(a){var l=t.getGraphics(a);oC(l.parentNode,s)})}})};rn.prototype.drawShape=function(n,e,t={}){var i=this._eventBus;return i.fire("render.shape",{gfx:n,element:e,attrs:t})};rn.prototype.getShapePath=function(n){var e=this._eventBus;return e.fire("render.getShapePath",n)};rn.prototype.drawConnection=function(n,e,t={}){var i=this._eventBus;return i.fire("render.connection",{gfx:n,element:e,attrs:t})};rn.prototype.getConnectionPath=function(n){var e=this._eventBus;return e.fire("render.getConnectionPath",n)};rn.prototype.update=function(n,e,t){if(e.parent){var i=this._clear(t);if(n==="shape")this.drawShape(i,e),jt(t,e.x,e.y);else if(n==="connection")this.drawConnection(i,e);else throw new Error("unknown type: "+n);e.hidden?j(t,"display","none"):j(t,"display","block")}};rn.prototype.remove=function(n){var e=this._elementRegistry.getGraphics(n);Fe(e.parentNode)};function oC(n,e,t){var i=t||e.firstChild;n!==i&&e.insertBefore(n,i)}var sC={__depends__:[R1],__init__:["canvas"],canvas:["type",Y],elementRegistry:["type",tn],elementFactory:["type",Hn],eventBus:["type",ut],graphicsFactory:["type",rn]};function DB(n){var e=new os(n);return e.init(),e}function IB(n){n=n||{};var e={config:["value",n]},t=[e,sC].concat(n.modules||[]);return DB(t)}function mr(n,e){this._injector=e||IB(n),this.get("eventBus").fire("diagram.init")}mr.prototype.get=function(n,e){return this._injector.get(n,e)};mr.prototype.invoke=function(n,e,t){return this._injector.invoke(n,e,t)};mr.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")};mr.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};var LB=new nn({name:"dmnElementRef",enumerable:!0},{name:"di",configurable:!0});function Rv(n,e){var t=[];function i(b){var _=b.gfx;if(_)throw new Error("already rendered "+b.id);return n.element(b)}function r(b){return n.root(b)}function o(b){try{var _=b.di&&i(b);return _}catch(v){g(v.message,{element:b,error:v})}}function s(b,_){var v=b.dmnDI;if(!v)throw new Error("no dmndi:DMNDI");var x=v.diagrams||[];if(_&&x.indexOf(_)===-1)throw new Error("diagram not part of dmndi:DMNDI");if(!_&&x&&x.length&&(_=x[0]),!_)throw new Error("no diagram to display");b.di=_,f(_),r(b),a(b.get("drgElement")),l(b.get("artifact")),m()}function a(b){k(b,function(_){o(_),u(_)})}function l(b){k(b,function(_){O(_,"dmn:Association")?c(_):o(_)})}function c(b){p(function(){o(b)})}function u(b){k(["informationRequirement","knowledgeRequirement","authorityRequirement"],function(_){k(b[_],function(v){p(function(){o(v)})})})}function f(b){k(b.diagramElements,h)}function h(b){d(b)}function d(b){var _=b.dmnElementRef;_?_.di?g("multiple DI elements defined for element",{element:_}):(LB.bind(_,"di"),_.di=b):g("no DMN element referenced in element",{element:b})}function p(b){t.push(b)}function m(){k(t,function(b){b()})}function g(b,_){n.error(b,_)}return{handleDefinitions:s}}function aC(n,e,t){var i=n.get("drdImporter"),r=n.get("eventBus"),o,s=[];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){s.push({message:f,context:h})}},u=new Rv(c);u.handleDefinitions(l)}r.fire("import.start",{definitions:e});try{a(e)}catch(l){o=l}r.fire("import.done",{error:o,warnings:s}),t(o,s)}var Lv="$NO_OP",BB="a runtime error occured! Use Inferno in development environment to find the error.",dp=Array.isArray;function Bv(n){var e=typeof n;return e==="string"||e==="number"}function we(n){return pp(n)||Ye(n)}function lo(n){return Ye(n)||n===!1||NB(n)||pp(n)}function ve(n){return typeof n=="function"}function va(n){return typeof n=="string"}function Pv(n){return typeof n=="number"}function Ye(n){return n===null}function NB(n){return n===!0}function pp(n){return n===void 0}function $B(n){throw n||(n=BB),new Error("Inferno Error: "+n)}function sf(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 rf="$";function Nv(n,e,t,i,r,o,s,a){return{childFlags:n,children:e,className:t,dom:null,flags:i,key:r===void 0?null:r,parentVNode:null,props:o===void 0?null:o,ref:s===void 0?null:s,type:a}}function y(n,e,t,i,r,o,s,a){var l=r===void 0?1:r,c=Nv(l,i,t,n,s,o,a,e),u=Wn.createVNode;return typeof u=="function"&&u(c),l===0&&gC(c,c.children),c}function P(n,e,t,i,r){(n&2)>0&&(n=e.prototype&&ve(e.prototype.render)?4:8);var o=e.defaultProps;if(!we(o)){t||(t={});for(var s in o)pp(t[s])&&(t[s]=o[s])}if((n&8)>0){var a=e.defaultHooks;if(!we(a))if(!r)r=a;else for(var l in a)pp(r[l])&&(r[l]=a[l])}var c=Nv(1,null,null,n,i,t,r,e),u=Wn.createVNode;return ve(u)&&u(c),c}function Z(n,e){return Nv(1,we(n)?"":n,null,16,e,null,null,null)}function En(n){var e=n.props;if(e){var t=n.flags;t&481&&(e.children!==void 0&&we(n.children)&&gC(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=sf(n.ref,e.ref):n.ref=e.ref,e.ref=void 0)}return n}function Wt(n){var e,t=n.flags;if(t&14){var i,r=n.props;if(!Ye(r)){i={};for(var o in r)i[o]=r[o]}e=P(t,n.type,i,n.key,n.ref)}else t&481?e=y(t,n.type,n.className,n.children,n.childFlags,n.props,n.key,n.ref):t&16?e=Z(n.children,n.key):t&1024&&(e=n);return e}function pC(){return Z("",null)}function mC(n,e,t,i){for(var r=n.length;t<r;t++){var o=n[t];if(!lo(o)){var s=i+rf+t;if(dp(o))mC(o,e,0,s);else{if(Bv(o))o=Z(o,s);else{var a=o.key,l=va(a)&&a[0]===rf;(!Ye(o.dom)||l)&&(o=Wt(o)),Ye(a)||l?o.key=s:o.key=i+a}e.push(o)}}}}function gC(n,e){var t,i=1;if(lo(e))t=e;else if(va(e))i=2,t=Z(e);else if(Pv(e))i=2,t=Z(e+"");else if(dp(e)){var r=e.length;if(r===0)t=null,i=1;else{(Object.isFrozen(e)||e.$===!0)&&(e=e.slice()),i=8;for(var o=0;o<r;o++){var s=e[o];if(lo(s)||dp(s)){t=t||e.slice(0,o),mC(e,t,o,"");break}else if(Bv(s))t=t||e.slice(0,o),t.push(Z(s,rf+o));else{var a=s.key,l=Ye(s.dom),c=Ye(a),u=!c&&va(a)&&a[0]===rf;!l||c||u?(t=t||e.slice(0,o),(!l||u)&&(s=Wt(s)),(c||u)&&(s.key=rf+o),t.push(s)):t&&t.push(s)}}t=t||e,t.$=!0}}else t=e,Ye(e.dom)||(t=Wt(e)),i=2;return n.children=t,n.childFlags=i,n}var Wn={afterRender:null,beforeRender:null,createVNode:null,renderComplete:null};var cs="http://www.w3.org/1999/xlink",Tv="http://www.w3.org/XML/1998/namespace",jB="http://www.w3.org/2000/svg",lC={"xlink:actuate":cs,"xlink:arcrole":cs,"xlink:href":cs,"xlink:role":cs,"xlink:show":cs,"xlink:title":cs,"xlink:type":cs,"xml:base":Tv,"xml:lang":Tv,"xml:space":Tv},At={},Ni=[];function mp(n,e){n.appendChild(e)}function up(n,e,t){we(t)?mp(n,e):n.insertBefore(e,t)}function FB(n,e){return e?document.createElementNS(jB,n):document.createElement(n)}function $v(n,e,t){n.replaceChild(e,t)}function qB(n,e){n.removeChild(e)}function jv(n){for(var e;(e=n.shift())!==void 0;)e()}var fp={},Av={};function yC(n,e,t){var i=fp[n],r=t.$EV;e?(i||(Av[n]=WB(n),fp[n]=0),r||(r=t.$EV={}),r[n]||fp[n]++,r[n]=e):r&&r[n]&&(fp[n]--,i===1&&(document.removeEventListener(vC(n),Av[n]),Av[n]=null),r[n]=e)}function VB(n){return ve(n.composedPath)?n.composedPath()[0]:n.target}function HB(n,e,t,i){for(var r=VB(n);!Ye(r);){if(e&&r.disabled)return;var o=r.$EV;if(o){var s=o[t];if(s&&(i.dom=r,s.event?s.event(s.data,n):s(n),n.cancelBubble))return}r=r.parentNode}}function vC(n){return n.substr(2).toLowerCase()}function zB(){this.cancelBubble=!0,this.immediatePropagationStopped||this.stopImmediatePropagation()}function WB(n){var e=function(i){var r=i.type,o=r==="click"||r==="dblclick";if(o&&i.button!==0)return i.stopPropagation(),!1;i.stopPropagation=zB;var s={dom:document};Object.defineProperty(i,"currentTarget",{configurable:!0,get:function(){return s.dom}}),HB(i,o,n,s)};return document.addEventListener(vC(n),e),e}function xC(n,e){var t=document.createElement("i");return t.innerHTML=e,t.innerHTML===n.innerHTML}function UB(n,e){return!!(e&&e.dangerouslySetInnerHTML&&e.dangerouslySetInnerHTML.__html&&xC(n,e.dangerouslySetInnerHTML.__html))}function cC(n,e,t){if(n[e]){var i=n[e];i.event?i.event(i.data,t):i(t)}else{var r=e.toLowerCase();n[r]&&n[r](t)}}function lf(n,e){var t=function(r){r.stopPropagation();var o=this.$V;if(o){var s=o.props||At,a=o.dom;if(va(n))cC(s,n,r);else for(var l=0;l<n.length;l++)cC(s,n[l],r);if(ve(e)){var c=this.$V,u=c.props||At;e(u,a,!1,c)}}};return Object.defineProperty(t,"wrapped",{configurable:!1,enumerable:!1,value:!0,writable:!1}),t}function Fv(n){return n==="checkbox"||n==="radio"}var QB=lf("onInput",qv),KB=lf(["onClick","onChange"],qv);function bC(n){n.stopPropagation()}bC.wrapped=!0;function GB(n,e){Fv(e.type)?(n.onchange=KB,n.onclick=bC):n.oninput=QB}function qv(n,e){var t=n.type,i=n.value,r=n.checked,o=n.multiple,s=n.defaultValue,a=!we(i);t&&t!==e.type&&e.setAttribute("type",t),!we(o)&&o!==e.multiple&&(e.multiple=o),!we(s)&&!a&&(e.defaultValue=s+""),Fv(t)?(a&&(e.value=i),we(r)||(e.checked=r)):a&&e.value!==i?(e.defaultValue=i,e.value=i):we(r)||(e.checked=r)}function uC(n,e){var t=n.type;if(t==="optgroup"){var i=n.children,r=n.childFlags;if(r&12)for(var o=0,s=i.length;o<s;o++)Mv(i[o],e);else r===2&&Mv(i,e)}else Mv(n,e)}function Mv(n,e){var t=n.props||At,i=n.dom;i.value=t.value,dp(e)&&e.indexOf(t.value)!==-1||t.value===e?i.selected=!0:(!we(e)||!we(t.selected))&&(i.selected=t.selected||!1)}var XB=lf("onChange",_C);function YB(n){n.onchange=XB}function _C(n,e,t,i){var r=!!n.multiple;!we(n.multiple)&&r!==e.multiple&&(e.multiple=r);var o=i.childFlags;if((o&1)===0){var s=i.children,a=n.value;if(t&&we(a)&&(a=n.defaultValue),o&12)for(var l=0,c=s.length;l<c;l++)uC(s[l],a);else o===2&&uC(s,a)}}var ZB=lf("onInput",wC),JB=lf("onChange");function eN(n,e){n.oninput=ZB,e.onChange&&(n.onchange=JB)}function wC(n,e,t){var i=n.value,r=e.value;if(we(i)){if(t){var o=n.defaultValue;!we(o)&&o!==r&&(e.defaultValue=o,e.value=o)}}else r!==i&&(e.defaultValue=i,e.value=i)}function CC(n,e,t,i,r,o){n&64?qv(i,t):n&256?_C(i,t,r,e):n&128&&wC(i,t,r),o&&(t.$V=e)}function tN(n,e,t){n&64?GB(e,t):n&256?YB(e):n&128&&eN(e,t)}function EC(n){return n.type&&Fv(n.type)?!we(n.checked):!we(n.value)}function zn(n,e){us(n),e&&n.dom&&(qB(e,n.dom),n.dom=null)}function us(n){var e=n.flags;if(e&481){var t=n.ref,i=n.props;ve(t)&&t(null);var r=n.children,o=n.childFlags;if(o&12?Vv(r):o===2&&us(r),!Ye(i))for(var s in i)switch(s){case"onClick":case"onDblClick":case"onFocusIn":case"onFocusOut":case"onKeyDown":case"onKeyPress":case"onKeyUp":case"onMouseDown":case"onMouseMove":case"onMouseUp":case"onSubmit":case"onTouchEnd":case"onTouchMove":case"onTouchStart":yC(s,null,n.dom);break}}else{var a=n.children;if(a)if(e&14){var l=n.ref;e&4?(ve(a.componentWillUnmount)&&a.componentWillUnmount(),ve(l)&&l(null),a.$UN=!0,a.$LI&&us(a.$LI)):(!we(l)&&ve(l.onComponentWillUnmount)&&l.onComponentWillUnmount(n.dom,n.props||At),us(a))}else e&1024&&zn(a,n.type)}}function Vv(n){for(var e=0,t=n.length;e<t;e++)us(n[e])}function hp(n,e){Vv(e),n.textContent=""}function nN(n,e){return function(t){n(e.data,t)}}function iN(n,e,t){var i=n.toLowerCase();if(!ve(e)&&!we(e)){var r=e.event;r&&ve(r)&&(t[i]=nN(r,e))}else{var o=t[i];(!o||!o.wrapped)&&(t[i]=e)}}function fC(n,e){switch(n){case"animationIterationCount":case"borderImageOutset":case"borderImageSlice":case"borderImageWidth":case"boxFlex":case"boxFlexGroup":case"boxOrdinalGroup":case"columnCount":case"fillOpacity":case"flex":case"flexGrow":case"flexNegative":case"flexOrder":case"flexPositive":case"flexShrink":case"floodOpacity":case"fontWeight":case"gridColumn":case"gridRow":case"lineClamp":case"lineHeight":case"opacity":case"order":case"orphans":case"stopOpacity":case"strokeDasharray":case"strokeDashoffset":case"strokeMiterlimit":case"strokeOpacity":case"strokeWidth":case"tabSize":case"widows":case"zIndex":case"zoom":return e;default:return e+"px"}}function rN(n,e,t){var i=t.style,r,o;if(va(e)){i.cssText=e;return}if(!we(n)&&!va(n)){for(r in e)o=e[r],o!==n[r]&&(i[r]=Pv(o)?fC(r,o):o);for(r in n)we(e[r])&&(i[r]="")}else for(r in e)o=e[r],i[r]=Pv(o)?fC(r,o):o}function Dv(n,e,t,i,r,o,s){switch(n){case"onClick":case"onDblClick":case"onFocusIn":case"onFocusOut":case"onKeyDown":case"onKeyPress":case"onKeyUp":case"onMouseDown":case"onMouseMove":case"onMouseUp":case"onSubmit":case"onTouchEnd":case"onTouchMove":case"onTouchStart":yC(n,t,i);break;case"children":case"childrenType":case"className":case"defaultValue":case"key":case"multiple":case"ref":break;case"autoFocus":i.autofocus=!!t;break;case"allowfullscreen":case"autoplay":case"capture":case"checked":case"controls":case"default":case"disabled":case"hidden":case"indeterminate":case"loop":case"muted":case"novalidate":case"open":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"selected":i[n]=!!t;break;case"defaultChecked":case"value":case"volume":if(o&&n==="value")return;var a=we(t)?"":t;i[n]!==a&&(i[n]=a);break;case"dangerouslySetInnerHTML":var l=e&&e.__html||"",c=t&&t.__html||"";l!==c&&!we(c)&&!xC(i,c)&&(Ye(s)||(s.childFlags&12?Vv(s.children):s.childFlags===2&&us(s.children),s.children=null,s.childFlags=1),i.innerHTML=c);break;default:n[0]==="o"&&n[1]==="n"?iN(n,t,i):we(t)?i.removeAttribute(n):n==="style"?rN(e,t,i):r&&lC[n]?i.setAttributeNS(lC[n],n,t):i.setAttribute(n,t);break}}function SC(n,e,t,i,r){var o=!1,s=(e&448)>0;s&&(o=EC(t),o&&tN(e,i,t));for(var a in t)Dv(a,null,t[a],i,r,o,null);s&&CC(e,n,i,t,!0,o)}function OC(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===At&&(r.props=t),r.$UN=!1,ve(r.componentWillMount)){if(r.$BR=!0,r.componentWillMount(),r.$PSS){var o=r.state,s=r.$PS;if(Ye(o))r.state=s;else for(var a in s)o[a]=s[a];r.$PSS=!1,r.$PS=null}r.$BR=!1}ve(Wn.beforeRender)&&Wn.beforeRender(r);var l=cf(r.render(t,r.state,i),n),c;return ve(r.getChildContext)&&(c=r.getChildContext()),we(c)?r.$CX=i:r.$CX=sf(i,c),ve(Wn.afterRender)&&Wn.afterRender(r),r.$LI=l,r}function cf(n,e){return lo(n)?n=pC():Bv(n)?n=Z(n,null):(n.dom&&(n=Wt(n)),n.flags&14&&(n.parentVNode=e)),n}function on(n,e,t,i){var r=n.flags;if(r&481)return kC(n,e,t,i);if(r&14)return oN(n,e,t,i,(r&4)>0);if(r&512||r&16)return Iv(n,e);if(r&1024)return on(n.children,n.type,t,!1),n.dom=Iv(pC(),e)}function Iv(n,e){var t=n.dom=document.createTextNode(n.children);return Ye(e)||mp(e,t),t}function kC(n,e,t,i){var r=n.flags,o=n.children,s=n.props,a=n.className,l=n.ref,c=n.childFlags;i=i||(r&32)>0;var u=FB(n.type,i);if(n.dom=u,!we(a)&&a!==""&&(i?u.setAttribute("class",a):u.className=a),Ye(e)||mp(e,u),(c&1)===0){var f=i===!0&&n.type!=="foreignObject";c===2?on(o,u,t,f):c&12&&of(o,u,t,f)}return Ye(s)||SC(n,r,s,u,i),ve(l)&&Hv(u,l),u}function of(n,e,t,i){for(var r=0,o=n.length;r<o;r++){var s=n[r];Ye(s.dom)||(n[r]=s=Wt(s)),on(s,e,t,i)}}function oN(n,e,t,i,r){var o,s=n.type,a=n.props||At,l=n.ref;if(r){var c=OC(n,s,a,t);n.dom=o=on(c.$LI,null,c.$CX,i),RC(n,l,c),c.$UPD=!1}else{var u=cf(s(a,t),n);n.children=u,n.dom=o=on(u,null,t,i),TC(a,l,o)}return Ye(e)||mp(e,o),o}function sN(n){return function(){n.$UPD=!0,n.componentDidMount(),n.$UPD=!1}}function RC(n,e,t){ve(e)&&e(t),ve(t.componentDidMount)&&Ni.push(sN(t))}function aN(n,e,t){return function(){return n.onComponentDidMount(e,t)}}function TC(n,e,t){we(e)||(ve(e.onComponentWillMount)&&e.onComponentWillMount(n),ve(e.onComponentDidMount)&&Ni.push(aN(e,t,n)))}function Hv(n,e){Ni.push(function(){return e(n)})}function lN(n,e,t,i,r){var o=n.type,s=n.ref,a=n.props||At;if(r){var l=OC(n,o,a,t),c=l.$LI;af(c,e,l.$CX,i),n.dom=c.dom,RC(n,s,l),l.$UPD=!1}else{var u=cf(o(a,t),n);af(u,e,t,i),n.children=u,n.dom=u.dom,TC(a,s,e)}}function cN(n,e,t,i){var r=n.children,o=n.props,s=n.className,a=n.flags,l=n.ref;if(i=i||(a&32)>0,e.nodeType!==1||e.tagName.toLowerCase()!==n.type){var c=kC(n,null,t,i);n.dom=c,$v(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)Ye(u)?on(r,e,t,i):(h=u.nextSibling,af(r,u,t,i),u=h);else if(f&12)for(var d=0,p=r.length;d<p;d++){var m=r[d];Ye(u)?on(m,e,t,i):(h=u.nextSibling,af(m,u,t,i),u=h)}for(;u;)h=u.nextSibling,e.removeChild(u),u=h}else!Ye(e.firstChild)&&!UB(e,o)&&(e.textContent="",a&448&&(e.defaultValue=""));Ye(o)||SC(n,a,o,e,i),we(s)?e.className!==""&&e.removeAttribute("class"):i?e.setAttribute("class",s):e.className=s,ve(l)&&Hv(e,l)}}function uN(n,e){if(e.nodeType!==3){var t=Iv(n,null);n.dom=t,$v(e.parentNode,t,e)}else{var i=n.children;e.nodeValue!==i&&(e.nodeValue=i),n.dom=e}}function af(n,e,t,i){var r=n.flags;r&14?lN(n,e,t,i,(r&4)>0):r&481?cN(n,e,t,i):r&16?uN(n,e):r&512?n.dom=e:$B()}function fN(n,e,t){var i=e.firstChild;if(!Ye(i))for(lo(n)||af(n,i,At,!1),i=e.firstChild;i=i.nextSibling;)e.removeChild(i);Ni.length>0&&jv(Ni),e.$V=n,ve(t)&&t()}function zv(n,e,t,i,r){us(n),$v(t,on(e,null,i,r),n.dom)}function gr(n,e,t,i,r){var o=e.flags|0;n.flags!==o||o&2048?zv(n,e,t,i,r):o&481?pN(n,e,t,i,r,o):o&14?mN(n,e,t,i,r,(o&4)>0):o&16?gN(n,e):o&512?e.dom=n.dom:dN(n,e,i)}function hN(n,e){n.textContent!==e.children&&(n.textContent=e.children)}function dN(n,e,t){var i=n.type,r=e.type,o=e.children;if(AC(n.childFlags,e.childFlags,n.children,o,i,t,!1),e.dom=n.dom,i!==r&&!lo(o)){var s=o.dom;i.removeChild(s),r.appendChild(s)}}function pN(n,e,t,i,r,o){var s=e.type;if(n.type!==s)zv(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||(o&32)>0,l!==c){var d=l||At;if(h=c||At,h!==At){u=(o&448)>0,u&&(f=EC(h));for(var p in h){var m=d[p],g=h[p];m!==g&&Dv(p,m,g,a,r,f,n)}}if(d!==At)for(var b in d)!h.hasOwnProperty(b)&&!we(d[b])&&Dv(b,d[b],null,a,r,f,n)}var _=n.children,v=e.children,x=e.ref,C=n.className,E=e.className;o&4096?hN(a,v):AC(n.childFlags,e.childFlags,_,v,a,i,r&&s!=="foreignObject"),u&&CC(o,e,a,h,!1,f),C!==E&&(we(E)?a.removeAttribute("class"):r?a.setAttribute("class",E):a.className=E),ve(x)&&n.ref!==x&&Hv(a,x)}}function AC(n,e,t,i,r,o,s){switch(n){case 2:switch(e){case 2:gr(t,i,r,o,s);break;case 1:zn(t,r);break;default:zn(t,r),of(i,r,o,s);break}break;case 1:switch(e){case 2:on(i,r,o,s);break;case 1:break;default:of(i,r,o,s);break}break;default:if(e&12){var a=t.length,l=i.length;a===0?l>0&&of(i,r,o,s):l===0?hp(r,t):e===8&&n===8?vN(t,i,r,o,s,a,l):yN(t,i,r,o,s,a,l)}else e===1?hp(r,t):e===2&&(hp(r,t),on(i,r,o,s));break}}function MC(n,e,t,i,r,o,s,a,l){var c=n.state,u=n.props;t.children=n;var f;if(!n.$UN){if(u!==i||i===At){if(!l&&ve(n.componentWillReceiveProps)){if(n.$BR=!0,n.componentWillReceiveProps(i,o),n.$UN)return;n.$BR=!1}n.$PSS&&(e=sf(e,n.$PS),n.$PSS=!1,n.$PS=null)}var h=!!n.shouldComponentUpdate;if(a||!h||h&&n.shouldComponentUpdate(i,e,o)){ve(n.componentWillUpdate)&&(n.$BS=!0,n.componentWillUpdate(i,e,o),n.$BS=!1),n.props=i,n.state=e,n.context=o,ve(Wn.beforeRender)&&Wn.beforeRender(n),f=n.render(i,e,o),ve(Wn.afterRender)&&Wn.afterRender(n);var d=f!==Lv,p;if(ve(n.getChildContext)&&(p=n.getChildContext()),we(p)?p=o:p=sf(o,p),n.$CX=p,d){var m=n.$LI,g=cf(f,t);gr(m,g,r,p,s),n.$LI=g,ve(n.componentDidUpdate)&&n.componentDidUpdate(u,c)}}else n.props=i,n.state=e,n.context=o;t.dom=n.$LI.dom}}function mN(n,e,t,i,r,o){var s=e.type,a=n.key,l=e.key;if(n.type!==s||a!==l)zv(n,e,t,i,r);else{var c=e.props||At;if(o){var u=n.children;u.$UPD=!0,u.$V=e,MC(u,u.state,e,c,t,i,r,!1,!1),u.$UPD=!1}else{var f=!0,h=n.props,d=e.ref,p=!we(d),m=n.children;if(e.dom=n.dom,e.children=m,p&&ve(d.onComponentShouldUpdate)&&(f=d.onComponentShouldUpdate(h,c)),f!==!1){p&&ve(d.onComponentWillUpdate)&&d.onComponentWillUpdate(h,c);var g=s(c,i);g!==Lv&&(g=cf(g,e),gr(m,g,t,i,r),e.children=g,e.dom=g.dom,p&&ve(d.onComponentDidUpdate)&&d.onComponentDidUpdate(h,c))}else m.flags&14&&(m.parentVNode=e)}}}function gN(n,e){var t=e.children,i=n.dom;t!==n.children&&(i.nodeValue=t),e.dom=i}function yN(n,e,t,i,r,o,s){for(var a=o>s?s:o,l=0,c,u;l<a;l++)c=e[l],u=n[l],c.dom&&(c=e[l]=Wt(c)),gr(u,c,t,i,r),n[l]=c;if(o<s)for(l=a;l<s;l++)c=e[l],c.dom&&(c=e[l]=Wt(c)),on(c,t,i,r);else if(o>s)for(l=a;l<o;l++)zn(n[l],t)}function vN(n,e,t,i,r,o,s){var a=o-1,l=s-1,c,u=0,f=n[u],h=e[u],d;e:{for(;f.key===h.key;){if(h.dom&&(e[u]=h=Wt(h)),gr(f,h,t,i,r),n[u]=h,u++,u>a||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=Wt(h)),gr(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=d<s?e[d].dom:null;u<=l;)h=e[u],h.dom&&(e[u]=h=Wt(h)),u++,up(t,on(h,null,i,r),p)}}else if(u>l)for(;u<=a;)zn(n[u++],t);else{var m=u,g=u,b=a-u+1,_=l-u+1,v=[];for(c=0;c<_;c++)v.push(0);var x=b===o,C=!1,E=0,S=0;if(s<4||(b|_)<32)for(c=m;c<=a;c++)if(f=n[c],S<_){for(u=g;u<=l;u++)if(h=e[u],f.key===h.key){if(v[u-g]=c+1,x)for(x=!1;c>m;)zn(n[m++],t);E>u?C=!0:E=u,h.dom&&(e[u]=h=Wt(h)),gr(f,h,t,i,r),S++;break}!x&&u>l&&zn(f,t)}else x||zn(f,t);else{var w={};for(c=g;c<=l;c++)w[e[c].key]=c;for(c=m;c<=a;c++)if(f=n[c],S<_)if(u=w[f.key],u!==void 0){if(x)for(x=!1;c>m;)zn(n[m++],t);h=e[u],v[u-g]=c+1,E>u?C=!0:E=u,h.dom&&(e[u]=h=Wt(h)),gr(f,h,t,i,r),S++}else x||zn(f,t);else x||zn(f,t)}if(x)hp(t,n),of(e,t,i,r);else if(C){var R=xN(v);for(u=R.length-1,c=_-1;c>=0;c--)v[c]===0?(E=c+g,h=e[E],h.dom&&(e[E]=h=Wt(h)),d=E+1,up(t,on(h,null,i,r),d<s?e[d].dom:null)):u<0||c!==R[u]?(E=c+g,h=e[E],d=E+1,up(t,h.dom,d<s?e[d].dom:null)):u--}else if(S!==_)for(c=_-1;c>=0;c--)v[c]===0&&(E=c+g,h=e[E],h.dom&&(e[E]=h=Wt(h)),d=E+1,up(t,on(h,null,i,r),d<s?e[d].dom:null))}}function xN(n){var e=n.slice(),t=[0],i,r,o,s,a,l=n.length;for(i=0;i<l;i++){var c=n[i];if(c!==0){if(r=t[t.length-1],n[r]<c){e[i]=r,t.push(i);continue}for(o=0,s=t.length-1;o<s;)a=(o+s)/2|0,n[t[a]]<c?o=a+1:s=a;c<n[t[o]]&&(o>0&&(e[i]=t[o-1]),t[o]=i)}}for(o=t.length,s=t[o-1];o-- >0;)t[o]=s,s=e[s];return t}function xa(n,e,t){if(n!==Lv){var i=e.$V;if(we(i)?lo(n)||(n.dom&&(n=Wt(n)),Ye(e.firstChild)?(on(n,e,At,!1),e.$V=n):fN(n,e),i=n):we(n)?(zn(i,e),e.$V=null):(n.dom&&(n=Wt(n)),gr(i,n,e,At,!1),i=e.$V=n),Ni.length>0&&jv(Ni),ve(t)&&t(),ve(Wn.renderComplete)&&Wn.renderComplete(i),i&&i.flags&14)return i.children}}function PC(n,e){return y(1024,e,null,n,0,null,lo(n)?null:n.key,null)}var hC=typeof Promise=="undefined"?null:Promise.resolve(),bN=typeof requestAnimationFrame=="undefined"?setTimeout:requestAnimationFrame.bind(window);function _N(n){return hC?hC.then(n):bN(n)}function dC(n,e,t,i){ve(e)&&(e=e(n.state,n.props,n.context));var r=n.$PS;if(we(r))n.$PS=e;else for(var o in e)r[o]=e[o];if(!n.$PSS&&!n.$BR)if(!n.$UPD)n.$PSS=!0,n.$UPD=!0,DC(n,i,t),n.$UPD=!1;else{var s=n.$QU;Ye(s)&&(s=n.$QU=[],_N(wN(n,s))),ve(t)&&s.push(t)}else n.$PSS=!0,n.$BR&&ve(t)&&Ni.push(t.bind(n))}function wN(n,e){return function(){n.$QU=null,n.$UPD=!0,DC(n,!1,function(){for(var t=0,i=e.length;t<i;t++)e[t].call(n)}),n.$UPD=!1}}function DC(n,e,t){if(!n.$UN){if(e||!n.$BR){n.$PSS=!1;var i=n.$PS,r=n.state,o=sf(r,i),s=n.props,a=n.context;n.$PS=null;var l=n.$V,c=n.$LI,u=c.dom&&c.dom.parentNode;if(MC(n,o,l,s,u,a,(l.flags&32)>0,e,!0),n.$UN)return;if((n.$LI.flags&1024)===0)for(var f=n.$LI.dom;!Ye(l=l.parentVNode);)(l.flags&14)>0&&(l.dom=f);Ni.length>0&&jv(Ni)}else n.state=n.$PS,n.$PS=null;ve(t)&&t.call(n)}}var L=(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||At,this.context=i||At}var e=n.prototype;return e.forceUpdate=function(i){this.$UN||dC(this,{},i,!0)},e.setState=function(i,r){if(!this.$UN)if(!this.$BS)dC(this,i,r,!1);else return},e.render=function(i,r,o){},n})();L.defaultProps=void 0;var IC='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.02 5.57" width="53" height="21" style="vertical-align:middle"><path fill="#000000" d="M1.88.92v.14c0 .41-.13.68-.4.8.33.14.46.44.46.86v.33c0 .61-.33.95-.95.95H0V0h.95c.65 0 .93.3.93.92zM.63.57v1.06h.24c.24 0 .38-.1.38-.43V.98c0-.28-.1-.4-.32-.4zm0 1.63v1.22h.36c.2 0 .32-.1.32-.39v-.35c0-.37-.12-.48-.4-.48H.63zM4.18.99v.52c0 .64-.31.98-.94.98h-.3V4h-.62V0h.92c.63 0 .94.35.94.99zM2.94.57v1.35h.3c.2 0 .3-.09.3-.37v-.6c0-.29-.1-.38-.3-.38h-.3zm2.89 2.27L6.25 0h.88v4h-.6V1.12L6.1 3.99h-.6l-.46-2.82v2.82h-.55V0h.87zM8.14 1.1V4h-.56V0h.79L9 2.4V0h.56v4h-.64zm2.49 2.29v.6h-.6v-.6zM12.12 1c0-.63.33-1 .95-1 .61 0 .95.37.95 1v2.04c0 .64-.34 1-.95 1-.62 0-.95-.37-.95-1zm.62 2.08c0 .28.13.39.33.39s.32-.1.32-.4V.98c0-.29-.12-.4-.32-.4s-.33.11-.33.4z"/><path fill="#000000" d="M0 4.53h14.02v1.04H0zM11.08 0h.63v.62h-.63zm.63 4V1h-.63v2.98z"/></svg>';function Wv(n){var e='<a href="http://bpmn.io" target="_blank" class="bjs-powered-by" title="Powered by bpmn.io" style="position: absolute; bottom: 15px; right: 15px; z-index: 100;">'+IC+"</a>",t=te(e);n.appendChild(t),q.bind(t,"click",function(i){kN(),i.preventDefault()})}var co=class extends L{constructor(e,t){super(e,t),this.node=null}componentDidMount(){Wv(this.node)}render(){return y(1,"div",null,null,1,null,null,e=>this.node=e)}};function Uv(n){return n.join(";")}var CN=Uv(["z-index: 1001","position: fixed","top: 0","left: 0","right: 0","bottom: 0"]),EN=Uv(["width: 100%","height: 100%","background: rgba(40,40,40,0.2)"]),SN=Uv(["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"]),ON='<div class="bjs-powered-by-lightbox" style="'+CN+'"><div class="backdrop" style="'+EN+'"></div><div class="notice" style="'+SN+'"><a href="https://bpmn.io" target="_blank" rel="noopener" style="margin: 15px 20px 15px 10px; align-self: center;">'+IC+'</a><span>Web-based tooling for BPMN, DMN and CMMN diagrams powered by <a href="https://bpmn.io" target="_blank" rel="noopener">bpmn.io</a>.</span></div></div>',uf;function kN(){uf||(uf=te(ON),_t.bind(uf,".backdrop","click",function(n){document.body.removeChild(uf)})),document.body.appendChild(uf)}var RN=new qn,gp="hsl(225, 10%, 15%)";function ff(n,e,t,i,r,o){mn.call(this,e);var s=RN.next(),a=i.computeStyle,l={},c=n&&n.defaultFillColor||"white",u=n&&n.defaultStrokeColor||gp,f=n&&n.defaultLabelColor;function h(S,w,R){var A=S+"-"+BC(w)+"-"+BC(R)+"-"+s;return l[A]||p(A,S,w,R),"url(#"+A+")"}function d(S,w){var R=T({strokeWidth:1,strokeLinecap:"round",strokeDasharray:"none"},w.attrs),A=w.ref||{x:0,y:0},I=w.scale||1;R.strokeDasharray==="none"&&(R.strokeDasharray=[1e4,1]);var D=Q("marker");j(w.element,R),K(D,w.element),j(D,{id:S,viewBox:"0 0 20 20",refX:A.x,refY:A.y,markerWidth:20*I,markerHeight:20*I,orient:"auto"});var N=X("defs",o._svg);N||(N=Q("defs"),K(o._svg,N)),K(N,D),l[S]=D}function p(S,w,R,A){if(w==="association-start"){var I=Q("path");j(I,{d:"M 11 5 L 1 10 L 11 15"}),d(S,{element:I,attrs:{fill:"none",stroke:A,strokeWidth:1.5},ref:{x:1,y:10},scale:.5})}else if(w==="association-end"){var D=Q("path");j(D,{d:"M 1 5 L 11 10 L 1 15"}),d(S,{element:D,attrs:{fill:"none",stroke:A,strokeWidth:1.5},ref:{x:12,y:10},scale:.5})}else if(w==="information-requirement-end"){var N=Q("path");j(N,{d:"M 1 5 L 11 10 L 1 15 Z"}),d(S,{element:N,attrs:{fill:A,stroke:"none"},ref:{x:11,y:10},scale:1})}else if(w==="knowledge-requirement-end"){var W=Q("path");j(W,{d:"M 1 3 L 11 10 L 1 17"}),d(S,{element:W,attrs:{fill:"none",stroke:A,strokeWidth:2},ref:{x:11,y:10},scale:.8})}else if(w==="authority-requirement-end"){var Re=Q("circle");j(Re,{cx:3,cy:3,r:3}),d(S,{element:Re,attrs:{fill:A,stroke:"none"},ref:{x:3,y:3},scale:.9})}}function m(S,w,R,A,I,D){Pe(I)&&(D=I,I=0),I=I||0,D=a(D,{stroke:gp,strokeWidth:2,fill:"white"});var N=Q("rect");return j(N,{x:I,y:I,width:w-I*2,height:R-I*2,rx:A,ry:A}),j(N,D),K(S,N),N}function g(S,w,R){var A=r.createText(w||"",R);return et(A,"class","djs-label"),K(S,A),A}function b(S,w,R,A){var I=f1(w);return A=T({box:w,align:R,padding:5,style:{fill:NC(w,f,u)}},A),g(S,I,A)}function _(S,w,R){R=a(R,["no-fill"],{strokeWidth:2,stroke:gp});var A=Q("path");return j(A,{d:w}),j(A,R),K(S,A),A}var v={"dmn:Decision":function(S,w){var R=m(S,w.width,w.height,0,{stroke:$i(w,u),fill:uo(w,c)});return b(S,w,"center-middle"),R},"dmn:KnowledgeSource":function(S,w){var R=t.getScaledPath("KNOWLEDGE_SOURCE",{xScaleFactor:1.021,yScaleFactor:1,containerWidth:w.width,containerHeight:w.height,position:{mx:0,my:.075}}),A=_(S,R,{strokeWidth:2,fill:uo(w,c),stroke:$i(w,u)});return b(S,w,"center-middle"),A},"dmn:BusinessKnowledgeModel":function(S,w){var R=t.getScaledPath("BUSINESS_KNOWLEDGE_MODEL",{xScaleFactor:1,yScaleFactor:1,containerWidth:w.width,containerHeight:w.height,position:{mx:0,my:.3}}),A=_(S,R,{strokeWidth:2,fill:uo(w,c),stroke:$i(w,u)});return b(S,w,"center-middle"),A},"dmn:InputData":function(S,w){var R=m(S,w.width,w.height,22,{stroke:$i(w,u),fill:uo(w,c)});return b(S,w,"center-middle"),R},"dmn:TextAnnotation":function(S,w){var R={fill:"none",stroke:"none"},A=m(S,w.width,w.height,0,0,R),I=t.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:w.width,containerHeight:w.height,position:{mx:0,my:0}});_(S,I,{stroke:$i(w,u)});var D=LC(w).text||"";return g(S,D,{style:{fill:NC(w,f,u)},box:w,align:"left-top",padding:5}),A},"dmn:Association":function(S,w){var R=LC(w),A=uo(w,c),I=$i(w,u),D={stroke:I,strokeDasharray:"0.5, 5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"};return(R.associationDirection==="One"||R.associationDirection==="Both")&&(D.markerEnd=h("association-end",A,I)),R.associationDirection==="Both"&&(D.markerStart=h("association-start",A,I)),E(S,w.waypoints,D)},"dmn:InformationRequirement":function(S,w){var R=uo(w,c),A=$i(w,u),I={stroke:A,strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:h("information-requirement-end",R,A)};return E(S,w.waypoints,I)},"dmn:KnowledgeRequirement":function(S,w){var R=uo(w,c),A=$i(w,u),I={stroke:A,strokeWidth:1,strokeDasharray:5,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:h("knowledge-requirement-end",R,A)};return E(S,w.waypoints,I)},"dmn:AuthorityRequirement":function(S,w){var R=uo(w,c),A=$i(w,u),I={stroke:A,strokeWidth:1.5,strokeDasharray:5,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:h("authority-requirement-end",R,A)};return E(S,w.waypoints,I)}};function x(S,w){var R=v[w.type];return R?R(S,w):mn.prototype.drawShape.apply(this,[S,w])}function C(S,w){var R=w.type,A=v[R];return A?A(S,w):mn.prototype.drawConnection.apply(this,[S,w])}function E(S,w,R){R=a(R,["no-fill"],{stroke:gp,strokeWidth:2,fill:"none"});var A=ro(w,R);return K(S,A),A}this.canRender=function(S){return O(S,"dmn:DMNElement")||O(S,"dmn:InformationRequirement")||O(S,"dmn:KnowledgeRequirement")||O(S,"dmn:AuthorityRequirement")},this.drawShape=x,this.drawConnection=C}fe(ff,mn);ff.$inject=["config.drdRenderer","eventBus","pathMap","styles","textRenderer","canvas"];function LC(n){return n.businessObject}function BC(n){return n.replace(/[^0-9a-zA-z]+/g,"_")}function $i(n,e){return e}function uo(n,e){return e}function NC(n,e,t){return e||$i(n,t)}var TN=0,AN={width:150,height:50};function MN(n){var e=n.split("-");return{horizontal:e[0]||"center",vertical:e[1]||"top"}}function PN(n){return Pe(n)?T({top:0,left:0,right:0,bottom:0},n):{top:n,left:n,right:n,bottom:n}}var Qv=null;function DN(){return Qv||(Qv=document.createElement("canvas").getContext("2d")),Qv}function IN(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(jC(n.fontSize)||"12px"),e.push(n.fontFamily||"sans-serif"),e.join(" ")}function jC(n){if(n!=null)return typeof n=="number"||/^-?\d+(\.\d+)?$/.test(n)?n+"px":n}function LN(n,e){var t=DN();if(!t)return{width:0,height:0};t.font=IN(e),"letterSpacing"in t&&(t.letterSpacing=jC(e.letterSpacing)||"0px");var i=n==="",r=i?"dummy":n.replace(/\s+$/,""),o=t.measureText(r);return{width:i?0:o.width,height:"fontBoundingBoxAscent"in o?o.fontBoundingBoxAscent+o.fontBoundingBoxDescent:o.actualBoundingBoxAscent+o.actualBoundingBoxDescent}}function BN(n,e,t){for(var i=n.shift(),r=i,o;;){if(o=LN(r,t),o.width=r?o.width:0,r===" "||r===""||o.width<Math.round(e)||r.length<2)return NN(n,r,i,o);r=jN(r,o.width,e)}}function NN(n,e,t,i){if(e.length<t.length){var r=t.slice(e.length).trim();n.unshift(r)}return{width:i.width,height:i.height,text:e}}var $C="\xAD";function $N(n,e){var t=n.split(/(\s|-|\u00AD)/g),i,r=[],o=0;if(t.length>1)for(;i=t.shift();)if(i.length+o<e)r.push(i),o+=i.length;else{(i==="-"||i===$C)&&r.pop();break}var s=r[r.length-1];return s&&s===$C&&(r[r.length-1]="-"),r.join("")}function jN(n,e,t){var i=Math.max(n.length*(t/e),1),r=$N(n,i);return r||(r=n.slice(0,Math.max(Math.round(i-1),1))),r}function ba(n){this._config=T({},{size:AN,padding:TN,style:{},align:"center-top"},n||{})}ba.prototype.createText=function(n,e){return this.layoutText(n,e).element};ba.prototype.getDimensions=function(n,e){return this.layoutText(n,e).dimensions};ba.prototype.layoutText=function(n,e){for(var t=T({},this._config.size,e.box),i=T({},this._config.style,e.style),r=MN(e.align||this._config.align),o=PN(e.padding!==void 0?e.padding:this._config.padding),s=e.fitBox||!1,a=FN(i),l=n.split(/\u00AD?\r?\n/),c=[],u=t.width-o.left-o.right;l.length;)c.push(BN(l,u,i));r.vertical==="middle"&&(o.top=o.bottom=0);var f=st(c,function(g,b,_){return g+(a||b.height)},0)+o.top+o.bottom,h=st(c,function(g,b,_){return b.width>g?b.width:g},0),d=o.top;r.vertical==="middle"&&(d+=(t.height-f)/2),d-=(a||c[0].height)/4;var p=Q("text");j(p,i),k(c,function(g){var b;switch(d+=a||g.height,r.horizontal){case"left":b=o.left;break;case"right":b=(s?h:u)-o.right-g.width;break;default:b=Math.max(((s?h:u)-g.width)/2+o.left,0)}var _=Q("tspan");j(_,{x:b,y:d}),_.textContent=g.text,K(p,_)});var m={width:h,height:f};return{dimensions:m,element:p}};function FN(n){if("fontSize"in n&&"lineHeight"in n)return n.lineHeight*parseInt(n.fontSize,10)}var qN=12,VN=1.2,HN=30;function yp(n){var e=T({fontFamily:"Arial, sans-serif",fontSize:qN,fontWeight:"normal",lineHeight:VN},n&&n.defaultStyle||{}),t=parseInt(e.fontSize,10)-1,i=T({},e,{fontSize:t},n&&n.externalStyle||{}),r=new ba({style:e});this.getExternalLabelBounds=function(o,s){var a=r.getDimensions(s,{box:{width:90,height:30,x:o.width/2+o.x,y:o.height/2+o.y},style:i});return{x:Math.round(o.x+o.width/2-a.width/2),y:Math.round(o.y),width:Math.ceil(a.width),height:Math.ceil(a.height)}},this.getTextAnnotationBounds=function(o,s){var a=r.getDimensions(s,{box:o,style:e,align:"left-top",padding:5});return{x:o.x,y:o.y,width:o.width,height:Math.max(HN,Math.round(a.height))}},this.createText=function(o,s){return r.createText(o,s||{})},this.getDefaultStyle=function(){return e},this.getExternalStyle=function(){return i}}yp.$inject=["config.textRenderer"];function Kv(){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,o;t.abspos?(r=t.abspos.x,o=t.abspos.y):(r=t.containerWidth*t.position.mx,o=t.containerHeight*t.position.my);var s={};if(t.position){for(var a=t.containerHeight/i.height*t.yScaleFactor,l=t.containerWidth/i.width*t.xScaleFactor,c=0;c<i.heightElements.length;c++)s["y"+c]=i.heightElements[c]*a;for(var u=0;u<i.widthElements.length;u++)s["x"+u]=i.widthElements[u]*l}var f=QN(i.d,{mx:r,my:o,e:s});return f}}var zN=/\{([^{}]+)\}/g,WN=/(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g;function UN(n,e,t){var i=t;return e.replace(WN,function(r,o,s,a,l){o=o||a,i&&(o in i&&(i=i[o]),typeof i=="function"&&l&&(i=i()))}),i=(i==null||i==t?n:i)+"",i}function QN(n,e){return String(n).replace(zN,function(t,i){return UN(t,i,e)})}var FC={__init__:["drdRenderer"],drdRenderer:["type",ff],textRenderer:["type",yp],pathMap:["type",Kv]};function yr(n,e,t,i){this._eventBus=n,this._canvas=e,this._elementRegistry=i,this._elementFactory=t}yr.$inject=["eventBus","canvas","elementFactory","elementRegistry"];yr.prototype.root=function(n){var e=this._elementFactory.createRoot(Gv(n));return this._canvas.setRootElement(e),e};yr.prototype.add=function(n){var e=this._elementFactory,t=this._canvas,i=this._eventBus,r=n.di,o,s,a,l,c,u;if(r.$instanceOf("dmndi:DMNShape"))u=r.bounds,c=Gv(n,{x:Math.round(u.x),y:Math.round(u.y),width:Math.round(u.width),height:Math.round(u.height)}),o=e.createShape(c),t.addShape(o),i.fire("drdElement.added",{element:o,di:r});else if(r.$instanceOf("dmndi:DMNEdge"))s=KN(r),a=this._getSource(n),l=this._getTarget(n),a&&l&&(c=Gv(n,{hidden:!1,source:a,target:l,waypoints:s}),o=e.createConnection(c),t.addConnection(o),i.fire("drdElement.added",{element:o,di:r}));else throw new Error("unknown di for element "+n.id);return o};yr.prototype._getSource=function(n){var e,t;if(O(n,"dmn:Association")?t=n.sourceRef:O(n,"dmn:InformationRequirement")?t=n.requiredDecision||n.requiredInput:O(n,"dmn:KnowledgeRequirement")?t=n.requiredKnowledge:O(n,"dmn:AuthorityRequirement")&&(t=n.requiredDecision||n.requiredInput||n.requiredAuthority),t&&(e=t.href),e)return this._getShape(qC(e))};yr.prototype._getTarget=function(n){return O(n,"dmn:Association")?n.targetRef&&this._getShape(qC(n.targetRef.href)):this._getShape(n.$parent.id)};yr.prototype._getShape=function(n){return this._elementRegistry.get(n)};function Gv(n,e){return T({id:n.id,type:n.$type,businessObject:n},e)}function KN(n){var e=n.waypoint;if(e)return Vt(e,function(t){var i={x:t.x,y:t.y};return T({original:i},i)})}function qC(n){return n.split("#").pop()}var VC={drdImporter:["type",yr]};var HC={__depends__:[FC,VC]};function Xv(n,e){return e=e||{},n.replace(/{([^}]+)}/g,function(t,i){return e[i]||"{"+i+"}"})}var qe={translate:["value",Xv]};function zC(n){!n||typeof n.stopPropagation!="function"||n.stopPropagation()}function vr(n){return n.originalEvent||n.srcEvent}function vp(n){zC(n),zC(vr(n))}function Un(n){return n.pointers&&n.pointers.length&&(n=n.pointers[0]),n.touches&&n.touches.length&&(n=n.touches[0]),n?{x:n.clientX,y:n.clientY}:null}function xp(){return/mac/i.test(navigator.platform)}function WC(n,e){return(vr(n)||n).button===e}function Sn(n){return WC(n,0)}function UC(n){return WC(n,1)}function hf(n){var e=vr(n)||n;return Sn(n)?xp()?e.metaKey:e.ctrlKey:!1}function df(n){var e=vr(n)||n;return Sn(n)&&e.shiftKey}function GN(n){return!0}function bp(n){return Sn(n)||UC(n)}var QC=500;function _p(n,e,t){var i=this;function r(w,R,A){if(!a(w,R)){var I,D,N;A?D=e.getGraphics(A):(I=R.delegateTarget||R.target,I&&(D=I,A=e.get(D))),!(!D||!A)&&(N=n.fire(w,{element:A,gfx:D,originalEvent:R}),N===!1&&(R.stopPropagation(),R.preventDefault()))}}var o={};function s(w){return o[w]}function a(w,R){var A=c[w]||Sn;return!A(R)}var l={click:"element.click",contextmenu:"element.contextmenu",dblclick:"element.dblclick",mousedown:"element.mousedown",mousemove:"element.mousemove",mouseover:"element.hover",mouseout:"element.out",mouseup:"element.mouseup"},c={"element.contextmenu":GN,"element.mousedown":bp,"element.mouseup":bp,"element.click":bp,"element.dblclick":bp};function u(w,R,A){var I=l[w];if(!I)throw new Error("unmapped DOM event name <"+w+">");return r(I,R,A)}var f="svg, .djs-element";function h(w,R,A,I){var D=o[A]=function(N){r(A,N)};I&&(c[A]=I),D.$delegate=_t.bind(w,f,R,D)}function d(w,R,A){var I=s(A);I&&_t.unbind(w,R,I.$delegate)}function p(w){k(l,function(R,A){h(w,A,R)})}function m(w){k(l,function(R,A){d(w,A,R)})}n.on("canvas.destroy",function(w){m(w.svg)}),n.on("canvas.init",function(w){p(w.svg)}),n.on(["shape.added","connection.added"],function(w){var R=w.element,A=w.gfx;n.fire("interactionEvents.createHit",{element:R,gfx:A})}),n.on(["shape.changed","connection.changed"],QC,function(w){var R=w.element,A=w.gfx;n.fire("interactionEvents.updateHit",{element:R,gfx:A})}),n.on("interactionEvents.createHit",QC,function(w){var R=w.element,A=w.gfx;i.createDefaultHit(R,A)}),n.on("interactionEvents.updateHit",function(w){var R=w.element,A=w.gfx;i.updateDefaultHit(R,A)});var g=C("djs-hit djs-hit-stroke"),b=C("djs-hit djs-hit-click-stroke"),_=C("djs-hit djs-hit-all"),v=C("djs-hit djs-hit-no-move"),x={all:_,"click-stroke":b,stroke:g,"no-move":v};function C(w,R){return R=T({stroke:"white",strokeWidth:15},R||{}),t.cls(w,["no-fill","no-border"],R)}function E(w,R){var A=x[R];if(!A)throw new Error("invalid hit type <"+R+">");return j(w,A),w}function S(w,R){K(w,R)}this.removeHits=function(w){var R=pn(".djs-hit",w);k(R,Fe)},this.createDefaultHit=function(w,R){var A=w.waypoints,I=w.isFrame,D;return A?this.createWaypointsHit(R,A):(D=I?"stroke":"all",this.createBoxHit(R,D,{width:w.width,height:w.height}))},this.createWaypointsHit=function(w,R){var A=ro(R);return E(A,"stroke"),S(w,A),A},this.createBoxHit=function(w,R,A){A=T({x:0,y:0},A);var I=Q("rect");return E(I,R),j(I,A),S(w,I),I},this.updateDefaultHit=function(w,R){var A=X(".djs-hit",R);if(A)return w.waypoints?bv(A,w.waypoints):j(A,{width:w.width,height:w.height}),A},this.fire=r,this.triggerMouseEvent=u,this.mouseHandler=s,this.registerEvent=h,this.unregisterEvent=d}_p.$inject=["eventBus","elementRegistry","styles"];var fo={__init__:["interactionEvents"],interactionEvents:["type",_p]};function ho(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)})}ho.$inject=["eventBus","canvas"];ho.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})}};ho.prototype.get=function(){return this._selectedElements};ho.prototype.isSelected=function(n){return this._selectedElements.indexOf(n)!==-1};ho.prototype.select=function(n,e){var t=this._selectedElements,i=t.slice();F(n)||(n=n?[n]:[]);var r=this._canvas,o=r.getRootElement();n=n.filter(function(s){var a=r.findRoot(s);return o===a}),e?k(n,function(s){t.indexOf(s)===-1&&t.push(s)}):this._selectedElements=t=n.slice(),this._eventBus.fire("selection.changed",{oldSelection:i,newSelection:t})};var KC="hover",GC="selected";function wp(n,e){this._canvas=n;function t(r,o){n.addMarker(r,o)}function i(r,o){n.removeMarker(r,o)}e.on("element.hover",function(r){t(r.element,KC)}),e.on("element.out",function(r){i(r.element,KC)}),e.on("selection.changed",function(r){function o(c){i(c,GC)}function s(c){t(c,GC)}var a=r.oldSelection,l=r.newSelection;k(a,function(c){l.indexOf(c)===-1&&o(c)}),k(l,function(c){a.indexOf(c)===-1&&s(c)})})}wp.$inject=["canvas","eventBus"];function Cp(n,e,t,i){n.on("create.end",500,function(r){var o=r.context,s=o.canExecute,a=o.elements,l=o.hints||{},c=l.autoSelect;if(s){if(c===!1)return;F(c)?e.select(c):e.select(a.filter(XN))}}),n.on("connect.end",500,function(r){var o=r.context,s=o.connection;s&&e.select(s)}),n.on("shape.move.end",500,function(r){var o=r.previousSelection||[],s=i.get(r.context.shape.id),a=ye(o,function(l){return s.id===l.id});a||e.select(s)}),n.on("element.click",function(r){if(Sn(r)){var o=r.element;o===t.getRootElement()&&(o=null);var s=e.isSelected(o),a=e.get().length>1,l=df(r);if(s&&a)return l?e.deselect(o):e.select(o);s?e.deselect(o):e.select(o,l)}})}Cp.$inject=["eventBus","selection","canvas","elementRegistry"];function XN(n){return!n.hidden}var ht={__init__:["selectionVisuals","selectionBehavior"],__depends__:[fo],selection:["type",ho],selectionVisuals:["type",wp],selectionBehavior:["type",Cp]};function po(n){this._counter=0,this._prefix=(n?n+"-":"")+Math.floor(Math.random()*1e9)+"-"}po.prototype.next=function(){return this._prefix+ ++this._counter};var YN=new po("ov"),ZN=500;function xt(n,e,t,i){this._eventBus=e,this._canvas=t,this._elementRegistry=i,this._ids=YN,this._overlayDefaults=T({show:null,scale:!0},n&&n.defaults),this._overlays={},this._overlayContainers=[],this._overlayRoot=JN(t.getContainer()),this._init()}xt.$inject=["config.overlays","eventBus","canvas","elementRegistry"];xt.prototype.get=function(n){if(Ie(n)&&(n={id:n}),Ie(n.element)&&(n.element=this._elementRegistry.get(n.element)),n.element){var e=this._getOverlayContainer(n.element,!0);return e?n.type?Ee(e.overlays,la({type:n.type})):e.overlays.slice():[]}else return n.type?Ee(this._overlays,la({type:n.type})):n.id?this._overlays[n.id]:null};xt.prototype.add=function(n,e,t){if(Pe(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=T({},this._overlayDefaults,t,{id:i,type:e,element:n,html:t.html}),this._addOverlay(t),i};xt.prototype.remove=function(n){var e=this.get(n)||[];F(e)||(e=[e]);var t=this;k(e,function(i){var r=t._getOverlayContainer(i.element,!0);if(i&&(Qe(i.html),Qe(i.htmlContainer),delete i.htmlContainer,delete i.element,delete t._overlays[i.id]),r){var o=r.overlays.indexOf(i);o!==-1&&r.overlays.splice(o,1)}})};xt.prototype.isShown=function(){return this._overlayRoot.style.display!=="none"};xt.prototype.show=function(){Ep(this._overlayRoot)};xt.prototype.hide=function(){Ep(this._overlayRoot,!1)};xt.prototype.clear=function(){this._overlays={},this._overlayContainers=[],no(this._overlayRoot)};xt.prototype._updateOverlayContainer=function(n){var e=n.element,t=n.html,i=e.x,r=e.y;if(e.waypoints){var o=Tt(e);i=o.x,r=o.y}XC(t,i,r),et(n.html,"data-container-id",e.id)};xt.prototype._updateOverlay=function(n){var e=n.position,t=n.htmlContainer,i=n.element,r=e.left,o=e.top;if(e.right!==void 0){var s;i.waypoints?s=Tt(i).width:s=i.width,r=e.right*-1+s}if(e.bottom!==void 0){var a;i.waypoints?a=Tt(i).height:a=i.height,o=e.bottom*-1+a}XC(t,r||0,o||0),this._updateOverlayVisibilty(n,this._canvas.viewbox())};xt.prototype._createOverlayContainer=function(n){var e=te('<div class="djs-overlays" />');is(e,{position:"absolute"}),this._overlayRoot.appendChild(e);var t={html:e,element:n,overlays:[]};return this._updateOverlayContainer(t),this._overlayContainers.push(t),t};xt.prototype._updateRoot=function(n){var e=n.scale||1,t="matrix("+[e,0,0,e,-1*n.x*e,-1*n.y*e].join(",")+")";YC(this._overlayRoot,t)};xt.prototype._getOverlayContainer=function(n,e){var t=ye(this._overlayContainers,function(i){return i.element===n});return!t&&!e?this._createOverlayContainer(n):t};xt.prototype._addOverlay=function(n){var e=n.id,t=n.element,i=n.html,r,o;i.get&&i.constructor.prototype.jquery&&(i=i.get(0)),Ie(i)&&(i=te(i)),o=this._getOverlayContainer(t),r=te('<div class="djs-overlay" data-overlay-id="'+e+'">'),is(r,{position:"absolute"}),r.appendChild(i),n.type&&ee(r).add("djs-overlay-"+n.type);var s=this._canvas.findRoot(t),a=this._canvas.getRootElement();Ep(r,s===a),n.htmlContainer=r,o.overlays.push(n),o.html.appendChild(r),this._overlays[e]=n,this._updateOverlay(n),this._updateOverlayVisibilty(n,this._canvas.viewbox())};xt.prototype._updateOverlayVisibilty=function(n,e){var t=n.show,i=this._canvas.findRoot(n.element),r=t&&t.minZoom,o=t&&t.maxZoom,s=n.htmlContainer,a=this._canvas.getRootElement(),l=!0;(i!==a||t&&(Me(r)&&r>e.scale||Me(o)&&o<e.scale))&&(l=!1),Ep(s,l),this._updateOverlayScale(n,e)};xt.prototype._updateOverlayScale=function(n,e){var t=n.scale,i,r,o=n.htmlContainer,s,a="";t!==!0&&(t===!1?(i=1,r=1):(i=t.min,r=t.max),Me(i)&&e.scale<i&&(s=(1/e.scale||1)*i),Me(r)&&e.scale>r&&(s=(1/e.scale||1)*r)),Me(s)&&(a="scale("+s+","+s+")"),YC(o,a)};xt.prototype._updateOverlaysVisibilty=function(n){var e=this;k(this._overlays,function(t){e._updateOverlayVisibilty(t,n)})};xt.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,o=e.get({element:r});k(o,function(l){e.remove(l.id)});var s=e._getOverlayContainer(r);if(s){Qe(s.html);var a=e._overlayContainers.indexOf(s);a!==-1&&e._overlayContainers.splice(a,1)}}),n.on("element.changed",ZN,function(i){var r=i.element,o=e._getOverlayContainer(r,!0);o&&(k(o.overlays,function(s){e._updateOverlay(s)}),e._updateOverlayContainer(o))}),n.on("element.marker.update",function(i){var r=e._getOverlayContainer(i.element,!0);r&&ee(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 JN(n){var e=te('<div class="djs-overlay-container" />');return is(e,{position:"absolute",width:0,height:0}),n.insertBefore(e,n.firstChild),e}function XC(n,e,t){is(n,{left:e+"px",top:t+"px"})}function Ep(n,e){n.style.display=e===!1?"none":""}function YC(n,e){n.style["transform-origin"]="top left",["","-ms-","-webkit-"].forEach(function(t){n.style[t+"transform"]=e})}var mo={__init__:["overlays"],overlays:["type",xt]};function _a(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='<div class="dmn-definitions"><div class="dmn-definitions-name" title="'+this._translate("Definition name")+'" spellcheck="false"></div><div class="dmn-definitions-id" title="'+this._translate("Definition ID")+'" spellcheck="false"></div></div>'}_a.$inject=["eventBus","canvas","translate"];_a.prototype._init=function(){var n=this._canvas,e=this._eventBus,t=n.getContainer(),i=this._container=te(this.HTML_MARKUP);t.appendChild(i),this.nameElement=X(".dmn-definitions-name",this._container),this.idElement=X(".dmn-definitions-id",this._container),_t.bind(i,".dmn-definitions-name, .dmn-definitions-id","mousedown",function(r){r.stopPropagation()}),e.fire("definitionIdView.create",{html:i})};_a.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 o=e.getContainer();ee(o).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 Ca={__depends__:[qe],__init__:["definitionPropertiesView","definitionPropertiesPaletteAdapter"],definitionPropertiesView:["type",_a],definitionPropertiesPaletteAdapter:["type",wa]};var ZC=[{className:"dmn-icon-decision-table",matches:function(n){var e=Ke(n);return O(e,"dmn:Decision")&&O(e.decisionLogic,"dmn:DecisionTable")},title:"Open decision table"},{className:"dmn-icon-literal-expression",matches:function(n){var e=dr(n);return O(e,"dmn:LiteralExpression")},title:"Open literal expression"}],Ea=class{constructor(e,t,i,r,o){this._injector=e,this._eventBus=t,this._overlays=i,this._translate=o,this._config=r||{enabled:!0},t.on(["shape.added"],({element:s})=>{for(let l=0;l<ZC.length;l++){let{matches:c,className:u,title:f}=ZC[l];var a=c&&c(s);a&&this.addOverlay(s,u,f)}})}addOverlay(e,t,i){let r=this._config.enabled!==!1,o=this._getOverlayNode(t,i,r),s=this._overlays.add(e,{position:{top:2,left:2},html:o});r&&(ee(o).add("interactive"),this.bindEventListener(e,o,s))}_getOverlayNode(e,t,i){let r=document.createElement("div");if(r.className="drill-down-overlay",!i){let s=document.createElement("span");return s.className=e,r.appendChild(s),r}let o=document.createElement("button");return o.type="button",o.className=e,o.title=this._translate(t),r.appendChild(o),r}bindEventListener(e,t,i){let r=this._overlays,o=this._eventBus,s=r._overlayRoot;_t.bind(s,'[data-overlay-id="'+i+'"]',"click",()=>{o.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}};Ea.$inject=["injector","eventBus","overlays","config.drillDown","translate"];var JC={__depends__:[mo,qe],__init__:["drillDown"],drillDown:["type",Ea]};function Et(n){this._container=this._createContainer(),Wv(this._container),this._init(this._container,n)}fe(Et,mr);Et.prototype.saveSVG=ha(function(n){var e=this;return new Promise(function(t){var i=e.get("canvas"),r=i.getActiveLayer(),o=X("defs",i._svg),s=w1(r),a=o&&o.outerHTML||"",l=r.getBBox(),c=`<?xml version="1.0" encoding="utf-8"?> 14<!-- created with dmn-js / http://bpmn.io --> 15<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> 16<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="`+l.width+'" height="'+l.height+'" viewBox="'+l.x+" "+l.y+" "+l.width+" "+l.height+'" version="1.1">'+a+s+"</svg>";t({svg:c})})});Et.prototype.getModules=function(){return this._modules};Et.prototype.destroy=function(){mr.prototype.destroy.call(this),Qe(this._container)};Et.prototype.on=function(n,e,t,i){return this.get("eventBus").on(n,e,t,i)};Et.prototype.off=function(n,e){this.get("eventBus").off(n,e)};Et.prototype._init=function(n,e){var{additionalModules:t,canvas:i,...r}=e,o=e.modules||this.getModules(),s=[{drd:["value",this]}],a=[...s,...o,...t||[]],l={...r,canvas:{...i,container:n},modules:a};mr.call(this,l),e&&e.container&&this.attachTo(e.container)};Et.prototype._emit=function(n,e){return this.get("eventBus").fire(n,e)};Et.prototype._createContainer=function(){return te('<div class="dmn-drd-container"></div>')};Et.prototype.open=function(n){var e=this;return new Promise((t,i)=>{var r;try{return e._definitions&&e.clear(),e._definitions=n,aC(e,n,function(o,s){o?(o.warnings=s||[],i(o)):t({warnings:s||[]})})}catch(o){r=o}r?(r.warnings=r.warnings||[],i(r)):t({warnings:[]})})};Et.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()};Et.prototype.detach=function(){var n=this._container,e=n.parentNode;e&&(this._emit("detach",{}),e.removeChild(n))};Et.prototype._modules=[HC,qe,ht,mo,Ca,JC];function Yv(n){return{x:n.x+n.width/2,y:n.y+n.height/2}}function xr(n,e){return{x:n.x-e.x,y:n.y-e.y}}function pf(n){return Math.log(n)/Math.log(10)}function Zv(n,e){var t=pf(n.min),i=pf(n.max),r=Math.abs(t)+Math.abs(i);return r/e}function eE(n,e){return Math.max(n.min,Math.min(n.max,e))}var e$=Math.sign||function(n){return n>=0?1:-1},Jv={min:.2,max:4},tE=10,t$=.1,n$=.75;function Qn(n,e,t){n=n||{},this._enabled=!1,this._canvas=t,this._container=t._container,this._handleWheel=at(this._handleWheel,this),this._totalDelta=0,this._scale=n.scale||n$;var i=this;e.on("canvas.mouseover",function(){i._init(n.enabled!==!1)}),e.on("canvas.mouseout",function(){i._init(!1)})}Qn.$inject=["config.zoomScroll","eventBus","canvas"];Qn.prototype.scroll=function(e){this._canvas.scroll(e)};Qn.prototype.reset=function(){this._canvas.zoom("fit-viewport")};Qn.prototype.zoom=function(e,t){var i=Zv(Jv,tE*2);this._totalDelta+=e,Math.abs(this._totalDelta)>t$&&(this._zoom(e,t,i),this._totalDelta=0)};Qn.prototype._handleWheel=function(e){if(this._enabled){var t=this._container;e.preventDefault();var i=e.ctrlKey||xp()&&e.metaKey,r=e.shiftKey,o=-1*this._scale,s;if(i?o*=e.deltaMode===0?.02:.32:o*=e.deltaMode===0?1:16,i){var a=t.getBoundingClientRect(),l={x:e.clientX-a.left,y:e.clientY-a.top};s=Math.sqrt(Math.pow(e.deltaY,2)+Math.pow(e.deltaX,2))*e$(e.deltaY)*o,this.zoom(s,l)}else r?s={dx:o*e.deltaY,dy:0}:s={dx:o*e.deltaX,dy:o*e.deltaY},this.scroll(s)}};Qn.prototype.stepZoom=function(e,t){var i=Zv(Jv,tE);this._zoom(e,t,i)};Qn.prototype._zoom=function(n,e,t){var i=this._canvas,r=n>0?1:-1,o=pf(i.zoom()),s=Math.round(o/t)*t;s+=t*r;var a=Math.pow(10,s);i.zoom(eE(Jv,a),e)};Qn.prototype.toggle=function(e){var t=this._container,i=this._handleWheel,r=this._enabled;return typeof e=="undefined"&&(e=!r),r!==e&&q[e?"bind":"unbind"](t,"wheel",i,!1),this._enabled=e,e};Qn.prototype._init=function(n){this.toggle(n)};var nE={__init__:["zoomScroll"],zoomScroll:["type",Qn]};var i$=/^djs-cursor-.*$/;function mf(n){var e=ee(document.body);e.removeMatching(i$),n&&e.add("djs-cursor-"+n)}function Sp(){mf(null)}var r$=5e3;function Op(n,e){e=e||"element.click";function t(){return!1}return n.once(e,r$,t),function(){n.off(e,t)}}var o$=15;function kp(n,e){var t;function i(a){return s(a.originalEvent)}n.on("canvas.focus.changed",function(a){a.focused?n.on("element.mousedown",500,i):n.off("element.mousedown",i)});function r(a){var l=t.start,c=t.button,u=Un(a),f=xr(u,l);if(!t.dragging&&s$(f)>o$&&(t.dragging=!0,c===0&&Op(n),mf("grab")),t.dragging){var h=t.last||t.start;f=xr(u,h),e.scroll({dx:f.x,dy:f.y}),t.last=u}a.preventDefault()}function o(a){q.unbind(document,"mousemove",r),q.unbind(document,"mouseup",o),t=null,Sp()}function s(a){if(!De(a.target,".djs-draggable")){var l=a.button;if(!(l>=2||a.ctrlKey||a.shiftKey||a.altKey))return t={button:l,start:Un(a)},q.bind(document,"mousemove",r),q.bind(document,"mouseup",o),!0}}this.isActive=function(){return!!t}}kp.$inject=["eventBus","canvas"];function s$(n){return Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2))}var iE={__init__:["moveCanvas"],moveCanvas:["type",kp]};function Sa(n){return CSS.escape(n)}var a$={"&":"&","<":"<",">":">",'"':""","'":"'"};function rE(n){return n=""+n,n&&n.replace(/[&<>"']/g,function(e){return a$[e]})}var oE=["c","C"],sE=["v","V"],l$=["d","D"],c$=["x","X"],aE=["y","Y"],ex=["z","Z"];function lE(n){return n.ctrlKey||n.metaKey||n.shiftKey||n.altKey}function Mt(n){return n.altKey?!1:n.ctrlKey||n.metaKey}function Ve(n,e){return n=F(n)?n:[n],n.indexOf(e.key)!==-1||n.indexOf(e.code)!==-1}function Rp(n){return n.shiftKey}function cE(n){return Mt(n)&&Ve(oE,n)}function uE(n){return Mt(n)&&Ve(sE,n)}function fE(n){return Mt(n)&&Ve(l$,n)}function hE(n){return Mt(n)&&Ve(c$,n)}function Tp(n){return Mt(n)&&!Rp(n)&&Ve(ex,n)}function Ap(n){return Mt(n)&&(Ve(aE,n)||Ve(ex,n)&&Rp(n))}var pE=300;function J(n,e,t,i){this._open=!1,this._results={},this._eventMaps=[],this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._canvas=n,this._eventBus=e,this._selection=t,this._translate=i,this._container=this._getBoxHtml(),this._searchInput=X(J.INPUT_SELECTOR,this._container),this._resultsContainer=X(J.RESULTS_CONTAINER_SELECTOR,this._container),this._canvas.getContainer().appendChild(this._container),e.on(["canvas.destroy","diagram.destroy","drag.init","elements.changed"],this.close,this)}J.$inject=["canvas","eventBus","selection","translate"];J.prototype._bindEvents=function(){var n=this;function e(t,i,r,o){n._eventMaps.push({el:t,type:r,listener:_t.bind(t,i,r,o)})}e(document,"html","click",function(t){n.close(!1)}),e(this._container,J.INPUT_SELECTOR,"click",function(t){t.stopPropagation(),t.delegateTarget.focus()}),e(this._container,J.RESULT_SELECTOR,"mouseover",function(t){t.stopPropagation(),n._scrollToNode(t.delegateTarget),n._preselect(t.delegateTarget)}),e(this._container,J.RESULT_SELECTOR,"click",function(t){t.stopPropagation(),n._select(t.delegateTarget)}),e(this._container,J.INPUT_SELECTOR,"keydown",function(t){Ve("ArrowUp",t)&&t.preventDefault(),Ve("ArrowDown",t)&&t.preventDefault()}),e(this._container,J.INPUT_SELECTOR,"keyup",function(t){if(Ve("Escape",t))return n.close();if(Ve("Enter",t)){var i=n._getCurrentResult();return i?n._select(i):n.close(!1)}if(Ve("ArrowUp",t))return n._scrollToDirection(!0);if(Ve("ArrowDown",t))return n._scrollToDirection();Ve(["ArrowLeft","ArrowRight"],t)||n._search(t.delegateTarget.value)})};J.prototype._unbindEvents=function(){this._eventMaps.forEach(function(n){_t.unbind(n.el,n.type,n.listener)})};J.prototype._search=function(n){var e=this;if(this._clearResults(),!!n.trim()){var t=this._searchProvider.find(n);if(t=t.filter(function(r){return!e._canvas.getRootElements().includes(r.element)}),!t.length){this._selection.select(null);return}t.forEach(function(r){var o=r.element.id,s=e._createResultNode(r,o);e._results[o]={element:r.element,node:s}});var i=X(J.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}};J.prototype._scrollToDirection=function(n){var e=this._getCurrentResult();if(e){var t=n?e.previousElementSibling:e.nextElementSibling;t&&(this._scrollToNode(t),this._preselect(t))}};J.prototype._scrollToNode=function(n){if(!(!n||n===this._getCurrentResult())){var e=n.offsetTop,t=this._resultsContainer.scrollTop,i=e-this._resultsContainer.clientHeight+n.clientHeight;e<t?this._resultsContainer.scrollTop=e:t<i&&(this._resultsContainer.scrollTop=i)}};J.prototype._clearResults=function(){no(this._resultsContainer),this._results={},this._eventBus.fire("searchPad.cleared")};J.prototype._getCurrentResult=function(){return X(J.RESULT_SELECTED_SELECTOR,this._resultsContainer)};J.prototype._createResultNode=function(n,e){var t=te(J.RESULT_HTML);return n.primaryTokens.length>0&&dE(t,n.primaryTokens,J.RESULT_PRIMARY_HTML),dE(t,n.secondaryTokens,J.RESULT_SECONDARY_HTML),et(t,J.RESULT_ID_ATTRIBUTE,e),this._resultsContainer.appendChild(t),t};J.prototype.registerProvider=function(n){this._searchProvider=n};J.prototype.open=function(){if(!this._searchProvider)throw new Error("no search provider registered");this.isOpen()||(this._cachedRootElement=this._canvas.getRootElement(),this._cachedSelection=this._selection.get(),this._cachedViewbox=this._canvas.viewbox(),this._selection.select(null),this._bindEvents(),this._open=!0,ee(this._canvas.getContainer()).add("djs-search-open"),ee(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))};J.prototype.close=function(n=!0){this.isOpen()&&(n&&(this._cachedRootElement&&this._canvas.setRootElement(this._cachedRootElement),this._cachedSelection&&this._selection.select(this._cachedSelection),this._cachedViewbox&&this._canvas.viewbox(this._cachedViewbox),this._eventBus.fire("searchPad.restored")),this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._unbindEvents(),this._open=!1,ee(this._canvas.getContainer()).remove("djs-search-open"),ee(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._eventBus.fire("searchPad.closed"),this._canvas.restoreFocus())};J.prototype.toggle=function(){this.isOpen()?this.close():this.open()};J.prototype.isOpen=function(){return this._open};J.prototype._preselect=function(n){var e=this._getCurrentResult();if(n!==e){e&&ee(e).remove(J.RESULT_SELECTED_CLASS);var t=et(n,J.RESULT_ID_ATTRIBUTE),i=this._results[t].element;ee(n).add(J.RESULT_SELECTED_CLASS),this._canvas.scrollToElement(i,{top:pE}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}};J.prototype._select=function(n){var e=et(n,J.RESULT_ID_ATTRIBUTE),t=this._results[e].element;this._cachedSelection=null,this._cachedViewbox=null,this.close(!1),this._canvas.scrollToElement(t,{top:pE}),this._selection.select(t),this._eventBus.fire("searchPad.selected",t)};J.prototype._getBoxHtml=function(){let n=te(J.BOX_HTML),e=X(J.INPUT_SELECTOR,n);return e&&e.setAttribute("aria-label",this._translate("Search in diagram")),n};function dE(n,e,t){var i=u$(e),r=te(t);r.innerHTML=i,n.appendChild(r)}function u$(n){var e="";return n.forEach(function(t){var i=rE(t.value||t.matched||t.normal),r=t.match||t.matched;r?e+='<b class="'+J.RESULT_HIGHLIGHT_CLASS+'">'+i+"</b>":e+=i}),e!==""?e:null}J.CONTAINER_SELECTOR=".djs-search-container";J.INPUT_SELECTOR=".djs-search-input input";J.RESULTS_CONTAINER_SELECTOR=".djs-search-results";J.RESULT_SELECTOR=".djs-search-result";J.RESULT_SELECTED_CLASS="djs-search-result-selected";J.RESULT_SELECTED_SELECTOR="."+J.RESULT_SELECTED_CLASS;J.RESULT_ID_ATTRIBUTE="data-result-id";J.RESULT_HIGHLIGHT_CLASS="djs-search-highlight";J.BOX_HTML=`<div class="djs-search-container djs-scrollable"> 17 <div class="djs-search-input"> 18 <svg class="djs-search-icon" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"> 19 <path fill-rule="evenodd" clip-rule="evenodd" d="M9.0325 8.5H9.625L13.3675 12.25L12.25 13.3675L8.5 9.625V9.0325L8.2975 8.8225C7.4425 9.5575 6.3325 10 5.125 10C2.4325 10 0.25 7.8175 0.25 5.125C0.25 2.4325 2.4325 0.25 5.125 0.25C7.8175 0.25 10 2.4325 10 5.125C10 6.3325 9.5575 7.4425 8.8225 8.2975L9.0325 8.5ZM1.75 5.125C1.75 6.9925 3.2575 8.5 5.125 8.5C6.9925 8.5 8.5 6.9925 8.5 5.125C8.5 3.2575 6.9925 1.75 5.125 1.75C3.2575 1.75 1.75 3.2575 1.75 5.125Z" fill="#22242A"/> 20 </svg> 21 <input type="text" spellcheck="false" /> 22 </div> 23 <div class="djs-search-results" /> 24</div>`;J.RESULT_HTML='<div class="djs-search-result"></div>';J.RESULT_PRIMARY_HTML='<div class="djs-search-result-primary"></div>';J.RESULT_SECONDARY_HTML='<p class="djs-search-result-secondary"></p>';var mE={__depends__:[qe,mo,ht],searchPad:["type",J]};function gE(n){if(O(n,"dmn:Decision")||O(n,"dmn:BusinessKnowledgeModel")||O(n,"dmn:InputData")||O(n,"dmn:KnowledgeSource"))return"name";if(O(n,"dmn:TextAnnotation"))return"text"}function fs(n){var e=n.businessObject,t=gE(e);if(t)return e[t]||""}function yE(n,e,t){var i=n.businessObject,r=gE(i);return r&&(i[r]=e),t&&(n.hidden=!e),n}function gf(n,e,t){this._elementRegistry=n,this._canvas=t,e.registerProvider(this)}gf.$inject=["elementRegistry","searchPad","canvas"];gf.prototype.find=function(n){let e=this._canvas.getRootElement(),t=this._elementRegistry.filter(function(i){return!i.labelTarget});return t=Ee(t,function(i){return i!==e}),t=Vt(t,function(i){return{primaryTokens:xE(fs(i),n),secondaryTokens:xE(i.id,n),element:i}}),t=Ee(t,function(i){return vE(i.primaryTokens)||vE(i.secondaryTokens)}),t=Fn(t,function(i){return fs(i.element)+i.element.id}),t};function vE(n){return Ee(n,function(t){return!!t.matched}).length>0}function xE(n,e){let t=[],i=n;if(!n)return t;n=n.toLowerCase(),e=e.toLowerCase();let r=n.indexOf(e);return r>-1?(r!==0&&t.push({normal:i.substr(0,r)}),t.push({matched:i.substr(r,e.length)}),e.length+r<n.length&&t.push({normal:i.substr(e.length+r,n.length)})):t.push({normal:i}),t}var bE={__depends__:[mE],__init__:["dmnSearch"],dmnSearch:["type",gf]};function br(n){Et.call(this,n)}fe(br,Et);br.prototype._navigationModules=[nE,iE,bE];br.prototype._modules=[].concat(br.prototype._modules,br.prototype._navigationModules);function tx(n){return n&&n[n.length-1]}function _E(n){return n.y}function wE(n){return n.x}var f$={left:wE,center:wE,right:function(n){return n.x+n.width},top:_E,middle:_E,bottom:function(n){return n.y+n.height}};function go(n,e){this._modeling=n,this._rules=e}go.$inject=["modeling","rules"];go.prototype._getOrientationDetails=function(n){var e=["top","bottom","middle"],t="x",i="width";return e.indexOf(n)!==-1&&(t="y",i="height"),{axis:t,dimension:i}};go.prototype._isType=function(n,e){return e.indexOf(n)!==-1};go.prototype._alignmentPosition=function(n,e){var t=this._getOrientationDetails(n),i=t.axis,r=t.dimension,o={},s={},a=!1,l,c,u;function f(h,d){return Math.round((h[i]+d[i]+d[r])/2)}if(this._isType(n,["left","top"]))o[n]=e[0][i];else if(this._isType(n,["right","bottom"]))u=tx(e),o[n]=u[i]+u[r];else if(this._isType(n,["center","middle"])){if(k(e,function(h){var d=h[i]+Math.round(h[r]/2);s[d]?s[d].elements.push(h):s[d]={elements:[h],center:d}}),l=Fn(s,function(h){return h.elements.length>1&&(a=!0),h.elements.length}),a)return o[n]=tx(l).center,o;c=e[0],e=Fn(e,function(h){return h[i]+h[r]}),u=tx(e),o[n]=f(c,u)}return o};go.prototype.trigger=function(n,e){var t=this._modeling,i,r=Ee(n,function(l){return!(l.waypoints||l.host||l.labelTarget)});if(i=this._rules.allowed("elements.align",{elements:r}),F(i)&&(r=i),!(r.length<2||!i)){var o=f$[e],s=Fn(r,o),a=this._alignmentPosition(e,s);t.alignElements(s,a)}};var CE={__init__:["alignElements"],alignElements:["type",go]};var h$=10,ix=50,d$=250;function rx(n,e,t,i){for(var r;r=p$(n,t,e);)t=i(e,t,r);return t}function EE(n){return function(e,t,i){var r={x:t.x,y:t.y};return["x","y"].forEach(function(o){var s=n[o];if(s){var a=o==="x"?"width":"height",l=s.margin,c=s.minDistance;l<0?r[o]=Math.min(i[o]+l-e[a]/2,t[o]-c+l):r[o]=Math.max(i[o]+i[a]+l+e[a]/2,t[o]+c+l)}}),r}}function p$(n,e,t){var i={x:e.x-t.width/2,y:e.y-t.height/2,width:t.width,height:t.height},r=m$(n);return ye(r,function(o){if(o===t)return!1;var s=vt(o,i,h$);return s==="intersect"})}function SE(n,e){e||(e={});function t(p){return p.source===n?1:-1}var i=e.defaultDistance||ix,r=e.direction||"e",o=e.filter,s=e.getWeight||t,a=e.maxDistance||d$,l=e.reference||"start";o||(o=v$);function c(p,m){return r==="n"?l==="start"?G(p).top-G(m).bottom:l==="center"?G(p).top-le(m).y:G(p).top-G(m).top:r==="w"?l==="start"?G(p).left-G(m).right:l==="center"?G(p).left-le(m).x:G(p).left-G(m).left:r==="s"?l==="start"?G(m).top-G(p).bottom:l==="center"?le(m).y-G(p).bottom:G(m).bottom-G(p).bottom:l==="start"?G(m).left-G(p).right:l==="center"?le(m).x-G(p).right:G(m).right-G(p).right}var u=n.incoming.filter(o).map(function(p){var m=s(p),g=m<0?c(p.source,n):c(n,p.source);return{id:p.source.id,distance:g,weight:m}}),f=n.outgoing.filter(o).map(function(p){var m=s(p),g=m>0?c(n,p.target):c(p.target,n);return{id:p.target.id,distance:g,weight:m}}),h=u.concat(f).reduce(function(p,m){return p[m.id+"__weight_"+m.weight]=m,p},{}),d=st(h,function(p,m){var g=m.distance,b=m.weight;return g<0||g>a||(p[String(g)]||(p[String(g)]=0),p[String(g)]+=1*b,(!p.distance||p[p.distance]<p[String(g)])&&(p.distance=g)),p},{});return d.distance||i}function m$(n){var e=nx(n);return n.host&&(e=e.concat(nx(n.host))),n.attachers&&(e=e.concat(n.attachers.reduce(function(t,i){return t.concat(nx(i))},[]))),e}function nx(n){return y$(n).concat(g$(n))}function g$(n){return n.incoming.map(function(e){return e.source})}function y$(n){return n.outgoing.map(function(e){return e.target})}function v$(){return!0}var x$=100;function Mp(n,e,t){n.on("autoPlace",x$,function(i){var r=i.shape,o=i.source;return b$(o,r)}),n.on("autoPlace.end",function(i){t.scrollToElement(i.shape)}),this.append=function(i,r,o){n.fire("autoPlace.start",{source:i,shape:r});var s=n.fire("autoPlace",{source:i,shape:r}),a=e.appendShape(i,r,s,i.parent,o);return n.fire("autoPlace.end",{source:i,shape:a}),a}}Mp.$inject=["eventBus","modeling","canvas"];function b$(n,e,t){t||(t={});var i=t.defaultDistance||ix,r=le(n),o=G(n);return{x:o.right+i+e.width/2,y:r.y}}function Pp(n,e){n.on("autoPlace.end",500,function(t){e.select(t.shape)})}Pp.$inject=["eventBus","selection"];var OE={__init__:["autoPlaceSelectionBehavior"],autoPlace:["type",Mp],autoPlaceSelectionBehavior:["type",Pp]};var _$={width:135,height:46},ox={width:180,height:80},w$={width:125,height:45},C$={width:100,height:63};function _r(n){Hn.call(this),this._drdFactory=n}fe(_r,Hn);_r.$inject=["drdFactory"];_r.prototype.baseCreate=Hn.prototype.create;_r.prototype.create=function(n,e){return this.createDrdElement(n,e)};_r.prototype.createDrdElement=function(n,e){var t=this._drdFactory,i;e=e||{};var r=e.businessObject;if(!r){if(!e.type)throw new Error("no shape type specified");r=t.create(e.type)}return r.di||(n==="connection"?r.di=t.createDiEdge(r,[]):n==="shape"&&(r.di=t.createDiShape(r,{}))),i=this._getDefaultSize(r),e=T({businessObject:r,id:r.id},i,e),this.baseCreate(n,e)};_r.prototype._getDefaultSize=function(n){return O(n,"dmn:BusinessKnowledgeModel")?_$:O(n,"dmn:Decision")?ox:O(n,"dmn:InputData")?w$:O(n,"dmn:KnowledgeSource")?C$:{width:100,height:80}};var sx="left",kE="right",Dp=60,RE=ox.width;function AE(n,e){if(O(e,"dmn:TextAnnotation"))return E$(n,e);if(O(e,"dmn:DRGElement"))return S$(n,e)}function E$(n,e){var t=G(n),i={x:t.right+e.width/2,y:t.top-50-e.height/2},r={y:{margin:-30,minDistance:20}};return rx(n,e,i,EE(r))}function S$(n,e){var t=G(n),i=le(n);function r(a){return a.target===n?1:-1}var o=SE(n,{defaultDistance:180,direction:"s",getWeight:r,filter:O$,reference:"center"}),s={x:i.x,y:t.bottom+o};return rx(n,e,s,k$(n))}function O$(n){return!O(n,"dmn:Association")}function TE(n,e){return Math.abs(e.x-n.x)}function k$(n){var e=le(n),t,i;return function(r,o,s){var a;return t?(o.x<e.x?t=s:i=s,TE(e,le(t))<TE(e,le(i))?a=sx:a=kE):(t=s,i=s,le(s).x-e.x>0?a=sx:a=kE),a===sx?{x:Math.min(le(t).x-RE-Dp,G(t).left-Dp-r.width/2),y:o.y}:{x:Math.max(le(i).x+RE+Dp,G(i).right+Dp+r.width/2),y:o.y}}}function Ip(n){n.on("autoPlace",function(e){var t=e.shape,i=e.source;return AE(i,t)})}Ip.$inject=["eventBus"];var ME={__depends__:[OE],__init__:["dmnAutoPlace"],dmnAutoPlace:["type",Ip]};var PE=1500;function Lp(n,e,t){var i=this,r=t.get("dragging",!1);function o(s){if(!s.hover){var a=s.originalEvent,l=i._findTargetGfx(a),c=l&&n.get(l);l&&c&&(s.stopPropagation(),r.hover({element:c,gfx:l}),r.move(a))}}r&&e.on("drag.start",function(s){e.once("drag.move",PE,function(a){o(a)})}),(function(){var s,a;e.on("element.hover",function(l){s=l.gfx,a=l.element}),e.on("element.hover",PE,function(l){a&&e.fire("element.out",{element:a,gfx:s})}),e.on("element.out",function(){s=null,a=null})})(),this._findTargetGfx=function(s){var a,l;if(s instanceof MouseEvent)return a=Un(s),l=document.elementFromPoint(a.x,a.y),R$(l)}}Lp.$inject=["elementRegistry","eventBus","injector"];function R$(n){return De(n,"svg, .djs-element",!0)}var DE={__init__:["hoverFix"],hoverFix:["type",Lp]};var Oa=Math.round,IE="djs-drag-active";function hs(n){n.preventDefault()}function T$(n){return typeof TouchEvent!="undefined"&&n instanceof TouchEvent}function A$(n){return Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2))}function Bp(n,e,t,i){var r={threshold:5,trapClick:!0},o;function s(v){var x=e.viewbox(),C=e._container.getBoundingClientRect();return{x:x.x+(v.x-C.left)/x.scale,y:x.y+(v.y-C.top)/x.scale}}function a(v,x){x=x||o;var C=n.createEvent(T({},x.payload,x.data,{isTouch:x.isTouch}));return n.fire("drag."+v,C)===!1?!1:n.fire(x.prefix+"."+v,C)}function l(v){var x=v.filter(function(C){return i.get(C.id)});x.length&&t.select(x)}function c(v,x){var C=o.payload,E=o.displacement,S=o.globalStart,w=Un(v),R=xr(w,S),A=o.localStart,I=s(w),D=xr(I,A);if(!o.active&&(x||A$(R)>o.threshold)){if(T(C,{x:Oa(A.x+E.x),y:Oa(A.y+E.y),dx:0,dy:0},{originalEvent:v}),a("start")===!1)return g();o.active=!0,o.keepSelection||(C.previousSelection=t.get(),t.select(null)),o.cursor&&mf(o.cursor),e.addMarker(e.getRootElement(),IE)}vp(v),o.active&&(T(C,{x:Oa(I.x+E.x),y:Oa(I.y+E.y),dx:Oa(D.x),dy:Oa(D.y)},{originalEvent:v}),a("move"))}function u(v){var x,C=!0;o.active&&(v&&(o.payload.originalEvent=v,vp(v)),C=a("end")),C===!1&&a("rejected"),x=b(C!==!0),a("ended",x)}function f(v){Ve("Escape",v)&&(hs(v),g())}function h(v){var x;o.active&&(x=Op(n),setTimeout(x,400),hs(v)),u(v)}function d(v){c(v)}function p(v){var x=o.payload;x.hoverGfx=v.gfx,x.hover=v.element,a("hover")}function m(v){a("out");var x=o.payload;x.hoverGfx=null,x.hover=null}function g(v){var x;if(o){var C=o.active;C&&a("cancel"),x=b(v),C&&a("canceled",x)}}function b(v){var x,C;a("cleanup"),Sp(),o.trapClick?C=h:C=u,q.unbind(document,"mousemove",c),q.unbind(document,"dragstart",hs),q.unbind(document,"selectstart",hs),q.unbind(document,"mousedown",C,!0),q.unbind(document,"mouseup",C,!0),q.unbind(document,"keyup",f),q.unbind(document,"touchstart",d,!0),q.unbind(document,"touchcancel",g,!0),q.unbind(document,"touchmove",c,!0),q.unbind(document,"touchend",u,!0),n.off("element.hover",p),n.off("element.out",m),e.removeMarker(e.getRootElement(),IE);var E=o.payload.previousSelection;return v!==!1&&E&&!t.get().length&&l(E),x=o,o=null,x}function _(v,x,C,E){o&&g(!1),typeof x=="string"&&(E=C,C=x,x=null),E=T({},r,E||{});var S=E.data||{},w,R,A,I,D;if(E.trapClick?I=h:I=u,v?(w=vr(v)||v,R=Un(v),vp(v),w.type==="dragstart"&&hs(w)):(w=null,R={x:0,y:0}),A=s(R),x||(x=A),D=T$(w),o=T({prefix:C,data:S,payload:{},globalStart:R,displacement:xr(x,A),localStart:A,isTouch:D},E),E.manual||(D?(q.bind(document,"touchstart",d,!0),q.bind(document,"touchcancel",g,!0),q.bind(document,"touchmove",c,!0),q.bind(document,"touchend",u,!0)):(q.bind(document,"mousemove",c),q.bind(document,"dragstart",hs),q.bind(document,"selectstart",hs),q.bind(document,"mousedown",I,!0),q.bind(document,"mouseup",I,!0)),q.bind(document,"keyup",f),n.on("element.hover",p),n.on("element.out",m)),a("init")===!1)return g(),!1;E.autoActivate&&c(v,!0)}n.on("diagram.destroy",g),this.init=_,this.move=c,this.hover=p,this.out=m,this.end=u,this.cancel=g,this.context=function(){return o},this.setOptions=function(v){T(r,v)}}Bp.$inject=["eventBus","canvas","selection","elementRegistry"];var gn={__depends__:[DE,ht],dragging:["type",Bp]};function yo(n,e,t){this._canvas=t,this._opts=T({scrollThresholdIn:[20,20,20,20],scrollThresholdOut:[0,0,0,0],scrollRepeatTimeout:15,scrollStep:10},n);var i=this;e.on("drag.move",function(r){var o=i._toBorderPoint(r);i.startScroll(o)}),e.on(["drag.cleanup"],function(){i.stopScroll()})}yo.$inject=["config.autoScroll","eventBus","canvas"];yo.prototype.startScroll=function(n){var e=this._canvas,t=this._opts,i=this,r=e.getContainer().getBoundingClientRect(),o=[n.x,n.y,r.width-n.x,r.height-n.y];this.stopScroll();for(var s=0,a=0,l=0;l<4;l++)M$(o[l],t.scrollThresholdOut[l],t.scrollThresholdIn[l])&&(l===0?s=t.scrollStep:l==1?a=t.scrollStep:l==2?s=-t.scrollStep:l==3&&(a=-t.scrollStep));(s!==0||a!==0)&&(e.scroll({dx:s,dy:a}),this._scrolling=setTimeout(function(){i.startScroll(n)},t.scrollRepeatTimeout))};function M$(n,e,t){return e<n&&n<t}yo.prototype.stopScroll=function(){clearTimeout(this._scrolling)};yo.prototype.setOptions=function(n){this._opts=T({},this._opts,n)};yo.prototype._toBorderPoint=function(n){var e=this._canvas._container.getBoundingClientRect(),t=Un(n.originalEvent);return{x:t.x-e.left,y:t.y-e.top}};var LE={__depends__:[gn],__init__:["autoScroll"],autoScroll:["type",yo]};function yf(n){this._commandStack=n.get("commandStack",!1)}yf.$inject=["injector"];yf.prototype.allowed=function(n,e){var t=!0,i=this._commandStack;return i&&(t=i.canExecute(n,e)),t===void 0?!0:t};var yn={__init__:["rules"],rules:["type",yf]};var Np=Math.round,P$=Math.max;function D$(n,e){var t=n.x,i=n.y;return[["M",t,i],["m",0,-e],["a",e,e,0,1,1,0,2*e],["a",e,e,0,1,1,0,-2*e],["z"]]}function I$(n){var e=[];return n.forEach(function(t,i){e.push([i===0?"M":"L",t.x,t.y])}),e}var BE=10;function L$(n,e){var t,i;for(t=0;i=n[t];t++)if(pa(i,e)<=BE)return{point:n[t],bendpoint:!0,index:t};return null}function B$(n,e){var t=ef(D$(e,BE),I$(n)),i=t[0],r=t[t.length-1],o;return i?i!==r?i.segment2!==r.segment2?(o=P$(i.segment2,r.segment2)-1,{point:n[o],bendpoint:!0,index:o}):{point:{x:Np(i.x+r.x)/2,y:Np(i.y+r.y)/2},index:i.segment2}:{point:{x:Np(i.x),y:Np(i.y)},index:i.segment2}:null}function NE(n,e){return L$(n,e)||B$(n,e)}function N$(n){return Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2))}function $$(n,e,t){var i=[{n:n[0]-t[0],lambda:e[0]},{n:n[1]-t[1],lambda:e[1]}],r=i[0].n*e[0]+i[1].n*e[1],o=i[0].lambda*e[0]+i[1].lambda*e[1];return-r/o}function ax(n,e){var t=e[0],i=e[1],r={x:i.x-t.x,y:i.y-t.y},o=$$([t.x,t.y],[r.x,r.y],[n.x,n.y]);return{x:t.x+o*r.x,y:t.y+o*r.y}}function $E(n,e){var t=ax(n,e),i={x:t.x-n.x,y:t.y-n.y};return N$(i)}var lx="djs-bendpoint",cx="djs-segment-dragger";function j$(n,e){var t=Un(e),i=n._container.getBoundingClientRect(),r;r={x:i.left,y:i.top};var o=n.viewbox();return{x:o.x+(t.x-r.x)/o.scale,y:o.y+(t.y-r.y)/o.scale}}function vf(n,e,t){var i=j$(n,t),r=NE(e,i);return r}function xf(n,e){var t=Q("g");ne(t).add(lx),K(n,t);var i=Q("circle");j(i,{cx:0,cy:0,r:4}),ne(i).add("djs-visual"),K(t,i);var r=Q("circle");return j(r,{cx:0,cy:0,r:10}),ne(r).add("djs-hit"),K(t,r),e&&ne(t).add(e),t}function F$(n,e,t,i){var r=Q("g");K(n,r);var o=18,s=6,a=11,l=q$(e,t,i),c=s+a,u=Q("rect");j(u,{x:-o/2,y:-s/2,width:o,height:s}),ne(u).add("djs-visual"),K(r,u);var f=Q("rect");return j(f,{x:-l/2,y:-c/2,width:l,height:c}),ne(f).add("djs-hit"),K(r,f),rC(r,i==="v"?90:0,0,0),r}function jp(n,e,t){var i=Q("g"),r=Ju(e,t),o=pr(e,t);return K(n,i),F$(i,e,t,o),ne(i).add(cx),ne(i).add(o==="h"?"horizontal":"vertical"),jt(i,r.x,r.y),i}function $p(n){return Math.abs(Math.round(n*2/3))}function jE(n,e){var t=V$(n,e);return ax(n,t)}function q$(n,e,t){var i=e.x-n.x,r=e.y-n.y;return $p(t==="h"?i:r)}function V$(n,e){for(var t=e.waypoints,i=1/0,r,o=0;o<t.length-1;o++){var s=t[o],a=t[o+1],l=$E(n,[s,a]);l<i&&(i=l,r=o)}return[t[r],t[r+1]]}function Fp(n,e,t,i,r){function o(v,x,C){var E=v.index,S=v.point,w,R,A,I,D,N;return E<=0||v.bendpoint?!1:(w=x[E-1],R=x[E],A=Ju(w,R),I=pr(w,R),D=Math.abs(S.x-A.x),N=Math.abs(S.y-A.y),I&&D<=C&&N<=C)}function s(v,x){var C=v.waypoints,E,S,w,R;return x.index<=0||x.bendpoint||(E={start:C[x.index-1],end:C[x.index]},S=pr(E.start,E.end),!S)?null:(S==="h"?w=E.end.x-E.start.x:w=E.end.y-E.start.y,R=$p(w)/2,R)}function a(v,x){var C=x.waypoints,E=vf(e,C,v),S;if(E){S=s(x,E);var w;if(o(E,C,S)?w=r.start(v,x,E.index):w=i.start(v,x,E.index,!E.bendpoint),w!==!1)return!0}}function l(v,x,C){q.bind(v,x,function(E){t.triggerMouseEvent(x,E,C),E.stopPropagation()})}function c(v,x){var C=e.getLayer("overlays"),E=X('.djs-bendpoints[data-element-id="'+Sa(v.id)+'"]',C);return!E&&x&&(E=Q("g"),j(E,{"data-element-id":v.id}),ne(E).add("djs-bendpoints"),K(C,E),l(E,"mousedown",v),l(E,"click",v),l(E,"dblclick",v)),E}function u(v,x){return X('.djs-segment-dragger[data-segment-idx="'+v+'"]',x)}function f(v,x){x.waypoints.forEach(function(C,E){var S=xf(v);K(v,S),jt(S,C.x,C.y)}),xf(v,"floating")}function h(v,x){for(var C=x.waypoints,E,S,w,R=1;R<C.length;R++)E=C[R-1],S=C[R],pr(E,S)&&(w=jp(v,E,S),j(w,{"data-segment-idx":R}),l(w,"mousemove",x))}function d(v){k(pn("."+lx,v),function(x){Fe(x)})}function p(v){k(pn("."+cx,v),function(x){Fe(x)})}function m(v){var x=c(v);return x||(x=c(v,!0),f(x,v),h(x,v)),x}function g(v){var x=c(v);x&&(p(x),d(x),h(x,v),f(x,v))}function b(v,x){var C=X(".floating",v),E=x.point;C&&jt(C,E.x,E.y)}function _(v,x,C){var E=u(x.index,v),S=C[x.index-1],w=C[x.index],R=x.point,A=Ju(S,w),I=pr(S,w),D,N;E&&(D=H$(E),N={x:R.x-A.x,y:R.y-A.y},I==="v"&&(N={x:N.y,y:N.x}),jt(D,N.x,N.y))}n.on("connection.changed",function(v){g(v.element)}),n.on("connection.remove",function(v){var x=c(v.element);x&&Fe(x)}),n.on("element.marker.update",function(v){var x=v.element,C;x.waypoints&&(C=m(x),v.add?ne(C).add(v.marker):ne(C).remove(v.marker))}),n.on("element.mousemove",function(v){var x=v.element,C=x.waypoints,E,S;if(C){if(E=c(x,!0),S=vf(e,C,v.originalEvent),!S)return;b(E,S),S.bendpoint||_(E,S,C)}}),n.on("element.mousedown",function(v){if(Sn(v)){var x=v.originalEvent,C=v.element;if(C.waypoints)return a(x,C)}}),n.on("selection.changed",function(v){var x=v.newSelection,C=x[0];C&&C.waypoints&&m(C)}),n.on("element.hover",function(v){var x=v.element;x.waypoints&&m(x)}),n.on("element.updateId",function(v){var x=v.element,C=v.newId;if(x.waypoints){var E=c(x);E&&j(E,{"data-element-id":C})}}),this.addHandles=m,this.updateHandles=g,this.getBendpointsContainer=c,this.getSegmentDragger=u}Fp.$inject=["eventBus","canvas","interactionEvents","bendpointMove","connectionSegmentMove"];function H$(n){return X(".djs-visual",n)}var FE=Math.round,ds="reconnectStart",ps="reconnectEnd",bf="updateWaypoints";function wf(n,e,t,i,r,o){this._injector=n,this.start=function(s,a,l,c){var u=t.getGraphics(a),f=a.source,h=a.target,d=a.waypoints,p;!c&&l===0?p=ds:!c&&l===d.length-1?p=ps:p=bf;var m=p===bf?"connection.updateWaypoints":"connection.reconnect",g=r.allowed(m,{connection:a,source:f,target:h});if(g===!1&&(g=r.allowed(m,{connection:a,source:h,target:f})),g!==!1)return i.init(s,"bendpoint.move",{data:{connection:a,connectionGfx:u,context:{allowed:g,bendpointIndex:l,connection:a,source:f,target:h,insert:c,type:p}}})},e.on("bendpoint.move.hover",function(s){var a=s.context,l=a.connection,c=l.source,u=l.target,f=s.hover,h=a.type;a.hover=f;var d;if(f){var p=h===bf?"connection.updateWaypoints":"connection.reconnect";if(d=a.allowed=r.allowed(p,{connection:l,source:h===ds?f:c,target:h===ps?f:u}),d){a.source=h===ds?f:c,a.target=h===ps?f:u;return}d===!1&&(d=a.allowed=r.allowed(p,{connection:l,source:h===ps?f:u,target:h===ds?f:c})),d&&(a.source=h===ps?f:u,a.target=h===ds?f:c)}}),e.on(["bendpoint.move.out","bendpoint.move.cleanup"],function(s){var a=s.context,l=a.type;a.hover=null,a.source=null,a.target=null,l!==bf&&(a.allowed=!1)}),e.on("bendpoint.move.end",function(s){var a=s.context,l=a.allowed,c=a.bendpointIndex,u=a.connection,f=a.insert,h=u.waypoints.slice(),d=a.source,p=a.target,m=a.type,g=a.hints||{},b={x:FE(s.x),y:FE(s.y)};if(!l)return!1;m===bf?(f?h.splice(c,0,b):h[c]=b,g.bendpointMove={insert:f,bendpointIndex:c},h=this.cropWaypoints(u,h),o.updateWaypoints(u,q1(h),g)):(m===ds?(g.docking="source",_f(a)&&(g.docking="target",g.newWaypoints=h.reverse())):m===ps&&(g.docking="target",_f(a)&&(g.docking="source",g.newWaypoints=h.reverse())),o.reconnect(u,d,p,b,g))},this)}wf.$inject=["injector","eventBus","canvas","dragging","rules","modeling"];wf.prototype.cropWaypoints=function(n,e){var t=this._injector.get("connectionDocking",!1);if(!t)return e;var i=n.waypoints;return n.waypoints=e,n.waypoints=t.getCroppedWaypoints(n),e=n.waypoints,n.waypoints=i,e};function _f(n){var e=n.hover,t=n.source,i=n.target,r=n.type;if(r===ds)return e&&i&&e===i&&t!==i;if(r===ps)return e&&t&&e===t&&t!==i}var z$="reconnectStart",W$="reconnectEnd",qE="updateWaypoints",Cf="connect-ok",qp="connect-not-ok",VE="connect-hover",HE="djs-updating",zE="djs-dragging",WE=1100;function Vp(n,e,t,i){this._injector=e;var r=e.get("connectionPreview",!1);t.on("bendpoint.move.start",function(o){var s=o.context,a=s.bendpointIndex,l=s.connection,c=s.insert,u=l.waypoints,f=u.slice();s.waypoints=u,c&&f.splice(a,0,{x:o.x,y:o.y}),l.waypoints=f;var h=s.draggerGfx=xf(i.getLayer("overlays"));ne(h).add("djs-dragging"),i.addMarker(l,zE),i.addMarker(l,HE)}),t.on("bendpoint.move.hover",function(o){var s=o.context,a=s.allowed,l=s.hover,c=s.type;if(l){if(i.addMarker(l,VE),c===qE)return;a?(i.removeMarker(l,qp),i.addMarker(l,Cf)):a===!1&&(i.removeMarker(l,Cf),i.addMarker(l,qp))}}),t.on(["bendpoint.move.out","bendpoint.move.cleanup"],WE,function(o){var s=o.context,a=s.hover,l=s.target;a&&(i.removeMarker(a,VE),i.removeMarker(a,l?Cf:qp))}),t.on("bendpoint.move.move",function(o){var s=o.context,a=s.allowed,l=s.bendpointIndex,c=s.draggerGfx,u=s.hover,f=s.type,h=s.connection,d=h.source,p=h.target,m=h.waypoints.slice(),g={x:o.x,y:o.y},b=s.hints||{},_={};r&&(b.connectionStart&&(_.connectionStart=b.connectionStart),b.connectionEnd&&(_.connectionEnd=b.connectionEnd),f===z$?_f(s)?(_.connectionEnd=_.connectionEnd||g,_.source=p,_.target=u||d,m=m.reverse()):(_.connectionStart=_.connectionStart||g,_.source=u||d,_.target=p):f===W$?_f(s)?(_.connectionStart=_.connectionStart||g,_.source=u||p,_.target=d,m=m.reverse()):(_.connectionEnd=_.connectionEnd||g,_.source=d,_.target=u||p):(_.noCropping=!0,_.noLayout=!0,m[l]=g),f===qE&&(m=n.cropWaypoints(h,m)),_.waypoints=m,r.drawPreview(s,a,_)),jt(c,o.x,o.y)},this),t.on(["bendpoint.move.end","bendpoint.move.cancel"],WE,function(o){var s=o.context,a=s.connection,l=s.draggerGfx,c=s.hover,u=s.target,f=s.waypoints;a.waypoints=f,Fe(l),i.removeMarker(a,HE),i.removeMarker(a,zE),c&&(i.removeMarker(c,Cf),i.removeMarker(c,u?Cf:qp)),r&&r.cleanUp(s)})}Vp.$inject=["bendpointMove","injector","eventBus","canvas"];var UE="connect-hover",QE="djs-updating";function KE(n,e,t){return ux(n,e,n[e]+t)}function ux(n,e,t){return{x:e==="x"?t:n.x,y:e==="y"?t:n.y}}function U$(n,e,t,i){var r=Math.max(e[i],t[i]),o=Math.min(e[i],t[i]),s=20,a=Math.min(Math.max(o+s,n[i]),r-s);return ux(e,i,a)}function XE(n){return n==="x"?"y":"x"}function GE(n,e,t){var i,r;return n.original?n.original:(i=le(e),r=XE(t),ux(n,r,i[r]))}function Hp(n,e,t,i,r,o){var s=n.get("connectionDocking",!1);this.start=function(f,h,d){var p,m=t.getGraphics(h),g=d-1,b=d,_=h.waypoints,v=_[g],x=_[b],C=vf(t,_,f),E,S,w;if(E=pr(v,x),!!E)return S=E==="v"?"x":"y",g===0&&(v=GE(v,h.source,S)),b===_.length-1&&(x=GE(x,h.target,S)),C?w=C.point:w={x:(v.x+x.x)/2,y:(v.y+x.y)/2},p={connection:h,segmentStartIndex:g,segmentEndIndex:b,segmentStart:v,segmentEnd:x,axis:S,dragPosition:w},i.init(f,w,"connectionSegment.move",{cursor:S==="x"?"resize-ew":"resize-ns",data:{connection:h,connectionGfx:m,context:p}})};function a(f,h){if(!s)return h;var d=f.waypoints,p;return f.waypoints=h,p=s.getCroppedWaypoints(f),f.waypoints=d,p}function l(f){r.update("connection",f.connection,f.connectionGfx)}function c(f,h,d){var p=f.newWaypoints,m=f.segmentStartIndex+h,g=p[m],b=f.segmentEndIndex+h,_=p[b],v=XE(f.axis),x=U$(d,g,_,v);jt(f.draggerGfx,x.x,x.y)}function u(f,h){var d=0,p=f.filter(function(m,g){return sp(f[g-1],f[g+1],m)?(d=g<=h?d-1:d,!1):!0});return{waypoints:p,segmentOffset:d}}e.on("connectionSegment.move.start",function(f){var h=f.context,d=f.connection,p=t.getLayer("overlays");h.originalWaypoints=d.waypoints.slice(),h.draggerGfx=jp(p,h.segmentStart,h.segmentEnd),ne(h.draggerGfx).add("djs-dragging"),t.addMarker(d,QE)}),e.on("connectionSegment.move.move",function(f){var h=f.context,d=h.connection,p=h.segmentStartIndex,m=h.segmentEndIndex,g=h.segmentStart,b=h.segmentEnd,_=h.axis,v=h.originalWaypoints.slice(),x=KE(g,_,f["d"+_]),C=KE(b,_,f["d"+_]),E=v.length,S=0;v[p]=x,v[m]=C;var w,R;p<2&&(w=vt(d.source,x),p===1?w==="intersect"&&(v.shift(),v[0]=x,S--):w!=="intersect"&&(v.unshift(g),S++)),m>E-3&&(R=vt(d.target,C),m===E-2?R==="intersect"&&(v.pop(),v[v.length-1]=C):R!=="intersect"&&v.push(b)),h.newWaypoints=d.waypoints=a(d,v),c(h,S,f),h.newSegmentStartIndex=p+S,l(f)}),e.on("connectionSegment.move.hover",function(f){f.context.hover=f.hover,t.addMarker(f.hover,UE)}),e.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],function(f){var h=f.context.hover;h&&t.removeMarker(h,UE)}),e.on("connectionSegment.move.cleanup",function(f){var h=f.context,d=h.connection;h.draggerGfx&&Fe(h.draggerGfx),t.removeMarker(d,QE)}),e.on(["connectionSegment.move.cancel","connectionSegment.move.end"],function(f){var h=f.context,d=h.connection;d.waypoints=h.originalWaypoints,l(f)}),e.on("connectionSegment.move.end",function(f){var h=f.context,d=h.connection,p=h.newWaypoints,m=h.newSegmentStartIndex;p=p.map(function(C){return{original:C.original,x:Math.round(C.x),y:Math.round(C.y)}});var g=u(p,m),b=g.waypoints,_=a(d,b),v=g.segmentOffset,x={segmentMove:{segmentStartIndex:h.segmentStartIndex,newSegmentStartIndex:m+v}};o.updateWaypoints(d,_,x)})}Hp.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var Q$=Math.abs,YE=Math.round;function ZE(n,e,t){t=t===void 0?10:t;var i,r;for(i=0;i<e.length;i++)if(r=e[i],Q$(r-n)<=t)return r}function JE(n){return{x:n.x,y:n.y}}function eS(n){return{x:n.x+n.width,y:n.y+n.height}}function ms(n,e){return!n||isNaN(n.x)||isNaN(n.y)?e:{x:YE(n.x+n.width/2),y:YE(n.y+n.height/2)}}function wr(n,e){var t=n.snapped;return t?typeof e=="string"?t[e]:t.x&&t.y:!1}function vn(n,e,t){if(typeof e!="string")throw new Error("axis must be in [x, y]");if(typeof t!="number"&&t!==!1)throw new Error("value must be Number or false");var i,r=n[e],o=n.snapped=n.snapped||{};return t===!1?o[e]=!1:(o[e]=!0,i=t-r,n[e]+=i,n["d"+e]+=i),r}function zp(n){return n.children||[]}var K$=Math.abs,tS=Math.round,fx=10;function Wp(n){function e(o,s){if(F(o)){for(var a=o.length;a--;)if(K$(o[a]-s)<=fx)return o[a]}else{o=+o;var l=s%o;if(l<fx)return s-l;if(l>o-fx)return s-l+o}return s}function t(o,s){if(o.waypoints)return jE(s,o);if(o.width)return{x:tS(o.width/2+o.x),y:tS(o.height/2+o.y)}}function i(o){var s=o.context,a=s.snapPoints,l=s.connection,c=l.waypoints,u=s.segmentStart,f=s.segmentStartIndex,h=s.segmentEnd,d=s.segmentEndIndex,p=s.axis;if(a)return a;var m=[c[f-1],u,h,c[d+1]];return f<2&&m.unshift(t(l.source,o)),d>c.length-3&&m.unshift(t(l.target,o)),s.snapPoints=a={horizontal:[],vertical:[]},k(m,function(g){g&&(g=g.original||g,p==="y"&&a.horizontal.push(g.y),p==="x"&&a.vertical.push(g.x))}),a}n.on("connectionSegment.move.move",1500,function(o){var s=i(o),a=o.x,l=o.y,c,u;if(s){c=e(s.vertical,a),u=e(s.horizontal,l);var f=a-c,h=l-u;T(o,{dx:o.dx-f,dy:o.dy-h,x:c,y:u}),(f||s.vertical.indexOf(a)!==-1)&&vn(o,"x",c),(h||s.horizontal.indexOf(l)!==-1)&&vn(o,"y",u)}});function r(o){var s=o.snapPoints,a=o.connection.waypoints,l=o.bendpointIndex;if(s)return s;var c=[a[l-1],a[l+1]];return o.snapPoints=s={horizontal:[],vertical:[]},k(c,function(u){u&&(u=u.original||u,s.horizontal.push(u.y),s.vertical.push(u.x))}),s}n.on(["connect.hover","connect.move","connect.end"],1500,function(o){var s=o.context,a=s.hover,l=a&&t(a,o);!Xe(a)||!l||!l.x||!l.y||(vn(o,"x",l.x),vn(o,"y",l.y))}),n.on(["bendpoint.move.move","bendpoint.move.end"],1500,function(o){var s=o.context,a=r(s),l=s.hover,c=l&&t(l,o),u=o.x,f=o.y,h,d;if(a){h=e(c?a.vertical.concat([c.x]):a.vertical,u),d=e(c?a.horizontal.concat([c.y]):a.horizontal,f);var p=u-h,m=f-d;T(o,{dx:o.dx-p,dy:o.dy-m,x:o.x-p,y:o.y-m}),(p||a.vertical.indexOf(u)!==-1)&&vn(o,"x",h),(m||a.horizontal.indexOf(f)!==-1)&&vn(o,"y",d)}})}Wp.$inject=["eventBus"];var nS={__depends__:[gn,yn],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",Fp],bendpointMove:["type",wf],bendpointMovePreview:["type",Vp],connectionSegmentMove:["type",Hp],bendpointSnapping:["type",Wp]};var G$=new po;function vo(n){this._scheduled={},n.on("diagram.destroy",()=>{Object.keys(this._scheduled).forEach(e=>{this.cancel(e)})})}vo.$inject=["eventBus"];vo.prototype.schedule=function(n,e=G$.next()){this.cancel(e);let t=this._schedule(n,e);return this._scheduled[e]=t,t.promise};vo.prototype._schedule=function(n,e){let t=X$();return{executionId:setTimeout(()=>{try{this._scheduled[e]=null;try{t.resolve(n())}catch(r){t.reject(r)}}catch(r){console.error("Scheduler#_schedule execution failed",r)}}),promise:t.promise}};vo.prototype.cancel=function(n){let e=this._scheduled[n];e&&(this._cancel(e),this._scheduled[n]=null)};vo.prototype._cancel=function(n){clearTimeout(n.executionId)};function X$(){let n={};return n.promise=new Promise((e,t)=>{n.resolve=e,n.reject=t}),n}var iS={scheduler:["type",vo]};var Y$="djs-element-hidden",Up=".entry",Z$=1e3,rS=8,J$=300;function tt(n,e,t,i){this._canvas=n,this._elementRegistry=e,this._eventBus=t,this._scheduler=i,this._current=null,this._init()}tt.$inject=["canvas","elementRegistry","eventBus","scheduler"];tt.prototype._init=function(){var n=this;this._eventBus.on("selection.changed",function(e){var t=e.newSelection,i=t.length?t.length===1?t[0]:t:null;i?n.open(i,!0):n.close()}),this._eventBus.on("elements.changed",function(e){var t=e.elements,i=n._current;if(i){var r=i.target,o=F(r)?r:[r],s=o.filter(function(l){return t.includes(l)});if(s.length){n.close();var a=o.filter(function(l){return n._elementRegistry.get(l.id)});a.length&&n._updateAndOpen(a.length>1?a:a[0])}}}),this._eventBus.on("canvas.viewbox.changed",function(){n._updatePosition()}),this._eventBus.on("element.marker.update",function(e){if(n.isOpen()){var t=e.element,i=n._current,r=F(i.target)?i.target:[i.target];r.includes(t)&&n._updateVisibility()}}),this._container=this._createContainer()};tt.prototype._createContainer=function(){var n=te('<div class="djs-context-pad-parent"></div>');return this._canvas.getContainer().appendChild(n),n};tt.prototype.registerProvider=function(n,e){e||(e=n,n=Z$),this._eventBus.on("contextPad.getProviders",n,function(t){t.providers.push(e)})};tt.prototype.getEntries=function(n){var e=this._getProviders(),t=F(n)?"getMultiElementContextPadEntries":"getContextPadEntries",i={};return k(e,function(r){if(ge(r[t])){var o=r[t](n);ge(o)?i=o(i):k(o,function(s,a){i[a]=s})}}),i};tt.prototype.trigger=function(n,e,t){var i=this,r,o,s=e.delegateTarget||e.target;if(!s)return e.preventDefault();if(r=et(s,"data-action"),o=e.originalEvent||e,n==="mouseover"){this._timeout=setTimeout(function(){i._mouseout=i.triggerEntry(r,"hover",o,t)},J$);return}else if(n==="mouseout"){clearTimeout(this._timeout),this._mouseout&&(this._mouseout(),this._mouseout=null);return}return this.triggerEntry(r,n,o,t)};tt.prototype.triggerEntry=function(n,e,t,i){if(this.isShown()){var r=this._current.target,o=this._current.entries,s=o[n];if(s){var a=s.action;if(this._eventBus.fire("contextPad.trigger",{entry:s,event:t})!==!1){if(ge(a)){if(e==="click")return a(t,r,i)}else if(a[e])return a[e](t,r,i);t.preventDefault()}}}};tt.prototype.open=function(n,e){if(!(!e&&this.isOpen(n))){var t=this._eventBus.fire("contextPad.open.allowed",{target:n});t!==!1&&(this.close(),this._updateAndOpen(n))}};tt.prototype._getProviders=function(){var n=this._eventBus.createEvent({type:"contextPad.getProviders",providers:[]});return this._eventBus.fire(n),n.providers};tt.prototype._updateAndOpen=function(n){var e=this.getEntries(n),t=this._createHtml(n),i;k(e,function(r,o){var s=r.group||"default",a=te(r.html||'<div class="entry" draggable="true"></div>'),l;et(a,"data-action",o),l=X("[data-group="+Sa(s)+"]",t),l||(l=te('<div class="group"></div>'),et(l,"data-group",s),t.appendChild(l)),l.appendChild(a),r.className&&ej(a,r.className),r.title&&et(a,"title",r.title),r.imageUrl&&(i=te("<img>"),et(i,"src",r.imageUrl),i.style.width="100%",i.style.height="100%",a.appendChild(i))}),ee(t).add("open"),this._current={entries:e,html:t,target:n},this._updatePosition(),this._updateVisibility(),this._eventBus.fire("contextPad.open",{current:this._current})};tt.prototype._createHtml=function(n){var e=this,t=te('<div class="djs-context-pad"></div>');return _t.bind(t,Up,"click",function(i){e.trigger("click",i)}),_t.bind(t,Up,"dragstart",function(i){e.trigger("dragstart",i)}),_t.bind(t,Up,"mouseover",function(i){e.trigger("mouseover",i)}),_t.bind(t,Up,"mouseout",function(i){e.trigger("mouseout",i)}),q.bind(t,"mousedown",function(i){i.stopPropagation()}),this._container.appendChild(t),this._eventBus.fire("contextPad.create",{target:n,pad:t}),t};tt.prototype.getPad=function(n){console.warn(new Error("ContextPad#getPad is deprecated and will be removed in future library versions, cf. https://github.com/bpmn-io/diagram-js/pull/888"));let e;return this.isOpen()&&nj(this._current.target,n)?e=this._current.html:e=this._createHtml(n),{html:e}};tt.prototype.close=function(){this.isOpen()&&(clearTimeout(this._timeout),this._container.innerHTML="",this._eventBus.fire("contextPad.close",{current:this._current}),this._current=null)};tt.prototype.isOpen=function(n){var e=this._current;if(!e)return!1;if(!n)return!0;var t=e.target;return F(n)!==F(t)?!1:F(n)?n.length===t.length&&kt(n,function(i){return t.includes(i)}):t===n};tt.prototype.isShown=function(){return this.isOpen()&&ee(this._current.html).has("open")};tt.prototype.show=function(){this.isOpen()&&(ee(this._current.html).add("open"),this._updatePosition(),this._eventBus.fire("contextPad.show",{current:this._current}))};tt.prototype.hide=function(){this.isOpen()&&(ee(this._current.html).remove("open"),this._eventBus.fire("contextPad.hide",{current:this._current}))};tt.prototype._getPosition=function(n){if(!F(n)&&Xe(n)){var e=this._canvas.viewbox(),t=tj(n),i=t.x*e.scale-e.x*e.scale,r=t.y*e.scale-e.y*e.scale;return{left:i+rS*this._canvas.zoom(),top:r}}var o=this._canvas.getContainer(),s=o.getBoundingClientRect(),a=this._getTargetBounds(n);return{left:a.right-s.left+rS*this._canvas.zoom(),top:a.top-s.top}};tt.prototype._updatePosition=function(){let n=()=>{if(this.isOpen()){var e=this._current.html,t=this._getPosition(this._current.target);"x"in t&&"y"in t?(e.style.left=t.x+"px",e.style.top=t.y+"px"):["top","right","bottom","left"].forEach(function(i){i in t&&(e.style[i]=t[i]+"px")})}};this._scheduler.schedule(n,"ContextPad#_updatePosition")};tt.prototype._updateVisibility=function(){let n=()=>{if(this.isOpen()){var e=this,t=this._current.target,i=F(t)?t:[t],r=i.some(function(o){return e._canvas.hasMarker(o,Y$)});r?e.hide():e.show()}};this._scheduler.schedule(n,"ContextPad#_updateVisibility")};tt.prototype._getTargetBounds=function(n){var e=this,t=F(n)?n:[n],i=t.map(function(r){return e._canvas.getGraphics(r)});return i.reduce(function(r,o){let s=o.getBoundingClientRect();return r.top=Math.min(r.top,s.top),r.right=Math.max(r.right,s.right),r.bottom=Math.max(r.bottom,s.bottom),r.left=Math.min(r.left,s.left),r.x=r.left,r.y=r.top,r.width=r.right-r.left,r.height=r.bottom-r.top,r},{top:1/0,right:-1/0,bottom:-1/0,left:1/0})};function ej(n,e){var t=ee(n);e=F(e)?e:e.split(/\s+/g),e.forEach(function(i){t.add(i)})}function tj(n){return n.waypoints[n.waypoints.length-1]}function nj(n,e){return n=F(n)?n:[n],e=F(e)?e:[e],n.length===e.length&&kt(n,function(t){return e.includes(t)})}var oS={__depends__:[fo,iS,mo],contextPad:["type",tt]};function Kp(n,e,t,i){function r(s,a){return i.allowed("connection.create",{source:s,target:a})}function o(s,a){return r(a,s)}n.on("connect.hover",function(s){var a=s.context,l=a.start,c=s.hover,u;if(a.hover=c,u=a.canExecute=r(l,c),!Yr(u)){if(u!==!1){a.source=l,a.target=c;return}u=a.canExecute=o(l,c),!Yr(u)&&u!==!1&&(a.source=c,a.target=l)}}),n.on(["connect.out","connect.cleanup"],function(s){var a=s.context;a.hover=null,a.source=null,a.target=null,a.canExecute=!1}),n.on("connect.end",function(s){var a=s.context,l=a.canExecute,c=a.connectionStart,u={x:s.x,y:s.y},f=a.source,h=a.target;if(!l)return!1;var d=null,p={connectionStart:Qp(a)?u:c,connectionEnd:Qp(a)?c:u};Pe(l)&&(d=l),a.connection=t.connect(f,h,d,p)}),this.start=function(s,a,l,c){Pe(l)||(c=l,l=le(a)),e.init(s,"connect",{autoActivate:c,data:{shape:a,context:{start:a,connectionStart:l}}})}}Kp.$inject=["eventBus","dragging","modeling","rules"];function Qp(n){var e=n.hover,t=n.source,i=n.target;return e&&t&&e===t&&t!==i}var ij=1100,rj=900,sS="connect-ok",aS="connect-not-ok";function Gp(n,e,t){var i=n.get("connectionPreview",!1);i&&e.on("connect.move",function(r){var o=r.context,s=o.canExecute,a=o.hover,l=o.source,c=o.start,u=o.startPosition,f=o.target,h=o.connectionStart||u,d=o.connectionEnd||{x:r.x,y:r.y},p=h,m=d;Qp(o)&&(p=d,m=h),i.drawPreview(o,s,{source:l||c,target:f||a,connectionStart:p,connectionEnd:m})}),e.on("connect.hover",rj,function(r){var o=r.context,s=r.hover,a=o.canExecute;a!==null&&t.addMarker(s,a?sS:aS)}),e.on(["connect.out","connect.cleanup"],ij,function(r){var o=r.hover;o&&(t.removeMarker(o,sS),t.removeMarker(o,aS))}),i&&e.on("connect.cleanup",function(r){i.cleanUp(r.context)})}Gp.$inject=["injector","eventBus","canvas"];var lS={__depends__:[ht,yn,gn],__init__:["connectPreview"],connect:["type",Kp],connectPreview:["type",Gp]};var oj=new po("ps"),sj=["marker-start","marker-mid","marker-end"],aj=["circle","ellipse","line","path","polygon","polyline","path","rect"];function ji(n,e,t,i){this._elementRegistry=n,this._canvas=t,this._styles=i}ji.$inject=["elementRegistry","eventBus","canvas","styles"];ji.prototype.cleanUp=function(){console.warn("PreviewSupport#cleanUp is deprecated and will be removed in future versions. You do not need to manually clean up previews anymore. cf. https://github.com/bpmn-io/diagram-js/pull/906")};ji.prototype.getGfx=function(n){return this._elementRegistry.getGraphics(n)};ji.prototype.addDragger=function(n,e,t,i="djs-dragger"){t=t||this.getGfx(n);var r=gv(t),o=t.getBoundingClientRect();return this._cloneMarkers(ls(r),i),j(r,this._styles.cls(i,[],{x:o.top,y:o.left})),K(e,r),j(r,"data-preview-support-element-id",n.id),r};ji.prototype.addFrame=function(n,e){var t=Q("rect",{class:"djs-resize-overlay",width:n.width,height:n.height,x:n.x,y:n.y});return K(e,t),j(t,"data-preview-support-element-id",n.id),t};ji.prototype._cloneMarkers=function(n,e="djs-dragger",t=n){var i=this;n.childNodes&&n.childNodes.forEach(r=>{i._cloneMarkers(r,e,t)}),fj(n)&&sj.forEach(function(r){if(j(n,r)){var o=lj(n,r,i._canvas.getContainer());o&&i._cloneMarker(t,n,o,r,e)}})};ji.prototype._cloneMarker=function(n,e,t,i,r="djs-dragger"){var o=[t.id,r,oj.next()].join("-"),s=X("marker#"+t.id,n);n=n||this._canvas._svg;var a=s||gv(t);a.id=o,ne(a).add(r);var l=X(":scope > defs",n);l||(l=Q("defs"),K(n,l)),K(l,a);var c=uj(a.id);j(e,i,c)};function lj(n,e,t){var i=cj(j(n,e));return X("marker#"+i,t||document)}function cj(n){return n.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]}function uj(n){return"url(#"+n+")"}function fj(n){return aj.indexOf(n.nodeName)!==-1}var ka={__init__:["previewSupport"],previewSupport:["type",ji]};var hj="drop-ok",cS="drop-not-ok",uS="attach-ok",fS="new-parent",hS="create",dj=2e3;function Xp(n,e,t,i,r){function o(l,c,u,f,h){if(!c)return!1;l=Ee(l,function(_){var v=_.labelTarget;return!_.parent&&!(Bi(_)&&l.indexOf(v)!==-1)});var d=ye(l,function(_){return!Xe(_)}),p=!1,m=!1,g=!1;pS(l)&&(p=r.allowed("shape.attach",{position:u,shape:d,target:c})),p||(pS(l)?g=r.allowed("shape.create",{position:u,shape:d,source:f,target:c}):g=r.allowed("elements.create",{elements:l,position:u,target:c}));var b=h.connectionTarget;return g||p?(d&&f&&(m=r.allowed("connection.create",{source:b===f?d:f,target:b===f?f:d,hints:{targetParent:c,targetAttach:p}})),{attach:p,connect:m}):g===null||p===null?null:!1}function s(l,c){[uS,hj,cS,fS].forEach(function(u){u===c?n.addMarker(l,u):n.removeMarker(l,u)})}t.on(["create.move","create.hover"],function(l){var c=l.context,u=c.elements,f=l.hover,h=c.source,d=c.hints||{};if(!f){c.canExecute=!1,c.target=null;return}dS(l);var p={x:l.x,y:l.y},m=c.canExecute=f&&o(u,f,p,h,d);f&&m!==null&&(c.target=f,m&&m.attach?s(f,uS):s(f,m?fS:cS))}),t.on(["create.end","create.out","create.cleanup"],function(l){var c=l.hover;c&&s(c,null)}),t.on("create.end",function(l){var c=l.context,u=c.source,f=c.shape,h=c.elements,d=c.target,p=c.canExecute,m=p&&p.attach,g=p&&p.connect,b=c.hints||{};if(p===!1||!d)return!1;dS(l);var _={x:l.x,y:l.y};g?f=i.appendShape(u,f,_,d,{attach:m,connection:g===!0?{}:g,connectionTarget:b.connectionTarget}):(h=i.createElements(h,_,d,T({},b,{attach:m})),f=ye(h,function(v){return!Xe(v)})),T(c,{elements:h,shape:f}),T(l,{elements:h,shape:f})});function a(){var l=e.context();l&&l.prefix===hS&&e.cancel()}t.on("create.init",function(){t.on("elements.changed",a),t.once(["create.cancel","create.end"],dj,function(){t.off("elements.changed",a)})}),this.start=function(l,c,u){F(c)||(c=[c]);var f=ye(c,function(p){return!Xe(p)});if(f){u=T({elements:c,hints:{},shape:f},u||{}),k(c,function(p){se(p.x)||(p.x=0),se(p.y)||(p.y=0)});var h=Ee(c,function(p){return!p.hidden}),d=Tt(h);k(c,function(p){Xe(p)&&(p.waypoints=Vt(p.waypoints,function(m){return{x:m.x-d.x-d.width/2,y:m.y-d.y-d.height/2}})),T(p,{x:p.x-d.x-d.width/2,y:p.y-d.y-d.height/2})}),e.init(l,hS,{cursor:"grabbing",autoActivate:!0,data:{shape:f,elements:c,context:u}})}}}Xp.$inject=["canvas","dragging","eventBus","modeling","rules"];function dS(n){var e=n.context,t=e.createConstraints;t&&(t.left&&(n.x=Math.max(n.x,t.left)),t.right&&(n.x=Math.min(n.x,t.right)),t.top&&(n.y=Math.max(n.y,t.top)),t.bottom&&(n.y=Math.min(n.y,t.bottom)))}function pS(n){return n&&n.length===1&&!Xe(n[0])}var pj=750;function Yp(n,e,t,i,r){function o(s){var a=Q("g");j(a,r.cls("djs-drag-group",["no-events"]));var l=Q("g");return s.forEach(function(c){var u;c.hidden||(c.waypoints?(u=t._createContainer("connection",l),t.drawConnection(ls(u),c)):(u=t._createContainer("shape",l),t.drawShape(ls(u),c),jt(u,c.x,c.y)),i.addDragger(c,a,u))}),a}e.on("create.move",pj,function(s){var a=s.hover,l=s.context,c=l.elements,u=l.dragGroup;u||(u=l.dragGroup=o(c));var f;a?(u.parentNode||(f=n.getActiveLayer(),K(f,u)),jt(u,s.x,s.y)):Fe(u)}),e.on("create.cleanup",function(s){var a=s.context,l=a.dragGroup;l&&Fe(l)})}Yp.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];var Zp={__depends__:[gn,ka,yn,ht],__init__:["create","createPreview"],create:["type",Xp],createPreview:["type",Yp]};var om,He,xS,mj,xo,mS,bS,_S,hx,em,Ef,wS,gx,dx,px,gj,nm={},im=[],yj=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,sm=Array.isArray;function Cr(n,e){for(var t in e)n[t]=e[t];return n}function yx(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function am(n,e,t){var i,r,o,s={};for(o in e)o=="key"?i=e[o]:o=="ref"?r=e[o]:s[o]=e[o];if(arguments.length>2&&(s.children=arguments.length>3?om.call(arguments,2):t),typeof n=="function"&&n.defaultProps!=null)for(o in n.defaultProps)s[o]===void 0&&(s[o]=n.defaultProps[o]);return tm(n,s,i,r,null)}function tm(n,e,t,i,r){var o={type:n,props:e,key:t,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r==null?++xS:r,__i:-1,__u:0};return r==null&&He.vnode!=null&&He.vnode(o),o}function lm(n){return n.children}function Sf(n,e){this.props=n,this.context=e}function Ra(n,e){if(e==null)return n.__?Ra(n.__,n.__i+1):null;for(var t;e<n.__k.length;e++)if((t=n.__k[e])!=null&&t.__e!=null)return t.__e;return typeof n.type=="function"?Ra(n):null}function vj(n){if(n.__P&&n.__d){var e=n.__v,t=e.__e,i=[],r=[],o=Cr({},e);o.__v=e.__v+1,He.vnode&&He.vnode(o),vx(n.__P,o,e,n.__n,n.__P.namespaceURI,32&e.__u?[t]:null,i,t==null?Ra(e):t,!!(32&e.__u),r),o.__v=e.__v,o.__.__k[o.__i]=o,OS(i,o,r),e.__e=e.__=null,o.__e!=t&&CS(o)}}function CS(n){if((n=n.__)!=null&&n.__c!=null)return n.__e=n.__c.base=null,n.__k.some(function(e){if(e!=null&&e.__e!=null)return n.__e=n.__c.base=e.__e}),CS(n)}function gS(n){(!n.__d&&(n.__d=!0)&&xo.push(n)&&!rm.__r++||mS!=He.debounceRendering)&&((mS=He.debounceRendering)||bS)(rm)}function rm(){try{for(var n,e=1;xo.length;)xo.length>e&&xo.sort(_S),n=xo.shift(),e=xo.length,vj(n)}finally{xo.length=rm.__r=0}}function ES(n,e,t,i,r,o,s,a,l,c,u){var f,h,d,p,m,g,b,_=i&&i.__k||im,v=e.length;for(l=xj(t,e,_,l,v),f=0;f<v;f++)(d=t.__k[f])!=null&&(h=d.__i!=-1&&_[d.__i]||nm,d.__i=f,g=vx(n,d,h,r,o,s,a,l,c,u),p=d.__e,d.ref&&h.ref!=d.ref&&(h.ref&&xx(h.ref,null,d),u.push(d.ref,d.__c||p,d)),m==null&&p!=null&&(m=p),(b=!!(4&d.__u))||h.__k===d.__k?(l=SS(d,l,n,b),b&&h.__e&&(h.__e=null)):typeof d.type=="function"&&g!==void 0?l=g:p&&(l=p.nextSibling),d.__u&=-7);return t.__e=m,l}function xj(n,e,t,i,r){var o,s,a,l,c,u=t.length,f=u,h=0;for(n.__k=new Array(r),o=0;o<r;o++)(s=e[o])!=null&&typeof s!="boolean"&&typeof s!="function"?(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?s=n.__k[o]=tm(null,s,null,null,null):sm(s)?s=n.__k[o]=tm(lm,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=n.__k[o]=tm(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):n.__k[o]=s,l=o+h,s.__=n,s.__b=n.__b+1,a=null,(c=s.__i=bj(s,t,l,f))!=-1&&(f--,(a=t[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(r>u?h--:r<u&&h++),typeof s.type!="function"&&(s.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,s.__u|=4))):n.__k[o]=null;if(f)for(o=0;o<u;o++)(a=t[o])!=null&&(2&a.__u)==0&&(a.__e==i&&(i=Ra(a)),RS(a,a));return i}function SS(n,e,t,i){var r,o;if(typeof n.type=="function"){for(r=n.__k,o=0;r&&o<r.length;o++)r[o]&&(r[o].__=n,e=SS(r[o],e,t,i));return e}n.__e!=e&&(i&&(e&&n.type&&!e.parentNode&&(e=Ra(n)),t.insertBefore(n.__e,e||null)),e=n.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function bj(n,e,t,i){var r,o,s,a=n.key,l=n.type,c=e[t],u=c!=null&&(2&c.__u)==0;if(c===null&&a==null||u&&a==c.key&&l==c.type)return t;if(i>(u?1:0)){for(r=t-1,o=t+1;r>=0||o<e.length;)if((c=e[s=r>=0?r--:o++])!=null&&(2&c.__u)==0&&a==c.key&&l==c.type)return s}return-1}function yS(n,e,t){e[0]=="-"?n.setProperty(e,t==null?"":t):n[e]=t==null?"":typeof t!="number"||yj.test(e)?t:t+"px"}function Jp(n,e,t,i,r){var o,s;e:if(e=="style")if(typeof t=="string")n.style.cssText=t;else{if(typeof i=="string"&&(n.style.cssText=i=""),i)for(e in i)t&&e in t||yS(n.style,e,"");if(t)for(e in t)i&&t[e]==i[e]||yS(n.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(wS,"$1")),s=e.toLowerCase(),e=s in n||e=="onFocusOut"||e=="onFocusIn"?s.slice(2):e.slice(2),n.l||(n.l={}),n.l[e+o]=t,t?i?t[Ef]=i[Ef]:(t[Ef]=gx,n.addEventListener(e,o?px:dx,o)):n.removeEventListener(e,o?px:dx,o);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in n)try{n[e]=t==null?"":t;break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?n.removeAttribute(e):n.setAttribute(e,e=="popover"&&t==1?"":t))}}function vS(n){return function(e){if(this.l){var t=this.l[e.type+n];if(e[em]==null)e[em]=gx++;else if(e[em]<t[Ef])return;return t(He.event?He.event(e):e)}}}function vx(n,e,t,i,r,o,s,a,l,c){var u,f,h,d,p,m,g,b,_,v,x,C,E,S,w,R=e.type;if(e.constructor!==void 0)return null;128&t.__u&&(l=!!(32&t.__u),o=[a=e.__e=t.__e]),(u=He.__b)&&u(e);e:if(typeof R=="function")try{if(b=e.props,_=R.prototype&&R.prototype.render,v=(u=R.contextType)&&i[u.__c],x=u?v?v.props.value:u.__:i,t.__c?g=(f=e.__c=t.__c).__=f.__E:(_?e.__c=f=new R(b,x):(e.__c=f=new Sf(b,x),f.constructor=R,f.render=wj),v&&v.sub(f),f.state||(f.state={}),f.__n=i,h=f.__d=!0,f.__h=[],f._sb=[]),_&&f.__s==null&&(f.__s=f.state),_&&R.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=Cr({},f.__s)),Cr(f.__s,R.getDerivedStateFromProps(b,f.__s))),d=f.props,p=f.state,f.__v=e,h)_&&R.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),_&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(_&&R.getDerivedStateFromProps==null&&b!==d&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(b,x),e.__v==t.__v||!f.__e&&f.shouldComponentUpdate!=null&&f.shouldComponentUpdate(b,f.__s,x)===!1){e.__v!=t.__v&&(f.props=b,f.state=f.__s,f.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.some(function(A){A&&(A.__=e)}),im.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&s.push(f);break e}f.componentWillUpdate!=null&&f.componentWillUpdate(b,f.__s,x),_&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(d,p,m)})}if(f.context=x,f.props=b,f.__P=n,f.__e=!1,C=He.__r,E=0,_)f.state=f.__s,f.__d=!1,C&&C(e),u=f.render(f.props,f.state,f.context),im.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,C&&C(e),u=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++E<25);f.state=f.__s,f.getChildContext!=null&&(i=Cr(Cr({},i),f.getChildContext())),_&&!h&&f.getSnapshotBeforeUpdate!=null&&(m=f.getSnapshotBeforeUpdate(d,p)),S=u!=null&&u.type===lm&&u.key==null?kS(u.props.children):u,a=ES(n,sm(S)?S:[S],e,t,i,r,o,s,a,l,c),f.base=e.__e,e.__u&=-161,f.__h.length&&s.push(f),g&&(f.__E=f.__=null)}catch(A){if(e.__v=null,l||o!=null)if(A.then){for(e.__u|=l?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,e.__e=a}else{for(w=o.length;w--;)yx(o[w]);mx(e)}else e.__e=t.__e,e.__k=t.__k,A.then||mx(e);He.__e(A,e,t)}else o==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):a=e.__e=_j(t.__e,e,t,i,r,o,s,l,c);return(u=He.diffed)&&u(e),128&e.__u?void 0:a}function mx(n){n&&(n.__c&&(n.__c.__e=!0),n.__k&&n.__k.some(mx))}function OS(n,e,t){for(var i=0;i<t.length;i++)xx(t[i],t[++i],t[++i]);He.__c&&He.__c(e,n),n.some(function(r){try{n=r.__h,r.__h=[],n.some(function(o){o.call(r)})}catch(o){He.__e(o,r.__v)}})}function kS(n){return typeof n!="object"||n==null||n.__b>0?n:sm(n)?n.map(kS):n.constructor!==void 0?null:Cr({},n)}function _j(n,e,t,i,r,o,s,a,l){var c,u,f,h,d,p,m,g=t.props||nm,b=e.props,_=e.type;if(_=="svg"?r="http://www.w3.org/2000/svg":_=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),o!=null){for(c=0;c<o.length;c++)if((d=o[c])&&"setAttribute"in d==!!_&&(_?d.localName==_:d.nodeType==3)){n=d,o[c]=null;break}}if(n==null){if(_==null)return document.createTextNode(b);n=document.createElementNS(r,_,b.is&&b),a&&(He.__m&&He.__m(e,o),a=!1),o=null}if(_==null)g===b||a&&n.data==b||(n.data=b);else{if(o=_=="textarea"&&b.defaultValue!=null?null:o&&om.call(n.childNodes),!a&&o!=null)for(g={},c=0;c<n.attributes.length;c++)g[(d=n.attributes[c]).name]=d.value;for(c in g)d=g[c],c=="dangerouslySetInnerHTML"?f=d:c=="children"||c in b||c=="value"&&"defaultValue"in b||c=="checked"&&"defaultChecked"in b||Jp(n,c,null,d,r);for(c in b)d=b[c],c=="children"?h=d:c=="dangerouslySetInnerHTML"?u=d:c=="value"?p=d:c=="checked"?m=d:a&&typeof d!="function"||g[c]===d||Jp(n,c,d,g[c],r);if(u)a||f&&(u.__html==f.__html||u.__html==n.innerHTML)||(n.innerHTML=u.__html),e.__k=[];else if(f&&(n.innerHTML=""),ES(e.type=="template"?n.content:n,sm(h)?h:[h],e,t,i,_=="foreignObject"?"http://www.w3.org/1999/xhtml":r,o,s,o?o[0]:t.__k&&Ra(t,0),a,l),o!=null)for(c=o.length;c--;)yx(o[c]);a&&_!="textarea"||(c="value",_=="progress"&&p==null?n.removeAttribute("value"):p!=null&&(p!==n[c]||_=="progress"&&!p||_=="option"&&p!=g[c])&&Jp(n,c,p,g[c],r),c="checked",m!=null&&m!=n[c]&&Jp(n,c,m,g[c],r))}return n}function xx(n,e,t){try{if(typeof n=="function"){var i=typeof n.__u=="function";i&&n.__u(),i&&e==null||(n.__u=n(e))}else n.current=e}catch(r){He.__e(r,t)}}function RS(n,e,t){var i,r;if(He.unmount&&He.unmount(n),(i=n.ref)&&(i.current&&i.current!=n.__e||xx(i,null,e)),(i=n.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(o){He.__e(o,e)}i.base=i.__P=null}if(i=n.__k)for(r=0;r<i.length;r++)i[r]&&RS(i[r],e,t||typeof n.type!="function");t||yx(n.__e),n.__c=n.__=n.__e=void 0}function wj(n,e,t){return this.constructor(n,t)}function cm(n,e,t){var i,r,o,s;e==document&&(e=document.documentElement),He.__&&He.__(n,e),r=(i=typeof t=="function")?null:t&&t.__k||e.__k,o=[],s=[],vx(e,n=(!i&&t||e).__k=am(lm,null,[n]),r||nm,nm,e.namespaceURI,!i&&t?[t]:r?null:e.firstChild?om.call(e.childNodes):null,o,!i&&t?t:r?r.__e:e.firstChild,i,s),OS(o,n,s)}om=im.slice,He={__e:function(n,e,t,i){for(var r,o,s;e=e.__;)if((r=e.__c)&&!r.__)try{if((o=r.constructor)&&o.getDerivedStateFromError!=null&&(r.setState(o.getDerivedStateFromError(n)),s=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(n,i||{}),s=r.__d),s)return r.__E=r}catch(a){n=a}throw n}},xS=0,mj=function(n){return n!=null&&n.constructor===void 0},Sf.prototype.setState=function(n,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Cr({},this.state),typeof n=="function"&&(n=n(Cr({},t),this.props)),n&&Cr(t,n),n!=null&&this.__v&&(e&&this._sb.push(e),gS(this))},Sf.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),gS(this))},Sf.prototype.render=lm,xo=[],bS=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,_S=function(n,e){return n.__v.__b-e.__v.__b},rm.__r=0,hx=Math.random().toString(8),em="__d"+hx,Ef="__a"+hx,wS=/(PointerCapture)$|Capture$/i,gx=0,dx=vS(!1),px=vS(!0),gj=0;var AS=function(n,e,t,i){var r;e[0]=0;for(var o=1;o<e.length;o++){var s=e[o++],a=e[o]?(e[0]|=s?1:2,t[e[o++]]):e[++o];s===3?i[0]=a:s===4?i[1]=Object.assign(i[1]||{},a):s===5?(i[1]=i[1]||{})[e[++o]]=a:s===6?i[1][e[++o]]+=a+"":s?(r=n.apply(a,AS(n,a,t,["",null])),i.push(r),a[0]?e[0]|=2:(e[o-2]=0,e[o]=r)):i.push(a)}return i},TS=new Map;function MS(n){var e=TS.get(this);return e||(e=new Map,TS.set(this,e)),(e=AS(this,e.get(n)||(e.set(n,e=(function(t){for(var i,r,o=1,s="",a="",l=[0],c=function(h){o===1&&(h||(s=s.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?l.push(0,h,s):o===3&&(h||s)?(l.push(3,h,s),o=2):o===2&&s==="..."&&h?l.push(4,h,0):o===2&&s&&!h?l.push(5,0,!0,s):o>=5&&((s||!h&&o===5)&&(l.push(o,0,s,r),o=6),h&&(l.push(o,h,0,r),o=6)),s=""},u=0;u<t.length;u++){u&&(o===1&&c(),c(u));for(var f=0;f<t[u].length;f++)i=t[u][f],o===1?i==="<"?(c(),l=[l],o=3):s+=i:o===4?s==="--"&&i===">"?(o=1,s=""):s=i+s[0]:a?i===a?a="":s+=i:i==='"'||i==="'"?a=i:i===">"?(c(),o=1):o&&(i==="="?(o=5,r=s,s=""):i==="/"&&(o<5||t[u][f+1]===">")?(c(),o===3&&(l=l[0]),o=l,(l=l[0]).push(2,0,o),o=0):i===" "||i===" "||i===` 25`||i==="\r"?(c(),o=2):s+=i),o===3&&s==="!--"&&(o=4,l=l[0])}return c(),l})(n)),e),arguments,[])).length>1?e:e[0]}var xe=MS.bind(am);var Ta,dt,bx,PS,Of=0,FS=[],bt=He,DS=bt.__b,IS=bt.__r,LS=bt.diffed,BS=bt.__c,NS=bt.unmount,$S=bt.__;function fm(n,e){bt.__h&&bt.__h(dt,n,Of||e),Of=0;var t=dt.__H||(dt.__H={__:[],__h:[]});return n>=t.__.length&&t.__.push({}),t.__[n]}function kf(n){return Of=1,qS(VS,n)}function qS(n,e,t){var i=fm(Ta++,2);if(i.t=n,!i.__c&&(i.__=[t?t(e):VS(void 0,e),function(a){var l=i.__N?i.__N[0]:i.__[0],c=i.t(l,a);l!==c&&(i.__N=[c,i.__[1]],i.__c.setState({}))}],i.__c=dt,!dt.__f)){var r=function(a,l,c){if(!i.__c.__H)return!0;var u=i.__c.__H.__.filter(function(h){return h.__c});if(u.every(function(h){return!h.__N}))return!o||o.call(this,a,l,c);var f=i.__c.props!==a;return u.some(function(h){if(h.__N){var d=h.__[0];h.__=h.__N,h.__N=void 0,d!==h.__[0]&&(f=!0)}}),o&&o.call(this,a,l,c)||f};dt.__f=!0;var o=dt.shouldComponentUpdate,s=dt.componentWillUpdate;dt.componentWillUpdate=function(a,l,c){if(this.__e){var u=o;o=void 0,r(a,l,c),o=u}s&&s.call(this,a,l,c)},dt.shouldComponentUpdate=r}return i.__N||i.__}function Aa(n,e){var t=fm(Ta++,3);!bt.__s&&wx(t.__H,e)&&(t.__=n,t.u=e,dt.__H.__h.push(t))}function Ma(n,e){var t=fm(Ta++,4);!bt.__s&&wx(t.__H,e)&&(t.__=n,t.u=e,dt.__h.push(t))}function Pa(n){return Of=5,Kn(function(){return{current:n}},[])}function Kn(n,e){var t=fm(Ta++,7);return wx(t.__H,e)&&(t.__=n(),t.__H=e,t.__h=n),t.__}function gs(n,e){return Of=8,Kn(function(){return n},e)}function Cj(){for(var n;n=FS.shift();){var e=n.__H;if(n.__P&&e)try{e.__h.some(um),e.__h.some(_x),e.__h=[]}catch(t){e.__h=[],bt.__e(t,n.__v)}}}bt.__b=function(n){dt=null,DS&&DS(n)},bt.__=function(n,e){n&&e.__k&&e.__k.__m&&(n.__m=e.__k.__m),$S&&$S(n,e)},bt.__r=function(n){IS&&IS(n),Ta=0;var e=(dt=n.__c).__H;e&&(bx===dt?(e.__h=[],dt.__h=[],e.__.some(function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0})):(e.__h.some(um),e.__h.some(_x),e.__h=[],Ta=0)),bx=dt},bt.diffed=function(n){LS&&LS(n);var e=n.__c;e&&e.__H&&(e.__H.__h.length&&(FS.push(e)!==1&&PS===bt.requestAnimationFrame||((PS=bt.requestAnimationFrame)||Ej)(Cj)),e.__H.__.some(function(t){t.u&&(t.__H=t.u),t.u=void 0})),bx=dt=null},bt.__c=function(n,e){e.some(function(t){try{t.__h.some(um),t.__h=t.__h.filter(function(i){return!i.__||_x(i)})}catch(i){e.some(function(r){r.__h&&(r.__h=[])}),e=[],bt.__e(i,t.__v)}}),BS&&BS(n,e)},bt.unmount=function(n){NS&&NS(n);var e,t=n.__c;t&&t.__H&&(t.__H.__.some(function(i){try{um(i)}catch(r){e=r}}),t.__H=void 0,e&&bt.__e(e,t.__v))};var jS=typeof requestAnimationFrame=="function";function Ej(n){var e,t=function(){clearTimeout(i),jS&&cancelAnimationFrame(e),setTimeout(n)},i=setTimeout(t,35);jS&&(e=requestAnimationFrame(t))}function um(n){var e=dt,t=n.__c;typeof t=="function"&&(n.__c=void 0,t()),dt=e}function _x(n){var e=dt;n.__c=n.__(),dt=e}function wx(n,e){return!n||n.length!==e.length||e.some(function(t,i){return t!==n[i]})}function VS(n,e){return typeof e=="function"?e(n):e}function Cx(n){let{navigationStack:e,setNavigationStack:t}=n,i=Kn(()=>e.length<=1?[]:e.slice(0,-1).map((s,a)=>({label:s.label,onClick:()=>t(l=>l.slice(0,a+1))})),[e,t]),r=e.length>0?()=>t([]):null,o=e.length>0?e[e.length-1].label:null;return xe` 26 <div class="djs-popup-breadcrumbs"> 27 ${r&&xe` 28 <button 29 type="button" 30 class="djs-popup-breadcrumbs-item djs-popup-breadcrumbs-item--back" 31 title="Back" 32 aria-label="Back" 33 onClick=${r} 34 > 35 <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"> 36 <path fill-rule="evenodd" clip-rule="evenodd" d="M8.03033 1.46967C8.32322 1.76256 8.32322 2.23744 8.03033 2.53033L4.56066 6L8.03033 9.46967C8.32322 9.76256 8.32322 10.2374 8.03033 10.5303C7.73744 10.8232 7.26256 10.8232 6.96967 10.5303L2.96967 6.53033C2.67678 6.23744 2.67678 5.76256 2.96967 5.46967L6.96967 1.46967C7.26256 1.17678 7.73744 1.17678 8.03033 1.46967Z" fill="currentColor"/> 37 </svg> 38 </button> 39 `} 40 ${i.map((s,a)=>xe` 41 <button 42 key=${a} 43 type="button" 44 class="djs-popup-breadcrumbs-item" 45 onClick=${s.onClick} 46 title=${s.label} 47 > 48 ${s.label} 49 </button> 50 <span class="djs-popup-breadcrumbs-item--separator" aria-hidden="true"></span> 51 `)} 52 ${o&&xe` 53 <span class="djs-popup-breadcrumbs-item djs-popup-breadcrumbs-item--current" title=${o}> 54 ${o} 55 </span> 56 `} 57 </div> 58 `}function HS(n){var e,t,i="";if(typeof n=="string"||typeof n=="number")i+=n;else if(typeof n=="object")if(Array.isArray(n)){var r=n.length;for(e=0;e<r;e++)n[e]&&(t=HS(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function Sj(){for(var n,e,t=0,i="",r=arguments.length;t<r;t++)(n=arguments[t])&&(e=HS(n))&&(i&&(i+=" "),i+=e);return i}var ys=Sj;function Ex(n){let{headerEntries:e,onSelect:t,selectedEntry:i,setSelectedEntry:r,title:o}=n,s=Kn(()=>Oj(e),[e]),a=c=>c.action&&!c.disabled,l=(c,u)=>{if(a(u))return t(c,u)};return xe` 59 <div class="djs-popup-header"> 60 <h3 class="djs-popup-title" title=${o}>${o}</h3> 61 ${s.map(c=>xe` 62 <ul key=${c.id} class="djs-popup-header-group" data-header-group=${c.id}> 63 64 ${c.entries.map(u=>xe` 65 <li key=${u.id}> 66 <${a(u)?"button":"span"} 67 class=${kj(u,u===i)} 68 onClick=${f=>l(f,u)} 69 title=${u.title||u.label} 70 data-id=${u.id} 71 aria-disabled=${u.disabled||void 0} 72 onMouseEnter=${()=>a(u)&&r(u)} 73 onMouseLeave=${()=>a(u)&&r(null)} 74 onFocus=${()=>a(u)&&r(u)} 75 onBlur=${()=>a(u)&&r(null)} 76 > 77 ${u.imageUrl&&xe`<img class="djs-popup-entry-icon" src=${u.imageUrl} alt="" />`||u.imageHtml&&xe`<div class="djs-popup-entry-icon" dangerouslySetInnerHTML=${{__html:u.imageHtml}} />`} 78 ${u.label?xe` 79 <span class="djs-popup-label">${u.label}</span> 80 `:null} 81 </${u.action?"button":"span"}> 82 </li> 83 `)} 84 </ul> 85 `)} 86 </div> 87 `}function Oj(n){return n.reduce((e,t)=>{let i=t.group||"default",r=e.find(o=>o.id===i);return r?r.entries.push(t):e.push({id:i,entries:[t]}),e},[])}function kj(n,e){return ys("entry",n.className,n.active?"active":"",n.disabled?"disabled":"",e?"selected":"")}function Sx(n){let{entry:e,selected:t,onMouseEnter:i,onMouseLeave:r,onAction:o}=n,s=(l,c)=>{if(!e.disabled)return o(l,e,c)},a=!e.entries;return xe` 88 <li 89 class=${ys("entry",{selected:t,disabled:e.disabled})} 90 data-id=${e.id} 91 title=${e.title} 92 aria-disabled=${e.disabled||void 0} 93 tabIndex="0" 94 onClick=${s} 95 onFocus=${i} 96 onBlur=${r} 97 onMouseEnter=${i} 98 onMouseLeave=${r} 99 onDragStart=${l=>a&&s(l,"dragstart")} 100 draggable=${a} 101 > 102 <div class="djs-popup-entry-content"> 103 <span 104 class=${ys("djs-popup-entry-name",e.className)} 105 > 106 ${e.imageUrl&&xe`<img class="djs-popup-entry-icon" src=${e.imageUrl} alt="" />`||e.imageHtml&&xe`<div class="djs-popup-entry-icon" dangerouslySetInnerHTML=${{__html:e.imageHtml}} />`} 107 108 ${e.label?xe` 109 <span class="djs-popup-label"> 110 ${e.label} 111 </span> 112 `:null} 113 114 ${e.documentationRef&&xe` 115 <a class="djs-popup-entry-docs" 116 href=${e.documentationRef} 117 onClick=${l=>l.stopPropagation()} 118 title="Open element documentation" 119 aria-label="Open element documentation" 120 target="_blank" 121 rel="noopener" 122 > 123 <svg aria-hidden="true" width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"> 124 <path fill-rule="evenodd" clip-rule="evenodd" d="M10.6368 10.6375V5.91761H11.9995V10.6382C11.9995 10.9973 11.8623 11.3141 11.5878 11.5885C11.3134 11.863 10.9966 12.0002 10.6375 12.0002H1.36266C0.982345 12.0002 0.660159 11.8681 0.396102 11.6041C0.132044 11.34 1.52588e-05 11.0178 1.52588e-05 10.6375V1.36267C1.52588e-05 0.98236 0.132044 0.660173 0.396102 0.396116C0.660159 0.132058 0.982345 2.95639e-05 1.36266 2.95639e-05H5.91624V1.36267H1.36266V10.6375H10.6368ZM12 0H7.2794L7.27873 1.36197H9.68701L3.06507 7.98391L4.01541 8.93425L10.6373 2.31231V4.72059H12V0Z" fill="#818798"/> 125 </svg> 126 </a> 127 `} 128 </span> 129 ${e.description&&xe` 130 <span 131 class="djs-popup-entry-description" 132 > 133 ${e.description} 134 </span> 135 `} 136 </div> 137 ${e.entries&&xe` 138 <div class="djs-popup-entry-chevron" aria-hidden="true"> 139 <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"> 140 <path fill-rule="evenodd" clip-rule="evenodd" d="M3.96967 1.46967C4.26256 1.17678 4.73744 1.17678 5.03033 1.46967L9.03033 5.46967C9.32322 5.76256 9.32322 6.23744 9.03033 6.53033L5.03033 10.5303C4.73744 10.8232 4.26256 10.8232 3.96967 10.5303C3.67678 10.2374 3.67678 9.76256 3.96967 9.46967L7.43934 6L3.96967 2.53033C3.67678 2.23744 3.67678 1.76256 3.96967 1.46967Z" fill="currentColor"/> 141 </svg> 142 </div> 143 `} 144 </li> 145 `}function Ox(n){let{selectedEntry:e,setSelectedEntry:t,groupedEntries:i,...r}=n,o=Pa();return Ma(()=>{let s=o.current;if(!s)return;let a=s.querySelector(".selected");a&&Rj(a)},[e]),xe` 146 <div class="djs-popup-results" ref=${o}> 147 ${i.map(s=>xe` 148 ${s.name&&xe` 149 <div key=${s.id} class="entry-header" title=${s.name}> 150 ${s.name} 151 </div> 152 `} 153 <ul class="djs-popup-group" data-group=${s.id}> 154 ${s.entries.map(a=>xe` 155 <${Sx} 156 key=${a.id} 157 entry=${a} 158 selected=${a===e} 159 onMouseEnter=${()=>t(a)} 160 onMouseLeave=${()=>t(null)} 161 ...${r} 162 /> 163 `)} 164 </ul> 165 `)} 166 </div> 167 `}function Rj(n){typeof n.scrollIntoViewIfNeeded=="function"?n.scrollIntoViewIfNeeded():n.scrollIntoView({scrollMode:"if-needed",block:"nearest"})}function kx(n){let{onClose:e,onSelect:t,className:i,headerEntries:r,position:o,title:s,width:a,scale:l,search:c,emptyPlaceholder:u,searchFn:f,entries:h,onOpened:d,onClosed:p}=n,[m,g]=kf([]);Aa(()=>{g([])},[h]);let[b,_]=kf(""),v=b.trim().length>0,x=Kn(()=>Mj(h),[h]),C=Kn(()=>Me(c)?x.length>5:!1,[c,x]),E=Kn(()=>{let re=m.length?m[m.length-1].entries:h;return C?v?f(x.filter(({searchable:me})=>me!==!1),b,{keys:["label","search","description"]}).map(({item:me})=>me):re.filter(({rank:me=0})=>me>=0):re},[C,v,x,b,f,m,h]),S=Kn(()=>v?E.length?[{id:"default",entries:E}]:[]:Pj(E),[E,v]),[w,R]=kf(E[0]),A=Pa(null);Aa(()=>{let re=A.current;re&&E.includes(re)?R(re):R(E[0]),A.current=null},[E]);let I=gs(re=>{let me=Aj(S),$e=me.indexOf(w)+re;$e<0&&($e=me.length-1),$e>=me.length&&($e=0),R(me[$e])},[S,w]),D=gs(re=>{re>0&&w&&w.entries&&g(me=>[...me,w]),re<0&&m.length>0&&(A.current=m[m.length+re],g(me=>me.slice(0,re)))},[w,m]),N=gs((re,me,Ue)=>{if(!(!me||me.disabled))return me.entries?(re.preventDefault(),D(1)):t(re,me,Ue)},[t,D]),W=gs(re=>{if(re.key==="Enter"&&w)return w.disabled?void 0:N(re,w);if(re.key==="Backspace"){let me=re.target;if(!(hr(me,"input")&&me.value!==""))return D(-1),re.preventDefault()}if(re.key==="ArrowUp")return I(-1),re.preventDefault();if(re.key==="ArrowDown")return I(1),re.preventDefault();if(re.key==="ArrowRight")return D(1),re.preventDefault();if(re.key==="ArrowLeft")return D(-1),re.preventDefault()},[w,I,D,N]),Re=gs(re=>{hr(re.target,"input")&&_(()=>re.target.value)},[_]);Aa(()=>(d(),()=>{p()}),[]);let _e=!v&&m.length>0,ue=(s||r.length>0)&&!_e;return xe` 168 <${zS} 169 onClose=${e} 170 onKeyup=${Re} 171 onKeydown=${W} 172 className=${i} 173 position=${o} 174 width=${a} 175 scale=${l} 176 > 177 ${ue&&xe` 178 <${Ex} 179 headerEntries=${r} 180 onSelect=${t} 181 selectedEntry=${w} 182 setSelectedEntry=${R} 183 title=${s} 184 /> 185 `} 186 ${_e&&xe` 187 <${Cx} 188 navigationStack=${m} 189 setNavigationStack=${g} 190 /> 191 `} 192 ${h.length>0&&xe` 193 <div class="djs-popup-body"> 194 195 ${C&&xe` 196 <div class="djs-popup-search"> 197 <svg class="djs-popup-search-icon" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"> 198 <path fill-rule="evenodd" clip-rule="evenodd" d="M9.0325 8.5H9.625L13.3675 12.25L12.25 13.3675L8.5 9.625V9.0325L8.2975 8.8225C7.4425 9.5575 6.3325 10 5.125 10C2.4325 10 0.25 7.8175 0.25 5.125C0.25 2.4325 2.4325 0.25 5.125 0.25C7.8175 0.25 10 2.4325 10 5.125C10 6.3325 9.5575 7.4425 8.8225 8.2975L9.0325 8.5ZM1.75 5.125C1.75 6.9925 3.2575 8.5 5.125 8.5C6.9925 8.5 8.5 6.9925 8.5 5.125C8.5 3.2575 6.9925 1.75 5.125 1.75C3.2575 1.75 1.75 3.2575 1.75 5.125Z" fill="#22242A"/> 199 </svg> 200 <input type="text" spellcheck=${!1} aria-label="${s||"Search"}" /> 201 </div> 202 `} 203 204 ${v&&xe` 205 <div class="djs-popup-search-count" aria-live="polite"> 206 ${E.length} ${E.length===1?"result":"results"} found 207 </div> 208 `} 209 210 <${Ox} 211 groupedEntries=${S} 212 selectedEntry=${w} 213 setSelectedEntry=${R} 214 onAction=${N} 215 /> 216 </div> 217 `} 218 ${u&&E.length===0&&xe` 219 <div class="djs-popup-no-results">${ge(u)?u(b):u}</div> 220 `} 221 </${zS}> 222 `}function zS(n){let{onClose:e,onKeydown:t,onKeyup:i,className:r,children:o,position:s}=n,a=Pa();return Ma(()=>{if(typeof s!="function")return;let l=a.current,c=s(l);l.style.left=`${c.x}px`,l.style.top=`${c.y}px`},[a.current,s]),Ma(()=>{let l=a.current;if(!l)return;(l.querySelector("input")||l).focus()},[]),Aa(()=>{let l=u=>{if(u.key==="Escape")return u.preventDefault(),e()},c=u=>{if(!De(u.target,".djs-popup",!0))return e()};return document.documentElement.addEventListener("keydown",l),document.body.addEventListener("click",c,!0),()=>{document.documentElement.removeEventListener("keydown",l),document.body.removeEventListener("click",c,!0)}},[]),xe` 223 <div 224 class=${ys("djs-popup",r)} 225 style=${Tj(n)} 226 onKeydown=${t} 227 onKeyup=${i} 228 ref=${a} 229 tabIndex="-1" 230 > 231 ${o} 232 </div> 233 `}function Tj(n){return{transform:`scale(${n.scale})`,width:`${n.width}px`,"transform-origin":"top left"}}function Aj(n){let e=[];return n.forEach(t=>{t.entries.forEach(i=>{e.push(i)})}),e}function Mj(n){let e=[];function t(i){i.forEach(r=>{if(r.entries){t(r.entries);return}e.push(r)})}return t(n),e}function Pj(n){let e=[],t=o=>e.find(s=>o.id===s.id),i=o=>!!t(o),r=o=>typeof o=="string"?{id:o}:o;return n.forEach(o=>{let s=o.group?r(o.group):{id:"default"};i(s)?t(s).entries.push(o):e.push({...s,entries:[o]})}),e}var Dj="data-id",WS=["contextPad.close","canvas.viewbox.changing","commandStack.changed"],Ij=1e3;function Le(n,e,t,i){this._eventBus=e,this._canvas=t,this._search=i,this._current=null;var r=Me(n&&n.scale)?n.scale:{min:1,max:1};this._config={scale:r},e.on("diagram.destroy",()=>{this.close()}),e.on("element.changed",o=>{let s=this.isOpen()&&this._current.target;o.element===s&&this.refresh()})}Le.$inject=["config.popupMenu","eventBus","canvas","search"];Le.prototype._render=function(){let{position:n,providerId:e,entries:t,headerEntries:i,emptyPlaceholder:r,options:o}=this._current,s=US(t),a=Object.entries(i).map(([h,d])=>({id:h,...d})),l=n&&(h=>this._ensureVisible(h,n)),c=this._updateScale(this._current.container);cm(xe` 234 <${kx} 235 onClose=${h=>this.close(h)} 236 onSelect=${(h,d,p)=>this.trigger(h,d,p)} 237 position=${l} 238 className=${e} 239 entries=${s} 240 headerEntries=${a} 241 emptyPlaceholder=${r} 242 scale=${c} 243 onOpened=${this._onOpened.bind(this)} 244 onClosed=${this._onClosed.bind(this)} 245 searchFn=${this._search} 246 ...${{...o}} 247 /> 248 `,this._current.container)};Le.prototype.open=function(n,e,t,i){if(!n)throw new Error("target is missing");if(!e)throw new Error("providers for <"+e+"> not found");if(!t)throw new Error("position is missing");var r=this._eventBus.fire("popupMenu.open.allowed",{target:n,providerId:e});if(r===!1)return;this.isOpen()&&this.close();let{entries:o,headerEntries:s,emptyPlaceholder:a}=this._getContext(n,e);this._current={position:t,providerId:e,target:n,entries:o,headerEntries:s,emptyPlaceholder:a,container:this._createContainer({provider:e}),options:i},this._emit("open"),this._bindAutoClose(),this._render()};Le.prototype.refresh=function(){if(!this.isOpen())return;let{target:n,providerId:e}=this._current,{entries:t,headerEntries:i,emptyPlaceholder:r}=this._getContext(n,e);this._current={...this._current,entries:t,headerEntries:i,emptyPlaceholder:r},this._emit("refresh"),this._render()};Le.prototype._getContext=function(n,e){let t=this._getProviders(e);if(!t||!t.length)throw new Error("provider for <"+e+"> not found");let i=this._getEntries(n,t),r=this._getHeaderEntries(n,t),o=this._getEmptyPlaceholder(t);return{entries:i,headerEntries:r,emptyPlaceholder:o,empty:!(Object.keys(i).length||Object.keys(r).length)}};Le.prototype.close=function(){this.isOpen()&&(this._emit("close"),this.reset(),this._canvas.restoreFocus(),this._current=null)};Le.prototype.reset=function(){let n=this._current.container;cm(null,n),Qe(n)};Le.prototype._emit=function(n,e){this._eventBus.fire(`popupMenu.${n}`,e)};Le.prototype._onOpened=function(){this._emit("opened")};Le.prototype._onClosed=function(){this._emit("closed")};Le.prototype._createContainer=function(n){var e=this._canvas,t=e.getContainer();let i=te(`<div class="djs-popup-parent djs-scrollable" data-popup=${n.provider}></div>`);return t.appendChild(i),i};Le.prototype._bindAutoClose=function(){this._eventBus.once(WS,this.close,this)};Le.prototype._unbindAutoClose=function(){this._eventBus.off(WS,this.close,this)};Le.prototype._updateScale=function(){var n=this._canvas.zoom(),e=this._config.scale,t,i,r=n;return e!==!0&&(e===!1?(t=1,i=1):(t=e.min,i=e.max),Me(t)&&n<t&&(r=t),Me(i)&&n>i&&(r=i)),r};Le.prototype._ensureVisible=function(n,e){var t=document.documentElement.getBoundingClientRect(),i=n.getBoundingClientRect(),r={},o=e.x,s=e.y;return e.x+i.width>t.width&&(r.x=!0),e.y+i.height>t.height&&(r.y=!0),r.x&&r.y?(o=e.x-i.width,s=e.y-i.height):r.x?(o=e.x-i.width,s=e.y):r.y&&e.y<i.height?(o=e.x,s=10):r.y&&(o=e.x,s=e.y-i.height),e.y<t.top&&(s=e.y+i.height),{x:o,y:s}};Le.prototype.isEmpty=function(n,e){if(!n)throw new Error("target is missing");if(!e)throw new Error("provider ID is missing");let t=this._getProviders(e);return!t||!t.length?!0:this._getContext(n,e).empty};Le.prototype.registerProvider=function(n,e,t){t||(t=e,e=Ij),this._eventBus.on("popupMenu.getProviders."+n,e,function(i){i.providers.push(t)})};Le.prototype._getProviders=function(n){var e=this._eventBus.createEvent({type:"popupMenu.getProviders."+n,providers:[]});return this._eventBus.fire(e),e.providers};Le.prototype._getEntries=function(n,e){var t={};return k(e,function(i){if(!i.getPopupMenuEntries){k(i.getEntries(n),function(o){var s=o.id;if(!s)throw new Error("entry ID is missing");t[s]=Uu(o,["id"])});return}var r=i.getPopupMenuEntries(n);ge(r)?t=r(t):k(r,function(o,s){t[s]=o})}),t};Le.prototype._getHeaderEntries=function(n,e){var t={};return k(e,function(i){if(!i.getPopupMenuHeaderEntries){if(!i.getHeaderEntries)return;k(i.getHeaderEntries(n),function(o){var s=o.id;if(!s)throw new Error("entry ID is missing");t[s]=Uu(o,["id"])});return}var r=i.getPopupMenuHeaderEntries(n);ge(r)?t=r(t):k(r,function(o,s){t[s]=o})}),t};Le.prototype._getEmptyPlaceholder=function(n){let e=n.find(t=>ge(t.getEmptyPlaceholder));return e&&e.getEmptyPlaceholder()};Le.prototype.isOpen=function(){return!!this._current};Le.prototype.trigger=function(n,e,t="click"){if(n.preventDefault(),!e){let r=De(n.delegateTarget||n.target,".entry",!0),o=et(r,Dj);e={id:o,...this._getEntry(o)}}let i=e.action;if(this._emit("trigger",{entry:e,event:n})!==!1){if(ge(i)){if(t==="click")return i(n,e)}else if(i[t])return i[t](n,e)}};Le.prototype._getEntry=function(n){var e=this._current.entries[n]||this._current.headerEntries[n];if(!e)throw new Error("entry not found");return e};function US(n){return Object.entries(n).map(([e,t])=>{let i={id:e,...t};return i.entries&&(i.entries=US(i.entries)),i})}function Rx(n,e,t){let{keys:i}=t;if(e=e.trim().toLowerCase(),!e)throw new Error("<pattern> must not be empty");let r=e.trim().toLowerCase().split(/\s+/);return n.flatMap(o=>{let s=Lj(o,r,i);return s?{item:o,tokens:s}:[]}).sort(Bj(i))}function Lj(n,e,t){let{matchedWords:i,tokens:r}=t.reduce((o,s)=>{let a=n[s],{tokens:l,matchedWords:c}=F(a)?a.reduce((u,f)=>{let{tokens:h,matchedWords:d}=XS(f,e);return{tokens:[...u.tokens,h],matchedWords:{...u.matchedWords,...d}}},{matchedWords:{},tokens:[]}):XS(a,e);return{tokens:{...o.tokens,[s]:l},matchedWords:{...o.matchedWords,...c}}},{matchedWords:{},tokens:{}});return Object.keys(i).length!==e.length?null:r}function Bj(n){return(e,t)=>{let i=0,r=1;for(let o of n){let s=Nj(e.tokens[o],t.tokens[o]);if(s!==0){i+=s*r,r*=QS;continue}let a=$j(e.item[o],t.item[o]);if(a!==0){i+=a*r,r*=QS;continue}}return i}}function Nj(n,e){return KS(e)-KS(n)}var QS=.5,Da={FULL:131.9,START_FULL_WORD:8,START_WORD_PART:7.87,WORD_START:2.19,WORD_PART:1,NO_MATCH:-.07};function KS(n){let e=n.reduce((a,l)=>a+YS(l),0),t=n.flat(),i=t.reduce((a,l)=>a+l.value.length,0),r=t.reduce((a,l)=>a+(l.match?l.value.length:0),0),o=i?r/i:0;return e*(1+o)}function YS(n){if(F(n))return Math.max(...n.map(YS));let e=Math.log(n.value.length);return n.match?(n.start?n.end?Da.FULL:n.wordEnd?Da.START_FULL_WORD:Da.START_WORD_PART:n.wordStart?Da.WORD_START:Da.WORD_PART)*e:Da.NO_MATCH*e}function GS(n=""){return F(n)?n.join(", "):n}function $j(n,e){return GS(n).localeCompare(GS(e))}function XS(n,e){var c;if(!n)return{tokens:[],matchedWords:{}};let t=[],i={},r=e.map(jj),o=[`(?<all>${r.join("\\s+")})`,...r].join("|"),s=new RegExp(o,"ig"),a,l=0;for(;a=s.exec(n);){let[u]=a,f=a.index,h=a.index+u.length,d=f===0,p=h===n.length,m=!!((c=a.groups)!=null&&c.all),g=d||/\s/.test(n.charAt(f-1)),b=p||/\s/.test(n.charAt(h));a.index>l&&t.push({value:n.slice(l,a.index),index:l}),t.push({value:u,index:a.index,match:!0,wordStart:g,wordEnd:b,start:d,end:p,all:m});let _=m?e:[u];for(let v of _)i[v.toLowerCase()]=!0;l=a.index+u.length}return l<n.length&&t.push({value:n.slice(l),index:l}),{tokens:t,matchedWords:i}}function jj(n){return n.replace(/[/\-\\^$*+?.()|[\]{}]/g,"\\$&")}var ZS={search:["value",Rx]};var JS={__depends__:[ZS],__init__:["popupMenu"],popupMenu:["type",Le]};var eO=Math.round;function Rf(n,e){this._modeling=n,this._eventBus=e}Rf.$inject=["modeling","eventBus"];Rf.prototype.replaceElement=function(n,e,t){if(n.waypoints)return null;var i=this._modeling,r=this._eventBus;r.fire("replace.start",{element:n,attrs:e,hints:t});var o=e.width||n.width,s=e.height||n.height,a=e.x||n.x,l=e.y||n.y,c=eO(a+o/2),u=eO(l+s/2),f=i.replaceShape(n,T({},e,{x:c,y:u,width:o,height:s}),t);return r.fire("replace.end",{element:n,newElement:f,hints:t}),f};function hm(n,e){e.on("replace.end",500,function(t){let{newElement:i,hints:r={}}=t;r.select!==!1&&n.select(i)})}hm.$inject=["selection","eventBus"];var tO={__init__:["replace","replaceSelectionBehavior"],replaceSelectionBehavior:["type",hm],replace:["type",Rf]};function dm(n,e,t,i){function r(o,s,a){a=a||{};var l=s.type,c=o.businessObject,u=n.create(l),f={type:l,businessObject:u};if(f.width=o.width,f.height=o.height,u.name=c.name,s.table){var h=n.create("dmn:DecisionTable");h.$parent=u;var d=n.create("dmn:OutputClause");d.typeRef="string",d.$parent=h,h.output=[d];var p=n.create("dmn:InputClause");p.$parent=h;var m=n.create("dmn:LiteralExpression",{typeRef:"string"});p.inputExpression=m,m.$parent=p,h.input=[p],nO(u,h,n)}if(s.expression){var g=n.create("dmn:LiteralExpression"),b=n.create("dmn:InformationItem",{name:c.name});nO(u,g,n,b)}return e.replaceElement(o,f,a)}this.replaceElement=r}dm.$inject=["drdFactory","replace","selection","modeling"];function nO(n,e,t,i){if(O(n,"dmn:Decision"))n.decisionLogic=e,e.$parent=n;else if(O(n,"dmn:BusinessKnowledgeModel")){var r=t.create("dmn:FunctionDefinition",{body:e});n.encapsulatedLogic=r,r.$parent=n,e.$parent=r}i&&(n.variable=i,i.$parent=n)}var iO={__depends__:[tO,ht],drdReplace:["type",dm]};var Tx={DECISION:[{label:"Empty",actionName:"replace-with-empty-decision",className:"dmn-icon-clear",target:{type:"dmn:Decision",table:!1,expression:!1}},{label:"Decision table",actionName:"replace-with-decision-table",className:"dmn-icon-decision-table",target:{type:"dmn:Decision",table:!0,expression:!1}},{label:"Literal expression",actionName:"replace-with-literal-expression",className:"dmn-icon-literal-expression",target:{type:"dmn:Decision",table:!1,expression:!0}}],BKM:[{label:"Empty",actionName:"replace-with-empty",className:"dmn-icon-clear",target:{type:"dmn:BusinessKnowledgeModel",table:!1,expression:!1}},{label:"Literal Expression",actionName:"replace-with-literal-expression",className:"dmn-icon-literal-expression",target:{type:"dmn:BusinessKnowledgeModel",table:!1,expression:!0}}]};function Er(n,e,t,i,r,o){this._popupMenu=n,this._modeling=e,this._moddle=t,this._drdReplace=i,this._rules=r,this._translate=o,this.register()}Er.$inject=["popupMenu","modeling","moddle","drdReplace","rules","translate"];Er.prototype.register=function(){this._popupMenu.registerProvider("dmn-replace",this)};Er.prototype.getEntries=function(n){var e=n.businessObject,t=this._rules,i,r;return t.allowed("shape.replace",{element:n})?O(e,"dmn:Decision")?(r=dr(e),i=Ee(Tx.DECISION,function(o){var s=o.actionName==="replace-with-empty-decision"&&r,a=o.actionName==="replace-with-decision-table"&&!O(r,"dmn:DecisionTable"),l=o.actionName==="replace-with-literal-expression"&&!O(r,"dmn:LiteralExpression");return s||a||l}),this._createEntries(n,i)):O(e,"dmn:BusinessKnowledgeModel")?(r=dr(e),i=Ee(Tx.BKM,function(o){var s=o.actionName==="replace-with-empty"&&r,a=o.actionName==="replace-with-decision-table"&&!O(r,"dmn:DecisionTable"),l=o.actionName==="replace-with-literal-expression"&&!O(r,"dmn:LiteralExpression");return s||a||l}),this._createEntries(n,i)):[]:[]};Er.prototype._createEntries=function(n,e){var t=[],i=this;return k(e,function(r){var o=i._createMenuEntry(r,n);t.push(o)}),t};Er.prototype._createMenuEntry=function(n,e,t){var i=this._drdReplace.replaceElement,r=this._translate,o=function(){return i(e,n.target)};t=t||o;var s={label:r(n.label),className:n.className,id:n.actionName,action:t};return s};Er.prototype.getHeaderEntries=function(n){return[]};var rO={__depends__:[qe,JS,iO],__init__:["replaceMenuProvider"],replaceMenuProvider:["type",Er]};function vs(n,e,t,i,r,o,s,a,l,c,u,f){u=u||{},e.registerProvider(this),this._contextPad=e,this._modeling=t,this._elementFactory=i,this._connect=r,this._create=o,this._rules=s,this._popupMenu=a,this._canvas=l,this._translate=c,u.autoPlace!==!1&&(this._autoPlace=f.get("autoPlace",!1)),n.on("create.end",250,function(h){var d=h.context.shape;if(hf(h)){var p=e.getEntries(d);p.replace&&p.replace.action.click(h,d)}})}vs.$inject=["eventBus","contextPad","modeling","elementFactory","connect","create","rules","popupMenu","canvas","translate","config.contextPad","injector"];vs.prototype.getContextPadEntries=function(n){var e=this._modeling,t=this._elementFactory,i=this._connect,r=this._create,o=this._popupMenu,s=this._contextPad,a=this._rules,l=this._translate,c=this._autoPlace,u={};if(n.type==="label")return u;var f=n.businessObject;function h(b,_,v){i.start(b,_,v)}function d(b){e.removeElements([n])}function p(b){var _=5,v=s.getPad(b).html,x=v.getBoundingClientRect(),C={x:x.left,y:x.bottom+_};return C}function m(b,_,v,x){function C(S,w){var R=t.createShape(T({type:b},x));r.start(S,R,{source:w,hints:{connectionTarget:w}})}var E=c?function(S,w){var R=t.createShape(T({type:b},x));c.append(w,R,{connectionTarget:w})}:C;return{group:"model",className:_,title:v,action:{dragstart:C,click:E}}}O(f,"dmn:Decision")&&T(u,{"append.decision":m("dmn:Decision","dmn-icon-decision",l("Append decision"))}),Ge(f,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:KnowledgeSource"])&&T(u,{"append.knowledge-source":m("dmn:KnowledgeSource","dmn-icon-knowledge-source",l("Append knowledge source"))}),Ge(f,["dmn:BusinessKnowledgeModel","dmn:Decision"])&&T(u,{"append.business-knowledge-model":m("dmn:BusinessKnowledgeModel","dmn-icon-business-knowledge",l("Append business knowledge model"))}),Ge(f,["dmn:Decision","dmn:KnowledgeSource"])&&T(u,{"append.input-data":m("dmn:InputData","dmn-icon-input-data",l("Append input data"))}),O(f,"dmn:DRGElement")&&T(u,{"append.text-annotation":m("dmn:TextAnnotation","dmn-icon-text-annotation",l("Add text annotation")),connect:{group:"connect",className:"dmn-icon-connection-multi",title:l("Connect to other element"),action:{click:h,dragstart:h}}}),O(f,"dmn:TextAnnotation")&&T(u,{connect:{group:"connect",className:"dmn-icon-connection-multi",title:l("Connect to other element"),action:{click:h,dragstart:h}}}),o.isEmpty(n,"dmn-replace")||T(u,{replace:{group:"edit",className:"dmn-icon-screw-wrench",title:l("Change type"),action:{click:function(b,_){var v=T(p(_),{cursor:{x:b.x,y:b.y}});o.open(_,"dmn-replace",v)}}}});var g=a.allowed("elements.delete",{elements:[n]});return F(g)&&(g=g[0]===n),g&&T(u,{delete:{group:"edit",className:"dmn-icon-trash",title:l("Delete"),action:{click:d}}}),u};vs.prototype.getMultiElementContextPadEntries=function(n){var e=this._modeling,t=this._translate,i={};return this._isDeleteAllowed(n)&&T(i,{delete:{group:"edit",className:"dmn-icon-trash",title:t("Delete"),action:{click:(r,o)=>e.removeElements(o.slice())}}}),i};vs.prototype._isDeleteAllowed=function(n){var e=this._rules.allowed("elements.delete",{elements:n});return F(e)?kt(n,t=>e.includes(t)):e};var oO={__depends__:[qe,oS,ht,lS,Zp,rO],__init__:["contextPadProvider"],contextPadProvider:["type",vs]};var Fj="djs-dragger";function pi(n,e,t,i){this._canvas=e,this._graphicsFactory=t,this._elementFactory=i,this._connectionDocking=n.get("connectionDocking",!1),this._layouter=n.get("layouter",!1)}pi.$inject=["injector","canvas","graphicsFactory","elementFactory"];pi.prototype.drawPreview=function(n,e,t){t=t||{};var i=n.connectionPreviewGfx,r=n.getConnection,o=t.source,s=t.target,a=t.waypoints,l=t.connectionStart,c=t.connectionEnd,u=t.noLayout,f=t.noCropping,h=t.noNoop,d,p=this;if(i||(i=n.connectionPreviewGfx=this.createConnectionPreviewGfx()),ss(i),r||(r=n.getConnection=qj(function(m,g,b){return p.getConnection(m,g,b)})),e&&(d=r(e,o,s)),!d){!h&&this.drawNoopPreview(i,t);return}d.waypoints=a||[],this._layouter&&!u&&(d.waypoints=this._layouter.layoutConnection(d,{source:o,target:s,connectionStart:l,connectionEnd:c,waypoints:t.waypoints||d.waypoints})),(!d.waypoints||!d.waypoints.length)&&(d.waypoints=[o?le(o):l,s?le(s):c]),this._connectionDocking&&(o||s)&&!f&&(d.waypoints=this._connectionDocking.getCroppedWaypoints(d,o,s)),this._graphicsFactory.drawConnection(i,d,{stroke:"var(--element-dragger-color)"})};pi.prototype.drawNoopPreview=function(n,e){var t=e.source,i=e.target,r=e.connectionStart||le(t),o=e.connectionEnd||le(i),s=this.cropWaypoints(r,o,t,i),a=this.createNoopConnection(s[0],s[1]);K(n,a)};pi.prototype.cropWaypoints=function(n,e,t,i){var r=this._graphicsFactory,o=t&&r.getShapePath(t),s=i&&r.getShapePath(i),a=r.getConnectionPath({waypoints:[n,e]});return n=t&&tf(o,a,!0)||n,e=i&&tf(s,a,!1)||e,[n,e]};pi.prototype.cleanUp=function(n){n&&n.connectionPreviewGfx&&Fe(n.connectionPreviewGfx)};pi.prototype.getConnection=function(n){var e=Vj(n);return this._elementFactory.createConnection(e)};pi.prototype.createConnectionPreviewGfx=function(){var n=Q("g");return j(n,{pointerEvents:"none"}),ne(n).add(Fj),K(this._canvas.getActiveLayer(),n),n};pi.prototype.createNoopConnection=function(n,e){return ro([n,e],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};function qj(n){var e={};return function(t){var i=JSON.stringify(t),r=e[i];return r||(r=e[i]=n.apply(null,arguments)),r}}function Vj(n){return Pe(n)?n:{}}var sO={__init__:["connectionPreview"],connectionPreview:["type",pi]};var Hj=/\s/,zj=/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i,Wj=/^[a-z_][\w-.]*$/i,Uj=/\$\{([^}]*)\}/g;function aO(n,e){let t=n.$model.ids.assigned(e),i=t&&t!==n;return e?i?"Element must have unique ID.":Qj(e):"Element must have ID."}function Qj(n){if(n=Gj(n),Kj(n))return"Id must not contain spaces.";if(!Wj.test(n))return zj.test(n)?"Id must not contain prefix.":"Id must be a valid QName."}function Kj(n){return Hj.test(n)}function Gj(n){return n.replace(Uj,"$1")}var Xj=300;function bo(n,e,t,i,r){this._eventBus=n,this._modeling=e,this._canvas=t,this._definitionPropertiesView=i,this._translate=r,n.on("definitionIdView.create",function(o){this._container=o.html;var s=X(".dmn-definitions-name",this._container),a=X(".dmn-definitions-id",this._container);this._setup(s,"name"),this._setup(a,"id")},this)}bo.$inject=["eventBus","modeling","canvas","definitionPropertiesView","translate"];bo.prototype.update=function(n,e){var t=this._canvas.getRootElement(),i={};if(i[n]=e,n==="id"){var r=aO(Ke(t),e);if(r){this._addErrorMessage(r);return}this._clearErrorMessage()}this._modeling.updateProperties(t,i)};bo.prototype._setup=function(n,e){var t=this;n.setAttribute("contenteditable",!0),n.addEventListener("input",Mi(function(i){var r=i.target.value||i.target.textContent;t.update(e,r.trim())},Xj)),n.addEventListener("keydown",function(i){i.keyCode===13&&(n.blur(),window.getSelection().removeAllRanges())}),n.addEventListener("blur",function(){t._clearErrorMessage(),t._definitionPropertiesView.update()})};bo.prototype._addErrorMessage=function(n){let e='<span class="dmn-definitions-error-message">'+this._translate(n)+"</span>";var t=X(".dmn-definitions-id",this._container);this._clearErrorMessage(),ee(t).add("dmn-definitions-error"),t.parentElement.appendChild(te(e))};bo.prototype._clearErrorMessage=function(){var n=X(".dmn-definitions-id",this._container);if(ee(n).has("dmn-definitions-error")){ee(n).remove("dmn-definitions-error");let e=X(".dmn-definitions-error-message",this._container);n.parentNode.removeChild(e)}};var lO={__depends__:[Ca],__init__:["definitionPropertiesEdit","definitionPropertiesPaletteAdapter"],definitionPropertiesEdit:["type",bo],definitionPropertiesPaletteAdapter:["type",wa]};var Yj={horizontal:["x","width"],vertical:["y","height"]},cO=5;function mi(n,e){this._modeling=n,this._filters=[],this.registerFilter(function(t){var i=e.allowed("elements.distribute",{elements:t});return F(i)?i:i?t:[]})}mi.$inject=["modeling","rules"];mi.prototype.registerFilter=function(n){if(typeof n!="function")throw new Error("the filter has to be a function");this._filters.push(n)};mi.prototype.trigger=function(n,e){var t=this._modeling,i,r;if(!(n.length<3)&&(this._setOrientation(e),r=this._filterElements(n),i=this._createGroups(r),!(i.length<=2)))return t.distributeElements(i,this._axis,this._dimension),i};mi.prototype._filterElements=function(n){var e=this._filters,t=this._axis,i=this._dimension,r=[].concat(n);return e.length?(k(e,function(o){r=o(r,t,i)}),r):n};mi.prototype._createGroups=function(n){var e=[],t=this,i=this._axis,r=this._dimension;if(!i)throw new Error('must have a defined "axis" and "dimension"');var o=Fn(n,i);return k(o,function(s,a){var l=t._findRange(s,i,r),c,u=e[e.length-1];u&&t._hasIntersection(u.range,l)?e[e.length-1].elements.push(s):(c={range:l,elements:[s]},e.push(c))}),e};mi.prototype._setOrientation=function(n){var e=Yj[n];this._axis=e[0],this._dimension=e[1]};mi.prototype._hasIntersection=function(n,e){return Math.max(n.min,n.max)>=Math.min(e.min,e.max)&&Math.min(n.min,n.max)<=Math.max(e.min,e.max)};mi.prototype._findRange=function(n){var e=n[this._axis],t=n[this._dimension];return{min:e+cO,max:e+t-cO}};var uO={__init__:["distributeElements"],distributeElements:["type",mi]};function pm(n){n.registerFilter(function(e){return Ee(e,function(t){var i=Ge(t,["dmn:AuthorityRequirement","dmn:InformationRequirement","dmn:KnowledgeRequirement","dmn:Association","dmn:TextAnnotation"]);return!(t.labelTarget||i)})})}pm.$inject=["distributeElements"];var fO={__depends__:[uO],__init__:["drdDistributeElements"],drdDistributeElements:["type",pm]};var hO="is not a registered action",Zj="is already registered";function sn(n,e){this._eventBus=n,this._actions={};var t=this;n.on("diagram.init",function(){t._registerDefaultActions(e),n.fire("editorActions.init",{editorActions:t})})}sn.$inject=["eventBus","injector"];sn.prototype._registerDefaultActions=function(n){var e=n.get("commandStack",!1),t=n.get("modeling",!1),i=n.get("selection",!1),r=n.get("zoomScroll",!1),o=n.get("copyPaste",!1),s=n.get("canvas",!1),a=n.get("rules",!1),l=n.get("keyboardMove",!1),c=n.get("keyboardMoveSelection",!1);e&&(this.register("undo",function(){e.undo()}),this.register("redo",function(){e.redo()})),o&&i&&this.register("copy",function(){var u=i.get();if(u.length)return o.copy(u)}),o&&i&&this.register("duplicate",function(){var u=i.get();if(u.length)return o.duplicate(u)}),o&&this.register("paste",function(){o.paste()}),o&&i&&a&&this.register("cut",function(){var u=i.get();if(u.length){var f=a.allowed("elements.delete",{elements:u});if(f!==!1){var h=F(f)?f:u;return o.cut(h.slice())}}}),r&&this.register("stepZoom",function(u){r.stepZoom(u.value)}),s&&this.register("zoom",function(u){s.zoom(u.value)}),t&&i&&a&&this.register("removeSelection",function(){var u=i.get();if(u.length){var f=a.allowed("elements.delete",{elements:u}),h;f!==!1&&(F(f)?h=f:h=u,h.length&&t.removeElements(h.slice()))}}),l&&this.register("moveCanvas",function(u){l.moveCanvas(u)}),c&&this.register("moveSelection",function(u){c.moveSelection(u.direction,u.accelerated)})};sn.prototype.trigger=function(n,e){if(!this._actions[n])throw Ax(n,hO);var t=this._eventBus.fire("editorActions.allowed",{action:n,opts:e});if(t!==!1)return this._actions[n](e)};sn.prototype.register=function(n,e){var t=this;if(typeof n=="string")return this._registerAction(n,e);k(n,function(i,r){t._registerAction(r,i)})};sn.prototype._registerAction=function(n,e){if(this.isRegistered(n))throw Ax(n,Zj);this._actions[n]=e};sn.prototype.unregister=function(n){if(!this.isRegistered(n))throw Ax(n,hO);this._actions[n]=void 0};sn.prototype.getActions=function(){return Object.keys(this._actions)};sn.prototype.isRegistered=function(n){return!!this._actions[n]};function Ax(n,e){return new Error(n+" "+e)}var dO={__init__:["editorActions"],editorActions:["type",sn]};function Ia(n){n.invoke(sn,this)}fe(Ia,sn);Ia.$inject=["injector"];Ia.prototype._registerDefaultActions=function(n){sn.prototype._registerDefaultActions.call(this,n);let e=n.get("canvas",!1),t=n.get("elementRegistry",!1),i=n.get("selection",!1),r=n.get("lassoTool",!1),o=n.get("handTool",!1),s=n.get("directEditing",!1),a=n.get("distributeElements",!1),l=n.get("alignElements",!1),c=n.get("searchPad",!1);e&&t&&i&&this._registerAction("selectElements",function(){var u=e.getRootElement(),f=t.filter(function(h){return h!==u});return i.select(f),f}),i&&a&&this._registerAction("distributeElements",function(u){var f=i.get(),h=u.type;f.length>2&&a.trigger(f,h)}),i&&l&&this._registerAction("alignElements",function(u){var f=i.get(),h=u.type;f.length>1&&l.trigger(f,h)}),r&&this._registerAction("lassoTool",function(){r.toggle()}),o&&this._registerAction("handTool",function(){o.toggle()}),i&&s&&this._registerAction("directEditing",function(){var u=i.get();u.length&&s.activate(u[0])}),i&&c&&this._registerAction("find",function(){c.toggle()})};var pO={__depends__:[dO],editorActions:["type",Ia]};function La(n){return n.dmnDI&&n.dmnDI.diagrams&&n.dmnDI.diagrams[0]}function mm(n,e,t,i){function r(o){var s=o.dmnDI;s||(s=n.create("dmndi:DMNDI"),o.set("dmnDI",s));var a=n.create("dmndi:DMNDiagram");s.set("diagrams",[a]);var l=0;k(o.get("drgElement"),function(c){if(O(c,"dmn:Decision")){var u=e._getDefaultSize(c),f=n.createDiShape(c,{x:150+l*30,y:150+l*30,width:u.width,height:u.height});i.updateDiParent(f,a),l++}})}t.on("import.start",({definitions:o})=>{La(o)||r(o)})}mm.$inject=["drdFactory","elementFactory","eventBus","drdUpdater"];var mO={__init__:["diGenerator"],diGenerator:["type",mm]};var Jj=1e3;function ae(n){this._eventBus=n}ae.$inject=["eventBus"];function eF(n,e){return function(t){return n.call(e||null,t.context,t.command,t)}}ae.prototype.on=function(n,e,t,i,r,o){if((ge(e)||se(e))&&(o=r,r=i,i=t,t=e,e=null),ge(t)&&(o=r,r=i,i=t,t=Jj),Pe(r)&&(o=r,r=!1),!ge(i))throw new Error("handlerFn must be a function");F(n)||(n=[n]);var s=this._eventBus;k(n,function(a){var l=["commandStack",a,e].filter(function(c){return c}).join(".");s.on(l,t,r?eF(i,o):i,o)})};ae.prototype.canExecute=Sr("canExecute");ae.prototype.preExecute=Sr("preExecute");ae.prototype.preExecuted=Sr("preExecuted");ae.prototype.execute=Sr("execute");ae.prototype.executed=Sr("executed");ae.prototype.postExecute=Sr("postExecute");ae.prototype.postExecuted=Sr("postExecuted");ae.prototype.revert=Sr("revert");ae.prototype.reverted=Sr("reverted");function Sr(n){return function(t,i,r,o,s){(ge(t)||se(t))&&(s=o,o=r,r=i,i=t,t=null),this.on(t,n,i,r,o,s)}}function Or(n,e){ae.call(this,n),this._gridSnapping=e;var t=this;this.preExecute("shape.resize",function(i){var r=i.context,o=r.hints||{},s=o.autoResize;if(s){var a=r.shape,l=r.newBounds;Ie(s)?r.newBounds=t.snapComplex(l,s):r.newBounds=t.snapSimple(a,l)}})}Or.$inject=["eventBus","gridSnapping","modeling"];fe(Or,ae);Or.prototype.snapSimple=function(n,e){var t=this._gridSnapping;return e.width=t.snapValue(e.width,{min:e.width}),e.height=t.snapValue(e.height,{min:e.height}),e.x=n.x+n.width/2-e.width/2,e.y=n.y+n.height/2-e.height/2,e};Or.prototype.snapComplex=function(n,e){return/w|e/.test(e)&&(n=this.snapHorizontally(n,e)),/n|s/.test(e)&&(n=this.snapVertically(n,e)),n};Or.prototype.snapHorizontally=function(n,e){var t=this._gridSnapping,i=/w/.test(e),r=/e/.test(e),o={};return o.width=t.snapValue(n.width,{min:n.width}),r&&(i?(o.x=t.snapValue(n.x,{max:n.x}),o.width+=t.snapValue(n.x-o.x,{min:n.x-o.x})):n.x=n.x+n.width-o.width),T(n,o),n};Or.prototype.snapVertically=function(n,e){var t=this._gridSnapping,i=/n/.test(e),r=/s/.test(e),o={};return o.height=t.snapValue(n.height,{min:n.height}),i&&(r?(o.y=t.snapValue(n.y,{max:n.y}),o.height+=t.snapValue(n.y-o.y,{min:n.y-o.y})):n.y=n.y+n.height-o.height),T(n,o),n};var tF=2e3;function gm(n,e){n.on(["spaceTool.move","spaceTool.end"],tF,function(t){var i=t.context;if(i.initialized){var r=i.axis,o;r==="x"?(o=e.snapValue(t.dx),t.x=t.x+o-t.dx,t.dx=o):(o=e.snapValue(t.dy),t.y=t.y+o-t.dy,t.dy=o)}})}gm.$inject=["eventBus","gridSnapping"];var gO={__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",Or],gridSnappingSpaceToolBehavior:["type",gm]};var Tf=10;function ym(n,e,t){return t||(t="round"),Math[t](n/e)*e}var nF=1200,iF=800;function Fi(n,e,t){var i=!t||t.active!==!1;this._eventBus=e;var r=this;e.on("diagram.init",iF,function(){r.setActive(i)}),e.on(["create.move","create.end","bendpoint.move.move","bendpoint.move.end","connect.move","connect.end","connectionSegment.move.move","connectionSegment.move.end","resize.move","resize.end","shape.move.move","shape.move.end"],nF,function(o){var s=o.originalEvent;if(!(!r.active||s&&Mt(s))){var a=o.context,l=a.gridSnappingContext;l||(l=a.gridSnappingContext={}),["x","y"].forEach(function(c){var u={},f=oF(o,c,n);f&&(u.offset=f);var h=rF(o,c);h&&T(u,h),wr(o,c)||r.snapEvent(o,c,u)})}})}Fi.prototype.snapEvent=function(n,e,t){var i=this.snapValue(n[e],t);vn(n,e,i)};Fi.prototype.getGridSpacing=function(){return Tf};Fi.prototype.snapValue=function(n,e){var t=0;e&&e.offset&&(t=e.offset),n+=t,n=ym(n,Tf);var i,r;return e&&e.min&&(i=e.min,se(i)&&(i=ym(i+t,Tf,"ceil"),n=Math.max(n,i))),e&&e.max&&(r=e.max,se(r)&&(r=ym(r+t,Tf,"floor"),n=Math.min(n,r))),n-=t,n};Fi.prototype.isActive=function(){return this.active};Fi.prototype.setActive=function(n){this.active=n,this._eventBus.fire("gridSnapping.toggle",{active:n})};Fi.prototype.toggleActive=function(){this.setActive(!this.active)};Fi.$inject=["elementRegistry","eventBus","config.gridSnapping"];function rF(n,e){var t=n.context,i=t.createConstraints,r=t.resizeConstraints||{},o=t.gridSnappingContext,s=o.snapConstraints;if(s&&s[e])return s[e];s||(s=o.snapConstraints={}),s[e]||(s[e]={});var a=t.direction;i&&(vm(e)?(s.x.min=i.left,s.x.max=i.right):(s.y.min=i.top,s.y.max=i.bottom));var l=r.min,c=r.max;return l&&(vm(e)?vO(a)?s.x.max=l.left:s.x.min=l.right:yO(a)?s.y.max=l.top:s.y.min=l.bottom),c&&(vm(e)?vO(a)?s.x.min=c.left:s.x.max=c.right:yO(a)?s.y.min=c.top:s.y.max=c.bottom),s[e]}function oF(n,e,t){var i=n.context,r=n.shape,o=i.gridSnappingContext,s=o.snapLocation,a=o.snapOffset;return a&&se(a[e])||(a||(a=o.snapOffset={}),se(a[e])||(a[e]=0),!r)||(t.get(r.id)||(vm(e)?a[e]+=r[e]+r.width/2:a[e]+=r[e]+r.height/2),!s)||(e==="x"?/left/.test(s)?a[e]-=r.width/2:/right/.test(s)&&(a[e]+=r.width/2):/top/.test(s)?a[e]-=r.height/2:/bottom/.test(s)&&(a[e]+=r.height/2)),a[e]}function vm(n){return n==="x"}function yO(n){return n.indexOf("n")!==-1}function vO(n){return n.indexOf("w")!==-1}var xO={__depends__:[gO],__init__:["gridSnapping"],gridSnapping:["type",Fi]};var xm="keyboard.keydown",sF="keyboard.keyup",aF=1e3,bO="Keyboard binding is now implicit; explicit binding to an element got removed. For more information, see https://github.com/bpmn-io/diagram-js/issues/661";function Pt(n,e){var t=this;this._config=n=n||{},this._eventBus=e,this._keydownHandler=this._keydownHandler.bind(this),this._keyupHandler=this._keyupHandler.bind(this),e.on("diagram.destroy",function(){t._fire("destroy"),t.unbind()}),n.bindTo&&console.error("unsupported configuration <keyboard.bindTo>",new Error(bO));var i=n&&n.bind!==!1;e.on("canvas.init",function(r){t._target=r.svg,i&&t.bind(),t._fire("init")})}Pt.$inject=["config.keyboard","eventBus"];Pt.prototype._keydownHandler=function(n){this._keyHandler(n,xm)};Pt.prototype._keyupHandler=function(n){this._keyHandler(n,sF)};Pt.prototype._keyHandler=function(n,e){var t;if(!this._isEventIgnored(n)){var i={keyEvent:n};t=this._eventBus.fire(e||xm,i),t&&n.preventDefault()}};Pt.prototype._isEventIgnored=function(n){return!1};Pt.prototype.bind=function(n){n&&console.error("unsupported argument <node>",new Error(bO)),this.unbind(),n=this._node=this._target,q.bind(n,"keydown",this._keydownHandler),q.bind(n,"keyup",this._keyupHandler),this._fire("bind")};Pt.prototype.getBinding=function(){return this._node};Pt.prototype.unbind=function(){var n=this._node;n&&(this._fire("unbind"),q.unbind(n,"keydown",this._keydownHandler),q.unbind(n,"keyup",this._keyupHandler)),this._node=null};Pt.prototype._fire=function(n){this._eventBus.fire("keyboard."+n,{node:this._node})};Pt.prototype.addListener=function(n,e,t){ge(n)&&(t=e,e=n,n=aF),this._eventBus.on(t||xm,n,e)};Pt.prototype.removeListener=function(n,e){this._eventBus.off(e||xm,n)};Pt.prototype.hasModifier=lE;Pt.prototype.isCmd=Mt;Pt.prototype.isShift=Rp;Pt.prototype.isKey=Ve;var lF=500;function kr(n,e){var t=this;n.on("editorActions.init",lF,function(i){var r=i.editorActions;t.registerBindings(e,r)})}kr.$inject=["eventBus","keyboard"];kr.prototype.registerBindings=function(n,e){function t(i,r){e.isRegistered(i)&&n.addListener(r)}t("undo",function(i){var r=i.keyEvent;if(Tp(r))return e.trigger("undo"),!0}),t("redo",function(i){var r=i.keyEvent;if(Ap(r))return e.trigger("redo"),!0}),t("copy",function(i){var r=i.keyEvent;if(cE(r))return e.trigger("copy"),!0}),t("paste",function(i){var r=i.keyEvent;if(uE(r))return e.trigger("paste"),!0}),t("duplicate",function(i){var r=i.keyEvent;if(fE(r))return e.trigger("duplicate"),!0}),t("cut",function(i){var r=i.keyEvent;if(hE(r))return e.trigger("cut"),!0}),t("stepZoom",function(i){var r=i.keyEvent;if(Ve(["+","Add","="],r)&&Mt(r))return e.trigger("stepZoom",{value:1}),!0}),t("stepZoom",function(i){var r=i.keyEvent;if(Ve(["-","Subtract"],r)&&Mt(r))return e.trigger("stepZoom",{value:-1}),!0}),t("zoom",function(i){var r=i.keyEvent;if(Ve("0",r)&&Mt(r))return e.trigger("zoom",{value:1}),!0}),t("removeSelection",function(i){var r=i.keyEvent;if(Ve(["Backspace","Delete","Del"],r))return e.trigger("removeSelection"),!0})};var _o={__init__:["keyboard","keyboardBindings"],keyboard:["type",Pt],keyboardBindings:["type",kr]};function Ba(n){n.invoke(kr,this)}fe(Ba,kr);Ba.$inject=["injector"];Ba.prototype.registerBindings=function(n,e){kr.prototype.registerBindings.call(this,n,e);function t(i,r){e.isRegistered(i)&&n.addListener(r)}t("selectElements",function(i){var r=i.keyEvent;if(n.isKey(["a","A"],r)&&n.isCmd(r))return e.trigger("selectElements"),!0}),t("lassoTool",function(i){var r=i.keyEvent;if(!n.hasModifier(r)&&n.isKey(["l","L"],r))return e.trigger("lassoTool"),!0}),t("handTool",function(i){var r=i.keyEvent;if(!n.hasModifier(r)&&n.isKey(["h","H"],r))return e.trigger("handTool"),!0}),t("directEditing",function(i){var r=i.keyEvent;if(!n.hasModifier(r)&&n.isKey(["e","E"],r))return e.trigger("directEditing"),!0}),t("find",function(i){var r=i.keyEvent;if(n.isKey(["f","F"],r)&&n.isCmd(r))return e.trigger("find"),!0})};var _O={__depends__:[_o],__init__:["keyboardBindings"],keyboardBindings:["type",Ba]};var cF={moveSpeed:50,moveSpeedAccelerated:200};function bm(n,e,t){var i=this;this._config=T({},cF,n||{}),e.addListener(r);function r(o){var s=o.keyEvent,a=i._config;if(e.isCmd(s)&&e.isKey(["ArrowLeft","Left","ArrowUp","Up","ArrowDown","Down","ArrowRight","Right"],s)){var l=e.isShift(s)?a.moveSpeedAccelerated:a.moveSpeed,c;switch(s.key){case"ArrowLeft":case"Left":c="left";break;case"ArrowUp":case"Up":c="up";break;case"ArrowRight":case"Right":c="right";break;case"ArrowDown":case"Down":c="down";break}return i.moveCanvas({speed:l,direction:c}),!0}}this.moveCanvas=function(o){var s=0,a=0,l=o.speed,c=l/Math.min(Math.sqrt(t.viewbox().scale),1);switch(o.direction){case"left":s=c;break;case"up":a=c;break;case"right":s=-c;break;case"down":a=-c;break}t.scroll({dx:s,dy:a})}}bm.$inject=["config.keyboardMove","keyboard","canvas"];var wO={__depends__:[_o],__init__:["keyboardMove"],keyboardMove:["type",bm]};var uF={moveSpeed:1,moveSpeedAccelerated:10},fF=1500,CO="left",EO="up",SO="right",OO="down",hF={ArrowLeft:CO,Left:CO,ArrowUp:EO,Up:EO,ArrowRight:SO,Right:SO,ArrowDown:OO,Down:OO},dF={left:function(n){return{x:-n,y:0}},up:function(n){return{x:0,y:-n}},right:function(n){return{x:n,y:0}},down:function(n){return{x:0,y:n}}};function _m(n,e,t,i,r){var o=this;this._config=T({},uF,n||{}),e.addListener(fF,function(s){var a=s.keyEvent,l=hF[a.key];if(l&&!e.isCmd(a)){var c=e.isShift(a);return o.moveSelection(l,c),!0}}),this.moveSelection=function(s,a){var l=r.get();if(l.length){var c=this._config[a?"moveSpeedAccelerated":"moveSpeed"],u=dF[s](c),f=i.allowed("elements.move",{shapes:l,hints:{keyboardMove:!0}});f&&t.moveElements(l,u)}}}_m.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];var kO={__depends__:[_o,ht],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",_m]};function ke(n,e){this._handlerMap={},this._stack=[],this._stackIdx=-1,this._currentExecution={actions:[],dirty:[],trigger:null},this._injector=e,this._eventBus=n,this._uid=1,n.on(["diagram.destroy","diagram.clear"],function(){this.clear(!1)},this)}ke.$inject=["eventBus","injector"];ke.prototype.execute=function(n,e){if(!n)throw new Error("command required");this._currentExecution.trigger="execute";let t={command:n,context:e};this._pushAction(t),this._internalExecute(t),this._popAction()};ke.prototype.canExecute=function(n,e){let t={command:n,context:e},i=this._getHandler(n),r=this._fire(n,"canExecute",t);if(r===void 0){if(!i)return!1;i.canExecute&&(r=i.canExecute(e))}return r};ke.prototype.clear=function(n){this._stack.length=0,this._stackIdx=-1,n!==!1&&this._fire("changed",{trigger:"clear"})};ke.prototype.undo=function(){let n=this._getUndoAction(),e;if(n){for(this._currentExecution.trigger="undo",this._pushAction(n);n&&(this._internalUndo(n),e=this._getUndoAction(),!(!e||e.id!==n.id));)n=e;this._popAction()}};ke.prototype.redo=function(){let n=this._getRedoAction(),e;if(n){for(this._currentExecution.trigger="redo",this._pushAction(n);n&&(this._internalExecute(n,!0),e=this._getRedoAction(),!(!e||e.id!==n.id));)n=e;this._popAction()}};ke.prototype.register=function(n,e){this._setHandler(n,e)};ke.prototype.registerHandler=function(n,e){if(!n||!e)throw new Error("command and handlerCls must be defined");let t=this._injector.instantiate(e);this.register(n,t)};ke.prototype.canUndo=function(){return!!this._getUndoAction()};ke.prototype.canRedo=function(){return!!this._getRedoAction()};ke.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]};ke.prototype._getUndoAction=function(){return this._stack[this._stackIdx]};ke.prototype._internalUndo=function(n){let e=n.command,t=n.context,i=this._getHandler(e);this._atomicDo(()=>{this._fire(e,"revert",n),i.revert&&this._markDirty(i.revert(t)),this._revertedAction(n),this._fire(e,"reverted",n)})};ke.prototype._fire=function(n,e,t){arguments.length<3&&(t=e,e=null);let i=e?[n+"."+e,e]:[n],r;t=this._eventBus.createEvent(t);for(let o of i)if(r=this._eventBus.fire("commandStack."+o,t),t.cancelBubble)break;return r};ke.prototype._createId=function(){return this._uid++};ke.prototype._atomicDo=function(n){let e=this._currentExecution;e.atomic=!0;try{n()}finally{e.atomic=!1}};ke.prototype._internalExecute=function(n,e){let t=n.command,i=n.context,r=this._getHandler(t);if(!r)throw new Error("no command handler registered for <"+t+">");this._pushAction(n),e||(this._fire(t,"preExecute",n),r.preExecute&&r.preExecute(i),this._fire(t,"preExecuted",n)),this._atomicDo(()=>{this._fire(t,"execute",n),r.execute&&this._markDirty(r.execute(i)),this._executedAction(n,e),this._fire(t,"executed",n)}),e||(this._fire(t,"postExecute",n),r.postExecute&&r.postExecute(i),this._fire(t,"postExecuted",n)),this._popAction()};ke.prototype._pushAction=function(n){let e=this._currentExecution,t=e.actions,i=t[0];if(e.atomic)throw new Error("illegal invocation in <execute> or <revert> phase (action: "+n.command+")");n.id||(n.id=i&&i.id||this._createId()),t.push(n)};ke.prototype._popAction=function(){let n=this._currentExecution,e=n.trigger,t=n.actions,i=n.dirty;t.pop(),t.length||(this._eventBus.fire("elements.changed",{elements:Bw("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:e}),n.trigger=null)};ke.prototype._markDirty=function(n){let e=this._currentExecution;n&&(n=F(n)?n:[n],e.dirty=e.dirty.concat(n))};ke.prototype._executedAction=function(n,e){let t=++this._stackIdx;e||this._stack.splice(t,this._stack.length,n)};ke.prototype._revertedAction=function(n){this._stackIdx--};ke.prototype._getHandler=function(n){return this._handlerMap[n]};ke.prototype._setHandler=function(n,e){if(!n||!e)throw new Error("command and handler required");if(this._handlerMap[n])throw new Error("overriding handler for command <"+n+">");this._handlerMap[n]=e};var xs={commandStack:["type",ke]};function wm(n,e,t,i){n.on("element.changed",function(r){var o=r.element;(o.parent||o===e.getRootElement())&&(r.gfx=t.getGraphics(o)),r.gfx&&n.fire(ip(o)+".changed",r)}),n.on("elements.changed",function(r){var o=r.elements;o.forEach(function(s){n.fire("element.changed",{element:s})}),i.updateContainments(o)}),n.on("shape.changed",function(r){i.update("shape",r.element,r.gfx)}),n.on("connection.changed",function(r){i.update("connection",r.element,r.gfx)})}wm.$inject=["eventBus","canvas","elementRegistry","graphicsFactory"];var Cm={__init__:["changeSupport"],changeSupport:["type",wm]};var RO=Math.min,TO=Math.max;function Mx(n){n.preventDefault()}function Af(n){n.stopPropagation()}function pF(n){return n.nodeType===Node.TEXT_NODE}function mF(n){return[].slice.call(n)}function On(n){this.container=n.container,this.parent=te('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=X("[contenteditable]",this.parent),this.keyHandler=n.keyHandler||function(){},this.resizeHandler=n.resizeHandler||function(){},this.autoResize=at(this.autoResize,this),this.handlePaste=at(this.handlePaste,this)}On.prototype.create=function(n,e,t,i){var r=this,o=this.parent,s=this.content,a=this.container;i=this.options=i||{},e=this.style=e||{};var l=hn(e,["width","height","maxWidth","maxHeight","minWidth","minHeight","left","top","backgroundColor","position","overflow","border","wordWrap","textAlign","outline","transform"]);T(o.style,{width:n.width+"px",height:n.height+"px",maxWidth:n.maxWidth+"px",maxHeight:n.maxHeight+"px",minWidth:n.minWidth+"px",minHeight:n.minHeight+"px",left:n.x+"px",top:n.y+"px",backgroundColor:"#ffffff",position:"absolute",overflow:"visible",border:"1px solid #ccc",boxSizing:"border-box",wordWrap:"normal",textAlign:"center",outline:"none"},l);var c=hn(e,["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"]);return T(s.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},c),i.centerVertically&&T(s.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},c),s.innerText=t,q.bind(s,"keydown",this.keyHandler),q.bind(s,"mousedown",Af),q.bind(s,"paste",r.handlePaste),i.autoResize&&q.bind(s,"input",this.autoResize),i.resizable&&this.resizable(e),a.appendChild(o),this.setSelection(s.lastChild,s.lastChild&&s.lastChild.length),o};On.prototype.handlePaste=function(n){var e=this.options,t=this.style;n.preventDefault();var i;if(n.clipboardData?i=n.clipboardData.getData("text/plain"):i=window.clipboardData.getData("Text"),this.insertText(i),e.autoResize){var r=this.autoResize(t);r&&this.resizeHandler(r)}};On.prototype.insertText=function(n){n=gF(n);var e=document.execCommand("insertText",!1,n);e||this._insertTextIE(n)};On.prototype._insertTextIE=function(n){var e=this.getSelection(),t=e.startContainer,i=e.endContainer,r=e.startOffset,o=e.endOffset,s=e.commonAncestorContainer,a=mF(s.childNodes),l,c;if(pF(s)){var u=t.textContent;t.textContent=u.substring(0,r)+n+u.substring(o),l=t,c=r+n.length}else if(t===this.content&&i===this.content){var f=document.createTextNode(n);this.content.insertBefore(f,a[r]),l=f,c=f.textContent.length}else{var h=a.indexOf(t),d=a.indexOf(i);a.forEach(function(p,m){m===h?p.textContent=t.textContent.substring(0,r)+n+i.textContent.substring(o):m>h&&m<=d&&Qe(p)}),l=t,c=r+n.length}l&&c!==void 0&&setTimeout(function(){self.setSelection(l,c)})};On.prototype.autoResize=function(){var n=this.parent,e=this.content,t=parseInt(this.style.fontSize)||12;if(e.scrollHeight>n.offsetHeight||e.scrollHeight<n.offsetHeight-t){var i=n.getBoundingClientRect(),r=e.scrollHeight;n.style.height=r+"px",this.resizeHandler({width:i.width,height:i.height,dx:0,dy:r-i.height})}};On.prototype.resizable=function(){var n=this,e=this.parent,t=this.resizeHandle,i=parseInt(this.style.minWidth)||0,r=parseInt(this.style.minHeight)||0,o=parseInt(this.style.maxWidth)||1/0,s=parseInt(this.style.maxHeight)||1/0;if(!t){t=this.resizeHandle=te('<div class="djs-direct-editing-resize-handle"></div>');var a,l,c,u,f=function(p){Mx(p),Af(p),a=p.clientX,l=p.clientY;var m=e.getBoundingClientRect();c=m.width,u=m.height,q.bind(document,"mousemove",h),q.bind(document,"mouseup",d)},h=function(p){Mx(p),Af(p);var m=RO(TO(c+p.clientX-a,i),o),g=RO(TO(u+p.clientY-l,r),s);e.style.width=m+"px",e.style.height=g+"px",n.resizeHandler({width:c,height:u,dx:p.clientX-a,dy:p.clientY-l})},d=function(p){Mx(p),Af(p),q.unbind(document,"mousemove",h,!1),q.unbind(document,"mouseup",d,!1)};q.bind(t,"mousedown",f)}T(t.style,{position:"absolute",bottom:"0px",right:"0px",cursor:"nwse-resize",width:"0",height:"0",borderTop:(parseInt(this.style.fontSize)/4||3)+"px solid transparent",borderRight:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderBottom:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderLeft:(parseInt(this.style.fontSize)/4||3)+"px solid transparent"}),e.appendChild(t)};On.prototype.destroy=function(){var n=this.parent,e=this.content,t=this.resizeHandle;e.innerText="",n.removeAttribute("style"),e.removeAttribute("style"),q.unbind(e,"keydown",this.keyHandler),q.unbind(e,"mousedown",Af),q.unbind(e,"input",this.autoResize),q.unbind(e,"paste",this.handlePaste),t&&(t.removeAttribute("style"),Qe(t)),Qe(n)};On.prototype.getValue=function(){return this.content.innerText.trim()};On.prototype.getSelection=function(){var n=window.getSelection(),e=n.getRangeAt(0);return e};On.prototype.setSelection=function(n,e){var t=document.createRange();n===null?t.selectNodeContents(this.content):(t.setStart(n,e),t.setEnd(n,e));var i=window.getSelection();i.removeAllRanges(),i.addRange(t)};function gF(n){return n.replace(/\r\n|\r|\n/g,` 249`)}function xn(n,e){this._eventBus=n,this._canvas=e,this._providers=[],this._textbox=new On({container:e.getContainer(),keyHandler:at(this._handleKey,this),resizeHandler:at(this._handleResize,this)})}xn.$inject=["eventBus","canvas"];xn.prototype.registerProvider=function(n){this._providers.push(n)};xn.prototype.isActive=function(n){return!!(this._active&&(!n||this._active.element===n))};xn.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())};xn.prototype._fire=function(n,e){this._eventBus.fire("directEditing."+n,e||{active:this._active})};xn.prototype.close=function(){this._textbox.destroy(),this._fire("deactivate"),this._active=null,this.resizable=void 0,this._canvas.restoreFocus&&this._canvas.restoreFocus()};xn.prototype.complete=function(){var n=this._active;if(n){var e,t=n.context.bounds,i=this.$textbox.getBoundingClientRect(),r=this.getValue(),o=n.context.text;(r!==o||i.height!==t.height||i.width!==t.width)&&(e=this._textbox.container.getBoundingClientRect(),n.provider.update(n.element,r,n.context.text,{x:i.left-e.left,y:i.top-e.top,width:i.width,height:i.height})),this._fire("complete"),this.close()}};xn.prototype.getValue=function(){return this._textbox.getValue()};xn.prototype._handleKey=function(n){n.stopPropagation();var e=n.keyCode||n.charCode;if(e===27)return n.preventDefault(),this.cancel();if(e===13&&!n.shiftKey)return n.preventDefault(),this.complete()};xn.prototype._handleResize=function(n){this._fire("resize",n)};xn.prototype.activate=function(n){if(this.isActive()&&this.cancel(),this._eventBus.fire("directEditing.activate.allowed",{element:n})===!1)return!1;var e,t=ye(this._providers,function(i){return(e=i.activate(n))?i:null});return e&&(this.$textbox=this._textbox.create(e.bounds,e.style,e.text,e.options),this._active={element:n,context:e,provider:t},e.options&&e.options.resizable&&(this.resizable=!0),this._fire("activate")),!!e};var AO={__depends__:[fo],__init__:["directEditing"],directEditing:["type",xn]};var MO="djs-label-hidden";function bs(n,e,t,i,r){this._canvas=n,this._modeling=i,this._textRenderer=r,this._eventBus=t,e.registerProvider(this),t.on("element.dblclick",function(o){e.activate(o.element)}),t.on(["autoPlace.start","canvas.viewbox.changing","drag.init","drillDown.click","element.mousedown","popupMenu.open","selection.changed"],function(){e.complete()}),t.on(["commandStack.changed"],function(){e.cancel()}),t.on("create.end",500,function(o){var s=o.shape;(O(s,"dmn:Decision")||O(s,"dmn:InputData")||O(s,"dmn:BusinessKnowledgeModel")||O(s,"dmn:KnowledgeSource")||O(s,"dmn:TextAnnotation"))&&e.activate(s)}),t.on("autoPlace.end",500,function(o){e.activate(o.shape)}),this._eventBus.on(["directEditing.complete","directEditing.cancel"],function(o){var s=o.active;if(s){var a=s.element.label||s.element;n.removeMarker(a,MO)}})}bs.$inject=["canvas","directEditing","eventBus","modeling","textRenderer"];bs.prototype.activate=function(n){var e=fs(n);if(Me(e)){var t={text:e},i=this.getEditingBBox(n);T(t,i);var r={},o=t.style||{};return O(n,"dmn:DRGElement")&&(T(r,{centerVertically:!0}),T(o,{backgroundColor:null,border:null})),O(n,"dmn:TextAnnotation")&&T(r,{resizable:!0}),T(t,{options:r,style:o}),this._canvas.addMarker(n,MO),t}};bs.prototype.getEditingBBox=function(n){var e=this._canvas,t=n.label||n,i=e.getAbsoluteBBox(t),r={x:i.x,y:i.y},o=e.zoom(),s=this._textRenderer.getDefaultStyle(),a=s.fontSize*o,l=s.lineHeight,c={fontFamily:this._textRenderer.getDefaultStyle().fontFamily,fontWeight:this._textRenderer.getDefaultStyle().fontWeight};return O(n,"dmn:DRGElement")&&(T(r,{width:i.width,height:i.height}),T(c,{fontSize:a+"px",lineHeight:l,paddingTop:7*o+"px",paddingBottom:7*o+"px",paddingLeft:5*o+"px",paddingRight:5*o+"px"})),O(n,"dmn:TextAnnotation")&&(T(r,{width:i.width,height:i.height,minWidth:30*o,minHeight:10*o}),T(c,{textAlign:"left",paddingTop:5*o+"px",paddingBottom:7*o+"px",paddingLeft:7*o+"px",paddingRight:5*o+"px",fontSize:a+"px",lineHeight:l})),{bounds:r,style:c}};bs.prototype.update=function(n,e,t,i){var r,o;O(n,"dmn:TextAnnotation")&&(o=this._canvas.getAbsoluteBBox(n),r={x:n.x,y:n.y,width:n.width/o.width*i.width,height:n.height/o.height*i.height}),yF(e)&&(e=null),this._modeling.updateLabel(n,e,r)};function yF(n){return!n||!n.trim()}var PO={__depends__:[xs,Cm,AO],__init__:["labelEditingProvider"],labelEditingProvider:["type",bs]};function Mf(n,e){e.invoke(ae,this),this.preExecute("connection.create",function(t){var i=t.connection,r=i.businessObject,o=t.source,s=t.target,a,l,c;O(i,"dmn:Association")?(l=r.sourceRef=n.create("dmn:DMNElementReference",{href:"#"+o.id}),l.$parent=r,c=r.targetRef=n.create("dmn:DMNElementReference",{href:"#"+s.id}),c.$parent=r):(a=r["required"+vF(o)]=n.create("dmn:DMNElementReference",{href:"#"+o.id}),a.$parent=r)},!0)}Mf.$inject=["drdFactory","injector"];fe(Mf,ae);function vF(n){if(O(n,"dmn:BusinessKnowledgeModel"))return"Knowledge";if(O(n,"dmn:Decision"))return"Decision";if(O(n,"dmn:InputData"))return"Input";if(O(n,"dmn:KnowledgeSource"))return"Authority"}var xF=500;function Pf(n,e,t,i){n.invoke(ae,this),this.preExecute(["connection.create","connection.reconnect"],function(o){var s=o.connection,a=o.newSource||o.source,l=o.newTarget||o.target;if(!(O(s,"dmn:InformationRequirement")&&!i.allowed("connection.connect",{connection:s,source:a,target:l}))&&O(s,"dmn:InformationRequirement")){var c=vt(a,l);o.hints||(o.hints={}),T(o.hints,bF(a,l,c))}},!0);function r(o,s,a){s||(s=o.incoming.filter(function(c){return O(c,"dmn:InformationRequirement")}));var l={};a?l[a]=s:l=wF(o,s),k(l,function(c,u){c=CF(c,u);var f=_F(c,o,u);c.forEach((h,d)=>{var p=f[d].start,m=f[d].end,g=e.layoutConnection(h,{connectionStart:p,connectionEnd:m});t.updateWaypoints(h,g)})})}this.postExecuted(["connection.create","connection.delete","connection.reconnect"],function(o){var s=o.connection,a=s.source||o.source,l=s.target||o.target;if(O(s,"dmn:InformationRequirement")){var c=vt(a,l),u=l.incoming.filter(f=>{var h=vt(f.source,f.target);return O(f,"dmn:InformationRequirement")&&DO(h,c)});u.length&&r(l,u,c)}},!0),this.preExecute("connection.reconnect",function(o){var s=o.connection,a=s.source,l=s.target;if(O(s,"dmn:InformationRequirement")){var c=vt(a,l),u=l.incoming.filter(f=>{var h=vt(f.source,f.target);return f!==s&&O(f,"dmn:InformationRequirement")&&DO(h,c)});u.length&&r(l,u,c)}},!0),this.postExecuted("elements.move",xF,function(o){var s=o.shapes,a=o.closure,l=a.enclosedConnections;s.forEach(function(c){if(Ge(c,["dmn:Decision","dmn:InputData"])){var u=c.incoming.filter(function(f){return O(f,"dmn:InformationRequirement")&&!l[f.id]});u.length&&r(c,u),c.outgoing.forEach(function(f){!O(f,"dmn:InformationRequirement")||l[f.id]||r(f.target)})}})},!0)}Pf.$inject=["injector","layouter","modeling","rules"];fe(Pf,ae);function bF(n,e,t){var i=le(n),r=le(e);return t.includes("bottom")?(i.y=n.y,r.y=e.y+e.height):t.includes("top")?(i.y=n.y+n.height,r.y=e.y):t.includes("right")?(i.x=n.x,r.x=e.x+e.width):(i.x=n.x+n.width,r.x=e.x),{connectionStart:i,connectionEnd:r}}function _F(n,e,t){return n.map(function(i,r){var o=i.source,s=le(o),a=G(o),l=G(e),c=n.length;return t.includes("bottom")?{start:{x:s.x,y:a.top},end:{x:l.left+e.width/(c+1)*(r+1),y:l.bottom}}:t.includes("top")?{start:{x:s.x,y:a.bottom},end:{x:l.left+e.width/(c+1)*(r+1),y:l.top}}:t.includes("right")?{start:{x:a.left,y:s.y},end:{x:l.right,y:l.top+e.height/(c+1)*(r+1)}}:{start:{x:a.right,y:s.y},end:{x:l.left,y:l.top+e.height/(c+1)*(r+1)}}})}function wF(n,e){var t={};return e.forEach(function(i){var r=vt(i.source,n).split("-").shift();t[r]||(t[r]=[]),t[r].push(i)}),t}function DO(n,e){return n&&e&&n.split("-").shift()===e.split("-").shift()}function CF(n,e){var t;return e.includes("top")||e.includes("bottom")?t="x":t="y",n.sort(function(i,r){return le(i.source)[t]-le(r.source)[t]})}function Df(n,e,t){n.invoke(ae,this),this.preExecute("connection.reconnect",function(i){var r=i.connection,o=i.newSource||r.source,s=i.newTarget||r.target,a=r.waypoints.slice(),l=t.allowed("connection.reconnect",{connection:r,source:o,target:s});!l||l.type===r.type||(i.connection=e.connect(o,s,{type:l.type,waypoints:a}),e.removeConnection(r))},!0)}fe(Df,ae);Df.$inject=["injector","modeling","rules"];function If(n,e,t){ae.call(this,n),this._modeling=e,this.postExecuted(["shape.replace"],1500,function(i){var r=i.context,o=r.oldShape,s=r.newShape;e.unclaimId(o.businessObject.id,o.businessObject),e.updateProperties(s,{id:o.id}),t.select(s)})}fe(If,ae);If.$inject=["eventBus","modeling","selection"];var IO="id",Gn=class extends ae{constructor(e){super(e),this.executed("element.updateProperties",this.updateIds.bind(this))}updateIds({context:e}){let{element:t,oldProperties:i,properties:r}=e,o=Ke(t);if(this.shouldSkipUpdate(o,i,r))return;let s=SF(o);s.get("drgElement").forEach(c=>{OF(c,i.id,r.id)}),s.get("artifact").forEach(c=>{kF(c,i.id,r.id)})}shouldSkipUpdate(e,t,i){return!EF(t,i)||!O(e,"dmn:DRGElement")&&!O(e,"dmn:TextAnnotation")}};Gn.$inject=["eventBus"];function EF(n,e){return IO in n&&IO in e}function SF(n){let e=n;for(;!O(e,"dmn:Definitions");)e=e.$parent;return e}function OF(n,e,t){k({authorityRequirement:()=>{n.authorityRequirement.forEach(r=>{let{requiredAuthority:o,requiredDecision:s,requiredInput:a}=r;o&&o.href===`#${e}`&&(o.href=`#${t}`),s&&s.href===`#${e}`&&(s.href=`#${t}`),a&&a.href===`#${e}`&&(a.href=`#${t}`)})},informationRequirement:()=>{n.informationRequirement.forEach(r=>{let{requiredDecision:o,requiredInput:s}=r;o&&o.href===`#${e}`&&(o.href=`#${t}`),s&&s.href===`#${e}`&&(s.href=`#${t}`)})},knowledgeRequirement:()=>{n.knowledgeRequirement.forEach(r=>{let{requiredKnowledge:o}=r;o&&o.href===`#${e}`&&(o.href=`#${t}`)})}},(r,o)=>{n[o]&&r()})}function kF(n,e,t){k({sourceRef:()=>{let{sourceRef:r}=n;r.href===`#${e}`&&(r.href=`#${t}`)},targetRef:()=>{let{targetRef:r}=n;r.href===`#${e}`&&(r.href=`#${t}`)}},(r,o)=>{n[o]&&r()})}var qi=class extends ae{constructor(t,i){super(t);M(this,"updateVariableFromLabel",({context:t})=>{let{element:i,newLabel:r}=t,o=Ke(i),s=o.variable;s&&this._modeling.updateProperties(s,{name:r})});M(this,"updateVariableFromElement",({context:t})=>{let{element:i,properties:r}=t,o=Ke(i);o.variable&&(O(i,"dmn:Decision")||O(i,"dmn:BusinessKnowledgeModel"))&&this.isNameChanged(r)&&(this.isVariable(i)||this.shouldSyncVariable(i)||this.syncElementVariableChange(o))});this._modeling=i,this.postExecuted("element.updateProperties",this.updateVariableFromElement),this.postExecuted("element.updateLabel",this.updateVariableFromLabel)}isNameChanged(t){return"name"in t}isVariable(t){let i=RF(t);return O(t,"dmn:InformationItem")&&i&&i.get("variable")===t}shouldSyncVariable(t){let i=Ke(t),r=i.get("variable");return r&&i.name===r.name}syncElementVariableChange(t){let i=t.get("name"),r=t.variable;this._modeling.updateProperties(r,{name:i})}};M(qi,"$inject",["eventBus","modeling"]);function RF(n){return n.$parent}var LO={__init__:["createConnectionBehavior","idChangeBehavior","nameChangeBehavior","layoutConnectionBehavior","replaceConnectionBehavior","replaceElementBehavior"],createConnectionBehavior:["type",Mf],idChangeBehavior:["type",Gn],nameChangeBehavior:["type",qi],layoutConnectionBehavior:["type",Pf],replaceConnectionBehavior:["type",Df],replaceElementBehavior:["type",If]};function Vi(n){ae.call(this,n),this.init()}Vi.$inject=["eventBus"];fe(Vi,ae);Vi.prototype.addRule=function(n,e,t){var i=this;typeof n=="string"&&(n=[n]),n.forEach(function(r){i.canExecute(r,e,function(o,s,a){return t(o)},!0)})};Vi.prototype.init=function(){};function Rr(n){n.invoke(Vi,this)}fe(Rr,Vi);Rr.$inject=["injector"];Rr.prototype.init=function(){this.addRule("connection.create",function(n){var e=n.source,t=n.target;return Px(e,t)}),this.addRule("connection.reconnect",function(n){var e=n.connection,t=n.source,i=n.target;return Px(t,i,e)}),this.addRule("connection.updateWaypoints",function(n){let e=n.connection;return{type:e.type,businessObject:e.businessObject}}),this.addRule("elements.move",function(n){var e=n.target,t=n.shapes,i=n.position;return $O(t,e,i)}),this.addRule("shape.create",function(n){var e=n.shape,t=n.target;return NO(e,t)}),this.addRule("shape.resize",function(n){var e=n.shape;return O(e,"dmn:TextAnnotation")})};Rr.prototype.canConnect=Px;Rr.prototype.canCreate=NO;Rr.prototype.canMove=$O;function Px(n,e){if(!n||BO(n)||!e||BO(e))return null;if(n===e)return!1;if(O(n,"dmn:BusinessKnowledgeModel")&&Ge(e,["dmn:BusinessKnowledgeModel","dmn:Decision"]))return{type:"dmn:KnowledgeRequirement"};if(O(n,"dmn:Decision")){if(O(e,"dmn:Decision"))return{type:"dmn:InformationRequirement"};if(O(e,"dmn:KnowledgeSource"))return{type:"dmn:AuthorityRequirement"}}if(O(n,"dmn:Definitions")||O(e,"dmn:Definitions"))return!1;if(O(n,"dmn:InputData")){if(O(e,"dmn:Decision"))return{type:"dmn:InformationRequirement"};if(O(e,"dmn:KnowledgeSource"))return{type:"dmn:AuthorityRequirement"}}return O(n,"dmn:KnowledgeSource")&&Ge(e,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:KnowledgeSource"])?{type:"dmn:AuthorityRequirement"}:O(n,"dmn:TextAnnotation")&&!O(e,"dmn:TextAnnotation")||!O(n,"dmn:TextAnnotation")&&O(e,"dmn:TextAnnotation")?{type:"dmn:Association"}:!1}function NO(n,e){return Ge(n,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:InputData","dmn:KnowledgeSource","dmn:TextAnnotation"])&&O(e,"dmn:Definitions")}function $O(n,e){return F(n)||(n=[n]),!!(!e||kt(n,function(t){return Ge(t,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:InputData","dmn:KnowledgeSource","dmn:TextAnnotation","dmn:InformationRequirement","dmn:AuthorityRequirement","dmn:KnowledgeRequirement","dmn:Association"])})&&O(e,"dmn:Definitions"))}function BO(n){return!!n.labelTarget}var jO={__depends__:[yn],__init__:["drdRules"],drdRules:["type",Rr]};function kn(n){this._model=n}kn.$inject=["moddle"];kn.prototype._needsId=function(n){return Ge(n,["dmn:Artifact","dmn:DMNElement","dmn:DRGElement","dmndi:DMNDiagram","dmndi:DMNDiagramElement"])};kn.prototype._ensureId=function(n){var e=(n.$type||"").replace(/^[^:]*:/g,"")+"_";!n.id&&this._needsId(n)&&(n.id=this._model.ids.nextPrefixed(e,n))};kn.prototype.create=function(n,e){var t=this._model.create(n,e||{});return this._ensureId(t),t};kn.prototype.createDiShape=function(n,e,t){return this.create("dmndi:DMNShape",T({dmnElementRef:n,bounds:this.createDiBounds(e)},t))};kn.prototype.createDiBounds=function(n){return this.create("dc:Bounds",n)};kn.prototype.createDiEdge=function(n,e,t){return this.create("dmndi:DMNEdge",{dmnElementRef:n,waypoint:this.createDiWaypoints(e)},t)};kn.prototype.createDiWaypoints=function(n){var e=this;return n.map(function(t){return e.createDiWaypoint(t)})};kn.prototype.createDiWaypoint=function(n){return this.create("dc:Point",hn(n,["x","y"]))};kn.prototype.createExtensionElements=function(){return this.create("dmn:ExtensionElements",{values:[]})};function Hi(n,e,t,i,r){r.invoke(ae,this),this._definitionPropertiesView=e,this._drdFactory=t,this._drdRules=i;var o=this;function s(f){var h=f.connection,d=f.cropped;d||(h.waypoints=n.getCroppedWaypoints(h),f.cropped=!0)}this.executed(["connection.create","connection.layout"],s,!0),this.reverted(["connection.layout"],function(f){delete f.cropped},!0);function a(f){var h=f.connection,d=f.parent,p=f.shape;h&&!O(h,"dmn:Association")&&(d=h.target),o.updateParent(p||h,d)}function l(f){var h=f.connection,d=f.shape,p=f.parent||f.newParent;h&&!O(h,"dmn:Association")&&(p=h.target),o.updateParent(d||h,p)}this.executed(["connection.create","connection.delete","connection.move","shape.create","shape.delete"],a,!0),this.reverted(["connection.create","connection.delete","connection.move","shape.create","shape.delete"],l,!0);function c(f){var h=f.shape;(O(h,"dmn:DRGElement")||O(h,"dmn:TextAnnotation"))&&o.updateBounds(h)}this.executed(["shape.create","shape.move","shape.resize"],c,!0),this.reverted(["shape.create","shape.move","shape.resize"],c,!0);function u(f){o.updateConnectionWaypoints(f)}this.executed(["connection.create","connection.layout","connection.move","connection.updateWaypoints"],u,!0),this.reverted(["connection.create","connection.layout","connection.move","connection.updateWaypoints"],u,!0),this.executed("connection.create",function(f){var h=f.connection,d=h.businessObject,p=f.target,m=p.businessObject;O(h,"dmn:Association")?a(f):o.updateSemanticParent(d,m)},!0),this.reverted("connection.create",function(f){l(f)},!0),this.executed("connection.reconnect",function(f){var h=f.connection,d=h.businessObject,p=f.newTarget,m=p.businessObject;O(d,"dmn:Association")||o.updateSemanticParent(d,m)},!0),this.reverted("connection.reconnect",function(f){var h=f.connection,d=h.businessObject,p=f.oldTarget,m=p.businessObject;O(d,"dmn:Association")||o.updateSemanticParent(d,m)},!0),this.executed("element.updateProperties",function(f){e.update()},!0),this.reverted("element.updateProperties",function(f){e.update()},!0)}fe(Hi,ae);Hi.$inject=["connectionDocking","definitionPropertiesView","drdFactory","drdRules","injector"];Hi.prototype.updateBounds=function(n){var e=n.businessObject,t=e.di.bounds;T(t,{x:n.x,y:n.y,width:n.width,height:n.height})};Hi.prototype.updateConnectionWaypoints=function(n){var e=this._drdFactory,t=n.connection,i=t.businessObject,r=i.di;r.waypoint=e.createDiWaypoints(t.waypoints).map(function(o){return o.$parent=r,o})};Hi.prototype.updateParent=function(n,e){var t=n.parent;!O(n,"dmn:DRGElement")&&!O(n,"dmn:Artifact")&&(t=e);var i=n.businessObject,r=t&&t.businessObject;this.updateSemanticParent(i,r),this.updateDiParent(i.di,r&&r.di)};Hi.prototype.updateSemanticParent=function(n,e){var t,i;n.$parent!==e&&(O(n,"dmn:DRGElement")?i="drgElement":O(n,"dmn:Artifact")?i="artifact":O(n,"dmn:InformationRequirement")?i="informationRequirement":O(n,"dmn:AuthorityRequirement")?i="authorityRequirement":O(n,"dmn:KnowledgeRequirement")&&(i="knowledgeRequirement"),n.$parent&&(t=n.$parent.get(i),Vn(t,n)),e?(t=e.get(i),t&&(t.push(n),n.$parent=e)):n.$parent=null)};Hi.prototype.updateDiParent=function(n,e){if(n.$parent!==e)if(Ge(n,["dmndi:DMNEdge","dmndi:DMNShape"])){for(var t=e||n;!O(t,"dmndi:DMNDiagram");)t=t.$parent;var i=t.get("diagramElements");e?(n.$parent=t,zt(i,n)):(n.$parent=null,Vn(i,n))}else throw new Error("unsupported")};function Na(n,e){this._modeling=n,this._canvas=e}Na.$inject=["modeling","canvas"];Na.prototype.preExecute=function(n){var e=this._modeling,t=n.elements,i=n.alignment;k(t,function(r){var o={x:0,y:0};Me(i.left)?o.x=i.left-r.x:Me(i.right)?o.x=i.right-r.width-r.x:Me(i.center)?o.x=i.center-Math.round(r.width/2)-r.x:Me(i.top)?o.y=i.top-r.y:Me(i.bottom)?o.y=i.bottom-r.height-r.y:Me(i.middle)&&(o.y=i.middle-Math.round(r.height/2)-r.y),e.moveElements([r],o,r.parent)})};Na.prototype.postExecute=function(n){};function $a(n){this._modeling=n}$a.$inject=["modeling"];$a.prototype.preExecute=function(n){var e=n.source;if(!e)throw new Error("source required");var t=n.target||e.parent,i=n.shape,r=n.hints||{};i=n.shape=this._modeling.createShape(i,n.position,t,{attach:r.attach}),n.shape=i};$a.prototype.postExecute=function(n){var e=n.hints||{};TF(n.source,n.shape)||(e.connectionTarget===n.source?this._modeling.connect(n.shape,n.source,n.connection):this._modeling.connect(n.source,n.shape,n.connection))};function TF(n,e){return zd(n.outgoing,function(t){return t.target===e})}function ja(n,e){this._canvas=n,this._layouter=e}ja.$inject=["canvas","layouter"];ja.prototype.execute=function(n){var e=n.connection,t=n.source,i=n.target,r=n.parent,o=n.parentIndex,s=n.hints;if(!t||!i)throw new Error("source and target required");if(!r)throw new Error("parent required");return e.source=t,e.target=i,e.waypoints||(e.waypoints=this._layouter.layoutConnection(e,s)),this._canvas.addConnection(e,r,o),e};ja.prototype.revert=function(n){var e=n.connection;return this._canvas.removeConnection(e),e.source=null,e.target=null,e};var Em=Math.round;function Lf(n){this._modeling=n}Lf.$inject=["modeling"];Lf.prototype.preExecute=function(n){var e=n.elements,t=n.parent,i=n.parentIndex,r=n.position,o=n.hints,s=this._modeling;k(e,function(f){se(f.x)||(f.x=0),se(f.y)||(f.y=0)});var a=Ee(e,function(f){return!f.hidden}),l=Tt(a);k(e,function(f){Xe(f)&&(f.waypoints=Vt(f.waypoints,function(h){return{x:Em(h.x-l.x-l.width/2+r.x),y:Em(h.y-l.y-l.height/2+r.y)}})),T(f,{x:Em(f.x-l.x-l.width/2+r.x),y:Em(f.y-l.y-l.height/2+r.y)})});var c=E1(e),u={};k(e,function(f){if(Xe(f)){u[f.id]=se(i)?s.createConnection(u[f.source.id],u[f.target.id],i,f,f.parent||t,o):s.createConnection(u[f.source.id],u[f.target.id],f,f.parent||t,o);return}var h=T({},o);c.indexOf(f)===-1&&(h.autoResize=!1),Bi(f)&&(h=Uu(h,["attach"])),u[f.id]=se(i)?s.createShape(f,hn(f,["x","y","width","height"]),f.parent||t,i,h):s.createShape(f,hn(f,["x","y","width","height"]),f.parent||t,h)}),n.elements=Wu(u)};var FO=Math.round;function gi(n){this._canvas=n}gi.$inject=["canvas"];gi.prototype.execute=function(n){var e=n.shape,t=n.position,i=n.parent,r=n.parentIndex;if(!i)throw new Error("parent required");if(!t)throw new Error("position required");return t.width!==void 0?T(e,t):T(e,{x:t.x-FO(e.width/2),y:t.y-FO(e.height/2)}),this._canvas.addShape(e,i,r),e};gi.prototype.revert=function(n){var e=n.shape;return this._canvas.removeShape(e),e};function _s(n){gi.call(this,n)}fe(_s,gi);_s.$inject=["canvas"];var AF=gi.prototype.execute;_s.prototype.execute=function(n){var e=n.shape;return PF(e),e.labelTarget=n.labelTarget,AF.call(this,n)};var MF=gi.prototype.revert;_s.prototype.revert=function(n){return n.shape.labelTarget=null,MF.call(this,n)};function PF(n){["width","height"].forEach(function(e){typeof n[e]=="undefined"&&(n[e]=0)})}function ws(n,e){if(typeof e!="function")throw new Error("removeFn iterator must be a function");if(!n)return[];for(var t;t=n[0];)e(t);return n}function Cs(n,e){this._canvas=n,this._modeling=e}Cs.$inject=["canvas","modeling"];Cs.prototype.preExecute=function(n){var e=this._modeling,t=n.connection;ws(t.incoming,function(i){e.removeConnection(i,{nested:!0})}),ws(t.outgoing,function(i){e.removeConnection(i,{nested:!0})})};Cs.prototype.execute=function(n){var e=n.connection,t=e.parent;return n.parent=t,n.parentIndex=op(t.children,e),n.source=e.source,n.target=e.target,this._canvas.removeConnection(e),e.source=null,e.target=null,e};Cs.prototype.revert=function(n){var e=n.connection,t=n.parent,i=n.parentIndex;return e.source=n.source,e.target=n.target,zt(t.children,e,i),this._canvas.addConnection(e,t),e};function Bf(n,e){this._modeling=n,this._elementRegistry=e}Bf.$inject=["modeling","elementRegistry"];Bf.prototype.postExecute=function(n){var e=this._modeling,t=this._elementRegistry,i=n.elements;k(i,function(r){t.get(r.id)&&(r.waypoints?e.removeConnection(r):e.removeShape(r))})};function Es(n,e){this._canvas=n,this._modeling=e}Es.$inject=["canvas","modeling"];Es.prototype.preExecute=function(n){var e=this._modeling,t=n.shape;ws(t.incoming,function(i){e.removeConnection(i,{nested:!0})}),ws(t.outgoing,function(i){e.removeConnection(i,{nested:!0})}),ws(t.children,function(i){Xe(i)?e.removeConnection(i,{nested:!0}):e.removeShape(i,{nested:!0})})};Es.prototype.execute=function(n){var e=this._canvas,t=n.shape,i=t.parent;return n.oldParent=i,n.oldParentIndex=op(i.children,t),e.removeShape(t),t};Es.prototype.revert=function(n){var e=this._canvas,t=n.shape,i=n.oldParent,r=n.oldParentIndex;return zt(i.children,t,r),e.addShape(t,i),t};function Fa(n){this._modeling=n}Fa.$inject=["modeling"];var qO={x:"y",y:"x"};Fa.prototype.preExecute=function(n){var e=this._modeling,t=n.groups,i=n.axis,r=n.dimension;function o(g,b){g.range.min=Math.min(b[i],g.range.min),g.range.max=Math.max(b[i]+b[r],g.range.max)}function s(g){return g[i]+g[r]/2}function a(g){return g.length-1}function l(g){return g.max-g.min}function c(g,b){var _={y:0};_[i]=g-s(b),_[i]&&(_[qO[i]]=0,e.moveElements([b],_,b.parent))}var u=t[0],f=a(t),h=t[f],d,p,m=0;k(t,function(g,b){var _,v,x;if(g.elements.length<2){b&&b!==t.length-1&&(o(g,g.elements[0]),m+=l(g.range));return}_=Fn(g.elements,i),v=_[0],b===f&&(v=_[a(_)]),x=s(v),g.range=null,k(_,function(C){if(c(x,C),g.range===null){g.range={min:C[i],max:C[i]+C[r]};return}o(g,C)}),b&&b!==t.length-1&&(m+=l(g.range))}),p=Math.abs(h.range.min-u.range.max),d=Math.round((p-m)/(t.length-1)),!(d<t.length-1)&&k(t,function(g,b){var _={},v;g===u||g===h||(v=t[b-1],g.range.max=0,k(g.elements,function(x,C){_[qO[i]]=0,_[i]=v.range.max-x[i]+d,g.range.min!==x[i]&&(_[i]+=x[i]-g.range.min),_[i]&&e.moveElements([x],_,x.parent),g.range.max=Math.max(x[i]+x[r],C?g.range.max:0)}))})};Fa.prototype.postExecute=function(n){};function qa(n,e){this._layouter=n,this._canvas=e}qa.$inject=["layouter","canvas"];qa.prototype.execute=function(n){var e=n.connection,t=e.waypoints;return T(n,{oldWaypoints:t}),e.waypoints=this._layouter.layoutConnection(e,n.hints),e};qa.prototype.revert=function(n){var e=n.connection;return e.waypoints=n.oldWaypoints,e};function Nf(){}Nf.prototype.execute=function(n){var e=n.connection,t=n.delta,i=n.newParent||e.parent,r=n.newParentIndex,o=e.parent;return n.oldParent=o,n.oldParentIndex=Vn(o.children,e),zt(i.children,e,r),e.parent=i,k(e.waypoints,function(s){s.x+=t.x,s.y+=t.y,s.original&&(s.original.x+=t.x,s.original.y+=t.y)}),e};Nf.prototype.revert=function(n){var e=n.connection,t=e.parent,i=n.oldParent,r=n.oldParentIndex,o=n.delta;return Vn(t.children,e),zt(i.children,e,r),e.parent=i,k(e.waypoints,function(s){s.x-=o.x,s.y-=o.y,s.original&&(s.original.x-=o.x,s.original.y-=o.y)}),e};function $f(n,e,t){var i=Yv(e),r=Yv(t),o=xr(n,i),s={x:o.x*(t.width/e.width),y:o.y*(t.height/e.height)};return ma({x:r.x+s.x,y:r.y+s.y})}function Va(n,e,t){var i=Sm(n),r=HO(i,e),o=i[0];return r.length?r[r.length-1]:$f(o.original||o,t,e)}function Ha(n,e,t){var i=Sm(n),r=HO(i,e),o=i[i.length-1];return r.length?r[0]:$f(o.original||o,t,e)}function za(n,e,t){var i=Sm(n),r=VO(e,t),o=i[0];return $f(o.original||o,r,e)}function Wa(n,e,t){var i=Sm(n),r=VO(e,t),o=i[i.length-1];return $f(o.original||o,r,e)}function VO(n,e){return{x:n.x-e.x,y:n.y-e.y,width:n.width,height:n.height}}function Sm(n){var e=n.waypoints;if(!e.length)throw new Error("connection#"+n.id+": no waypoints");return e}function HO(n,e){var t=Vt(n,IF);return Ee(t,function(i){return DF(i,e)})}function DF(n,e){return vt(e,n,1)==="intersect"}function IF(n){return n.original||n}function jf(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}jf.prototype.add=function(n,e){return this.addAll([n],e)};jf.prototype.addAll=function(n,e){var t=k1(n,!!e,this);return T(this,t),this};function wo(n){this._modeling=n}wo.prototype.moveRecursive=function(n,e,t){return n?this.moveClosure(this.getClosure(n),e,t):[]};wo.prototype.moveClosure=function(n,e,t,i,r){var o=this._modeling,s=n.allShapes,a=n.allConnections,l=n.enclosedConnections,c=n.topLevel,u=!1;r&&r.parent===t&&(u=!0),k(s,function(f){o.moveShape(f,e,c[f.id]&&!u&&t,{recurse:!1,layout:!1})}),k(a,function(f){var h=!!s[f.source.id],d=!!s[f.target.id];l[f.id]&&h&&d?o.moveConnection(f,e,c[f.id]&&!u&&t):o.layoutConnection(f,{connectionStart:h&&za(f,f.source,e),connectionEnd:d&&Wa(f,f.target,e)})})};wo.prototype.getClosure=function(n){return new jf().addAll(n,!0)};function Ua(n){this._helper=new wo(n)}Ua.$inject=["modeling"];Ua.prototype.preExecute=function(n){n.closure=this._helper.getClosure(n.shapes)};Ua.prototype.postExecute=function(n){var e=n.hints,t;e&&e.primaryShape&&(t=e.primaryShape,e.oldParent=t.parent),this._helper.moveClosure(n.closure,n.delta,n.newParent,n.newHost,t)};function Tr(n){this._modeling=n,this._helper=new wo(n)}Tr.$inject=["modeling"];Tr.prototype.execute=function(n){var e=n.shape,t=n.delta,i=n.newParent||e.parent,r=n.newParentIndex,o=e.parent;return n.oldBounds=hn(e,["x","y","width","height"]),n.oldParent=o,n.oldParentIndex=Vn(o.children,e),zt(i.children,e,r),T(e,{parent:i,x:e.x+t.x,y:e.y+t.y}),e};Tr.prototype.postExecute=function(n){var e=n.shape,t=n.delta,i=n.hints,r=this._modeling;i.layout!==!1&&(k(e.incoming,function(o){r.layoutConnection(o,{connectionEnd:Wa(o,e,t)})}),k(e.outgoing,function(o){r.layoutConnection(o,{connectionStart:za(o,e,t)})})),i.recurse!==!1&&this.moveChildren(n)};Tr.prototype.revert=function(n){var e=n.shape,t=n.oldParent,i=n.oldParentIndex,r=n.delta;return zt(t.children,e,i),T(e,{parent:t,x:e.x-r.x,y:e.y-r.y}),e};Tr.prototype.moveChildren=function(n){var e=n.delta,t=n.shape;this._helper.moveRecursive(t.children,e,null)};Tr.prototype.getNewParent=function(n){return n.newParent||n.shape.parent};function Ss(n){this._modeling=n}Ss.$inject=["modeling"];Ss.prototype.execute=function(n){var e=n.newSource,t=n.newTarget,i=n.connection,r=n.dockingOrPoints;if(!e&&!t)throw new Error("newSource or newTarget required");return F(r)&&(n.oldWaypoints=i.waypoints,i.waypoints=r),e&&(n.oldSource=i.source,i.source=e),t&&(n.oldTarget=i.target,i.target=t),i};Ss.prototype.postExecute=function(n){var e=n.connection,t=n.newSource,i=n.newTarget,r=n.dockingOrPoints,o=n.hints||{},s={};o.connectionStart&&(s.connectionStart=o.connectionStart),o.connectionEnd&&(s.connectionEnd=o.connectionEnd),o.layoutConnection!==!1&&(t&&(!i||o.docking==="source")&&(s.connectionStart=s.connectionStart||zO(F(r)?r[0]:r)),i&&(!t||o.docking==="target")&&(s.connectionEnd=s.connectionEnd||zO(F(r)?r[r.length-1]:r)),o.newWaypoints&&(s.waypoints=o.newWaypoints),this._modeling.layoutConnection(e,s))};Ss.prototype.revert=function(n){var e=n.oldSource,t=n.oldTarget,i=n.oldWaypoints,r=n.connection;return e&&(r.source=e),t&&(r.target=t),i&&(r.waypoints=i),r};function zO(n){return n.original||n}function yi(n,e){this._modeling=n,this._rules=e}yi.$inject=["modeling","rules"];yi.prototype.preExecute=function(n){var e=this,t=this._modeling,i=this._rules,r=n.oldShape,o=n.newData,s=n.hints||{},a;function l(p,m,g){return i.allowed("connection.reconnect",{connection:g,source:p,target:m})}var c={x:o.x,y:o.y},u={x:r.x,y:r.y,width:r.width,height:r.height};a=n.newShape=n.newShape||e.createShape(o,c,r.parent,s),r.host&&t.updateAttachment(a,r.host);var f;s.moveChildren!==!1&&(f=r.children.slice(),t.moveElements(f,{x:0,y:0},a,s));var h=r.incoming.slice(),d=r.outgoing.slice();k(h,function(p){var m=p.source,g=l(m,a,p);g&&e.reconnectEnd(p,a,Ha(p,a,u),s)}),k(d,function(p){var m=p.target,g=l(a,m,p);g&&e.reconnectStart(p,a,Va(p,a,u),s)})};yi.prototype.postExecute=function(n){var e=n.oldShape;this._modeling.removeShape(e)};yi.prototype.execute=function(n){};yi.prototype.revert=function(n){};yi.prototype.createShape=function(n,e,t,i){return this._modeling.createShape(n,e,t,i)};yi.prototype.reconnectStart=function(n,e,t,i){this._modeling.reconnectStart(n,e,t,i)};yi.prototype.reconnectEnd=function(n,e,t,i){this._modeling.reconnectEnd(n,e,t,i)};function Os(n){this._modeling=n}Os.$inject=["modeling"];Os.prototype.execute=function(n){var e=n.shape,t=n.newBounds,i=n.minBounds;if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)throw new Error("newBounds must have {x, y, width, height} properties");if(i&&(t.width<i.width||t.height<i.height))throw new Error("width and height cannot be less than minimum height and width");if(!i&&t.width<10||t.height<10)throw new Error("width and height cannot be less than 10px");return n.oldBounds={width:e.width,height:e.height,x:e.x,y:e.y},T(e,{width:t.width,height:t.height,x:t.x,y:t.y}),e};Os.prototype.postExecute=function(n){var e=this._modeling,t=n.shape,i=n.oldBounds,r=n.hints||{};r.layout!==!1&&(k(t.incoming,function(o){e.layoutConnection(o,{connectionEnd:Ha(o,t,i)})}),k(t.outgoing,function(o){e.layoutConnection(o,{connectionStart:Va(o,t,i)})}))};Os.prototype.revert=function(n){var e=n.shape,t=n.oldBounds;return T(e,{width:t.width,height:t.height,x:t.x,y:t.y}),e};function WO(n,e){var t=[];return k(n.concat(e),function(i){var r=i.incoming,o=i.outgoing;k(r.concat(o),function(s){var a=s.source,l=s.target;(Ff(n,a)||Ff(n,l)||Ff(e,a)||Ff(e,l))&&(Ff(t,s)||t.push(s))})}),t}function Ff(n,e){return n.indexOf(e)!==-1}function UO(n,e,t){var i=n.x,r=n.y,o=n.width,s=n.height,a=t.x,l=t.y;switch(e){case"n":return{x:i,y:r+l,width:o,height:s-l};case"s":return{x:i,y:r,width:o,height:s+l};case"w":return{x:i+a,y:r,width:o-a,height:s};case"e":return{x:i,y:r,width:o+a,height:s};default:throw new Error("unknown direction: "+e)}}function zi(n){this._modeling=n}zi.$inject=["modeling"];zi.prototype.preExecute=function(n){var e=n.delta,t=n.direction,i=n.movingShapes,r=n.resizingShapes,o=n.start,s={};this.moveShapes(i,e),k(r,function(a){s[a.id]=BF(a)}),this.resizeShapes(r,e,t),this.updateConnectionWaypoints(WO(i,r),e,t,o,i,r,s)};zi.prototype.execute=function(){};zi.prototype.revert=function(){};zi.prototype.moveShapes=function(n,e){var t=this;k(n,function(i){t._modeling.moveShape(i,e,null,{autoResize:!1,layout:!1,recurse:!1})})};zi.prototype.resizeShapes=function(n,e,t){var i=this;k(n,function(r){var o=UO(r,t,e);i._modeling.resizeShape(r,o,null,{attachSupport:!1,autoResize:!1,layout:!1})})};zi.prototype.updateConnectionWaypoints=function(n,e,t,i,r,o,s){var a=this,l=r.concat(o);k(n,function(c){var u=c.source,f=c.target,h=LF(c),d=GO(t),p={};Co(l,u)&&Co(l,f)?(h=Vt(h,function(m){return KO(m,i,t)&&(m[d]=m[d]+e[d]),m.original&&KO(m.original,i,t)&&(m.original[d]=m.original[d]+e[d]),m}),a._modeling.updateWaypoints(c,h,{labelBehavior:!1})):(Co(l,u)||Co(l,f))&&(Co(r,u)?p.connectionStart=za(c,u,e):Co(r,f)?p.connectionEnd=Wa(c,f,e):Co(o,u)?p.connectionStart=Va(c,u,s[u.id]):Co(o,f)&&(p.connectionEnd=Ha(c,f,s[f.id])),a._modeling.layoutConnection(c,p))})};function QO(n){return T({},n)}function LF(n){return Vt(n.waypoints,function(e){return e=QO(e),e.original&&(e.original=QO(e.original)),e})}function GO(n){switch(n){case"n":return"y";case"w":return"x";case"s":return"y";case"e":return"x"}}function KO(n,e,t){var i=GO(t);if(/e|s/.test(t))return n[i]>e;if(/n|w/.test(t))return n[i]<e}function Co(n,e){return n.indexOf(e)!==-1}function BF(n){return{x:n.x,y:n.y,height:n.height,width:n.width}}function Qa(n){this._modeling=n}Qa.$inject=["modeling"];Qa.prototype.execute=function(n){var e=n.shape,t=e.children;n.oldChildrenVisibility=XO(t),e.collapsed=!e.collapsed;var i=YO(t,e.collapsed);return[e].concat(i)};Qa.prototype.revert=function(n){var e=n.shape,t=n.oldChildrenVisibility,i=e.children,r=ZO(i,t);return e.collapsed=!e.collapsed,[e].concat(r)};function XO(n){var e={};return k(n,function(t){e[t.id]=t.hidden,t.children&&(e=T({},e,XO(t.children)))}),e}function YO(n,e){var t=[];return k(n,function(i){i.hidden=e,t=t.concat(i),i.children&&(t=t.concat(YO(i.children,i.collapsed||e)))}),t}function ZO(n,e){var t=[];return k(n,function(i){i.hidden=e[i.id],t=t.concat(i),i.children&&(t=t.concat(ZO(i.children,e)))}),t}function Ka(n){this._modeling=n}Ka.$inject=["modeling"];Ka.prototype.execute=function(n){var e=n.shape,t=n.newHost,i=e.host;return n.oldHost=i,n.attacherIdx=JO(i,e),ek(t,e),e.host=t,e};Ka.prototype.revert=function(n){var e=n.shape,t=n.newHost,i=n.oldHost,r=n.attacherIdx;return e.host=i,JO(t,e),ek(i,e,r),e};function JO(n,e){return Vn(n&&n.attachers,e)}function ek(n,e,t){if(n){var i=n.attachers;i||(n.attachers=i=[]),zt(i,e,t)}}function qf(){}qf.prototype.execute=function(n){var e=n.connection,t=n.newWaypoints;return n.oldWaypoints=e.waypoints,e.waypoints=t,e};qf.prototype.revert=function(n){var e=n.connection,t=n.oldWaypoints;return e.waypoints=t,e};function Se(n,e,t){this._eventBus=n,this._elementFactory=e,this._commandStack=t;var i=this;n.on("diagram.init",function(){i.registerHandlers(t)})}Se.$inject=["eventBus","elementFactory","commandStack"];Se.prototype.getHandlers=function(){return{"shape.append":$a,"shape.create":gi,"shape.delete":Es,"shape.move":Tr,"shape.resize":Os,"shape.replace":yi,"shape.toggleCollapse":Qa,spaceTool:zi,"label.create":_s,"connection.create":ja,"connection.delete":Cs,"connection.move":Nf,"connection.layout":qa,"connection.updateWaypoints":qf,"connection.reconnect":Ss,"elements.create":Lf,"elements.move":Ua,"elements.delete":Bf,"elements.distribute":Fa,"elements.align":Na,"element.updateAttachment":Ka}};Se.prototype.registerHandlers=function(n){k(this.getHandlers(),function(e,t){n.registerHandler(t,e)})};Se.prototype.moveShape=function(n,e,t,i,r){typeof i=="object"&&(r=i,i=null);var o={shape:n,delta:e,newParent:t,newParentIndex:i,hints:r||{}};this._commandStack.execute("shape.move",o)};Se.prototype.updateAttachment=function(n,e){var t={shape:n,newHost:e};this._commandStack.execute("element.updateAttachment",t)};Se.prototype.moveElements=function(n,e,t,i){i=i||{};var r=i.attach,o=t,s;r===!0?(s=t,o=t.parent):r===!1&&(s=null);var a={shapes:n,delta:e,newParent:o,newHost:s,hints:i};this._commandStack.execute("elements.move",a)};Se.prototype.moveConnection=function(n,e,t,i,r){typeof i=="object"&&(r=i,i=void 0);var o={connection:n,delta:e,newParent:t,newParentIndex:i,hints:r||{}};this._commandStack.execute("connection.move",o)};Se.prototype.layoutConnection=function(n,e){var t={connection:n,hints:e||{}};this._commandStack.execute("connection.layout",t)};Se.prototype.createConnection=function(n,e,t,i,r,o){typeof t=="object"&&(o=r,r=i,i=t,t=void 0),i=this._create("connection",i);var s={source:n,target:e,parent:r,parentIndex:t,connection:i,hints:o};return this._commandStack.execute("connection.create",s),s.connection};Se.prototype.createShape=function(n,e,t,i,r){typeof i!="number"&&(r=i,i=void 0),r=r||{};var o=r.attach,s,a;n=this._create("shape",n),o?(s=t.parent,a=t):s=t;var l={position:e,shape:n,parent:s,parentIndex:i,host:a,hints:r};return this._commandStack.execute("shape.create",l),l.shape};Se.prototype.createElements=function(n,e,t,i,r){F(n)||(n=[n]),typeof i!="number"&&(r=i,i=void 0),r=r||{};var o={position:e,elements:n,parent:t,parentIndex:i,hints:r};return this._commandStack.execute("elements.create",o),o.elements};Se.prototype.createLabel=function(n,e,t,i){t=this._create("label",t);var r={labelTarget:n,position:e,parent:i||n.parent,shape:t};return this._commandStack.execute("label.create",r),r.shape};Se.prototype.appendShape=function(n,e,t,i,r){r=r||{},e=this._create("shape",e);var o={source:n,position:t,target:i,shape:e,connection:r.connection,connectionParent:r.connectionParent,hints:r};return this._commandStack.execute("shape.append",o),o.shape};Se.prototype.removeElements=function(n){var e={elements:n};this._commandStack.execute("elements.delete",e)};Se.prototype.distributeElements=function(n,e,t){var i={groups:n,axis:e,dimension:t};this._commandStack.execute("elements.distribute",i)};Se.prototype.removeShape=function(n,e){var t={shape:n,hints:e||{}};this._commandStack.execute("shape.delete",t)};Se.prototype.removeConnection=function(n,e){var t={connection:n,hints:e||{}};this._commandStack.execute("connection.delete",t)};Se.prototype.replaceShape=function(n,e,t){var i={oldShape:n,newData:e,hints:t||{}};return this._commandStack.execute("shape.replace",i),i.newShape};Se.prototype.alignElements=function(n,e){var t={elements:n,alignment:e};this._commandStack.execute("elements.align",t)};Se.prototype.resizeShape=function(n,e,t,i){var r={shape:n,newBounds:e,minBounds:t,hints:i};this._commandStack.execute("shape.resize",r)};Se.prototype.createSpace=function(n,e,t,i,r){var o={delta:t,direction:i,movingShapes:n,resizingShapes:e,start:r};this._commandStack.execute("spaceTool",o)};Se.prototype.updateWaypoints=function(n,e,t){var i={connection:n,newWaypoints:e,hints:t||{}};this._commandStack.execute("connection.updateWaypoints",i)};Se.prototype.reconnect=function(n,e,t,i,r){var o={connection:n,newSource:e,newTarget:t,dockingOrPoints:i,hints:r||{}};this._commandStack.execute("connection.reconnect",o)};Se.prototype.reconnectStart=function(n,e,t,i){i||(i={}),this.reconnect(n,e,n.target,t,T(i,{docking:"source"}))};Se.prototype.reconnectEnd=function(n,e,t,i){i||(i={}),this.reconnect(n,n.source,e,t,T(i,{docking:"target"}))};Se.prototype.connect=function(n,e,t,i){return this.createConnection(n,e,t||{},n.parent,i)};Se.prototype._create=function(n,e){return tC(e)?e:this._elementFactory.create(n,e)};Se.prototype.toggleCollapse=function(n,e){var t={shape:n,hints:e||{}};this._commandStack.execute("shape.toggleCollapse",t)};function Ga(n){this._moddle=n}Ga.$inject=["moddle"];Ga.prototype.execute=function(n){var e=this._moddle.ids,t=n.id,i=n.element,r=n.claiming;r?e.claim(t,i):e.unclaim(t)};Ga.prototype.revert=function(n){var e=this._moddle.ids,t=n.id,i=n.element,r=n.claiming;r?e.unclaim(t):e.claim(t,i)};function Dx(){function n(i,r){var o=i.label||i,s=i.labelTarget||i;return yE(o,r,s!==o),[o,s]}function e(i){return i.oldLabel=fs(i.element),n(i.element,i.newLabel)}function t(i){return n(i.element,i.oldLabel)}this.execute=e,this.revert=t}var NF="name",Ar="id";function Xa(n,e){this._elementRegistry=n,this._moddle=e}Xa.$inject=["elementRegistry","moddle"];Xa.prototype.execute=function(n){let{element:e,properties:t}=n,i=[e];if(!e)throw new Error("element required");let r=this._elementRegistry,o=this._moddle.ids,s=Ke(e),a=n.oldProperties||$F(s,di(t));return tk(t,s)&&(o.unclaim(s[Ar]),r.updateId(e,t[Ar]),o.claim(t[Ar],s)),NF in t&&e.label&&i.push(e.label),nk(s,t),n.oldProperties=a,n.changed=i,i};Xa.prototype.revert=function(n){let{element:e,properties:t,oldProperties:i}=n,r=Ke(e),o=this._elementRegistry,s=this._moddle.ids;return nk(r,i),tk(t,r)&&(s.unclaim(t[Ar]),o.updateId(e,i[Ar]),s.claim(i[Ar],r)),n.changed};function tk(n,e){return Ar in n&&n[Ar]!==e[Ar]}function $F(n,e){return st(e,function(t,i){return t[i]=n.get(i),t},{})}function nk(n,e){k(e,function(t,i){n.set(i,t)})}function Ya(n){this._elementRegistry=n}Ya.$inject=["elementRegistry"];Ya.prototype.execute=function(n){var e=n.element,t=n.moddleElement,i=n.properties;if(!t)throw new Error("<moddleElement> required");var r=n.changed||[e],o=n.oldProperties||jF(t,di(i));return ik(t,i),n.oldProperties=o,n.changed=r,r};Ya.prototype.revert=function(n){var e=n.oldProperties,t=n.moddleElement,i=n.changed;return ik(t,e),i};function jF(n,e){return st(e,function(t,i){return t[i]=n.get(i),t},{})}function ik(n,e){k(e,function(t,i){n.set(i,t)})}function Xn(n,e,t){this._canvas=n,this._drdRules=e,t.invoke(Se,this)}fe(Xn,Se);Xn.$inject=["canvas","drdRules","injector"];Xn.prototype.claimId=function(n,e){this._commandStack.execute("id.updateClaim",{id:n,element:e,claiming:!0})};Xn.prototype.connect=function(n,e,t,i){var r=this._drdRules,o=this._canvas.getRootElement();return t||(t=r.canConnect(n,e)||{type:"dmn:Association"}),this.createConnection(n,e,t,o,i)};Xn.prototype.getHandlers=function(){var n=Se.prototype.getHandlers.call(this);return n["id.updateClaim"]=Ga,n["element.updateLabel"]=Dx,n["element.updateProperties"]=Xa,n["element.updateModdleProperties"]=Ya,n};Xn.prototype.unclaimId=function(n,e){this._commandStack.execute("id.updateClaim",{id:n,element:e})};Xn.prototype.updateModdleProperties=function(n,e,t){this._commandStack.execute("element.updateModdleProperties",{element:n,moddleElement:e,properties:t})};Xn.prototype.updateProperties=function(n,e){this._commandStack.execute("element.updateProperties",{element:n,properties:e})};Xn.prototype.updateLabel=function(n,e,t,i){this._commandStack.execute("element.updateLabel",{element:n,newLabel:e,newBounds:t,hints:i||{}})};function Om(){}Om.prototype.layoutConnection=function(n,e){return e=e||{},[e.connectionStart||le(e.source||n.source),e.connectionEnd||le(e.target||n.target)]};var km=20;function Za(n){this._connectionDocking=n}fe(Za,Om);Za.$inject=["connectionDocking"];Za.prototype.layoutConnection=function(n,e){var t=this._connectionDocking;e||(e={});var i=e.source||n.source,r=e.target||n.target,o=e.waypoints||n.waypoints||[],s=e.connectionStart,a=e.connectionEnd,l=vt(i,r);if(s||(s=rk(o[0],i)),a||(a=rk(o[o.length-1],r)),O(n,"dmn:InformationRequirement")){o=[s,a];var c=t.getCroppedWaypoints(T({},n,{waypoints:o}),i,r);a=c.pop();var u={x:a.x,y:a.y};return l.includes("bottom")?u.y+=km:l.includes("top")?u.y-=km:l.includes("right")?u.x+=km:u.x-=km,o=c.concat([u,a]),o}return[s,a]};function rk(n,e){return n?n.original||n:le(e)}function ok(n){return T({original:n.point.original||n.point},n.actual)}function Wi(n,e){this._elementRegistry=n,this._graphicsFactory=e}Wi.$inject=["elementRegistry","graphicsFactory"];Wi.prototype.getCroppedWaypoints=function(n,e,t){e=e||n.source,t=t||n.target;var i=this.getDockingPoint(n,e,!0),r=this.getDockingPoint(n,t),o=n.waypoints.slice(i.idx+1,r.idx);return o.unshift(ok(i)),o.push(ok(r)),o};Wi.prototype.getDockingPoint=function(n,e,t){var i=n.waypoints,r,o,s;return r=t?0:i.length-1,o=i[r],s=this._getIntersection(e,n,t),{point:o,actual:s||o,idx:r}};Wi.prototype._getIntersection=function(n,e,t){var i=this._getShapePath(n),r=this._getConnectionPath(e);return tf(i,r,t)};Wi.prototype._getConnectionPath=function(n){return this._graphicsFactory.getConnectionPath(n)};Wi.prototype._getShapePath=function(n){return this._graphicsFactory.getShapePath(n)};Wi.prototype._getGfx=function(n){return this._elementRegistry.getGraphics(n)};var sk={__init__:["modeling","drdUpdater"],__depends__:[LO,jO,Ca,xs,ht,Cm],drdFactory:["type",kn],drdUpdater:["type",Hi],elementFactory:["type",_r],modeling:["type",Xn],layouter:["type",Za],connectionDocking:["type",Wi]};var FF=500,qF=1e3;function Mr(n,e){this._eventBus=n,this.offset=5;var t=e.cls("djs-outline",["no-fill"]),i=this;function r(o){var s=Q("rect");return j(s,T({x:0,y:0,rx:4,width:100,height:100},t)),s}n.on(["shape.added","shape.changed"],FF,function(o){var s=o.element,a=o.gfx,l=X(".djs-outline",a);l||(l=i.getOutline(s)||r(a),K(a,l)),i.updateShapeOutline(l,s)}),n.on(["connection.added","connection.changed"],function(o){var s=o.element,a=o.gfx,l=X(".djs-outline",a);l||(l=r(a),K(a,l)),i.updateConnectionOutline(l,s)})}Mr.prototype.updateShapeOutline=function(n,e){var t=!1,i=this._getProviders();i.length&&k(i,function(r){t=t||r.updateOutline(e,n)}),t||j(n,{x:-this.offset,y:-this.offset,width:e.width+this.offset*2,height:e.height+this.offset*2})};Mr.prototype.updateConnectionOutline=function(n,e){var t=Tt(e);j(n,{x:t.x-this.offset,y:t.y-this.offset,width:t.width+this.offset*2,height:t.height+this.offset*2})};Mr.prototype.registerProvider=function(n,e){e||(e=n,n=qF),this._eventBus.on("outline.getProviders",n,function(t){t.providers.push(e)})};Mr.prototype._getProviders=function(){var n=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(n),n.providers};Mr.prototype.getOutline=function(n){var e,t=this._getProviders();return k(t,function(i){ge(i.getOutline)&&(e=e||i.getOutline(n))}),e};Mr.$inject=["eventBus","styles","elementRegistry"];var Rm=6;function Vf(n,e,t){this._canvas=e;var i=this;n.on("element.changed",function(r){t.isSelected(r.element)&&i._updateMultiSelectionOutline(t.get())}),n.on("selection.changed",function(r){var o=r.newSelection;i._updateMultiSelectionOutline(o)})}Vf.prototype._updateMultiSelectionOutline=function(n){var e=this._canvas.getLayer("selectionOutline");ss(e);var t=n.length>1,i=this._canvas.getContainer();if(ne(i)[t?"add":"remove"]("djs-multi-select"),!!t){var r=VF(Tt(n)),o=Q("rect");j(o,T({rx:3},r)),ne(o).add("djs-selection-outline"),K(e,o)}};Vf.$inject=["eventBus","canvas","selection"];function VF(n){return{x:n.x-Rm,y:n.y-Rm,width:n.width+Rm*2,height:n.height+Rm*2}}var Tm={__depends__:[ht],__init__:["outline","multiSelectionOutline"],outline:["type",Mr],multiSelectionOutline:["type",Vf]};var HF=500,zF=1250,WF=1500,Am=Math.round;function UF(n){return{x:n.x+Am(n.width/2),y:n.y+Am(n.height/2)}}function Mm(n,e,t,i,r){function o(a,l,c,u){return r.allowed("elements.move",{shapes:a,delta:l,position:c,target:u})}n.on("shape.move.start",WF,function(a){var l=a.context,c=a.shape,u=i.get().slice();u.indexOf(c)===-1&&(u=[c]),u=QF(u),T(l,{shapes:u,validatedShapes:u,shape:c})}),n.on("shape.move.start",zF,function(a){var l=a.context,c=l.validatedShapes,u;if(u=l.canExecute=o(c),!u)return!1}),n.on("shape.move.move",HF,function(a){var l=a.context,c=l.validatedShapes,u=a.hover,f={x:a.dx,y:a.dy},h={x:a.x,y:a.y},d;if(d=o(c,f,h,u),l.delta=f,l.canExecute=d,d===null){l.target=null;return}l.target=u}),n.on("shape.move.end",function(a){var l=a.context,c=l.delta,u=l.canExecute,f=u==="attach",h=l.shapes;if(u===!1)return!1;c.x=Am(c.x),c.y=Am(c.y),!(c.x===0&&c.y===0)&&t.moveElements(h,c,l.target,{primaryShape:l.shape,attach:f})}),n.on("element.mousedown",function(a){if(Sn(a)){var l=vr(a);if(!l)throw new Error("must supply DOM mousedown event");return s(l,a.element)}});function s(a,l,c,u){if(Pe(c)&&(u=c,c=!1),!(l.waypoints||!l.parent)&&!ne(a.target).has("djs-hit-no-move")){var f=UF(l),h=e.init(a,f,"shape.move",{cursor:"grabbing",autoActivate:c,data:{shape:l,context:u||{}}});if(h!==!1)return!0}}this.start=s}Mm.$inject=["eventBus","dragging","modeling","selection","rules"];function QF(n){var e=ur(n,"id");return Ee(n,function(t){for(;t=t.parent;)if(e[t.id])return!1;return!0})}var ak=499,Ix="djs-dragging",lk="drop-ok",ck="drop-not-ok",uk="new-parent",fk="attach-ok";function Pm(n,e,t,i){function r(l){var c=o(l),u=KF(c);return u}function o(l){var c=O1(l,!0),u=c.flatMap(d=>(d.incoming||[]).concat(d.outgoing||[])),f=c.concat(u),h=[...new Set(f)];return h}function s(l,c){[fk,lk,ck,uk].forEach(function(u){u===c?e.addMarker(l,u):e.removeMarker(l,u)})}function a(l,c,u){i.addDragger(c,l.dragGroup),u&&e.addMarker(c,Ix),l.allDraggedElements?l.allDraggedElements.push(c):l.allDraggedElements=[c]}n.on("shape.move.start",ak,function(l){var c=l.context,u=c.shapes,f=c.allDraggedElements,h=r(u);if(!c.dragGroup){var d=Q("g");j(d,t.cls("djs-drag-group",["no-events"]));var p=e.getActiveLayer();K(p,d),c.dragGroup=d}h.forEach(function(m){i.addDragger(m,c.dragGroup)}),f?f=Dw([f,o(u)]):f=o(u),k(f,function(m){e.addMarker(m,Ix)}),c.allDraggedElements=f,c.differentParents=GF(u)}),n.on("shape.move.move",ak,function(l){var c=l.context,u=c.dragGroup,f=c.target,h=c.shape.parent,d=c.canExecute;f&&(d==="attach"?s(f,fk):c.canExecute&&h&&f.id!==h.id?s(f,uk):s(f,c.canExecute?lk:ck)),jt(u,l.dx,l.dy)}),n.on(["shape.move.out","shape.move.cleanup"],function(l){var c=l.context,u=c.target;u&&s(u,null)}),n.on("shape.move.cleanup",function(l){var c=l.context,u=c.allDraggedElements,f=c.dragGroup;k(u,function(h){e.removeMarker(h,Ix)}),f&&Fe(f)}),this.makeDraggable=a}Pm.$inject=["eventBus","canvas","styles","previewSupport"];function KF(n){var e=Ee(n,function(t){return Xe(t)?ye(n,la({id:t.source.id}))&&ye(n,la({id:t.target.id})):!0});return e}function GF(n){return Lw(ur(n,function(e){return e.parent&&e.parent.id}))!==1}var hk={__depends__:[fo,ht,Tm,yn,gn,ka],__init__:["move","movePreview"],move:["type",Mm],movePreview:["type",Pm]};var dk=` 250M2.45221 16.0068L18.7175 1.74436L18.0615 0.996331L18.7175 1.74436C19.2646 1.26455 19.9676 2511 20.6953 1H140.926C142.583 1 143.926 2.34295 143.926 3.99967L143.93 37.5457C143.93 25238.3668 143.593 39.152 142.999 39.7183L143.689 40.4424L142.999 39.7183L127.299 25354.6723C126.741 55.2036 126 55.5 125.23 55.5H4.53787C2.88599 55.5 1.54491 54.1646 1.5379 25452.5127L1.43066 27.229L1.43065 27.2248L1.4301 18.2626C1.43005 25517.3986 1.80255 16.5765 2.45221 16.0068Z 256`,pk=` 257M1.79494 63.0032L1.2941 63.6423L1.79493 63.0032C1.71778 62.9427 1.6428 62.8741 1.57288 25862.8L1.01736 63.3241L1.57288 62.8C1.20495 62.41 1 61.8941 1 61.3579V2.65067C1 1.74066 2591.73867 1.00345 2.64868 1.00526L108.006 1.2145C109.66 1.21778 111 2.55996 111 2604.21449V21.7015V61.6762C111 63.3188 109.679 64.656 108.037 64.676L107.06 64.6879C106.66 26164.6927 106.26 64.6165 105.89 64.4652C105.04 64.1176 104.222 63.78 103.43 26263.4531C93.4866 59.3517 87.6891 56.9603 76.3991 58.1057C71.7035 58.5821 66.8747 60.74 26361.5721 63.1744C61.3243 63.2881 61.0753 63.4026 60.825 63.5177C55.6712 65.8868 49.9696 26468.5077 43.2365 70.3468C31.101 73.6617 15.2135 73.5179 1.79494 63.0032Z 265`,mk={width:135,height:46},gk={width:100,height:63};function Lx(n,e,t){return Q("path",{d:n,strokeWidth:2,transform:`translate(${e.x}, ${e.y})`,...t})}var Dm=5;function Ja(n,e){this._styles=e,n.registerProvider(this)}Ja.$inject=["outline","styles"];Ja.prototype.getOutline=function(n){let e=this._styles.cls("djs-outline",["no-fill"]);var t;return O(n,"dmn:InputData")?(t=Q("rect"),j(t,T({x:-Dm,y:-Dm,rx:27,width:n.width+Dm*2,height:n.height+Dm*2},e))):O(n,"dmn:BusinessKnowledgeModel")&&yk(n,"dmn:BusinessKnowledgeModel")?t=Lx(dk,{x:-6,y:-6},e):O(n,"dmn:KnowledgeSource")&&yk(n,"dmn:KnowledgeSource")&&(t=Lx(pk,{x:-6,y:-1.5},e)),t};Ja.prototype.updateOutline=function(n){return!!Ge(n,["dmn:InputData","dmn:BusinessKnowledgeModel","dmn:KnowledgeSource"])};function yk(n,e){var t;return e==="dmn:BusinessKnowledgeModel"?t=mk:e==="dmn:KnowledgeSource"&&(t=gk),n.width===t.width&&n.height===t.height}var vk={__depends__:[Tm],__init__:["outlineProvider"],outlineProvider:["type",Ja]};var bk=".djs-palette-toggle",_k=".entry",XF=bk+", "+_k,Bx="djs-palette-",YF="shown",Nx="open",xk="two-column",ZF=1e3;function nt(n,e){this._eventBus=n,this._canvas=e;var t=this;n.on("tool-manager.update",function(i){var r=i.tool;t.updateToolHighlight(r)}),n.on("i18n.changed",function(){t._update()}),n.on("diagram.init",function(){t._diagramInitialized=!0,t._rebuild()})}nt.$inject=["eventBus","canvas"];nt.prototype.registerProvider=function(n,e){e||(e=n,n=ZF),this._eventBus.on("palette.getProviders",n,function(t){t.providers.push(e)}),this._rebuild()};nt.prototype.getEntries=function(){var n=this._getProviders();return n.reduce(e3,{})};nt.prototype._rebuild=function(){if(this._diagramInitialized){var n=this._getProviders();n.length&&(this._container||this._init(),this._update())}};nt.prototype._init=function(){var n=this,e=this._eventBus,t=this._getParentContainer(),i=this._container=te(nt.HTML_MARKUP);t.appendChild(i),ee(t).add(Bx+YF),_t.bind(i,XF,"click",function(r){var o=r.delegateTarget;if(hr(o,bk))return n.toggle();n.trigger("click",r)}),q.bind(i,"mousedown",function(r){r.stopPropagation()}),_t.bind(i,_k,"dragstart",function(r){n.trigger("dragstart",r)}),e.on("canvas.resized",this._layoutChanged,this),e.fire("palette.create",{container:i})};nt.prototype._getProviders=function(n){var e=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(e),e.providers};nt.prototype._toggleState=function(n){n=n||{};var e=this._getParentContainer(),t=this._container,i=this._eventBus,r,o=ee(t),s=ee(e);"twoColumn"in n?r=n.twoColumn:r=this._needsCollapse(e.clientHeight,this._entries||{}),o.toggle(xk,r),s.toggle(Bx+xk,r),"open"in n&&(o.toggle(Nx,n.open),s.toggle(Bx+Nx,n.open)),i.fire("palette.changed",{twoColumn:r,open:this.isOpen()})};nt.prototype._update=function(){var n=X(".djs-palette-entries",this._container),e=this._entries=this.getEntries();no(n),k(e,function(t,i){var r=t.group||"default",o=X("[data-group="+Sa(r)+"]",n);o||(o=te('<div class="group"></div>'),et(o,"data-group",r),n.appendChild(o));var s=t.html||(t.separator?'<hr class="separator" />':'<div class="entry" draggable="true"></div>'),a=te(s);if(o.appendChild(a),!t.separator&&(et(a,"data-action",i),t.title&&et(a,"title",t.title),t.className&&JF(a,t.className),t.imageUrl)){var l=te("<img>");et(l,"src",t.imageUrl),a.appendChild(l)}}),this.open()};nt.prototype.trigger=function(n,e,t){var i,r,o=e.delegateTarget||e.target;return o?(i=et(o,"data-action"),r=e.originalEvent||e,this.triggerEntry(i,n,r,t)):e.preventDefault()};nt.prototype.triggerEntry=function(n,e,t,i){var r=this._entries,o,s;if(o=r[n],!!o&&(s=o.action,this._eventBus.fire("palette.trigger",{entry:o,event:t})!==!1)){if(ge(s)){if(e==="click")return s(t,i)}else if(s[e])return s[e](t,i);t.preventDefault()}};nt.prototype._layoutChanged=function(){this._toggleState({})};nt.prototype._needsCollapse=function(n,e){var t=50,i=Object.keys(e).length*46;return n<i+t};nt.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})};nt.prototype.open=function(){this._toggleState({open:!0})};nt.prototype.toggle=function(){this.isOpen()?this.close():this.open()};nt.prototype.isActiveTool=function(n){return n&&this._activeTool===n};nt.prototype.updateToolHighlight=function(n){var e,t;this._toolsContainer||(e=X(".djs-palette-entries",this._container),this._toolsContainer=X("[data-group=tools]",e)),t=this._toolsContainer,k(t.children,function(i){var r=i.getAttribute("data-action");if(r){var o=ee(i);r=r.replace("-tool",""),o.contains("entry")&&r===n?o.add("highlighted-entry"):o.remove("highlighted-entry")}})};nt.prototype.isOpen=function(){return ee(this._container).has(Nx)};nt.prototype._getParentContainer=function(){return this._canvas.getContainer()};nt.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';function JF(n,e){var t=ee(n),i=F(e)?e:e.split(/\s+/g);i.forEach(function(r){t.add(r)})}function e3(n,e){var t=e.getPaletteEntries();return ge(t)?t(n):(k(t,function(i,r){n[r]=i}),n)}var wk={__init__:["palette"],palette:["type",nt]};var t3=250;function Pr(n){this._eventBus=n,this._tools=[],this._active=null}Pr.$inject=["eventBus"];Pr.prototype.registerTool=function(n,e){var t=this._tools;if(!e)throw new Error(`A tool has to be registered with it's "events"`);t.push(n),this.bindEvents(n,e)};Pr.prototype.isActive=function(n){return n&&this._active===n};Pr.prototype.length=function(n){return this._tools.length};Pr.prototype.setActive=function(n){var e=this._eventBus;this._active!==n&&(this._active=n,e.fire("tool-manager.update",{tool:n}))};Pr.prototype.bindEvents=function(n,e){var t=this._eventBus,i=[];t.on(e.tool+".init",function(r){var o=r.context;if(!o.reactivate&&this.isActive(n)){this.setActive(null);return}this.setActive(n)},this),k(e,function(r){i.push(r+".ended"),i.push(r+".canceled")}),t.on(i,t3,function(r){this._active&&(n3(r)||this.setActive(null))},this)};function n3(n){var e=n.originalEvent&&n.originalEvent.target;return e&&De(e,'.group[data-group="tools"]')}var Im={__depends__:[gn],__init__:["toolManager"],toolManager:["type",Pr]};function Hf(n){var e=this;this._lastMoveEvent=null;function t(i){e._lastMoveEvent=i}n.on("canvas.init",function(i){var r=e._svg=i.svg;r.addEventListener("mousemove",t)}),n.on("canvas.destroy",function(){e._lastMouseEvent=null,e._svg.removeEventListener("mousemove",t)})}Hf.$inject=["eventBus"];Hf.prototype.getLastMoveEvent=function(){return this._lastMoveEvent||i3(0,0)};function i3(n,e){var t=document.createEvent("MouseEvent"),i=n,r=e,o=n,s=e;return t.initMouseEvent&&t.initMouseEvent("mousemove",!0,!0,window,0,i,r,o,s,!1,!1,!1,!1,0,null),t}var Lm={__init__:["mouse"],mouse:["type",Hf]};var Sk="crosshair",Ck="selected",r3="djs-dragging-active-lasso";function Ui(n,e,t,i,r,o,s){this._selection=r,this._dragging=t,this._mouse=s;var a=this,l={create:function(f){var h=e.getActiveLayer(),d=f.frame=Q("rect");j(d,{class:"djs-lasso-overlay",width:1,height:1,x:0,y:0}),K(h,d),c(!0),this.update(f)},update:function(f){var h=f.frame,d=f.bbox;h&&d&&j(h,{x:d.x,y:d.y,width:d.width,height:d.height});var p=f.marked,m=f.lastMarked;if(p&&m){for(let g of m)p.has(g)||e.removeMarker(g,Ck);for(let g of p)m.has(g)||e.addMarker(g,Ck)}},remove:function(f){this.update(f),f.frame&&Fe(f.frame),c(!1)}};function c(f){ne(e.getContainer()).toggle(r3,f)}function u(f){var h=i.getAll();return new Set(Wu(wv(h,f)))}o.registerTool("lasso",{tool:"lasso.selection",dragging:"lasso"}),n.on("lasso.selection.end",function(f){var h=f.originalEvent.target;!f.hover&&!(h instanceof SVGElement)||n.once("lasso.selection.ended",function(){a.activateLasso(f.originalEvent,!0)})}),n.on("lasso.end",0,function(f){var h=f.context;a._select(Array.from(h.marked))}),n.on("lasso.start",function(f){var h=f.context;h.bbox=Ek(f),h.add=df(f),h.lastMarked=new Set(r.get()),h.add?h.marked=h.lastMarked:h.marked=new Set,h.initialMarked=h.marked,l.create(h)}),n.on("lasso.move",function(f){var h=f.context,d=h.bbox=Ek(f),p=u(d),m=h.initialMarked.union(p);h.lastMarked=h.marked,h.marked=m,l.update(h)}),n.on("lasso.cleanup",function(f){var h=f.context;h.lastMarked=h.marked,h.marked=new Set(r.get()),l.remove(f.context)}),n.on("element.mousedown",1500,function(f){if(df(f))return a.activateLasso(f.originalEvent),!0})}Ui.$inject=["eventBus","canvas","dragging","elementRegistry","selection","toolManager","mouse"];Ui.prototype.activateLasso=function(n,e){this._dragging.init(n,"lasso",{autoActivate:e,cursor:Sk,data:{context:{}},keepSelection:!0})};Ui.prototype.activateSelection=function(n,e){this._dragging.init(n,"lasso.selection",{trapClick:!1,autoActivate:e,cursor:Sk,data:{context:{}},keepSelection:!0})};Ui.prototype._select=function(n){this._selection.select(n)};Ui.prototype.select=function(n,e,t=[]){var i=Wu(wv(n,e));this._select([...t,...i])};Ui.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var n=this._mouse.getLastMoveEvent();this.activateSelection(n,!!n)};Ui.prototype.isActive=function(){var n=this._dragging.context();return n&&/^lasso/.test(n.prefix)};function Ek(n){var e={x:n.x-n.dx,y:n.y-n.dy},t={x:n.x,y:n.y},i;return e.x<=t.x&&e.y<t.y||e.x<t.x&&e.y<=t.y?i={x:e.x,y:e.y,width:t.x-e.x,height:t.y-e.y}:e.x>=t.x&&e.y<t.y||e.x>t.x&&e.y<=t.y?i={x:t.x,y:e.y,width:e.x-t.x,height:t.y-e.y}:e.x<=t.x&&e.y>t.y||e.x<t.x&&e.y>=t.y?i={x:e.x,y:t.y,width:t.x-e.x,height:e.y-t.y}:e.x>=t.x&&e.y>t.y||e.x>t.x&&e.y>=t.y?i={x:t.x,y:t.y,width:e.x-t.x,height:e.y-t.y}:i={x:t.x,y:t.y,width:0,height:0},i}var Ok={__depends__:[Im,Lm],__init__:["lassoTool"],lassoTool:["type",Ui]};var $x=1500,Rk="grab";function Eo(n,e,t,i,r,o){this._dragging=t,this._mouse=o;var s=this,a=i.get("keyboard",!1);r.registerTool("hand",{tool:"hand",dragging:"hand.move"}),n.on("element.mousedown",$x,function(l){if(hf(l))return s.activateMove(l.originalEvent,!0),!1}),a&&a.addListener($x,function(l){if(!(!kk(l.keyEvent)||s.isActive())){var c=s._mouse.getLastMoveEvent();s.activateMove(c,!!c)}},"keyboard.keydown"),a&&a.addListener($x,function(l){!kk(l.keyEvent)||!s.isActive()||s.toggle()},"keyboard.keyup"),n.on("hand.end",function(l){var c=l.originalEvent.target;if(!l.hover&&!(c instanceof SVGElement))return!1;n.once("hand.ended",function(){s.activateMove(l.originalEvent,{reactivate:!0})})}),n.on("hand.move.move",function(l){var c=e.viewbox().scale;e.scroll({dx:l.dx*c,dy:l.dy*c})}),n.on("hand.move.end",function(l){var c=l.context,u=c.reactivate;return!hf(l)&&u&&n.once("hand.move.ended",function(f){s.activateHand(f.originalEvent,!0,!0)}),!1})}Eo.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"];Eo.prototype.activateMove=function(n,e,t){typeof e=="object"&&(t=e,e=!1),this._dragging.init(n,"hand.move",{autoActivate:e,cursor:Rk,data:{context:t||{}}})};Eo.prototype.activateHand=function(n,e,t){this._dragging.init(n,"hand",{trapClick:!1,autoActivate:e,cursor:Rk,data:{context:{reactivate:t}}})};Eo.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var n=this._mouse.getLastMoveEvent();this.activateHand(n,!!n)};Eo.prototype.isActive=function(){var n=this._dragging.context();return n?/^(hand|hand\.move)$/.test(n.prefix):!1};function kk(n){return Ve("Space",n)}var Tk={__depends__:[Im,Lm],__init__:["handTool"],handTool:["type",Eo]};function zf(n,e,t,i,r,o){this._palette=n,this._create=e,this._elementFactory=t,this._handTool=i,this._lassoTool=r,this._translate=o,n.registerProvider(this)}zf.$inject=["palette","create","elementFactory","handTool","lassoTool","translate"];zf.prototype.getPaletteEntries=function(n){var e={},t=this._create,i=this._elementFactory,r=this._handTool,o=this._lassoTool,s=this._translate;function a(l,c,u,f,h){function d(p){var m=i.createShape(T({type:l},h));t.start(p,m)}return{group:c,className:u,title:f,action:{dragstart:d,click:d}}}return T(e,{"hand-tool":{group:"tools",className:"dmn-icon-hand-tool",title:s("Activate hand tool"),action:{click:function(l){r.activateHand(l)}}},"lasso-tool":{group:"tools",className:"dmn-icon-lasso-tool",title:s("Activate lasso tool"),action:{click:function(l){o.activateSelection(l)}}},"tool-separator":{group:"tools",separator:!0},"create.decision":a("dmn:Decision","drd","dmn-icon-decision",s("Create decision")),"create.input-data":a("dmn:InputData","drd","dmn-icon-input-data",s("Create input data")),"create.knowledge-source":a("dmn:KnowledgeSource","drd","dmn-icon-knowledge-source",s("Create knowledge source")),"create.business-knowledge-model":a("dmn:BusinessKnowledgeModel","drd","dmn-icon-business-knowledge",s("Create knowledge model"))}),e};var Ak={__depends__:[qe,wk,Zp,Ok,Tk],__init__:["paletteProvider"],paletteProvider:["type",zf]};var Nm=Math.max,$m=Math.min,o3=20;function Mk(n,e,t){var i=t.x,r=t.y,o={x:n.x,y:n.y,width:n.width,height:n.height};return e.indexOf("n")!==-1?(o.y=n.y+r,o.height=n.height-r):e.indexOf("s")!==-1&&(o.height=n.height+r),e.indexOf("e")!==-1?o.width=n.width+i:e.indexOf("w")!==-1&&(o.x=n.x+i,o.width=n.width-i),o}function Bm(n,e,t){var i=e[n],r=t.min&&t.min[n],o=t.max&&t.max[n];return se(r)&&(i=(/top|left/.test(n)?$m:Nm)(i,r)),se(o)&&(i=(/top|left/.test(n)?Nm:$m)(i,o)),i}function Pk(n,e){if(!e)return n;var t=G(n);return Ov({top:Bm("top",t,e),right:Bm("right",t,e),bottom:Bm("bottom",t,e),left:Bm("left",t,e)})}function Dk(n,e,t,i){var r=G(e),o={top:/n/.test(n)?r.bottom-t.height:r.top,left:/w/.test(n)?r.right-t.width:r.left,bottom:/s/.test(n)?r.top+t.height:r.bottom,right:/e/.test(n)?r.left+t.width:r.right},s=i?G(i):o,a={top:$m(o.top,s.top),left:$m(o.left,s.left),bottom:Nm(o.bottom,s.bottom),right:Nm(o.right,s.right)};return Ov(a)}function Wf(n,e){return typeof n!="undefined"?n:o3}function s3(n,e){var t,i,r,o;return typeof e=="object"?(t=Wf(e.left),i=Wf(e.right),r=Wf(e.top),o=Wf(e.bottom)):t=i=r=o=Wf(e),{x:n.x-t,y:n.y-r,width:n.width+t+i,height:n.height+r+o}}function a3(n){return!(n.waypoints||n.type==="label")}function Ik(n,e){var t;if(n.length===void 0?t=Ee(n.children,a3):t=n,t.length)return s3(Tt(t),e)}var Lk=10;function ks(n,e,t,i){this._dragging=i,this._rules=e;var r=this;function o(l,c){var u=l.shape,f=l.direction,h=l.resizeConstraints,d;l.delta=c,d=Mk(u,f,c),l.newBounds=Pk(d,h),l.canExecute=r.canResize(l)}function s(l){var c=l.resizeConstraints,u=l.minBounds;c===void 0&&(u===void 0&&(u=r.computeMinResizeBox(l)),l.resizeConstraints={min:G(u)})}function a(l){var c=l.shape,u=l.canExecute,f=l.newBounds;if(u){if(f=F1(f),!l3(c,f))return;t.resizeShape(c,f)}}n.on("resize.start",function(l){s(l.context)}),n.on("resize.move",function(l){var c={x:l.dx,y:l.dy};o(l.context,c)}),n.on("resize.end",function(l){a(l.context)})}ks.prototype.canResize=function(n){var e=this._rules,t=hn(n,["newBounds","shape","delta","direction"]);return e.allowed("shape.resize",t)};ks.prototype.activate=function(n,e,t){var i=this._dragging,r,o;if(typeof t=="string"&&(t={direction:t}),r=T({shape:e},t),o=r.direction,!o)throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");i.init(n,jx(e,o),"resize",{autoActivate:!0,cursor:c3(o),data:{shape:e,context:r}})};ks.prototype.computeMinResizeBox=function(n){var e=n.shape,t=n.direction,i,r;return i=n.minDimensions||{width:Lk,height:Lk},r=Ik(e,n.childrenBoxPadding),Dk(t,e,i,r)};ks.$inject=["eventBus","rules","modeling","dragging"];function l3(n,e){return n.x!==e.x||n.y!==e.y||n.width!==e.width||n.height!==e.height}function jx(n,e){var t=le(n),i=G(n),r={x:t.x,y:t.y};return e.indexOf("n")!==-1?r.y=i.top:e.indexOf("s")!==-1&&(r.y=i.bottom),e.indexOf("e")!==-1?r.x=i.right:e.indexOf("w")!==-1&&(r.x=i.left),r}function c3(n){var e="resize-";return n==="n"||n==="s"?e+"ns":n==="e"||n==="w"?e+"ew":n==="nw"||n==="se"?e+"nwse":e+"nesw"}var Bk="djs-resizing",Nk="resize-not-ok",u3=500;function jm(n,e,t){function i(o){var s=o.shape,a=o.newBounds,l=o.frame;l||(l=o.frame=t.addFrame(s,e.getActiveLayer()),e.addMarker(s,Bk)),a.width>5&&j(l,{x:a.x,width:a.width}),a.height>5&&j(l,{y:a.y,height:a.height}),o.canExecute?ne(l).remove(Nk):ne(l).add(Nk)}function r(o){var s=o.shape,a=o.frame;a&&Fe(o.frame),e.removeMarker(s,Bk)}n.on("resize.move",u3,function(o){i(o.context)}),n.on("resize.cleanup",function(o){r(o.context)})}jm.$inject=["eventBus","canvas","previewSupport"];var Fm=-6,qm=8,Vm=20,Uf="djs-resizer",f3=["n","w","s","e","nw","ne","se","sw"];function Qi(n,e,t,i){this._resize=i,this._canvas=e;var r=this;n.on("selection.changed",function(o){var s=o.newSelection;r.removeResizers(),s.length===1&&k(s,at(r.addResizer,r))}),n.on("shape.changed",function(o){var s=o.element;t.isSelected(s)&&(r.removeResizers(),r.addResizer(s))})}Qi.prototype.makeDraggable=function(n,e,t){var i=this._resize;function r(o){Sn(o)&&i.activate(o,n,t)}q.bind(e,"mousedown",r),q.bind(e,"touchstart",r)};Qi.prototype._createResizer=function(n,e,t,i){var r=this._getResizersParent(),o=h3(i),s=Q("g");ne(s).add(Uf),ne(s).add(Uf+"-"+n.id),ne(s).add(Uf+"-"+i),K(r,s);var a=Q("rect");j(a,{x:-qm/2+o.x,y:-qm/2+o.y,width:qm,height:qm}),ne(a).add(Uf+"-visual"),K(s,a);var l=Q("rect");return j(l,{x:-Vm/2+o.x,y:-Vm/2+o.y,width:Vm,height:Vm}),ne(l).add(Uf+"-hit"),K(s,l),iC(s,e,t),s};Qi.prototype.createResizer=function(n,e){var t=jx(n,e),i=this._createResizer(n,t.x,t.y,e);this.makeDraggable(n,i,e)};Qi.prototype.addResizer=function(n){var e=this;Xe(n)||k(f3,function(t){e._resize.canResize({shape:n,direction:t})&&e.createResizer(n,t)})};Qi.prototype.removeResizers=function(){var n=this._getResizersParent();ss(n)};Qi.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")};Qi.$inject=["eventBus","canvas","selection","resize"];function h3(n){var e={x:0,y:0};return n.indexOf("e")!==-1?e.x=-Fm:n.indexOf("w")!==-1&&(e.x=Fm),n.indexOf("s")!==-1?e.y=-Fm:n.indexOf("n")!==-1&&(e.y=Fm),e}var $k={__depends__:[yn,gn,ka],__init__:["resize","resizePreview","resizeHandles"],resize:["type",ks],resizePreview:["type",jm],resizeHandles:["type",Qi]};var d3="reconnectStart",p3="reconnectEnd",m3=2e3;function Hm(n){n.on(["bendpoint.move.move","bendpoint.move.end"],m3,function(e){var t=e.context,i=t.allowed,r=t.hover,o=t.source,s=t.target,a=t.type;if(t.hints||(t.hints={}),delete t.hints.connectionStart,delete t.hints.connectionEnd,!(i&&i.type!=="dmn:InformationRequirement")&&!(!r||!Ge(r,["dmn:Decision","dmn:InputData"]))&&o!==s){var l=a===d3||a===p3,c=vt(o,s);l&&r===o?(g3(e,c),t.hints.connectionEnd=Fk(s,c)):l&&r===s&&(t.hints.connectionStart=jk(o,c),y3(e,c))}})}Hm.$inject=["eventBus"];function jk(n,e){var t=G(n),i=le(n);return e.includes("bottom")?i.y=t.top:e.includes("top")?i.y=t.bottom:e.includes("right")?i.x=t.left:i.x=t.right,i}function Fk(n,e){var t=G(n),i=le(n);return e.includes("bottom")?i.y=t.bottom:e.includes("top")?i.y=t.top:e.includes("right")?i.x=t.right:i.x=t.left,i}function g3(n,e){var t=n.context,i=t.source,r=jk(i,e),o=n.x-r.x,s=n.y-r.y;n.x-=o,n.y-=s,n.dx-=o,n.dy-=s}function y3(n,e){var t=n.context,i=t.target,r=Fk(i,e),o=0,s=0;e.includes("top")||e.includes("bottom")?s=n.y-r.y:o=n.x-r.x,n.x-=o,n.y-=s,n.dx-=o,n.dy-=s}var v3=250;function zm(n){n.on(["connect.hover","connect.move","connect.end"],v3,function(e){var t=e.context,i=t.canExecute,r=t.hover,o=t.source,s=t.target;if(i&&i.type==="dmn:InformationRequirement"){var a=vt(o,s);t.connectionStart=le(o),r===o?t.connectionEnd=le(s):t.connectionEnd={x:e.x,y:e.y},a.includes("bottom")?(t.connectionStart.y=G(o).top,t.connectionEnd.y=G(s).bottom):a.includes("top")?(t.connectionStart.y=G(o).bottom,t.connectionEnd.y=G(s).top):a.includes("right")?(t.connectionStart.x=G(o).left,t.connectionEnd.x=G(s).right):(t.connectionStart.x=G(o).right,t.connectionEnd.x=G(s).left)}else delete t.connectionStart,delete t.connectionEnd})}zm.$inject=["eventBus"];function vi(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}vi.prototype.getSnapOrigin=function(n){return this._snapOrigins[n]};vi.prototype.setSnapOrigin=function(n,e){this._snapOrigins[n]=e,this._snapLocations.indexOf(n)===-1&&this._snapLocations.push(n)};vi.prototype.addDefaultSnap=function(n,e){var t=this._defaultSnaps[n];t||(t=this._defaultSnaps[n]=[]),t.push(e)};vi.prototype.getSnapLocations=function(){return this._snapLocations};vi.prototype.setSnapLocations=function(n){this._snapLocations=n};vi.prototype.pointsForTarget=function(n){var e=n.id||n,t=this._targets[e];return t||(t=this._targets[e]=new Wm,t.initDefaults(this._defaultSnaps)),t};function Wm(){this._snapValues={}}Wm.prototype.add=function(n,e){var t=this._snapValues[n];t||(t=this._snapValues[n]={x:[],y:[]}),t.x.indexOf(e.x)===-1&&t.x.push(e.x),t.y.indexOf(e.y)===-1&&t.y.push(e.y)};Wm.prototype.snap=function(n,e,t,i){var r=this._snapValues[e];return r&&ZE(n[t],r[t],i)};Wm.prototype.initDefaults=function(n){var e=this;k(n||{},function(t,i){k(t,function(r){e.add(i,r)})})};var x3=1250;function Rs(n,e,t){var i=this;this._elementRegistry=n,e.on(["create.start","shape.move.start"],function(r){i.initSnap(r)}),e.on(["create.move","create.end","shape.move.move","shape.move.end"],x3,function(r){var o=r.context,s=o.shape,a=o.snapContext,l=o.target;if(!(r.originalEvent&&Mt(r.originalEvent))&&!(wr(r)||!l)){var c=a.pointsForTarget(l);c.initialized||(c=i.addSnapTargetPoints(c,s,l),c.initialized=!0),t.snap(r,c)}}),e.on(["create.cleanup","shape.move.cleanup"],function(){t.hide()})}Rs.$inject=["elementRegistry","eventBus","snapping"];Rs.prototype.initSnap=function(n){var e=this._elementRegistry,t=n.context,i=t.shape,r=t.snapContext;r||(r=t.snapContext=new vi);var o;e.get(i.id)?o=ms(i,n):o={x:n.x+ms(i).x,y:n.y+ms(i).y};var s={x:o.x-i.width/2,y:o.y-i.height/2},a={x:o.x+i.width/2,y:o.y+i.height/2};return r.setSnapOrigin("mid",{x:o.x-n.x,y:o.y-n.y}),Bi(i)||(r.setSnapOrigin("top-left",{x:s.x-n.x,y:s.y-n.y}),r.setSnapOrigin("bottom-right",{x:a.x-n.x,y:a.y-n.y})),r};Rs.prototype.addSnapTargetPoints=function(n,e,t){var i=this.getSnapTargets(e,t);return k(i,function(r){if(Bi(r)){Bi(e)&&n.add("mid",ms(r));return}if(Xe(r)){if(r.waypoints.length<3)return;var o=r.waypoints.slice(1,-1);k(o,function(s){n.add("mid",s)});return}n.add("mid",ms(r))}),!se(e.x)||!se(e.y)||this._elementRegistry.get(e.id)&&n.add("mid",ms(e)),n};Rs.prototype.getSnapTargets=function(n,e){return zp(e).filter(function(t){return!b3(t)})};function b3(n){return!!n.hidden}var _3=1250;function Ts(n,e){var t=this;n.on(["resize.start"],function(i){t.initSnap(i)}),n.on(["resize.move","resize.end"],_3,function(i){var r=i.context,o=r.shape,s=o.parent,a=r.direction,l=r.snapContext;if(!(i.originalEvent&&Mt(i.originalEvent))&&!wr(i)){var c=l.pointsForTarget(s);c.initialized||(c=t.addSnapTargetPoints(c,o,s,a),c.initialized=!0),E3(a)&&vn(i,"x",i.x),S3(a)&&vn(i,"y",i.y),e.snap(i,c)}}),n.on(["resize.cleanup"],function(){e.hide()})}Ts.prototype.initSnap=function(n){var e=n.context,t=e.shape,i=e.direction,r=e.snapContext;r||(r=e.snapContext=new vi);var o=qk(t,i);return r.setSnapOrigin("corner",{x:o.x-n.x,y:o.y-n.y}),r};Ts.prototype.addSnapTargetPoints=function(n,e,t,i){var r=this.getSnapTargets(e,t);return k(r,function(o){n.add("corner",eS(o)),n.add("corner",JE(o))}),n.add("corner",qk(e,i)),n};Ts.$inject=["eventBus","snapping"];Ts.prototype.getSnapTargets=function(n,e){return zp(e).filter(function(t){return!w3(t,n)&&!Xe(t)&&!C3(t)&&!Bi(t)})};function qk(n,e){var t=le(n),i=G(n),r={x:t.x,y:t.y};return e.indexOf("n")!==-1?r.y=i.top:e.indexOf("s")!==-1&&(r.y=i.bottom),e.indexOf("e")!==-1?r.x=i.right:e.indexOf("w")!==-1&&(r.x=i.left),r}function w3(n,e){return n.host===e}function C3(n){return!!n.hidden}function E3(n){return n==="n"||n==="s"}function S3(n){return n==="e"||n==="w"}var O3=7,k3=1e3;function Ki(n){this._canvas=n,this._asyncHide=Mi(at(this.hide,this),k3)}Ki.$inject=["canvas"];Ki.prototype.snap=function(n,e){var t=n.context,i=t.snapContext,r=i.getSnapLocations(),o={x:wr(n,"x"),y:wr(n,"y")};k(r,function(s){var a=i.getSnapOrigin(s),l={x:n.x+a.x,y:n.y+a.y};if(k(["x","y"],function(c){var u;o[c]||(u=e.snap(l,s,c,O3),u!==void 0&&(o[c]={value:u,originValue:u-a[c]}))}),o.x&&o.y)return!1}),this.showSnapLine("vertical",o.x&&o.x.value),this.showSnapLine("horizontal",o.y&&o.y.value),k(["x","y"],function(s){var a=o[s];Pe(a)&&vn(n,s,a.originValue)})};Ki.prototype._createLine=function(n){var e=this._canvas.getLayer("snap"),t=Q("path");return j(t,{d:"M0,0 L0,0"}),ne(t).add("djs-snap-line"),K(e,t),{update:function(i){se(i)?n==="horizontal"?j(t,{d:"M-100000,"+i+" L+100000,"+i,display:""}):j(t,{d:"M "+i+",-100000 L "+i+", +100000",display:""}):j(t,{display:"none"})}}};Ki.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}};Ki.prototype.showSnapLine=function(n,e){var t=this.getSnapLine(n);t&&t.update(e),this._asyncHide()};Ki.prototype.getSnapLine=function(n){return this._snapLines||this._createSnapLines(),this._snapLines[n]};Ki.prototype.hide=function(){k(this._snapLines,function(n){n.update()})};var Vk={__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",Rs],resizeSnapping:["type",Ts],snapping:["type",Ki]};var Hk={__depends__:[Vk],__init__:["bendpointSnapping","connectSnapping"],bendpointSnapping:["type",Hm],connectSnapping:["type",zm]};function So(n){br.call(this,n)}fe(So,br);So.prototype._modelingModules=[CE,ME,LE,nS,oO,sO,lO,fO,pO,mO,xO,_O,wO,kO,PO,sk,hk,vk,Ak,$k,Hk];So.prototype._modules=[].concat(So.prototype._modules,So.prototype._modelingModules);function Fx(n){let e={variables:[],rootElement:V3(n)};for(let t=n;t;t=t.$parent)R3(t,e);return e.variables}function R3(n,e){el(n,"dmn:Decision")?T3(n,e):el(n,"dmn:BusinessKnowledgeModel")?A3(n,e):el(n,"dmn:Expression")&&j3(n,e)}function T3(n,e){for(let t of n.get("informationRequirement"))M3(t,e);for(let t of n.get("knowledgeRequirement"))Wk(t,e)}function A3(n,e){for(let t of n.get("knowledgeRequirement"))Wk(t,e)}function M3(n,e){let t=n.get("requiredInput");t&&P3(t,e);let i=n.get("requiredDecision");i&&D3(i,e)}function P3(n,e){let t=qx(n,e.rootElement);if(!t)return;let i=t.get("name");i&&e.variables.push({name:i,origin:t})}function D3(n,e){let t=qx(n,e.rootElement);if(!t)return;let i=t.get("name");if(!i)return;let r={name:i,origin:t},o=t.get("decisionLogic");o&&I3(o,r,e),e.variables.push(r)}function I3(n,e,t){if(el(n,"dmn:DecisionTable")){let i=n.get("output");L3(i,e,t)}}function L3(n,e,t){if(n.length===1){let r={...zk(n[0]),name:e.name};Object.assign(e,r);return}let i=n.map(zk);e.entries=i.filter(r=>!!r.name)}function zk(n){let e={name:n.name};return n.typeRef&&(e.detail=n.typeRef),e}function Wk(n,e){let t=n.get("requiredKnowledge");t&&B3(t,e)}function B3(n,e){let t=qx(n,e.rootElement);t&&el(t,"dmn:BusinessKnowledgeModel")&&N3(t,e)}function N3(n,e){let t=n.get("name");if(!t)return;let i={name:t,origin:n},r=n.get("encapsulatedLogic");r&&$3(r,i),e.variables.push(i)}function $3(n,e,t){let r=n.get("formalParameter").map((o,s)=>{let a={name:o.get("name")||`param ${s+1}`,type:o.get("typeRef")};return a.type||delete a.type,a});Object.assign(e,{type:"function",params:r})}function j3(n,e){el(n,"dmn:FunctionDefinition")&&F3(n,e)}function F3(n,e){let t=n.get("formalParameter");for(let i of t)q3(i,e)}function q3(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 V3(n){let e=n;for(;e.$parent;)e=e.$parent;return e}function qx(n,e){let t=n.get("href");if(!t||!t.startsWith("#"))return;let i=t.slice(1);return e.get("drgElement").find(o=>o.get("id")===i)}function el(n,e){return n.$instanceOf(e)}var Qf=class{constructor(e){e.registerProvider(this)}getVariables(e,t){return e.concat(Fx(t))}};Qf.$inject=["variableResolver"];var Um=class{constructor(){this._providers=[]}registerProvider(e){this._providers.push(e)}getVariables(e){return this._providers.reduce((t,i)=>i.getVariables(t,e),[])}};var tl={__init__:["dmnVariableProvider"],dmnVariableProvider:["type",Qf],variableResolver:["type",Um]};var Oo=class{constructor(e){T(this,e),Dr(this,"businessObject",{writable:!0})}},Vx=class extends Oo{constructor(e){super(e),Dr(this,"rows",{enumerable:!0,value:this.rows||[]}),Dr(this,"cols",{enumerable:!0,value:this.cols||[]})}},pt=class extends Oo{constructor(e){super(e),Dr(this,"root",{writable:!0}),Dr(this,"cells",{enumerable:!0,value:this.cells||[]})}},mt=class extends Oo{constructor(e){super(e),Dr(this,"root",{writable:!0}),Dr(this,"cells",{enumerable:!0,value:this.cells||[]})}},ko=class extends Oo{constructor(e){super(e),Dr(this,"row",{writable:!0}),Dr(this,"col",{writable:!0})}},H3={root:Vx,row:pt,col:mt,cell:ko};function Uk(n,e){let t=H3[n];if(!t)throw new Error("unknown type "+n);return new t(e)}function Dr(n,e,t){Object.defineProperty(n,e,t)}var As=class{constructor(){this._uid=12}create(e,t={}){return t.id||(t.id=e+"_"+this._uid++),Uk(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 nl=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 Hx(this._elements)}forEach(e){Hx(this._elements).forEach(t=>e(t))}filter(e){return Hx(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")}};nl.$inject=["eventBus"];function Hx(n){return Object.keys(n).map(function(e){return n[e]})}var il=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 o=r.root.id;this.updateId(i,o)})}),e.on("element.updateId",({element:t,newId:i})=>{this.updateId(t.id,i)})}elementsChanged(e){let t={},i=e.length;for(let r=0;r<i;r++){let{id:o}=e[r];if(t[o])return;t[o]=!0;let s=this._listeners[o]&&this._listeners[o].length;if(s)for(let a=0;a<s;a++)this._listeners[o][a]&&this._listeners[o][a]()}}onElementsChanged(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e][this._listeners[e].length]=t}offElementsChanged(e,t){if(this._listeners[e])if(t){let i=this._listeners[e].indexOf(t);i!==-1&&this._listeners[e].splice(i,1)}else this._listeners[e].length=0}updateId(e,t){this._listeners[e]&&(this._listeners[t]=this._listeners[e],delete this._listeners[e])}};il.$inject=["eventBus"];var z3=1e3,Kf=class{constructor(){this._listeners={}}getComponent(e,t){let i=this._listeners[e];if(!i)return;let r;for(let o=0;o<i.length&&(r=i[o].callback(t),!r);o++);return r}getComponents(e,t){let i=this._listeners[e],r=[];if(!i)return r;for(let o=0;o<i.length;o++){let s=i[o].callback(t);s&&r.push(s)}return r.length,r}onGetComponent(e,t,i){if(ge(t)&&(i=t,t=z3),!se(t))throw new Error("priority must be a number");let r=this._getListeners(e),o,s,a={priority:t,callback:i};for(s=0;o=r[s];s++)if(o.priority<t){r.splice(s,0,a);return}r.push(a)}offGetComponent(e,t){let i=this._getListeners(e),r,o,s;if(t)for(s=i.length-1;r=i[s];s--)o=r.callback,o===t&&i.splice(s,1);else i.length=0}_getListeners(e){let t=this._listeners[e];return t||(this._listeners[e]=t=[]),t}};var Gf=class extends L{constructor(e){super(e);let t=this._injector=e.injector;this._sheet=t.get("sheet"),this._changeSupport=t.get("changeSupport"),this._components=t.get("components"),this._eventBus=t.get("eventBus");let i=t.get("throttle");this.onElementsChanged=this.onElementsChanged.bind(this),this.onScroll=i(this.onScroll.bind(this))}onElementsChanged(){this.forceUpdate()}onScroll(){this._eventBus.fire("sheet.scroll")}getChildContext(){return{changeSupport:this._changeSupport,components:this._components,injector:this._injector}}componentWillMount(){let{id:e}=this._sheet.getRoot();this._changeSupport.onElementsChanged(e,this.onElementsChanged)}componentWillUnmount(){let{id:e}=this._sheet.getRoot();this._changeSupport.offElementsChanged(e,this.onElementsChanged)}render(){let{rows:e,cols:t}=this._sheet.getRoot(),i=this._components.getComponents("table.before"),r=this._components.getComponents("table.after"),o=this._components.getComponent("table.head"),s=this._components.getComponent("table.body"),a=this._components.getComponent("table.foot");return y(1,"div","tjs-container",[i&&i.map((l,c)=>P(2,l,null,c)),y(1,"div","tjs-table-container",y(1,"table","tjs-table",[o&&P(2,o,{rows:e,cols:t}),s&&P(2,s,{rows:e,cols:t}),a&&P(2,a,{rows:e,cols:t})],0),2,{onScroll:this.onScroll}),r&&r.map((l,c)=>P(2,l,null,c))],0)}};var rl=class{constructor(e,t,i,r,o){let{container:s}=i;this._container=s,r.on("root.added",()=>{xa(P(2,Gf,{injector:o}),s)}),r.on("root.remove",()=>{xa(null,s)})}getContainer(){return this._container}};rl.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var Qm={__init__:["changeSupport","components","renderer"],changeSupport:["type",il],components:["type",Kf],renderer:["type",rl]};var ol=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),Km(t,i.rows,e),e.root=i,this._elementRegistry.add(e),e.cells.forEach((r,o)=>{this._elementRegistry.add(r),r.row=e,r.col=i.cols[o],Km(t,i.cols[o].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&&(Gm(i,t.rows),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach((r,o)=>{this._elementRegistry.remove(r),r.col=void 0,Gm(i,t.cols[o].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),Km(t,i.cols,e),e.root=i,e.cells.forEach((r,o)=>{this._elementRegistry.add(r),r.col=e,r.row=i.rows[o],Km(t,i.rows[o].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&&(Gm(i,t.cols),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach((r,o)=>{this._elementRegistry.remove(r),r.row=void 0,Gm(i,t.rows[o].cells)}),this._eventBus.fire("col.remove",{col:e}))}resized(){this._eventBus.fire("sheet.resized")}};ol.$inject=["elementRegistry","eventBus"];function Km(n,e,t){return e.splice(n,0,t)}function Gm(n,e){return e.splice(n,1)}function Xm(n=!0){let e=typeof n=="number"?n:n?300:0;return e?t=>Nw(t,e):t=>t}Xm.$inject=["config.throttle"];var Qk={__depends__:[Qm],__init__:["elementFactory","sheet"],elementFactory:["type",As],elementRegistry:["type",nl],eventBus:["type",ut],sheet:["type",ol],throttle:["factory",Xm]};var Xf=class{constructor(e={}){let{injector:t}=e;if(!t){let{modules:i,config:r}=this._init(e);t=W3(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 W3(n,e){let t=[{config:["value",n]},Qk].concat(e||[]),i=new os(t);return i.init(),i}var Kk=Xf;function Ym(n){if(!n)return"<null>";let e=n.id?` id="${n.id}"`:"";return`<${n.$type}${e} />`}function zx(n,e){function t(l,c,u){var f=l.gfx;if(f)throw new Error(`already rendered ${Ym(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 ${Ym(c)}`);let u=i(c);c.input&&o(c.input,u,c),o(c.output,u,c),s(c.rule,u,c)}else throw new Error(`no table for ${Ym(l)}`)}function o(l,c,u){k(l,function(f){t(f,c,u)})}function s(l,c,u){k(l,function(f){t(f,c,u),a(f.inputEntry,f),a(f.outputEntry,f)})}function a(l,c,u){k(l,function(f){t(f,c,u)})}return{handleDecision:r}}function Gk(n,e,t){let i=n.get("tableImporter"),r=n.get("eventBus"),o=n.get("sheet"),s=n.get("modeling",!1),a,l=[];function c(u){let f={create(d,p,m,g){return i.create(d,p,m,g)},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 zx(f,{canAddMissingEntries:s}).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:[o.getRoot()]}),t(a,l)}function U3(){return{elements:[],index:{}}}function Xk(n,e){let{elements:t,index:i}=n;return i[e]?n:{elements:[...t,e],index:{...i,[e]:!0}}}function Q3(n,e){return n.elements.join(e)}function Ro(...n){let e=U3();return n.forEach(function(t){let i=typeof t;i==="string"&&t.length>0?e=Xk(e,t):i==="object"&&t!==null&&Object.keys(t).forEach(function(r){t[r]&&(e=Xk(e,r))})}),Q3(e," ")}function Ce(n){let e=n.constructor;return Zm(e,n)}function Zm(n,e){let t=n.$inject;if(!t)return;let{injector:i}=e.context,r=[...t,function(...o){for(let s in o){let a=t[s],l=o[s];e[a]=l}}];i.invoke(r)}function Wx(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 Ut(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]=Wx(n,r,i)}else n[t]=i.bind(n)}),"$inject"in e&&Zm(e,n),"__init"in e&&e.__init.call(n,n.props,n.context)}var Yk={getSelectionClasses(){let{selected:n,selectedSecondary:e,focussed:t}=this.state;return Ro({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)}},Yf=Yk;Yk.$inject=["eventBus"];var Zf=class extends L{constructor(e,t){super(e,t),Ut(this,Yf),Ce(this)}getRenderProps(...e){let{className:t,elementId:i,coords:r,...o}=this.props,s={className:Ro(...e,this.getSelectionClasses(),t)};return i&&(s["data-element-id"]=i),r&&(s["data-coords"]=r),{...s,...o}}};var Rn=class extends Zf{constructor(e,t){super(e,t),this.state={}}render(){let{children:e}=this.props,t=this.getRenderProps("cell");return En(y(1,"td",null,e,0,{...t}))}};var Zk={slotFill(n,e){let{type:t,context:i,...r}=n,o=this.components.getComponent(t,i)||e;return o?En(P(2,o,{...i,...r})):null},slotFills(n){let{type:e,context:t,...i}=n;return this.components.getComponents(e,t).map(o=>En(P(2,o,{...t,...i})))}},xi=Zk;Zk.$inject=["components"];var Jk=400,To=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});Ut(this,xi),Ce(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")||Jk)+"px";return y(1,"th","annotation header",[this.slotFills({type:"cell-inner",context:{cellType:"annotations",col:this.sheet.getRoot(),minWidth:Jk}}),this.translate("Annotations")],0,{style:{width:r}})}};To.$inject=["changeSupport","sheet","translate"];function Ux(n){let{row:e}=n,{id:t,description:i}=e.businessObject;return P(2,Rn,{className:"annotation",elementId:t,children:i||"-"})}function Jm(n){n.onGetComponent("cell",({cellType:e})=>{if(e==="after-label-cells")return To;if(e==="after-rule-cells")return Ux})}Jm.$inject=["components"];var eR={__init__:["annotationsProvider"],annotationsProvider:["type",Jm]};function Jf(n,e){return T({id:n.id,type:n.$type,businessObject:n},e)}var sl=class{constructor(e,t,i){this._elementFactory=e,this._eventBus=t,this._sheet=i}add(e){let t;if(O(e,"dmn:DecisionTable"))t=this._elementFactory.createRoot(Jf(e)),this._sheet.setRoot(t);else if(O(e,"dmn:InputClause"))t=this._elementFactory.createCol(Jf(e)),this._sheet.addCol(t);else if(O(e,"dmn:OutputClause"))t=this._elementFactory.createCol(Jf(e)),this._sheet.addCol(t);else if(O(e,"dmn:DecisionRule")){e.inputEntry||(e.inputEntry=[]),e.outputEntry||(e.outputEntry=[]);let i=[...e.inputEntry,...e.outputEntry].map(r=>this._elementFactory.createCell(Jf(r)));t=this._elementFactory.createRow(T(Jf(e),{cells:i})),this._sheet.addRow(t)}return this._eventBus.fire("dmnElement.added",{element:t}),t}};sl.$inject=["elementFactory","eventBus","sheet"];var tR={__depends__:[qe],tableImporter:["type",sl]};var nR={__depends__:[tR,Qm]};var eh=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});Ut(this,xi),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(!O(t,"dmn:DMNElement"))return null;let i=Ke(t),r=i.input,o=i.output;return y(1,"thead",null,y(1,"tr",null,[y(1,"th","index-column"),this.slotFills({type:"cell",context:{cellType:"before-label-cells"}}),r&&r.map((s,a)=>{let l=s.width||"192px";return this.slotFill({type:"cell",context:{cellType:"input-header",input:s,index:a,inputsLength:r.length,width:l},key:s.id},K3)}),o.map((s,a)=>this.slotFill({type:"cell",context:{cellType:"output-header",output:s,index:a,outputsLength:o.length},key:s.id},G3)),this.slotFills({type:"cell",context:{cellType:"after-label-cells"}})],0),2)}};function K3(n,e){let{input:t,className:i,index:r}=n,{label:o,inputExpression:s,inputValues:a}=t,l=e.injector.get("translate"),c=(i||"")+" input-cell";return y(1,"th",c,[y(1,"div","clause",l(r===0?"When":"And"),0),o?y(1,"div","input-label",o,0,{title:l("Input label: ")+o}):y(1,"div","input-expression",s.text,0,{title:l("Input expression: ")+s.text}),y(1,"div","input-variable",a&&a.text||s.typeRef,0,{title:a&&a.text?l("Input values"):l("Input type")})],0,{"data-col-id":t.id},t.id)}function G3(n,e){let{output:t,className:i,index:r}=n,{label:o,name:s,outputValues:a,typeRef:l}=t,c=e.injector.get("translate"),u=(i||"")+" output-cell";return y(1,"th",u,[y(1,"div","clause",c(r===0?"Then":"And"),0),o?y(1,"div","output-label",o,0,{title:c("Output label")}):y(1,"div","output-name",s,0,{title:c("Output name")}),y(1,"div","output-variable",a&&a.text||l,0,{title:a&&a.text?c("Output values"):c("Output type")})],0,null,t.id)}function eg(n){n.onGetComponent("table.head",()=>eh)}eg.$inject=["components"];var iR={__init__:["decisionTableHeadProvider"],decisionTableHeadProvider:["type",eg]};var al=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),Ce(this)}render(){let e=this.sheet.getRoot();if(!O(e,"dmn:DMNElement"))return null;let{name:t}=e.businessObject.$parent,i=this.components.getComponent("hit-policy")||X3;return y(1,"div","decision-table-properties",[y(1,"div","decision-table-name",t,0,{title:this._translate("Decision name: ")+t}),y(1,"div","decision-table-header-separator"),P(2,i)],4)}};al.$inject=["sheet","components"];function X3(){return null}var Y3=500,ll=class{constructor(e){e.onGetComponent("table.before",Y3,()=>al)}};ll.$inject=["components"];var rR={__init__:["decisionTableProperties"],decisionTableProperties:["type",ll]};var th=class extends L{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 y(1,"td","rule-index",[r&&r.map(o=>P(2,o,{row:e,rowIndex:t})),t+1],0,{"data-element-id":e.id,"data-row-id":e.id})}};var cl=class{constructor(e){e.onGetComponent("cell",({cellType:t})=>{if(t==="before-rule-cells")return th})}};cl.$inject=["components"];var oR={__init__:["decisionRuleIndices"],decisionRuleIndices:["type",cl]};var Z3=[{label:"FEEL",value:"feel"}],ul=class{constructor(e){this._injector=e;let t=e.get("config.expressionLanguages")||{};this._config={options:Z3,defaults:{editor:"feel"}},t.options&&(this._config.options=t.options);let i=this._getLegacyDefaults();T(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 ye(this.getAll(),t=>e===t.value)}};ul.$inject=["injector"];var Qt={__init__:["expressionLanguages"],expressionLanguages:["type",ul]};var fl=class{constructor(e){this._feelLanguageContext=e}getConfig(){return this._feelLanguageContext}};fl.$inject=["config.feelLanguageContext"];var Yn={__init__:["feelLanguageContext"],feelLanguageContext:["type",fl]};var nh=class extends L{render({rows:e,cols:t}){let{components:i}=this.context;return y(1,"tbody",null,e.map((r,o)=>{let s=i.getComponent("row",{rowType:"rule"});return s&&P(2,s,{row:r,rowIndex:o,cols:t},r.id)}),0)}};var ih=class extends L{constructor(e,t){super(e,t),Ut(this,xi)}render(){let{row:e,rowIndex:t,cols:i}=this.props,{cells:r}=e;return y(1,"tr",null,[this.slotFills({type:"cell",context:{cellType:"before-rule-cells",row:e,rowIndex:t}}),r.map((o,s)=>this.slotFill({type:"cell",context:{cellType:"rule",cell:o,rowIndex:t,colIndex:s},key:o.id,row:e,col:i[s]})),this.slotFills({type:"cell",context:{cellType:"after-rule-cells",row:e,rowIndex:t}})],0)}};var rh=class extends L{render(){let{cell:e,row:t,col:i}=this.props;return O(e,"dmn:UnaryTests")?P(2,Rn,{className:"input-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":i.id,children:e.businessObject.text}):P(2,Rn,{className:"output-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":i.id,children:e.businessObject.text})}};var hl=class{constructor(e){e.onGetComponent("table.body",()=>nh),e.onGetComponent("row",({rowType:t})=>{if(t==="rule")return ih}),e.onGetComponent("cell",({cellType:t})=>{if(t==="rule")return rh})}};hl.$inject=["components"];var tg={__depends__:[Qt,Yn],__init__:["decisionRules"],decisionRules:["type",hl]};var oh=[{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 dl=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),Ce(this)}getRoot(){return this.sheet.getRoot()}render(){let e=this.getRoot(),t=e.businessObject,{aggregation:i,hitPolicy:r}=t,o=ye(oh,s=>J3(s.value,{aggregation:i,hitPolicy:r}));return y(1,"div","hit-policy header",[y(1,"label","dms-label",this._translate("Hit policy:"),0),y(1,"span","hit-policy-value",this._translate(o.label),0)],4,{title:this._translate(o.explanation)})}};dl.$inject=["sheet"];function J3(n,e){return n.hitPolicy===e.hitPolicy&&n.aggregation===e.aggregation}function ng(n){n.onGetComponent("hit-policy",()=>dl)}ng.$inject=["components"];var sR={__init__:["hitPolicyProvider"],hitPolicyProvider:["type",ng]};var sh=class extends L{constructor(t,i){super(t,i);M(this,"onClick",()=>{this._eventBus.fire("showDrd")});let{injector:r}=i;this._translate=r.get("translate"),this._eventBus=r.get("eventBus")}render(){return y(1,"div","view-drd",y(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,t=>this.node=t)}};var pl=class{constructor(e,t,i,r){this._injector=i,this._sheet=r,e.onGetComponent("table.before",()=>{if(this.canViewDrd())return sh}),t.on("showDrd",()=>{let o=i.get("_parent",!1),s=r.getRoot(),a=aR(s);if(!a)return;let l=o.getView(a);o.open(l)})}canViewDrd(){let e=this._injector.get("_parent",!1);if(!e)return!1;let t=this._sheet.getRoot(),i=aR(t);return!!e.getView(i)}};pl.$inject=["components","eventBus","injector","sheet"];function aR(n){let{businessObject:e}=n;return e?e.$parent.$parent:void 0}var lR={__init__:["viewDrd"],viewDrd:["type",pl]};var ml=class{constructor(e){e.onGetComponent("table.before",()=>co)}};ml.$inject=["components"];var cR={__init__:["poweredBy"],poweredBy:["type",ml]};var Ao=class n extends Kk{constructor(e={}){let t=n._createContainer();super(T(e,{renderer:{container:t}})),this._container=t}open(e){var t=this;return new Promise((i,r)=>{var o;try{return t._decision&&t.clear(),t._decision=e,Gk(t,e,function(s,a){s?(s.warnings=a||[],r(s)):i({warnings:a||[]})})}catch(s){o=s}o?(o.warnings=o.warnings||[],r(o)):i({warnings:[]})})}_init(e){let{modules:t,additionalModules:i,...r}=e,o=t||this.getModules(),s=i||[],a=[{decisionTable:["value",this]}];return{modules:[cR,...o,...s,...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",{}),Qe(e))}destroy(){super.destroy(),this.detach()}getModules(){return n._getModules()}static _getModules(){return[eR,nR,qe,iR,rR,oR,tg,sR,lR]}static _createContainer(){return te('<div class="dmn-decision-table-container"></div>')}};var gl=class extends L{constructor(t,i){super(t,i);M(this,"handleClick",t=>{t.stopPropagation(),this.addRule(t.target.dataset.colIndex)});Ce(this),this.addRule=this.addRule.bind(this)}componentWillMount(){this._eventBus=this.context.injector.get("eventBus")}addRule(t){this._eventBus.fire("addRule",{colIndex:t})}render(){let{cols:t}=this.props,i=[y(1,"td","add-rule-add",y(1,"button","dmn-icon-plus action-icon",null,1,{title:this.translate("Add rule")}),2)],{businessObject:r}=this.sheet.getRoot();(!r.input||!r.input.length)&&i.push(y(1,"td","input-cell",Z("-"),2));for(let o=0;o<t.length+1;o++){let s="add-rule",a=t[o]&&t[o].businessObject,l="";a?(a.$instanceOf("dmn:InputClause")&&(s+=" input-cell",l="-"),a.$instanceOf("dmn:OutputClause")&&(s+=" output-cell")):s+=" annotation",i.push(y(1,"td",s,l,0,{"data-col-index":o}))}return y(1,"tfoot","actionable add-rule",y(1,"tr",null,i,0),2,{onClick:this.handleClick})}};gl.$inject=["sheet","translate"];var yl=class{constructor(e,t,i,r){e.onGetComponent("table.foot",()=>gl),i.on("addRule",(o,s)=>{let a=t.trigger("addRule"),l=s.colIndex;a.cells[l]?r.select(a.cells[l]):r.select(a.cells[0])})}};yl.$inject=["components","editorActions","eventBus","selection"];var vl=class{constructor(e,t,i){this._elementRegistry=e,this._eventBus=t,this._renderer=i,this._selection=void 0,t.on("diagram.clear",()=>{this._selection=void 0})}select(e){Ie(e)&&(e=this._elementRegistry.get(e));let t=this._selection;t!==e&&(this._selection=e,this._eventBus.fire("selection.changed",{oldSelection:t,selection:e}))}deselect(){let e=this._selection;this._selection=void 0,this._eventBus.fire("selection.changed",{oldSelection:e,selection:this._selection})}get(){return this._selection}hasSelection(){return!!this._selection}};vl.$inject=["elementRegistry","eventBus","renderer"];var xl=class{constructor(e,t,i,r){this._elementRegistry=e,this._renderer=i,this._selection=r,t.on(["cell.click","cell.contextmenu"],({id:o})=>{let s=e.get(o);s&&r.select(s)}),t.on("row.remove",({row:o})=>{let s=r.get();s&&o===s.row&&r.deselect()}),t.on("col.remove",({col:o})=>{let s=r.get();s&&o===s.col&&r.deselect()})}};xl.$inject=["elementRegistry","eventBus","renderer","selection"];var Mo={__init__:["selection","selectionBehavior"],selection:["type",vl],selectionBehavior:["type",xl]};function e5(n,e,t){return(e=t5(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function t5(n){var e=n5(n,"string");return typeof e=="symbol"?e:e+""}function n5(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var uR=["click","dblclick","contextmenu","mousedown","mouseup","mouseenter","mouseleave","mouseout","mouseover","mousemove","focusin","focusout","drag","dragstart","dragend","dragover","dragenter","dragleave","drop"],bl=class{constructor(e,t){e5(this,"_handleEvent",i=>{let{target:r,type:o}=i,s=i5(r);if(!s)return;let a=s.getAttribute("data-element-id");if(a){let l=this._eventBus.createEvent({id:a,event:i,node:s,target:s});this._eventBus.fire(`cell.${o}`,l),l.defaultPrevented&&i.preventDefault(),l.cancelBubble&&i.stopPropagation()}}),this._eventBus=t,this._container=e.container,t.on("table.init",()=>{this._addEventListeners(uR)}),t.on("table.destroy",()=>{this._removeEventListeners(uR)})}_addEventListeners(e){let t=this._container;e.forEach(i=>{t.addEventListener(i,this._handleEvent)})}_removeEventListeners(e){let t=this._container;e.forEach(i=>{t.removeEventListener(i,this._handleEvent)})}};bl.$inject=["config.renderer","eventBus"];function i5(n){return De(n,"[data-element-id]",!0)}var _l={__init__:["interactionEvents"],interactionEvents:["type",bl]};var Jx=Pw(hR());function r5(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Kx,dR;function o5(){if(dR)return Kx;dR=1,Kx=n;function n(e,t){return e^t}return Kx}var Gx,pR;function s5(){if(pR)return Gx;pR=1;var n=/\b(Array|Date|Object|Math|JSON)\b/g;Gx=function(o,s){var a=i(e(o));return s&&typeof s=="string"&&(s=r(s)),s?t(o,a,s):a};function e(o){return o.replace(/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\//g,"").replace(n,"").match(/[a-zA-Z_]\w*/g)||[]}function t(o,s,a){var l=/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g;return o.replace(l,function(c){return c[c.length-1]=="("||~s.indexOf(c)?a(c):c})}function i(o){for(var s=[],a=0;a<o.length;a++)~s.indexOf(o[a])||s.push(o[a]);return s}function r(o){return function(s){return o+s}}return Gx}var Xx,mR;function a5(){if(mR)return Xx;mR=1;var n=o5(),e=s5();Xx=t;function t(r,o){if(!(this instanceof t))return new t(r,o);if(this.node=this.start=this.peeked=r,this.root=o,this.closingTag=!1,this._revisit=!0,this._selects=[],this._rejects=[],r&&this.higher(r))throw new Error("root must be a parent or ancestor to node")}t.prototype.reset=function(r){return this.node=r||this.start,this},t.prototype.revisit=function(r){return this._revisit=r==null?!0:r,this},t.prototype.opening=function(){return this.node.nodeType==1&&(this.closingTag=!1),this},t.prototype.atOpening=function(){return!this.closingTag},t.prototype.closing=function(){return this.node.nodeType==1&&(this.closingTag=!0),this},t.prototype.atClosing=function(){return this.closingTag},t.prototype.next=i("nextSibling","firstChild"),t.prototype.previous=t.prototype.prev=i("previousSibling","lastChild");function i(r,o){var s=r=="nextSibling";return function(l,c,u){l=this.compile(l),c=c&&c>0?c:1;for(var f=this.node,h=this.closingTag,d=this._revisit;f;){if(n(s,h)&&f[o])f=f[o],h=!s;else if(f.nodeType==1&&!f[o]&&n(s,h)){if(h=s,!d)continue}else if(f[r])f=f[r],h=!s;else if(f=f.parentNode,h=s,!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,o){var s=this._selects,a=s.length;if(!a)return!0;for(var l=0;l<a;l++)if(s[l].call(this,r,o))return!0;return!1},t.prototype.reject=function(r){return r=this.compile(r),this._rejects.push(r),this},t.prototype.rejects=function(r,o){var s=this._rejects,a=s.length;if(!a)return!0;for(var l=0;l<a;l++)if(s[l].call(this,r,o))return!1;return!0},t.prototype.higher=function(r){var o=this.root;if(!o)return!1;for(r=r.parentNode;r&&r!=o;)r=r.parentNode;return r!=o},t.prototype.compile=function(r){switch(typeof r){case"number":return function(o){return r==o.nodeType};case"string":return new Function("node","Object.freeze(node); return "+e(r,"node."));case"function":return r;default:return function(){return!0}}},t.prototype.peak=t.prototype.peek=function(r,o){return arguments.length==1&&(o=r,r=!0),o=o==null?1:o,o?o>0?this.next(r,o,!0):this.prev(r,Math.abs(o),!0):this.node},t.prototype.use=function(r){return r(this),this},Xx}var l5=a5(),gR=r5(l5),Zn=window.getSelection();function Zx(n){Zn==null||Zn.removeAllRanges(),Zn==null||Zn.addRange(n)}function yR(){return Zn}function c5(n){if(!(Zn!=null&&Zn.rangeCount))return null;var e=Zn.focusNode;return ig(e)&&(e=e.parentNode),n==e||n.contains(e)}function rg(n,e){var t=u5(n,e);Zx(t)}function wl(n){if(!c5(n))return null;var e=Zn.getRangeAt(0),t=e.startContainer,i=e.endContainer,r=e.startOffset,o=e.endOffset,s=gR(n.firstChild,n),a=s.node,l,c=!1,u,f=0;function h(p,m){return arguments.length===1&&(m=p),p.parentNode===i&&m==i.childNodes[o]}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)||Yx(a)&&i===a));){if(c||(Yx(a)||l&&l.nextSibling==a&&(vR(a)||xR(a)))&&f++,ig(a)){if(t===a&&(u=f+r),i===a){f+=o;break}f+=a.textContent.length}if((ig(a)||c)&&(d(a,a.nextSibling)&&(u=f),h(a,a.nextSibling)))break;l=a,a=s.next(),c=s.closingTag}return{start:typeof u=="undefined"?f:u,end:f}}function u5(n,e){for(var t=e.start,i=e.end,r=document.createRange(),o=gR(n.firstChild,n),s=o.node,a=!1,l=0,c;s;){if(l===t&&(a?r.setStartAfter(s):r.setStartBefore(s)),l===i)return a?r.setEndAfter(s):r.setEndBefore(s),r;if(a||(Yx(s)||s.previousSibling&&(vR(s)||xR(s)))&&l++,ig(s)){if(c=s.textContent.length,l<=t&&l+c>t&&r.setStart(s,t-l),l+c>i)return r.setEnd(s,i-l),r;l+=c}s=o.next(),a=o.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 ig(n){return n.nodeType===3}function Yx(n){return n.nodeType===1&&n.nodeName==="BR"}function vR(n){return n.nodeType===1&&n.nodeName==="DIV"}function xR(n){return n.nodeType===1&&n.nodeName==="P"}var f5="[contenteditable]",h5="[data-element-id]";function ah(n){return n.getAttribute("data-element-id")}function bR(n){let e=n.getAttribute("data-coords");if(!e)return null;let[t,i]=e.split(":");return{row:t,col:i}}function _R(n,e){let t=`${n.row}:${n.col}`;return X(`[data-coords="${(0,Jx.default)(t)}"]`,e)}function Gi(n,e){return X(`[data-element-id="${(0,Jx.default)(n)}"]`,e)}function wR(n){return De(n,".no-deselect",!0)}function lh(n){return De(n,h5,!0)}function e0(n){let e=f5;return hr(n,e)?n:X(e,n)}function CR(n){let e=e0(n);if(!e||!document.body.contains(e)||document.activeElement===e)return;e.focus();let t=wl(e);(!t||t.end===0)&&window.getSelection().setPosition(e.firstChild,e.firstChild.length)}var t0=500,d5={above:!0,below:!0,right:!0,left:!0};function og(n,e,t,i,r){let{container:o}=n,s=null;function a(h,d){e.fire("selection."+h+".changed",d),e.fire("cellSelection.changed",{elementId:h,selection:d})}function l(h){let d=h.target;if(wR(d))return;let p=lh(d),m=p&&ah(p),g=!h.defaultPrevented;f(m,g)}function c(h){let d=ah(h.target),p=!h.defaultPrevented;return h.stopPropagation(),f(d,p)}function u(h){let d=ah(h.target);a(d,{focussed:!1})}function f(h,d=!0){s!==h&&a(s,{selected:!1,focussed:!1}),s=h,h&&a(h,{selected:!0,focussed:d}),h?i.select(h):i.deselect()}e.on("cell.click",t0,l),e.on("cell.focusin",t0,c),e.on("cell.focusout",t0,u),e.on("cellSelection.changed",function(h){let{elementId:d,selection:p}=h,m=Gi(d,o);p.focussed&&m&&CR(m)}),e.on("selection.changed",function(h){let{selection:d,oldSelection:p}=h;var m=d&&d.id,g=p&&p.id;m&&m!==s?f(d.id):g&&g===s&&f()}),this.isCellSelected=function(){return!!s},this.getCellSelection=function(){return s},this.selectCell=function(h){if(!s)return;if(!(h in d5))throw new Error("direction must be any of { above, below, left, right }");var d=Gi(s,o);let p=bR(d);if(!p)return!1;let m=p5(p,h),g=_R(m,o);if(!g)return!1;let b=ah(g);return b&&f(b,{focussed:!0,selected:!0}),!0},e.on("contextMenu.close",function(){if(s)return f(s)})}og.$inject=["config.renderer","eventBus","sheet","selection","elementRegistry"];function p5(n,e){let{row:t,col:i}=n;if(e==="above"||e==="below"){let r=parseInt(t,10);if(isNaN(r))return n;let o=e==="above"?r-1:r+1;return{col:i,row:o}}if(e==="left"||e==="right"){let r=parseInt(i,10);if(isNaN(r))return n;let o=e==="left"?r-1:r+1;return{row:t,col:o}}throw new Error("invalid direction <"+e+">")}var Po={__depends__:[_l,Mo],__init__:["cellSelection"],cellSelection:["type",og]};function Ms(){}Ms.prototype.get=function(){return this._data};Ms.prototype.set=function(n){this._data=n};Ms.prototype.clear=function(){var n=this._data;return delete this._data,n};Ms.prototype.isEmpty=function(){return!this._data};var sg={clipboard:["type",Ms]};var n0=2e3,Cl=class extends Vi{constructor(e,t){super(e),this._sheet=t}init(){this.addRule("col.move",n0,({col:e,index:t})=>{let{businessObject:i}=this._sheet.getRoot(),{input:r}=i;return ie(e)?t<r.length:t>=r.length}),this.addRule("col.remove",n0,({col:e})=>{let{cols:t}=this._sheet.getRoot();return Te(e)?t.filter(i=>Te(i)).length>1:!0}),this.addRule("paste",n0,({data:e,target:t})=>{if(!e||!t)return!1;let{root:i}=e;return t instanceof pt?this.canPasteRows(i):t instanceof mt?this.canPasteCols(i,t):!1})}canPasteRows(e){let{cols:t}=this._sheet.getRoot();return kt(e,i=>i.type!=="row"||i.cells.length!==t.length?!1:kt(i.cells,(r,o)=>ie(t[o])?r.businessObject.$type==="dmn:UnaryTests":r.businessObject.$type==="dmn:LiteralExpression"))}canPasteCols(e,t){let{rows:i}=this._sheet.getRoot();return kt(e,r=>r.type!=="col"||r.cells.length!==i.length?!1:ie(t)?r.businessObject.$type==="dmn:InputClause":r.businessObject.$type==="dmn:OutputClause")}};Cl.$inject=["eventBus","sheet"];var ER={__depends__:[yn]};var El={__depends__:[ER],__init__:["decisionTableModelingRules"],decisionTableModelingRules:["type",Cl]};var Sl=class{constructor(e,t,i){this._clipboard=e,this._modeling=t,this._sheet=i}execute(e){let{data:t}=e;return e.oldData=this._clipboard.get(),this._clipboard.set(t),this._sheet.getRoot()}postExecute(e){let{elements:t}=e;t.forEach(i=>{i instanceof pt?this._modeling.removeRow(i):i instanceof mt&&this._modeling.removeCol(i)})}revert(e){let{oldData:t}=e;return this._clipboard.set(t),this._sheet.getRoot()}};Sl.$inject=["clipboard","modeling","sheet"];var m5=[x5,b5],g5=[S5,E5];function ag(n,e,t){return t=t||m5,e=e||{},F(n)?y5(n,e,t):SR(n,e,t)}function y5(n,e,t){return st(n,(i,r)=>{var o=i.descriptorCache,s=i.root;let{root:a,descriptorCache:l}=SR(r,o,t);return{root:[...s,a],descriptorCache:{...o,...l}}},{root:[],descriptorCache:e})}function SR(n,e,t){var i=n.id,r={id:i},o=e.elements||{},s=o[i];if(s)return{root:s,descriptorCache:e};let a=v5(n,r,t,{...e,elements:o});return{root:a.root,descriptorCache:{...a.descriptorCache,elements:{...a.descriptorCache.elements,[i]:a.root}}}}function v5(n,e,t,i){function r(o,s){return ag(o,s,t)}return st(t,function(o,s){return s(n,o.root,o.descriptorCache,r)},{root:e,descriptorCache:i})}function x5(n,e,t,i){var r=t,o={...e,type:_5(n)};if(n instanceof pt||n instanceof mt){let s=i(n.cells,r);o.cells=s.root,r=s.descriptorCache}return{root:o,descriptorCache:r}}function b5(n,e,t){var i=n.businessObject;if(!i)return{root:e,descriptorCache:t};var r=i0(i,t);return{root:{...e,businessObject:r.root},descriptorCache:r.descriptorCache}}function _5(n){if(n instanceof pt)return"row";if(n instanceof mt)return"col";if(n instanceof ko)return"cell";throw new Error("cannot deduce element type: #"+n.id)}function i0(n,e){var t,i,r=n.id;if(r&&(t=e.boCache||{},i=t[r],i))return{root:i,descriptorCache:e};var o={$type:n.$type};return r&&(o.id=r,t={...t,[r]:o},e={...e,boCache:t}),n.$descriptor.properties.forEach(function(s){var a=n[s.name];if(a){if(F(a)&&(a=a.map(l=>{var c=i0(l,e);return e=c.descriptorCache,c.root})),a.$type){let l=i0(a,e);e=l.descriptorCache,a=l.root}o[s.name]=a}}),{root:o,descriptorCache:e}}function o0(n,e,t){return t=t||g5,e=e||{},F(n.root)?w5(n,e,t):OR(n,e,t)}function w5(n,e,t){let i=n.root,r=n.descriptorCache;return st(i,(o,s)=>{var a=o.reviveCache,l=o.root;let{root:c,reviveCache:u}=OR({root:s,descriptorCache:r},a,t);return{root:[...l,c],reviveCache:u}},{root:[],reviveCache:e})}function OR(n,e,t){var i=n.root,r=i.id,o=e.elements||{},s=o[r];if(s)return{root:s,reviveCache:e};var a={id:r};let l=C5(n,a,t,{...e,elements:o});return{root:l.root,reviveCache:{...l.reviveCache,elements:{...l.reviveCache.elements,[r]:l.root}}}}function C5(n,e,t,i){function r(o,s){return o0(o,s,t)}return st(t,function(o,s){return s(n,o.root,o.reviveCache,r)},{root:e,reviveCache:i})}function E5(n,e,t,i){var r=n.root,o=n.descriptorCache,s={...e};if(e.businessObject&&e.businessObject.id&&(s.id=e.businessObject.id),r.type==="row"||r.type==="col"){let c=i({root:r.cells,descriptorCache:o},t);s.cells=c.root,t=c.reviveCache}var a=O5(r),l=new a(s);return l instanceof pt?l.cells.forEach(c=>{c.row=l}):l instanceof mt&&l.cells.forEach(c=>{c.col=l}),{root:l,reviveCache:t}}function S5(n,e,t){var i=n.root.businessObject;if(!i)return{root:e,reviveCache:t};var r=r0({root:i,descriptorCache:n.descriptorCache},t);return{root:{...e,businessObject:r.root},reviveCache:r.reviveCache}}function O5(n){switch(n.type){case"row":return pt;case"cell":return ko;case"col":return mt;default:throw new Error("unknown element type: #"+n.type)}}function r0(n,e){var t=n.root,i=t.id;let r,o;if(i&&(r=e.boCache||{},o=r[i],o))return{root:o,reviveCache:e};var s={};di(t).forEach(c=>{let u,f;t[c].$type?(f=r0({root:t[c]},e),u=f.root,e=f.reviveCache,r=e.boCache||{}):F(t[c])?u=t[c].map(h=>(f=r0({root:h},e),e=f.reviveCache,r=e.boCache||{},f.root)):u=t[c],s[c]=u});let a=s.$type;delete s.$type,(!e._keepIds||e._model.ids.assigned(s.id))&&delete s.id;var l=e._dmnFactory.create(a,s);return k(s,c=>{c.$type&&(c.$parent=l),F(c)&&c.forEach(u=>u.$parent=l)}),i&&(r={...r,[i]:l},e={...e,boCache:r}),{root:l,reviveCache:e}}var Ol=class{constructor(e,t,i,r,o,s,a,l){this._clipboard=e,this._dmnFactory=t,this._elementFactory=i,this._elementRegistry=r,this._eventBus=o,this._model=s,this._modeling=a,this._sheet=l}postExecute(e){let{element:t,after:i}=e,r=this._clipboard.get();if(!r)throw new Error("missing clipboard data");let o=this._sheet.getRoot(),s=o0(r.elements,{_dmnFactory:this._dmnFactory,_keepIds:r.keepIds,_model:this._model}).root;if(t instanceof pt){let a=o.rows.indexOf(t);if(a===-1)return;s.forEach(l=>{i&&a++,this._modeling.addRow(l,a)})}else if(t instanceof mt){let a=o.cols.indexOf(t);if(a===-1)return;s.forEach(l=>{i&&a++,this._modeling.addCol(l,a)})}return e.oldElements=this._clipboard.get(),this._sheet.getRoot()}revert(e){}};Ol.$inject=["clipboard","dmnFactory","elementFactory","elementRegistry","eventBus","moddle","modeling","sheet"];var kl=class{constructor(e,t,i,r,o,s){this._clipboard=e,this._commandStack=t,this._eventBus=i,this._modeling=r,this._sheet=o,this._rules=s,t.registerHandler("cut",Sl),t.registerHandler("paste",Ol)}copy(e){F(e)||(e=[e]);let t={elements:ag(e)};this._eventBus.fire("copyCutPaste.copy",{data:t}),this._clipboard.set(t)}cut(e){F(e)||(e=[e]);let t={elements:ag(e),keepIds:!0},i={elements:e,data:t};this._eventBus.fire("copyCutPaste.cut",{data:t}),this._commandStack.execute("cut",i)}pasteBefore(e){return this._paste(e,{before:!0})}pasteAfter(e){return this._paste(e,{after:!0})}_paste(e,t){let i=this._clipboard.get();return i?this._rules.allowed("paste",{data:i.elements,target:e})?(this._commandStack.execute("paste",{element:e,...t}),this._clipboard.clear(),!0):!1:void 0}pasteAt(e){}};kl.$inject=["clipboard","commandStack","eventBus","modeling","sheet","rules"];var lg={__depends__:[sg,El],__init__:["copyCutPaste"],copyCutPaste:["type",kl]};var Rl=class{constructor(e,t,i,r,o,s){let a={addRule(){return i.addRow({type:"dmn:DecisionRule"})},addRuleAbove(l){let c=l&&l.rule;if(!c&&!r.hasSelection())return;c=c||r.get().row;let u=s.getRoot(),f=u.rows.indexOf(c);if(f!==-1)return i.addRow({type:"dmn:DecisionRule"},f)},addRuleBelow(l){let c=l&&l.rule;if(!c&&!r.hasSelection())return;c=c||r.get().row;let u=s.getRoot(),f=u.rows.indexOf(c);if(f!==-1)return i.addRow({type:"dmn:DecisionRule"},f+1)},removeRule(l){let c=l&&l.rule;!c&&!r.hasSelection()||(c=c||r.get().row,i.removeRow(c))},addInput(){let l=s.getRoot(),c=l.businessObject,{input:u}=c;return i.addCol({type:"dmn:InputClause"},u?u.length:0)},addInputLeft(l){let c=l&&l.input;if(!c&&!r.hasSelection())return;c=c||r.get().col;let u=s.getRoot(),f=u.cols.indexOf(c);if(f!==-1)return i.addCol({type:"dmn:InputClause"},f)},addInputRight(l){let c=l&&l.input;if(!c&&!r.hasSelection())return;c=c||r.get().col;let u=s.getRoot(),f=u.cols.indexOf(c);if(f!==-1)return i.addCol({type:"dmn:InputClause"},f+1)},removeInput(l){let c=l&&l.input;!c&&!r.hasSelection()||(c=c||r.get().col,i.removeCol(c))},addOutput(){let l=s.getRoot(),c=l.businessObject,u=c.get("input"),f=c.get("output");return i.addCol({type:"dmn:OutputClause"},u.length+f.length)},addOutputLeft(l){let c=l&&l.output;if(!c&&!r.hasSelection())return;c=c||r.get().col;let u=s.getRoot(),f=u.cols.indexOf(c);if(f!==-1)return i.addCol({type:"dmn:OutputClause"},f)},addOutputRight(l){let c=l&&l.output;if(!c&&!r.hasSelection())return;c=c||r.get().col;let u=s.getRoot(),f=u.cols.indexOf(c);if(f!==-1)return i.addCol({type:"dmn:OutputClause"},f+1)},removeOutput(l){let c=l&&l.output;!c&&!r.hasSelection()||(c=c||r.get().col,i.removeCol(c))},addClause(){if(!r.hasSelection())return;let l=r.get().col;if(O(l,"dmn:InputClause"))return a.addInput({input:l});if(O(l,"dmn:OutputClause"))return a.addOutput({output:l})},addClauseLeft(){if(!r.hasSelection())return;let l=r.get().col;if(O(l,"dmn:InputClause"))return a.addInputLeft({input:l});if(O(l,"dmn:OutputClause"))return a.addOutputLeft({output:l})},addClauseRight(){if(!r.hasSelection())return;let l=r.get().col;if(O(l,"dmn:InputClause"))return a.addInputRight({input:l});if(O(l,"dmn:OutputClause"))return a.addOutputRight({output:l})},removeClause(){if(!r.hasSelection())return;let l=r.get().col;if(O(l,"dmn:InputClause"))return a.removeInput({input:l});if(O(l,"dmn:OutputClause"))return a.removeOutput({output:l})},selectCellAbove(){return o.selectCell("above")},selectCellBelow(){return o.selectCell("below")},copy({element:l}){e.copy(l)},cut({element:l}){e.cut(l)},pasteBefore({element:l}){return e.pasteBefore(l)},pasteAfter({element:l}){return e.pasteAfter(l)}};t.register(a)}};Rl.$inject=["copyCutPaste","editorActions","modeling","selection","cellSelection","sheet"];var kR="is not a registered action",k5="is already registered",Tl=class{constructor(e,t,i,r){this._actions={undo(){e.undo()},redo(){e.redo()},select({cell:o}){r.select(o)},deselect(){r.deselect()},addRow({attrs:o,index:s}){i.addRow(o,s)},removeRow({row:o}){i.removeRow(o)},moveRow({row:o,index:s}){i.moveRow(o,s)},addCol({attrs:o,index:s}){i.addCol(o,s)},removeCol({col:o}){i.removeCol(o)},moveCol({col:o,index:s}){i.moveCol(o,s)}}}trigger(e,t){if(!this._actions[e])throw s0(e,kR);return this._actions[e](t)}register(e,t){if(typeof e=="string")return this._registerAction(e,t);k(e,(i,r)=>{this._registerAction(r,i)},this)}_registerAction(e,t){if(this.isRegistered(e))throw s0(e,k5);this._actions[e]=t}unregister(e){if(!this.isRegistered(e))throw s0(e,kR);this._actions[e]=void 0}isRegistered(e){return!!this._actions[e]}};Tl.$inject=["commandStack","eventBus","modeling","selection"];function s0(n,e){return new Error(n+" "+e)}var cg={__depends__:[Mo],__init__:["editorActions"],editorActions:["type",Tl]};var Jn={__depends__:[Po,lg,cg,Mo],__init__:["decisionTableEditorActions"],decisionTableEditorActions:["type",Rl]};var RR={__depends__:[Jn],__init__:["addRule"],addRule:["type",yl]};var PR=Pw(AR());function MR(n,e,t){var i=n.start,r=i,o=e.substring(i);t.lastIndexOf(o)===t.length-o.length&&(e=e.substring(0,e.length-o.length),t=t.substring(0,t.length-o.length));var s=A5(e,t);return s&&(s.type==="remove"?r=s.newStart:r=s.newEnd),M5(r)}function A5(n,e){var t,i,r,o=0,s,a,l=0;for(e.length>n.length?(i=e,s=n):(i=n,s=e);o<i.length;)r=i.charAt(o),a=s.charAt(l),r!==a?(t||(t={l_start:o,s_start:l}),o++):(t&&!t.complete&&(t.l_end=o,t.s_end=l,t.complete=!0),l++,o++);if(t&&!t.complete&&(t.complete=!0,t.s_end=s.length,t.l_end=i.length),!!t)return e.length>n.length?{newStart:t.l_start,newEnd:t.l_end,type:"add"}:{newStart:t.s_start,newEnd:t.s_end,type:e.length<n.length?"remove":"replace"}}function M5(n,e){return{start:n,end:e===void 0?n:e}}var Tn=class extends L{constructor(t,i){super(t,i);M(this,"onFocus",t=>{var i=this.props.onFocus;this.setState({focussed:!0}),typeof i=="function"&&i(t)});M(this,"onBlur",t=>{let{onBlur:i,onChange:r,value:o}=this.props;if(this.setState({focussed:!1}),typeof r=="function"&&this.node){let s=ug(this.node);s!==o&&r(s)}typeof i=="function"&&i(t)});M(this,"onkeydown",t=>{if(t.which===13){if(t.preventDefault(),this.props.ctrlForNewline&&!I5(t)||this.props.singleLine)return;t.stopPropagation(),D5(),this.onInput(t)}});M(this,"onInput",t=>{var i=this.props.onInput;if(typeof i=="function"){var r=ug(this.node);i(r)}});M(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,o=i.focussed&&wl(r);this.selected=o&&{range:o,text:ug(r)}}componentDidUpdate(){var t=this.selected;if(!t)return;let i=t.range,r=t.text,o=this.node,s=ug(o),a=s!==r?MR(i,r,s):i;rg(o,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:o}=t;return r=(0,PR.default)(r).replace(/\r?\n/g,"<br/>")+"<br/>",y(1,"div",this.getClassName(),null,1,{"aria-label":i,role:"textbox","aria-multiline":!this.props.singleLine,tabIndex:"0",contentEditable:"true",spellCheck:"false","data-placeholder":o||"",onInput:this.onInput,onkeypress:this.onkeypress,onPaste:this.onPaste,onFocus:this.onFocus,onBlur:this.onBlur,onkeydown:this.onkeydown,dangerouslySetInnerHTML:{__html:r}},null,s=>this.node=s)}};function P5(){return document.createElement("br")}function ug(n){return n.innerText.replace(/\n$/,"")}function D5(){var n=yR(),e=n.getRangeAt(0);if(e){var t=e.cloneRange(),i=P5();t.deleteContents(),t.insertNode(i),t.setStartAfter(i),t.setEndAfter(i),Zx(t)}}function I5(n){return n.metaKey||n.ctrlKey}var an=class extends L{constructor(t,i){super(t,i);M(this,"onFocus",t=>{this.setState({focussed:!0});var{onFocus:i}=this.props;typeof i=="function"&&i(t)});M(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,o=r.get("debounceInput");this.inputChanged=o(s=>{let{onChange:a}=this.props;typeof a=="function"&&a(s);let l=this.state.changing;this.setState({changing:l===s?!1:l})}),this.onInput=s=>{var a=this.props.validate||function(){},l=a(s);this.setState({changing:s,invalid:l}),l||this.inputChanged(s)}}getClassName(){var{className:t,value:i}=this.props,{changing:r,focussed:o,invalid:s}=this.state;return t+=" editable",o&&(t+=" focussed"),s&&(t+=" invalid"),!i&&!r&&(t+=" empty"),t}getDisplayValue(){var{value:t,placeholder:i}=this.props,{focussed:r,changing:o}=this.state;return typeof o=="string"&&(t=o),t||(t=r?"":i||""),t}getEditor(t={}){return P(2,Tn,{className:t.className,ctrlForNewline:this.props.ctrlForNewline,label:this.props.label,onFocus:this.onFocus,onBlur:this.onBlur,onInput:this.onInput,value:this.getDisplayValue()})}};var Al=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"setAnnotationValue",t=>{let{row:i}=this.props;this.modeling.editAnnotation(i.businessObject,t)});Ce(this)}componentWillMount(){let{row:t}=this.props;this.changeSupport.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){let{row:t}=this.props;this.changeSupport.offElementsChanged(t.id,this.onElementsChanged)}render(){let{row:t,rowIndex:i}=this.props,{description:r,id:o}=t.businessObject;return P(2,Rn,{className:"annotation",onChange:this.setAnnotationValue,coords:`${i}:annotation`,value:r,elementId:o,"data-row-id":t.id,children:P(2,a0,{label:this.translate("Annotation"),ctrlForNewline:!0,className:"annotation-editor",onChange:this.setAnnotationValue,value:r})})}};Al.$inject=["changeSupport","modeling","translate"];var a0=class extends an{render(){return y(1,"div",this.getClassName(),this.getEditor(),0)}};function fg(n){n.onGetComponent("cell",({cellType:e})=>{if(e==="after-label-cells")return To;if(e==="after-rule-cells")return Al})}fg.$inject=["components"];var L5=300;function hg(n){return function(t){if(n!==!1){var i=se(n)?n:L5;return Mi(t,i)}else return t}}hg.$inject=["config.debounceInput"];var Kt={debounceInput:["factory",hg]};var DR={__depends__:[Kt],__init__:["annotationsProvider"],annotationsProvider:["type",fg]};function Ps(n,e,t){return(e=B5(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function B5(n){var e=N5(n,"string");return typeof e=="symbol"?e:e+""}function N5(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var $5={position:"absolute"},Ml=class extends L{constructor(e,t){super(e,t),Ps(this,"open",({position:i,context:r})=>{this.close(),this.setState({isOpen:!0,position:i||{x:0,y:0},context:r||{}})}),Ps(this,"close",()=>{this.state.isOpen&&this.setState({context:void 0,isOpen:!1,position:{x:0,y:0}})}),Ps(this,"triggerClose",()=>{this.eventBus.fire("contextMenu.close")}),this.state={isOpen:!1,position:{x:0,y:0}},Ce(this)}componentDidMount(){this.eventBus.on("contextMenu.open",this.open),this.eventBus.on("contextMenu.close",this.close)}componentWillUnmount(){this.eventBus.off("contextMenu.open",this.open),this.eventBus.off("contextMenu.close",this.close)}render(){let{isOpen:e,context:t,position:i}=this.state;if(!e)return null;let r=this.components.getComponents("context-menu",t);return r.length?P(2,dg,{className:"context-menu no-deselect",context:t,position:i,offset:t.offset||{x:0,y:0},autoFocus:t.autoFocus!==!1,autoClose:t.autoClose!==!1,components:r,onClose:this.triggerClose}):null}};Ml.$inject=["eventBus","components"];var dg=class extends L{constructor(e,t){super(e,t),Ps(this,"onGlobalMouseDown",i=>{this.checkClose(i.target)}),Ps(this,"onGlobalKey",i=>{var r=i.which;(r===13||r===27)&&(i.stopPropagation(),i.preventDefault(),this.close())}),Ps(this,"onFocusChanged",i=>{this.checkClose(i.target)}),Ps(this,"setNode",i=>{this.node=i;let{autoFocus:r}=this.props;i&&(this.updatePosition(),r&&F5(i))}),Ce(this)}close(){let{onClose:e}=this.props;ge(e)&&e()}checkClose(e){let{autoClose:t}=this.props;if(t){var i=this.node;i&&i!==e&&(i.contains(e)||this.close())}}componentDidMount(){document.addEventListener("focusin",this.onFocusChanged),document.addEventListener("keydown",this.onGlobalKey),document.addEventListener("mousedown",this.onGlobalMouseDown)}componentWillUnmount(){document.removeEventListener("focusin",this.onFocusChanged),document.removeEventListener("keydown",this.onGlobalKey),document.removeEventListener("mousedown",this.onGlobalMouseDown)}updatePosition(){let{position:e,offset:t}=this.props,{node:i}=this,r=i.getBoundingClientRect();e.width||(e.width=0),e.height||(e.height=0);let o=this.renderer.getContainer(),s=o.getBoundingClientRect();s.width>s.height?(this.node.classList.add("horizontal"),this.node.classList.remove("vertical")):(this.node.classList.add("vertical"),this.node.classList.remove("horizontal"));let{scrollLeft:a,scrollTop:l}=q5(i),c={},u;e.align&&(u=e.align.split("-"));let f,h;(u&&u[1]||(e.x+e.width/2>s.width/2?"left":"right"))==="left"?(f=e.x-s.left-r.width+t.x+a,i.classList.remove("right"),i.classList.add("left")):(f=-s.left+e.x+e.width-t.x+a,i.classList.remove("left"),i.classList.add("right")),f=u?f:IR(f,0+a,s.width-r.width+a),c.left=f+"px",(u&&u[0]||(e.y+e.height/2>s.height/2?"top":"bottom"))==="top"?(h=e.y-s.top-r.height+t.y+l,i.classList.remove("bottom"),i.classList.add("top")):(h=-s.top+e.y-t.y+l,i.classList.remove("top"),i.classList.add("bottom")),h=u?h:IR(h,0+l,s.height-r.height+l),c.top=h+"px",c.overflowY="auto",c.maxHeight=s.height-h+l+"px",T(this.node.style,$5,c)}render(){let{context:e,components:t,className:i}=this.props;return y(1,"div",i,t.map((r,o)=>P(2,r,{context:e},o)),0,{onContextMenu:r=>r.preventDefault()},null,this.setNode)}};dg.$inject=["renderer"];function IR(n,e,t){return Math.max(e,Math.min(t,n))}var j5=` 266 input[type=text], 267 input[type=number], 268 input[type=button], 269 input[type=submit], 270 [contenteditable], 271 [tabindex], 272 a[href], 273 textarea, 274 button 275`;function F5(n){var e=X(j5,n);e&&(e.focus(),e.selectionStart&&e.type==="text"?e.selectionStart=1e5:"contentEditable"in e&&rg(e,{start:1e5,end:1e5}))}function q5(n){let e=De(n,".tjs-container");if(!e)return{scrollTop:0,scrollLeft:0};let{scrollLeft:t,scrollTop:i}=e;return{scrollTop:i,scrollLeft:t}}var Pl=class{constructor(e,t,i){this._eventBus=t,e.onGetComponent("table.before",()=>Ml)}open(e,t){this._eventBus.fire("contextMenu.open",{position:e,context:t})}close(){this._eventBus.fire("contextMenu.close")}};Pl.$inject=["components","eventBus","renderer"];var Gt={__init__:["contextMenu"],contextMenu:["type",Pl]};function Ir(n){return n.altKey?!1:n.ctrlKey||n.metaKey}function Lr(n){return n.shiftKey}var Dl=class{constructor(e,t,i,r,o,s,a){M(this,"_clearClipboard",()=>{this._clipboard.clear()});M(this,"_registerBindings",()=>{[(r,o)=>{if(Ir(o)&&r===67){let s=this._getSelectedCell();return s?(Lr(o)?this._editorActions.trigger("copy",{element:s.col}):this._editorActions.trigger("copy",{element:s.row}),!0):void 0}},(r,o)=>{if(Ir(o)&&r===88){let s=this._getSelectedCell();return s?(Lr(o)?this._editorActions.trigger("cut",{element:s.col}):this._editorActions.trigger("cut",{element:s.row}),!0):void 0}},(r,o)=>{let s;if(Ir(o)&&r===86){let a=this._getSelectedCell();if(!a)return;Lr(o)?(s=this._editorActions.trigger("pasteAfter",{element:a.col}),s&&this._cellSelection.selectCell("right")):(s=this._editorActions.trigger("pasteAfter",{element:a.row}),s&&this._cellSelection.selectCell("below"))}return typeof s!="undefined"}].forEach(r=>{this._keyboard.addListener(r)})});this._clipboard=i,this._cellSelection=r,this._elementRegistry=o,this._editorActions=s,this._keyboard=e.get("keyboard",!1),this._renderer=a,this._keyboard&&(t.on("keyboard.init",this._registerBindings),t.on("keyboard.bind",()=>{q.bind(document,"copy",this._clearClipboard,!0),q.bind(document,"cut",this._clearClipboard,!0)}),t.on("keyboard.unbind",()=>{q.unbind(document,"copy",this._clearClipboard,!0),q.unbind(document,"cut",this._clearClipboard,!0)}))}_getSelectedCell(){let e=this._cellSelection.getCellSelection();if(!e)return;let t=this._elementRegistry.get(e);if(!t)return;let i=this._renderer.getContainer(),r=Gi(e,i),o=e0(r);if(document.activeElement!==o)return;let s=wl(r);if(!(s&&s.start!==s.end))return t}};Dl.$inject=["injector","eventBus","clipboard","cellSelection","elementRegistry","editorActions","renderer"];var LR={__depends__:[sg,Po],__init__:["copyCutPasteKeyBindings"],copyCutPasteKeyBindings:["type",Dl]};var Il=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{this.editorActions.trigger("addInput")});Ce(this)}render(){return y(1,"th","input-cell create-inputs header actionable",[this.translate("Input"),Z(" "),y(1,"button","add-input dmn-icon-plus action-icon",null,1,{title:this.translate("Add input")})],0,{onClick:this.onClick,title:this.translate("Add input")})}};Il.$inject=["editorActions","translate"];var Ll=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{this.editorActions.trigger("addInput")});Ce(this)}render(){return y(1,"td","input-cell create-inputs",Z("-"),2,{onClick:this.onClick,title:this.translate("Add input")})}};Ll.$inject=["editorActions","translate"];var V5=500,Bl=class{constructor(e,t){e.onGetComponent("cell",V5,({cellType:i})=>{let{businessObject:r}=t.getRoot();if(!(r.input&&r.input.length)){if(i==="before-label-cells")return Il;if(i==="before-rule-cells")return Ll}})}};Bl.$inject=["components","sheet"];var BR={__depends__:[Jn],__init__:["createInputsProvider"],createInputsProvider:["type",Bl]};var H5=["string","boolean","number","date","time","dateTime","dayTimeDuration","yearMonthDuration","Any"],Nl=class{constructor(e){this._dataTypes=e||H5}getAll(){return this._dataTypes}};Nl.$inject=["config.dataTypes"];var Xi={__init__:["dataTypes"],dataTypes:["type",Nl]};var $l=class{constructor(e,t,i,r,o,s,a,l,c,u,f){this._contextMenu=t,this._clipboard=i,this._editorActions=r,this._elementRegistry=s,this._eventBus=o,this._modeling=a,this._selection=l,this._sheet=c,this._rules=u,this._translate=f,this._getEntries=this._getEntries.bind(this),e.onGetComponent("context-menu",(h={})=>{if(h.contextMenuType&&h.contextMenuType==="context-menu"){let d=this._getEntries(h),p=this._elementRegistry.get(h.id),m=z5(p)&&e.getComponents("context-menu-cell-additional",h);if(m&&m.length){let g=y(1,"div","context-menu-group context-menu-group-cell",m,0,{role:"presentation"});d.push(g)}return()=>y(1,"div","context-menu-flex",d,0,{tabIndex:0,role:"menu","aria-label":"Decision table context menu"})}}),o.on("cell.contextmenu",({event:h,id:d,node:p})=>{h.preventDefault(),t.open({x:h.pageX,y:h.pageY},{contextMenuType:"context-menu",event:h,id:d})})}_getEntries(e){let t={addRuleAbove:l=>{let c=l.cells.map(f=>f.id).indexOf(e.id),u=this._editorActions.trigger("addRuleAbove",{rule:l});u.cells[c]?this._selection.select(u.cells[c]):this._selection.select(u.cells[0]),this._contextMenu.close()},addRuleBelow:l=>{let c=l.cells.map(f=>f.id).indexOf(e.id),u=this._editorActions.trigger("addRuleBelow",{rule:l});u.cells[c]?this._selection.select(u.cells[c]):this._selection.select(u.cells[0]),this._contextMenu.close()},removeRule:l=>{this._editorActions.trigger("removeRule",{rule:l}),this._contextMenu.close()},addInputLeft:l=>{this._editorActions.trigger("addInputLeft",{input:l}),this._contextMenu.close()},addInputRight:l=>{this._editorActions.trigger("addInputRight",{input:l}),this._contextMenu.close()},removeInput:l=>{this._editorActions.trigger("removeInput",{input:l}),this._contextMenu.close()},addOutputLeft:l=>{this._editorActions.trigger("addOutputLeft",{output:l}),this._contextMenu.close()},addOutputRight:l=>{this._editorActions.trigger("addOutputRight",{output:l}),this._contextMenu.close()},removeOutput:l=>{this._editorActions.trigger("removeOutput",{output:l}),this._contextMenu.close()},copy:l=>{this._editorActions.trigger("copy",{element:l}),this._contextMenu.close()},cut:l=>{this._editorActions.trigger("cut",{element:l}),this._contextMenu.close()},pasteBefore:l=>{this._editorActions.trigger("pasteBefore",{element:l}),this._contextMenu.close()},pasteAfter:l=>{this._editorActions.trigger("pasteAfter",{element:l}),this._contextMenu.close()}},i=e&&e.id;if(!i)return null;let r=this._elementRegistry.get(i);if(!r)return null;let o=this._clipboard.get()||{},s=[],a=r.row||r;if(O(a,"dmn:DecisionRule")){let l=this._rules.allowed("paste",{data:o.elements,target:a});s.push(y(1,"div","context-menu-group",[y(1,"div","context-menu-group-entry context-menu-entry-copy-rule",this._translate("Copy rule"),0,{onClick:()=>t.copy(a),tabIndex:"-1",role:"menuitem"}),y(1,"div","context-menu-group-entry context-menu-entry-cut-rule",this._translate("Cut rule"),0,{onClick:()=>t.cut(a),tabIndex:"-1",role:"menuitem"}),y(1,"div",`context-menu-group-entry ${l?"":"disabled"} context-menu-entry-paste-rule-above`,this._translate("Paste rule above"),0,{onClick:()=>t.pasteBefore(a),tabIndex:"-1",role:"menuitem","aria-disabled":!l}),y(1,"div",`context-menu-group-entry ${l?"":"disabled"} context-menu-entry-paste-rule-below`,this._translate("Paste rule below"),0,{onClick:()=>t.pasteAfter(a),tabIndex:"-1",role:"menuitem","aria-disabled":!l})],4,{role:"presentation"}),y(1,"div","context-menu-group",[y(1,"div","context-menu-group-entry context-menu-entry-add-rule-above",this._translate("Add rule above"),0,{onClick:()=>t.addRuleAbove(a),tabIndex:"-1",role:"menuitem"}),y(1,"div","context-menu-group-entry context-menu-entry-add-rule-below",this._translate("Add rule below"),0,{onClick:()=>t.addRuleBelow(a),tabIndex:"-1",role:"menuitem"}),y(1,"div","context-menu-group-entry context-menu-entry-remove-rule",this._translate("Remove rule"),0,{onClick:()=>t.removeRule(a),tabIndex:"-1",role:"menuitem"})],4,{role:"presentation"}))}else if(O(r,"dmn:InputClause")){let l=O(r,"dmn:InputClause")?r:r.col,c=this._rules.allowed("col.remove",{col:r.col||r}),u=this._rules.allowed("paste",{data:o.elements,target:r.col||r});s.push(y(1,"div","context-menu-group",[y(1,"div","context-menu-group-entry context-menu-entry-copy-input",this._translate("Copy input column"),0,{onClick:()=>t.copy(l),tabIndex:"-1",role:"menuitem"}),y(1,"div",`context-menu-group-entry ${c?"":"disabled"} context-menu-entry-cut-input`,this._translate("Cut input column"),0,{onClick:()=>t.cut(l),tabIndex:"-1",role:"menuitem","aria-disabled":!c}),y(1,"div",`context-menu-group-entry ${u?"":"disabled"} context-menu-entry-paste-input-left`,this._translate("Paste input column left"),0,{onClick:()=>t.pasteBefore(l),tabIndex:"-1",role:"menuitem","aria-disabled":!u}),y(1,"div",`context-menu-group-entry ${u?"":"disabled"} context-menu-entry-paste-input-right`,this._translate("Paste input column right"),0,{onClick:()=>t.pasteAfter(l),tabIndex:"-1",role:"menuitem","aria-disabled":!u})],4,{role:"presentation"}),y(1,"div","context-menu-group",[y(1,"div","context-menu-group-entry context-menu-entry-add-input-left",this._translate("Add input column left"),0,{onClick:()=>t.addInputLeft(l),tabIndex:"-1",role:"menuitem"}),y(1,"div","context-menu-group-entry context-menu-entry-add-input-right",this._translate("Add input column right"),0,{onClick:()=>t.addInputRight(l),tabIndex:"-1",role:"menuitem"}),y(1,"div",`context-menu-group-entry ${c?"":"disabled"} context-menu-entry-remove-input`,this._translate("Remove input column"),0,{onClick:()=>t.removeInput(l),tabIndex:"-1",role:"menuitem","aria-disabled":!c})],4,{role:"presentation"}))}else if(O(r,"dmn:OutputClause")||O(r.col,"dmn:OutputClause")){let l=O(r,"dmn:OutputClause")?r:r.col,c=this._rules.allowed("col.remove",{col:r.col||r}),u=this._rules.allowed("paste",{data:o.elements,target:r.col||r});s.push(y(1,"div","context-menu-group",[y(1,"div","context-menu-group-entry context-menu-entry-copy-output",this._translate("Copy output column"),0,{onClick:()=>t.copy(l),tabIndex:"-1",role:"menuitem"}),y(1,"div",`context-menu-group-entry ${c?"":"disabled"} context-menu-entry-cut-output`,this._translate("Cut output column"),0,{onClick:()=>t.cut(l),tabIndex:"-1",role:"menuitem","aria-disabled":!c}),y(1,"div",`context-menu-group-entry ${u?"":"disabled"} context-menu-entry-paste-output-left`,this._translate("Paste output column left"),0,{onClick:()=>t.pasteBefore(l),tabIndex:"-1",role:"menuitem","aria-disabled":!u}),y(1,"div",`context-menu-group-entry ${u?"":"disabled"} context-menu-entry-paste-output-right`,this._translate("Paste output column right"),0,{onClick:()=>t.pasteAfter(l),tabIndex:"-1",role:"menuitem","aria-disabled":!u})],4,{role:"presentation"}),y(1,"div","context-menu-group",[y(1,"div","context-menu-group-entry context-menu-entry-add-output-left",this._translate("Add output column left"),0,{onClick:()=>t.addOutputLeft(l),tabIndex:"-1",role:"menuitem"}),y(1,"div","context-menu-group-entry context-menu-entry-add-output-right",this._translate("Add output column right"),0,{onClick:()=>t.addOutputRight(l),tabIndex:"-1",role:"menuitem"}),y(1,"div",`context-menu-group-entry ${c?"":"disabled"} context-menu-entry-remove-output`,this._translate("Remove output column"),0,{onClick:()=>t.removeOutput(l),tabIndex:"-1",role:"menuitem","aria-disabled":!c})],4,{role:"presentation"}))}return s}};$l.$inject=["components","contextMenu","clipboard","editorActions","eventBus","elementRegistry","modeling","selection","sheet","rules","translate"];function z5(n){return n instanceof ko}var W5=["row.add","row.remove","col.add","col.remove"],jl=class{constructor(e,t){t.on("commandStack.executed",({command:i})=>{W5.indexOf(i)!==-1&&e.close()}),t.on("commandStack.reverted",()=>{e.close()})}};jl.$inject=["contextMenu","eventBus"];var Fl=class{constructor(e){M(this,"addEventListeners",()=>{document.addEventListener("keydown",this.handleKeyEvent),document.addEventListener("mouseover",this.handleMouseOver)});M(this,"removeEventListeners",()=>{document.removeEventListener("keydown",this.handleKeyEvent),document.removeEventListener("mouseover",this.handleMouseOver)});M(this,"handleKeyEvent",e=>{this.getEntries().length&&(e.key==="ArrowUp"?(e.preventDefault(),this.move(e.target,-1)):e.key==="ArrowDown"?(e.preventDefault(),this.move(e.target,1)):e.key==="Enter"&&(e.preventDefault(),this.clickCurrentEntry()))});M(this,"handleMouseOver",()=>{this.getEntries().forEach(i=>Q5(i));let{focused:t}=this.getActiveEntries(document);t&&ee(t).remove("focused")});M(this,"getEntries",()=>Array.from(pn(".context-menu-group-entry")).filter(e=>!ee(e).has("disabled")));M(this,"getActiveEntries",e=>{let t=X(".context-menu-group-entry:hover",e),i=X(".context-menu-group-entry.focused",e);return{hover:t,focused:i,current:i||t}});M(this,"move",(e,t)=>{let i=this.getEntries(),{current:r,hover:o}=this.getActiveEntries(e);if(!r){let l=i[0];if(!l)return;ee(l).add("focused");return}let s=i.indexOf(r)+t,a=i[s];s<0&&(a=i[i.length-1]),s>=i.length&&(a=i[0]),o&&U5(o),ee(r).remove("focused"),ee(a).add("focused"),a.style.removeProperty("background-color")});M(this,"clickCurrentEntry",()=>{let{current:e}=this.getActiveEntries(document);e&&e.click()});e.on("contextMenu.open",()=>this.addEventListeners()),e.on("contextMenu.close",()=>this.removeEventListeners()),e.on("commandStack.executed",()=>this.removeEventListeners())}};Fl.$inject=["eventBus"];function U5(n){n.style.setProperty("pointer-events","none"),n.style.setProperty("background-color","transparent")}function Q5(n){n.style.removeProperty("background-color"),n.style.removeProperty("pointer-events")}var NR={__depends__:[Jn,Gt,El],__init__:["decisionTableContextMenu","contextMenuCloseBehavior","contextMenuKeyboard"],decisionTableContextMenu:["type",$l],contextMenuCloseBehavior:["type",jl],contextMenuKeyboard:["type",Fl]};var ch=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{let{output:i}=this.props;this._eventBus.fire("output.edit",{event:t,output:i})});M(this,"onContextmenu",t=>{let{id:i}=this.props.output;this._eventBus.fire("cell.contextmenu",{event:t,id:i})});M(this,"onElementsChanged",()=>{this.forceUpdate()});Ut(this,xi),this._translate=i.injector.get("translate")}componentWillMount(){let{injector:t}=this.context;this._changeSupport=this.context.changeSupport,this._eventBus=t.get("eventBus"),this._elementRegistry=t.get("elementRegistry");let{output:i}=this.props;this._changeSupport.onElementsChanged(i.id,this.onElementsChanged)}componentWillUnmount(){let{output:t}=this.props;this._changeSupport.offElementsChanged(t.id,this.onElementsChanged)}render(){let{output:t,index:i,outputsLength:r}=this.props,{label:o,name:s,outputValues:a,typeRef:l}=t,c=t.width?t.width+"px":"192px";return y(1,"th","output-cell output-editor",[this.slotFills({type:"cell-inner",context:{cellType:"output-cell",col:this._elementRegistry.get(t.id),index:i,outputsLength:r},col:t}),y(1,"div","clause",i===0?this._translate("Then"):this._translate("And"),0),o?y(1,"div","output-label",o,0,{title:this._translate("Output label: ")+o}):y(1,"div","output-name",s,0,{title:this._translate("Output name: ")+s}),y(1,"div","output-variable",a&&a.text||this._translate(l||""),0,{title:a&&a.text?this._translate("Output values"):this._translate("Output type")})],0,{"data-col-id":t.id,onDblClick:this.onClick,onContextMenu:this.onContextmenu,style:{width:c}})}};var St=class extends L{constructor(t,i){super(t,i);M(this,"onInput",t=>{let{onInput:i}=this.props,r=t.target.value;this.setState({value:r},()=>{typeof i=="function"&&i(r)})});M(this,"onChange",t=>{let{onChange:i}=this.props;typeof i=="function"&&i(t.target.value)});M(this,"onKeyDown",t=>{let{onKeyDown:i}=this.props;typeof i=="function"&&i(t)});M(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:o,type:s}=this.props,{value:a}=this.state;return y(64,"input",[t||"","dms-input"].join(" "),null,1,{"aria-label":i,placeholder:o||"",onChange:this.onChange,onInput:this.onInput,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,spellCheck:"false",type:s||"text",value:a,id:r})}};var uh=class extends L{constructor(e,t){super(e,t),this.translate=t.injector?t.injector.get("translate"):K5,this.setName=i=>{i=i||void 0,this.handleChange({name:i})},this.setLabel=i=>{i=i||void 0,this.handleChange({label:i})}}handleChange(e){var{onChange:t}=this.props;typeof t=="function"&&t(e)}render(){let{name:e,label:t}=this.props;return y(1,"div","context-menu-container ref-output-editor output-edit",[y(1,"div","dms-form-control",P(2,Tn,{label:this.translate("Output label"),className:"dms-output-label",value:t||"",placeholder:this.translate("Output"),singleLine:!0,onInput:this.setLabel}),2),y(1,"div","dms-form-control",[y(1,"label","dms-label",this.translate("Output name"),0),P(2,St,{label:this.translate("Output name"),className:"ref-output-name",value:e||"",onInput:this.setName})],4)],4)}};function K5(n){return n}var ql=class extends L{constructor(t,i){super(t,i);M(this,"persistChanges",()=>{let{output:t}=this.props.context,{unsaved:i}=this.state;i&&(this.modeling.updateProperties(t,i),this.setState({unsaved:!1}))});M(this,"handleChange",t=>{this.setState({unsaved:{...this.state.unsaved,...t}},this.persistChanges)});this.state={},Ce(this),this.persistChanges=this.debounceInput(this.persistChanges)}getValue(t){let{output:i}=this.props.context,{unsaved:r}=this.state;return r&&t in r?r[t]:i.get(t)}render(){return P(2,uh,{name:this.getValue("name"),label:this.getValue("label"),onChange:this.handleChange})}};ql.$inject=["debounceInput","modeling"];var pg=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{let{col:i}=this.props;this._eventBus.fire("output.edit",{event:t,output:i})});this._translate=i.injector.get("translate"),this._eventBus=i.injector.get("eventBus")}render(){return y(1,"button","edit-button dmn-icon-edit",null,1,{"aria-label":this._translate("Edit output"),type:"button",onClick:this.onClick})}};var Vl=class{constructor(e,t,i,r){e.onGetComponent("cell",({cellType:o})=>{if(o==="output-header")return ch}),e.onGetComponent("context-menu",(o={})=>{if(o.contextMenuType==="output-edit")return ql}),e.onGetComponent("cell-inner",(o={})=>{let{cellType:s}=o;if(s==="output-cell")return pg}),i.on("output.edit",({event:o,output:s})=>{let{target:a}=o,l=De(a,"th",!0),{left:c,top:u}=l.getBoundingClientRect(),f=G5(l);t.open({x:c,y:u,align:"bottom-right"},{contextMenuType:"output-edit",output:s,offset:f})})}};Vl.$inject=["components","contextMenu","eventBus","renderer"];function G5(n){if(!hr(n,".output-cell + .output-cell"))return{x:-1,y:0}}var fh=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{let{input:i}=this.props;this._eventBus.fire("input.edit",{event:t,input:i})});M(this,"onContextmenu",t=>{let{id:i}=this.props.input;this._eventBus.fire("cell.contextmenu",{event:t,id:i})});M(this,"onElementsChanged",()=>{this.forceUpdate()});Ut(this,xi),this._translate=i.injector.get("translate")}componentWillMount(){let{injector:t}=this.context;this._changeSupport=this.context.changeSupport,this._sheet=t.get("sheet"),this._eventBus=t.get("eventBus"),this._elementRegistry=t.get("elementRegistry");let i=this._sheet.getRoot(),{input:r}=this.props;this._changeSupport.onElementsChanged(i.id,this.onElementsChanged),this._changeSupport.onElementsChanged(r.id,this.onElementsChanged)}componentWillUnmount(){let t=this._sheet.getRoot(),{input:i}=this.props;this._changeSupport.offElementsChanged(t.id,this.onElementsChanged),this._changeSupport.offElementsChanged(i.id,this.onElementsChanged)}render(){let{input:t,index:i,inputsLength:r}=this.props,{inputExpression:o,inputValues:s}=t,a=t.get("label"),l=t.width?t.width+"px":"192px";return y(1,"th","input-cell input-editor",[this.slotFills({type:"cell-inner",context:{cellType:"input-cell",col:this._elementRegistry.get(t.id),index:i,inputsLength:r},col:t}),y(1,"div","clause",i===0?this._translate("When"):this._translate("And"),0),a?y(1,"div","input-label",a,0,{title:this._translate("Input label: ")+a}):y(1,"div","input-expression",o.text,0,{title:this._translate("Input expression: ")+o.text}),y(1,"div","input-variable",s&&s.text||this._translate(o.typeRef||""),0,{title:s&&s.text?this._translate("Input values"):this._translate("Input type")})],0,{"data-col-id":t.id,onDblClick:this.onClick,onContextMenu:this.onContextmenu,style:{width:l}})}};var c0=[],qR=[];(()=>{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<n.length;e++)(e%2?qR:c0).push(t=t+n[e])})();function X5(n){if(n<768)return!1;for(let e=0,t=c0.length;;){let i=e+t>>1;if(n<c0[i])t=i;else if(n>=qR[i])e=i+1;else return!0;if(e==t)return!1}}function $R(n){return n>=127462&&n<=127487}var jR=8205;function VR(n,e,t=!0,i=!0){return(t?HR:Y5)(n,e,i)}function HR(n,e,t){if(e==n.length)return e;e&&zR(n.charCodeAt(e))&&WR(n.charCodeAt(e-1))&&e--;let i=l0(n,e);for(e+=FR(i);e<n.length;){let r=l0(n,e);if(i==jR||r==jR||t&&X5(r))e+=FR(r),i=r;else if($R(r)){let o=0,s=e-2;for(;s>=0&&$R(l0(n,s));)o++,s-=2;if(o%2==0)break;e+=2}else break}return e}function Y5(n,e,t){for(;e>0;){let i=HR(n,e-2,t);if(i<e)return i;e--}return 0}function l0(n,e){let t=n.charCodeAt(e);if(!WR(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return zR(i)?(t-55296<<10)+(i-56320)+65536:t}function zR(n){return n>=56320&&n<57344}function WR(n){return n>=55296&&n<56320}function FR(n){return n<65536?1:2}var be=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]=Ql(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),zl.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]=Ql(this,e,t);let i=[];return this.decompose(e,t,i,0),zl.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 Ls(this),o=new Ls(e);for(let s=t,a=t;;){if(r.next(s),o.next(s),s=0,r.lineBreak!=o.lineBreak||r.done!=o.done||r.value!=o.value)return!1;if(a+=r.value.length,r.done||a>=i)return!0}}iter(e=1){return new Ls(this,e)}iterRange(e,t=this.length){return new xg(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 bg(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 An(e):zl.from(An.split(e,[]))}},An=class n extends be{constructor(e,t=Z5(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 o=0;;o++){let s=this.text[o],a=r+s.length;if((t?i:a)>=e)return new f0(r,a,i,s);r=a+1,i++}}decompose(e,t,i,r){let o=e<=0&&t>=this.length?this:new n(UR(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let s=i.pop(),a=vg(o.text,s.text.slice(),0,o.length);if(a.length<=32)i.push(new n(a,s.length+o.length));else{let l=a.length>>1;i.push(new n(a.slice(0,l)),new n(a.slice(l)))}}else i.push(o)}replace(e,t,i){if(!(i instanceof n))return super.replace(e,t,i);[e,t]=Ql(this,e,t);let r=vg(this.text,vg(i.text,UR(this.text,0,e)),t),o=this.length+i.length-(t-e);return r.length<=32?new n(r,o):zl.from(n.split(r,[]),o)}sliceString(e,t=this.length,i=` 276`){[e,t]=Ql(this,e,t);let r="";for(let o=0,s=0;o<=t&&s<this.text.length;s++){let a=this.text[s],l=o+a.length;o>e&&s&&(r+=i),e<l&&t>o&&(r+=a.slice(Math.max(0,e-o),t-o)),o=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 o of e)i.push(o),r+=o.length+1,i.length==32&&(t.push(new n(i,r)),i=[],r=-1);return r>-1&&t.push(new n(i,r)),t}},zl=class n extends be{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 o=0;;o++){let s=this.children[o],a=r+s.length,l=i+s.lines-1;if((t?l:a)>=e)return s.lineInner(e,t,i,r);r=a+1,i=l+1}}decompose(e,t,i,r){for(let o=0,s=0;s<=t&&o<this.children.length;o++){let a=this.children[o],l=s+a.length;if(e<=l&&t>=s){let c=r&((s<=e?1:0)|(l>=t?2:0));s>=e&&l<=t&&!c?i.push(a):a.decompose(e-s,t-s,i,c)}s=l+1}}replace(e,t,i){if([e,t]=Ql(this,e,t),i.lines<this.lines)for(let r=0,o=0;r<this.children.length;r++){let s=this.children[r],a=o+s.length;if(e>=o&&t<=a){let l=s.replace(e-o,t-o,i),c=this.lines-s.lines+l.lines;if(l.lines<c>>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(o,a,l)}o=a+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` 277`){[e,t]=Ql(this,e,t);let r="";for(let o=0,s=0;o<this.children.length&&s<=t;o++){let a=this.children[o],l=s+a.length;s>e&&o&&(r+=i),e<l&&t>s&&(r+=a.sliceString(e-s,t-s,i)),s=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,o,s,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,o+=t){if(r==s||o==a)return i;let l=this.children[r],c=e.children[o];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 An(d,t)}let r=Math.max(32,i>>5),o=r<<1,s=r>>1,a=[],l=0,c=-1,u=[];function f(d){let p;if(d.lines>o&&d instanceof n)for(let m of d.children)f(m);else d.lines>s&&(l>s||!l)?(h(),a.push(d)):d instanceof An&&l&&(p=u[u.length-1])instanceof An&&d.lines+p.lines<=32?(l+=d.lines,c+=d.length+1,u[u.length-1]=new An(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)}};be.empty=new An([""],0);function Z5(n){let e=-1;for(let t of n)e+=t.length+1;return e}function vg(n,e,t=0,i=1e9){for(let r=0,o=0,s=!0;o<n.length&&r<=i;o++){let a=n[o],l=r+a.length;l>=t&&(l>i&&(a=a.slice(0,i-r)),r<t&&(a=a.slice(t-r)),s?(e[e.length-1]+=a,s=!1):e.push(a)),r=l+1}return e}function UR(n,e,t){return vg(n,[""],e,t)}var Ls=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof An?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],o=this.offsets[i],s=o>>1,a=r instanceof An?r.text.length:r.children.length;if(s==(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((o&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` 278`,this;e--}else if(r instanceof An){let l=r.text[s+(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[s+(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 An?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)}},xg=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Ls(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!=""}},bg=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"&&(be.prototype[Symbol.iterator]=function(){return this.iter()},Ls.prototype[Symbol.iterator]=xg.prototype[Symbol.iterator]=bg.prototype[Symbol.iterator]=function(){return this});var f0=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 Ql(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function Dt(n,e,t=!0,i=!0){return VR(n,e,t,i)}function J5(n){return n>=56320&&n<57344}function eq(n){return n>=55296&&n<56320}function ti(n,e){let t=n.charCodeAt(e);if(!eq(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return J5(i)?(t-55296<<10)+(i-56320)+65536:t}function E0(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Yi(n){return n<65536?1:2}var h0=/\r\n?|\n/,Ot=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(Ot||(Ot={})),Br=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let o=this.sections[t++],s=this.sections[t++];s<0?(e(i,r,o),r+=o):r+=s,i+=o}}iterChangedRanges(e,t=!1){d0(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new n(e)}composeDesc(e){return this.empty?e:e.empty?this:YR(this,e)}mapDesc(e,t=!1){return e.empty?this:p0(this,e,t)}mapPos(e,t=-1,i=Ot.Simple){let r=0,o=0;for(let s=0;s<this.sections.length;){let a=this.sections[s++],l=this.sections[s++],c=r+a;if(l<0){if(c>e)return o+(e-r);o+=a}else{if(i!=Ot.Simple&&c>=e&&(i==Ot.TrackDel&&r<e&&c>e||i==Ot.TrackBefore&&r<e||i==Ot.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!a)return e==r||t<0?o:o+l;o+=l}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return o}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let o=this.sections[i++],s=this.sections[i++],a=r+o;if(s>=0&&r<=t&&a>=e)return r<e&&a>t?"cover":!0;r=a}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=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)}},cn=class n extends Br{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 d0(this,(t,i,r,o,s)=>e=e.replace(r,r+(i-t),s),!1),e}mapDesc(e,t=!1){return p0(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,o=0;r<t.length;r+=2){let s=t[r],a=t[r+1];if(a>=0){t[r]=a,t[r+1]=s;let l=r>>1;for(;i.length<l;)i.push(be.empty);i.push(s?e.slice(o,o+s):be.empty)}o+=s}return new n(t,i)}compose(e){return this.empty?e:e.empty?this:YR(this,e,!0)}map(e,t=!1){return e.empty?this:p0(this,e,t,!0)}iterChanges(e,t=!1){d0(this,e,t)}get desc(){return Br.create(this.sections)}filter(e){let t=[],i=[],r=[],o=new Bs(this);e:for(let s=0,a=0;;){let l=s==e.length?1e9:e[s++];for(;a<l||a==l&&o.len==0;){if(o.done)break e;let u=Math.min(o.len,l-a);Xt(r,u,-1);let f=o.ins==-1?-1:o.off==0?o.ins:0;Xt(t,u,f),f>0&&Do(i,t,o.text),o.forward(u),a+=u}let c=e[s++];for(;a<c;){if(o.done)break e;let u=Math.min(o.len,c-a);Xt(t,u,-1),Xt(r,u,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(u),a+=u}}return{changes:new n(t,i),filtered:Br.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],o=[],s=0,a=null;function l(u=!1){if(!u&&!r.length)return;s<t&&Xt(r,t-s,-1);let f=new n(r,o);a=a?a.compose(f.map(a)):f,r=[],o=[],s=0}function c(u){if(Array.isArray(u))for(let f of u)c(f);else if(u instanceof n){if(u.length!=t)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${t})`);l(),a=a?a.compose(u.map(a)):u}else{let{from:f,to:h=f,insert:d}=u;if(f>h||f<0||h>t)throw new RangeError(`Invalid change range ${f} to ${h} (in doc of length ${t})`);let p=d?typeof d=="string"?be.of(d.split(i||h0)):d:be.empty,m=p.length;if(f==h&&m==0)return;f<s&&l(),f>s&&Xt(r,f-s,-1),Xt(r,h-f,m),Do(o,r,p),s=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;r<e.length;r++){let o=e[r];if(typeof o=="number")t.push(o,-1);else{if(!Array.isArray(o)||typeof o[0]!="number"||o.some((s,a)=>a&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)t.push(o[0],0);else{for(;i.length<r;)i.push(be.empty);i[r]=be.of(o.slice(1)),t.push(o[0],i[r].length)}}}return new n(t,i)}static createSet(e,t){return new n(e,t)}};function Xt(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=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 Do(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(be.empty);n.push(t)}}function d0(n,e,t){let i=n.inserted;for(let r=0,o=0,s=0;s<n.sections.length;){let a=n.sections[s++],l=n.sections[s++];if(l<0)r+=a,o+=a;else{let c=r,u=o,f=be.empty;for(;c+=a,u+=l,l&&i&&(f=f.append(i[s-2>>1])),!(t||s==n.sections.length||n.sections[s+1]<0);)a=n.sections[s++],l=n.sections[s++];e(r,c,o,u,f),r=c,o=u}}}function p0(n,e,t,i=!1){let r=[],o=i?[]:null,s=new Bs(n),a=new Bs(e);for(let l=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(s.ins==-1&&a.ins==-1){let c=Math.min(s.len,a.len);Xt(r,c,-1),s.forward(c),a.forward(c)}else if(a.ins>=0&&(s.ins<0||l==s.i||s.off==0&&(a.len<s.len||a.len==s.len&&!t))){let c=a.len;for(Xt(r,a.ins,-1);c;){let u=Math.min(s.len,c);s.ins>=0&&l<s.i&&s.len<=u&&(Xt(r,0,s.ins),o&&Do(o,r,s.text),l=s.i),s.forward(u),c-=u}a.next()}else if(s.ins>=0){let c=0,u=s.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.len<u)u-=a.len,a.next();else break;Xt(r,c,l<s.i?s.ins:0),o&&l<s.i&&Do(o,r,s.text),l=s.i,s.forward(s.len-u)}else{if(s.done&&a.done)return o?cn.createSet(r,o):Br.create(r);throw new Error("Mismatched change set lengths")}}}function YR(n,e,t=!1){let i=[],r=t?[]:null,o=new Bs(n),s=new Bs(e);for(let a=!1;;){if(o.done&&s.done)return r?cn.createSet(i,r):Br.create(i);if(o.ins==0)Xt(i,o.len,0,a),o.next();else if(s.len==0&&!s.done)Xt(i,0,s.ins,a),r&&Do(r,i,s.text),s.next();else{if(o.done||s.done)throw new Error("Mismatched change set lengths");{let l=Math.min(o.len2,s.len),c=i.length;if(o.ins==-1){let u=s.ins==-1?-1:s.off?0:s.ins;Xt(i,l,u,a),r&&u&&Do(r,i,s.text)}else s.ins==-1?(Xt(i,o.off?0:o.len,l,a),r&&Do(r,i,o.textBit(l))):(Xt(i,o.off?0:o.len,s.off?0:s.ins,a),r&&!s.off&&Do(r,i,s.text));a=(o.ins>l||s.ins>=0&&s.len>l)&&(a||i.length>c),o.forward2(l),s.forward(l)}}}}var Bs=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?be.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?be.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)}},Hl=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 $.range(e,t,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return $.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 $.range(e.anchor,e.head)}static create(e,t,i){return new n(e,t,i)}},$=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;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new n([this.main],0)}addRange(e,t=!0){return n.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,n.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new n(e.ranges.map(t=>Hl.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;r<e.length;r++){let o=e[r];if(o.empty?o.from<=i:o.from<i)return n.normalized(e.slice(),t);i=o.to}return new n(e,t)}static cursor(e,t=0,i,r){return Hl.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(r!=null?r:16777215)<<6)}static range(e,t,i,r,o){let s=(i!=null?i:16777215)<<6|(r==null?7:Math.min(6,r));return!o&&e!=t&&(o=t<e?1:-1),t<e?Hl.create(t,e,48|s):Hl.create(e,t,(o?o<0?8:16:0)|s)}static normalized(e,t=0){let i=e[t];e.sort((r,o)=>r.from-o.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let o=e[r],s=e[r-1];if(o.empty?o.from<=s.to:o.from<s.to){let a=s.from,l=Math.max(o.to,s.to);r<=t&&t--,e.splice(--r,2,o.anchor>o.head?n.range(l,a):n.range(a,l))}}return new n(e,t)}};function ZR(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var S0=0,H=class n{constructor(e,t,i,r,o){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=S0++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}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:O0),!!e.static,e.enables)}of(e){return new Wl([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Wl(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Wl(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function O0(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var Wl=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=S0++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,o=this.id,s=e[o]>>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[s]=i(f),1},update(f,h){if(l&&h.docChanged||c&&(h.docChanged||h.selection)||m0(f,u)){let d=i(f);if(a?!QR(d,f.values[s],r):!r(d,f.values[s]))return f.values[s]=d,1}return 0},reconfigure:(f,h)=>{let d,p=h.config.address[o];if(p!=null){let m=Cg(h,p);if(this.dependencies.every(g=>g instanceof H?h.facet(g)===f.facet(g):g instanceof qt?h.field(g,!1)==f.field(g,!1):!0)||(a?QR(d=i(f),m,r):r(d=i(f),m)))return f.values[s]=m,0}else d=i(f);return f.values[s]=d,1}}}};function QR(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function m0(n,e){let t=!1;for(let i of e)dh(n,i)&1&&(t=!0);return t}function tq(n,e,t){let i=t.map(l=>n[l.id]),r=t.map(l=>l.type),o=i.filter(l=>!(l&1)),s=n[e.id]>>1;function a(l){let c=[];for(let u=0;u<i.length;u++){let f=Cg(l,i[u]);if(r[u]==2)for(let h of f)c.push(h);else c.push(f)}return e.combine(c)}return{create(l){for(let c of i)dh(l,c);return l.values[s]=a(l),1},update(l,c){if(!m0(l,o))return 0;let u=a(l);return e.compare(u,l.values[s])?0:(l.values[s]=u,1)},reconfigure(l,c){let u=m0(l,i),f=c.config.facets[e.id],h=c.facet(e);if(f&&!u&&O0(t,f))return l.values[s]=h,0;let d=a(l);return e.compare(d,h)?(l.values[s]=h,0):(l.values[s]=d,1)}}}var mg=H.define({static:!0}),qt=class n{constructor(e,t,i,r,o){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=o,this.provides=void 0}static define(e){let t=new n(S0++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(mg).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 o=i.values[t],s=this.updateF(o,r);return this.compareF(o,s)?0:(i.values[t]=s,1)},reconfigure:(i,r)=>{let o=i.facet(mg),s=r.facet(mg),a;return(a=o.find(l=>l.field==this))&&a!=s.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,mg.of({field:this,create:e})]}get extension(){return this}},Ds={lowest:4,low:3,default:2,high:1,highest:0};function hh(n){return e=>new _g(e,n)}var $r={highest:hh(Ds.highest),high:hh(Ds.high),default:hh(Ds.default),low:hh(Ds.low),lowest:hh(Ds.lowest)},_g=class{constructor(e,t){this.inner=e,this.prec=t}},Ns=class n{of(e){return new ph(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},ph=class{constructor(e,t){this.compartment=e,this.inner=t}},wg=class n{constructor(e,t,i,r,o,s){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=o,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],o=Object.create(null),s=new Map;for(let h of nq(e,t,s))h instanceof qt?r.push(h):(o[h.facet.id]||(o[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 o){let d=o[h],p=d[0].facet,m=u&&u[h]||[];if(d.every(g=>g.type==0))if(a[p.id]=l.length<<1|1,O0(m,d))l.push(i.facet(p));else{let g=p.combine(d.map(b=>b.value));l.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(a[g.id]=l.length<<1|1,l.push(g.value)):(a[g.id]=c.length<<1,c.push(b=>g.dynamicSlot(b)));a[p.id]=c.length<<1,c.push(g=>tq(g,p,d))}}let f=c.map(h=>h(a));return new n(e,s,f,a,l,o)}};function nq(n,e,t){let i=[[],[],[],[],[]],r=new Map;function o(s,a){let l=r.get(s);if(l!=null){if(l<=a)return;let c=i[l].indexOf(s);c>-1&&i[l].splice(c,1),s instanceof ph&&t.delete(s.compartment)}if(r.set(s,a),Array.isArray(s))for(let c of s)o(c,a);else if(s instanceof ph){if(t.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;t.set(s.compartment,c),o(c,a)}else if(s instanceof _g)o(s.inner,s.prec);else if(s instanceof qt)i[a].push(s),s.provides&&o(s.provides,a);else if(s instanceof Wl)i[a].push(s),s.facet.extensions&&o(s.facet.extensions,Ds.default);else{let c=s.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(c,a)}}return o(n,Ds.default),i.reduce((s,a)=>s.concat(a))}function dh(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 Cg(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var JR=H.define(),g0=H.define({combine:n=>n.some(e=>e),static:!0}),eT=H.define({combine:n=>n.length?n[0]:void 0,static:!0}),tT=H.define(),nT=H.define(),iT=H.define(),rT=H.define({combine:n=>n.length?n[0]:!1}),Mn=class{constructor(e,t){this.type=e,this.value=t}static define(){return new y0}},y0=class{of(e){return new Mn(this,e)}},v0=class{constructor(e){this.map=e}of(e){return new de(this,e)}},de=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 v0(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let o=r.map(t);o&&i.push(o)}return i}};de.reconfigure=de.define();de.appendConfig=de.define();var Ft=class n{constructor(e,t,i,r,o,s){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=o,this.scrollIntoView=s,this._doc=null,this._state=null,i&&ZR(i,t.newLength),o.some(a=>a.type==n.time)||(this.annotations=o.concat(n.time.of(Date.now())))}static create(e,t,i,r,o,s){return new n(e,t,i,r,o,s)}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]=="."))}};Ft.time=Mn.define();Ft.userEvent=Mn.define();Ft.addToHistory=Mn.define();Ft.remote=Mn.define();function iq(n,e){let t=[];for(let i=0,r=0;;){let o,s;if(i<n.length&&(r==e.length||e[r]>=n[i]))o=n[i++],s=n[i++];else if(r<e.length)o=e[r++],s=e[r++];else return t;!t.length||t[t.length-1]<o?t.push(o,s):t[t.length-1]<s&&(t[t.length-1]=s)}}function oT(n,e,t){var i;let r,o,s;return t?(r=e.changes,o=cn.empty(e.changes.length),s=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),o=n.changes.mapDesc(e.changes,!0),s=n.changes.compose(r)),{changes:s,selection:e.selection?e.selection.map(o):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:de.mapEffects(n.effects,r).concat(de.mapEffects(e.effects,o)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function x0(n,e,t){let i=e.selection,r=Ul(e.annotations);return e.userEvent&&(r=r.concat(Ft.userEvent.of(e.userEvent))),{changes:e.changes instanceof cn?e.changes:cn.of(e.changes||[],t,n.facet(eT)),selection:i&&(i instanceof $?i:$.single(i.anchor,i.head)),effects:Ul(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function sT(n,e,t){let i=x0(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let o=1;o<e.length;o++){e[o].filter===!1&&(t=!1);let s=!!e[o].sequential;i=oT(i,x0(n,e[o],s?i.changes.newLength:n.doc.length),s)}let r=Ft.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return oq(t?rq(r):r)}function rq(n){let e=n.startState,t=!0;for(let r of e.facet(tT)){let o=r(n);if(o===!1){t=!1;break}Array.isArray(o)&&(t=t===!0?o:iq(t,o))}if(t!==!0){let r,o;if(t===!1)o=n.changes.invertedDesc,r=cn.empty(e.doc.length);else{let s=n.changes.filter(t);r=s.changes,o=s.filtered.mapDesc(s.changes).invertedDesc}n=Ft.create(e,r,n.selection&&n.selection.map(o),de.mapEffects(n.effects,o),n.annotations,n.scrollIntoView)}let i=e.facet(nT);for(let r=i.length-1;r>=0;r--){let o=i[r](n);o instanceof Ft?n=o:Array.isArray(o)&&o.length==1&&o[0]instanceof Ft?n=o[0]:n=sT(e,Ul(o),!1)}return n}function oq(n){let e=n.startState,t=e.facet(iT),i=n;for(let r=t.length-1;r>=0;r--){let o=t[r](n);o&&Object.keys(o).length&&(i=oT(i,x0(e,o,n.changes.newLength),!0))}return i==n?n:Ft.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var sq=[];function Ul(n){return n==null?sq:Array.isArray(n)?n:[n]}var ln=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(ln||(ln={})),aq=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,b0;try{b0=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function lq(n){if(b0)return b0.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||aq.test(t)))return!0}return!1}function cq(n){return e=>{if(!/\S/.test(e))return ln.Space;if(lq(e))return ln.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return ln.Word;return ln.Other}}var Ze=class n{constructor(e,t,i,r,o,s){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=o,s&&(s._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)dh(this,a<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return dh(this,i),Cg(this,i)}update(...e){return sT(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let a of e.effects)a.is(Ns.reconfigure)?(t&&(r=new Map,t.compartments.forEach((l,c)=>r.set(c,l)),t=null),r.set(a.value.compartment,a.value.extension)):a.is(de.reconfigure)?(t=null,i=a.value):a.is(de.appendConfig)&&(t=null,i=Ul(i).concat(a.value));let o;t?o=e.startState.values.slice():(t=wg.resolve(i,r,this),o=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let s=e.startState.facet(g0)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,s,o,(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:$.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),o=[i.range],s=Ul(i.effects);for(let a=1;a<t.ranges.length;a++){let l=e(t.ranges[a]),c=this.changes(l.changes),u=c.map(r);for(let h=0;h<a;h++)o[h]=o[h].map(u);let f=r.mapDesc(c,!0);o.push(l.range.map(f)),r=r.compose(u),s=de.mapEffects(s,u).concat(de.mapEffects(Ul(l.effects),f))}return{changes:r,selection:$.create(o,t.mainIndex),effects:s}}changes(e=[]){return e instanceof cn?e:cn.of(e,this.doc.length,this.facet(n.lineSeparator))}toText(e){return be.of(e.split(this.facet(n.lineSeparator)||h0))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(dh(this,t),Cg(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof qt&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let o in i)if(Object.prototype.hasOwnProperty.call(e,o)){let s=i[o],a=e[o];r.push(s.init(l=>s.spec.fromJSON(a,l)))}}return n.create({doc:e.doc,selection:$.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=wg.resolve(e.extensions||[],new Map),i=e.doc instanceof be?e.doc:be.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||h0)),r=e.selection?e.selection instanceof $?e.selection:$.single(e.selection.anchor,e.selection.head):$.single(0);return ZR(r,i.length),t.staticFacet(g0)||(r=r.asSingle()),new n(t,i,r,t.dynamicSlots.map(()=>null),(o,s)=>s.create(o),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||` 279`}get readOnly(){return this.facet(rT)}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 o=+(r||1);return!o||o>t.length?i:t[o-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let o of this.facet(JR))for(let s of o(this,t,i))Object.prototype.hasOwnProperty.call(s,e)&&r.push(s[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return cq(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),o=this.charCategorizer(e),s=e-i,a=e-i;for(;s>0;){let l=Dt(t,s,!1);if(o(t.slice(l,s))!=ln.Word)break;s=l}for(;a<r;){let l=Dt(t,a);if(o(t.slice(a,l))!=ln.Word)break;a=l}return s==a?null:$.range(s+i,a+i)}};Ze.allowMultipleSelections=g0;Ze.tabSize=H.define({combine:n=>n.length?n[0]:4});Ze.lineSeparator=eT;Ze.readOnly=rT;Ze.phrases=H.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])}});Ze.languageData=JR;Ze.changeFilter=tT;Ze.transactionFilter=nT;Ze.transactionExtender=iT;Ns.reconfigure=de.define();function Io(n,e,t={}){let i={};for(let r of n)for(let o of Object.keys(r)){let s=r[o],a=i[o];if(a===void 0)i[o]=s;else if(!(a===s||s===void 0))if(Object.hasOwnProperty.call(t,o))i[o]=t[o](a,s);else throw new Error("Config merge conflict for field "+o)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var ei=class{eq(e){return this==e}range(e,t=e){return mh.create(e,t,this)}};ei.prototype.startSide=ei.prototype.endSide=0;ei.prototype.point=!1;ei.prototype.mapMode=Ot.TrackDel;function k0(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}var mh=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 _0(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var w0=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 o=i?this.to:this.from;for(let s=r,a=o.length;;){if(s==a)return s;let l=s+a>>1,c=o[l]-e||(i?this.value[l].endSide:this.value[l].startSide)-t;if(l==s)return c>=0?s:a;c>=0?a=l:s=l+1}}between(e,t,i,r){for(let o=this.findIndex(t,-1e9,!0),s=this.findIndex(i,1e9,!1,o);o<s;o++)if(r(this.from[o]+e,this.to[o]+e,this.value[o])===!1)return!1}map(e,t){let i=[],r=[],o=[],s=-1,a=-1;for(let l=0;l<this.value.length;l++){let c=this.value[l],u=this.from[l]+e,f=this.to[l]+e,h,d;if(u==f){let p=t.mapPos(u,c.startSide,c.mapMode);if(p==null||(h=d=p,c.startSide!=c.endSide&&(d=t.mapPos(u,c.endSide),d<h)))continue}else if(h=t.mapPos(u,c.startSide),d=t.mapPos(f,c.endSide),h>d||h==d&&c.startSide>0&&c.endSide<=0)continue;(d-h||c.endSide-c.startSide)<0||(s<0&&(s=h),c.point&&(a=Math.max(a,d-h)),i.push(c),r.push(h-s),o.push(d-s))}return{mapped:i.length?new n(r,o,i,a):null,pos:s}}},Be=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:o=this.length}=e,s=e.filter;if(t.length==0&&!s)return this;if(i&&(t=t.slice().sort(_0)),this.isEmpty)return t.length?n.of(t):this;let a=new Eg(this,null,-1).goto(0),l=0,c=[],u=new Nr;for(;a.value||l<t.length;)if(l<t.length&&(a.from-t[l].from||a.startSide-t[l].value.startSide)>=0){let f=t[l++];u.addInner(f.from,f.to,f.value)||c.push(f)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(a.chunkIndex)<t[l].from)&&(!s||r>this.chunkEnd(a.chunkIndex)||o<this.chunkPos[a.chunkIndex])&&u.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!s||r>a.to||o<a.from||s(a.from,a.to,a.value))&&(u.addInner(a.from,a.to,a.value)||c.push(mh.create(a.from,a.to,a.value))),a.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?n.empty:this.nextLayer.update({add:c,filter:s,filterFrom:r,filterTo:o}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],r=-1;for(let s=0;s<this.chunk.length;s++){let a=this.chunkPos[s],l=this.chunk[s],c=e.touchesRange(a,a+l.length);if(c===!1)r=Math.max(r,l.maxPoint),t.push(l),i.push(e.mapPos(a));else if(c===!0){let{mapped:u,pos:f}=l.map(a,e);u&&(r=Math.max(r,u.maxPoint),t.push(u),i.push(f))}}let o=this.nextLayer.map(e);return t.length==0?o:new n(i,t,o||n.empty,r)}between(e,t,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let o=this.chunkPos[r],s=this.chunk[r];if(t>=o&&e<=o+s.length&&s.between(o,e-o,t-o,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return gh.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return gh.from(e).goto(t)}static compare(e,t,i,r,o=-1){let s=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=o),a=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=o),l=KR(s,a,i),c=new Is(s,l,o),u=new Is(a,l,o);i.iterGaps((f,h,d)=>GR(c,f,u,h,d,r)),i.empty&&i.length==0&&GR(c,0,u,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let o=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),s=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(o.length!=s.length)return!1;if(!o.length)return!0;let a=KR(o,s),l=new Is(o,a,0).goto(i),c=new Is(s,a,0).goto(i);for(;;){if(l.to!=c.to||!C0(l.active,c.active)||l.point&&(!c.point||!k0(l.point,c.point)))return!1;if(l.to>r)return!0;l.next(),c.next()}}static spans(e,t,i,r,o=-1){let s=new Is(e,null,o).goto(t),a=t,l=s.openStart;for(;;){let c=Math.min(s.to,i);if(s.point){let u=s.activeForPoint(s.to),f=s.pointFrom<t?u.length+1:s.point.startSide<0?u.length:Math.min(u.length,l);r.point(a,c,s.point,u,f,s.pointRank),l=Math.min(s.openEnd(c),u.length)}else c>a&&(r.span(a,c,s.active,l),l=s.openEnd(c));if(s.to>i)return l+(s.point&&s.to>i?1:0);a=s.to,s.next()}}static of(e,t=!1){let i=new Nr;for(let r of e instanceof mh?[e]:t?uq(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}};Be.empty=new Be([],[],null,-1);function uq(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(_0(e,i)>0)return n.slice().sort(_0);e=i}return n}Be.empty.nextLayer=Be.empty;var Nr=class n{finishChunk(e){this.chunks.push(new w0(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(Be.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=Be.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function KR(n,e,t){let i=new Map;for(let o of n)for(let s=0;s<o.chunk.length;s++)o.chunk[s].maxPoint<=0&&i.set(o.chunk[s],o.chunkPos[s]);let r=new Set;for(let o of e)for(let s=0;s<o.chunk.length;s++){let a=i.get(o.chunk[s]);a!=null&&(t?t.mapPos(a):a)==o.chunkPos[s]&&!(t!=null&&t.touchesRange(a,a+o.chunk[s].length))&&r.add(o.chunk[s])}return r}var Eg=class{constructor(e,t,i,r=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},gh=class n{constructor(e){this.heap=e}static from(e,t=null,i=-1){let r=[];for(let o=0;o<e.length;o++)for(let s=e[o];!s.isEmpty;s=s.nextLayer)s.maxPoint>=i&&r.push(new Eg(s,t,i,o));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--)u0(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--)u0(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(),u0(this.heap,0)}}};function u0(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1<n.length&&r.compare(n[i+1])>=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}var Is=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=gh.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){gg(this.active,e),gg(this.activeTo,e),gg(this.activeRank,e),this.minActive=XR(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:o}=this.cursor;for(;t<this.activeRank.length&&(o-this.activeRank[t]||r-this.activeTo[t])>0;)t++;yg(this.active,t,i),yg(this.activeTo,t,r),yg(this.activeRank,t,o),e&&yg(e,t,this.cursor.from),this.minActive=XR(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&&gg(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 o=this.cursor.value;if(!o.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=o,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=o.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&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 GR(n,e,t,i,r,o){n.goto(e),t.goto(i);let s=i+r,a=i,l=i-e,c=!!o.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,s);if(n.point||t.point?(n.point&&t.point&&k0(n.point,t.point)&&C0(n.activeForPoint(n.to),t.activeForPoint(t.to))||o.comparePoint(a,p,n.point,t.point),u=!1):(u&&o.boundChange(a),p>a&&!C0(n.active,t.active)&&o.compareRange(a,p,n.active,t.active),c&&p<s&&(f||n.openEnd(d)!=t.openEnd(d))&&(u=!0)),d>s)break;a=d,h<=0&&n.next(),h>=0&&t.next()}}function C0(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!k0(n[t],e[t]))return!1;return!0}function gg(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function yg(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function XR(n,e){let t=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||n[r].endSide-n[t].endSide)<0&&(t=r,i=e[r]);return t}function $s(n,e,t=n.length){let i=0;for(let r=0;r<t&&r<n.length;)n.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=Dt(n,r));return i}function aT(n,e,t,i){for(let r=0,o=0;;){if(o>=e)return r;if(r==n.length)break;o+=n.charCodeAt(r)==9?t-o%t:1,r=Dt(n,r)}return i===!0?-1:n.length}var lT=typeof Symbol=="undefined"?"__\u037C":Symbol.for("\u037C"),R0=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),cT=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},ni=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function o(s,a,l,c){let u=[],f=/^@(\w+)\b/.exec(s[0]),h=f&&f[1]=="keyframes";if(f&&a==null)return l.push(s[0]+";");for(let d in a){let p=a[d];if(/&/.test(d))o(d.split(/,\s*/).map(m=>s.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,l);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");o(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?s.map(i):s).join(", ")+" {"+u.join(" ")+"}")}for(let s in e)o(r(s),e[s],this.rules)}getRules(){return this.rules.join(` 280`)}static newName(){let e=cT[lT]||1;return cT[lT]=e+1,"\u037C"+e.toString(36)}static mount(e,t,i){let r=e[R0],o=i&&i.nonce;r?o&&r.setNonce(o):r=new T0(e,o),r.mount(Array.isArray(t)?t:[t],e)}},uT=new Map,T0=class{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let o=uT.get(i);if(o)return e[R0]=o;this.sheet=new r.CSSStyleSheet,uT.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[R0]=this}mount(e,t){let i=this.sheet,r=0,o=0;for(let s=0;s<e.length;s++){let a=e[s],l=this.modules.indexOf(a);if(l<o&&l>-1&&(this.modules.splice(l,1),o--,l=-1),l==-1){if(this.modules.splice(o++,0,a),i)for(let c=0;c<a.rules.length;c++)i.insertRule(a.rules[c],r++)}else{for(;o<l;)r+=this.modules[o++].rules.length;r+=a.rules.length,o++}}if(i)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let s="";for(let l=0;l<this.modules.length;l++)s+=this.modules[l].getRules()+` 281`;this.styleTag.textContent=s;let a=t.head||t;this.styleTag.parentNode!=a&&a.insertBefore(this.styleTag,a.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var jr={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Kl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},fq=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),hq=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(wt=0;wt<10;wt++)jr[48+wt]=jr[96+wt]=String(wt);var wt;for(wt=1;wt<=24;wt++)jr[wt+111]="F"+wt;var wt;for(wt=65;wt<=90;wt++)jr[wt]=String.fromCharCode(wt+32),Kl[wt]=String.fromCharCode(wt);var wt;for(Sg in jr)Kl.hasOwnProperty(Sg)||(Kl[Sg]=jr[Sg]);var Sg;function fT(n){var e=fq&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||hq&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Kl:jr)[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 Pn(){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(;e<arguments.length;e++)hT(n,arguments[e]);return n}function hT(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)hT(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}var un=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""},L0=typeof document!="undefined"?document:{documentElement:{style:{}}},B0=/Edge\/(\d+)/.exec(un.userAgent),zT=/MSIE \d/.test(un.userAgent),N0=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(un.userAgent),Jg=!!(zT||N0||B0),dT=!Jg&&/gecko\/(\d+)/i.test(un.userAgent),A0=!Jg&&/Chrome\/(\d+)/.exec(un.userAgent),pT="webkitFontSmoothing"in L0.documentElement.style,$0=!Jg&&/Apple Computer/.test(un.vendor),mT=$0&&(/Mobile\/\w+/.test(un.userAgent)||un.maxTouchPoints>2),z={mac:mT||/Mac/.test(un.platform),windows:/Win/.test(un.platform),linux:/Linux|X11/.test(un.platform),ie:Jg,ie_version:zT?L0.documentMode||6:N0?+N0[1]:B0?+B0[1]:0,gecko:dT,gecko_version:dT?+(/Firefox\/(\d+)/.exec(un.userAgent)||[0,0])[1]:0,chrome:!!A0,chrome_version:A0?+A0[1]:0,ios:mT,android:/Android\b/.test(un.userAgent),webkit:pT,webkit_version:pT?+(/\bAppleWebKit\/(\d+)/.exec(un.userAgent)||[0,0])[1]:0,safari:$0,safari_version:$0?+(/\bVersion\/(\d+(\.\d+)?)/.exec(un.userAgent)||[0,0])[1]:0,tabSize:L0.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function _b(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 Ng=Object.create(null);function wb(n,e,t){if(n==e)return!0;n||(n=Ng),e||(e=Ng);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 o of i)if(o!=t&&(r.indexOf(o)==-1||n[o]!==e[o]))return!1;return!0}function dq(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 gT(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 pq(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}var ai=class{eq(e){return!1}updateDOM(e,t,i){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},si=(function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n})(si||(si={})),he=class extends ei{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new kh(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new qs(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:o,end:s}=WT(e,t);i=(o?t?-3e8:-1:5e8)-1,r=(s?t?2e8:1:-6e8)+1}return new qs(e,i,r,t,e.widget||null,!0)}static line(e){return new Rh(e)}static set(e,t=!1){return Be.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};he.none=Be.empty;var kh=class n extends he{constructor(e){let{start:t,end:i}=WT(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?_b(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ng}eq(e){return this==e||e instanceof n&&this.tagName==e.tagName&&wb(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)}};kh.prototype.point=!1;var Rh=class n extends he{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&wb(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)}};Rh.prototype.mapMode=Ot.TrackBefore;Rh.prototype.point=!0;var qs=class n extends he{constructor(e,t,i,r,o,s){super(t,i,o,e),this.block=r,this.isReplace=s,this.mapMode=r?t<=0?Ot.TrackBefore:Ot.TrackAfter:Ot.TrackDel}get type(){return this.startSide!=this.endSide?si.WidgetRange:this.startSide<=0?si.WidgetBefore:si.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&mq(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)}};qs.prototype.point=!0;function WT(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 mq(n,e){return n==e||!!(n&&e&&n.compare(e))}function Jl(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 $g=class n extends ei{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof n&&this.tagName==e.tagName&&wb(this.attributes,e.attributes)}static create(e){return new n(e.tagName,e.attributes||Ng,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return Be.of(e,t)}};$g.prototype.startSide=$g.prototype.endSide=-1;function Th(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function j0(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function xh(n,e){if(!e.anchorNode)return!1;try{return j0(n,e.anchorNode)}catch{return!1}}function bh(n){return n.nodeType==3?Mh(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function _h(n,e,t,i){return t?yT(n,e,t,i,-1)||yT(n,e,t,i,1):!1}function No(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function jg(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function yT(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:Vr(n))){if(n.nodeName=="DIV")return!1;let o=n.parentNode;if(!o||o.nodeType!=1)return!1;e=No(n)+(r<0?0:1),n=o}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?Vr(n):0}else return!1}}function Vr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ah(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function gq(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 UT(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 yq(n,e,t,i,r,o,s,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=gq(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 _=u.getBoundingClientRect();({scaleX:p,scaleY:m}=UT(u,_)),h={left:_.left,right:_.left+u.clientWidth*p,top:_.top,bottom:_.top+u.clientHeight*m}}let g=0,b=0;if(r=="nearest")e.top<h.top+s?(b=e.top-(h.top+s),t>0&&e.bottom>h.bottom+b&&(b=e.bottom-h.bottom+s)):e.bottom>h.bottom-s&&(b=e.bottom-h.bottom+s,t<0&&e.top-b<h.top&&(b=e.top-(h.top+s)));else{let _=e.bottom-e.top,v=h.bottom-h.top;b=(r=="center"&&_<=v?e.top+_/2-v/2:r=="start"||r=="center"&&t<0?e.top-s:e.bottom-v+s)-h.top}if(i=="nearest"?e.left<h.left+o?(g=e.left-(h.left+o),t>0&&e.right>h.right+g&&(g=e.right-h.right+o)):e.right>h.right-o&&(g=e.right-h.right+o,t<0&&e.left<h.left+g&&(g=e.left-(h.left+o))):g=(i=="center"?e.left+(e.right-e.left)/2-(h.right-h.left)/2:i=="start"==a?e.left-o:e.right-(h.right-h.left)+o)-h.left,g||b)if(d)c.scrollBy(g,b);else{let _=0,v=0;if(b){let x=u.scrollTop;u.scrollTop+=b/m,v=(u.scrollTop-x)*m}if(g){let x=u.scrollLeft;u.scrollLeft+=g/p,_=(u.scrollLeft-x)*p}e={left:e.left-_,top:e.top-v,right:e.right-_,bottom:e.bottom-v},_&&Math.abs(_-g)<1&&(i="nearest"),v&&Math.abs(v-b)<1&&(r="nearest")}if(d)break;(e.top<h.top||e.bottom>h.bottom||e.left<h.left||e.right>h.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 QT(n,e=!0){let t=n.ownerDocument,i=null,r=null;for(let o=n.parentNode;o&&!(o==t.body||(!e||i)&&r);)if(o.nodeType==1)!r&&o.scrollHeight>o.clientHeight&&(r=o),e&&!i&&o.scrollWidth>o.clientWidth&&(i=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:i,y:r}}var F0=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?Vr(t):0),i,Math.min(e.focusOffset,i?Vr(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},js=null;z.safari&&z.safari_version>=26&&(js=!1);function KT(n){if(n.setActive)return n.setActive();if(js)return n.focus(js);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(js==null?{get preventScroll(){return js={preventScroll:!0},!0}}:void 0),!js){js=!1;for(let t=0;t<e.length;){let i=e[t++],r=e[t++],o=e[t++];i.scrollTop!=r&&(i.scrollTop=r),i.scrollLeft!=o&&(i.scrollLeft=o)}}}var vT;function Mh(n,e,t=e){let i=vT||(vT=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function ec(n,e,t,i){let r={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let o=new KeyboardEvent("keydown",r);o.synthetic=!0,n.dispatchEvent(o);let s=new KeyboardEvent("keyup",r);return s.synthetic=!0,n.dispatchEvent(s),o.defaultPrevented||s.defaultPrevented}function vq(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function xq(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,Vr(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=Vr(t))}else{if(t==n)return!0;i=No(t),t=t.parentNode}}function GT(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function XT(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=Vr(t)}else if(t.parentNode&&!jg(t))i=No(t),t=t.parentNode;else return null}}function YT(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!jg(t))i=No(t)+1,t=t.parentNode;else return null}}var Ji=class n{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new n(e.parentNode,No(e),t)}static after(e,t){return new n(e.parentNode,No(e)+1,t)}},We=(function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n})(We||(We={})),Vs=We.LTR,Cb=We.RTL;function ZT(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}var bq=ZT("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),_q=ZT("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),q0=Object.create(null),Zi=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);q0[e]=t,q0[t]=-e}function JT(n){return n<=247?bq[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?_q[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}var wq=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,oi=class{get dir(){return this.level%2?Cb:Vs}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,r){let o=-1;for(let s=0;s<e.length;s++){let a=e[s];if(a.from<=t&&a.to>=t){if(a.level==i)return s;(o<0||(r!=0?r<0?a.from<t:a.to>t:e[o].level>a.level))&&(o=s)}}if(o<0)throw new RangeError("Index out of range");return o}};function eA(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],r=e[t];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!eA(i.inner,r.inner))return!1}return!0}var Ne=[];function Cq(n,e,t,i,r){for(let o=0;o<=i.length;o++){let s=o?i[o-1].to:e,a=o<i.length?i[o].from:t,l=o?256:r;for(let c=s,u=l,f=l;c<a;c++){let h=JT(n.charCodeAt(c));h==512?h=u:h==8&&f==4&&(h=16),Ne[c]=h==4?2:h,h&7&&(f=h),u=h}for(let c=s,u=l,f=l;c<a;c++){let h=Ne[c];if(h==128)c<a-1&&u==Ne[c+1]&&u&24?h=Ne[c]=u:Ne[c]=256;else if(h==64){let d=c+1;for(;d<a&&Ne[d]==64;)d++;let p=c&&u==8||d<t&&Ne[d]==8?f==1?1:8:256;for(let m=c;m<d;m++)Ne[m]=p;c=d-1}else h==8&&f==1&&(Ne[c]=1);u=h,h&7&&(f=h)}}}function Eq(n,e,t,i,r){let o=r==1?2:1;for(let s=0,a=0,l=0;s<=i.length;s++){let c=s?i[s-1].to:e,u=s<i.length?i[s].from:t;for(let f=c,h,d,p;f<u;f++)if(d=q0[h=n.charCodeAt(f)])if(d<0){for(let m=a-3;m>=0;m-=3)if(Zi[m+1]==-d){let g=Zi[m+2],b=g&2?r:g&4?g&1?o:r:0;b&&(Ne[f]=Ne[Zi[m]]=b),a=m;break}}else{if(Zi.length==189)break;Zi[a++]=f,Zi[a++]=h,Zi[a++]=l}else if((p=Ne[f])==2||p==1){let m=p==r;l=m?0:1;for(let g=a-3;g>=0;g-=3){let b=Zi[g+2];if(b&2)break;if(m)Zi[g+2]|=2;else{if(b&4)break;Zi[g+2]|=4}}}}}function Sq(n,e,t,i){for(let r=0,o=i;r<=t.length;r++){let s=r?t[r-1].to:n,a=r<t.length?t[r].from:e;for(let l=s;l<a;){let c=Ne[l];if(c==256){let u=l+1;for(;;)if(u==a){if(r==t.length)break;u=t[r++].to,a=r<t.length?t[r].from:e}else if(Ne[u]==256)u++;else break;let f=o==1,h=(u<e?Ne[u]:i)==1,d=f==h?f?1:2:i;for(let p=u,m=r,g=m?t[m-1].to:n;p>l;)p==g&&(p=t[--m].from,g=m?t[m-1].to:n),Ne[--p]=d;l=u}else o=c,l++}}}function V0(n,e,t,i,r,o,s){let a=i%2?2:1;if(i%2==r%2)for(let l=e,c=0;l<t;){let u=!0,f=!1;if(c==o.length||l<o[c].from){let m=Ne[l];m!=a&&(u=!1,f=m==16)}let h=!u&&a==1?[]:null,d=u?i:i+1,p=l;e:for(;;)if(c<o.length&&p==o[c].from){if(f)break e;let m=o[c];if(!u)for(let g=m.to,b=c+1;;){if(g==t)break e;if(b<o.length&&o[b].from==g)g=o[b++].to;else{if(Ne[g]==a)break e;break}}if(c++,h)h.push(m);else{m.from>l&&s.push(new oi(l,m.from,d));let g=m.direction==Vs!=!(d%2);H0(n,g?i+1:i,r,m.inner,m.from,m.to,s),l=m.to}p=m.to}else{if(p==t||(u?Ne[p]!=a:Ne[p]==a))break;p++}h?V0(n,l,p,i+1,r,h,s):l<p&&s.push(new oi(l,p,d)),l=p}else for(let l=t,c=o.length;l>e;){let u=!0,f=!1;if(!c||l>o[c-1].to){let m=Ne[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==o[c-1].to){if(f)break e;let m=o[--c];if(!u)for(let g=m.from,b=c;;){if(g==e)break e;if(b&&o[b-1].to==g)g=o[--b].from;else{if(Ne[g-1]==a)break e;break}}if(h)h.push(m);else{m.to<l&&s.push(new oi(m.to,l,d));let g=m.direction==Vs!=!(d%2);H0(n,g?i+1:i,r,m.inner,m.from,m.to,s),l=m.from}p=m.from}else{if(p==e||(u?Ne[p-1]!=a:Ne[p-1]==a))break;p--}h?V0(n,p,l,i+1,r,h,s):p<l&&s.push(new oi(p,l,d)),l=p}}function H0(n,e,t,i,r,o,s){let a=e%2?2:1;Cq(n,r,o,i,a),Eq(n,r,o,i,a),Sq(r,o,i,a),V0(n,r,o,e,t,i,s)}function Oq(n,e,t){if(!n)return[new oi(0,0,e==Cb?1:0)];if(e==Vs&&!t.length&&!wq.test(n))return tA(n.length);if(t.length)for(;n.length>Ne.length;)Ne[Ne.length]=256;let i=[],r=e==Vs?0:1;return H0(n,r,r,t,0,n.length,i),i}function tA(n){return[new oi(0,n,0)]}var nA="";function kq(n,e,t,i,r){var o;let s=i.head-n.from,a=oi.find(e,s,(o=i.bidiLevel)!==null&&o!==void 0?o:-1,i.assoc),l=e[a],c=l.side(r,t);if(s==c){let h=a+=r?1:-1;if(h<0||h>=e.length)return null;l=e[a=h],s=l.side(!r,t),c=l.side(r,t)}let u=Dt(n.text,s,l.forward(r,t));(u<l.from||u>l.to)&&(u=c),nA=n.text.slice(Math.min(s,u),Math.max(s,u));let f=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return f&&u==c&&f.level+(r?0:1)<l.level?$.cursor(f.side(!r,t)+n.from,f.forward(r,t)?1:-1,f.level):$.cursor(u+n.from,l.forward(r,t)?-1:1,l.level)}function Rq(n,e,t){for(let i=e;i<t;i++){let r=JT(n.charCodeAt(i));if(r==1)return Vs;if(r==2||r==4)return Cb}return Vs}var iA=H.define(),rA=H.define(),oA=H.define(),sA=H.define(),z0=H.define(),aA=H.define(),lA=H.define(),Eb=H.define(),Sb=H.define(),cA=H.define({combine:n=>n.some(e=>e)}),Tq=H.define({combine:n=>n.some(e=>e)}),uA=H.define(),wh=class n{constructor(e,t,i,r,o,s=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=o,this.isSnapshot=s}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($.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Og=de.define({map:(n,e)=>n.map(e)}),fA=de.define();function It(n,e,t){let i=n.facet(sA);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 Fr=H.define({combine:n=>n.length?n[0]:!0}),Aq=0,Xl=H.define({combine(n){return n.filter((e,t)=>{for(let i=0;i<t;i++)if(n[i].plugin==e.plugin)return!1;return!0})}}),Yt=class n{constructor(e,t,i,r,o){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.baseExtensions=o(this),this.extension=this.baseExtensions.concat(Xl.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Xl.of({plugin:this,arg:e}))}static define(e,t){let{eventHandlers:i,eventObservers:r,provide:o,decorations:s}=t||{};return new n(Aq++,e,i,r,a=>{let l=[];return s&&l.push(ey.of(c=>{let u=c.plugin(a);return u?s(u):he.none})),o&&l.push(o(a)),l})}static fromClass(e,t){return n.define((i,r)=>new e(i,r),t)}},Ch=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(It(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){It(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){It(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},hA=H.define(),Ob=H.define(),ey=H.define(),dA=H.define(),kb=H.define(),Ph=H.define(),pA=H.define();function xT(n,e){let t=n.state.facet(pA);if(!t.length)return t;let i=t.map(o=>o instanceof Function?o(n):o),r=[];return Be.spans(i,e.from,e.to,{point(){},span(o,s,a,l){let c=o-e.from,u=s-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=Rq(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 mA=H.define();function Rb(n){let e=0,t=0,i=0,r=0;for(let o of n.state.facet(mA)){let s=o(n);s&&(s.left!=null&&(e=Math.max(e,s.left)),s.right!=null&&(t=Math.max(t,s.right)),s.top!=null&&(i=Math.max(i,s.top)),s.bottom!=null&&(r=Math.max(r,s.bottom)))}return{left:e,right:t,top:i,bottom:r}}var yh=H.define(),_i=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.toA<i.fromA)break;i=i.join(r),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let r=0,o=0,s=0;;){let a=r<e.length?e[r].fromB:1e9,l=o<t.length?t[o]:1e9,c=Math.min(a,l);if(c==1e9)break;let u=c+s,f=c,h=u;for(;;)if(o<t.length&&t[o]<=f){let d=t[o+1];o+=2,f=Math.max(f,d);for(let p=r;p<e.length&&e[p].fromB<=f;p++)s=e[p].toA-e[p].toB;h=Math.max(h,d+s)}else if(r<e.length&&e[r].fromB<=f){let d=e[r++];f=Math.max(f,d.toB),h=Math.max(h,d.toA),s=d.toA-d.toB}else break;i.push(new n(u,h,c,f))}return i}},Fg=class n{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=cn.empty(this.startState.doc.length);for(let o of i)this.changes=this.changes.compose(o.changes);let r=[];this.changes.iterChangedRanges((o,s,a,l)=>r.push(new _i(o,s,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}},Mq=[],it=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 Mq}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&&dq(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=No(this.dom),r=this.length?e>0:t>0;return new Ji(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 nc)return e;return null}static get(e){return e.cmTile}},tc=class extends it{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,o=(e==null?void 0:e.node)==t?e:null,s=0;for(let a of this.children){if(a.sync(e),s+=a.length+a.breakAfter,r=i?i.nextSibling:t.firstChild,o&&r!=a.dom&&(o.written=!0),a.dom.parentNode==t)for(;r&&r!=a.dom;)r=bT(r);else t.insertBefore(a.dom,r);i=a.dom}for(r=i?i.nextSibling:t.firstChild,o&&r&&(o.written=!0);r;)r=bT(r);this.length=s}};function bT(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var nc=class extends tc{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=it.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,r=0,o=0;;)if(r==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&o++,r=t.pop()}else{let s=i.children[r++];if(s instanceof qr)t.push(r),i=s,r=0;else{let a=o+s.length,l=e(s,o);if(l!==void 0)return l;o=a+s.breakAfter}}}resolveBlock(e,t){let i,r=-1,o,s=-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)}(l<e||e==c&&(t<-1?a.length:a.covers(1)))&&(!i||!a.isWidget()&&i.isWidget())&&(i=a,r=e-l),(c>e||e==l&&(t>1?a.length:a.covers(-1)))&&(!o||!a.isWidget()&&o.isWidget())&&(o=a,s=e-l)}}),!i&&!o)throw new Error("No tile at position "+e);return i&&t<0||!o?{tile:i,offset:r}:{tile:o,offset:s}}},qr=class n extends tc{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}},ic=class n extends tc{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,o=-1,s=null,a=-1;function l(u,f){for(let h=0,d=0;h<u.children.length&&d<=f;h++){let p=u.children[h],m=d+p.length;m>=f&&(p.isComposite()?l(p,f-d):(!s||s.isHidden&&(t>0||i&&Dq(s,p)))&&(m>f||p.flags&32)?(s=p,a=f-d):(d<f||p.flags&16&&!p.isHidden)&&(r=p,o=f-d)),d=m}}l(this,e);let c=(t<0?r:s)||r||s;return c?{tile:c,offset:c==r?o:a}:null}coordsIn(e,t){let i=this.resolveInline(e,t,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),t):Pq(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:r,offset:o}=i;if(this.dom.contains(r.dom))return r.isText()?new Ji(r.dom,Math.min(r.dom.nodeValue.length,o)):r.domPosFor(o,r.flags&16?1:r.flags&32?-1:t);let s=i.tile.parent,a=!1;for(let l of s.children){if(a)return new Ji(l.dom,0);l==i.tile&&(a=!0)}}return new Ji(this.dom,0)}};function Pq(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=bh(e);return t[t.length-1]||null}function Dq(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}var bn=class n extends tc{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new n(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}},Fs=class n extends it{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let i=this.dom.nodeValue.length;e>i&&(e=i);let r=e,o=e,s=0;e==0&&t<0||e==i&&t>=0?z.chrome||z.gecko||(e?(r--,s=1):o<i&&(o++,s=-1)):t<0?r--:o<i&&o++;let a=Mh(this.dom,r,o).getClientRects();if(!a.length)return null;let l=a[(s?s<0:t>=0)?0:a.length-1];return z.safari&&!s&&l.width==0&&(l=Array.prototype.find.call(a,c=>c.width)||l),s?Ah(l,s<0):l||null}static of(e,t){let i=new n(t||document.createTextNode(e),e);return t||(i.flags|=2),i}},Hs=class n extends it{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 Ah(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let o=this.dom.getClientRects(),s=null;if(!o.length)return null;let a=this.flags&16?!0:this.flags&32?!1:e>0;for(let l=a?o.length-1:0;s=o[l],!(e>0?l==0:l==o.length-1||s.top<s.bottom);l+=a?-1:1);return Ah(s,!a)}}get overrideDOMText(){if(!this.length)return be.empty;let{root:e}=this;if(!e)return be.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,r,o){return o||(o=e.toDOM(t),e.editable||(o.contentEditable="false")),new n(o,i,e,r)}},rc=class extends it{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return be.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},W0=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:r,index:o,beforeBreak:s,parents:a}=this;for(;e||t>0;)if(r.isComposite())if(s){if(!e)break;i&&i.break(),e--,s=!1}else if(o==r.children.length){if(!e&&!a.length)break;i&&i.leave(r),s=!!r.breakAfter,{tile:r,index:o}=a.pop(),o++}else{let l=r.children[o],c=l.breakAfter;(t>0?l.length<=e:l.length<e)&&(!i||i.skip(l,0,l.length)!==!1||!l.isComposite)?(s=!!c,o++,e-=l.length):(a.push({tile:r,index:o}),r=l,o=0,i&&l.isComposite()&&i.enter(l))}else if(o==r.length)s=!!r.breakAfter,{tile:r,index:o}=a.pop(),o++;else if(e){let l=Math.min(e,r.length-o);i&&i.skip(r,o,o+l),e-=l,o+=l}else break;return this.tile=r,this.index=o,this.beforeBreak=s,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},U0=class{constructor(e,t,i,r){this.from=e,this.to=t,this.wrapper=i,this.rank=r}},Q0=class{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,r){var o;this.flushBuffer();let s=this.ensureMarks(t,i),a=s.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let l=s.children[s.children.length-1]=new Fs(a.dom,a.text+e);l.parent=s}else s.append(r||Fs.of(e,(o=this.cache.find(Fs))===null||o===void 0?void 0:o.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?M0(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=i;for(let a=t.marks.length-1;a>=0;a--){let l=t.marks[a],c=r.lastChild;if(c instanceof bn&&c.mark.eq(l.mark))c.dom!=l.dom&&c.setDOM(M0(l.dom)),r=c;else{if(this.cache.reused.get(l)){let f=it.get(l.dom);f&&f.setDOM(M0(l.dom))}let u=bn.of(l.mark,l.dom);r.append(u),r=u}this.cache.reused.set(l,2)}let o=it.get(e.text);o&&this.cache.reused.set(o,2);let s=new Fs(e.text,e.text.nodeValue);s.flags|=8,this.pos=e.range.toB,r.append(s)}addInlineWidget(e,t,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let o=this.ensureMarks(t,i);!r&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.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=gA);let r=ic.start(e,t||((i=this.cache.find(ic))===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 o=e.length-1;o>=0;o--){let s=e[o],a;if(t>0&&(a=r.lastChild)&&a instanceof bn&&a.mark.eq(s))r=a,t--;else{let l=bn.of(s,(i=this.cache.find(bn,c=>c.mark.eq(s)))===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||!_T(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(z.ios&&_T(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(P0,0,32)||new Hs(P0.toDOM(),0,P0,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,i=new U0(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let r=t.lastChild;if(i.from<this.pos&&r instanceof qr&&r.wrapper.eq(i.wrapper))t=r;else{let o=qr.of(i.wrapper,(e=this.cache.find(qr,s=>s.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(o),t=o}}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(rc,void 0,1);return i&&(i.flags=t),i||new rc(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},K0=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:o,done:s}=this.cursor.next(this.skipCount);if(this.skipCount=0,s)throw new Error("Ran out of text content when drawing inline views");this.text=r;let a=this.textOff=Math.min(e,r.length);return o?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}},qg=[Hs,ic,Fs,bn,rc,qr,nc];for(let n=0;n<qg.length;n++)qg[n].bucket=n;var G0=class{constructor(e){this.view=e,this.buckets=qg.map(()=>[]),this.index=qg.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,o=this.buckets[r],s=this.index[r];for(let a=o.length-1;a>=0;a--){let l=(a+s)%o.length,c=o[l];if((!t||t(c))&&!this.reused.has(c))return o.splice(l,1),l<s&&this.index[r]--,this.reused.set(c,i),c}return null}findWidget(e,t,i){let r=this.buckets[0];if(r.length)for(let o=0,s=0;;o++){if(o==r.length){if(s)return null;s=1,o=0}let a=r[o];if(!this.reused.has(a)&&(s==0?a.widget.compare(e):a.widget.constructor==e.constructor&&e.updateDOM(a.dom,this.view,a.widget)))return r.splice(o,1),o<this.index[0]&&this.index[0]--,a.widget==e&&a.length==t&&(a.flags&497)==i?(this.reused.set(a,1),a):(this.reused.set(a,2),new Hs(a.dom,t,e,a.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},X0=class{constructor(e,t,i,r,o){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=o,this.openWidget=!1,this.openMarks=0,this.cache=new G0(e),this.text=new K0(e.state.doc),this.builder=new Q0(this.cache,new nc(e,e.contentDOM),Be.iter(i)),this.cache.reused.set(t,2),this.old=new W0(t),this.reuseWalker={skip:(s,a,l)=>{if(this.cache.add(s),s.isComposite())return!1},enter:s=>this.cache.add(s),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let r=0,o=0,s=0;;){let a=s<e.length?e[s++]:null,l=a?a.fromA:this.old.root.length;if(l>r){let c=l-r;this.preserve(c,!s,!a),r=l,o+=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<t.range.toA?1:-1),this.emit(o,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,a.toA),this.emit(t.range.toB,a.toB)):(this.forward(a.fromA,a.toA),this.emit(o,a.toB)),o=a.toB,r=a.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let r=Bq(this.old),o=this.openMarks;this.old.advance(e,i?1:-1,{skip:(s,a,l)=>{if(s.isWidget())if(this.openWidget)this.builder.continueWidget(l-a);else{let c=l>0||a<s.length?Hs.of(s.widget,this.view,l-a,s.flags&496,this.cache.maybeReuse(s)):this.cache.reuse(s);c.flags&256?(c.flags&=-2,this.builder.addBlockWidget(c)):(this.builder.ensureLine(null),this.builder.addInlineWidget(c,r,o),o=r.length)}else if(s.isText())this.builder.ensureLine(null),!a&&l==s.length&&!this.cache.reused.has(s)?this.builder.addText(s.text,r,o,this.cache.reuse(s)):(this.cache.add(s),this.builder.addText(s.text.slice(a,l),r,o)),o=r.length;else if(s.isLine())s.flags&=-2,this.cache.reused.set(s,1),this.builder.addLine(s);else if(s instanceof rc)this.cache.add(s);else if(s instanceof bn)this.builder.ensureLine(null),this.builder.addMark(s,r,o),this.cache.reused.set(s,1),o=r.length;else return!1;this.openWidget=!1},enter:s=>{s.isLine()?this.builder.addLineStart(s.attrs,this.cache.maybeReuse(s)):(this.cache.add(s),s instanceof bn&&r.unshift(s.mark)),this.openWidget=!1},leave:s=>{s.isLine()?r.length&&(r.length=o=0):s instanceof bn&&(r.shift(),o=Math.min(o,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,r=this.builder,o=0,s=Be.spans(this.decorations,e,t,{point:(a,l,c,u,f,h)=>{if(c instanceof qs){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(o=u.length,f>u.length)r.continueWidget(l-a);else{let d=c.widget||(c.block?$o.block:$o.inline),p=Iq(c),m=this.cache.findWidget(d,l-a,p)||Hs.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=Lq(i,c);l>a&&this.text.skip(l-a)},span:(a,l,c,u)=>{for(let f=a;f<l;){let h=this.text.next(Math.min(512,l-f));h==null?(r.addLineStartIfNotCovered(i),r.addBreak(),f++):(r.ensureLine(i),r.addText(h,c,f==a?u:c.length),f+=h.length),i=null}}});r.addLineStartIfNotCovered(i),this.openWidget=s>o,this.openMarks=s}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 o=it.get(r);if(r==this.view.contentDOM)break;o instanceof bn?t.push(o):o!=null&&o.isLine()?i=o:o instanceof qr||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new ic(r,gA):i||t.push(bn.of(new kh({tagName:r.nodeName.toLowerCase(),attributes:pq(r)}),r)))}return{line:i,marks:t}}};function _T(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 Iq(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 gA={class:"cm-line"};function Lq(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&_b(t,n),i&&(n.class+=" "+i)),n}function Bq(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 bn&&e.push(i.mark)}return e}function M0(n){let e=it.get(n);return e&&e.setDOM(n.cloneNode()),n}var $o=class extends ai{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}};$o.inline=new $o("span");$o.block=new $o("div");var P0=new class extends ai{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},Vg=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=he.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 nc(e,e.contentDOM),this.updateInner([new _i(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})=>f<this.minWidthFrom||u>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!zq(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let o=r>-1?$q(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:u,to:f}=this.hasComposition;i=new _i(u,f,e.changes.mapPos(u,-1),e.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(z.ie||z.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let s=this.decorations,a=this.blockWrappers;this.updateDeco();let l=qq(s,this.decorations,e.changes);l.length&&(i=_i.extendWithRanges(i,l));let c=Vq(a,this.blockWrappers,e.changes);return c.length&&(i=_i.extendWithRanges(i,c)),o&&!i.some(u=>u.fromA<=o.range.fromA&&u.toA>=o.range.toA)&&(i=o.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,o),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 s=this.tile,a=new X0(this.view,s,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&it.get(t.text)&&a.cache.reused.set(it.get(t.text),2),this.tile=a.run(e,t),Y0(s,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 o=z.chrome||z.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||i.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.tile.children)o.isWidget()&&o.widget instanceof Eh&&r.push(o.dom);i.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(fA)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,r=this.view.root.activeElement,o=r==i,s=!o&&!(this.view.state.facet(Fr)||i.tabIndex>-1)&&xh(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(o||t||s))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)),z.gecko&&l.empty&&!this.hasComposition&&Nq(c)){let h=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(h,c.node.childNodes[c.offset]||null)),c=u=new Ji(h,0),a=!0}let f=this.view.observer.selectionRange;(a||!f.focusNode||(!_h(c.node,c.offset,f.anchorNode,f.anchorOffset)||!_h(u.node,u.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,l))&&(this.view.observer.ignore(()=>{z.android&&z.chrome&&i.contains(f.focusNode)&&Hq(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let h=Th(this.view.root);if(h)if(l.empty){if(z.gecko){let d=jq(c.node,c.offset);if(d&&d!=3){let p=(d==1?XT:YT)(c.node,c.offset);p&&(c=new Ji(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)}s&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,u)),this.impreciseAnchor=c.precise?null:new Ji(f.anchorNode,f.anchorOffset),this.impreciseHead=u.precise?null:new Ji(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&_h(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=Th(e.root),{anchorNode:r,anchorOffset:o}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let s=this.lineAt(t.head,t.assoc);if(!s)return;let a=s.posAtStart;if(t.head==a||t.head==a+s.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,o)}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 o;if(e==i.dom)o=i.dom.childNodes[t];else{let s=Vr(e)==0?0:t==0?-1:1;for(;;){let a=e.parentNode;if(a==i.dom)break;s==0&&a.firstChild!=a.lastChild&&(e==a.firstChild?s=-1:s=1),e=a}s<0?o=e:o=e.nextSibling}if(o==i.dom.firstChild)return r;for(;o&&!it.get(o);)o=o.nextSibling;if(!o)return r+i.length;for(let s=0,a=r;;s++){let l=i.children[s];if(l.dom==o)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,o=!1,s,a=-1,l=!1;return this.tile.blockTiles((c,u)=>{if(c.isWidget()){if(c.flags&32&&u>=e)return!0;c.flags&16&&(o=!0)}else{let f=u+c.length;if(u<=e&&(i=c,r=e-u,o=f<e),f>=e&&!s&&(s=c,a=e-u,l=u>e),u>e&&s)return!0}}),!i&&!s?this.domAtPos(e,t):(o&&s?i=null:l&&i&&(s=null),i&&t<0||!s?i.domIn(r,t):s.domIn(a,t))}coordsAt(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof Eh?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(o,s){if(o.isComposite())for(let a of o.children){if(a.length>=s){let l=r(a,s);if(l)return l}if(s-=a.length,s<0)break}else if(o.isText()&&s<o.length){let a=Dt(o.text,s);if(a==s)return null;let l=Mh(o.dom,s,a).getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(c==l.length-1||u.top<u.bottom&&u.left<u.right)return u}}return null}return r(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:r}=e,o=this.view.contentDOM.clientWidth,s=o>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==We.LTR,c=0,u=(f,h,d)=>{for(let p=0;p<f.children.length&&!(h>r);p++){let m=f.children[p],g=h+m.length,b=m.dom.getBoundingClientRect(),{height:_}=b;if(d&&!p&&(c+=b.top-d.top),m instanceof qr)g>i&&u(m,h,b);else if(h>=i&&(c>0&&t.push(-c),t.push(_+c),c=0,s)){let v=m.dom.lastChild,x=v?bh(v):[];if(x.length){let C=x[x.length-1],E=l?C.right-b.left:b.right-C.left;E>a&&(a=E,this.minWidth=o,this.minWidthFrom=h,this.minWidthTo=g)}}d&&p==f.children.length-1&&(c+=d.bottom-b.bottom),h=g+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"?We.RTL:We.LTR}measureTextSize(){let e=this.tile.blockTiles(s=>{if(s.isLine()&&s.children.length&&s.length<=20){let a=0,l;for(let c of s.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let u=bh(c.dom);if(u.length!=1)return;a+=u[0].width,l=u[0].height}if(a)return{lineHeight:s.dom.getBoundingClientRect().height,charWidth:a/s.length,textHeight:l}}});if(e)return e;let t=document.createElement("div"),i,r,o;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let s=bh(t.firstChild)[0];i=t.getBoundingClientRect().height,r=s&&s.width?s.width/27:7,o=s&&s.height?s.height:i,t.remove()}),{lineHeight:i,charWidth:r,textHeight:o}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let o=r==t.viewports.length?null:t.viewports[r],s=o?o.from-1:this.view.state.doc.length;if(s>i){let a=(t.lineBlockAt(s).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(he.replace({widget:new Eh(a),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!o)break;i=o.to+1}return he.set(e)}updateDeco(){let e=1,t=this.view.state.facet(ey).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),i=!1,r=this.view.state.facet(kb).map((o,s)=>{let a=typeof o=="function";return a&&(i=!0),a?o(this.view):o});for(r.length&&(this.dynamicDecorationMap[e++]=i,t.push(Be.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(dA).map(o=>typeof o=="function"?o(this.view):o)}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(uA))try{if(u(this.view,e.range,e))return!0}catch(f){It(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),o;if(!r)return;!i.empty&&(o=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(r={left:Math.min(r.left,o.left),top:Math.min(r.top,o.top),right:Math.max(r.right,o.right),bottom:Math.max(r.bottom,o.bottom)});let s=Rb(this.view),a={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:l,offsetHeight:c}=this.view.scrollDOM;if(yq(this.view.scrollDOM,a,i.head<i.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,c),-c),this.view.textDirection==We.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(r.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||r.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let u=this.view.docView.lineAt(i.head,1);u&&u.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Y0(this.tile)}};function Y0(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)Y0(i,e)}}function Nq(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 yA(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=XT(t.focusNode,t.focusOffset),r=YT(t.focusNode,t.focusOffset),o=i||r;if(r&&i&&r.node!=i.node){let a=it.get(r.node);if(!a||a.isText()&&a.text!=r.node.nodeValue)o=r;else if(n.docView.lastCompositionAfterCursor){let l=it.get(i.node);!l||l.isText()&&l.text!=i.node.nodeValue||(o=r)}}if(n.docView.lastCompositionAfterCursor=o!=i,!o)return null;let s=e-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}function $q(n,e,t){let i=yA(n,t);if(!i)return null;let{node:r,from:o,to:s}=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 _i(l.mapPos(o),l.mapPos(s),o,s),text:r}}function jq(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}var Fq=class{constructor(){this.changes=[]}compareRange(e,t){Jl(e,t,this.changes)}comparePoint(e,t){Jl(e,t,this.changes)}boundChange(e){Jl(e,e,this.changes)}};function qq(n,e,t){let i=new Fq;return Be.compare(n,e,t,i),i.changes}var Z0=class{constructor(){this.changes=[]}compareRange(e,t){Jl(e,t,this.changes)}comparePoint(){}boundChange(e){Jl(e,e,this.changes)}};function Vq(n,e,t){let i=new Z0;return Be.compare(n,e,t,i),i.changes}function Hq(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function zq(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}var Eh=class extends ai{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 Wq(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),o=e-r.from;if(r.length==0)return $.cursor(e);o==0?t=1:o==r.length&&(t=-1);let s=o,a=o;t<0?s=Dt(r.text,o,!1):a=Dt(r.text,o);let l=i(r.text.slice(s,a));for(;s>0;){let c=Dt(r.text,s,!1);if(i(r.text.slice(c,s))!=l)break;s=c}for(;a<r.length;){let c=Dt(r.text,a);if(i(r.text.slice(a,c))!=l)break;a=c}return $.range(s+r.from,a+r.from)}function Uq(n,e,t,i,r){let o=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let a=n.viewState.heightOracle.textHeight,l=Math.floor((r-t.top-(n.defaultLineHeight-a)*.5)/a);o+=l*n.viewState.heightOracle.lineLength}let s=n.state.sliceDoc(t.from,t.to);return t.from+aT(s,o,n.state.tabSize)}function Qq(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let o of i.type){if(o.from>e)break;if(!(o.to<e)){if(o.from<e&&o.to>e)return o;(!r||o.type==si.Text&&(r.type!=o.type||(t<0?o.from<e:o.to>e)))&&(r=o)}}return r||i}return i}function Kq(n,e,t,i){let r=Qq(n,e.head,e.assoc||-1),o=!i||r.type!=si.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(o){let s=n.dom.getBoundingClientRect(),a=n.textDirectionAt(r.from),l=n.posAtCoords({x:t==(a==We.LTR)?s.right-1:s.left+1,y:(o.top+o.bottom)/2});if(l!=null)return $.cursor(l,t?-1:1)}return $.cursor(t?r.to:r.from,t?-1:1)}function wT(n,e,t,i){let r=n.state.doc.lineAt(e.head),o=n.bidiSpans(r),s=n.textDirectionAt(r.from);for(let a=e,l=null;;){let c=kq(r,o,s,a,t),u=nA;if(!c){if(r.number==(t?n.state.doc.lines:1))return a;u=` 282`,r=n.state.doc.line(r.number+(t?1:-1)),o=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 Gq(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return o=>{let s=i(o);return r==ln.Space&&(r=s),r==s}}function Xq(n,e,t,i){let r=e.head,o=t?1:-1;if(r==(t?n.state.doc.length:0))return $.cursor(r,e.assoc);let s=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)s==null&&(s=c.left-l.left),a=o<0?c.top:c.bottom;else{let p=n.viewState.lineBlockAt(r);s==null&&(s=Math.min(l.right-l.left,n.defaultCharacterWidth*(r-p.from))),a=(o<0?p.top:p.bottom)+u}let f=l.left+s,h=n.viewState.heightOracle.textHeight>>1,d=i!=null?i:h;for(let p=0;;p+=h){let m=a+(d+p)*o,g=J0(n,{x:f,y:m},!1,o);if(t?m>l.bottom:m<l.top)return $.cursor(g.pos,g.assoc);let b=n.coordsAtPos(g.pos,g.assoc),_=b?(b.top+b.bottom)/2:0;if(!b||(t?_>a:_<a))return $.cursor(g.pos,g.assoc,void 0,s)}}function Sh(n,e,t){for(;;){let i=0;for(let r of n)r.between(e-1,e+1,(o,s,a)=>{if(e>o&&e<s){let l=i||t||(e-o<s-e?-1:1);e=l<0?o:s,i=l}});if(!i)return e}}function vA(n,e){let t=null;for(let i=0;i<e.ranges.length;i++){let r=e.ranges[i],o=null;if(r.empty){let s=Sh(n,r.from,0);s!=r.from&&(o=$.cursor(s,-1))}else{let s=Sh(n,r.from,-1),a=Sh(n,r.to,1);(s!=r.from||a!=r.to)&&(o=$.range(r.from==r.anchor?s:a,r.from==r.head?s:a))}o&&(t||(t=e.ranges.slice()),t[i]=o)}return t?$.create(t,e.mainIndex):e}function D0(n,e,t){let i=Sh(n.state.facet(Ph).map(r=>r(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:$.cursor(i,i<t.from?1:-1)}var ri=class{constructor(e,t){this.pos=e,this.assoc=t}};function J0(n,e,t,i){let r=n.contentDOM.getBoundingClientRect(),o=r.top+n.viewState.paddingTop,{x:s,y:a}=e,l=a-o,c;for(;;){if(l<0)return new ri(0,1);if(l>n.viewState.docHeight)return new ri(n.state.doc.length,-1);if(c=n.elementAtHeight(l),i==null)break;if(c.type==si.Text){if(i<0?c.to<n.viewport.from:c.from>n.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+o:h.bottom>=l+o))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==si.Text){let f=Uq(n,r,c,s,a);return new ri(f,f==c.from?1:-1)}}if(c.type!=si.Text)return l<(c.top+c.bottom)/2?new ri(c.from,1):new ri(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 eb(n,s,a,n.textDirectionAt(c.from)).scanTile(u,c.from)}var eb=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.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:r}=this.bidiSpansAt(e);return r[oi.find(r,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:r}=this.bidiSpansAt(e);return r[oi.find(r,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:r}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from<t)}scan(e,t,i=!1){let r=0,o=e.length-1,s=new Set,a=this.bidiIn(e[0],e[o]),l,c,u=-1,f=1e9,h;e:for(;r<o;){let p=o-r,m=r+o>>1;t:if(s.has(m)){let b=r+Math.floor(Math.random()*p);for(let _=0;_<p;_++){if(!s.has(b)){m=b;break t}b++,b==o&&(b=r)}break e}s.add(m);let g=t(m);if(g)for(let b=0;b<g.length;b++){let _=g[b],v=0;if(!(_.width==0&&g.length>1)){if(_.bottom<this.y)(!l||l.bottom<_.bottom)&&(l=_),v=1;else if(_.top>this.y)(!c||c.top>_.top)&&(c=_),v=-1;else{let x=_.left>this.x?this.x-_.left:_.right<this.x?this.x-_.right:0,C=Math.abs(x);C<f&&(u=m,f=C,h=_),x&&(v=x<0==(this.baseDir==We.LTR)?-1:1)}v==-1&&(!a||this.baseDirAt(e[m],1))?o=m:v==1&&(!a||this.baseDirAt(e[m+1],-1))&&(r=m+1)}}}if(!h){if(!c&&!l)return{i:e[0],after:!1};let p=l&&(!c||this.y-l.bottom<c.top-this.y)?l:c;return this.y=(p.top+p.bottom)/2,this.scan(e,t,!0)}if(f&&!i){let{top:p,bottom:m}=h;if(l&&l.bottom>(p+p+m)/3)return this.y=l.bottom-1,this.scan(e,t,!0);if(c&&c.top<(p+m+m)/3)return this.y=c.top+1,this.scan(e,t,!0)}let d=(a?this.dirAt(e[u],1):this.baseDir)==We.LTR;return{i:u,after:this.x>(h.left+h.right)/2==d}}scanText(e,t){let i=[];for(let o=0;o<e.length;o=Dt(e.text,o))i.push(t+o);i.push(t+e.length);let r=this.scan(i,o=>{let s=i[o]-t,a=i[o+1]-t;return Mh(e.dom,s,a).getClientRects()});return r.after?new ri(i[r.i+1],-1):new ri(i[r.i],1)}scanTile(e,t){if(!e.length)return new ri(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<e.children.length;a++)i.push(l+=e.children[a].length);let r=this.scan(i,a=>{let l=e.children[a];return l.flags&48?null:(l.dom.nodeType==1?l.dom:Mh(l.dom,0,l.length)).getClientRects()}),o=e.children[r.i],s=i[r.i];return o.isText()?this.scanText(o,s):o.isComposite()?this.scanTile(o,s):r.after?new ri(i[r.i+1],-1):new ri(s,1)}},Gl="\uFFFF",tb=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(Ze.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Gl}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let o=this.text.length;this.readNode(r);let s=it.get(r),a=r.nextSibling;if(a==t){s!=null&&s.breakAfter&&!a&&i!=this.view.contentDOM&&this.lineBreak();break}let l=it.get(a);(s&&l?s.breakAfter:(s?s.breakAfter:jg(r))||jg(a)&&(r.nodeName!="BR"||s!=null&&s.isWidget())&&this.text.length>o)&&!Zq(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 o=-1,s=1,a;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,i),s=this.lineSeparator.length):(a=r.exec(t))&&(o=a.index,s=a[0].length),this.append(t.slice(i,o<0?t.length:o)),o<0)break;if(this.lineBreak(),s>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=s-1);i=o+s}}readNode(e){let t=it.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+(Yq(e,i.node,i.offset)?t:0))}};function Yq(n,e,t){for(;;){if(!e||t<Vr(e))return!1;if(e==n)return!0;t=No(e)+1,e=e.parentNode}}function Zq(n,e){let t;for(;!(n==e||!n);n=n.nextSibling){let i=it.get(n);if(!(i!=null&&i.isWidget()))return!1;i&&(t||(t=[])).push(i)}if(t)for(let i of t){let r=i.overrideDOMText;if(r!=null&&r.length)return!1}return!0}var Hg=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},nb=class{constructor(e,t,i,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:o,impreciseAnchor:s}=e.docView,a=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=xA(e.docView.tile,t,i,0))){let l=o||s?[]:eV(e),c=new tb(l,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=tV(l,this.bounds.from)}else{let l=e.observer.selectionRange,c=o&&o.node==l.focusNode&&o.offset==l.focusOffset||!j0(e.contentDOM,l.focusNode)?a.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),u=s&&s.node==l.anchorNode&&s.offset==l.anchorOffset||!j0(e.contentDOM,l.anchorNode)?a.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),f=e.viewport;if((z.ios||z.chrome)&&a.main.empty&&c!=u&&(f.from>0||f.to<e.state.doc.length)){let h=Math.min(c,u),d=Math.max(c,u),p=f.from-h,m=f.to-d;(p==0||p==1||h==0)&&(m==0||m==-1||d==e.state.doc.length)&&(c=0,u=e.state.doc.length)}if(e.inputState.composing>-1&&a.ranges.length>1)this.newSel=a.replaceRange($.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=$.create([$.cursor(c,d)])}else this.newSel=$.single(u,c)}}};function xA(n,e,t,i){if(n.isComposite()){let r=-1,o=-1,s=-1,a=-1;for(let l=0,c=i,u=i;l<n.children.length;l++){let f=n.children[l],h=c+f.length;if(c<e&&h>t)return xA(f,e,t,c);if(h>=e&&r==-1&&(r=l,o=c),c>t&&f.dom.parentNode==n.dom){s=l,a=u;break}u=h,c=h+f.breakAfter}return{from:o,to:a<0?i+n.length:a,startDOM:(r?n.children[r-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:s<n.children.length&&s>=0?n.children[s].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function bA(n,e){let t,{newSel:i}=e,{state:r}=n,o=r.selection.main,s=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:l}=e.bounds,c=o.from,u=null;(s===8||z.android&&e.text.length<l-a)&&(c=o.to,u="end");let f=r.doc.sliceString(a,l,Gl),h,d;!o.empty&&o.from>=a&&o.to<=l&&(e.typeOver||f!=e.text)&&f.slice(0,o.from-a)==e.text.slice(0,o.from-a)&&f.slice(o.to-a)==e.text.slice(h=e.text.length-(f.length-(o.to-a)))?t={from:o.from,to:o.to,insert:be.of(e.text.slice(o.from-a,h).split(Gl))}:(d=_A(f,e.text,c-a,u))&&(z.chrome&&s==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==Gl+Gl&&d.toB--,t={from:a+d.from,to:a+d.toA,insert:be.of(e.text.slice(d.from,d.toB).split(Gl))})}else i&&(!n.hasFocus&&r.facet(Fr)||zg(i,o))&&(i=null);if(!t&&!i)return!1;if((z.mac||z.android)&&t&&t.from==t.to&&t.from==o.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=$.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:be.of([t.insert.toString().replace("."," ")])}):r.doc.lineAt(o.from).to<o.to&&n.docView.lineHasWidget(o.to)&&n.inputState.insertingTextAt>Date.now()-50?t={from:o.from,to:o.to,insert:r.toText(n.inputState.insertingText)}:z.chrome&&t&&t.from==t.to&&t.from==o.head&&t.insert.toString()==` 283 `&&n.lineWrapping&&(i&&(i=$.single(i.main.anchor-1,i.main.head-1)),t={from:o.from,to:o.to,insert:be.of([" "])}),t)return Tb(n,t,i,s);if(i&&!zg(i,o)){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=vA(r.facet(Ph).map(c=>c(n)),i))),n.dispatch({selection:i,scrollIntoView:a,userEvent:l}),!0}else return!1}function Tb(n,e,t,i=-1){if(z.ios&&n.inputState.flushIOSKey(e))return!0;let r=n.state.selection.main;if(z.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&&ec(n.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&ec(n.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&ec(n.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let s,a=()=>s||(s=Jq(n,e,t));return n.state.facet(aA).some(l=>l(n,e.from,e.to,o,a))||n.dispatch(a()),!0}function Jq(n,e,t){let i,r=n.state,o=r.selection.main,s=-1;if(e.from==e.to&&e.from<o.from||e.from>o.to){let l=e.from<o.from?-1:1,c=l<0?o.from:o.to,u=Sh(r.facet(Ph).map(f=>f(n)),c,l);e.from==u&&(s=u)}if(s>-1)i={changes:e,selection:$.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=o.from<e.from?r.sliceDoc(o.from,e.from):"",c=o.to>e.to?r.sliceDoc(e.to,o.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<=o.to+10&&e.to>=o.to-10){let u=n.state.sliceDoc(e.from,e.to),f,h=t&&yA(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(o.head);let d=o.to-e.to;i=r.changeByRange(p=>{if(p.from==o.from&&p.to==o.to)return{changes:l,range:c||p.map(l)};let m=p.to-d,g=m-u.length;if(n.state.sliceDoc(g,m)!=u||m>=f.from&&g<=f.to)return{range:p};let b=r.changes({from:g,to:m,insert:e.insert}),_=p.to-o.to;return{changes:b,range:c?$.range(Math.max(0,c.anchor+_),Math.max(0,c.head+_)):p.map(b)}})}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 _A(n,e,t,i){let r=Math.min(n.length,e.length),o=0;for(;o<r&&n.charCodeAt(o)==e.charCodeAt(o);)o++;if(o==r&&n.length==e.length)return null;let s=n.length,a=e.length;for(;s>0&&a>0&&n.charCodeAt(s-1)==e.charCodeAt(a-1);)s--,a--;if(i=="end"){let l=Math.max(0,o-Math.min(s,a));t-=s+l-o}if(s<o&&n.length<e.length){let l=t<=o&&t>=s?o-t:0;o-=l,a=o+(a-s),s=o}else if(a<o){let l=t<=o&&t>=a?o-t:0;o-=l,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function eV(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:o}=n.observer.selectionRange;return t&&(e.push(new Hg(t,i)),(r!=t||o!=i)&&e.push(new Hg(r,o))),e}function tV(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?$.single(t+e,i+e):null}function zg(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}var ib=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,z.safari&&e.contentDOM.addEventListener("input",()=>null),z.gecko&&mV(e.contentDOM.ownerDocument)}handleEvent(e){!lV(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=nV(e),i=this.handlers,r=this.view.contentDOM;for(let o in t)if(o!="scroll"){let s=!t[o].handlers.length,a=i[o];a&&s!=!a.handlers.length&&(r.removeEventListener(o,this.handleEvent),a=null),a||r.addEventListener(o,this.handleEvent,{passive:s})}for(let o in i)o!="scroll"&&!t[o]&&r.removeEventListener(o,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&&CA.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),z.android&&z.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return z.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=wA.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||iV.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.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,ec(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:z.safari&&!z.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 CT(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){It(t.state,r)}}}function nV(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,o=r&&r.plugin.domEventHandlers,s=r&&r.plugin.domEventObservers;if(o)for(let a in o){let l=o[a];l&&t(a).handlers.push(CT(i.value,l))}if(s)for(let a in s){let l=s[a];l&&t(a).observers.push(CT(i.value,l))}}for(let i in wi)t(i).handlers.push(wi[i]);for(let i in _n)t(i).observers.push(_n[i]);return e}var wA=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],iV="dthko",CA=[16,17,18,20,91,92,224,225],kg=6;function Rg(n){return Math.max(0,n)*.7+8}function rV(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var rb=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=QT(e.contentDOM),this.atoms=e.state.facet(Ph).map(s=>s(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Ze.allowMultipleSelections)&&oV(e,t),this.dragging=aV(e,t)&&OA(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&&rV(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,r=0,o=0,s=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:s}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=Rb(this.view);e.clientX-l.left<=r+kg?t=-Rg(r-e.clientX):e.clientX+l.right>=s-kg&&(t=Rg(e.clientX-s)),e.clientY-l.top<=o+kg?i=-Rg(o-e.clientY):e.clientY+l.bottom>=a-kg&&(i=Rg(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=vA(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 oV(n,e){let t=n.state.facet(iA);return t.length?t[0](e):z.mac?e.metaKey:e.ctrlKey}function sV(n,e){let t=n.state.facet(rA);return t.length?t[0](e):z.mac?!e.altKey:!e.ctrlKey}function aV(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=Th(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let o=0;o<r.length;o++){let s=r[o];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}function lV(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=it.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}var wi=Object.create(null),_n=Object.create(null),EA=z.ie&&z.ie_version<15||z.ios&&z.webkit_version<604;function cV(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(),SA(n,t.value)},50)}function ty(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function SA(n,e){e=ty(n.state,Eb,e);let{state:t}=n,i,r=1,o=t.toText(e),s=o.lines==t.selection.ranges.length;if(ob!=null&&t.selection.ranges.every(l=>l.empty)&&ob==o.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((s?o.line(r++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:f},range:$.cursor(c.from+f.length)}})}else s?i=t.changeByRange(l=>{let c=o.line(r++);return{changes:{from:l.from,to:l.to,insert:c.text},range:$.cursor(l.from+c.length)}}):i=t.replaceSelection(o);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};_n.wheel=_n.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};wi.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);_n.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")};_n.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};wi.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(oA))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=fV(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new rb(n,e,t,i)),i&&n.observer.ignore(()=>{KT(n.contentDOM);let o=n.root.activeElement;o&&!o.contains(n.contentDOM)&&o.blur()});let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function ET(n,e,t,i){if(i==1)return $.cursor(e,t);if(i==2)return Wq(n.state,e,t);{let r=n.docView.lineAt(e,t),o=n.state.doc.lineAt(r?r.posAtEnd:e),s=r?r.posAtStart:o.from,a=r?r.posAtEnd:o.to;return a<n.state.doc.length&&a==o.to&&a++,$.range(s,a)}}var uV=z.ie&&z.ie_version<=11,ST=null,OT=0,kT=0;function OA(n){if(!uV)return n.detail;let e=ST,t=kT;return ST=n,kT=Date.now(),OT=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(OT+1)%3:1}function fV(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=OA(e),r=n.state.selection;return{update(o){o.docChanged&&(t.pos=o.changes.mapPos(t.pos),r=r.map(o.changes))},get(o,s,a){let l=n.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),c,u=ET(n,l.pos,l.assoc,i);if(t.pos!=l.pos&&!s){let f=ET(n,t.pos,t.assoc,i),h=Math.min(f.from,u.from),d=Math.max(f.to,u.to);u=h<u.from?$.range(h,d,u.assoc):$.range(d,h,u.assoc)}return s?r.replaceRange(r.main.extend(u.from,u.to,u.assoc)):a&&i==1&&r.ranges.length>1&&(c=hV(r,l.pos))?c:a?r.addRange(u):$.create([u])}}}function hV(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:r}=n.ranges[t];if(i<=e&&r>=e)return $.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}wi.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 o=r.posAtStart,s=o+r.length;(o>=t.to||s<=t.from)&&(t=$.range(o,s))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",ty(n.state,Sb,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};wi.dragend=n=>(n.inputState.draggedContent=null,!1);function RT(n,e,t,i){if(t=ty(n.state,Eb,t),!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=n.inputState,s=i&&o&&sV(n,e)?{from:o.from,to:o.to}:null,a={from:r,insert:t},l=n.state.changes(s?[s,a]:a);n.focus(),n.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:s?"move.drop":"input.drop"}),n.inputState.draggedContent=null}wi.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,o=()=>{++r==t.length&&RT(n,e,i.filter(s=>s!=null).join(n.state.lineBreak),!1)};for(let s=0;s<t.length;s++){let a=new FileReader;a.onerror=o,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(i[s]=a.result),o()},a.readAsText(t[s])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return RT(n,e,i,!0),!0}return!1};wi.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=EA?null:e.clipboardData;return t?(SA(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(cV(n),!1)};function dV(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 pV(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:o}of n.selection.ranges){let s=n.doc.lineAt(o);s.number>r&&(e.push(s.text),t.push({from:s.from,to:Math.min(n.doc.length,s.to+1)})),r=s.number}i=!0}return{text:ty(n,Sb,e.join(n.lineBreak)),ranges:t,linewise:i}}var ob=null;wi.copy=wi.cut=(n,e)=>{if(!xh(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:r}=pV(n.state);if(!t&&!r)return!1;ob=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let o=EA?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",t),!0):(dV(n,t),!1)};var kA=Mn.define();function RA(n,e){let t=[];for(let i of n.facet(lA)){let r=i(n,e);r&&t.push(r)}return t.length?n.update({effects:t,annotations:kA.of(!0)}):null}function TA(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=RA(n.state,e);t?n.dispatch(t):n.update([])}},10)}_n.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),TA(n)};_n.blur=n=>{n.observer.clearSelectionRange(),TA(n)};_n.compositionstart=_n.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};_n.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,z.chrome&&z.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};_n.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};wi.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 o=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),s=e.getTargetRanges();if(o&&s.length){let a=s[0],l=n.posAtDOM(a.startContainer,a.startOffset),c=n.posAtDOM(a.endContainer,a.endOffset);return Tb(n,{from:l,to:c,insert:n.state.toText(o)},null),!0}}let r;if(z.chrome&&z.android&&(r=wA.find(o=>o.inputType==e.inputType))&&(n.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let o=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>o+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return z.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),z.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>_n.compositionend(n,e),20),!1};var TT=new Set;function mV(n){TT.has(n)||(TT.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var AT=["pre-wrap","normal","pre-line","break-spaces"],oc=!1;function MT(){oc=!1}var sb=class{constructor(e){this.lineWrapping=e,this.doc=be.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 AT.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,o,s){let a=AT.indexOf(e)>-1,l=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=o,l){this.heightSamples={};for(let c=0;c<s.length;c++){let u=s[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return l}},ab=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},bi=class n{constructor(e,t,i,r,o){this.from=e,this.length=t,this.top=i,this.height=r,this._content=o}get type(){return typeof this._content=="number"?si.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof qs?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new n(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ze=(function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n})(ze||(ze={})),Lg=.001,Dn=class n{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Lg&&(oc=!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 o=this,s=i.doc;for(let a=r.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:f}=r[a],h=o.lineAt(l,ze.ByPosNoHeight,i.setDoc(t),0,0),d=h.to>=c?h:o.lineAt(c,ze.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--,l<h.from&&(h=o.lineAt(l,ze.ByPosNoHeight,i,0,0));u+=h.from-l,l=h.from;let p=cb.build(i.setDoc(s),e,u,f);o=Wg(o,o.replace(l,c,p))}return o.updateHeight(i,0)}static empty(){return new ii(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,o=0;for(;;)if(t==i)if(r>o*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(o>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,o-=a.size}else break;else if(r<o){let a=e[t++];a&&(r+=a.size)}else{let a=e[--i];a&&(o+=a.size)}let s=0;return e[t-1]==null?(s=1,t--):e[t]==null&&(s=1,i++),new lb(n.of(e.slice(0,t)),s,n.of(e.slice(i)))}};function Wg(n,e){return n==e?n:(n.constructor!=e.constructor&&(oc=!0),e)}Dn.prototype.size=1;var gV=he.replace({}),Ug=class extends Dn{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new bi(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,r){return this.spaceAbove&&e<i+this.spaceAbove?new bi(r,0,i,this.spaceAbove,gV):this.mainBlock(i,r)}lineAt(e,t,i,r,o){let s=this.mainBlock(r,o);return this.spaceAbove?this.blockAt(0,i,r,o).join(s):s}forEachLine(e,t,i,r,o,s){e<=o+this.length&&t>=o&&s(this.lineAt(0,ze.ByPos,i,r,o))}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})`}},ii=class n extends Ug{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 bi(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 Bo&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Bo?r=new n(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Dn.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:""})`}},Bo=class n extends Dn{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,o=r-i+1,s,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*o);s=l/o,this.length>o+1&&(a=(this.height-l)/(this.length-o-1))}else s=this.height/o;return{firstLine:i,lastLine:r,perLine:s,perChar:a}}blockAt(e,t,i,r){let{firstLine:o,lastLine:s,perLine:a,perChar:l}=this.heightMetrics(t,r);if(t.lineWrapping){let c=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),u=t.doc.lineAt(c),f=a+u.length*l,h=Math.max(i,e-f/2);return new bi(u.from,u.length,h,f,0)}else{let c=Math.max(0,Math.min(s-o,Math.floor((e-i)/a))),{from:u,length:f}=t.doc.line(o+c);return new bi(u,f,i+a*c,a,0)}}lineAt(e,t,i,r,o){if(t==ze.ByHeight)return this.blockAt(e,i,r,o);if(t==ze.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(e);return new bi(d,p-d,0,0,0)}let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(i,o),c=i.doc.lineAt(e),u=a+c.length*l,f=c.number-s,h=r+a*f+l*(c.from-o-f);return new bi(c.from,c.length,Math.max(r,Math.min(h,r+this.height-u)),u,0)}forEachLine(e,t,i,r,o,s){e=Math.max(e,o),t=Math.min(t,o+this.length);let{firstLine:a,perLine:l,perChar:c}=this.heightMetrics(i,o);for(let u=e,f=r;u<=t;){let h=i.doc.lineAt(u);if(u==e){let p=h.number-a;f+=l*p+c*(e-o-p)}let d=l+c*h.length;s(new bi(h.from,h.length,f,d,0)),f+=d,u=h.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let o=i[i.length-1];o instanceof n?i[i.length-1]=new n(o.length+r):i.push(null,new n(r-1))}if(e>0){let o=i[0];o instanceof n?i[0]=new n(e+o.length):i.unshift(new n(e-1),null)}return Dn.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 o=t+this.length;if(r&&r.from<=t+this.length&&r.more){let s=[],a=Math.max(t,r.from),l=-1;for(r.from>t&&s.push(new n(r.from-t-1).updateHeight(e,t));a<=o&&r.more;){let u=e.doc.lineAt(a).length;s.length&&s.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)>=Lg&&(l=-2);let d=new ii(u,f,h);d.outdated=!1,s.push(d),a+=u+1}a<=o&&s.push(null,new n(o-a).updateHeight(e,a));let c=Dn.of(s);return(l<0||Math.abs(c.height-this.height)>=Lg||Math.abs(l-this.heightMetrics(e,t).perLine)>=Lg)&&(oc=!0),Wg(this,c)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},lb=class extends Dn{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 o=i+this.left.height;return e<o?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,o,r+this.left.length+this.break)}lineAt(e,t,i,r,o){let s=r+this.left.height,a=o+this.left.length+this.break,l=t==ze.ByHeight?e<s:e<a,c=l?this.left.lineAt(e,t,i,r,o):this.right.lineAt(e,t,i,s,a);if(this.break||(l?c.to<a:c.from>a))return c;let u=t==ze.ByPosNoHeight?ze.ByPosNoHeight:ze.ByPos;return l?c.join(this.right.lineAt(a,u,i,s,a)):this.left.lineAt(a,u,i,r,o).join(c)}forEachLine(e,t,i,r,o,s){let a=r+this.left.height,l=o+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,t,i,r,o,s),t>=l&&this.right.forEachLine(e,t,i,a,l,s);else{let c=this.lineAt(l,ze.ByPos,i,r,o);e<c.from&&this.left.forEachLine(e,c.from-1,i,r,o,s),c.to>=e&&c.from<=t&&s(c),t>c.to&&this.right.forEachLine(c.to+1,t,i,a,l,s)}}replace(e,t,i){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let o=[];e>0&&this.decomposeLeft(e,o);let s=o.length;for(let a of i)o.push(a);if(e>0&&PT(o,s-1),t<this.length){let a=o.length;this.decomposeRight(t,o),PT(o,a)}return Dn.of(o)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=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);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Dn.of(this.break?[e,null,t]:[e,t]):(this.left=Wg(this.left,e),this.right=Wg(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:o,right:s}=this,a=t+o.length+this.break,l=null;return r&&r.from<=t+o.length&&r.more?l=o=o.updateHeight(e,t,i,r):o.updateHeight(e,t,i),r&&r.from<=a+s.length&&r.more?l=s=s.updateHeight(e,a,i,r):s.updateHeight(e,a,i),l?this.balanced(o,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function PT(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Bo&&(i=n[e+1])instanceof Bo&&n.splice(e-1,3,new Bo(t.length+1+i.length))}var yV=5,cb=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 ii?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ii(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<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,o=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let s=t-e;i.block?this.addBlock(new Ug(s,r,i)):(s||o||r>=yV)&&this.addLineDeco(r,o,s)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new ii(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new Bo(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 ii)return e;let t=new ii(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 ii)&&!this.isCovered?this.nodes.push(new ii(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof ii&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let o=new n(i,e);return Be.spans(t,i,r,o,0),o.finish(i)}};function vV(n,e,t){let i=new ub;return Be.compare(n,e,t,i,0),i.changes}var ub=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&Jl(e,t,this.changes,5)}};function xV(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,r=i.defaultView||window,o=Math.max(0,t.left),s=Math.min(r.innerWidth,t.right),a=Math.max(0,t.top),l=Math.min(r.innerHeight,t.bottom);for(let c=n.parentNode;c&&c!=i.body;)if(c.nodeType==1){let u=c,f=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&f.overflow!="visible"){let h=u.getBoundingClientRect();o=Math.max(o,h.left),s=Math.min(s,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:o-t.left,right:Math.max(o,s)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function bV(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function _V(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Oh=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;i<e.length;i++){let r=e[i],o=t[i];if(r.from!=o.from||r.to!=o.to||r.size!=o.size)return!1}return!0}draw(e,t){return he.replace({widget:new fb(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},fb=class extends ai{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},Qg=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=DT,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=We.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=t.facet(Ob).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new sb(i),this.stateDeco=IT(t),this.heightMap=Dn.empty().applyChanges(this.stateDeco,be.empty,this.heightOracle.setDoc(t.doc),[new _i(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=he.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:o,to:s})=>r>=o&&r<=s)){let{from:o,to:s}=this.lineBlockAt(r);e.push(new Yl(o,s))}}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?DT:new hb(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(vh(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=IT(this.state);let r=e.changedRanges,o=_i.extendWithRanges(r,vV(i,this.stateDeco,e?e.changes:cn.empty(this.state.doc.length))),s=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);MT(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=s||oc)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=s);let l=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<l.from||t.range.head>l.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(Tq)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,o=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?We.RTL:We.LTR;let s=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",a=t.getBoundingClientRect(),l=s||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:E}=UT(t,a);(C>.005&&Math.abs(this.scaleX-C)>.005||E>.005&&Math.abs(this.scaleY-E)>.005)&&(this.scaleX=C,this.scaleY=E,c|=16,s=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=QT(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=GT(this.scrollParent||e.win);let m=(this.printing?_V:xV)(t,this.paddingTop),g=m.top-this.pixelViewport.top,b=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(l=!0)),!this.inView&&!this.scrollTarget&&!bV(e.dom))return 0;let v=a.width;if((this.contentDOMWidth!=v||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)&&(s=!0),s||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:E,charWidth:S,textHeight:w}=e.docView.measureTextSize();s=E>0&&r.refresh(o,E,S,w,Math.max(5,v/S),C),s&&(e.docView.minWidth=0,c|=16)}g>0&&b>0?u=Math.max(g,b):g<0&&b<0&&(u=Math.min(g,b)),MT();for(let E of this.viewports){let S=E.from==this.viewport.from?C:e.docView.measureVisibleLineHeights(E);this.heightMap=(s?Dn.empty().applyChanges(this.stateDeco,be.empty,this.heightOracle,[new _i(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,s,new ab(E.from,S))}oc&&(c|=2)}let x=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return x&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),c|=this.updateForViewport()),(c&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]: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,o=this.heightOracle,{visibleTop:s,visibleBottom:a}=this,l=new Yl(r.lineAt(s-i*1e3,ze.ByHeight,o,0,0).from,r.lineAt(a+(1-i)*1e3,ze.ByHeight,o,0,0).to);if(t){let{head:c}=t.range;if(c<l.from||c>l.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(c,ze.ByPos,o,0,0),h;t.y=="center"?h=(f.top+f.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c<l.from?h=f.top:h=f.bottom-u,l=new Yl(r.lineAt(h-1e3/2,ze.ByHeight,o,0,0).from,r.lineAt(h+u+1e3/2,ze.ByHeight,o,0,0).to)}}return l}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new Yl(this.heightMap.lineAt(i,ze.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ze.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,ze.ByPos,this.heightOracle,0,0),{bottom:o}=this.heightMap.lineAt(t,ze.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:a}=this;return(e==0||r<=s-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||o>=a+Math.max(10,Math.min(i,250)))&&r>s-2*1e3&&o<a+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new Oh(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,o=r>>1,s=r<<1;if(this.defaultTextDirection!=We.LTR&&!i)return[];let a=[],l=(u,f,h,d)=>{if(f-u<o)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let b of m)if(b>u&&b<f){l(u,b-10,h,d),l(b+10,f,h,d);return}let g=CV(e,b=>b.from>=h.from&&b.to<=h.to&&Math.abs(b.from-u)<o&&Math.abs(b.to-f)<o&&!m.some(_=>b.from<_&&b.to>_));if(!g){if(f<h.to&&t&&i&&t.visibleRanges.some(v=>v.from<=f&&v.to>=f)){let v=t.moveToLineBoundary($.cursor(f),!1,!0).head;v>u&&(f=v)}let b=this.gapSize(h,u,f,d),_=i||b<2e6?b:2e6;g=new Oh(u,f,b,_)}a.push(g)},c=u=>{if(u.length<s||u.type!=si.Text)return;let f=wV(u.from,u.to,this.stateDeco);if(f.total<s)return;let h=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let m=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,b;if(h!=null){let _=Ag(f,h),v=((this.visibleBottom-this.visibleTop)/2+m)/u.height;g=_-v,b=_+v}else g=(this.visibleTop-u.top-m)/u.height,b=(this.visibleBottom-u.top+m)/u.height;d=Tg(f,g),p=Tg(f,b)}else{let m=f.total*this.heightOracle.charWidth,g=r*this.heightOracle.charWidth,b=0;if(m>2e6)for(let E of e)E.from>=u.from&&E.from<u.to&&E.size!=E.displaySize&&E.from*this.heightOracle.charWidth+b<this.pixelViewport.left&&(b=E.size-E.displaySize);let _=this.pixelViewport.left+b,v=this.pixelViewport.right+b,x,C;if(h!=null){let E=Ag(f,h),S=((v-_)/2+g)/m;x=E-S,C=E+S}else x=(_-g)/m,C=(v+g)/m;d=Tg(f,x),p=Tg(f,C)}d>u.from&&l(u.from,d,u,f),p<u.to&&l(p,u.to,u,f)};for(let u of this.viewportLines)Array.isArray(u.type)?u.type.forEach(c):c(u);return a}gapSize(e,t,i,r){let o=Ag(r,i)-Ag(r,t);return this.heightOracle.lineWrapping?e.height*o:r.total*this.heightOracle.charWidth*o}updateLineGaps(e){Oh.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=he.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];Be.spans(t,this.viewport.from,this.viewport.to,{span(o,s){i.push({from:o,to:s})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let o=0;o<i.length&&!(r&8);o++){let s=this.visibleRanges[o],a=i[o];(s.from!=a.from||s.to!=a.to)&&(r|=4,e&&e.mapPos(s.from,-1)==a.from&&e.mapPos(s.to,1)==a.to||(r|=8))}return this.visibleRanges=i,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||vh(this.heightMap.lineAt(e,ze.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)||vh(this.heightMap.lineAt(this.scaler.fromDOM(e),ze.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 vh(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}},Yl=class{constructor(e,t){this.from=e,this.to=t}};function wV(n,e,t){let i=[],r=n,o=0;return Be.spans(t,n,e,{span(){},point(s,a){s>r&&(i.push({from:r,to:s}),o+=s-r),r=a}},20),r<e&&(i.push({from:r,to:e}),o+=e-r),{total:o,ranges:i}}function Tg({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:o,to:s}=e[r],a=s-o;if(i<=a)return o+i;i-=a}}function Ag(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 CV(n,e){for(let t of n)if(e(t))return t}var DT={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function IT(n){let e=n.facet(ey).filter(i=>typeof i!="function"),t=n.facet(kb).filter(i=>typeof i!="function");return t.length&&e.push(Be.join(t)),e}var hb=class n{constructor(e,t,i){let r=0,o=0,s=0;this.viewports=i.map(({from:a,to:l})=>{let c=t.lineAt(a,ze.ByPos,e,0,0).top,u=t.lineAt(l,ze.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=s+(a.top-o)*this.scale,s=a.domBottom=a.domTop+(a.bottom-a.top),o=a.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let o=t<this.viewports.length?this.viewports[t]:null;if(!o||e<o.top)return r+(e-i)*this.scale;if(e<=o.bottom)return o.domTop+(e-o.top);i=o.bottom,r=o.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let o=t<this.viewports.length?this.viewports[t]:null;if(!o||e<o.domTop)return i+(e-r)/this.scale;if(e<=o.domBottom)return o.top+(e-o.domTop);i=o.bottom,r=o.domBottom}}eq(e){return e instanceof n?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}};function vh(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new bi(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>vh(r,e)):n._content)}var Mg=H.define({combine:n=>n.join(" ")}),db=H.define({combine:n=>n.indexOf(!0)>-1}),pb=ni.newName(),AA=ni.newName(),MA=ni.newName(),PA={"&light":"."+AA,"&dark":"."+MA};function mb(n,e,t){return new ni(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 EV=mb("."+pb,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},PA),SV={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},I0=z.ie&&z.ie_version<=11,gb=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new F0,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);(z.ie&&z.ie_version<=11||z.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&&z.android&&e.constructor.EDIT_CONTEXT!==!1&&!(z.chrome&&z.chrome_version<126)&&(this.editContext=new yb(e),e.state.facet(Fr)&&(e.contentDOM.editContext=this.editContext.editContext)),I0&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,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(Fr)?i.root.activeElement!=this.dom:!xh(this.dom,r))return;let o=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(z.ie&&z.ie_version<=11||z.android&&z.chrome)&&!i.state.selection.main.empty&&r.focusNode&&_h(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Th(e.root);if(!t)return!1;let i=z.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&OV(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let r=xh(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&xq(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,SV),I0&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),I0&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&ec(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let o of e){let s=this.readMutation(o);s&&(s.typeOver&&(r=!0),t==-1?{from:t,to:i}=s:(t=Math.min(s.from,t),i=Math.max(s.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&xh(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 o=new nb(this.view,e,t,i);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}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=bA(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!zg(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=LT(t,e.previousSibling||e.target.previousSibling,-1),r=LT(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(Fr)!=e.state.facet(Fr)&&(e.view.contentDOM.editContext=e.state.facet(Fr)?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 LT(n,e,t){for(;e;){let i=it.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 BT(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,o=e.endOffset,s=n.docView.domAtPos(n.state.selection.main.anchor,1);return _h(s.node,s.offset,r,o)&&([t,i,r,o]=[r,o,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:o}}function OV(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return BT(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?BT(n,t):null}var yb=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:o,head:s}=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&&o<this.from?a=o:l==this.to&&o>this.to&&(l=o);let u=_A(e.state.sliceDoc(a,l),i.text,(c?r.from:r.to)-a,c?"end":null);if(!u){let h=$.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));zg(h,r)||e.dispatch({selection:h,userEvent:"select"});return}let f={from:u.from+a,to:u.toA+a,insert:be.of(i.text.slice(u.from,u.toB).split(` 284`))};if((z.mac||z.android)&&f.from==s-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:a,to:l,insert:be.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let h=this.to-this.from+(f.to-f.from+f.insert.length);Tb(e,f,$.single(this.toEditorPos(i.selectionStart,h),this.toEditorPos(i.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from<f.to&&!f.insert.length&&e.inputState.composing>=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=[],o=null;for(let s=this.toEditorPos(i.rangeStart),a=this.toEditorPos(i.rangeEnd);s<a;s++){let l=e.coordsForChar(s);o=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||o||new DOMRect,r.push(o)}t.updateCharacterBounds(i.rangeStart,r)},this.handlers.textformatupdate=i=>{let r=[];for(let o of i.getTextFormats()){let s=o.underlineStyle,a=o.underlineThickness;if(!/none/i.test(s)&&!/none/i.test(a)){let l=this.toEditorPos(o.rangeStart),c=this.toEditorPos(o.rangeEnd);if(l<c){let u=`text-decoration: underline ${/^[a-z]/.test(s)?s+" ":s=="Dashed"?"dashed ":s=="Squiggle"?"wavy ":""}${/thin/i.test(a)?1:2}px`;r.push(he.mark({attributes:{style:u}}).range(l,c))}}}e.dispatch({effects:fA.of(he.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let r=Th(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((o,s,a,l,c)=>{if(i)return;let u=c.length-(s-o);if(r&&s>=r.to)if(r.from==o&&r.to==s&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=u,this.to+=u;return}else r=null,this.revertPending(e.state);if(o+=t,s+=t,s<=this.from)this.from+=u,this.to+=u;else if(o<this.to){if(o<this.from||s>this.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(s),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.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*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])}},U=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(o=>i(o,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||vq(e.parent)||document,this.viewState=new Qg(this,e.state||Ze.create(e)),e.scrollTo&&e.scrollTo.is(Og)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Xl).map(r=>new Ch(r));for(let r of this.plugins)r.update(this);this.observer=new gb(this),this.inputState=new ib(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Vg(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 Ft?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,o=this.state;for(let h of e){if(h.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=h.state}if(this.destroyed){this.viewState.state=o;return}let s=this.hasFocus,a=0,l=null;e.some(h=>h.annotation(kA))?(this.inputState.notifiedFocused=s,a=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=RA(o,s),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(u=null)):this.observer.clear(),o.facet(Ze.phrases)!=this.state.facet(Ze.phrases))return this.setState(o);r=Fg.create(this,o,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 wh(d.empty?d:$.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of h.effects)d.is(Og)&&(f=d.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Kg.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(yh)!=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(Mg)!=r.state.facet(Mg)&&(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(z0))try{h(r)}catch(d){It(this.state,d,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!bA(this,u)&&c.force&&ec(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 Qg(this,e),this.plugins=e.facet(Xl).map(i=>new Ch(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Vg(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(Xl),i=e.state.facet(Xl);if(t!=i){let r=[];for(let o of i){let s=t.indexOf(o);if(s<0)r.push(new Ch(o));else{let a=this.plugins[s];a.mustUpdate=e,r.push(a)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){It(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:s}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(s<0)if(GT(i||this.win))o=-1,s=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);o=d.from,s=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 It(this.state,p),NT}}),f=Fg.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;d<c.length;d++)if(u[d]!=NT)try{let p=c[d];p.write&&p.write(u[d],this)}catch(p){It(this.state,p)}if(h&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}else{let p=((o<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(o).top)-s)/this.scaleY;if((p>1||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),s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(z0))a(t)}get themeClasses(){return pb+" "+(this.state.facet(db)?MA:AA)+" "+this.state.facet(Mg)}updateAttrs(){let e=$T(this,hA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Fr)?"true":"false",class:"cm-content",style:`${z.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),$T(this,Ob,t);let i=this.observer.ignore(()=>{let r=gT(this.contentDOM,this.contentAttrs,t),o=gT(this.dom,this.editorAttrs,e);return r||o});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 o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(yh);let e=this.state.facet(n.cspNonce);ni.mount(this.root,this.styleModules.concat(EV).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;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.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 D0(this,e,wT(this,e,t,i))}moveByGroup(e,t){return D0(this,e,wT(this,e,t,i=>Gq(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),o=i[t?i.length-1:0];return $.cursor(o.side(t,r)+e.from,o.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return Kq(this,e,t,i)}moveVertically(e,t,i){return D0(this,e,Xq(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=J0(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),J0(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),o=this.bidiSpans(r),s=o[oi.find(o,e-r.from,-1,t)];return Ah(i,s.dir==We.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(cA)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>kV)return tA(e.length);let t=this.textDirectionAt(e.from),i;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==t&&(o.fresh||eA(o.isolates,i=xT(this,e))))return o.order;i||(i=xT(this,e));let r=Oq(e.text,t,i);return this.bidiCache.push(new Kg(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||z.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{KT(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,o,s;return Og.of(new wh(typeof e=="number"?$.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(r=t.x)!==null&&r!==void 0?r:"nearest",(o=t.yMargin)!==null&&o!==void 0?o:5,(s=t.xMargin)!==null&&s!==void 0?s:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Og.of(new wh($.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 Yt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Yt.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ni.newName(),r=[Mg.of(i),yh.of(mb(`.${i}`,e))];return t&&t.dark&&r.push(db.of(!0)),r}static baseTheme(e){return $r.lowest(yh.of(mb("."+pb,e,PA)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&it.get(i)||it.get(e);return((t=r==null?void 0:r.root)===null||t===void 0?void 0:t.view)||null}};U.styleModule=yh;U.inputHandler=aA;U.clipboardInputFilter=Eb;U.clipboardOutputFilter=Sb;U.scrollHandler=uA;U.focusChangeEffect=lA;U.perLineTextDirection=cA;U.exceptionSink=sA;U.updateListener=z0;U.editable=Fr;U.mouseSelectionStyle=oA;U.dragMovesSelection=rA;U.clickAddsSelectionRange=iA;U.decorations=ey;U.blockWrappers=dA;U.outerDecorations=kb;U.atomicRanges=Ph;U.bidiIsolatedRanges=pA;U.cursorScrollMargin=H.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}}});U.scrollMargins=mA;U.darkTheme=db;U.cspNonce=H.define({combine:n=>n.length?n[0]:""});U.contentAttributes=Ob;U.editorAttributes=hA;U.lineWrapping=U.contentAttributes.of({class:"cm-lineWrapping"});U.announce=de.define();var kV=4096,NT={},Kg=class n{constructor(e,t,i,r,o,s){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=o,this.order=s}static update(e,t){if(t.empty&&!e.some(o=>o.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:We.LTR;for(let o=Math.max(0,e.length-10);o<e.length;o++){let s=e[o];s.dir==r&&!t.touchesRange(s.from,s.to)&&i.push(new n(t.mapPos(s.from,1),t.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return i}};function $T(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let o=i[r],s=typeof o=="function"?o(n):o;s&&_b(s,t)}return t}var RV=z.mac?"mac":z.windows?"win":z.linux?"linux":"key";function TV(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,o,s,a;for(let l=0;l<t.length-1;++l){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))o=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))e=="mac"?a=!0:o=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(i="Alt-"+i),o&&(i="Ctrl-"+i),a&&(i="Meta-"+i),s&&(i="Shift-"+i),i}function Pg(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}var AV=$r.default(U.domEventHandlers({keydown(n,e){return IV(MV(e.state),n,e,"editor")}})),sc=H.define({enables:AV}),jT=new WeakMap;function MV(n){let e=n.facet(sc),t=jT.get(e);return t||jT.set(e,t=DV(e.reduce((i,r)=>i.concat(r),[]))),t}var Lo=null,PV=4e3;function DV(n,e=RV){let t=Object.create(null),i=Object.create(null),r=(s,a)=>{let l=i[s];if(l==null)i[s]=a;else if(l!=a)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},o=(s,a,l,c,u)=>{var f,h;let d=t[s]||(t[s]=Object.create(null)),p=a.split(/ (?!$)/).map(b=>TV(b,e));for(let b=1;b<p.length;b++){let _=p.slice(0,b).join(" ");r(_,!0),d[_]||(d[_]={preventDefault:!0,stopPropagation:!1,run:[v=>{let x=Lo={view:v,prefix:_,scope:s};return setTimeout(()=>{Lo==x&&(Lo=null)},PV),!0}]})}let m=p.join(" ");r(m,!1);let g=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&&g.run.push(l),c&&(g.preventDefault=!0),u&&(g.stopPropagation=!0)};for(let s of n){let a=s.scope?s.scope.split(" "):["editor"];if(s.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}=s;for(let h in u)u[h].run.push(d=>f(d,vb))}let l=s[e]||s.key;if(l)for(let c of a)o(c,l,s.run,s.preventDefault,s.stopPropagation),s.shift&&o(c,"Shift-"+l,s.shift,s.preventDefault,s.stopPropagation)}return t}var vb=null;function IV(n,e,t,i){vb=e;let r=fT(e),o=ti(r,0),s=Yi(o)==r.length&&r!=" ",a="",l=!1,c=!1,u=!1;Lo&&Lo.view==t&&Lo.scope==i&&(a=Lo.prefix+" ",CA.indexOf(e.keyCode)<0&&(c=!0,Lo=null));let f=new Set,h=g=>{if(g){for(let b of g.run)if(!f.has(b)&&(f.add(b),b(t)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},d=n[i],p,m;return d&&(h(d[a+Pg(r,e,!s)])?l=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(z.windows&&e.ctrlKey&&e.altKey)&&!(z.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=jr[e.keyCode])&&p!=r?(h(d[a+Pg(p,e,!0)])||e.shiftKey&&(m=Kl[e.keyCode])!=r&&m!=p&&h(d[a+Pg(m,e,!1)]))&&(l=!0):s&&e.shiftKey&&h(d[a+Pg(r,e,!0)])&&(l=!0),!l&&h(d._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),vb=null,l}var pge=/x/.unicode!=null?"gu":"g";var xb=class extends ai{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?bh(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),r=Ah(t[0],i.direction!="rtl"),o=parseInt(i.lineHeight);return r.bottom-r.top>o*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+o}:r}ignoreEvent(){return!1}};function Ab(n){let e=Yt.fromClass(class{constructor(t){this.view=t,this.placeholder=n?he.set([he.widget({widget:new xb(n),side:1}).range(0)]):he.none}get decorations(){return this.view.state.doc.length?he.none:this.placeholder}},{decorations:t=>t.decorations});return typeof n=="string"?[e,U.contentAttributes.of({"aria-placeholder":n})]:e}var Dg="-10000px",Gg=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(s=>s);let o=null;this.tooltipViews=this.tooltips.map(s=>o=i(s,o))}update(e,t){var i;let r=e.state.facet(this.facet),o=r.filter(l=>l);if(r===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let s=[],a=t?[]:null;for(let l=0;l<o.length;l++){let c=o[l],u=-1;if(c){for(let f=0;f<this.tooltips.length;f++){let h=this.tooltips[f];h&&h.create==c.create&&(u=f)}if(u<0)s[l]=this.createTooltipView(c,l?s[l-1]:null),a&&(a[l]=!!c.above);else{let f=s[l]=this.tooltipViews[u];a&&(a[l]=t[u]),f.update&&f.update(e)}}}for(let l of this.tooltipViews)s.indexOf(l)<0&&(this.removeTooltipView(l),(i=l.destroy)===null||i===void 0||i.call(l));return t&&(a.forEach((l,c)=>t[c]=l),t.length=a.length),this.input=r,this.tooltips=o,this.tooltipViews=s,!0}};function DA(n={}){return Bg.of(n)}function LV(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}var Bg=H.define({combine:n=>{var e,t,i;return{position:z.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)||LV}}}),FT=new WeakMap,Mb=Yt.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(Bg);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 Gg(n,Dh,(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(Bg);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=Dg,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:o}=this.manager.tooltipViews[0];if(z.safari){let s=o.getBoundingClientRect();t=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}else t=!!o.offsetParent&&o.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(n=o.width/this.parent.offsetWidth,e=o.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=Rb(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((o,s)=>{let a=this.manager.tooltipViews[s];return a.getCoords?a.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(Bg).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:o}=n,s=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:u}=c,f=n.pos[a],h=n.size[a];if(!f||l.clip!==!1&&(f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1)){u.style.top=Dg;continue}let d=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=h.right-h.left,g=(e=FT.get(c))!==null&&e!==void 0?e:h.bottom-h.top,b=c.offset||NV,_=this.view.textDirection==We.LTR,v=h.width>i.right-i.left?_?i.left:i.right-h.width:_?Math.max(i.left,Math.min(f.left-(d?14:0)+b.x,i.right-m)):Math.min(Math.max(i.left,f.left-m+(d?14:0)-b.x),i.right-m),x=this.above[a];!l.strictSide&&(x?f.top-g-p-b.y<i.top:f.bottom+g+p+b.y>i.bottom)&&x==i.bottom-f.bottom>f.top-i.top&&(x=this.above[a]=!x);let C=(x?f.top-i.top:i.bottom-f.bottom)-p;if(C<g&&c.resize!==!1){if(C<this.view.defaultLineHeight){u.style.top=Dg;continue}FT.set(c,g),u.style.height=(g=C)/o+"px"}else u.style.height&&(u.style.height="");let E=x?f.top-g-p-b.y:f.bottom+p+b.y,S=v+m;if(c.overlap!==!0)for(let w of s)w.left<S&&w.right>v&&w.top<E+g&&w.bottom>E&&(E=x?w.top-g-2-p:w.bottom+p+2);if(this.position=="absolute"?(u.style.top=(E-n.parent.top)/o+"px",qT(u,(v-n.parent.left)/r)):(u.style.top=E/o+"px",qT(u,v/r)),d){let w=f.left+(_?b.x:-b.x)-(v+14-7);d.style.left=w/r+"px"}c.overlap!==!0&&s.push({left:v,top:E,right:S,bottom:E+g}),u.classList.toggle("cm-tooltip-above",x),u.classList.toggle("cm-tooltip-below",!x),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=Dg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function qT(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}var BV=U.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"}}}),NV={x:0,y:0},Dh=H.define({enables:[Mb,BV]}),Xg=H.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])}),Yg=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 Gg(e,Xg,(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")}},$V=Dh.compute([Xg],n=>{let e=n.facet(Xg);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:Yg.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),jV=H.define(),bb=class{constructor(e,t,i,r,o,s){this.view=e,this.source=t,this.field=i,this.locked=r,this.setHover=o,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(e){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;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.tile.nearest(t.target);if(!i)return;let r,o=1;if(i.isWidget())r=i.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let s=e.coordsAtPos(r);if(!s||t.y<s.top||t.y>s.bottom||t.x<s.left-e.defaultCharacterWidth||t.x>s.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),l=a&&a.dir==We.RTL?-1:1;o=t.x<s.left?-l:l}this.activateHover(e,r,o)}activateHover(e,t,i,r){let o=this.source(e,t,i),s=a=>{if(a&&!(Array.isArray(a)&&!a.length)){let l=Array.isArray(a)?a:[a];r&&this.locked.set(l,r),e.dispatch({effects:this.setHover.of(l)})}};if(o&&"then"in o){let a=this.pending={pos:t};o.then(l=>{this.pending==a&&(this.pending=null,s(l))},l=>It(e.state,l,"hover tooltip"))}else s(o)}get tooltip(){let e=this.view.plugin(Mb),t=e?e.manager.tooltips.findIndex(i=>i.create==Yg.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:o}=this;if(r.length&&!this.locked.has(r)&&o&&!FV(o.dom,e)||this.pending){let{pos:s}=r[0]||this.pending,a=(i=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:s;(s==a?this.view.posAtCoords(this.lastMove)!=s:!qV(this.view,s,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&&!this.locked.has(t)){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);let{active:r}=this;r.length&&!this.locked.has(r)&&!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)}},Ig=4;function FV(n,e){let{left:t,right:i,top:r,bottom:o}=n.getBoundingClientRect(),s;if(s=n.querySelector(".cm-tooltip-arrow")){let a=s.getBoundingClientRect();r=Math.min(a.top,r),o=Math.max(a.bottom,o)}return e.clientX>=t-Ig&&e.clientX<=i+Ig&&e.clientY>=r-Ig&&e.clientY<=o+Ig}function qV(n,e,t,i,r,o){let s=n.scrollDOM.getBoundingClientRect(),a=n.documentTop+n.documentPadding.top+n.contentHeight;if(s.left>i||s.right<i||s.top>r||Math.min(s.bottom,a)<r)return!1;let l=n.posAtCoords({x:i,y:r},!1);return l>=e&&l<=t}function IA(n,e={}){let t=de.define(),i=new WeakMap,r=qt.define({create(){return[]},update(s,a){let l=i.get(s);if(s.length&&(e.hideOnChange&&(a.docChanged||a.selection)?s=[]:l&&l(a)?s=[]:e.hideOn&&(s=s.filter(c=>!e.hideOn(a,c)))),a.docChanged&&s.length){let c=[];for(let u of s){let f=a.changes.mapPos(u.pos,-1,Ot.TrackDel);if(f!=null){let h=Object.assign(Object.create(null),u);h.pos=f,h.end!=null&&(h.end=a.changes.mapPos(h.end)),c.push(h)}}s=c}for(let c of a.effects)c.is(t)&&(s=c.value,l=void 0),(c.is(VV)&&!c.value||c.value==r)&&(s=[]);return s.length&&l&&i.set(s,l),s},provide:s=>Xg.from(s)}),o=Yt.define(s=>new bb(s,n,r,i,t,e.hoverTime||300));return{active:r,extension:[r,o,jV.of(o),$V]}}function Pb(n,e){let t=n.plugin(Mb);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}var VV=de.define();var VT=H.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 HV=Yt.fromClass(class{constructor(n){this.input=n.state.facet(Zg),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(VT);this.top=new Zl(n,!0,e.topContainer),this.bottom=new Zl(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(VT);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Zl(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Zl(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Zg);if(t!=this.input){let i=t.filter(l=>l),r=[],o=[],s=[],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?o:s).push(u)}this.specs=i,this.panels=r,this.top.sync(o),this.bottom.sync(s);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=>U.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Zl=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=HT(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=HT(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 HT(n){let e=n.nextSibling;return n.remove(),e}var Zg=H.define({enables:HV});var er=class extends ei{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};er.prototype.elementClass="";er.prototype.toDOM=void 0;er.prototype.mapMode=Ot.TrackBefore;er.prototype.startSide=er.prototype.endSide=-1;er.prototype.point=!0;var zV=0,Ih=class{constructor(e,t){this.from=e,this.to=t}},ce=class{constructor(e={}){this.id=zV++,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=Zt.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};ce.closedBy=new ce({deserialize:n=>n.split(" ")});ce.openedBy=new ce({deserialize:n=>n.split(" ")});ce.group=new ce({deserialize:n=>n.split(" ")});ce.isolate=new ce({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});ce.contextHash=new ce({perNode:!0});ce.lookAhead=new ce({perNode:!0});ce.mounted=new ce({perNode:!0});var zs=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[ce.mounted.id]}},WV=Object.create(null),Zt=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):WV,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 o of e.props)if(Array.isArray(o)||(o=o(r)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[o[0].id]=o[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(ce.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(ce.group),o=-1;o<(r?r.length:0);o++){let s=t[o<0?i.name:r[o]];if(s)return s}}}};Zt.none=new Zt("",Object.create(null),0,8);var Lh=class n{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let r=null;for(let o of e){let s=o(i);if(s){r||(r=Object.assign({},i.props));let a=s[1],l=s[0];l.combine&&l.id in r&&(a=l.combine(r[l.id],a)),r[l.id]=a}}t.push(r?new Zt(i.name,r,i.id,i.flags):i)}return new n(t)}},ny=new WeakMap,LA=new WeakMap,rt;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays",n[n.EnterBracketed=16]="EnterBracketed"})(rt||(rt={}));var gt=class n{constructor(e,t,i,r,o){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,o&&o.length){this.props=Object.create(null);for(let[s,a]of o)this.props[typeof s=="number"?s:s.id]=a}}toString(){let e=zs.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new $h(this.topNode,e)}cursorAt(e,t=0,i=0){let r=ny.get(this)||this.topNode,o=new $h(r);return o.moveTo(e,t),ny.set(this,o._tree),o}get topNode(){return new tr(this,0,0,null)}resolve(e,t=0){let i=Bh(ny.get(this)||this.topNode,e,t,!1);return ny.set(this,i),i}resolveInner(e,t=0){let i=Bh(LA.get(this)||this.topNode,e,t,!0);return LA.set(this,i),i}resolveStack(e,t=0){return UV(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:o=this.length}=e,s=e.mode||0,a=(s&rt.IncludeAnonymous)>0;for(let l=this.cursor(s|rt.IncludeAnonymous);;){let c=!1;if(l.from<=o&&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:jb(Zt.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(Zt.none,t,i,r)))}static build(e){return QV(e)}};gt.empty=new gt(Zt.none,[],[],0);var Db=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)}},jo=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Zt.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],o=r.name;if(/\W/.test(o)&&!r.isError&&(o=JSON.stringify(o)),e+=4,i==e)return o;let s=[];for(;e<i;)s.push(this.childString(e)),e=this.buffer[e+3];return o+"("+s.join(",")+")"}findChild(e,t,i,r,o){let{buffer:s}=this,a=-1;for(let l=e;l!=t&&!($A(o,r,s[l+1],s[l+2])&&(a=l,i>0));l=s[l+3]);return a}slice(e,t,i){let r=this.buffer,o=new Uint16Array(t-e),s=0;for(let a=e,l=0;a<t;){o[l++]=r[a++],o[l++]=r[a++]-i;let c=o[l++]=r[a++]-i;o[l++]=r[a++]-e,s=Math.max(s,c)}return new n(o,s,this.set)}};function $A(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Bh(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.to<e);){let s=!i&&n instanceof tr&&n.index<0?null:n.parent;if(!s)return n;n=s}let o=i?0:rt.IgnoreOverlays;if(i)for(let s=n,a=s.parent;a;s=a,a=s.parent)s instanceof tr&&s.index<0&&((r=a.enter(e,t,o))===null||r===void 0?void 0:r.from)!=s.from&&(n=a);for(;;){let s=n.enter(e,t,o);if(!s)return n;n=s}}var ry=class{cursor(e=0){return new $h(this,e)}getChild(e,t=null,i=null){let r=BA(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return BA(this,e,t,i)}resolve(e,t=0){return Bh(this,e,t,!1)}resolveInner(e,t=0){return Bh(this,e,t,!0)}matchContext(e){return Ib(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}},tr=class n extends ry{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,o=0){for(let s=this;;){for(let{children:a,positions:l}=s._tree,c=t>0?a.length:-1;e!=c;e+=t){let u=a[e],f=l[e]+s.from,h;if(!(!(o&rt.EnterBracketed&&u instanceof gt&&(h=zs.get(u))&&!h.overlay&&h.bracketed&&i>=f&&i<=f+u.length)&&!$A(r,i,f,f+u.length))){if(u instanceof jo){if(o&rt.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,t,i-f,r);if(d>-1)return new Nh(new Lb(s,u,e,f),null,d)}else if(o&rt.IncludeAnonymous||!u.type.isAnonymous||$b(u)){let d;if(!(o&rt.IgnoreMounts)&&(d=zs.get(u))&&!d.overlay)return new n(d.tree,f,e,s);let p=new n(u,f,e,s);return o&rt.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?u.children.length-1:0,t,i,r,o)}}}if(o&rt.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+t:e=t<0?-1:s._parent._tree.children.length,s=s._parent,!s))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&rt.IgnoreOverlays)&&(r=zs.get(this._tree))&&r.overlay){let o=e-this.from,s=i&rt.EnterBracketed&&r.bracketed;for(let{from:a,to:l}of r.overlay)if((t>0||s?a<=o:a<o)&&(t<0||s?l>=o:l>o))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 BA(n,e,t,i){let r=n.cursor(),o=[];if(!r.firstChild())return o;if(t!=null){for(let s=!1;!s;)if(s=r.type.is(t),!r.nextSibling())return o}for(;;){if(i!=null&&r.type.is(i))return o;if(r.type.is(e)&&o.push(r.node),!r.nextSibling())return i==null?o:[]}}function Ib(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 Lb=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},Nh=class n extends ry{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,o=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return o<0?null:new n(this.context,this,o)}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&rt.ExcludeBuffers)return null;let{buffer:r}=this.context,o=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return o<0?null:new n(this.context,this,o)}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,o=i.buffer[this.index+3];if(o>r){let s=i.buffer[this.index+1];e.push(i.slice(r,o,s)),t.push(0)}return new gt(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function jA(n){if(!n.length)return null;let e=0,t=n[0];for(let o=1;o<n.length;o++){let s=n[o];(s.from>t.from||s.to<t.to)&&(t=s,e=o)}let i=t instanceof tr&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new Bb(r,t)}var Bb=class{constructor(e,t){this.heads=e,this.node=t}get next(){return jA(this.heads)}};function UV(n,e,t){let i=n.resolveInner(e,t),r=null;for(let o=i instanceof tr?i:i.context.parent;o;o=o.parent)if(o.index<0){let s=o.parent;(r||(r=[i])).push(s.resolve(e,t)),o=s}else{let s=zs.get(o.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let a=new tr(s.tree,s.overlay[0].from+o.from,-1,o);(r||(r=[i])).push(Bh(a,e,t,!1))}}return r?jA(r):i}var $h=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&~rt.EnterBracketed,e instanceof tr)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 tr?(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,o=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}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&rt.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&rt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&rt.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<r.buffer.buffer.length)return!1}else for(let o=0;o<this.index;o++)if(r.buffer.buffer[o+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let o=t+e,s=e<0?-1:i._tree.children.length;o!=s;o+=e){let a=i._tree.children[o];if(this.mode&rt.IncludeAnonymous||a instanceof jo||!a.type.isAnonymous||$b(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<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,o=this.stack.length;o>=0;){for(let s=e;s;s=s._parent)if(s.index==r){if(r==this.index)return s;t=s,i=o+1;break e}r=this.stack[--o]}for(let r=i;r<this.stack.length;r++)t=new Nh(this.buffer,t,this.stack[r]);return this.bufferNode=new Nh(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return Ib(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,o=this.stack.length-1;r>=0;o--){if(o<0)return Ib(this._tree,e,r);let s=i[t.buffer[this.stack[o]]];if(!s.isAnonymous){if(e[r]&&e[r]!=s.name)return!1;r--}}return!0}};function $b(n){return n.children.some(e=>e instanceof jo||!e.type.isAnonymous||$b(e))}function QV(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:o=[],minRepeatType:s=i.types.length}=n,a=Array.isArray(t)?new Db(t,t.length):t,l=i.types,c=0,u=0;function f(C,E,S,w,R,A){let{id:I,start:D,end:N,size:W}=a,Re=u,_e=c;if(W<0)if(a.next(),W==-1){let $e=o[I];S.push($e),w.push(D-C);return}else if(W==-3){c=I;return}else if(W==-4){u=I;return}else throw new RangeError(`Unrecognized record size: ${W}`);let ue=l[I],re,me,Ue=D-C;if(N-D<=r&&(me=g(a.pos-E,R))){let $e=new Uint16Array(me.size-me.skip),Ct=a.pos-me.size,Nt=$e.length;for(;a.pos>Ct;)Nt=b(me.start,$e,Nt);re=new jo($e,N-me.start,i),Ue=me.start-C}else{let $e=a.pos-W;a.next();let Ct=[],Nt=[],fn=I>=s?I:-1,ct=0,Ti=N;for(;a.pos>$e;)fn>=0&&a.id==fn&&a.size>=0?(a.end<=Ti-r&&(p(Ct,Nt,D,ct,a.end,Ti,fn,Re,_e),ct=Ct.length,Ti=a.end),a.next()):A>2500?h(D,$e,Ct,Nt):f(D,$e,Ct,Nt,fn,A+1);if(fn>=0&&ct>0&&ct<Ct.length&&p(Ct,Nt,D,ct,D,Ti,fn,Re,_e),Ct.reverse(),Nt.reverse(),fn>-1&&ct>0){let Zo=d(ue,_e);re=jb(ue,Ct,Nt,0,Ct.length,0,N-D,Zo,Zo)}else re=m(ue,Ct,Nt,N-D,Re-N,_e)}S.push(re),w.push(Ue)}function h(C,E,S,w){let R=[],A=0,I=-1;for(;a.pos>E;){let{id:D,start:N,end:W,size:Re}=a;if(Re>4)a.next();else{if(I>-1&&N<I)break;I<0&&(I=W-r),R.push(D,N,W),A++,a.next()}}if(A){let D=new Uint16Array(A*4),N=R[R.length-2];for(let W=R.length-3,Re=0;W>=0;W-=3)D[Re++]=R[W],D[Re++]=R[W+1]-N,D[Re++]=R[W+2]-N,D[Re++]=Re;S.push(new jo(D,R[2]-N,i)),w.push(N-C)}}function d(C,E){return(S,w,R)=>{let A=0,I=S.length-1,D,N;if(I>=0&&(D=S[I])instanceof gt){if(!I&&D.type==C&&D.length==R)return D;(N=D.prop(ce.lookAhead))&&(A=w[I]+D.length+N)}return m(C,S,w,R,A,E)}}function p(C,E,S,w,R,A,I,D,N){let W=[],Re=[];for(;C.length>w;)W.push(C.pop()),Re.push(E.pop()+S-R);C.push(m(i.types[I],W,Re,A-R,D-A,N)),E.push(R-S)}function m(C,E,S,w,R,A,I){if(A){let D=[ce.contextHash,A];I=I?[D].concat(I):[D]}if(R>25){let D=[ce.lookAhead,R];I=I?[D].concat(I):[D]}return new gt(C,E,S,w,I)}function g(C,E){let S=a.fork(),w=0,R=0,A=0,I=S.end-r,D={size:0,start:0,skip:0};e:for(let N=S.pos-C;S.pos>N;){let W=S.size;if(S.id==E&&W>=0){D.size=w,D.start=R,D.skip=A,A+=4,w+=4,S.next();continue}let Re=S.pos-W;if(W<0||Re<N||S.start<I)break;let _e=S.id>=s?4:0,ue=S.start;for(S.next();S.pos>Re;){if(S.size<0)if(S.size==-3||S.size==-4)_e+=4;else break e;else S.id>=s&&(_e+=4);S.next()}R=ue,w+=W,A+=_e}return(E<0||w==C)&&(D.size=w,D.start=R,D.skip=A),D.size>4?D:void 0}function b(C,E,S){let{id:w,start:R,end:A,size:I}=a;if(a.next(),I>=0&&w<s){let D=S;if(I>4){let N=a.pos-(I-4);for(;a.pos>N;)S=b(C,E,S)}E[--S]=D,E[--S]=A-C,E[--S]=R-C,E[--S]=w}else I==-3?c=w:I==-4&&(u=w);return S}let _=[],v=[];for(;a.pos>0;)f(n.start||0,n.bufferStart||0,_,v,-1,0);let x=(e=n.length)!==null&&e!==void 0?e:_.length?v[0]+_[0].length:0;return new gt(l[n.topID],_.reverse(),v.reverse(),x)}var NA=new WeakMap;function iy(n,e){if(!n.isAnonymous||e instanceof jo||e.type!=n)return 1;let t=NA.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof gt)){t=1;break}t+=iy(n,i)}NA.set(e,t)}return t}function jb(n,e,t,i,r,o,s,a,l){let c=0;for(let p=i;p<r;p++)c+=iy(n,e[p]);let u=Math.ceil(c*1.5/8),f=[],h=[];function d(p,m,g,b,_){for(let v=g;v<b;){let x=v,C=m[v],E=iy(n,p[v]);for(v++;v<b;v++){let S=iy(n,p[v]);if(E+S>=u)break;E+=S}if(v==x+1){if(E>u){let S=p[x];d(S.children,S.positions,0,S.children.length,m[x]+_);continue}f.push(p[x])}else{let S=m[v-1]+p[v-1].length-C;f.push(jb(n,p,m,x,v,C,S,null,l))}h.push(C+_-o)}}return d(e,t,i,r,0),(a||l)(f,h,s)}var Ws=class n{constructor(e,t,i,r,o=!1,s=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(o?1:0)|(s?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 o of t)o.to>e.length&&r.push(o);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],o=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<t.length?t[a]:null,f=u?u.fromA:1e9;if(f-l>=i)for(;s&&s.from<f;){let h=s;if(l>=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),s.to>f)break;s=o<e.length?e[o++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return r}},ac=class{startParse(e,t,i){return typeof e=="string"&&(e=new Nb(e)),i=i?i.length?i.map(r=>new Ih(r.from,r.to)):[new Ih(0,0)]:[new Ih(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let o=r.advance();if(o)return o}}},Nb=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 bge=new ce({perNode:!0});var KV=0,Ci=class n{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=KV++}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 o of t.set)r.set.push(o);return r}static defineModifier(e){let t=new ly(e);return i=>i.modified.indexOf(t)>-1?i:ly.get(i.base||i,i.modified.concat(t).sort((r,o)=>r.id-o.id))}},GV=0,ly=class n{constructor(e){this.name=e,this.instances=[],this.id=GV++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(a=>a.base==e&&XV(t,a.modified));if(i)return i;let r=[],o=new Ci(e.name,r,e,t);for(let a of t)a.instances.push(o);let s=YV(t);for(let a of e.set)if(!a.modified.length)for(let l of s)r.push(n.get(a,l));return o}};function XV(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function YV(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function cy(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 o=[],s=2,a=r;for(let f=0;;){if(a=="..."&&f>0&&f+3==r.length){s=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+r);if(o.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=="!"){s=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);a=r.slice(f)}let l=o.length-1,c=o[l];if(!c)throw new RangeError("Invalid path: "+r);let u=new Qs(i,s,l>0?o.slice(0,l):null);e[c]=u.sort(e[c])}}return VA.add(e)}var VA=new ce({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 o=new Qs(r.tags,r.mode,r.context);t?t.next=o:i=o,t=o}return i}}),Qs=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<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Qs.empty=new Qs([],2,null);function Hb(n,e){let t=Object.create(null);for(let o of n)if(!Array.isArray(o.tag))t[o.tag.id]=o.class;else for(let s of o.tag)t[s.id]=o.class;let{scope:i,all:r=null}=e||{};return{style:o=>{let s=r;for(let a of o)for(let l of a.set){let c=t[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:i}}function ZV(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function HA(n,e,t,i=0,r=n.length){let o=new qb(i,Array.isArray(e)?e:[e],t);o.highlightRange(n.cursor(),i,r,"",o.highlighters),o.flush(r)}var qb=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,o){let{type:s,from:a,to:l}=e;if(a>=i||l<=t)return;s.isTop&&(o=this.highlighters.filter(d=>!d.scope||d.scope(s)));let c=r,u=JV(e)||Qs.empty,f=ZV(o,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(ce.mounted);if(h&&h.overlay){let d=e.node.enter(h.overlay[0].from+a,1),p=this.highlighters.filter(g=>!g.scope||g.scope(h.tree.type)),m=e.firstChild();for(let g=0,b=a;;g++){let _=g<h.overlay.length?h.overlay[g]:null,v=_?_.from+a:l,x=Math.max(t,b),C=Math.min(i,v);if(x<C&&m)for(;e.from<C&&(this.highlightRange(e,x,C,r,o),this.startSpan(Math.min(C,e.to),c),!(e.to>=v||!e.nextSibling())););if(!_||v>i)break;b=_.to+a,b>t&&(this.highlightRange(d.cursor(),Math.max(t,_.from+a),Math.min(i,b),"",p),this.startSpan(Math.min(i,b),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,o),this.startSpan(Math.min(i,e.to),c)}while(e.nextSibling());e.parent()}}};function JV(n){let e=n.type.prop(VA);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var V=Ci.define,oy=V(),Fo=V(),FA=V(Fo),qA=V(Fo),qo=V(),sy=V(qo),Fb=V(qo),rr=V(),Us=V(rr),nr=V(),ir=V(),Vb=V(),jh=V(Vb),ay=V(),B={comment:oy,lineComment:V(oy),blockComment:V(oy),docComment:V(oy),name:Fo,variableName:V(Fo),typeName:FA,tagName:V(FA),propertyName:qA,attributeName:V(qA),className:V(Fo),labelName:V(Fo),namespace:V(Fo),macroName:V(Fo),literal:qo,string:sy,docString:V(sy),character:V(sy),attributeValue:V(sy),number:Fb,integer:V(Fb),float:V(Fb),bool:V(qo),regexp:V(qo),escape:V(qo),color:V(qo),url:V(qo),keyword:nr,self:V(nr),null:V(nr),atom:V(nr),unit:V(nr),modifier:V(nr),operatorKeyword:V(nr),controlKeyword:V(nr),definitionKeyword:V(nr),moduleKeyword:V(nr),operator:ir,derefOperator:V(ir),arithmeticOperator:V(ir),logicOperator:V(ir),bitwiseOperator:V(ir),compareOperator:V(ir),updateOperator:V(ir),definitionOperator:V(ir),typeOperator:V(ir),controlOperator:V(ir),punctuation:Vb,separator:V(Vb),bracket:jh,angleBracket:V(jh),squareBracket:V(jh),paren:V(jh),brace:V(jh),content:rr,heading:Us,heading1:V(Us),heading2:V(Us),heading3:V(Us),heading4:V(Us),heading5:V(Us),heading6:V(Us),contentSeparator:V(rr),list:V(rr),quote:V(rr),emphasis:V(rr),strong:V(rr),link:V(rr),monospace:V(rr),strikethrough:V(rr),inserted:V(),deleted:V(),changed:V(),invalid:V(),meta:ay,documentMeta:V(ay),annotation:V(ay),processingInstruction:V(ay),definition:Ci.defineModifier("definition"),constant:Ci.defineModifier("constant"),function:Ci.defineModifier("function"),standard:Ci.defineModifier("standard"),local:Ci.defineModifier("local"),special:Ci.defineModifier("special")};for(let n in B){let e=B[n];e instanceof Ci&&(e.name=n)}var Cge=Hb([{tag:B.link,class:"tok-link"},{tag:B.heading,class:"tok-heading"},{tag:B.emphasis,class:"tok-emphasis"},{tag:B.strong,class:"tok-strong"},{tag:B.keyword,class:"tok-keyword"},{tag:B.atom,class:"tok-atom"},{tag:B.bool,class:"tok-bool"},{tag:B.url,class:"tok-url"},{tag:B.labelName,class:"tok-labelName"},{tag:B.inserted,class:"tok-inserted"},{tag:B.deleted,class:"tok-deleted"},{tag:B.literal,class:"tok-literal"},{tag:B.string,class:"tok-string"},{tag:B.number,class:"tok-number"},{tag:[B.regexp,B.escape,B.special(B.string)],class:"tok-string2"},{tag:B.variableName,class:"tok-variableName"},{tag:B.local(B.variableName),class:"tok-variableName tok-local"},{tag:B.definition(B.variableName),class:"tok-variableName tok-definition"},{tag:B.special(B.variableName),class:"tok-variableName2"},{tag:B.definition(B.propertyName),class:"tok-propertyName tok-definition"},{tag:B.typeName,class:"tok-typeName"},{tag:B.namespace,class:"tok-namespace"},{tag:B.className,class:"tok-className"},{tag:B.macroName,class:"tok-macroName"},{tag:B.propertyName,class:"tok-propertyName"},{tag:B.operator,class:"tok-operator"},{tag:B.comment,class:"tok-comment"},{tag:B.meta,class:"tok-meta"},{tag:B.invalid,class:"tok-invalid"},{tag:B.punctuation,class:"tok-punctuation"}]);var zb,lc=new ce;function t4(n){return H.define({combine:n?e=>e.concat(n):void 0})}var n4=new ce,In=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,Ze.prototype.hasOwnProperty("tree")||Object.defineProperty(Ze.prototype,"tree",{get(){return lt(this)}}),this.parser=t,this.extension=[cc.of(this),Ze.languageData.of((o,s,a)=>{let l=zA(o,s,a),c=l.type.prop(lc);if(!c)return[];let u=o.facet(c),f=l.type.prop(n4);if(f){let h=l.resolve(s-l.from,a);for(let d of f)if(d.test(h,o)){let p=o.facet(d.facet);return d.type=="replace"?p:p.concat(u)}}return u})].concat(i)}isActiveAt(e,t,i=-1){return zA(e,t,i).type.prop(lc)==this.data}findRegions(e){let t=e.facet(cc);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(o,s)=>{if(o.prop(lc)==this.data){i.push({from:s,to:s+o.length});return}let a=o.prop(ce.mounted);if(a){if(a.tree.prop(lc)==this.data){if(a.overlay)for(let l of a.overlay)i.push({from:l.from+s,to:l.to+s});else i.push({from:s,to:s+o.length});return}else if(a.overlay){let l=i.length;if(r(a.tree,a.overlay[0].from+s),i.length>l)return}}for(let l=0;l<o.children.length;l++){let c=o.children[l];c instanceof gt&&r(c,o.positions[l]+s)}};return r(lt(e),0),i}get allowsNesting(){return!0}};In.setState=de.define();function zA(n,e,t){let i=n.facet(cc),r=lt(n).topNode;if(!i||i.allowsNesting)for(let o=r;o;o=o.enter(e,t,rt.ExcludeBuffers|rt.EnterBracketed))o.type.isTop&&(r=o);return r}var uy=class n extends In{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=t4(e.languageData);return new n(t,e.parser.configure({props:[lc.add(i=>i.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 lt(n){let e=n.field(In.state,!1);return e?e.tree:gt.empty}var Kb=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<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},Fh=null,Gb=class n{constructor(e,t,i=[],r,o,s,a,l){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=o,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],gt.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Kb(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=gt.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.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(Ws.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=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(Ws.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Fh;Fh=this;try{return e()}finally{Fh=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=WA(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:o,viewport:s,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=Ws.applyChanges(i,l),r=gt.empty,o=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.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);u<f&&a.push({from:u,to:f})}}}return new n(this.parser,t,i,r,o,s,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:o}=this.skipped[i];r<e.to&&o>e.from&&(this.fragments=WA(this.fragments,r,o),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 ac{createParse(t,i,r){let o=r[0].from,s=r[r.length-1].to;return{parsedPos:o,advance(){let l=Fh;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=s,new gt(Zt.none,[],[],s-o)},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 Fh}};function WA(n,e,t){return Ws.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var qh=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=Gb.create(e.facet(cc).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};In.state=qt.define({create:qh.init,update(n,e){for(let t of e.effects)if(t.is(In.setState))return t.value;return e.startState.facet(cc)!=e.state.facet(cc)?qh.init(e.state):n.apply(e)}});var XA=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(XA=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Wb=typeof navigator!="undefined"&&(!((zb=navigator.scheduling)===null||zb===void 0)&&zb.isInputPending)?()=>navigator.scheduling.isInputPending():null,i4=Yt.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(In.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(In.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=XA(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,o=i.field(In.state);if(o.tree==o.context.tree&&o.context.isDone(r+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!Wb?Math.max(25,e.timeRemaining()-5):1e9),a=o.context.treeLen<r&&i.doc.length>r+1e3,l=o.context.work(()=>Wb&&Wb()||Date.now()>s,r+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:In.setState.of(new qh(o.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>It(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()}}}),cc=H.define({combine(n){return n.length?n[0]:null},enables:n=>[In.state,i4,U.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),fy=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var r4=H.define(),fc=H.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 Vh(n){let e=n.facet(fc);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function hc(n,e){let t="",i=n.tabSize,r=n.facet(fc)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let o=0;o<e;o++)t+=r;return t}function hy(n,e){n instanceof Ze&&(n=new Ks(n));for(let i of n.state.facet(r4)){let r=i(n,e);if(r!==void 0)return r}let t=lt(n.state);return t.length>=e?o4(n,t,e):null}var Ks=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Vh(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:o}=this.options;return r!=null&&r>=i.from&&r<=i.to?o&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),o=this.countColumn(i,e-r),s=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return s>-1&&(o+=s-this.countColumn(i,i.search(/\S|$/))),o}countColumn(e,t=e.length){return $s(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),o=this.options.overrideIndentation;if(o){let s=o(r);if(s>-1)return s}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},t_=new ce;function o4(n,e,t){let i=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=i.node){let o=[];for(let s=r;s&&!(s.from<i.node.from||s.to>i.node.to||s.from==i.node.from&&s.type==i.node.type);s=s.parent)o.push(s);for(let s=o.length-1;s>=0;s--)i={node:o[s],next:i}}return YA(i,n,t)}function YA(n,e,t){for(let i=n;i;i=i.next){let r=a4(i.node);if(r)return r(Xb.create(e,t,i))}return 0}function s4(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function a4(n){let e=n.type.prop(t_);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(ce.closedBy))){let r=n.lastChild,o=r&&i.indexOf(r.name)>-1;return s=>ZA(s,!0,1,void 0,o&&!s4(s)?r.from:void 0)}return n.parent==null?l4:null}function l4(){return 0}var Xb=class n extends Ks{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(c4(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return YA(this.context.next,this.base,this.pos)}};function c4(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function u4(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,o=n.state.doc.lineAt(t.from),s=r==null||r<=o.from?o.to:Math.min(o.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>=s)return null;let c=/^ */.exec(o.text.slice(t.to-o.from))[0].length;return{from:t.from,to:t.to+c}}a=l.to}}function n_({closing:n,align:e=!0,units:t=1}){return i=>ZA(i,e,t,n)}function ZA(n,e,t,i,r){let o=n.textAfter,s=o.match(/^\s*/)[0].length,a=i&&o.slice(s,s+i.length)==i||r==n.pos+s,l=e?u4(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*t)}function dy({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}var f4=200;function JA(){return Ze.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+f4)return n;let o=t.sliceString(r.from,i);if(!e.some(c=>c.test(o)))return n;let{state:s}=n,a=-1,l=[];for(let{head:c}of s.selection.ranges){let u=s.doc.lineAt(c);if(u.from==a)continue;a=u.from;let f=hy(s,u.from);if(f==null)continue;let h=/^\s*/.exec(u.text)[0],d=hc(s,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 eM=new ce;function py(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}var uc=class n{constructor(e,t){this.specs=e;let i;function r(a){let l=ni.newName();return(i||(i=Object.create(null)))["."+l]=a,l}let o=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,s=t.scope;this.scope=s instanceof In?a=>a.prop(lc)==s.data:s?a=>a==s:void 0,this.style=Hb(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:o}).style,this.module=i?new ni(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},Yb=H.define(),tM=H.define({combine(n){return n.length?[n[0]]:null}});function Ub(n){let e=n.facet(Yb);return e.length?e:n.facet(tM)}function nM(n,e){let t=[h4],i;return n instanceof uc&&(n.module&&t.push(U.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(tM.of(n)):i?t.push(Yb.computeN([U.darkTheme],r=>r.facet(U.darkTheme)==(i=="dark")?[n]:[])):t.push(Yb.of(n)),t}var Zb=class{constructor(e){this.markCache=Object.create(null),this.tree=lt(e.state),this.decorations=this.buildDeco(e,Ub(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=lt(e.state),i=Ub(e.state),r=i!=Ub(e.startState),{viewport:o}=e.view,s=e.changes.mapPos(this.decoratedTo,1);t.length<o.to&&!r&&t.type==this.tree.type&&s>=o.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=o.to)}buildDeco(e,t){if(!t||!this.tree.length)return he.none;let i=new Nr;for(let{from:r,to:o}of e.visibleRanges)HA(this.tree,t,(s,a,l)=>{i.add(s,a,this.markCache[l]||(this.markCache[l]=he.mark({class:l})))},r,o);return i.finish()}},h4=$r.high(Yt.fromClass(Zb,{decorations:n=>n.decorations})),Mge=uc.define([{tag:B.meta,color:"#404740"},{tag:B.link,textDecoration:"underline"},{tag:B.heading,textDecoration:"underline",fontWeight:"bold"},{tag:B.emphasis,fontStyle:"italic"},{tag:B.strong,fontWeight:"bold"},{tag:B.strikethrough,textDecoration:"line-through"},{tag:B.keyword,color:"#708"},{tag:[B.atom,B.bool,B.url,B.contentSeparator,B.labelName],color:"#219"},{tag:[B.literal,B.inserted],color:"#164"},{tag:[B.string,B.deleted],color:"#a11"},{tag:[B.regexp,B.escape,B.special(B.string)],color:"#e40"},{tag:B.definition(B.variableName),color:"#00f"},{tag:B.local(B.variableName),color:"#30a"},{tag:[B.typeName,B.namespace],color:"#085"},{tag:B.className,color:"#167"},{tag:[B.special(B.variableName),B.macroName],color:"#256"},{tag:B.definition(B.propertyName),color:"#00c"},{tag:B.comment,color:"#940"},{tag:B.invalid,color:"#f00"}]),d4=U.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),iM=1e4,rM="()[]{}",oM=H.define({combine(n){return Io(n,{afterCursor:!0,brackets:rM,maxScanDistance:iM,renderMatch:g4})}}),p4=he.mark({class:"cm-matchingBracket"}),m4=he.mark({class:"cm-nonmatchingBracket"});function g4(n){let e=[],t=n.matched?p4:m4;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 UA(n){let e=[],t=n.facet(oM);for(let i of n.selection.ranges){if(!i.empty)continue;let r=Ei(n,i.head,-1,t)||i.head>0&&Ei(n,i.head-1,1,t)||t.afterCursor&&(Ei(n,i.head,1,t)||i.head<n.doc.length&&Ei(n,i.head+1,-1,t));r&&(e=e.concat(t.renderMatch(r,n)))}return he.set(e,!0)}var y4=Yt.fromClass(class{constructor(n){this.paused=!1,this.decorations=UA(n.state)}update(n){(n.docChanged||n.selectionSet||this.paused)&&(n.view.composing?(this.decorations=this.decorations.map(n.changes),this.paused=!0):(this.decorations=UA(n.state),this.paused=!1))}},{decorations:n=>n.decorations}),v4=[y4,d4];function sM(n={}){return[oM.of(n),v4]}var x4=new ce;function Jb(n,e,t){let i=n.prop(e<0?ce.openedBy:ce.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 e_(n){let e=n.type.prop(x4);return e?e(n.node):n}function Ei(n,e,t,i={}){let r=i.maxScanDistance||iM,o=i.brackets||rM,s=lt(n),a=s.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=Jb(l.type,t,o);if(c&&l.from<l.to){let u=e_(l);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return b4(n,e,t,l,u,c,o)}}return _4(n,e,t,s,a.type,r,o)}function b4(n,e,t,i,r,o,s){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&&o.indexOf(u.type.name)>-1&&u.from<u.to){let f=e_(u);return{start:l,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(Jb(u.type,t,s))c++;else if(Jb(u.type,-t,s)){if(c==0){let f=e_(u);return{start:l,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}c--}}while(t<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function _4(n,e,t,i,r,o,s){if(t<0?!e:e==n.doc.length)return null;let a=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),l=s.indexOf(a);if(l<0||l%2==0!=t>0)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<=o;){let d=u.value;t<0&&(h+=d.length);let p=e+h*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let b=s.indexOf(d[m]);if(!(b<0||i.resolveInner(p+m,1).type!=r))if(b%2==0==t>0)f++;else{if(f==1)return{start:c,end:{from:p+m,to:p+m+1},matched:b>>1==l>>1};f--}}t>0&&(h+=d.length)}return u.done?{start:c,matched:!1}:null}var w4=Object.create(null),QA=[Zt.none];var KA=[],GA=Object.create(null),C4=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"]])C4[n]=E4(w4,e);function Qb(n,e){KA.indexOf(n)>-1||(KA.push(n),console.warn(e))}function E4(n,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=n[c]||B[c];u?typeof u=="function"?l.length?l=l.map(u):Qb(c,`Modifier ${c} used at start of tag`):l.length?Qb(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:Qb(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),o=GA[r];if(o)return o.id;let s=GA[r]=Zt.define({id:QA.length,name:i,props:[cy({[i]:t})]});return QA.push(s),s.id}var Pge={rtl:he.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:We.RTL}),ltr:he.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:We.LTR}),auto:he.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var gy=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=lt(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),o=r.search(mM(e,!1));return o<0?null:{from:i+o,to:this.pos,text:r.slice(o)}}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 aM(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 S4(n){let e=Object.create(null),t=Object.create(null);for(let{label:r}of n){e[r[0]]=!0;for(let o=1;o<r.length;o++)t[r[o]]=!0}let i=aM(e)+aM(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function pc(n){let e=n.map(r=>typeof r=="string"?{label:r}:r),[t,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:S4(e);return r=>{let o=r.matchBefore(i);return o||r.explicit?{from:o?o.from:r.pos,options:e,validFor:t}:null}}var yy=class{constructor(e,t,i,r){this.completion=e,this.source=t,this.match=i,this.score=r}};function Xs(n){return n.selection.main.from}function mM(n,e){var t;let{source:i}=n,r=e&&i[0]!="^",o=i[i.length-1]!="$";return!r&&!o?n:new RegExp(`${r?"^":""}(?:${i})${o?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}var m_=Mn.define();function O4(n,e,t,i){let{main:r}=n.selection,o=t-r.from,s=i-r.from;return{...n.changeByRange(a=>{if(a!=r&&t!=i&&n.sliceDoc(a.from+o,a.from+s)!=n.sliceDoc(t,i))return{range:a};let l=n.toText(e);return{changes:{from:a.from+o,to:i==r.from?a.to:a.from+s,insert:l},range:$.cursor(a.from+o+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}var lM=new WeakMap;function k4(n){if(!Array.isArray(n))return n;let e=lM.get(n);return e||lM.set(n,e=pc(n)),e}var vy=de.define(),Hh=de.define(),s_=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<e.length;){let i=ti(e,t),r=Yi(i);this.chars.push(i);let o=e.slice(t,t+r),s=o.toUpperCase();this.folded.push(ti(s==o?o.toLowerCase():s,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:r,precise:o,byWord:s}=this;if(t.length==1){let _=ti(e,0),v=Yi(_),x=v==e.length?0:-100;if(_!=t[0])if(_==i[0])x+=-200;else return null;return this.ret(x,[0,v])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,c=0;if(a<0){for(let _=0,v=Math.min(e.length,200);_<v&&c<l;){let x=ti(e,_);(x==t[c]||x==i[c])&&(r[c++]=_),_+=Yi(x)}if(c<l)return null}let u=0,f=0,h=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),b=!0;for(let _=0,v=Math.min(e.length,200),x=0;_<v&&f<l;){let C=ti(e,_);a<0&&(u<l&&C==t[u]&&(o[u++]=_),d<l&&(C==t[d]||C==i[d]?(d==0&&(p=_),m=_+1,d++):d=0));let E,S=C<255?C>=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(E=E0(C))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!_||S==1&&g||x==0&&S!=0)&&(t[f]==C||i[f]==C&&(h=!0)?s[f++]=_:s.length&&(b=!1)),x=S,_+=Yi(C)}return f==l&&s[0]==0&&b?this.result(-100+(h?-200:0),s,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+(b?0:-1100),s,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,i){let r=[],o=0;for(let s of t){let a=s+(this.astral?Yi(ti(i,s)):1);o&&r[o-1]==s?r[o-1]=a:(r[o++]=s,r[o++]=a)}return this.ret(e-i.length,r)}},a_=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}},Lt=H.define({combine(n){return Io(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:R4,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=>cM(e(i),t(i)),optionClass:(e,t)=>i=>cM(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function cM(n,e){return n?e?n+" "+e:n:e}function R4(n,e,t,i,r,o){let s=n.textDirection==We.RTL,a=s,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<Math.min(p,d)?a=!1:!a&&d<Math.min(p,h)&&(a=!0),p<=(a?h:d))u=Math.max(r.top,Math.min(t.top,r.bottom-m))-e.top,f=Math.min(400,a?h:d);else{l=!0,f=Math.min(400,(s?e.right:r.right-e.left)-30);let _=r.bottom-e.bottom;_>=m||_>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let g=(e.bottom-e.top)/o.offsetHeight,b=(e.right-e.left)/o.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${f/b}px`,class:"cm-completionInfo-"+(l?s?"left-narrow":"right-narrow":a?"left":"right")}}var g_=de.define();function T4(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,o){let s=document.createElement("span");s.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;c<o.length;){let u=o[c++],f=o[c++];u>l&&s.appendChild(document.createTextNode(a.slice(l,u)));let h=s.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(a.slice(u,f))),h.className="cm-completionMatchedText",l=f}return l<a.length&&s.appendChild(document.createTextNode(a.slice(l))),s},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function i_(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.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}var l_=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:o,selected:s}=r.open,a=e.state.facet(Lt);this.optionContent=T4(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=i_(o.length,s,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]<c.length){this.applyCompletion(e,c[+f[1]]),l.preventDefault();return}if(l.target==this.list){let u=this.list.classList.contains("cm-completionListIncompleteTop")&&l.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&l.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;u!=null&&(e.dispatch({effects:g_.of(u)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Lt).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Hh.of(null)})}),this.showOptions(o,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:o,selected:s,disabled:a}=i.open;(!r.open||r.open.options!=o)&&(this.range=i_(o.length,s,e.state.facet(Lt).maxRenderedOptions),this.showOptions(o,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.from||t.selected>=this.range.to)&&(this.range=i_(t.options.length,t.selected,this.view.state.facet(Lt).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:o}=r;if(!o)return;let s=typeof o=="string"?document.createTextNode(o):o(r);if(!s)return;"then"in s?s.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,r)}).catch(a=>It(this.view.state,a,"completion info")):(this.addInfoPane(s,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:o}=e;i.appendChild(r),this.infoDestroy=o||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&&M4(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(),o=this.space;if(!o){let s=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:s.clientWidth,bottom:s.clientHeight}}return r.top>Math.min(o.bottom,t.bottom)-10||r.bottom<Math.max(o.top,t.top)+10?null:this.view.state.facet(Lt).positionInfo(this.view,t,r,i,o,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){let r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",s=>{s.target==r&&s.preventDefault()});let o=null;for(let s=i.from;s<i.to;s++){let{completion:a,match:l}=e[s],{section:c}=a;if(c){let h=typeof c=="string"?c:c.name;if(h!=o&&(s>i.from||i.from==0))if(o=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+"-"+s,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.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}};function A4(n,e){return t=>new l_(t,n,e)}function M4(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),r=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/r:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/r)}function uM(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function P4(n,e){let t=[],i=null,r=null,o=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)}},s=e.facet(Lt);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)o(new yy(h,u.source,f?f(h):[],1e9-t.length));else{let h=e.sliceDoc(u.from,u.to),d,p=s.filterStrict?new a_(h):new s_(h);for(let m of u.result.options)if(d=p.match(m.label)){let g=m.displayLabel?f?f(m,d.matched):[]:d.matched,b=d.score+(m.boost||0);if(o(new yy(m,u.source,g,b)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:_}=m.section;r||(r=Object.create(null)),r[_]=Math.max(b,r[_]||-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.name<p.name?-1:1);for(let d of i.sort(h))f-=1e5,u[d.name]=f;for(let d of t){let{section:p}=d.completion;p&&(d.score+=u[typeof p=="string"?p:p.name])}}let a=[],l=null,c=s.compareCompletions;for(let u of t.sort((f,h)=>h.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):uM(u.completion)>uM(l)&&(a[a.length-1]=u),l=u.completion}return a}var c_=class n{constructor(e,t,i,r,o,s){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=r,this.selected=o,this.disabled=s}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new n(this.options,fM(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,r,o,s){if(r&&!s&&e.some(c=>c.isPending))return r.setDisabled();let a=P4(e,t);if(!a.length)return r&&e.some(c=>c.isPending)?r.setDisabled():null;let l=t.facet(Lt).selectOnOpen?0:-1;if(r&&r.selected!=l&&r.selected!=-1){let c=r.options[r.selected].completion;for(let u=0;u<a.length;u++)if(a[u].completion==c){l=u;break}}return new n(a,fM(i,l),{pos:e.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:$4,above:o.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)}},u_=class n{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new n(B4,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Lt),o=(i.override||t.languageDataAt("autocomplete",Xs(t)).map(k4)).map(l=>(this.active.find(u=>u.source==l)||new Hr(l,this.active.some(u=>u.state!=0)?1:0)).update(e,i));o.length==this.active.length&&o.every((l,c)=>l==this.active[c])&&(o=this.active);let s=this.open,a=e.effects.some(l=>l.is(y_));s&&e.docChanged&&(s=s.map(e.changes)),e.selection||o.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!D4(o,this.active)||a?s=c_.build(o,t,this.id,s,i,a):s&&s.disabled&&!o.some(l=>l.isPending)&&(s=null),!s&&o.every(l=>!l.isPending)&&o.some(l=>l.hasResult())&&(o=o.map(l=>l.hasResult()?new Hr(l.source,0):l));for(let l of e.effects)l.is(g_)&&(s=s&&s.setSelected(l.value,this.id));return o==this.active&&s==this.open?this:new n(o,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?I4:L4}};function D4(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult();)t++;for(;i<e.length&&!e[i].hasResult();)i++;let r=t==n.length,o=i==e.length;if(r||o)return r==o;if(n[t++].result!=e[i++].result)return!1}}var I4={"aria-autocomplete":"list"},L4={};function fM(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}var B4=[];function gM(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(m_);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 Hr=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=gM(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 o of e.effects)if(o.is(vy))r=new n(r.source,1,o.value);else if(o.is(Hh))r=new n(r.source,0);else if(o.is(y_))for(let s of o.value)s.source==r.source&&(r=s);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Xs(e.state))}},xy=class n extends Hr{constructor(e,t,i,r,o,s){super(e,3,t),this.limit=i,this.result=r,this.from=o,this.to=s}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 o=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1),a=Xs(e.state);if(a>s||!r||t&2&&(Xs(e.startState)==this.from||a<this.limit))return new Hr(this.source,t&4?1:0);let l=e.changes.mapPos(this.limit);return N4(r.validFor,e.state,o,s)?new n(this.source,this.explicit,l,r,o,s):r.update&&(r=r.update(r,o,s,new gy(e.state,a,!1)))?new n(this.source,this.explicit,l,r,r.from,(i=r.to)!==null&&i!==void 0?i:Xs(e.state)):new Hr(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new n(this.source,this.explicit,e.mapPos(this.limit),t,e.mapPos(this.from),e.mapPos(this.to,1)):new Hr(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function N4(n,e,t,i){if(!n)return!1;let r=e.sliceDoc(t,i);return typeof n=="function"?n(r,t,i,e):mM(n,!0).test(r)}var y_=de.define({map(n,e){return n.map(t=>t.map(e))}}),wn=qt.define({create(){return u_.start()},update(n,e){return n.update(e)},provide:n=>[Dh.from(n,e=>e.tooltip),U.contentAttributes.from(n,e=>e.attrs)]});function v_(n,e){let t=e.completion.apply||e.completion.label,i=n.state.field(wn).active.find(r=>r.source==e.source);return i instanceof xy?(typeof t=="string"?n.dispatch({...O4(n.state,t,i.from,i.to),annotations:m_.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}var $4=A4(wn,v_);function my(n,e="option"){return t=>{let i=t.state.field(wn,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(Lt).interactionDelay)return!1;let r=1,o;e=="page"&&(o=Pb(t,i.open.tooltip))&&(r=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=i.open.options,a=i.open.selected>-1?i.open.selected+r*(n?1:-1):n?0:s-1;return a<0?a=e=="page"?0:s-1:a>=s&&(a=e=="page"?s-1:0),t.dispatch({effects:g_.of(a)}),!0}}var j4=n=>{let e=n.state.field(wn,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(Lt).interactionDelay?!1:v_(n,e.open.options[e.open.selected])},r_=n=>n.state.field(wn,!1)?(n.dispatch({effects:vy.of(!0)}),!0):!1,F4=n=>{let e=n.state.field(wn,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Hh.of(null)}),!0)},f_=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},q4=50,V4=1e3,H4=Yt.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(wn).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(wn),t=n.state.facet(Lt);if(!n.selectionSet&&!n.docChanged&&n.startState.field(wn)==e)return;let i=n.transactions.some(o=>{let s=gM(o,t);return s&8||(o.selection||o.docChanged)&&!(s&3)});for(let o=0;o<this.running.length;o++){let s=this.running[o];if(i||s.context.abortOnDocChange&&n.docChanged||s.updates.length+n.transactions.length>q4&&Date.now()-s.time>V4){for(let a of s.context.abortListeners)try{a()}catch(l){It(this.view.state,l)}s.context.abortListeners=null,this.running.splice(o--,1)}else s.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(o=>o.effects.some(s=>s.is(vy)))&&(this.pendingStart=!0);let r=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(o=>o.isPending&&!this.running.some(s=>s.active.source==o.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let o of n.transactions)o.isUserEvent("input.type")?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(wn);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(Lt).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=Xs(e),i=new gy(e,t,n.explicit,this.view),r=new f_(n,i);this.running.push(r),Promise.resolve(n.source(i)).then(o=>{r.context.aborted||(r.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:Hh.of(null)}),It(this.view.state,o)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Lt).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Lt),i=this.view.state.field(wn);for(let r=0;r<this.running.length;r++){let o=this.running[r];if(o.done===void 0)continue;if(this.running.splice(r--,1),o.done){let a=Xs(o.updates.length?o.updates[0].startState:this.view.state),l=Math.min(a,o.done.from+(o.active.explicit?0:1)),c=new xy(o.active.source,o.active.explicit,l,o.done,o.done.from,(n=o.done.to)!==null&&n!==void 0?n:a);for(let u of o.updates)c=c.update(u,t);if(c.hasResult()){e.push(c);continue}}let s=i.active.find(a=>a.source==o.active.source);if(s&&s.isPending)if(o.done==null){let a=new Hr(o.active.source,0);for(let l of o.updates)a=a.update(l,t);a.isPending||e.push(a)}else this.startQuery(s)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:y_.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(wn,!1);if(e&&e.tooltip&&this.view.state.facet(Lt).closeOnBlur){let t=e.open&&Pb(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Hh.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:vy.of(!1)}),20),this.composing=0}}}),z4=typeof navigator=="object"&&/Win/.test(navigator.platform),W4=$r.highest(U.domEventHandlers({keydown(n,e){let t=e.state.field(wn,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(z4&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],r=t.active.find(s=>s.source==i.source),o=i.completion.commitCharacters||r.result.commitCharacters;return o&&o.indexOf(n.key)>-1&&v_(e,i),!1}})),yM=U.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",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\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"}}}),h_=class{constructor(e,t,i,r){this.field=e,this.line=t,this.from=i,this.to=r}},d_=class n{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,Ot.TrackDel),i=e.mapPos(this.to,1,Ot.TrackDel);return t==null||i==null?null:new n(this.field,t,i)}},p_=class n{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],r=[t],o=e.doc.lineAt(t),s=/^\s*/.exec(o.text)[0];for(let l of this.lines){if(i.length){let c=s,u=/^\t*/.exec(l)[0].length;for(let f=0;f<u;f++)c+=e.facet(fc);r.push(t+c.length-u),l=c+l.slice(u)}i.push(l),t+=l.length+1}let a=this.fieldPositions.map(l=>new d_(l.field,r[l.line]+l.from,r[l.line]+l.to));return{text:i,ranges:a}}static parse(e){let t=[],i=[],r=[],o;for(let s of e.split(/\r\n?|\n/)){for(;o=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(s);){let a=o[1]?+o[1]:null,l=o[2]||o[3]||"",c=-1;a===0&&(a=1e9);let u=l.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f<t.length;f++)(a!=null?t[f].seq==a:u&&t[f].name==u)&&(c=f);if(c<0){let f=0;for(;f<t.length&&(a==null||t[f].seq!=null&&t[f].seq<a);)f++;t.splice(f,0,{seq:a,name:u}),c=f;for(let h of r)h.field>=c&&h.field++}for(let f of r)if(f.line==i.length&&f.from>o.index){let h=o[2]?3+(o[1]||"").length:2;f.from-=h,f.to-=h}r.push(new h_(c,i.length,o.index,o.index+u.length)),s=s.slice(0,o.index)+l+s.slice(o.index+o[0].length)}s=s.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(s)}return new n(i,r)}},U4=he.widget({widget:new class extends ai{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Q4=he.mark({class:"cm-snippetField"}),dc=class n{constructor(e,t){this.ranges=e,this.active=t,this.deco=he.set(e.map(i=>(i.from==i.to?U4:Q4).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))}},Wh=de.define({map(n,e){return n&&n.map(e)}}),K4=de.define(),zh=qt.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(Wh))return t.value;if(t.is(K4)&&n)return new dc(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=>U.decorations.from(n,e=>e?e.deco:he.none)});function x_(n,e){return $.create(n.filter(t=>t.field==e).map(t=>$.range(t.from,t.to)))}function G4(n){let e=p_.parse(n);return(t,i,r,o)=>{let{text:s,ranges:a}=e.instantiate(t.state,r),{main:l}=t.state.selection,c={changes:{from:r,to:o==l.from?l.to:o,insert:be.of(s)},scrollIntoView:!0,annotations:i?[m_.of(i),Ft.userEvent.of("input.complete")]:void 0};if(a.length&&(c.selection=x_(a,0)),a.some(u=>u.field>0)){let u=new dc(a,0),f=c.effects=[Wh.of(u)];t.state.field(zh,!1)===void 0&&f.push(de.appendConfig.of([zh,eH,tH,yM]))}t.dispatch(t.state.update(c))}}function vM(n){return({state:e,dispatch:t})=>{let i=e.field(zh,!1);if(!i||n<0&&i.active==0)return!1;let r=i.active+n,o=n>0&&!i.ranges.some(s=>s.field==r+n);return t(e.update({selection:x_(i.ranges,r),effects:Wh.of(o?null:new dc(i.ranges,r)),scrollIntoView:!0})),!0}}var X4=({state:n,dispatch:e})=>n.field(zh,!1)?(e(n.update({effects:Wh.of(null)})),!0):!1,Y4=vM(1),Z4=vM(-1);var J4=[{key:"Tab",run:Y4,shift:Z4},{key:"Escape",run:X4}],hM=H.define({combine(n){return n.length?n[0]:J4}}),eH=$r.highest(sc.compute([hM],n=>n.facet(hM)));function li(n,e){return{...e,apply:G4(n)}}var tH=U.domEventHandlers({mousedown(n,e){let t=e.state.field(zh,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let r=t.ranges.find(o=>o.from<=i&&o.to>=i);return!r||r.field==t.active?!1:(e.dispatch({selection:x_(t.ranges,r.field),effects:Wh.of(t.ranges.some(o=>o.field>r.field)?new dc(t.ranges,r.field):null),scrollIntoView:!0}),!0)}});var by={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Gs=de.define({map(n,e){let t=e.mapPos(n,-1,Ot.TrackAfter);return t==null?void 0:t}}),b_=new class extends ei{};b_.startSide=1;b_.endSide=-1;var xM=qt.define({create(){return Be.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(Gs)&&(n=n.update({add:[b_.range(t.value,t.value+1)]}));return n}});function bM(){return[oH,xM]}var o_="()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D";function nH(n){for(let e=0;e<o_.length;e+=2)if(o_.charCodeAt(e)==n)return o_.charAt(e+1);return E0(n<128?n:n+1)}function iH(n,e){return n.languageDataAt("closeBrackets",e)[0]||by}var rH=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),oH=U.inputHandler.of((n,e,t,i)=>{if((rH?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&Yi(ti(i,0))==1||e!=r.from||t!=r.to)return!1;let o=sH(n.state,i);return o?(n.dispatch(o),!0):!1});function sH(n,e){let t=iH(n,n.selection.main.head),i=t.brackets||by.brackets;for(let r of i){let o=nH(ti(r,0));if(e==r)return o==r?cH(n,r,i.indexOf(r+r+r)>-1,t):aH(n,r,o,t.before||by.before);if(e==o&&_M(n,n.selection.main.from))return lH(n,r,o)}return null}function _M(n,e){let t=!1;return n.field(xM).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function __(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Yi(ti(t,0)))}function aH(n,e,t,i){let r=null,o=n.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:t,from:s.to}],effects:Gs.of(s.to+e.length),range:$.range(s.anchor+e.length,s.head+e.length)};let a=__(n.doc,s.head);return!a||/\s/.test(a)||i.indexOf(a)>-1?{changes:{insert:e+t,from:s.head},effects:Gs.of(s.head+e.length),range:$.cursor(s.head+e.length)}:{range:r=s}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function lH(n,e,t){let i=null,r=n.changeByRange(o=>o.empty&&__(n.doc,o.head)==t?{changes:{from:o.head,to:o.head+t.length,insert:t},range:$.cursor(o.head+t.length)}:i={range:o});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function cH(n,e,t,i){let r=i.stringPrefixes||by.stringPrefixes,o=null,s=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Gs.of(a.to+e.length),range:$.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=__(n.doc,l),u;if(c==e){if(dM(n,l))return{changes:{insert:e+e,from:l},effects:Gs.of(l+e.length),range:$.cursor(l+e.length)};if(_M(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:$.cursor(l+h.length)}}}else{if(t&&n.sliceDoc(l-2*e.length,l)==e+e&&(u=pM(n,l-2*e.length,r))>-1&&dM(n,u))return{changes:{insert:e+e+e+e,from:l},effects:Gs.of(l+e.length),range:$.cursor(l+e.length)};if(n.charCategorizer(l)(c)!=ln.Word&&pM(n,l,r)>-1&&!uH(n,l,e,r))return{changes:{insert:e+e,from:l},effects:Gs.of(l+e.length),range:$.cursor(l+e.length)}}return{range:o=a}});return o?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function dM(n,e){let t=lt(n).resolveInner(e+1);return t.parent&&t.from==e}function uH(n,e,t,i){let r=lt(n).resolveInner(e,-1),o=i.reduce((s,a)=>Math.max(s,a.length),0);for(let s=0;s<5;s++){let a=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+o)),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 pM(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=ln.Word)return e;for(let r of t){let o=e-r.length;if(n.sliceDoc(o,e)==r&&i(n.sliceDoc(o-1,o))!=ln.Word)return o}return-1}function wM(n={}){return[W4,wn,Lt.of(n),H4,hH,yM]}var fH=[{key:"Ctrl-Space",run:r_},{mac:"Alt-`",run:r_},{mac:"Alt-i",run:r_},{key:"Escape",run:F4},{key:"ArrowDown",run:my(!0)},{key:"ArrowUp",run:my(!1)},{key:"PageDown",run:my(!0,"page")},{key:"PageUp",run:my(!1,"page")},{key:"Enter",run:j4}],hH=$r.highest(sc.computeN([Lt],n=>n.facet(Lt).defaultKeymap?[fH]:[]));var dH=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=k_(n.state,t.from);return i.line?pH(n):i.block?gH(n):!1};function O_(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 pH=O_(xH,0);var mH=O_(PM,0);var gH=O_((n,e)=>PM(n,e,vH(e)),0);function k_(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}var Uh=50;function yH(n,{open:e,close:t},i,r){let o=n.sliceDoc(i-Uh,i),s=n.sliceDoc(r,r+Uh),a=/\s*$/.exec(o)[0].length,l=/^\s*/.exec(s)[0].length,c=o.length-a;if(o.slice(c-e.length,c)==e&&s.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*Uh?u=f=n.sliceDoc(i,r):(u=n.sliceDoc(i,i+Uh),f=n.sliceDoc(r-Uh,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 vH(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 o=e.length-1;o>=0&&e[o].to>i.from?e[o].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function PM(n,e,t=e.selection.ranges){let i=t.map(o=>k_(e,o.from).block);if(!i.every(o=>o))return null;let r=t.map((o,s)=>yH(e,i[s],o.from,o.to));if(n!=2&&!r.every(o=>o))return{changes:e.changes(t.map((o,s)=>r[s]?[]:[{from:o.from,insert:i[s].open+" "},{from:o.to,insert:" "+i[s].close}]))};if(n!=1&&r.some(o=>o)){let o=[];for(let s=0,a;s<r.length;s++)if(a=r[s]){let l=i[s],{open:c,close:u}=a;o.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:o}}return null}function xH(n,e,t=e.selection.ranges){let i=[],r=-1;e:for(let{from:o,to:s}of t){let a=i.length,l=1e9,c;for(let u=o;u<=s;){let f=e.doc.lineAt(u);if(c==null&&(c=k_(e,f.from).line,!c))continue e;if(f.from>r&&(o==s||s>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;h<f.text.length&&h<l&&(l=h),i.push({line:f,comment:p,token:c,indent:h,empty:d,single:!1})}u=f.to+1}if(l<1e9)for(let u=a;u<i.length;u++)i[u].indent<i[u].line.text.length&&(i[u].indent=l);i.length==a+1&&(i[a].single=!0)}if(n!=2&&i.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:l,indent:c,empty:u,single:f}of i)(f||!u)&&o.push({from:a.from+c,insert:l+" "});let s=e.changes(o);return{changes:s,selection:e.selection.map(s,1)}}else if(n!=1&&i.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:a,token:l}of i)if(a>=0){let c=s.from+a,u=c+l.length;s.text[u-s.from]==" "&&u++,o.push({from:c,to:u})}return{changes:o}}return null}var CM=Mn.define();var bH=H.define();var Ys=class n{constructor(e,t,i,r,o){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=o}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&&cn.fromJSON(e.changes),[],e.mapped&&Br.fromJSON(e.mapped),e.startSelection&&$.fromJSON(e.startSelection),e.selectionsAfter.map($.fromJSON))}static fromTransaction(e,t){let i=ci;for(let r of e.startState.facet(bH)){let o=r(e);o.length&&(i=i.concat(o))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,ci)}static selection(e){return new n(void 0,ci,void 0,void 0,e)}};function C_(n,e,t,i){let r=e+1>t+20?e-t-1:0,o=n.slice(r,e);return o.push(i),o}function _H(n,e){let t=[],i=!1;return n.iterChangedRanges((r,o)=>t.push(r,o)),e.iterChangedRanges((r,o,s,a)=>{for(let l=0;l<t.length;){let c=t[l++],u=t[l++];a>=c&&s<=u&&(i=!0)}}),i}function wH(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function DM(n,e){return n.length?e.length?n.concat(e):n:e}var ci=[],CH=200;function EH(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-CH));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),C_(n,n.length-1,1e9,t.setSelAfter(i)))}else return[Ys.selection([e])]}function SH(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 w_(n,e){if(!n.length)return n;let t=n.length,i=ci;for(;t;){let r=OH(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let o=n.slice(0,t);return o[t-1]=r,o}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[Ys.selection(i)]:ci}function OH(n,e,t){let i=DM(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):ci,t);if(!n.changes)return Ys.selection(i);let r=n.changes.map(e),o=e.mapDesc(n.changes,!0),s=n.mapped?n.mapped.composeDesc(o):o;return new Ys(r,de.mapEffects(n.effects,e),s,n.startSelection.map(o),i)}var kH=/^(input\.type|delete)($|\.)/,wy=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,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!i||kH.test(i))&&(!a.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(o,_H(a.changes,e.changes))||i=="input.type.compose")?s=C_(s,s.length-1,r.minDepth,new Ys(e.changes.compose(a.changes),DM(de.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,ci)):s=C_(s,s.length,r.minDepth,e),new n(s,ci,t,i)}addSelection(e,t,i,r){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:ci;return o.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&wH(o[o.length-1],e)?this:new n(EH(this.done,e),this.undone,t,i)}addMapping(e){return new n(w_(this.done,e),w_(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let o=r[r.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):t.selection);if(i&&o.selectionsAfter.length)return t.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:CM.of({side:e,rest:SH(r),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let a=r.length==1?ci:r.slice(0,r.length-1);return o.mapped&&(a=w_(a,o.mapped)),t.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:CM.of({side:e,rest:a,selection:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};wy.empty=new wy(ci,ci);function mc(n,e){return $.create(n.ranges.map(e),n.mainIndex)}function Si(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Oi({state:n,dispatch:e},t){let i=mc(n.selection,t);return i.eq(n.selection,!0)?!1:(e(Si(n,i)),!0)}function Cy(n,e){return $.cursor(e?n.to:n.from)}function IM(n,e){return Oi(n,t=>t.empty?n.moveByChar(t,e):Cy(t,e))}function Jt(n){return n.textDirectionAt(n.state.selection.main.head)==We.LTR}var LM=n=>IM(n,!Jt(n)),BM=n=>IM(n,Jt(n));function NM(n,e){return Oi(n,t=>t.empty?n.moveByGroup(t,e):Cy(t,e))}var RH=n=>NM(n,!Jt(n)),TH=n=>NM(n,Jt(n));var Qge=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function AH(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 Ey(n,e,t){let i=lt(n).resolveInner(e.head),r=t?ce.closedBy:ce.openedBy;for(let l=e.head;;){let c=t?i.childAfter(l):i.childBefore(l);if(!c)break;AH(n,c,r)?i=c:l=t?c.to:c.from}let o=i.type.prop(r),s,a;return o&&(s=t?Ei(n,i.from,1):Ei(n,i.to,-1))&&s.matched?a=t?s.end.to:s.end.from:a=t?i.to:i.from,$.cursor(a,t?-1:1)}var MH=n=>Oi(n,e=>Ey(n.state,e,!Jt(n))),PH=n=>Oi(n,e=>Ey(n.state,e,Jt(n)));function $M(n,e){return Oi(n,t=>{if(!t.empty)return Cy(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var jM=n=>$M(n,!1),FM=n=>$M(n,!0);function qM(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let o of n.state.facet(U.scrollMargins)){let s=o(n);s!=null&&s.top&&(t=Math.max(s==null?void 0:s.top,t)),s!=null&&s.bottom&&(i=Math.max(s==null?void 0:s.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function VM(n,e){let t=qM(n),{state:i}=n,r=mc(i.selection,s=>s.empty?n.moveVertically(s,e,t.height):Cy(s,e));if(r.eq(i.selection))return!1;let o;if(t.selfScroll){let s=n.coordsAtPos(i.selection.main.head),a=n.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;s&&s.top>l&&s.bottom<c&&(o=U.scrollIntoView(r.main.head,{y:"start",yMargin:s.top-l}))}return n.dispatch(Si(i,r),{effects:o}),!0}var EM=n=>VM(n,!1),E_=n=>VM(n,!0);function Vo(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 o=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;o&&e.head!=i.from+o&&(r=$.cursor(i.from+o))}return r}var DH=n=>Oi(n,e=>Vo(n,e,!0)),IH=n=>Oi(n,e=>Vo(n,e,!1)),LH=n=>Oi(n,e=>Vo(n,e,!Jt(n))),BH=n=>Oi(n,e=>Vo(n,e,Jt(n))),NH=n=>Oi(n,e=>$.cursor(n.lineBlockAt(e.head).from,1)),$H=n=>Oi(n,e=>$.cursor(n.lineBlockAt(e.head).to,-1));function jH(n,e,t){let i=!1,r=mc(n.selection,o=>{let s=Ei(n,o.head,-1)||Ei(n,o.head,1)||o.head>0&&Ei(n,o.head-1,1)||o.head<n.doc.length&&Ei(n,o.head+1,-1);if(!s||!s.end)return o;i=!0;let a=s.start.from==o.head?s.end.to:s.end.from;return t?$.range(o.anchor,a):$.cursor(a)});return i?(e(Si(n,r)),!0):!1}var FH=({state:n,dispatch:e})=>jH(n,e,!1);function ui(n,e){let t=mc(n.state.selection,i=>{let r=e(i);return $.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return t.eq(n.state.selection)?!1:(n.dispatch(Si(n.state,t)),!0)}function HM(n,e){return ui(n,t=>n.moveByChar(t,e))}var zM=n=>HM(n,!Jt(n)),WM=n=>HM(n,Jt(n));function UM(n,e){return ui(n,t=>n.moveByGroup(t,e))}var qH=n=>UM(n,!Jt(n)),VH=n=>UM(n,Jt(n));var HH=n=>ui(n,e=>Ey(n.state,e,!Jt(n))),zH=n=>ui(n,e=>Ey(n.state,e,Jt(n)));function QM(n,e){return ui(n,t=>n.moveVertically(t,e))}var KM=n=>QM(n,!1),GM=n=>QM(n,!0);function XM(n,e){return ui(n,t=>n.moveVertically(t,e,qM(n).height))}var SM=n=>XM(n,!1),OM=n=>XM(n,!0),WH=n=>ui(n,e=>Vo(n,e,!0)),UH=n=>ui(n,e=>Vo(n,e,!1)),QH=n=>ui(n,e=>Vo(n,e,!Jt(n))),KH=n=>ui(n,e=>Vo(n,e,Jt(n))),GH=n=>ui(n,e=>$.cursor(n.lineBlockAt(e.head).from)),XH=n=>ui(n,e=>$.cursor(n.lineBlockAt(e.head).to)),kM=({state:n,dispatch:e})=>(e(Si(n,{anchor:0})),!0),RM=({state:n,dispatch:e})=>(e(Si(n,{anchor:n.doc.length})),!0),TM=({state:n,dispatch:e})=>(e(Si(n,{anchor:n.selection.main.anchor,head:0})),!0),AM=({state:n,dispatch:e})=>(e(Si(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),YH=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),ZH=({state:n,dispatch:e})=>{let t=Sy(n).map(({from:i,to:r})=>$.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:$.create(t),userEvent:"select"})),!0},JH=({state:n,dispatch:e})=>{let t=mc(n.selection,i=>{let r=lt(n),o=r.resolveStack(i.from,1);if(i.empty){let s=r.resolveStack(i.from,-1);s.node.from>=o.node.from&&s.node.to<=o.node.to&&(o=s)}for(let s=o;s;s=s.next){let{node:a}=s;if((a.from<i.from&&a.to>=i.to||a.to>i.to&&a.from<=i.from)&&s.next)return $.range(a.to,a.from)}return i});return t.eq(n.selection)?!1:(e(Si(n,t)),!0)};function YM(n,e){let{state:t}=n,i=t.selection,r=t.selection.ranges.slice();for(let o of t.selection.ranges){let s=t.doc.lineAt(o.head);if(e?s.to<n.state.doc.length:s.from>0)for(let a=o;;){let l=n.moveVertically(a,e);if(l.head<s.from||l.head>s.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(Si(t,$.create(r,r.length-1))),!0)}var e6=n=>YM(n,!1),t6=n=>YM(n,!0),n6=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=$.create([t.main]):t.main.empty||(i=$.create([$.cursor(t.main.head)])),i?(e(Si(n,i)),!0):!1};function Qh(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let l=e(o);l<s?(t="delete.backward",l=_y(n,l,!1)):l>s&&(t="delete.forward",l=_y(n,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=_y(n,s,!1),a=_y(n,a,!0);return s==a?{range:o}:{changes:{from:s,to:a},range:$.cursor(s,s<o.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?U.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function _y(n,e,t){if(n instanceof U)for(let i of n.state.facet(U.atomicRanges).map(r=>r(n)))i.between(e,e,(r,o)=>{r<e&&o>e&&(e=t?o:r)});return e}var ZM=(n,e,t)=>Qh(n,i=>{let r=i.from,{state:o}=n,s=o.doc.lineAt(r),a,l;if(t&&!e&&r>s.from&&r<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,r-s.from))){if(a[a.length-1]==" ")return r-1;let c=$s(a,o.tabSize),u=c%Vh(o)||Vh(o);for(let f=0;f<u&&a[a.length-1-f]==" ";f++)r--;l=r}else l=Dt(s.text,r-s.from,e,e)+s.from,l==r&&s.number!=(e?o.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,r-s.from))&&(l=Dt(s.text,l-s.from,!1,!1)+s.from);return l}),S_=n=>ZM(n,!1,!0);var JM=n=>ZM(n,!0,!1),eP=(n,e)=>Qh(n,t=>{let i=t.head,{state:r}=n,o=r.doc.lineAt(i),s=r.charCategorizer(i);for(let a=null;;){if(i==(e?o.to:o.from)){i==t.head&&o.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let l=Dt(o.text,i-o.from,e)+o.from,c=o.text.slice(Math.min(i,l)-o.from,Math.max(i,l)-o.from),u=s(c);if(a!=null&&u!=a)break;(c!=" "||i!=t.head)&&(a=u),i=l}return i}),tP=n=>eP(n,!1),i6=n=>eP(n,!0);var r6=n=>Qh(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var o6=n=>Qh(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),s6=n=>Qh(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var a6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:be.of(["",""])},range:$.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},l6=({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,o=n.doc.lineAt(r),s=r==o.from?r-1:Dt(o.text,r-o.from,!1)+o.from,a=r==o.to?r+1:Dt(o.text,r-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:n.doc.slice(r,a).append(n.doc.slice(s,r))},range:$.cursor(a)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Sy(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),o=n.doc.lineAt(i.to);if(!i.empty&&i.to==o.from&&(o=n.doc.lineAt(i.to-1)),t>=r.number){let s=e[e.length-1];s.to=o.to,s.ranges.push(i)}else e.push({from:r.from,to:o.to,ranges:[i]});t=o.number+1}return e}function nP(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let o of Sy(n)){if(t?o.to==n.doc.length:o.from==0)continue;let s=n.doc.lineAt(t?o.to+1:o.from-1),a=s.length+1;if(t){i.push({from:o.to,to:s.to},{from:o.from,insert:s.text+n.lineBreak});for(let l of o.ranges)r.push($.range(Math.min(n.doc.length,l.anchor+a),Math.min(n.doc.length,l.head+a)))}else{i.push({from:s.from,to:o.from},{from:o.to,insert:n.lineBreak+s.text});for(let l of o.ranges)r.push($.range(l.anchor-a,l.head-a))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:$.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var c6=({state:n,dispatch:e})=>nP(n,e,!1),u6=({state:n,dispatch:e})=>nP(n,e,!0);function iP(n,e,t){if(n.readOnly)return!1;let i=[];for(let o of Sy(n))t?i.push({from:o.from,insert:n.doc.slice(o.from,o.to)+n.lineBreak}):i.push({from:o.to,insert:n.lineBreak+n.doc.slice(o.from,o.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 f6=({state:n,dispatch:e})=>iP(n,e,!1),h6=({state:n,dispatch:e})=>iP(n,e,!0),d6=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Sy(e).map(({from:r,to:o})=>(r>0?r--:o<e.doc.length&&o++,{from:r,to:o}))),i=mc(e.selection,r=>{let o;if(n.lineWrapping){let s=n.lineBlockAt(r.head),a=n.coordsAtPos(r.head,r.assoc||1);a&&(o=s.bottom+n.documentTop-a.bottom+n.defaultLineHeight/2)}return n.moveVertically(r,!0,o)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function p6(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=lt(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),o;return i&&r&&i.to<=e&&r.from>=e&&(o=i.type.prop(ce.closedBy))&&o.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 MM=rP(!1),m6=rP(!0);function rP(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:o,to:s}=r,a=e.doc.lineAt(o),l=!n&&o==s&&p6(e,o);n&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new Ks(e,{simulateBreak:o,simulateDoubleBreak:!!l}),u=hy(c,o);for(u==null&&(u=$s(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;l?{from:o,to:s}=l:o>a.from&&o<a.from+100&&!/\S/.test(a.text.slice(0,o))&&(o=a.from);let f=["",hc(e,u)];return l&&f.push(hc(e,c.lineIndent(a.from,-1))),{changes:{from:o,to:s,insert:be.of(f)},range:$.cursor(o+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function R_(n,e){let t=-1;return n.changeByRange(i=>{let r=[];for(let s=i.from;s<=i.to;){let a=n.doc.lineAt(s);a.number>t&&(i.empty||i.to>a.from)&&(e(a,r,i),t=a.number),s=a.to+1}let o=n.changes(r);return{changes:r,range:$.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}})}var g6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Ks(n,{overrideIndentation:o=>{let s=t[o];return s==null?-1:s}}),r=R_(n,(o,s,a)=>{let l=hy(i,o.from);if(l==null)return;/\S/.test(o.text)||(l=0);let c=/^\s*/.exec(o.text)[0],u=hc(n,l);(c!=u||a.from<o.from+c.length)&&(t[o.from]=l,s.push({from:o.from,to:o.from+c.length,insert:u}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},y6=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(R_(n,(t,i)=>{i.push({from:t.from,insert:n.facet(fc)})}),{userEvent:"input.indent"})),!0),v6=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(R_(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let o=$s(r,n.tabSize),s=0,a=hc(n,Math.max(0,o-Vh(n)));for(;s<r.length&&s<a.length&&r.charCodeAt(s)==a.charCodeAt(s);)s++;i.push({from:t.from+s,to:t.from+r.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0),x6=n=>(n.setTabFocusMode(),!0);var b6=[{key:"Ctrl-b",run:LM,shift:zM,preventDefault:!0},{key:"Ctrl-f",run:BM,shift:WM},{key:"Ctrl-p",run:jM,shift:KM},{key:"Ctrl-n",run:FM,shift:GM},{key:"Ctrl-a",run:NH,shift:GH},{key:"Ctrl-e",run:$H,shift:XH},{key:"Ctrl-d",run:JM},{key:"Ctrl-h",run:S_},{key:"Ctrl-k",run:r6},{key:"Ctrl-Alt-h",run:tP},{key:"Ctrl-o",run:a6},{key:"Ctrl-t",run:l6},{key:"Ctrl-v",run:E_}],_6=[{key:"ArrowLeft",run:LM,shift:zM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:RH,shift:qH,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:LH,shift:QH,preventDefault:!0},{key:"ArrowRight",run:BM,shift:WM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:TH,shift:VH,preventDefault:!0},{mac:"Cmd-ArrowRight",run:BH,shift:KH,preventDefault:!0},{key:"ArrowUp",run:jM,shift:KM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kM,shift:TM},{mac:"Ctrl-ArrowUp",run:EM,shift:SM},{key:"ArrowDown",run:FM,shift:GM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:RM,shift:AM},{mac:"Ctrl-ArrowDown",run:E_,shift:OM},{key:"PageUp",run:EM,shift:SM},{key:"PageDown",run:E_,shift:OM},{key:"Home",run:IH,shift:UH,preventDefault:!0},{key:"Mod-Home",run:kM,shift:TM},{key:"End",run:DH,shift:WH,preventDefault:!0},{key:"Mod-End",run:RM,shift:AM},{key:"Enter",run:MM,shift:MM},{key:"Mod-a",run:YH},{key:"Backspace",run:S_,shift:S_,preventDefault:!0},{key:"Delete",run:JM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:tP,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:i6,preventDefault:!0},{mac:"Mod-Backspace",run:o6,preventDefault:!0},{mac:"Mod-Delete",run:s6,preventDefault:!0}].concat(b6.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),oP=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:MH,shift:HH},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:PH,shift:zH},{key:"Alt-ArrowUp",run:c6},{key:"Shift-Alt-ArrowUp",run:f6},{key:"Alt-ArrowDown",run:u6},{key:"Shift-Alt-ArrowDown",run:h6},{key:"Mod-Alt-ArrowUp",run:e6},{key:"Mod-Alt-ArrowDown",run:t6},{key:"Escape",run:n6},{key:"Mod-Enter",run:m6},{key:"Alt-l",mac:"Ctrl-l",run:ZH},{key:"Mod-i",run:JH,preventDefault:!0},{key:"Mod-[",run:v6},{key:"Mod-]",run:y6},{key:"Mod-Alt-\\",run:g6},{key:"Shift-Mod-k",run:d6},{key:"Shift-Mod-\\",run:FH},{key:"Mod-/",run:dH},{key:"Alt-A",run:mH},{key:"Ctrl-m",mac:"Shift-Alt-m",run:x6}].concat(_6);var ky=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},Zs=class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=i.facet(or).markerFilter;r&&(e=r(e,i));let o=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),s=new Nr,a=[],l=0,c=i.doc.iter(),u=0,f=i.doc.length;for(let d=0;;){let p=d==o.length?null:o[d];if(!p&&!a.length)break;let m,g;if(a.length)m=l,g=a.reduce((v,x)=>Math.min(v,x.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;g=p.to,a.push(p),d++}for(;d<o.length;){let v=o[d];if(v.from==m&&(v.to>v.from||v.to==m))a.push(v),d++,g=Math.min(v.to,g);else{g=Math.min(v.from,g);break}}g=Math.min(g,f);let b=!1;if(a.some(v=>v.from==m&&(v.to==g||g==f))&&(b=m==g,!b&&g-m<10)){let v=m-(u+c.value.length);v>0&&(c.next(v),u=m);for(let x=m;;){if(x>=g){b=!0;break}if(!c.lineBreak&&u+c.value.length>x)break;x=u+c.value.length,u+=c.value.length,c.next()}}let _=D6(a);if(b)s.add(m,m,he.widget({widget:new T_(_),diagnostics:a.slice()}));else{let v=a.reduce((x,C)=>C.markClass?x+" "+C.markClass:x,"");s.add(m,g,he.mark({class:"cm-lintRange cm-lintRange-"+_+v,diagnostics:a.slice(),inclusiveEnd:a.some(x=>x.to>g)}))}if(l=g,l==f)break;for(let v=0;v<a.length;v++)a[v].to<=l&&a.splice(v--,1)}let h=s.finish();return new n(h,t,gc(h))}};function gc(n,e=null,t=0){let i=null;return n.between(t,1e9,(r,o,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(!i)i=new ky(r,o,e||s.diagnostics[0]);else{if(s.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new ky(i.from,o,i.diagnostic)}}),i}function w6(n,e){let t=e.pos,i=e.end||t,r=n.state.facet(or).hideOn(n,t,i);if(r!=null)return r;let o=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(s=>s.is(Kh))||n.changes.touchesRange(o.from,Math.max(o.to,i)))}function C6(n,e){return n.field(ki,!1)?e:e.concat(de.appendConfig.of(dP))}function E6(n,e){return{effects:C6(n,[Kh.of(e)])}}var Kh=de.define(),lP=de.define(),cP=de.define(),ki=qt.define({create(){return new Zs(he.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 o=e.changes.mapPos(n.selected.from,1);i=gc(t,n.selected.diagnostic,o)||gc(t,null,o)}!t.size&&r&&e.state.facet(or).autoPanel&&(r=null),n=new Zs(t,r,i)}for(let t of e.effects)if(t.is(Kh)){let i=e.state.facet(or).autoPanel?t.value.length?Ty.open:null:n.panel;n=Zs.init(t.value,i,e.state)}else t.is(lP)?n=new Zs(n.diagnostics,t.value?Ty.open:null,n.selected):t.is(cP)&&(n=new Zs(n.diagnostics,n.panel,t.value));return n},provide:n=>[Zg.from(n,e=>e.panel),U.decorations.from(n,e=>e.diagnostics)]});var S6=he.mark({class:"cm-lintRange cm-lintRange-active"});function O6(n,e,t){let{diagnostics:i}=n.state.field(ki),r,o=-1,s=-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)&&(e<c||t<0)))return r=u.diagnostics,o=l,s=c,!1});let a=n.state.facet(or).tooltipFilter;return r&&a&&(r=a(r,n.state)),r?{pos:o,end:s,above:!0,create(){return{dom:k6(n,r)}}}:null}function k6(n,e){return Pn("ul",{class:"cm-tooltip-lint"},e.map(t=>hP(n,t,!1)))}var sP=n=>{let e=n.state.field(ki,!1);return!e||!e.panel?!1:(n.dispatch({effects:lP.of(!1)}),!0)};var R6=Yt.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(or);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(n<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(or);t.length&&T6(t.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(E6(this.view.state,i.reduce((r,o)=>r.concat(o))))},i=>{It(this.view.state,i)})}}update(n){let e=n.state.facet(or);(n.docChanged||e!=n.startState.facet(or)||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 T6(n,e,t){let i=[],r=-1;for(let o of n)o.then(s=>{i.push(s),clearTimeout(r),i.length==n.length?e(i):r=setTimeout(()=>e(i),200)},t)}var or=H.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...Io(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:aP,tooltipFilter:aP,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,r,o)=>e(i,r,o)||t(i,r,o):e:t,autoPanel:(e,t)=>e||t})}}});function aP(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function uP(n,e={}){return[or.of({source:n,config:e}),R6,dP]}function fP(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let r=t[i];if(/[a-zA-Z]/.test(r)&&!e.some(o=>o.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function hP(n,e,t){var i;let r=t?fP(e.actions):[];return Pn("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Pn("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((o,s)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let p=gc(n.state.field(ki).diagnostics,e);p&&o.apply(n,p.from,p.to)},{name:c}=o,u=r[s]?c.indexOf(r[s]):-1,f=u<0?c:[c.slice(0,u),Pn("u",c.slice(u,u+1)),c.slice(u+1)],h=o.markClass?" "+o.markClass:"";return Pn("button",{type:"button",class:"cm-diagnosticAction"+h,onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${r[s]})"`}.`},f)}),e.source&&Pn("div",{class:"cm-diagnosticSource"},e.source))}var T_=class extends ai{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Pn("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},Ry=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=hP(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Ty=class n{constructor(e){this.view=e,this.items=[];let t=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)sP(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:o}=this.items[this.selectedIndex],s=fP(o.actions);for(let a=0;a<s.length;a++)if(s[a].toUpperCase().charCodeAt(0)==r.keyCode){let l=gc(this.view.state.field(ki).diagnostics,o);l&&o.actions[a].apply(e,l.from,l.to)}}else return;r.preventDefault()}},i=r=>{for(let o=0;o<this.items.length;o++)this.items[o].dom.contains(r.target)&&this.moveSelection(o)};this.list=Pn("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=Pn("div",{class:"cm-panel-lint"},this.list,Pn("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>sP(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(ki).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(ki),i=0,r=!1,o=null,s=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:c})=>{for(let u of c.diagnostics){if(s.has(u))continue;s.add(u);let f=-1,h;for(let d=i;d<this.items.length;d++)if(this.items[d].diagnostic==u){f=d;break}f<0?(h=new Ry(this.view,u),this.items.splice(i,0,h),r=!0):(h=this.items[f],f>i&&(this.items.splice(i,f-i),r=!0)),t&&h.diagnostic==t.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),o=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Ry(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/c:a.bottom>l.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(ki),i=gc(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:cP.of(i)})}static open(e){return new n(e)}};function A6(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function Oy(n){return A6(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var M6=U.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:Oy("#f11")},".cm-lintRange-warning":{backgroundImage:Oy("orange")},".cm-lintRange-info":{backgroundImage:Oy("#999")},".cm-lintRange-hint":{backgroundImage:Oy("#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 P6(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function D6(n){let e="hint",t=1;for(let i of n){let r=P6(i.severity);r>t&&(t=r,e=i.severity)}return e}var I6=IA(O6,{hideOn:w6}),dP=[ki,U.decorations.compute([ki],n=>{let{selected:e,panel:t}=n.field(ki);return!e||!t||e.from==e.to?he.none:he.set([S6.range(e.from,e.to)])}),I6,M6];function pP(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 P_=class n{constructor(e,t,i,r,o,s,a,l,c,u=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=r,this.pos=o,this.score=s,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 Ay(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:o}=this.p,s=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=o.dynamicPrecedence(r);if(a&&(this.score+=a),i==0){r<o.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(o.getGoto(this.state,r,!0),this.reducePos),r<o.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(r,this.reducePos);return}let l=this.stack.length-(i-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from;r<o.minRepeatTerm&&c==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let u=this.reducePos-c;u>=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.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let f=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-f;if(r<o.minRepeatTerm||e&131072){let d=o.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,c,d,h+4,!0)}if(e&262144)this.state=this.stack[l];else{let d=this.stack[l-3];this.state=o.getGoto(d,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,c)}storeNode(e,t,i,r=4,o=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this.buffer.length;if(s>0&&this.buffer[s-4]==0&&this.buffer[s-1]>-1){if(t==i)return;if(this.buffer[s-2]>=t){this.buffer[s-2]=i;return}}}if(!o||this.pos==i)this.buffer.push(e,t,i,r);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let a=!1;for(let l=s;l>0&&this.buffer[l-2]>i;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;s>0&&this.buffer[s-2]>i;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,r>4&&(r-=4)}this.buffer[s]=e,this.buffer[s+1]=t,this.buffer[s+2]=i,this.buffer[s+3]=r}}shift(e,t,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let o=e,{parser:s}=this.p;this.pos=r;let a=s.stateFlag(o,1);!a&&(r>i||t<=s.maxNode)&&(this.reducePos=r),this.pushState(o,a?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=s.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 D_(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 o=0,s;o<t.length;o+=2)(s=t[o+1])!=this.state&&this.p.parser.hasAction(s,e)&&r.push(t[o],s);if(this.stack.length<120)for(let o=0;r.length<8&&o<t.length;o+=2){let s=t[o+1];r.some((a,l)=>l&1&&a==s)||r.push(t[o],s)}t=r}let i=[];for(let r=0;r<t.length&&i.length<4;r+=2){let o=t[r+1];if(o==this.state)continue;let s=this.split();s.pushState(o,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(t[r],this.pos),s.reducePos=this.pos,s.score-=200,i.push(s)}return i}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let i=t>>19,r=t&65535,o=this.stack.length-i*3;if(o<0||e.getGoto(this.stack[o],r,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;t=s}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,o)=>{if(!t.includes(r))return t.push(r),e.allActions(r,s=>{if(!(s&393216))if(s&65536){let a=(s>>19)-o;if(a>1){let l=s&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(s,o+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;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new Ay(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},Ay=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},D_=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}},I_=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 Gh(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,r=0;i<n.length;){let o=0;for(;;){let s=n.charCodeAt(i++),a=!1;if(s==126){o=65535;break}s>=92&&s--,s>=34&&s--;let l=s-32;if(l>=46&&(l-=46,a=!0),o+=l,a)break;o*=46}t?t[r++]=o:t=new e(o)}return t}var yc=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},mP=new yc,L_=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=mP,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,o=this.pos+e;for(;o<i.from;){if(!r)return null;let s=this.ranges[--r];o-=i.from-s.to,i=s}for(;t<0?o>i.to:o>=i.to;){if(r==this.ranges.length-1)return null;let s=this.ranges[++r];o+=s.from-i.to,i=s}return o}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,r;if(t>=0&&t<this.chunk.length)i=this.pos+e,r=this.chunk.charCodeAt(t);else{let o=this.resolveOffset(e,1);if(o==null)return-1;if(i=o,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let s=this.rangeIndex,a=this.range;for(;a.to<=i;)a=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>a.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.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=mP,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let 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}},Ho=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;bP(this.data,e,t,this.id,i.data,i.tokenPrecTable)}};Ho.prototype.contextual=Ho.prototype.fallback=Ho.prototype.extend=!1;var B_=class{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?Gh(e):e}token(e,t){let i=e.pos,r=0;for(;;){let o=e.next<0,s=e.resolveOffset(1,1);if(bP(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(o||r++,s==null)break;e.reset(s,e.token)}r&&(e.reset(i,e.token),e.acceptToken(this.elseToken,r))}};B_.prototype.contextual=Ho.prototype.fallback=Ho.prototype.extend=!1;var vc=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function bP(n,e,t,i,r,o){let s=0,a=1<<i,{dialect:l}=t.p.parser;e:for(;(a&n[s])!=0;){let c=n[s+1];for(let d=s+3;d<c;d+=2)if((n[d+1]&a)>0){let p=n[d];if(l.allows(p)&&(e.token.value==-1||e.token.value==p||B6(p,e.token.value,r,o))){e.acceptToken(p);break}}let u=e.next,f=0,h=n[s+2];if(e.next<0&&h>f&&n[c+h*3-3]==65535){s=n[c+h*3-1];continue e}for(;f<h;){let d=f+h>>1,p=c+d+(d<<1),m=n[p],g=n[p+1]||65536;if(u<m)h=d;else if(u>=g)f=d+1;else{s=n[p+2],e.advance();continue e}}break}}function gP(n,e,t){for(let i=e,r;(r=n[i])!=65535;i++)if(r==t)return i-e;return-1}function B6(n,e,t,i){let r=gP(t,i,e);return r<0||gP(t,i,n)<r}var Ln=typeof process!="undefined"&&process.env&&/\bparse\b/.test(process.env.LOG),A_=null;function yP(n,e,t){let i=n.cursor(rt.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.to<e:i.from>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 N_=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?yP(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?yP(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let i=this.trees[t],r=this.index[t];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let o=i.children[r],s=this.start[t]+i.positions[r];if(s>e)return this.nextStart=s,null;if(o instanceof gt){if(s==e){if(s<this.safeFrom)return null;let a=s+o.length;if(a<=this.safeTo){let l=o.prop(ce.lookAhead);if(!l||a+l<this.fragment.to)return o}}this.index[t]++,s+o.length>=Math.max(this.safeFrom,e)&&(this.trees.push(o),this.start.push(s),this.index.push(0))}else this.index[t]++,this.nextStart=s+o.length}}},$_=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new yc)}getActions(e){let t=0,i=null,{parser:r}=e.p,{tokenizers:o}=r,s=r.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<o.length;c++){if((1<<c&s)==0)continue;let u=o[c],f=this.tokens[c];if(!(i&&!u.fallback)&&((u.contextual||f.start!=e.pos||f.mask!=s||f.context!=a)&&(this.updateCachedToken(f,u,e),f.mask=s,f.context=a),f.lookAhead>f.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 yc,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 yc,{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:o}=i.p;for(let s=0;s<o.specialized.length;s++)if(o.specialized[s]==e.value){let a=o.specializers[s](this.stream.read(e.start,e.end),i);if(a>=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 o=0;o<r;o+=3)if(this.actions[o]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=i,r}addActions(e,t,i,r){let{state:o}=e,{parser:s}=e.p,{data:a}=s;for(let l=0;l<2;l++)for(let c=s.stateSlot(o,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=zr(a,c+2);else{r==0&&a[c+1]==2&&(r=this.putAction(zr(a,c+2),t,i,r));break}a[c]==t&&(r=this.putAction(zr(a,c+1),t,i,r))}return r}},j_=class{constructor(e,t,i,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new L_(t,r),this.tokens=new $_(e,this.stream),this.topTerm=e.top[1];let{from:o}=r[0];this.stacks=[P_.start(this,e.top[0],o)],this.fragments=i.length&&this.stream.end-o>e.bufferLength*4?new N_(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],r,o;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let a=e[s];for(;;){if(this.tokens.mainToken=null,a.pos>t)i.push(a);else{if(this.advanceStack(a,i,e))continue;{r||(r=[],o=[]),r.push(a);let l=this.tokens.getMainToken(a);o.push(l.value,l.end)}}break}}if(!i.length){let s=r&&N6(r);if(s)return Ln&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw Ln&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let s=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,o,i);if(s)return Ln&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(i.length>s)for(i.sort((a,l)=>l.score-a.score);i.length>s;)i.pop();i.some(a=>a.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let s=0;s<i.length-1;s++){let a=i[s];for(let l=s+1;l<i.length;l++){let c=i[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)i.splice(l--,1);else{i.splice(s--,1);continue e}}}i.length>12&&(i.sort((s,a)=>a.score-s.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let s=1;s<i.length;s++)i[s].pos<this.minStackPos&&(this.minStackPos=i[s].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let r=e.pos,{parser:o}=this,s=Ln?this.stackID(e)+" -> ":"";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?o.getGoto(e.state,f.type.id):-1;if(h>-1&&f.length&&(!c||(f.prop(ce.contextHash)||0)==u))return e.useNode(f,h),Ln&&console.log(s+this.stackID(e)+` (via reuse of ${o.getName(f.type.id)})`),!0;if(!(f instanceof gt)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof gt&&f.positions[0]==0)f=d;else break}}let a=o.stateSlot(e.state,4);if(a>0)return e.reduce(a),Ln&&console.log(s+this.stackID(e)+` (via always-reduce ${o.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;c<l.length;){let u=l[c++],f=l[c++],h=l[c++],d=c==l.length||!i,p=d?e:e.split(),m=this.tokens.mainToken;if(p.apply(u,f,m?m.start:p.pos,h),Ln&&console.log(s+this.stackID(p)+` (via ${(u&65536)==0?"shift":`reduce of ${o.getName(u&65535)}`} for ${o.getName(f)} @ ${r}${p==e?"":", split"})`),d)return!0;p.pos>r?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 vP(e,t),!0}}runRecovery(e,t,i){let r=null,o=!1;for(let s=0;s<e.length;s++){let a=e[s],l=t[s<<1],c=t[(s<<1)+1],u=Ln?this.stackID(a)+" -> ":"";if(a.deadEnd&&(o||(o=!0,a.restart(),Ln&&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()&&(Ln&&console.log(h+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)Ln&&(h=this.stackID(f)+" -> ");for(let d of a.recoverByInsert(l))Ln&&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),Ln&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),vP(a,i)):(!r||r.score<f.score)&&(r=f)}return r}stackToTree(e){return e.close(),gt.build({buffer:I_.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(A_||(A_=new WeakMap)).get(e);return t||A_.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function vP(n,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==n.pos&&i.sameState(n)){e[t].score<n.score&&(e[t]=n);return}}e.push(n)}var F_=class{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}},M_=n=>n,My=class{constructor(e){this.start=e.start,this.shift=e.shift||M_,this.reduce=e.reduce||M_,this.reuse=e.reuse||M_,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},Py=class n extends ac{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;a<e.repeatNodeCount;a++)t.push("");let i=Object.keys(e.topRules).map(a=>e.topRules[a][1]),r=[];for(let a=0;a<t.length;a++)r.push([]);function o(a,l,c){r[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=ce[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)o(u,l,a[c++]);else{let f=a[c+-u];for(let h=-u;h>0;h--)o(a[c++],l,f);c++}}}this.nodeSet=new Lh(t.map((a,l)=>Zt.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 s=Gh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(xP),this.states=Gh(e.states,Uint32Array),this.data=Gh(e.stateData),this.goto=Gh(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Ho(s,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 j_(this,e,t,i);for(let o of this.wrappers)r=o(r,e,t,i);return r}getGoto(e,t,i=!1){let r=this.goto;if(t>=r[0])return-1;for(let o=r[t+1];;){let s=r[o++],a=s&1,l=r[o++];if(a&&i)return l;for(let c=o+(s>>1);o<c;o++)if(r[o]==e)return l;if(a)return-1}}hasAction(e,t){let i=this.data;for(let r=0;r<2;r++)for(let o=this.stateSlot(e,r?2:1),s;;o+=3){if((s=i[o])==65535)if(i[o+1]==1)s=i[o=zr(i,o+2)];else{if(i[o+1]==2)return zr(i,o+2);break}if(s==t||s==0)return zr(i,o+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}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 o=this.stateSlot(e,1);r==null;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=zr(this.data,o+2);else break;r=t(zr(this.data,o+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=zr(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];t.some((o,s)=>s&1&&o==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(o=>o.from==i);return r?r.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,r)=>{let o=e.specializers.find(a=>a.from==i.external);if(!o)return i;let s=Object.assign(Object.assign({},i),{external:o.to});return t.specializers[r]=xP(s),s})),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 o of e.split(" ")){let s=t.indexOf(o);s>=0&&(i[s]=!0)}let r=null;for(let o=0;o<t.length;o++)if(!i[o])for(let s=this.dialects[t[o]],a;(a=this.data[s++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[a]=1;return new F_(e,i,r)}static deserialize(e){return new n(e)}};function zr(n,e){return n[e]|n[e+1]<<16}function N6(n){let e=null;for(let t of n){let i=t.p.stoppedAt;(t.pos==t.p.stream.end||i!=null&&t.pos>i)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function xP(n){if(n.external){let e=n.extend?1:0;return(t,i)=>n.external(t,i)<<1|e}return n.get}var $6=121,H_=122,kP=123,j6=124,_P=128,F6=4,q6=131,V6=7,H6=8,z6=9,W6=10,U6=139,RP=19,Q6=140,K6=23,G6=141,X6=27,Y6=37,Z6=41,J6=144,ez=145,tz=146,nz=147,iz=47,rz=68,TP=153,AP=70,MP=154,PP=72,oz=155,sz=76,az=160,lz=79,cz=80,uz=81,fz=167,DP=89,hz=90,dz=169,pz=97,mz=171,gz=98,yz=100,vz=101,z_=typeof process!="undefined"&&process.env&&/\bfparse(:dbg)?\b/.test(process.env.LOG),W_=typeof process!="undefined"&&process.env&&/\bfparse:dbg\b/.test(process.env.LOG),Wr=typeof process!="undefined"&&process.env&&/\bcontext\b/.test(process.env.LOG),IP=[9,11,12,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],xz=LP(` 285\r`),wP=42,bz=LP("'./-+*^");function LP(n){return Array.from(n).map(e=>e.charCodeAt(0))}function _z(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 wz(n){return bz.includes(n)}function Cz(n){return n>=48&&n<=57||n===183||n>=768&&n<=879||n>=8255&&n<=8256}function Ez(n){return IP.includes(n)}function CP(n,e){return e.concat(n.split(/\n/g).join(` 286`+e))}function Sz(n,e=0){let t=n.peek(e);return t===wP&&n.peek(e+1)===wP?{offset:2,token:"**"}:wz(t)?{offset:1,token:String.fromCharCode(t)}:null}function Dy(n,e=0,t=!1){for(let i=!1,r=[],o=0;;o++){let s=n.peek(e+o);if(_z(s)||(i||t)&&Cz(s))i||(i=!0),r.push(s);else return r.length?{token:String.fromCharCode(...r),offset:o}:null}}function BP(n,e){for(let t=!1,i=0;;i++){let r=n.peek(e+i);if(Ez(r))t||(t=!0);else return t?{token:" ",offset:i}:null}}function Oz(n,e){let{keys:t,prefixes:i}=e.contextCache(),r=e.tokens;for(let o=0,s=[],a=null;;){let l=r.length+s.length>0,c=s.length>0,u=Dy(n,o,l)||l&&Sz(n,o)||c&&BP(n,o);if(!u)return a;let{token:f,offset:h}=u;if(o+=h,f===" ")continue;s=[...s,f];let d=[...r,...s].join(" ");if(t.has(d)){let p=s[0];a={token:p,offset:p.length,term:kP}}if(!i.has(d)){if(EP.some(p=>p===d)){let p=s[0];a={token:p,offset:p.length,term:H_}}if(!EP.some(p=>p.startsWith(d)))return a}}}var kz={[H_]:"identifier",[kP]:"nameIdentifier"},Rz=new vc((n,e)=>{W_&&console.log("%s: T <identifier | nameIdentifier>",n.pos);let t=Oz(n,e.context),i=e.context.tokens,r=t||Dy(n,0,i.length>0);r&&(n.advance(r.offset),n.acceptToken(t?t.term:H_),z_&&console.log("%s: MATCH <%s> <%s>",n.pos,t?kz[t.term]:"identifier",r.token))},{contextual:!0}),Tz=new vc((n,e)=>{W_&&console.log("%s: T <propertyIdentifier>",n.pos);let t=e.context.tokens,i=Dy(n,0,t.length>0);i&&(n.advance(i.offset),n.acceptToken($6),z_&&console.log("%s: MATCH <propertyIdentifier> <%s>",n.pos,i.token))}),Az=new vc((n,e)=>{W_&&console.log("%s: T <insertSemi>",n.pos);let t,i=!1;for(t=0;;t++){let r=n.peek(t);if(!IP.includes(r)){xz.includes(r)&&(i=!0);break}}if(i){let r=Dy(n,t+1);if(BP(n,t+1)||r&&/^(then|else|return|satisfies)$/.test(r.token))return;z_&&console.log("%s: MATCH <insertSemi>",n.pos),n.acceptToken(j6)}}),Mz={[oz]:"FunctionInvocation",[MP]:"FilterExpression",[TP]:"PathExpression"},Pz={[mz]:"Context",[dz]:"FunctionDefinition",[q6]:"ForExpression",[fz]:"List",[Q6]:"IfExpression",[G6]:"QuantifiedExpression"},Dz={[pz]:"Context",[hz]:"FunctionDefinition",[F6]:"ForExpression",[DP]:"List",[RP]:"IfExpression",[K6]:"QuantifiedExpression",[rz]:"PathExpression",[PP]:"FunctionInvocation",[AP]:"FilterExpression",[Z6]:"ArithmeticExpression"},bc=class n{constructor(e){this.fn=e}get(e){return this.fn(e)}static of(e){return new n(e)}},Iz={"date and time":1,date:1,time:1,duration:1},EP=Object.keys(Iz);function Lz(n){let e=[];for(let t=1;t<=n.length;t++)e.push(n.substring(0,t));return e}function NP(n,e){let t=U_(n),i=Lz(t);e.keys.add(t);for(let r of i)e.prefixes.add(r);return e.originalMap.set(t,n),e}function SP(n){let e=$P();for(let t of n.getKeys())NP(t,e);return e}function $P(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 q_=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 bc||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,o]of Object.entries(this.__unwrap(t))){if(o instanceof bc){i[r]=o;continue}if(Zr(i,r)){i[r]=this.__merge(i[r],o);continue}i[r]=o}return i}},V_=class n{constructor({name:e="Expressions",tokens:t=[],children:i=[],parent:r=null,context:o,value:s,raw:a,__cache:l}){this.name=e,this.tokens=t,this.children=i,this.parent=r,this.context=o,this.value=s,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 Wr&&console.log("[%s] enter",t.path,t.context),t}exitScope(e){return this.parent?(Wr&&console.log(`[%s] exit %o 287%s`,this.path,this.context,CP(e," ")),this.parent.pushChild(this)):(Wr&&console.log(`[%s] NO exit %o 288%s`,this.path,this.context,CP(e," ")),this)}token(e){return Wr&&console.log("[%s] token <%s> + <%s>",this.path,this.tokens.join(" "),e),this.assign({tokens:[...this.tokens,e]})}literal(e){return Wr&&console.log("[%s] literal %o",this.path,e),this.pushChild(this.of({name:"Literal",value:e}))}computedValue(){for(let e=this;;e=xc(e.children)){if(!e)return null;if(!Yr(e.value))return e.value}}contextCache(){let e=this.cache.get(this.context);return e||(e=SP(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&&U_(e),i=this.contextCache().originalMap.get(t);if(typeof i=="undefined")return;let r=this.context.get(i);return r instanceof bc?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 Wr&&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 Wr&&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 Wr&&console.log("[%s] no define <%s=%s>",this.path,e,t),this;Wr&&console.log("[%s] define <%s=%s>",this.path,e,t);let i=this.context,r=i.set(e,t),o=this.cache.get(i)||SP(i),s=NP(e,$P(o));return this.cache.set(r,s),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:o=null,context:s,value:a,raw:l,__cache:c}=e;if(!s)throw new Error("must provide <context>");return new n({name:t,tokens:[...i],children:[...r],context:s,parent:o,value:a,raw:l,__cache:c})}};function U_(n){return n.replace(/\s*([./\-'+]|\*\*?)\s*/g," $1 ").replace(/\s{2,}/g," ").trim()}function OP(n,e,t){var c;let i=n.children.filter(u=>u.name!==e),r=n.children.filter(u=>u.name===e),o=i[0],s=i[Math.max(1,i.length-1)],a=o==null?void 0:o.computedValue(),l=(c=s==null?void 0:s.computedValue())!=null?c:null;return n.assign({children:r}).enterScope(e).pushChildren(i).exitScope(t).define(a,l)}function Q_(n={},e=q_){let t=V_.of({context:e.of(n)});return new My({start:t,reduce(i,r,o,s){if(r===RP){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===DP&&(i=i.assign({value:e.of(...i.children.map(f=>f==null?void 0:f.computedValue()))})),r===AP){let[f,h]=i.children.slice(-2);i=i.assign({value:f==null?void 0:f.computedValue()})}if(r===PP){let[f,...h]=i.children;(f==null?void 0:f.raw)==="get value"?i=Nz(i,h):i=i.assign({value:(f==null?void 0:f.computedValue())||e.of(void 0)})}let a=Pz[r];if(a)return i.enterScope(a);let l=Mz[r];if(l){let{children:f,context:h}=i,d=f.slice(0,-1),p=xc(f),m=null;return r===TP&&(m=e.of(p==null?void 0:p.computedValue())),r===MP&&(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=s.read(s.pos,o.pos);if(Dz[r])return i.exitScope(c);if(r===gz){let f=i.children.filter(p=>p.name!=="ContextEntry"),h=f[0],d=xc(f);return OP(i,"ContextEntry",c).assign({value:e.of(i.value).set(h==null?void 0:h.computedValue(),d==null?void 0:d.computedValue())})}if(r===V6||r===X6)return OP(i,"InExpression",c);if(r===U6)return i.define("partial",bc.of(f=>{var h;return(h=xc(f.children))==null?void 0:h.computedValue()}));if(r===sz){let f=xc(i.children).computedValue();return i.define(f,1)}if(r===J6||r===ez||r===tz){let f=i.children.slice(0,-1),h=xc(i.children);return i.assign({children:f}).enterScope("ArithmeticExpression").pushChild(h)}if(r===nz)return i.enterScope("ArithmeticExpression");if(r===z6||r===W6||r===vz)return i.token(c);if(r===cz)return i.literal(c.replace(/^"|"$/g,"").replace(/\\(["\\])/g,"$1"));if(r===uz)return i.literal(c==="true");if(r===lz)return i.literal(parseFloat(c));if(r===az)return i.literal(null);if(r===iz)return i.resolveName();if(r===H6||r===yz)return i.declareName();if((r===_P||r===Y6)&&i.tokens.length>0)throw new Error("uncleared name");if(r===_P){let f=i;for(;f.parent;)f=f.exitScope(c);return f}return i}})}var Bz=Q_({});function Nz(n,e){if(!e.length)return n.assign({value:null});if(e[0].name==="Name"&&(e=$z(e,["m","key"])),e.length!==2)return n.assign({value:null});let[t,i]=e,r=i==null?void 0:i.computedValue(),o=t==null?void 0:t.computedValue();return!o||typeof o!="object"||typeof r!="string"?n.assign({value:null}):n.assign({value:[U_(r),r].reduce((s,a)=>o.get(a)||s,null)})}function $z(n,e){let t={};for(let i=0;i<n.length;i+=2){let[r,o]=n.slice(i,i+2);t[r.value]=o}return e.map(i=>t[i])}function xc(n){return n[n.length-1]}var jz=cy({StringLiteral:B.string,NumericLiteral:B.number,BooleanLiteral:B.bool,"AtLiteral!":B.special(B.string),CompareOp:B.compareOperator,ArithOp:B.arithmeticOperator,"for if then else some every return":B.controlKeyword,"in instance of and or satisfies between as":B.operatorKeyword,function:B.definitionKeyword,"Type/...":B.typeName,"Wildcard!":B.modifier,null:B.null,LineComment:B.lineComment,BlockComment:B.blockComment,"VariableName!":B.variableName,'"?"':B.special(B.variableName),"DateTimeConstructor! SpecialFunctionName!":B.standard(B.function(B.variableName)),"FunctionInvocation/VariableName!":B.function(B.variableName),"Name!":B.definition(B.variableName),"Key/Name! ContextEntryType/Name!":B.definition(B.propertyName),"PathExpression/VariableName!":B.propertyName,"FormalParameter/ParameterName!":B.function(B.definition(B.variableName)),"( )":B.paren,"[ ]":B.squareBracket,"{ }":B.brace,".":B.derefOperator,", ;":B.separator,"..":B.punctuation}),Fz={__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},jP=Py.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/]O<jQYO1G/]O<tQYO1G/]OOQQ1G/x1G/xO>hQYO1G/zO>oQYO1G/PO?xQYO1G/ROARQYO1G/TO`QYO1G/TOOQQ1G/T1G/TOAiQYO1G/^OBWQ^O'#CdOCjQYO'#FpOOQO'#Dz'#DzOCtQWO'#DyOCyQWO'#FoOOQO'#Dx'#DxOOQO'#D{'#D{ODRQWO,5<YOOQQ1G0^1G0^O`QYO1G0]O`QYO'#EsODWQWO,5<[OOQQ1G0_1G0_ODcQWO'#E[ODnQWO'#F|OOQO'#EZ'#EZODvQWO1G0`OOQP'#Eu'#EuOD{QXO,5;OO`QYO,5:|OESQXO'#EvOE_QWO,5<jOOQQ1G0g1G0gO`QYO1G.uO%TQYO'#ElOEgQYO,5;zO`QYO1G.yOEoQYO1G/}OOQO1G0X1G0XOOQO,5;c,5;cOOQO-E8u-E8uOOQO,5;X,5;XOOQO-E8k-E8kOEtQWOOOOQQ-E8h-E8hOEyQYO'#CmOOQQ1G1]1G1]OOQQ,5;V,5;VOOQQ-E8i-E8iOFZQYO7+$QOOQQ7+%f7+%fO`QYO7+$oOGQQYO,5:rOG_QWO7+$oOGdQYO'#D[OOQQ'#DZ'#DZOIWQYO'#D_OI]QYO'#D_OIbQYO'#D_OIgQ`O'#DgOIlQ`O'#DjOIqQ`O'#DnOOQQ7+$x7+$xO`QYO,5:eO%TQYO'#ErOIvQWO,5<ZOOQQ1G1t1G1tOJ|QYO7+%wOKZQYO,5;_OOQO-E8q-E8qOAiQYO,5:vO%TQYO'#EtOKhQWO,5<hOKpQYO7+%zOOQP-E8s-E8sOKwQYO1G0hOOQO,5;b,5;bOOQO-E8t-E8tOLRQYO7+$aOOQQ,5;W,5;WOOQQ-E8j-E8jOLYQYO7+$eOOQO7+%i7+%iO`QYO,59XOMPQYO<<HZOOQQ<<HZ<<HZO/}QYO'#EoONYQYO,59vO! |QYO,59yO!!RQYO,59yO!!WQYO,59yO!!]QYO,5:RO%TQYO,5:UO!!zQbO,5:YO!#RQYO1G0POOQO,5;^,5;^OOQO-E8p-E8pO!#]QYO<<IcOOQQ<<Ic<<IcOOQO1G0b1G0bOOQO,5;`,5;`OOQO-E8r-E8rO!&_QYO'#E^OOQQ<<If<<IfO`QYO<<IfO`QYO<<G{O!'UQYO1G.sOOQQ,5;Z,5;ZOOQQ-E8m-E8mO!'cQYO1G/eOOQQ1G/e1G/eO!'hQbO'#D]O!'yQ`O'#D[O!(UQ`O1G/mO!(ZQWO'#DmO!(`Q`O'#FgOOQO'#Dl'#DlO!(hQ`O1G/pOOQO'#Dq'#DqO!(mQ`O'#FiOOQO'#Dp'#DpO!(uQ`O1G/tOOQQAN?QAN?QO!(zQYOAN=gOOQQ7+%P7+%PO!)qQ`O,59vOOQQ7+%X7+%XO!!]QYO,5:XO%TQYO'#EpO!)|Q`O,5<ROOQQ7+%[7+%[O!!]QYO'#EqO!*UQ`O,5<TO!*^Q`O7+%`OOQO1G/s1G/sOOQO,5;[,5;[OOQO-E8n-E8nOOQO,5;],5;]OOQO-E8o-E8oOAiQYO<<HzOOQQAN>fAN>fO/}QYO'#EoO!!]QYO<<HzO!*cQ`O7+%`O!*hQ`O1G/tO!!zQbO,5:YO!*mQ`O'#Dn",stateData:"!+Q~O#rOS#sOSPOSQOS~OTsOZVO[UOdtOhvOivOr}Os}OviO!T{O!U{O!VxO!XzO!c!OO!g|O!igO!pyO!wjO#SnO#nRO#oRO$YZO$h_O$i`O$j`O$kaO$lbO~OTsO[UOdtOhvOivOr}Os}OviO!T{O!U{O!VxO!XzO!c!OO!g|O!igO!pyO!wjO#SnO#nRO#oRO$YZO$h_O$i`O$j`O$kaO$lbO~OZ!TO#]!UO~P#VO#nRO#oRO~OZ!^O[!^O]!_O^!_O_!`O`!kOn!hOp!iOr!]Os!]Ot!jO{!lO!i!fO#z!dOv$aX~O#l#tX$s#tX~P%]O$h!mOT$XXZ$XX[$XXd$XXh$XXi$XXr$XXs$XXv$XX!T$XX!U$XX!V$XX!X$XX!c$XX!g$XX!i$XX!p$XX!w$XX#S$XX#n$XX#o$XX$Y$XX$i$XX$j$XX$k$XX$l$XX~O#nRO#oROZ!PX[!PX]!PX^!PX_!PX`!PXn!PXp!PXr!PXs!PXt!PXv!PX{!PX!i!PX#l!PX#p!PX#z!PX$s!PX$O!PXx!PX#}!PX!g!PXe!PXb!PX#R!PXf!PXl!PX~Ov!pO~O$i`O$j`O~O#p!uOZ#vX[#vX]#vX^#vX_#vX`#vXn#vXp#vXr#vXs#vXt#vXv#vX{#vX!i#vX#l#vX#z#vX$s#vX$O#vXx#vX#}#vX!g#vXe#vXb#vX#R#vXf#vXl#vX~O!g$dP~P`Ov!xO~O#m!yO$i`O$j`O#R$rP~Op#UO~Op#VOv!uX~O$s#YO~O#luX$OuX$suXxuX#}uX!guXeuXbuX#RuXfuXluX~P%]O$O#[O#l$TXx$TX~O#l#[X~P&hOv#^O~OZ#_O[#_O]#_O^#_O_#_O#nRO#oRO#z#_O#{#_O$[WX~O`WXxWX$OWX~P.lO`#cO~O$O#dOb#xX~Ob#gO~O#nRO#oRO$YZO~OTsOZVO[UOdtOhvOivOr}Os}O!T{O!U{O!VxO!XzO!c!OO!g|O!igO!pyO!wjO#SnO#nRO#oRO$YZO$h_O$i`O$j`O$kaO$lbO~Ov#qO~P0YO|#sO~O{!lO!i!fO#z!dOZya[ya]ya^ya_ya`yanyapyaryasyatyav$aX#lya$sya$Oyaxya#}ya!gyaeyabya#Ryafyalya~Ox$dP~P`Ox#|O#}#}O~P%]O#}#}O$O$OO!g$dX~P%]O!g$QO~O#nRO#oROx$pP~OZ#_O[#_O]#_O^#_O_#_O#m!yO#z#_O#{#_O~O$[#WX~P4|O$[$XO~O$O$YO#R$rX~O#R$[O~Oe$]O~P%]O$O$^Ol$SX~Ol$`O~O!W$aO~O!T$bO~O#l!xa$s!xa$O!xax!xa#}!xa!g!xae!xab!xa#R!xaf!xal!xa~P%]O$O#[O#l$Tax$Ta~OZ#_O[#_O]#_O^#_O_#_O#nRO#oRO#z#_O#{#_O~O`Wa$[WaxWa$OWa~P7sO$O#dOb#xa~OZ!^O[!^O]!_O^!_O_!`O{!lO!i!fO#z!dOv$aX~O`qinqipqirqisqitqi#lqi$sqi$Oqixqi#}qi!gqieqibqi#Rqifqilqi~P8zO_!`O{!lO!i!fO#z!dOZyi[yi`yinyipyiryisyityiv$aX#lyi$syi$Oyixyi#}yi!gyieyibyi#Ryifyilyi~O]!_O^!_O~P:rO]yi^yi~P:rO{!lO!i!fO#z!dOZyi[yi]yi^yi_yi`yinyipyiryisyityiv$aX#lyi$syi$Oyixyi#}yi!gyieyibyi#Ryifyilyi~O!g$nO~P%]O`!kOp!iOr!]Os!]Ot!jOnmi#lmi$smi$Omixmi#}mi!gmiemibmi#Rmifmilmi~P8zO`!kOr!]Os!]Ot!jOnoipoi#loi$soi$Ooixoi#}oi!goieoiboi#Roifoiloi~P8zO`!kOn!hOp$oOr!]Os!]Ot!jO~P8zO!S$tO!V$uO!X$vO![$wO!_$xO!c$yO#nRO#oRO$YZO~OZ#bX[#bX]#bX^#bX_#bX`#bXn#bXp#bXr#bXs#bXt#bXv#bXx#bX{#bX!i#bX#n#bX#o#bX#p#bX#z#bX$O#bX~P.lO$O$OOx$dX~P%]O$[${O~O$O$|Ox$cX~Ox%OO~O$O$OO!g$dax$da~O$[%SOx#OX$O#OX~O$O%TOx$pX~Ox%VO~O$[#Wa~P4|O#m!yO$i`O$j`O~O$O$YO#R$ra~O$O$^Ol$Sa~O!U%`O~OxrO~O#}%aObaX$OaXlaX~P%]O#lSq$sSq$OSqxSq#}Sq!gSqeSqbSq#RSqfSqlSq~P%]Ox#|O#}#}O$OuX~P%]Ox%cO~O#z%dOZ!OX[!OX]!OX^!OX_!OX`!OXn!OXp!OXr!OXs!OXt!OXv!OX{!OX!i!OX#l!OX$s!OX$O!OXx!OX#}!OX!g!OXe!OXb!OX#R!OXf!OXl!OX~Op%fO~Op%gO~Op%hO~O!]%iO~O!]%jO~O!]%kO~O$O$|Ox$ca~OZ!^O[!^O]!_O^!_O_!`O`!kOn!hOp!iOr!]Os!]Ot!jO{!lO#z!dOv$aX~Ox%pO!g%pO!i%oO~PJOO!g#ga$O#gax#ga~P%]O$O%TOx$pa~O#P%vO~P`O#R#Ui$O#Ui~P%]Of%wO~P%]O#lgq$sgq$Ogqxgq#}gq!ggqegqbgq#Rgqfgqlgq~P%]O`qynqypqyrqysqytqy#lqy$sqy$Oqyxqy#}qy!gqyeqybqy#Rqyfqylqy~P8zO#z%dOZ!Oa[!Oa]!Oa^!Oa_!Oa`!Oan!Oap!Oar!Oas!Oat!Oav!Oa{!Oa!i!Oa#l!Oa$s!Oa$O!Oax!Oa#}!Oa!g!Oae!Oab!Oa#R!Oaf!Oal!Oa~O!T%{O~O!W%{O~O!T%|O~O!S$tO!V$uO!X$vO![$wO!_$xO!c&rO#nRO#oRO$YZO~O!Y$]P~P!!]Ox!mi$O!mi~P%]OT$`XZ$`X[$`X]!yy^!yy_!yy`!yyd$`Xh$`Xi$`Xn!yyp!yyr$`Xs$`Xt!yyv$`X{!yy!T$`X!U$`X!V$`X!X$`X!c$`X!g$`X!i$`X!p$`X!w$`X#S$`X#l!yy#n$`X#o$`X#z!yy$Y$`X$h$`X$i$`X$j$`X$k$`X$l$`X$s!yy$O!yyx!yy#}!yye!yyb!yy#R!yyf!yyl!yy~O#l#QX$s#QX$O#QXx#QX#}#QX!g#QXe#QXb#QX#R#QXf#QXl#QX~P%]Obai$Oailai~P%]O!U&[O~O#nRO#oRO!Y!PX#z!PX$O!PX~O#z&mO!Y!OX$O!OX~O!Y&^O~O$[&_O~O$O&`O!Y$ZX~O!Y&bO~O$O&cO!Y$]X~O!Y&eO~O#lc!R$sc!R$Oc!Rxc!R#}c!R!gc!Rec!Rbc!R#Rc!Rfc!Rlc!R~P%]O#z&mO!Y!Oa$O!Oa~O$O&`O!Y$Za~O$O&cO!Y$]a~O$^&kO~O$^&nO~O!Y&oO~O!]&qO~O$Y$i~$i$j_^$h#zQP]Q~",goto:"EX$sPPPP$tP%l%o%u&V'oPPPPPP'xP$tPPP$tPP'{(OP$tP$tP$tPPP(UP(aP$t$tPP(j)P)[*h)PPPPPPPP)PPP)PP+l+o)PP+u+{$tP$tP$t,S,z,}-T,zP-].T-]-]/S/zP$t0r$t1j1j2b2eP2kPP1j2q2w/O2{PP3TP3W3_3e3k3q4{5V5]5c5i5p5v5|6SPPPPPPPP6Y6c8g9_:V:YPP:bPP:e:h;`<W<Z<`<|=k>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:Bz,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:[jz],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:[Tz,Rz,Az,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=>Fz[n]||-1}],tokenPrec:2567});function qz(n){let e=[];return n.iterate({enter:t=>{let i=t.node;if(!i.type.isError)return;let r=i.parent,o=qP(i),s={from:i.from,to:i.to,severity:"error",type:"Syntax Error"};if(i.from!==i.to)s.message=`Unrecognized token in <${r.name}>`;else if(o)s.message=`Unrecognized token <${o.name}> in <${r.name}>`,s.to=o.to;else{let a=r.enterUnfinishedNodesBefore(i.to);s.message=`Incomplete <${(a||r).name}>`}e.push(s)}}),e}function qP(n){return n?n.nextSibling||qP(n.parent):null}var Vz="first-item",Hz={create(n){return{enter(e){if(e.name!=="FilterExpression")return;let t=n.readContent(e.from,e.to);if(FP().test(t)){let{from:i,to:r}=e;n.report({from:i,to:r,message:"First item is accessed via [1]",severity:"warning",type:Vz,actions:[{name:"fix",apply(o,s=i,a=r){n.updateContent(s,a,t.replace(FP(),"[1]"))}}]})}}}}};function FP(){return/\[\s*0\s*\]$/}var zz=[Hz];function Wz(n){let{readContent:e,syntaxTree:t,updateContent:i}=n,r=[],o={readContent:e,report:a=>{r.push(a)},updateContent:i},s=zz.map(a=>a.create(o));return t.iterate({enter:a=>{for(let l of s)l.enter&&l.enter(a)},leave:a=>{for(let l of s)l.leave&&l.leave(a)}}),r}function Uz(n){return[...qz(n.syntaxTree),...Wz(n)]}var VP=()=>n=>{if(n.state.doc.length===0)return[];let e=lt(n.state);return Uz({syntaxTree:e,readContent:(i,r)=>n.state.sliceDoc(i,r),updateContent:(i,r,o)=>n.dispatch({changes:{from:i,to:r,insert:o}})}).map(i=>({...i,source:i.type}))};var G_=[li("function(${params}) ${body}",{label:"function",detail:"definition",type:"keyword"}),li("for ${var} in ${collection} return ${value}",{label:"for",detail:"expression",type:"keyword"}),li("every ${var} in ${collection} satisfies ${condition}",{label:"every",detail:"quantified expression",type:"keyword"}),li("some ${var} in ${collection} satisfies ${condition}",{label:"some",detail:"quantified expression",type:"keyword"}),li("if ${condition} then ${value} else ${other value}",{label:"if",detail:"block",type:"keyword"}),li("{ ${key}: ${value} }",{label:"context",detail:"block",type:"keyword"}),li("null",{label:"null",detail:"literal",type:"keyword"}),li("true",{label:"true",detail:"literal",type:"keyword"}),li("false",{label:"false",detail:"literal",type:"keyword"})];function K_(){return K_=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},K_.apply(null,arguments)}function Xh(n){let{context:e,after:t,before:i,keyword:r}=n;return Yz({nodes:e,before:i,after:t,keyword:r},pc([{label:r,type:"keyword",boost:10}]))}var X_=[Xh({context:"InExpression",keyword:"in"}),Xh({context:"IfExpression",keyword:"then",after:"if",before:"else"}),Xh({context:"IfExpression",keyword:"else",after:"then"}),Xh({context:"QuantifiedExpression",keyword:"satisfies"}),Xh({context:"ForExpression",after:"InExpressions",keyword:"return"})],HP=["StringLiteral","Identifier","LineComment","BlockComment","PathExpression","Context","Key","ParameterName"],Qz=["Expr","ContextEntry"];function Kz(n){let e=[...HP,...Qz];return t=>{let{state:i,pos:r}=t,o=UP(lt(i).resolveInner(r,-1),e);if(o){let[s,a]=o;if(HP.includes(a))return null}return n(t)}}function Gz(n){return Kz(pc(n.map(e=>K_({},e,{type:"text"}))))}function zP(n,e,t){return WP(n,e,t,-1)}function Xz(n,e,t){return WP(n,e,t,1)}function WP(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 UP(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 Yz(n,e){let{nodes:t,before:i,after:r,keyword:o}=n;return s=>{let{state:a,pos:l}=s,c=UP(lt(a).resolveInner(l,-1),t);if(!c)return null;let[u]=c;return zP(u,l,[o,i])||Xz(u,l,[o,r])||r&&!zP(u,l,[r])?null:e(s)}}var QP=uy.define({parser:jP.configure({props:[t_.add({Context:n_({closing:"}"}),"List FilterExpression":n_({closing:"]"}),"ParenthesizedExpression FunctionInvocation":dy({except:/^\s*\)/}),"ForExpression QuantifiedExpression IfExpression":dy({except:/^\s*(then|else|return|satisfies)\b/}),FunctionDefinition:dy({except:/^\s*(\(|\))/})}),eM.add({Context:py,List:py,ParenthesizedExpression:py,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:"*/"}}}}),Zz=QP.configure({top:"UnaryTests"},"FEEL unary tests"),Jz=QP.configure({top:"Expression"},"FEEL expression");function KP(n={}){let e=n.dialect==="unaryTests"?Zz:Jz,t=n.parserDialect,i=Q_(n.context),r=e.configure({contextTracker:i,dialect:t}),o=n.completions||[Gz(G_),X_].flat();return new fy(r,[...o.map(s=>r.data.of({autocomplete:s}))])}var eW=[{name:"not",type:"function",params:[{name:"negand"}],info:`<p>Returns the logical negation of the given value.</p> 289<p><strong>Function signature</strong></p> 290<pre><code class="language-feel">not(negand: boolean): boolean 291</code></pre> 292<p><strong>Examples</strong></p> 293<pre><code class="language-feel">not(true) 294// false 295 296not(null) 297// null 298</code></pre> 299`},{name:"get value",type:"function",params:[{name:"context"},{name:"key"}],info:`<p>Returns the value of the context entry with the given key.</p> 300<p><strong>Function signature</strong></p> 301<pre><code class="language-feel">get value(context: context, key: string): Any 302</code></pre> 303<p><strong>Examples</strong></p> 304<pre><code class="language-feel">get value({foo: 123}, "foo") 305// 123 306 307get value({a: 1}, "b") 308// null 309</code></pre> 310`},{name:"get entries",type:"function",params:[{name:"context"}],info:`<p>Returns the entries of the context as a list of key-value-pairs.</p> 311<p><strong>Function signature</strong></p> 312<pre><code class="language-feel">get entries(context: context): list<context> 313</code></pre> 314<p>The return value is a list of contexts. Each context contains two entries for "key" and "value".</p> 315<p><strong>Examples</strong></p> 316<pre><code class="language-feel">get entries({foo: 123}) 317// [{key: "foo", value: 123}] 318</code></pre> 319`},{name:"context put",type:"function",params:[{name:"context"},{name:"keys"},{name:"value"}],info:`<p>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.</p> 320<p>If <code>keys</code> contains the keys <code>[k1, k2]</code> then it adds the nested entry <code>k1.k2 = value</code> to the context.</p> 321<p>If an entry for the same keys already exists in the context, it overrides the value.</p> 322<p>If <code>keys</code> are empty, it returns <code>null</code>.</p> 323<p><strong>Function signature</strong></p> 324<pre><code class="language-feel">context put(context: context, keys: list<string>, value: Any): context 325</code></pre> 326<p><strong>Examples</strong></p> 327<pre><code class="language-feel">context put({x:1}, ["y"], 2) 328// {x:1, y:2} 329 330context put({x:1, y: {z:0}}, ["y", "z"], 2) 331// {x:1, y: {z:2}} 332 333context put({x:1}, ["y", "z"], 2) 334// {x:1, y: {z:2}} 335</code></pre> 336`},{name:"string",type:"function",params:[{name:"from"}],info:`<p>Returns the given value as a string representation.</p> 337<p><strong>Function signature</strong></p> 338<pre><code class="language-feel">string(from: Any): string 339</code></pre> 340<p><strong>Examples</strong></p> 341<pre><code class="language-feel">string(1.1) 342// "1.1" 343 344string(date("2012-12-25")) 345// "2012-12-25" 346</code></pre> 347`},{name:"number",type:"function",params:[{name:"from"}],info:`<p>Parses the given string to a number.</p> 348<p>Returns <code>null</code> if the string is not a number.</p> 349<p><strong>Function signature</strong></p> 350<pre><code class="language-feel">number(from: string): number 351</code></pre> 352<p><strong>Examples</strong></p> 353<pre><code class="language-feel">number("1500.5") 354// 1500.5 355</code></pre> 356`},{name:"number",type:"function",params:[{name:"from"},{name:"grouping separator"}],info:`<p>Parses the given string to a number using the specified grouping separator.</p> 357<p>Returns <code>null</code> if the string is not a number.</p> 358<p><strong>Function signature</strong></p> 359<pre><code class="language-feel">number(from: string, grouping separator: string): number 360</code></pre> 361<p><strong>Examples</strong></p> 362<pre><code class="language-feel">number("1,500", ",") 363// 1500 364</code></pre> 365`},{name:"number",type:"function",params:[{name:"from"},{name:"grouping separator"},{name:"decimal separator"}],info:`<p>Parses the given string to a number using the specified grouping and decimal separators.</p> 366<p>Returns <code>null</code> if the string is not a number.</p> 367<p><strong>Function signature</strong></p> 368<pre><code class="language-feel">number(from: string, grouping separator: string, decimal separator: string): number 369</code></pre> 370<p><strong>Examples</strong></p> 371<pre><code class="language-feel">number("1 500.5", " ", ".") 372// 1500.5 373</code></pre> 374`},{name:"context",type:"function",params:[{name:"entries"}],info:`<p>Constructs a context of the given list of key-value pairs. It is the reverse function to <a href="feel-built-in-functions-context.md#get-entriescontext">get entries()</a>.</p> 375<p>Each key-value pair must be a context with two entries: <code>key</code> and <code>value</code>. The entry with name <code>key</code> must have a value of the type <code>string</code>.</p> 376<p>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.</p> 377<p>Returns <code>null</code> if one of the entries is not a context or if a context doesn't contain the required entries.</p> 378<p><strong>Function signature</strong></p> 379<pre><code class="language-feel">context(entries: list<context>): context 380</code></pre> 381<p><strong>Examples</strong></p> 382<pre><code class="language-feel">context([{"key":"a", "value":1}, {"key":"b", "value":2}]) 383// {a:1, b:2} 384</code></pre> 385`},{name:"date",type:"function",params:[{name:"from"}],info:`<p>Returns a date from the given value.</p> 386<p>Returns <code>null</code> if the string is not a valid calendar date. For example, <code>"2024-06-31"</code> is invalid because June has 387only 30 days.</p> 388<p><strong>Function signature</strong></p> 389<pre><code class="language-feel">date(from: string): date 390</code></pre> 391<p>Parses the given string into a date.</p> 392<pre><code class="language-feel">date(from: date and time): date 393</code></pre> 394<p>Extracts the date component from the given date and time.</p> 395<p><strong>Examples</strong></p> 396<pre><code class="language-feel">date("2018-04-29") 397// date("2018-04-29") 398 399date(date and time("2012-12-25T11:00:00")) 400// date("2012-12-25") 401</code></pre> 402`},{name:"date",type:"function",params:[{name:"year"},{name:"month"},{name:"day"}],info:`<p>Returns a date from the given components.</p> 403<p>Returns <code>null</code> if the components don't represent a valid calendar date. For example, <code>2024,6,31</code> is invalid because 404June has only 30 days.</p> 405<p><strong>Function signature</strong></p> 406<pre><code class="language-feel">date(year: number, month: number, day: number): date 407</code></pre> 408<p><strong>Examples</strong></p> 409<pre><code class="language-feel">date(2012, 12, 25) 410// date("2012-12-25") 411</code></pre> 412`},{name:"time",type:"function",params:[{name:"from"}],info:`<p>Returns a time from the given value.</p> 413<p><strong>Function signature</strong></p> 414<pre><code class="language-feel">time(from: string): time 415</code></pre> 416<p>Parses the given string into a time.</p> 417<pre><code class="language-feel">time(from: date and time): time 418</code></pre> 419<p>Extracts the time component from the given date and time.</p> 420<p><strong>Examples</strong></p> 421<pre><code class="language-feel">time("12:00:00") 422// time("12:00:00") 423 424time(date and time("2012-12-25T11:00:00")) 425// time("11:00:00") 426</code></pre> 427`},{name:"time",type:"function",params:[{name:"hour"},{name:"minute"},{name:"second"}],info:`<p>Returns a time from the given components.</p> 428<p><strong>Function signature</strong></p> 429<pre><code class="language-feel">time(hour: number, minute: number, second: number): time 430</code></pre> 431<p><strong>Examples</strong></p> 432<pre><code class="language-feel">time(23, 59, 0) 433// time("23:59:00") 434</code></pre> 435`},{name:"time",type:"function",params:[{name:"hour"},{name:"minute"},{name:"second"},{name:"offset"}],info:`<p>Returns a time from the given components, including a timezone offset.</p> 436<p><strong>Function signature</strong></p> 437<pre><code class="language-feel">time(hour: number, minute: number, second: number, offset: days and time duration): time 438</code></pre> 439<p><strong>Examples</strong></p> 440<pre><code class="language-feel">time(14, 30, 0, duration("PT1H")) 441// time("14:30:00+01:00") 442</code></pre> 443`},{name:"date and time",type:"function",params:[{name:"from"}],info:`<p>Parses the given string into a date and time. The function supports strings in the format <code>YYYY-MM-DDThh:mm:ss</code> with 444optional timezone information either as offset (e.g., <code>+01:00</code> or <code>Z</code>), as IANA timezone ID (e.g., <code>@Europe/Berlin</code>), or 445as a combination of both (e.g., <code>+01:00[Europe/Berlin]</code>).</p> 446<p>Returns <code>null</code> if the string is not a valid calendar date. For example, <code>"2024-06-31T10:00:00"</code> is invalid because 447June has only 30 days.</p> 448<p><strong>Function signature</strong></p> 449<pre><code class="language-feel">date and time(from: string): date and time 450</code></pre> 451<p><strong>Examples</strong></p> 452<pre><code class="language-feel">date and time("2018-04-29T09:30:00") 453// date and time("2018-04-29T09:30:00") 454 455date and time("2018-04-29T09:30:00+02:00") 456// date and time("2018-04-29T09:30:00+02:00") 457 458date and time("2018-04-29T09:30:00@Europe/Berlin") 459// date and time("2018-04-29T09:30:00@Europe/Berlin") 460 461date and time("2018-04-29T09:30:00+02:00[Europe/Berlin]") 462// date and time("2018-04-29T09:30:00@Europe/Berlin") 463</code></pre> 464`},{name:"date and time",type:"function",params:[{name:"date"},{name:"time"}],info:`<p>Returns a date and time from the given components.</p> 465<p><strong>Function signature</strong></p> 466<pre><code class="language-feel">date and time(date: date, time: time): date and time 467</code></pre> 468<pre><code class="language-feel">date and time(date: date and time, time: time): date and time 469</code></pre> 470<p>Returns a date and time value that consists of the date component of <code>date</code> combined with <code>time</code>.</p> 471<p><strong>Examples</strong></p> 472<pre><code class="language-feel">date and time(date("2012-12-24"),time("T23:59:00")) 473// date and time("2012-12-24T23:59:00") 474 475date and time(date and time("2012-12-25T11:00:00"),time("T23:59:00")) 476// date and time("2012-12-25T23:59:00") 477</code></pre> 478`},{name:"duration",type:"function",params:[{name:"from"}],info:`<p>Parses the given string into a duration. The duration is either a days and time duration or a years and months duration.</p> 479<p><strong>Function signature</strong></p> 480<pre><code class="language-feel">duration(from: string): days and time duration 481</code></pre> 482<pre><code class="language-feel">duration(from: string): years and months duration 483</code></pre> 484<p><strong>Examples</strong></p> 485<pre><code class="language-feel">duration("P5D") 486// duration("P5D") 487 488duration("P32Y") 489// duration("P32Y") 490</code></pre> 491`},{name:"years and months duration",type:"function",params:[{name:"from"},{name:"to"}],info:`<p>Returns the years and months duration between <code>from</code> and <code>to</code>.</p> 492<p><strong>Function signature</strong></p> 493<pre><code class="language-feel">years and months duration(from: date, to: date): years and months duration 494</code></pre> 495<p><strong>Examples</strong></p> 496<pre><code class="language-feel">years and months duration(date("2011-12-22"), date("2013-08-24")) 497// duration("P1Y8M") 498</code></pre> 499`},{name:"from json",type:"function",params:[{name:"value"}],info:`<p>Parses a JSON string into a FEEL value. The function converts JSON primitives, objects, and arrays into their corresponding FEEL types.</p> 500<p>Returns <code>null</code> if the string is not a valid JSON value.</p> 501<p><strong>Function signature</strong></p> 502<pre><code class="language-feel">from json(value: string): Any 503</code></pre> 504<p><strong>Examples</strong></p> 505<pre><code class="language-feel">from json("{\\"a\\": 1, \\"b\\": 2}") 506// {a: 1, b: 2} 507 508from json("true") 509// true 510 511from json("\\"2023-06-14\\"") 512// "2023-06-14" 513</code></pre> 514`,engines:{camunda:">=8.9"}},{name:"to json",type:"function",params:[{name:"value"}],info:`<p>Converts a FEEL value into a JSON string. The function converts FEEL primitives, contexts, and lists into their 515corresponding JSON types. Temporal values are converted to their ISO 8601 string representation, including timezone 516information for date and time values (format: <code>2025-11-24T10:00:00+01:00[Europe/Berlin]</code>).</p> 517<p><strong>Function signature</strong></p> 518<pre><code class="language-feel">to json(value: Any): string 519</code></pre> 520<p><strong>Examples</strong></p> 521<pre><code class="language-feel">to json({a: 1, b: 2}) 522// "{\\"a\\":1,\\"b\\":2}" 523 524to json(true) 525// "true" 526 527to json(@"2023-06-14") 528// "\\"2023-06-14\\"" 529 530to json(@"2025-11-24T10:00:00@Europe/Berlin") 531// "\\"2025-11-24T10:00:00+01:00[Europe/Berlin]\\"" 532 533to json(@"P3Y") 534// "\\"P3Y\\"" 535</code></pre> 536`,engines:{camunda:">=8.9"}},{name:"list contains",type:"function",params:[{name:"list"},{name:"element"}],info:`<p>Returns <code>true</code> if the given list contains the element. Otherwise, returns <code>false</code>.</p> 537<p><strong>Function signature</strong></p> 538<pre><code class="language-feel">list contains(list: list, element: Any): boolean 539</code></pre> 540<p><strong>Examples</strong></p> 541<pre><code class="language-feel">list contains([1,2,3], 2) 542// true 543</code></pre> 544`},{name:"count",type:"function",params:[{name:"list"}],info:`<p>Returns the number of elements of the given list.</p> 545<p><strong>Function signature</strong></p> 546<pre><code class="language-feel">count(list: list): number 547</code></pre> 548<p><strong>Examples</strong></p> 549<pre><code class="language-feel">count([1,2,3]) 550// 3 551</code></pre> 552`},{name:"min",type:"function",params:[{name:"list"}],info:`<p>Returns the minimum of the given list.</p> 553<p><strong>Function signature</strong></p> 554<pre><code class="language-feel">min(list: list): Any 555</code></pre> 556<p>All elements in <code>list</code> should have the same type and be comparable.</p> 557<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p> 558<p><strong>Examples</strong></p> 559<pre><code class="language-feel">min([1,2,3]) 560// 1 561 562min(1,2,3) 563// 1 564</code></pre> 565`},{name:"max",type:"function",params:[{name:"list"}],info:`<p>Returns the maximum of the given list.</p> 566<p><strong>Function signature</strong></p> 567<pre><code class="language-feel">max(list: list): Any 568</code></pre> 569<p>All elements in <code>list</code> should have the same type and be comparable.</p> 570<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p> 571<p><strong>Examples</strong></p> 572<pre><code class="language-feel">max([1,2,3]) 573// 3 574 575max(1,2,3) 576// 3 577</code></pre> 578`},{name:"sum",type:"function",params:[{name:"list"}],info:`<p>Returns the sum of the given list of numbers.</p> 579<p><strong>Function signature</strong></p> 580<pre><code class="language-feel">sum(list: list<number>): number 581</code></pre> 582<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p> 583<p><strong>Examples</strong></p> 584<pre><code class="language-feel">sum([1,2,3]) 585// 6 586 587sum(1,2,3) 588// 6 589</code></pre> 590`},{name:"product",type:"function",params:[{name:"list"}],info:`<p>Returns the product of the given list of numbers.</p> 591<p><strong>Function signature</strong></p> 592<pre><code class="language-feel">product(list: list<number>): number 593</code></pre> 594<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p> 595<p><strong>Examples</strong></p> 596<pre><code class="language-feel">product([2, 3, 4]) 597// 24 598 599product(2, 3, 4) 600// 24 601</code></pre> 602`},{name:"mean",type:"function",params:[{name:"list"}],info:`<p>Returns the arithmetic mean (i.e. average) of the given list of numbers.</p> 603<p><strong>Function signature</strong></p> 604<pre><code class="language-feel">mean(list: list<number>): number 605</code></pre> 606<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p> 607<p><strong>Examples</strong></p> 608<pre><code class="language-feel">mean([1,2,3]) 609// 2 610 611mean(1,2,3) 612// 2 613</code></pre> 614`},{name:"median",type:"function",params:[{name:"list"}],info:`<p>Returns the median element of the given list of numbers.</p> 615<p><strong>Function signature</strong></p> 616<pre><code class="language-feel">median(list: list<number>): number 617</code></pre> 618<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p> 619<p><strong>Examples</strong></p> 620<pre><code class="language-feel">median(8, 2, 5, 3, 4) 621// 4 622 623median([6, 1, 2, 3]) 624// 2.5 625</code></pre> 626`},{name:"stddev",type:"function",params:[{name:"list"}],info:`<p>Returns the standard deviation of the given list of numbers.</p> 627<p><strong>Function signature</strong></p> 628<pre><code class="language-feel">stddev(list: list<number>): number 629</code></pre> 630<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p> 631<p><strong>Examples</strong></p> 632<pre><code class="language-feel">stddev(2, 4, 7, 5) 633// 2.0816659994661326 634 635stddev([2, 4, 7, 5]) 636// 2.0816659994661326 637</code></pre> 638`},{name:"mode",type:"function",params:[{name:"list"}],info:`<p>Returns the mode of the given list of numbers.</p> 639<p><strong>Function signature</strong></p> 640<pre><code class="language-feel">mode(list: list<number>): number 641</code></pre> 642<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p> 643<p><strong>Examples</strong></p> 644<pre><code class="language-feel">mode(6, 3, 9, 6, 6) 645// [6] 646 647mode([6, 1, 9, 6, 1]) 648// [1, 6] 649</code></pre> 650`},{name:"all",type:"function",params:[{name:"list"}],info:`<p>Returns <code>false</code> if any element of the given list is <code>false</code>. Otherwise, returns <code>true</code>.</p> 651<p>If the given list is empty, it returns <code>true</code>.</p> 652<p><strong>Function signature</strong></p> 653<pre><code class="language-feel">all(list: list<boolean>): boolean 654</code></pre> 655<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p> 656<p><strong>Examples</strong></p> 657<pre><code class="language-feel">all([true,false]) 658// false 659 660all(false,null,true) 661// false 662</code></pre> 663<p>:::info 664The function <code>all()</code> replaced the previous function <code>and()</code>. The previous function is deprecated and 665should not be used anymore. 666:::</p> 667`},{name:"any",type:"function",params:[{name:"list"}],info:`<p>Returns <code>true</code> if any element of the given list is <code>true</code>. Otherwise, returns <code>false</code>.</p> 668<p>If the given list is empty, it returns <code>false</code>.</p> 669<p><strong>Function signature</strong></p> 670<pre><code class="language-feel">any(list: list<boolean>): boolean 671</code></pre> 672<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p> 673<p><strong>Examples</strong></p> 674<pre><code class="language-feel">any([false,true]) 675// true 676 677any(false,null,true) 678// true 679</code></pre> 680<p>:::info 681The function <code>any()</code> replaced the previous function <code>or()</code>. The previous function is deprecated and 682should not be used anymore. 683:::</p> 684`},{name:"sublist",type:"function",params:[{name:"list"},{name:"start position"}],info:`<p>Returns a partial list of the given value starting at <code>start position</code>.</p> 685<p><strong>Function signature</strong></p> 686<pre><code class="language-feel">sublist(list: list, start position: number): list 687</code></pre> 688<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p> 689<p><strong>Examples</strong></p> 690<pre><code class="language-feel">sublist([1,2,3], 2) 691// [2,3] 692</code></pre> 693`},{name:"sublist",type:"function",params:[{name:"list"},{name:"start position"},{name:"length"}],info:`<p>Returns a partial list of the given value starting at <code>start position</code>.</p> 694<p><strong>Function signature</strong></p> 695<pre><code class="language-feel">sublist(list: list, start position: number, length: number): list 696</code></pre> 697<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p> 698<p><strong>Examples</strong></p> 699<pre><code class="language-feel">sublist([1,2,3], 1, 2) 700// [1,2] 701</code></pre> 702`},{name:"append",type:"function",params:[{name:"list"},{name:"items"}],info:`<p>Returns the given list with all <code>items</code> appended.</p> 703<p><strong>Function signature</strong></p> 704<pre><code class="language-feel">append(list: list, items: Any): list 705</code></pre> 706<p>The parameter <code>items</code> can be a single element or a sequence of elements.</p> 707<p><strong>Examples</strong></p> 708<pre><code class="language-feel">append([1], 2, 3) 709// [1,2,3] 710</code></pre> 711`},{name:"concatenate",type:"function",params:[{name:"lists"}],info:`<p>Returns a list that includes all elements of the given lists.</p> 712<p><strong>Function signature</strong></p> 713<pre><code class="language-feel">concatenate(lists: list): list 714</code></pre> 715<p>The parameter <code>lists</code> is a sequence of lists.</p> 716<p><strong>Examples</strong></p> 717<pre><code class="language-feel">concatenate([1,2],[3]) 718// [1,2,3] 719 720concatenate([1],[2],[3]) 721// [1,2,3] 722</code></pre> 723`},{name:"insert before",type:"function",params:[{name:"list"},{name:"position"},{name:"newItem"}],info:`<p>Returns the given list with <code>newItem</code> inserted at <code>position</code>.</p> 724<p><strong>Function signature</strong></p> 725<pre><code class="language-feel">insert before(list: list, position: number, newItem: Any): list 726</code></pre> 727<p>The <code>position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p> 728<p><strong>Examples</strong></p> 729<pre><code class="language-feel">insert before([1,3],1,2) 730// [2,1,3] 731</code></pre> 732`},{name:"remove",type:"function",params:[{name:"list"},{name:"position"}],info:`<p>Returns the given list without the element at <code>position</code>.</p> 733<p><strong>Function signature</strong></p> 734<pre><code class="language-feel">remove(list: list, position: number): list 735</code></pre> 736<p>The <code>position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p> 737<p><strong>Examples</strong></p> 738<pre><code class="language-feel">remove([1,2,3], 2) 739// [1,3] 740</code></pre> 741`},{name:"reverse",type:"function",params:[{name:"list"}],info:`<p>Returns the given list in revered order.</p> 742<p><strong>Function signature</strong></p> 743<pre><code class="language-feel">reverse(list: list): list 744</code></pre> 745<p><strong>Examples</strong></p> 746<pre><code class="language-feel">reverse([1,2,3]) 747// [3,2,1] 748</code></pre> 749`},{name:"index of",type:"function",params:[{name:"list"},{name:"match"}],info:`<p>Returns an ascending list of positions containing <code>match</code>.</p> 750<p><strong>Function signature</strong></p> 751<pre><code class="language-feel">index of(list: list, match: Any): list<number> 752</code></pre> 753<p><strong>Examples</strong></p> 754<pre><code class="language-feel">index of([1,2,3,2],2) 755// [2,4] 756</code></pre> 757`},{name:"union",type:"function",params:[{name:"list"}],info:`<p>Returns a list that includes all elements of the given lists without duplicates.</p> 758<p><strong>Function signature</strong></p> 759<pre><code class="language-feel">union(list: list): list 760</code></pre> 761<p>The parameter <code>list</code> is a sequence of lists.</p> 762<p><strong>Examples</strong></p> 763<pre><code class="language-feel">union([1,2],[2,3]) 764// [1,2,3] 765</code></pre> 766`},{name:"distinct values",type:"function",params:[{name:"list"}],info:`<p>Returns the given list without duplicates.</p> 767<p><strong>Function signature</strong></p> 768<pre><code class="language-feel">distinct values(list: list): list 769</code></pre> 770<p><strong>Examples</strong></p> 771<pre><code class="language-feel">distinct values([1,2,3,2,1]) 772// [1,2,3] 773</code></pre> 774`},{name:"flatten",type:"function",params:[{name:"list"}],info:`<p>Returns a list that includes all elements of the given list without nested lists.</p> 775<p><strong>Function signature</strong></p> 776<pre><code class="language-feel">flatten(list: list): list 777</code></pre> 778<p><strong>Examples</strong></p> 779<pre><code class="language-feel">flatten([[1,2],[[3]], 4]) 780// [1,2,3,4] 781</code></pre> 782`},{name:"sort",type:"function",params:[{name:"list"},{name:"precedes"}],info:`<p>Returns the given list sorted by the <code>precedes</code> function.</p> 783<p><strong>Function signature</strong></p> 784<pre><code class="language-feel">sort(list: list, precedes: function<(Any, Any) -> boolean>): list 785</code></pre> 786<p><strong>Examples</strong></p> 787<pre><code class="language-feel">sort(list: [3,1,4,5,2], precedes: function(x,y) x < y) 788// [1,2,3,4,5] 789</code></pre> 790`},{name:"string join",type:"function",params:[{name:"list"}],info:`<p>Joins a list of strings into a single string. This is similar to 791Java's <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)">joining</a> 792function.</p> 793<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is 794neither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p> 795<p><strong>Function signature</strong></p> 796<pre><code class="language-feel">string join(list: list<string>): string 797</code></pre> 798<p><strong>Examples</strong></p> 799<pre><code class="language-feel">string join(["a","b","c"]) 800// "abc" 801 802string join(["a",null,"c"]) 803// "ac" 804 805string join([]) 806// "" 807</code></pre> 808`},{name:"string join",type:"function",params:[{name:"list"},{name:"delimiter"}],info:`<p>Joins a list of strings into a single string. This is similar to 809Java's <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)">joining</a> 810function.</p> 811<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is 812neither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p> 813<p>The resulting string contains a <code>delimiter</code> between each element.</p> 814<p><strong>Function signature</strong></p> 815<pre><code class="language-feel">string join(list: list<string>, delimiter: string): string 816</code></pre> 817<p><strong>Examples</strong></p> 818<pre><code class="language-feel">string join(["a"], "X") 819// "a" 820 821string join(["a","b","c"], ", ") 822// "a, b, c" 823</code></pre> 824`},{name:"decimal",type:"function",params:[{name:"n"},{name:"scale"}],info:`<p>Rounds the given value at the given scale.</p> 825<p><strong>Function signature</strong></p> 826<pre><code class="language-feel">decimal(n: number, scale: number): number 827</code></pre> 828<p><strong>Examples</strong></p> 829<pre><code class="language-feel">decimal(1/3, 2) 830// .33 831 832decimal(1.5, 0) 833// 2 834</code></pre> 835`},{name:"floor",type:"function",params:[{name:"n"}],info:`<p>Rounds the given value with rounding mode flooring.</p> 836<p><strong>Function signature</strong></p> 837<pre><code class="language-feel">floor(n: number): number 838</code></pre> 839<p><strong>Examples</strong></p> 840<pre><code class="language-feel">floor(1.5) 841// 1 842 843floor(-1.5) 844// -2 845</code></pre> 846`},{name:"floor",type:"function",params:[{name:"n"},{name:"scale"}],info:`<p>Rounds the given value with rounding mode flooring at the given scale.</p> 847<p><strong>Function signature</strong></p> 848<pre><code class="language-feel">floor(n: number, scale: number): number 849</code></pre> 850<p><strong>Examples</strong></p> 851<pre><code class="language-feel">floor(-1.56, 1) 852// -1.6 853</code></pre> 854`},{name:"ceiling",type:"function",params:[{name:"n"}],info:`<p>Rounds the given value with rounding mode ceiling.</p> 855<p><strong>Function signature</strong></p> 856<pre><code class="language-feel">ceiling(n: number): number 857</code></pre> 858<p><strong>Examples</strong></p> 859<pre><code class="language-feel">ceiling(1.5) 860// 2 861 862ceiling(-1.5) 863// -1 864</code></pre> 865`},{name:"ceiling",type:"function",params:[{name:"n"},{name:"scale"}],info:`<p>Rounds the given value with rounding mode ceiling at the given scale.</p> 866<p><strong>Function signature</strong></p> 867<pre><code class="language-feel">ceiling(n: number, scale: number): number 868</code></pre> 869<p><strong>Examples</strong></p> 870<pre><code class="language-feel">ceiling(-1.56, 1) 871// -1.5 872</code></pre> 873`},{name:"round up",type:"function",params:[{name:"n"},{name:"scale"}],info:`<p>Rounds the given value with the rounding mode round-up at the given scale.</p> 874<p><strong>Function signature</strong></p> 875<pre><code class="language-feel">round up(n: number, scale: number): number 876</code></pre> 877<p><strong>Examples</strong></p> 878<pre><code class="language-feel">round up(5.5) 879// 6 880 881round up(-5.5) 882// -6 883 884round up(1.121, 2) 885// 1.13 886 887round up(-1.126, 2) 888// -1.13 889</code></pre> 890`},{name:"round down",type:"function",params:[{name:"n"},{name:"scale"}],info:`<p>Rounds the given value with the rounding mode round-down at the given scale.</p> 891<p><strong>Function signature</strong></p> 892<pre><code class="language-feel">round down(n: number, scale: number): number 893</code></pre> 894<p><strong>Examples</strong></p> 895<pre><code class="language-feel">round down(5.5, 0) 896// 5 897 898round down (-5.5, 0) 899// -5 900 901round down (1.121, 2) 902// 1.12 903 904round down (-1.126, 2) 905// -1.12 906</code></pre> 907`},{name:"round half up",type:"function",params:[{name:"n"},{name:"scale"}],info:`<p>Rounds the given value with the rounding mode round-half-up at the given scale.</p> 908<p><strong>Function signature</strong></p> 909<pre><code class="language-feel">round half up(n: number, scale: number): number 910</code></pre> 911<p><strong>Examples</strong></p> 912<pre><code class="language-feel">round half up(5.5, 0) 913// 6 914 915round half up(-5.5, 0) 916// -6 917 918round half up(1.121, 2) 919// 1.12 920 921round half up(-1.126, 2) 922// -1.13 923</code></pre> 924`},{name:"round half down",type:"function",params:[{name:"n"},{name:"scale"}],info:`<p>Rounds the given value with the rounding mode round-half-down at the given scale.</p> 925<p><strong>Function signature</strong></p> 926<pre><code class="language-feel">round half down(n: number, scale: number): number 927</code></pre> 928<p><strong>Examples</strong></p> 929<pre><code class="language-feel">round half down (5.5, 0) 930// 5 931 932round half down (-5.5, 0) 933// -5 934 935round half down (1.121, 2) 936// 1.12 937 938round half down (-1.126, 2) 939// -1.13 940</code></pre> 941`},{name:"abs",type:"function",params:[{name:"number"}],info:`<p>Returns the absolute value of the given numeric value.</p> 942<p><strong>Function signature</strong></p> 943<pre><code class="language-feel">abs(number: number): number 944</code></pre> 945<p><strong>Examples</strong></p> 946<pre><code class="language-feel">abs(10) 947// 10 948 949abs(-10) 950// 10 951</code></pre> 952`},{name:"modulo",type:"function",params:[{name:"dividend"},{name:"divisor"}],info:`<p>Returns the remainder of the division of dividend by divisor.</p> 953<p><strong>Function signature</strong></p> 954<pre><code class="language-feel">modulo(dividend: number, divisor: number): number 955</code></pre> 956<p><strong>Examples</strong></p> 957<pre><code class="language-feel">modulo(12, 5) 958// 2 959</code></pre> 960`},{name:"sqrt",type:"function",params:[{name:"number"}],info:`<p>Returns the square root of the given value.</p> 961<p><strong>Function signature</strong></p> 962<pre><code class="language-feel">sqrt(number: number): number 963</code></pre> 964<p><strong>Examples</strong></p> 965<pre><code class="language-feel">sqrt(16) 966// 4 967</code></pre> 968`},{name:"log",type:"function",params:[{name:"number"}],info:`<p>Returns the natural logarithm (base e) of the given value.</p> 969<p><strong>Function signature</strong></p> 970<pre><code class="language-feel">log(number: number): number 971</code></pre> 972<p><strong>Examples</strong></p> 973<pre><code class="language-feel">log(10) 974// 2.302585092994046 975</code></pre> 976`},{name:"exp",type:"function",params:[{name:"number"}],info:`<p>Returns the Euler\u2019s number e raised to the power of the given number .</p> 977<p><strong>Function signature</strong></p> 978<pre><code class="language-feel">exp(number: number): number 979</code></pre> 980<p><strong>Examples</strong></p> 981<pre><code class="language-feel">exp(5) 982// 148.4131591025766 983</code></pre> 984`},{name:"odd",type:"function",params:[{name:"number"}],info:`<p>Returns <code>true</code> if the given value is odd. Otherwise, returns <code>false</code>.</p> 985<p><strong>Function signature</strong></p> 986<pre><code class="language-feel">odd(number: number): boolean 987</code></pre> 988<p><strong>Examples</strong></p> 989<pre><code class="language-feel">odd(5) 990// true 991 992odd(2) 993// false 994</code></pre> 995`},{name:"even",type:"function",params:[{name:"number"}],info:`<p>Returns <code>true</code> if the given is even. Otherwise, returns <code>false</code>.</p> 996<p><strong>Function signature</strong></p> 997<pre><code class="language-feel">even(number: number): boolean 998</code></pre> 999<p><strong>Examples</strong></p> 1000<pre><code class="language-feel">even(5) 1001// false 1002 1003even(2) 1004// true 1005</code></pre> 1006`},{name:"before",type:"function",params:[{name:"point1"},{name:"point2"}],info:`<p><strong>Function signature</strong></p> 1007<pre><code class="language-feel">before(point1: Any, point2: Any): boolean 1008</code></pre> 1009<p><strong>Examples</strong></p> 1010<pre><code class="language-feel">before(1, 10) 1011// true 1012 1013before(10, 1) 1014// false 1015</code></pre> 1016`},{name:"before",type:"function",params:[{name:"range"},{name:"point"}],info:`<p><strong>Function signature</strong></p> 1017<pre><code class="language-feel">before(range: range, point: Any): boolean 1018</code></pre> 1019<p><strong>Examples</strong></p> 1020<pre><code class="language-feel">before([1..5], 10) 1021// true 1022</code></pre> 1023`},{name:"before",type:"function",params:[{name:"point"},{name:"range"}],info:`<p><strong>Function signature</strong></p> 1024<pre><code class="language-feel">before(point: Any, range: range): boolean 1025</code></pre> 1026<p><strong>Examples</strong></p> 1027<pre><code class="language-feel">before(1, [2..5]) 1028// true 1029</code></pre> 1030`},{name:"before",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1031<pre><code class="language-feel">before(range1: range, range2: range): boolean 1032</code></pre> 1033<p><strong>Examples</strong></p> 1034<pre><code class="language-feel">before([1..5], [6..10]) 1035// true 1036 1037before([1..5),[5..10]) 1038// true 1039</code></pre> 1040`},{name:"after",type:"function",params:[{name:"point1"},{name:"point2"}],info:`<p><strong>Function signature</strong></p> 1041<pre><code class="language-feel">after(point1: Any, point2: Any): boolean 1042</code></pre> 1043<p><strong>Examples</strong></p> 1044<pre><code class="language-feel">after(10, 1) 1045// true 1046 1047after(1, 10) 1048// false 1049</code></pre> 1050`},{name:"after",type:"function",params:[{name:"range"},{name:"point"}],info:`<p><strong>Function signature</strong></p> 1051<pre><code class="language-feel">after(range: range, point: Any): boolean 1052</code></pre> 1053<p><strong>Examples</strong></p> 1054<pre><code class="language-feel">after([1..5], 10) 1055// false 1056</code></pre> 1057`},{name:"after",type:"function",params:[{name:"point"},{name:"range"}],info:`<p><strong>Function signature</strong></p> 1058<pre><code class="language-feel">after(point: Any, range: range): boolean 1059</code></pre> 1060<p><strong>Examples</strong></p> 1061<pre><code class="language-feel">after(12, [2..5]) 1062// true 1063</code></pre> 1064`},{name:"after",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1065<pre><code class="language-feel">after(range1: range, range2: range): boolean 1066</code></pre> 1067<p><strong>Examples</strong></p> 1068<pre><code class="language-feel">after([6..10], [1..5]) 1069// true 1070 1071after([5..10], [1..5)) 1072// true 1073</code></pre> 1074`},{name:"meets",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1075<pre><code class="language-feel">meets(range1: range, range2: range): boolean 1076</code></pre> 1077<p><strong>Examples</strong></p> 1078<pre><code class="language-feel">meets([1..5], [5..10]) 1079// true 1080 1081meets([1..3], [4..6]) 1082// false 1083 1084meets([1..3], [3..5]) 1085// true 1086 1087meets([1..5], (5..8]) 1088// false 1089</code></pre> 1090`},{name:"met by",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1091<pre><code class="language-feel">met by(range1: range, range2: range): boolean 1092</code></pre> 1093<p><strong>Examples</strong></p> 1094<pre><code class="language-feel">met by([5..10], [1..5]) 1095// true 1096 1097met by([3..4], [1..2]) 1098// false 1099 1100met by([3..5], [1..3]) 1101// true 1102 1103met by((5..8], [1..5)) 1104// false 1105 1106met by([5..10], [1..5)) 1107// false 1108</code></pre> 1109`},{name:"overlaps",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1110<pre><code class="language-feel">overlaps(range1: range, range2: range): boolean 1111</code></pre> 1112<p><strong>Examples</strong></p> 1113<pre><code class="language-feel">overlaps([5..10], [1..6]) 1114// true 1115 1116overlaps((3..7], [1..4]) 1117// true 1118 1119overlaps([1..3], (3..6]) 1120// false 1121 1122overlaps((5..8], [1..5)) 1123// false 1124 1125overlaps([4..10], [1..5)) 1126// true 1127</code></pre> 1128`},{name:"overlaps before",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1129<pre><code class="language-feel">overlaps before(range1: range, range2: range): boolean 1130</code></pre> 1131<p><strong>Examples</strong></p> 1132<pre><code class="language-feel">overlaps before([1..5], [4..10]) 1133// true 1134 1135overlaps before([3..4], [1..2]) 1136// false 1137 1138overlaps before([1..3], (3..5]) 1139// false 1140 1141overlaps before([1..5), (3..8]) 1142// true 1143 1144overlaps before([1..5), [5..10]) 1145// false 1146</code></pre> 1147`},{name:"overlaps after",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1148<pre><code class="language-feel">overlaps after(range1: range, range2: range): boolean 1149</code></pre> 1150<p><strong>Examples</strong></p> 1151<pre><code class="language-feel">overlaps after([4..10], [1..5]) 1152// true 1153 1154overlaps after([3..4], [1..2]) 1155// false 1156 1157overlaps after([3..5], [1..3)) 1158// false 1159 1160overlaps after((5..8], [1..5)) 1161// false 1162 1163overlaps after([4..10], [1..5)) 1164// true 1165</code></pre> 1166`},{name:"finishes",type:"function",params:[{name:"point"},{name:"range"}],info:`<p><strong>Function signature</strong></p> 1167<pre><code class="language-feel">finishes(point: Any, range: range): boolean 1168</code></pre> 1169<p><strong>Examples</strong></p> 1170<pre><code class="language-feel">finishes(5, [1..5]) 1171// true 1172 1173finishes(10, [1..7]) 1174// false 1175</code></pre> 1176`},{name:"finishes",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1177<pre><code class="language-feel">finishes(range1: range, range2: range): boolean 1178</code></pre> 1179<p><strong>Examples</strong></p> 1180<pre><code class="language-feel">finishes([3..5], [1..5]) 1181// true 1182 1183finishes((1..5], [1..5)) 1184// false 1185 1186finishes([5..10], [1..10)) 1187// false 1188</code></pre> 1189`},{name:"finished by",type:"function",params:[{name:"range"},{name:"point"}],info:`<p><strong>Function signature</strong></p> 1190<pre><code class="language-feel">finished by(range: range, point: Any): boolean 1191</code></pre> 1192<p><strong>Examples</strong></p> 1193<pre><code class="language-feel">finished by([5..10], 10) 1194// true 1195 1196finished by([3..4], 2) 1197// false 1198</code></pre> 1199`},{name:"finished by",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1200<pre><code class="language-feel">finished by(range1: range, range2: range): boolean 1201</code></pre> 1202<p><strong>Examples</strong></p> 1203<pre><code class="language-feel">finished by([1..5], [3..5]) 1204// true 1205 1206finished by((5..8], [1..5)) 1207// false 1208 1209finished by([5..10], (1..10)) 1210// false 1211</code></pre> 1212`},{name:"includes",type:"function",params:[{name:"range"},{name:"point"}],info:`<p><strong>Function signature</strong></p> 1213<pre><code class="language-feel">includes(range: range, point: Any): boolean 1214</code></pre> 1215<p><strong>Examples</strong></p> 1216<pre><code class="language-feel">includes([5..10], 6) 1217// true 1218 1219includes([3..4], 5) 1220// false 1221</code></pre> 1222`},{name:"includes",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1223<pre><code class="language-feel">includes(range1: range, range2: range): boolean 1224</code></pre> 1225<p><strong>Examples</strong></p> 1226<pre><code class="language-feel">includes([1..10], [4..6]) 1227// true 1228 1229includes((5..8], [1..5)) 1230// false 1231 1232includes([1..10], [1..5)) 1233// true 1234</code></pre> 1235`},{name:"during",type:"function",params:[{name:"point"},{name:"range"}],info:`<p><strong>Function signature</strong></p> 1236<pre><code class="language-feel">during(point: Any, range: range): boolean 1237</code></pre> 1238<p><strong>Examples</strong></p> 1239<pre><code class="language-feel">during(5, [1..10]) 1240// true 1241 1242during(12, [1..10]) 1243// false 1244 1245during(1, (1..10]) 1246// false 1247</code></pre> 1248`},{name:"during",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1249<pre><code class="language-feel">during(range1: range, range2: range): boolean 1250</code></pre> 1251<p><strong>Examples</strong></p> 1252<pre><code class="language-feel">during([4..6], [1..10)) 1253// true 1254 1255during((1..5], (1..10]) 1256// true 1257</code></pre> 1258`},{name:"starts",type:"function",params:[{name:"point"},{name:"range"}],info:`<p><strong>Function signature</strong></p> 1259<pre><code class="language-feel">starts(point: Any, range: range): boolean 1260</code></pre> 1261<p><strong>Examples</strong></p> 1262<pre><code class="language-feel">starts(1, [1..5]) 1263// true 1264 1265starts(1, (1..8]) 1266// false 1267</code></pre> 1268`},{name:"starts",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1269<pre><code class="language-feel">starts(range1: range, range2: range): boolean 1270</code></pre> 1271<p><strong>Examples</strong></p> 1272<pre><code class="language-feel">starts((1..5], [1..5]) 1273// false 1274 1275starts([1..10], [1..5]) 1276// false 1277 1278starts((1..5), (1..10)) 1279// true 1280</code></pre> 1281`},{name:"started by",type:"function",params:[{name:"range"},{name:"point"}],info:`<p><strong>Function signature</strong></p> 1282<pre><code class="language-feel">started by(range: range, point: Any): boolean 1283</code></pre> 1284<p><strong>Examples</strong></p> 1285<pre><code class="language-feel">started by([1..10], 1) 1286// true 1287 1288started by((1..10], 1) 1289// false 1290</code></pre> 1291`},{name:"started by",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1292<pre><code class="language-feel">started by(range1: range, range2: range): boolean 1293</code></pre> 1294<p><strong>Examples</strong></p> 1295<pre><code class="language-feel">started by([1..10], [1..5]) 1296// true 1297 1298started by((1..10], [1..5)) 1299// false 1300 1301started by([1..10], [1..10)) 1302// true 1303</code></pre> 1304`},{name:"coincides",type:"function",params:[{name:"point1"},{name:"point2"}],info:`<p><strong>Function signature</strong></p> 1305<pre><code class="language-feel">coincides(point1: Any, point2: Any): boolean 1306</code></pre> 1307<p><strong>Examples</strong></p> 1308<pre><code class="language-feel">coincides(5, 5) 1309// true 1310 1311coincides(3, 4) 1312// false 1313</code></pre> 1314`},{name:"coincides",type:"function",params:[{name:"range1"},{name:"range2"}],info:`<p><strong>Function signature</strong></p> 1315<pre><code class="language-feel">coincides(range1: range, range2: range): boolean 1316</code></pre> 1317<p><strong>Examples</strong></p> 1318<pre><code class="language-feel">coincides([1..5], [1..5]) 1319// true 1320 1321coincides((1..5], [1..5)) 1322// false 1323 1324coincides([1..5], [2..6]) 1325// false 1326</code></pre> 1327`},{name:"substring",type:"function",params:[{name:"string"},{name:"start position"}],info:`<p>Returns a substring of the given value starting at <code>start position</code>.</p> 1328<p><strong>Function signature</strong></p> 1329<pre><code class="language-feel">substring(string: string, start position: number): string 1330</code></pre> 1331<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p> 1332<p><strong>Examples</strong></p> 1333<pre><code class="language-feel">substring("foobar", 3) 1334// "obar" 1335 1336substring("foobar", -2) 1337// "ar" 1338</code></pre> 1339`},{name:"substring",type:"function",params:[{name:"string"},{name:"start position"},{name:"length"}],info:`<p>Returns a substring of the given value, starting at <code>start position</code> with the given <code>length</code>. If <code>length</code> is greater than 1340the remaining characters of the value, it returns all characters from <code>start position</code> until the end.</p> 1341<p><strong>Function signature</strong></p> 1342<pre><code class="language-feel">substring(string: string, start position: number, length: number): string 1343</code></pre> 1344<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p> 1345<p><strong>Examples</strong></p> 1346<pre><code class="language-feel">substring("foobar", 3, 3) 1347// "oba" 1348 1349substring("foobar", -3, 2) 1350// "ba" 1351 1352substring("foobar", 3, 10) 1353// "obar" 1354</code></pre> 1355`},{name:"string length",type:"function",params:[{name:"string"}],info:`<p>Returns the number of characters in the given value.</p> 1356<p><strong>Function signature</strong></p> 1357<pre><code class="language-feel">string length(string: string): number 1358</code></pre> 1359<p><strong>Examples</strong></p> 1360<pre><code class="language-feel">string length("foo") 1361// 3 1362</code></pre> 1363`},{name:"upper case",type:"function",params:[{name:"string"}],info:`<p>Returns the given value with all characters are uppercase.</p> 1364<p><strong>Function signature</strong></p> 1365<pre><code class="language-feel">upper case(string: string): string 1366</code></pre> 1367<p><strong>Examples</strong></p> 1368<pre><code class="language-feel">upper case("aBc4") 1369// "ABC4" 1370</code></pre> 1371`},{name:"lower case",type:"function",params:[{name:"string"}],info:`<p>Returns the given value with all characters are lowercase.</p> 1372<p><strong>Function signature</strong></p> 1373<pre><code class="language-feel">lower case(string: string): string 1374</code></pre> 1375<p><strong>Examples</strong></p> 1376<pre><code class="language-feel">lower case("aBc4") 1377// "abc4" 1378</code></pre> 1379`},{name:"substring before",type:"function",params:[{name:"string"},{name:"match"}],info:`<p>Returns a substring of the given value that contains all characters before <code>match</code>.</p> 1380<p><strong>Function signature</strong></p> 1381<pre><code class="language-feel">substring before(string: string, match: string): string 1382</code></pre> 1383<p><strong>Examples</strong></p> 1384<pre><code class="language-feel">substring before("foobar", "bar") 1385// "foo" 1386</code></pre> 1387`},{name:"substring after",type:"function",params:[{name:"string"},{name:"match"}],info:`<p>Returns a substring of the given value that contains all characters after <code>match</code>.</p> 1388<p><strong>Function signature</strong></p> 1389<pre><code class="language-feel">substring after(string: string, match: string): string 1390</code></pre> 1391<p><strong>Examples</strong></p> 1392<pre><code class="language-feel">substring after("foobar", "ob") 1393// "ar" 1394</code></pre> 1395`},{name:"contains",type:"function",params:[{name:"string"},{name:"match"}],info:`<p>Returns <code>true</code> if the given value contains the substring <code>match</code>. Otherwise, returns <code>false</code>.</p> 1396<p><strong>Function signature</strong></p> 1397<pre><code class="language-feel">contains(string: string, match: string): boolean 1398</code></pre> 1399<p><strong>Examples</strong></p> 1400<pre><code class="language-feel">contains("foobar", "of") 1401// false 1402</code></pre> 1403`},{name:"starts with",type:"function",params:[{name:"string"},{name:"match"}],info:`<p>Returns <code>true</code> if the given value starts with the substring <code>match</code>. Otherwise, returns <code>false</code>.</p> 1404<p><strong>Function signature</strong></p> 1405<pre><code class="language-feel">starts with(string: string, match: string): boolean 1406</code></pre> 1407<p><strong>Examples</strong></p> 1408<pre><code class="language-feel">starts with("foobar", "fo") 1409// true 1410</code></pre> 1411`},{name:"ends with",type:"function",params:[{name:"string"},{name:"match"}],info:`<p>Returns <code>true</code> if the given value ends with the substring <code>match</code>. Otherwise, returns <code>false</code>.</p> 1412<p><strong>Function signature</strong></p> 1413<pre><code class="language-feel">ends with(string: string, match: string): boolean 1414</code></pre> 1415<p><strong>Examples</strong></p> 1416<pre><code class="language-feel">ends with("foobar", "r") 1417// true 1418</code></pre> 1419`},{name:"matches",type:"function",params:[{name:"input"},{name:"pattern"}],info:`<p>Returns <code>true</code> if the given value matches the <code>pattern</code>. Otherwise, returns <code>false</code>.</p> 1420<p><strong>Function signature</strong></p> 1421<pre><code class="language-feel">matches(input: string, pattern: string): boolean 1422</code></pre> 1423<p>The <code>pattern</code> is a string that contains a regular expression.</p> 1424<p><strong>Examples</strong></p> 1425<pre><code class="language-feel">matches("foobar", "^fo*bar") 1426// true 1427</code></pre> 1428`},{name:"matches",type:"function",params:[{name:"input"},{name:"pattern"},{name:"flags"}],info:`<p>Returns <code>true</code> if the given value matches the <code>pattern</code>. Otherwise, returns <code>false</code>.</p> 1429<p><strong>Function signature</strong></p> 1430<pre><code class="language-feel">matches(input: string, pattern: string, flags: string): boolean 1431</code></pre> 1432<p>The <code>pattern</code> is a string that contains a regular expression.</p> 1433<p>The <code>flags</code> can contain one or more of the following characters:</p> 1434<ul> 1435<li><code>s</code> (dot-all)</li> 1436<li><code>m</code> (multi-line)</li> 1437<li><code>i</code> (case insensitive)</li> 1438<li><code>x</code> (comments)</li> 1439</ul> 1440<p><strong>Examples</strong></p> 1441<pre><code class="language-feel">matches("FooBar", "foo", "i") 1442// true 1443</code></pre> 1444`},{name:"replace",type:"function",params:[{name:"input"},{name:"pattern"},{name:"replacement"}],info:`<p>Returns the resulting string after replacing all occurrences of <code>pattern</code> with <code>replacement</code>.</p> 1445<p><strong>Function signature</strong></p> 1446<pre><code class="language-feel">replace(input: string, pattern: string, replacement: string): string 1447</code></pre> 1448<p>The <code>pattern</code> is a string that contains a regular expression.</p> 1449<p>The <code>replacement</code> can access the match groups by using <code>$</code> and the number of the group, for example, 1450<code>$1</code> to access the first group.</p> 1451<p><strong>Examples</strong></p> 1452<pre><code class="language-feel">replace("abcd", "(ab)|(a)", "[1=$1][2=$2]") 1453// "[1=ab][2=]cd" 1454 1455replace("0123456789", "(\\d{3})(\\d{3})(\\d{4})", "($1) $2-$3") 1456// "(012) 345-6789" 1457</code></pre> 1458`},{name:"replace",type:"function",params:[{name:"input"},{name:"pattern"},{name:"replacement"},{name:"flags"}],info:`<p>Returns the resulting string after replacing all occurrences of <code>pattern</code> with <code>replacement</code>.</p> 1459<p><strong>Function signature</strong></p> 1460<pre><code class="language-feel">replace(input: string, pattern: string, replacement: string, flags: string): string 1461</code></pre> 1462<p>The <code>pattern</code> is a string that contains a regular expression.</p> 1463<p>The <code>replacement</code> can access the match groups by using <code>$</code> and the number of the group, for example, 1464<code>$1</code> to access the first group.</p> 1465<p>The <code>flags</code> can contain one or more of the following characters:</p> 1466<ul> 1467<li><code>s</code> (dot-all)</li> 1468<li><code>m</code> (multi-line)</li> 1469<li><code>i</code> (case insensitive)</li> 1470<li><code>x</code> (comments)</li> 1471</ul> 1472<p><strong>Examples</strong></p> 1473<pre><code class="language-feel">replace("How do you feel?", "Feel", "FEEL", "i") 1474// "How do you FEEL?" 1475</code></pre> 1476`},{name:"split",type:"function",params:[{name:"string"},{name:"delimiter"}],info:`<p>Splits the given value into a list of substrings, breaking at each occurrence of the <code>delimiter</code> pattern.</p> 1477<p><strong>Function signature</strong></p> 1478<pre><code class="language-feel">split(string: string, delimiter: string): list<string> 1479</code></pre> 1480<p>The <code>delimiter</code> is a string that contains a regular expression.</p> 1481<p><strong>Examples</strong></p> 1482<pre><code class="language-feel">split("John Doe", "\\s" ) 1483// ["John", "Doe"] 1484 1485split("a;b;c;;", ";") 1486// ["a", "b", "c", "", ""] 1487</code></pre> 1488`},{name:"now",type:"function",params:[],info:`<p>Returns the current date and time including the timezone.</p> 1489<p><strong>Function signature</strong></p> 1490<pre><code class="language-feel">now(): date and time 1491</code></pre> 1492<p><strong>Examples</strong></p> 1493<pre><code class="language-feel">now() 1494// date and time("2020-07-31T14:27:30@Europe/Berlin") 1495</code></pre> 1496`},{name:"today",type:"function",params:[],info:`<p>Returns the current date.</p> 1497<p><strong>Function signature</strong></p> 1498<pre><code class="language-feel">today(): date 1499</code></pre> 1500<p><strong>Examples</strong></p> 1501<pre><code class="language-feel">today() 1502// date("2020-07-31") 1503</code></pre> 1504`},{name:"day of week",type:"function",params:[{name:"date"}],info:`<p>Returns the day of the week according to the Gregorian calendar. Note that it always returns the English name of the day.</p> 1505<p><strong>Function signature</strong></p> 1506<pre><code class="language-feel">day of week(date: date): string 1507</code></pre> 1508<pre><code class="language-feel">day of week(date: date and time): string 1509</code></pre> 1510<p><strong>Examples</strong></p> 1511<pre><code class="language-feel">day of week(date("2019-09-17")) 1512// "Tuesday" 1513 1514day of week(date and time("2019-09-17T12:00:00")) 1515// "Tuesday" 1516</code></pre> 1517`},{name:"day of year",type:"function",params:[{name:"date"}],info:`<p>Returns the Gregorian number of the day within the year.</p> 1518<p><strong>Function signature</strong></p> 1519<pre><code class="language-feel">day of year(date: date): number 1520</code></pre> 1521<pre><code class="language-feel">day of year(date: date and time): number 1522</code></pre> 1523<p><strong>Examples</strong></p> 1524<pre><code class="language-feel">day of year(date("2019-09-17")) 1525// 260 1526 1527day of year(date and time("2019-09-17T12:00:00")) 1528// 260 1529</code></pre> 1530`},{name:"week of year",type:"function",params:[{name:"date"}],info:`<p>Returns the Gregorian number of the week within the year, according to ISO 8601.</p> 1531<p><strong>Function signature</strong></p> 1532<pre><code class="language-feel">week of year(date: date): number 1533</code></pre> 1534<pre><code class="language-feel">week of year(date: date and time): number 1535</code></pre> 1536<p><strong>Examples</strong></p> 1537<pre><code class="language-feel">week of year(date("2019-09-17")) 1538// 38 1539 1540week of year(date and time("2019-09-17T12:00:00")) 1541// 38 1542</code></pre> 1543`},{name:"month of year",type:"function",params:[{name:"date"}],info:`<p>Returns the month of the year according to the Gregorian calendar. Note that it always returns the English name of the month.</p> 1544<p><strong>Function signature</strong></p> 1545<pre><code class="language-feel">month of year(date: date): string 1546</code></pre> 1547<pre><code class="language-feel">month of year(date: date and time): string 1548</code></pre> 1549<p><strong>Examples</strong></p> 1550<pre><code class="language-feel">month of year(date("2019-09-17")) 1551// "September" 1552 1553month of year(date and time("2019-09-17T12:00:00")) 1554// "September" 1555</code></pre> 1556`},{name:"abs",type:"function",params:[{name:"n"}],info:`<p>Returns the absolute value of a given duration.</p> 1557<p><strong>Function signature</strong></p> 1558<pre><code class="language-feel">abs(n: days and time duration): days and time duration 1559</code></pre> 1560<pre><code class="language-feel">abs(n: years and months duration): years and months duration 1561</code></pre> 1562<p><strong>Examples</strong></p> 1563<pre><code class="language-feel">abs(duration("-PT5H")) 1564// "duration("PT5H")" 1565 1566abs(duration("PT5H")) 1567// "duration("PT5H")" 1568 1569abs(duration("-P2M")) 1570// duration("P2M") 1571</code></pre> 1572`}],tW=[{name:"is defined",type:"function",params:[{name:"value"}],info:`<p><em>Camunda Extension</em></p> 1573<p>Checks if a given value is not <code>null</code>. If the value is <code>null</code> then the function returns <code>false</code>. 1574Otherwise, the function returns <code>true</code>.</p> 1575<p>The function requires one argument. Calling <code>is defined()</code> without an argument is invalid.</p> 1576<p><strong>Function signature</strong></p> 1577<pre><code class="language-feel">is defined(value: Any): boolean 1578</code></pre> 1579<p><strong>Examples</strong></p> 1580<pre><code class="language-feel">is defined(1) 1581// true 1582 1583is defined(null) 1584// false 1585 1586is defined(x) 1587// false - if no variable "x" exists 1588 1589is defined(x.y) 1590// false - if no variable "x" exists or it doesn't have a property "y" 1591 1592is defined() 1593// error - expected one argument 1594</code></pre> 1595<p>:::caution Breaking change</p> 1596<p>This function worked differently in previous versions. It returned <code>true</code> if the value was <code>null</code>. 1597Since this version, the function returns <code>false</code> if the value is <code>null</code>.</p> 1598<p>:::</p> 1599`},{name:"get or else",type:"function",params:[{name:"value"},{name:"default"}],info:`<p><em>Camunda Extension</em></p> 1600<p>Return the provided value parameter if not <code>null</code>, otherwise return the default parameter</p> 1601<p><strong>Function signature</strong></p> 1602<pre><code class="language-feel">get or else(value: Any, default: Any): Any 1603</code></pre> 1604<p><strong>Examples</strong></p> 1605<pre><code class="language-feel">get or else("this", "default") 1606// "this" 1607 1608get or else(null, "default") 1609// "default" 1610 1611get or else(null, null) 1612// null 1613</code></pre> 1614`,engines:{camunda:">=8.3"}},{name:"assert",type:"function",params:[{name:"value"},{name:"condition"}],info:`<p><em>Camunda Extension</em></p> 1615<p>Verify that the given condition is met. If the condition is <code>true</code>, the function returns the value. 1616Otherwise, the evaluation fails with an error.</p> 1617<p><strong>Function signature</strong></p> 1618<pre><code class="language-feel">assert(value: Any, condition: Any) 1619</code></pre> 1620<p><strong>Examples</strong></p> 1621<pre><code class="language-feel">assert(x, x != null) 1622// "value" - if x is "value" 1623// error - if x is null or doesn't exist 1624 1625assert(x, x >= 0) 1626// 4 - if x is 4 1627// error - if x is less than zero 1628</code></pre> 1629`,engines:{camunda:">=8.3"}},{name:"assert",type:"function",params:[{name:"value"},{name:"condition"},{name:"cause"}],info:`<p><em>Camunda Extension</em></p> 1630<p>Verify that the given condition is met. If the condition is <code>true</code>, the function returns the value. 1631Otherwise, the evaluation fails with an error containing the given message.</p> 1632<p><strong>Function signature</strong></p> 1633<pre><code class="language-feel">assert(value: Any, condition: Any, cause: String) 1634</code></pre> 1635<p><strong>Examples</strong></p> 1636<pre><code class="language-feel">assert(x, x != null, "'x' should not be null") 1637// "value" - if x is "value" 1638// error('x' should not be null) - if x is null or doesn't exist 1639 1640assert(x, x >= 0, "'x' should be positive") 1641// 4 - if x is 4 1642// error('x' should be positive) - if x is less than zero 1643</code></pre> 1644`,engines:{camunda:">=8.3"}},{name:"get value",type:"function",params:[{name:"context"},{name:"keys"}],info:`<p><em>Camunda Extension</em></p> 1645<p>Returns the value of the context entry for a context path defined by the given keys.</p> 1646<p>If <code>keys</code> contains the keys <code>[k1, k2]</code> then it returns the value at the nested entry <code>k1.k2</code> of the context.</p> 1647<p>If <code>keys</code> are empty or the nested entry defined by the keys doesn't exist in the context, it returns <code>null</code>.</p> 1648<p><strong>Function signature</strong></p> 1649<pre><code class="language-feel">get value(context: context, keys: list<string>): Any 1650</code></pre> 1651<p><strong>Examples</strong></p> 1652<pre><code class="language-feel">get value({x:1, y: {z:0}}, ["y", "z"]) 1653// 0 1654 1655get value({x: {y: {z:0}}}, ["x", "y"]) 1656// {z:0} 1657 1658get value({a: {b: 3}}, ["b"]) 1659// null 1660</code></pre> 1661`},{name:"context put",type:"function",params:[{name:"context"},{name:"key"},{name:"value"}],info:`<p>Adds a new entry with the given key and value to the context. Returns a new context that includes the entry.</p> 1662<p>If an entry for the same key already exists in the context, it overrides the value.</p> 1663<p><strong>Function signature</strong></p> 1664<pre><code class="language-feel">context put(context: context, key: string, value: Any): context 1665</code></pre> 1666<p><strong>Examples</strong></p> 1667<pre><code class="language-feel">context put({x:1}, "y", 2) 1668// {x:1, y:2} 1669</code></pre> 1670<p>:::info 1671The function <code>context put()</code> replaced the previous function <code>put()</code> (Camunda Extension). The 1672previous function is deprecated and should not be used anymore. 1673:::</p> 1674`},{name:"context merge",type:"function",params:[{name:"contexts"}],info:`<p>Union the given contexts. Returns a new context that includes all entries of the given contexts.</p> 1675<p>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.</p> 1676<p><strong>Function signature</strong></p> 1677<pre><code class="language-feel">context merge(contexts: list<context>): context 1678</code></pre> 1679<p><strong>Examples</strong></p> 1680<pre><code class="language-feel">context merge([{x:1}, {y:2}]) 1681// {x:1, y:2} 1682 1683context merge([{x:1, y: 0}, {y:2}]) 1684// {x:1, y:2} 1685</code></pre> 1686<p>:::info 1687The function <code>context merge()</code> replaced the previous function <code>put all()</code> (Camunda Extension). The 1688previous function is deprecated and should not be used anymore. 1689:::</p> 1690`,engines:{camunda:">=8.2"}},{name:"date and time",type:"function",params:[{name:"date"},{name:"timezone"}],info:`<p><em>Camunda Extension</em></p> 1691<p>Returns the given date and time value at the given timezone.</p> 1692<p>If <code>date</code> has a different timezone than <code>timezone</code> then it adjusts the time to match the local time of <code>timezone</code>.</p> 1693<p><strong>Function signature</strong></p> 1694<pre><code class="language-feel">date and time(date: date and time, timezone: string): date and time 1695</code></pre> 1696<p><strong>Examples</strong></p> 1697<pre><code class="language-feel">date and time(@"2020-07-31T14:27:30@Europe/Berlin", "America/Los_Angeles") 1698// date and time("2020-07-31T05:27:30@America/Los_Angeles") 1699 1700date and time(@"2020-07-31T14:27:30", "Z") 1701// date and time("2020-07-31T12:27:30Z") 1702</code></pre> 1703`},{name:"duplicate values",type:"function",params:[{name:"list"}],info:`<p><em>Camunda Extension</em></p> 1704<p>Returns all duplicate values of the given list.</p> 1705<p><strong>Function signature</strong></p> 1706<pre><code class="language-feel">duplicate values(list: list): list 1707</code></pre> 1708<p><strong>Examples</strong></p> 1709<pre><code class="language-feel">duplicate values([1,2,3,2,1]) 1710// [1,2] 1711</code></pre> 1712`,engines:{camunda:">=8.3"}},{name:"string join",type:"function",params:[{name:"list"},{name:"delimiter"},{name:"prefix"},{name:"suffix"}],info:`<p><em>Camunda Extension</em></p> 1713<p>Joins a list of strings into a single string. This is similar to 1714Java's <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)">joining</a> 1715function.</p> 1716<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is 1717neither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p> 1718<p>The resulting string starts with <code>prefix</code>, contains a <code>delimiter</code> between each element, and ends 1719with <code>suffix</code>.</p> 1720<p><strong>Function signature</strong></p> 1721<pre><code class="language-feel">string join(list: list<string>, delimiter: string, prefix: string, suffix: string): string 1722</code></pre> 1723<p><strong>Examples</strong></p> 1724<pre><code class="language-feel">string join(["a","b","c"], ", ", "[", "]") 1725// "[a, b, c]" 1726</code></pre> 1727`},{name:"is empty",type:"function",params:[{name:"list"}],info:`<p><em>Camunda Extension</em></p> 1728<p>Returns <code>true</code> if the given list is empty. Otherwise, returns <code>false</code>.</p> 1729<p><strong>Function signature</strong></p> 1730<pre><code class="language-feel">is empty(list: list): boolean 1731</code></pre> 1732<p><strong>Examples</strong></p> 1733<pre><code class="language-feel">is empty([]) 1734// true 1735 1736is empty([1,2,3]) 1737// false 1738</code></pre> 1739`,engines:{camunda:">=8.6"}},{name:"partition",type:"function",params:[{name:"list"},{name:"size"}],info:`<p><em>Camunda Extension</em></p> 1740<p>Returns consecutive sublists of a list, each of the same size (the final list may be smaller).</p> 1741<p>If <code>size</code> is less than <code>0</code>, it returns <code>null</code>.</p> 1742<p><strong>Function signature</strong></p> 1743<pre><code class="language-feel">partition(list: list, size: number): list 1744</code></pre> 1745<p><strong>Examples</strong></p> 1746<pre><code class="language-feel">partition([1,2,3,4,5], 2) 1747// [[1,2], [3,4], [5]] 1748 1749partition([], 2) 1750// [] 1751 1752partition([1,2], 0) 1753// null 1754</code></pre> 1755`,engines:{camunda:">=8.7"}},{name:"fromAi",type:"function",params:[{name:"value"}],info:`<p><em>Camunda Extension</em></p> 1756<p>Returns the unmodified <code>value</code> parameter.</p> 1757<ul> 1758<li>The purpose of this function is solely to tag the value as being generated by an AI integration.</li> 1759<li>The actual handling is not performed by the FEEL engine, but by a custom integration such as a connector or a job worker.</li> 1760</ul> 1761<p>The main use case of this function is for <a href="../../../connectors/out-of-the-box-connectors/agentic-ai-aiagent-tool-definitions.md">tool definitions</a> used by the <a href="../../../connectors/out-of-the-box-connectors/agentic-ai-aiagent.md">AI Agent connector</a>.</p> 1762<p>See the following function overloads for additional function parameters.</p> 1763<p><strong>Function signature</strong></p> 1764<pre><code class="language-feel">fromAi(value: Any): Any 1765</code></pre> 1766<p><strong>Examples</strong></p> 1767<pre><code class="language-feel">fromAi(toolCall.searchQuery) 1768// toolCall.searchQuery contents 1769 1770fromAi(toolCall.userId) 1771// toolCall.userId contents 1772</code></pre> 1773`,engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"}],info:`<p><em>Camunda Extension</em></p> 1774<p>Returns the unmodified <code>value</code> parameter.</p> 1775<p>In addition to the previous overload, it also accepts an optional <code>description</code> parameter to provide a textual description of the value. The description must be <code>null</code> or a string constant.</p> 1776<p><strong>Function signature</strong></p> 1777<pre><code class="language-feel">fromAi(value: Any, description: string): Any 1778</code></pre> 1779<p><strong>Examples</strong></p> 1780<pre><code class="language-feel">fromAi(toolCall.searchQuery, "The search query used to find the best match.") 1781// toolCall.searchQuery contents 1782 1783fromAi(toolCall.searchQuery, null) 1784// toolCall.searchQuery contents 1785</code></pre> 1786`,engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"},{name:"type"}],info:`<p><em>Camunda Extension</em></p> 1787<p>Returns the unmodified <code>value</code> parameter.</p> 1788<p>In addition to the previous overload, it also accepts an optional <code>type</code> parameter to provide type information about the value. The type must be <code>null</code> or a string constant.</p> 1789<p><strong>Function signature</strong></p> 1790<pre><code class="language-feel">fromAi(value: Any, description: string, type: string): Any 1791</code></pre> 1792<p><strong>Examples</strong></p> 1793<pre><code class="language-feel">fromAi(toolCall.searchQuery, "The search query used to find the best match.", "string") 1794// toolCall.searchQuery contents 1795 1796fromAi(toolCall.userId, "The user's ID", "number") 1797// toolCall.userId contents 1798 1799fromAi(toolCall.userId, null, "number") 1800// toolCall.userId contents 1801 1802fromAi(value: toolCall.userId, type: "number") 1803// toolCall.userId contents 1804</code></pre> 1805`,engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"},{name:"type"},{name:"schema"}],info:`<p><em>Camunda Extension</em></p> 1806<p>Returns the unmodified <code>value</code> parameter.</p> 1807<p>In addition to the previous overload, it also accepts an optional <code>schema</code> parameter to provide a (partial) <a href="https://json-schema.org/">JSON schema</a> for the value.</p> 1808<ul> 1809<li>The schema must be <code>null</code> or a context (map) containing only constant values. For example, function calls within the schema are not supported.</li> 1810<li>The schema is not validated by the FEEL engine but might be by a custom integration consuming the information.</li> 1811<li>From the engine side it is possible to specify both a <code>type</code> and a <code>schema</code>, and it depends on the integration as to which value takes precedence. The <a href="../../../connectors/out-of-the-box-connectors/agentic-ai-aiagent.md">AI Agent connector</a> will override any type specified in the schema if the <code>type</code> parameter is also provided.</li> 1812</ul> 1813<p><strong>Function signature</strong></p> 1814<pre><code class="language-feel">fromAi(value: Any, description: string, type: string, schema: context): Any 1815</code></pre> 1816<p><strong>Examples</strong></p> 1817<pre><code class="language-feel">fromAi(toolCall.documentType, "The document type to provide", "string", { 1818 enum: ["invoice", "receipt", "contract"] 1819}) 1820// toolCall.documentType contents 1821 1822fromAi(value: toolCall.documentType, description: "The document type to provide", schema: { 1823 type: "string", 1824 enum: ["invoice", "receipt", "contract"] 1825}) 1826// toolCall.documentType contents 1827 1828fromAi(toolCall.tags, "Tags to apply to the blog post", "array", { 1829 items: { 1830 type: "string" 1831 } 1832}) 1833// toolCall.tags contents 1834</code></pre> 1835`,engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"},{name:"type"},{name:"schema"},{name:"options"}],info:`<p><em>Camunda Extension</em></p> 1836<p>Returns the unmodified <code>value</code> parameter.</p> 1837<p>In addition to the previous overload, it also accepts an optional <code>options</code> parameter to provide additional options for the integration handling the value definition.</p> 1838<ul> 1839<li>The options parameter must be <code>null</code> or a context (map) containing only constant values. For example, function calls within options are not supported.</li> 1840</ul> 1841<p><strong>Function signature</strong></p> 1842<pre><code class="language-feel">fromAi(value: Any, description: string, type: string, schema: context, options: context): Any 1843</code></pre> 1844<p><strong>Examples</strong></p> 1845<pre><code class="language-feel">fromAi(toolCall.documentType, "The document type to provide", "string", null, { 1846 required: false 1847}) 1848// toolCall.documentType contents 1849 1850fromAi(value: toolCall.documentType, options: { 1851 required: false 1852}) 1853// toolCall.documentType contents 1854</code></pre> 1855`,engines:{camunda:">=8.8"}},{name:"random number",type:"function",params:[],info:`<p><em>Camunda Extension</em></p> 1856<p>Returns a random number between <code>0</code> and <code>1</code>.</p> 1857<p><strong>Function signature</strong></p> 1858<pre><code class="language-feel">random number(): number 1859</code></pre> 1860<p><strong>Examples</strong></p> 1861<pre><code class="language-feel">random number() 1862// 0.9701618132579795 1863</code></pre> 1864`,engines:{camunda:">=8.2"}},{name:"extract",type:"function",params:[{name:"string"},{name:"pattern"}],info:`<p><em>Camunda Extension</em></p> 1865<p>Returns all matches of the pattern in the given string. Returns an empty list if the pattern doesn't 1866match.</p> 1867<p><strong>Function signature</strong></p> 1868<pre><code class="language-feel">extract(string: string, pattern: string): list<string> 1869</code></pre> 1870<p>The <code>pattern</code> is a string that contains a regular expression.</p> 1871<p><strong>Examples</strong></p> 1872<pre><code class="language-feel">extract("references are 1234, 1256, 1378", "12[0-9]*") 1873// ["1234","1256"] 1874</code></pre> 1875`},{name:"trim",type:"function",params:[{name:"string"}],info:`<p><em>Camunda Extension</em></p> 1876<p>Returns the given string without leading and trailing spaces.</p> 1877<p><strong>Function signature</strong></p> 1878<pre><code class="language-feel">trim(string: string): string 1879</code></pre> 1880<p><strong>Examples</strong></p> 1881<pre><code class="language-feel">trim(" hello world ") 1882// "hello world" 1883 1884trim("hello world ") 1885// "hello world" 1886</code></pre> 1887`,engines:{camunda:">=8.6"}},{name:"uuid",type:"function",params:[],info:`<p><em>Camunda Extension</em></p> 1888<p>Returns a UUID (Universally Unique Identifier) with 36 characters.</p> 1889<p><strong>Function signature</strong></p> 1890<pre><code class="language-feel">uuid(): string 1891</code></pre> 1892<p><strong>Examples</strong></p> 1893<pre><code class="language-feel">uuid() 1894// "7793aab1-d761-4d38-916b-b7270e309894" 1895</code></pre> 1896`,engines:{camunda:">=8.6"}},{name:"to base64",type:"function",params:[{name:"value"}],info:`<p><em>Camunda Extension</em></p> 1897<p>Returns the given string encoded in Base64 format.</p> 1898<p><strong>Function signature</strong></p> 1899<pre><code class="language-feel">to base64(value: string): string 1900</code></pre> 1901<p><strong>Examples</strong></p> 1902<pre><code class="language-feel">to base64("FEEL") 1903// "RkVFTA==" 1904</code></pre> 1905`,engines:{camunda:">=8.6"}},{name:"is blank",type:"function",params:[{name:"string"}],info:`<p><em>Camunda Extension</em></p> 1906<p>Returns <code>true</code> if the given string is blank (empty or contains only whitespaces).</p> 1907<p><strong>Function signature</strong></p> 1908<pre><code class="language-feel">is blank(string: string): boolean 1909</code></pre> 1910<p><strong>Examples</strong></p> 1911<pre><code class="language-feel">is blank("") 1912// true 1913 1914is blank(" ") 1915// true 1916 1917is blank("hello world") 1918// false 1919</code></pre> 1920`,engines:{camunda:">=8.8"}},{name:"last day of month",type:"function",params:[{name:"date"}],info:`<p><em>Camunda Extension</em></p> 1921<p>Takes the month of the given date or date-time value and returns the last day of this month.</p> 1922<p><strong>Function signature</strong></p> 1923<pre><code class="language-feel">last day of month(date: date): date 1924</code></pre> 1925<pre><code class="language-feel">last day of month(date: date and time): date 1926</code></pre> 1927<p><strong>Examples</strong></p> 1928<pre><code class="language-feel">last day of month(date("2022-10-01")) 1929// date("2022-10-31")) 1930 1931last day of month(date and time("2022-10-16T12:00:00")) 1932// date("2022-10-31")) 1933</code></pre> 1934`,engines:{camunda:">=8.2"}}],GP=[...eW,...tW];var nW=[uP(VP())],iW=U.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}}),rW=U.baseTheme({"& .variableName":{color:"#10f"},"& .number":{color:"#164"},"& .string":{color:"#a11"},"& .bool":{color:"#219"},"& .function":{color:"#aa3731",fontWeight:"bold"},"& .control":{color:"#708"}}),oW=nM(uc.define([{tag:B.variableName,class:"variableName"},{tag:B.name,class:"variableName"},{tag:B.number,class:"number"},{tag:B.string,class:"string"},{tag:B.bool,class:"bool"},{tag:B.function(B.variableName),class:"function"},{tag:B.function(B.special(B.variableName)),class:"function"},{tag:B.controlKeyword,class:"control"},{tag:B.operatorKeyword,class:"control"}])),sW=[iW,rW,oW];function XP(n){return n&&n.from===n.to}function aW(n,e){let t=n.nextSibling;return XP(n)||t&&t.from===e&&XP(t)}function lW(n){return n&&n.parent&&n.parent.name==="VariableName"}function Y_(n){return n?n.name==="PathExpression"?!0:Y_(n.parent):!1}function cW({variables:n}){return e=>{let t=lt(e.state).resolve(e.pos,-1);if(!Y_(t))return null;let i=uW(t),r=t===i?e.pos:t.from,o=Z_(i,e),s=n;for(var a=0;a<o.length-1;a++){var l=s.find(f=>f.name===o[a].name);if(!l||l.isList!=="optional"&&!!l.isList!==o[a].isList)return null;s=l.entries}if(!s)return null;let c=s.map(f=>({label:f.name,type:"variable",info:f.info,detail:f.detail}));return{from:r,options:c}}}function uW(n){for(;n;){if(n.name==="PathExpression")return n;n=n.parent}}function Z_(n,e){let t=[];for(let i=n.firstChild;i;i=i.nextSibling)i.name==="PathExpression"?t.push(...Z_(i,e)):i.name==="FilterExpression"?t.push(...fW(i,e)):t.push({name:ZP(i,e),isList:!1});return t}function fW(n,e){let t=n.firstChild;if(t.name==="PathExpression"){let i=Z_(t,e),r=i[i.length-1];return r.isList=!0,i}return[{name:ZP(t,e),isList:!0}]}function ZP(n,e){return e.state.sliceDoc(n.from,n.to)}function hW({variables:n=[],builtins:e=[]}){let t=dW(n,e),i=/^[\w ]*$/;return t.length?r=>{let{pos:o,state:s}=r,a=lt(s).resolve(o,-1);if(aW(a,o))return r.explicit?{from:o,options:t,validFor:i}:null;if(!lW(a)||Y_(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 dW(n,e){return[].concat(n.map(t=>YP(t)),e.map(t=>YP(t)))}function YP(n,e){return n.type==="function"?pW(n,e):{label:n.name,type:"variable",info:n.info,detail:n.detail,boost:e}}function pW(n,e){let{name:t,info:i,detail:r,params:o=[]}=n,s=o.map(({name:u,type:f},h)=>({name:u||`param ${h+1}`,type:f})),a=`${t}(${s.map(u=>"${"+u.name+"}").join(", ")})`,l=s.map(({name:u,type:f})=>f?`${u}: ${f}`:u).join(", "),c=`${t}(${l})`;return li(a,{label:c,type:"function",info:i,detail:r,boost:e})}function mW({variables:n=[],builtins:e=[]}){return[cW({variables:n}),hW({variables:n,builtins:e}),pc(G_),...X_]}function gW(n){return KP(n)}function yW(n){return n.slice().reverse().reduce((e,t)=>(e[t.name]=()=>{},e),{})}var JP=H.define(),e2=H.define(),t2=H.define(),n2=H.define();function i2({dialect:n="expression",parserDialect:e,variables:t=[],builtins:i=[],completions:r=mW({builtins:i,variables:t})}){let o=yW([...t,...i]);return[t2.of(n),JP.of(i),e2.of(t),n2.of(e),gW({dialect:n,parserDialect:e,context:o,completions:r})]}function vW(n){let e=n.facet(JP)[0],t=n.facet(e2)[0],i=n.facet(t2)[0],r=n.facet(n2)[0];return{builtins:e,variables:t,dialect:i,parserDialect:r}}var xW=GP.map(n=>({...n,info:()=>te(n.info)})),r2=new Ns,o2=new Ns;function Ur({extensions:n=[],dialect:e="expression",parserDialect:t,container:i,contentAttributes:r={},tooltipContainer:o,onChange:s=()=>{},onKeyDown:a=()=>{},onLint:l=()=>{},placeholder:c="",readOnly:u=!1,value:f="",builtins:h=xW,variables:d=[]}){this._events=pP();let p=U.updateListener.of(v=>{v.docChanged&&s(v.state.doc.toString())}),m=U.updateListener.of(v=>{let x=v.transactions.flatMap(E=>E.effects).filter(E=>E.is(Kh));if(!x.length)return;let C=x.flatMap(E=>E.value);this._events.emit("lint",{diagnostics:C})}),g=U.domEventObservers({keydown:a});typeof o=="string"&&(o=document.querySelector(o));let b=o?DA({tooltipSpace:function(){return o.getBoundingClientRect()}}):[],_=[wM(),r2.of(i2({dialect:e,builtins:h,variables:d,parserDialect:t})),sM(),JA(),bM(),U.contentAttributes.of(r),p,g,sc.of([...oP]),nW,m,b,o2.of(Ab(c)),sW,...n];return u&&_.push(U.editable.of(!1)),this.on("lint",({diagnostics:v})=>l(v)),this._cmEditor=new U({state:Ze.create({doc:f,extensions:_}),parent:i}),this}Ur.prototype.setValue=function(n){this._cmEditor.dispatch({changes:{from:0,to:this._cmEditor.state.doc.length,insert:n}})};Ur.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}})}};Ur.prototype.on=function(n,e){this._events.on(n,e)};Ur.prototype.off=function(n,e){this._events.off(n,e)};Ur.prototype.getSelection=function(){return this._cmEditor.state.selection};Ur.prototype.setVariables=function(n){let e=vW(this._cmEditor.state);this._cmEditor.dispatch({effects:[r2.reconfigure(i2({...e,variables:n}))]})};Ur.prototype.setPlaceholder=function(n){this._cmEditor.dispatch({effects:o2.reconfigure(Ab(n))})};var Ri=class extends L{constructor(t,i){var r;super(t,i);M(this,"handleMouseEvent",t=>{t.stopPropagation()});M(this,"handleKeyDownCapture",t=>{if(t.key==="Enter"){if(_W(this.node)){t.triggeredFromAutocomplete=!0;return}this.props.ctrlForNewline&&!bW(t)&&t.preventDefault(),this.props.singleLine&&t.preventDefault()}});M(this,"handleKeyDown",t=>{["Enter","Escape"].includes(t.key)&&t.triggeredFromAutocomplete&&t.stopPropagation()});M(this,"handleChange",t=>{let{onInput:i}=this.props;this.setState({value:t}),i&&i(t)});M(this,"handleBlur",()=>{let{onBlur:t,onChange:i}=this.props;i&&this.state.value!==this.props.value&&i(this.state.value),t&&t()});M(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 Ur({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:[U.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)}),wW(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 y(1,"div",["literal-expression",this.props.className||""].join(" "),null,1,{onClick:this.handleMouseEvent,onFocusIn:this.props.onFocus,onFocusOut:this.handleBlur},null,this.setNode)}};function bW(n){return n.metaKey||n.ctrlKey}function _W(n){return n.querySelector(".cm-tooltip-autocomplete")}function wW(n,e){return JSON.stringify(n)===JSON.stringify(e)}var Yh=class extends L{constructor(t,i){super(t,i);M(this,"handleKeyDown",t=>{t.key==="Enter"&&t.stopPropagation()});this.translate=i.injector.get("translate"),this.expressionLanguages=i.injector.get("expressionLanguages",!1),this.variableResolver=i.injector.get("variableResolver",!1),this.handleValue=r=>{let o={text:r};this.handleChange(o)},this.handleLabelChange=r=>{var o=r||void 0;this.handleChange({label:o})}}handleChange(t){var{onChange:i}=this.props;typeof i=="function"&&i(t)}getExpressionEditorComponent(){return this.expressionLanguages&&this.expressionLanguages.getDefault("inputCell").value!=="feel"?Tn:Ri}_getVariables(){return this.variableResolver&&this.variableResolver.getVariables(this.props.element)}render(){let{label:t,text:i}=this.props,r=this.getExpressionEditorComponent(),o=this._getVariables();return y(1,"div","context-menu-container ref-input-editor input-edit",[y(1,"div","dms-form-control",P(2,Tn,{label:this.translate("Input label"),className:"dms-input-label",value:t||"",placeholder:this.translate("Input"),singleLine:!0,onInput:this.handleLabelChange}),2),y(1,"div","dms-form-control",[y(1,"label","dms-label",this.translate("Expression"),0),P(2,r,{label:this.translate("Input expression"),placeholder:this.translate("Enter expression"),className:["ref-text","dms-input"].join(" "),onInput:this.handleValue,value:i||"",variables:o})],4)],4,{onKeyDown:this.handleKeyDown})}};var _c=class extends L{constructor(t,i){super(t,i);M(this,"persistChanges",()=>{let{input:t}=this.props.context,{unsaved:i}=this.state;if(!i)return;let{label:r,...o}=i;var s={};"label"in i&&(s.label=r),CW(o)&&(s.inputExpression=o),this.modeling.updateProperties(t,s),this.setState({unsaved:!1})});M(this,"handleChange",t=>{this.setState({unsaved:{...this.state.unsaved,...t}},this.persistChanges)});this.state={},Ce(this),this.persistChanges=this.debounceInput(this.persistChanges)}getValue(t){let{input:i}=this.props.context,{unsaved:r}=this.state,o=i;return t==="text"&&(o=o.inputExpression),r&&t in r?r[t]:o.get(t)}render(){return P(2,Yh,{label:this.getValue("label"),text:this.getValue("text"),element:this.props.context.input,onChange:this.handleChange})}};_c.$inject=["debounceInput","modeling","injector"];function CW(n){return Object.keys(n).length}var Iy=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{let{col:i}=this.props;this._eventBus.fire("input.edit",{event:t,input:i})});this._translate=i.injector.get("translate"),this._eventBus=i.injector.get("eventBus")}render(){return y(1,"button","edit-button dmn-icon-edit",null,1,{"aria-label":this._translate("Edit input"),type:"button",onClick:this.onClick})}};var wc=class{constructor(e,t,i,r){e.onGetComponent("cell",({cellType:o})=>{if(o==="input-header")return fh}),e.onGetComponent("context-menu",(o={})=>{if(o.contextMenuType==="input-edit")return _c}),e.onGetComponent("cell-inner",(o={})=>{let{cellType:s}=o;if(s==="input-cell")return Iy}),i.on("input.edit",({event:o,input:s})=>{let{target:a}=o,l=De(a,"th",!0),{left:c,top:u}=l.getBoundingClientRect();t.open({x:c,y:u,align:"bottom-right"},{contextMenuType:"input-edit",input:s})})}};wc.$inject=["components","contextMenu","eventBus","renderer"];var pe=class extends L{constructor(t,i){super(t,i);M(this,"onChange",t=>{this.setState({value:t});let{onChange:i}=this.props;typeof i=="function"&&i(t)});M(this,"onInputClick",t=>{t.preventDefault(),t.stopPropagation(),this.setOptionsVisible(!this.state.optionsVisible),this.focusInput()});M(this,"onInput",t=>{let{value:i}=t.target;this.onChange(i)});M(this,"onOptionClick",(t,i)=>{i.preventDefault(),i.stopPropagation(),this.setOptionsVisible(!1),this.onChange(t),this.focusInput()});M(this,"onFocusChanged",t=>{this.checkClose(t.target)});M(this,"onGlobalClick",t=>{this.checkClose(t.target)});M(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))});M(this,"onKeyboard",t=>{let{optionsVisible:i}=this.state;if(i&&t===27)return this.setOptionsVisible(!1),!0});Ce(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();T(this._portalEl.style,i)}getOptionsBounds(){let t=this.renderer.getContainer(),{top:i,left:r,bottom:o}=t.getBoundingClientRect(),{top:s,left:a,width:l,height:c,bottom:u}=this.inputNode.getBoundingClientRect(),f=s+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(o-u<c){let p=o-s;d.bottom=`${p}px`,d["max-height"]=`calc(100% - ${p})`,delete d.top}return d}addPortalEl(){this._portalEl=te('<div class="dms-select-options"></div>'),this.renderer.getContainer().appendChild(this._portalEl),this._portalEl.addEventListener("mousedown",s2)}removePortalEl(){this._portalEl&&(this._portalEl.removeEventListener("mousedown",s2),Qe(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 o=i.filter(c=>c.value===r)[0],s=o?i.indexOf(o):-1,a=s===-1?t===1?0:i.length-1:(s+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 y(1,"div","options",t.map(r=>y(1,"div",["option",i===r?"active":""].join(" "),r.label,0,{"data-value":r.value,onClick:o=>this.onOptionClick(r.value,o)})),0)}render(){let{className:t,label:i,id:r,options:o,noInput:s,title:a}=this.props,{optionsVisible:l,value:c}=this.state,u=o?o.filter(h=>h.value===c)[0]:!1,f=u?u.label:c;return y(1,"div",[t||"","dms-input-select"].join(" "),[s?y(1,"div","dms-input",f,0,{"aria-label":i,tabIndex:"0",onKeyDown:this.onKeyDown},null,h=>this.inputNode=h):y(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),y(1,"span",["dms-input-select-icon",l?"dmn-icon-up":"dmn-icon-down"].join(" ")),l&&PC(this.renderOptions(o,u),this._portalEl)],0,{title:a,onClick:this.onInputClick},null,h=>this.parentNode=h)}};pe.$inject=["keyboard","renderer"];function s2(n){n.stopPropagation()}var Zh=class extends L{constructor(t,i){super(t);M(this,"onTypeChange",t=>{let i=this.getElement(),r=O(i,"dmn:LiteralExpression")?i.$parent:i,o;ie(r)?o={inputExpression:{typeRef:t}}:Te(r)&&(o={typeRef:t}),this._modeling.updateProperties(r,o)});this._translate=i.injector.get("translate"),this._modeling=i.injector.get("modeling"),this._dataTypes=i.injector.get("dataTypes")}getElement(){return this.props.context.input||this.props.context.output}render(){let t=this.getElement(),i=(O(t,"dmn:InputClause")?t.inputExpression:t).typeRef,r=this._dataTypes.getAll().map(s=>({label:this._translate(s),value:s})),o=this._translate("Type");return y(1,"div","type-ref-edit context-menu-container",y(1,"div","dms-form-control",[y(1,"label","dms-label",[o,Z(":")],0),P(2,pe,{className:"type-ref-edit-select",label:o,onChange:this.onTypeChange,options:r,value:i})],4),2)}};var EW=750,Cc=class{constructor(e){e.onGetComponent("context-menu",EW,(t={})=>{let{contextMenuType:i}=t;if(i==="input-edit"||i==="output-edit")return Zh})}};Cc.$inject=["components"];var a2={__depends__:[Gt,Xi],__init__:["typeRefEditingProvider"],typeRefEditingProvider:["type",Cc]};var Ec=class extends ae{constructor(e,t){super(e),this.postExecuted("element.updateProperties",i=>{let{element:r,properties:o}=i.context,s=ie(r)?o.inputExpression:o;if(s&&s.typeRef&&s.typeRef!=="string"){let a=O(r,"dmn:LiteralExpression")?r.$parent:r;t.editAllowedValues(a,null)}})}};Ec.$inject=["eventBus","modeling"];var SW="radio",OW="remove dmn-icon-clear",Js=class extends L{constructor(t,i){super(t,i);M(this,"getRemoveClickHandler",t=>i=>{i.stopPropagation(),this.removeItem(t)});M(this,"getToggleClickHandler",t=>i=>{i.stopPropagation(),this.toggleItem(t)});M(this,"removeItem",t=>{let{onChange:i}=this.props,r=this.state.items.filter(o=>o!==t);this.setState({items:r}),i&&i(r)});M(this,"toggleItem",t=>{let{onChange:i,type:r}=this.props,o=this.state.items.map(s=>(s===t?s.isChecked=!s.isChecked:r===SW&&(s.isChecked=!1),s));this.setState({items:o}),i&&i(o)});let{items:r}=t;this.state={items:r}}componentWillReceiveProps(t){let{items:i}=t;this.setState({items:i})}render(){let{className:t,items:i,type:r,labelComponent:o}=this.props,s=["dms-list-component"];t&&s.push(t);let a=ur(i,"group"),l=kW(a);return y(1,"div",s.join(" "),l.map(c=>{let u=c[0],f=c[1];return y(1,"div","group",[o&&o(u)||y(1,"h4","dms-heading",u,0),y(1,"ul","items no-wrap",f.map(h=>y(1,"li","item",[r&&y(64,"input","item-toggle",null,1,{type:r,checked:h.isChecked,onClick:this.getToggleClickHandler(h)}),Z("\xA0"),h.value,h.isRemovable&&y(1,"span",OW,null,1,{title:"Remove item",onClick:this.getRemoveClickHandler(h)})],0)),0)],0)}),0)}};function kW(n){let e=[];for(let t in n)e.push([t,n[t]]);return e}var ot=class extends L{constructor(e,t){super(e,t);let{validate:i,value:r}=e,o=i?i(r||""):void 0;this.state={validationWarning:o,value:r},this.onInput=this.onInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this)}componentWillReceiveProps(e){let{validate:t,value:i}=e,r=t?t(i||""):void 0;this.setState({validationWarning:r,value:i})}onInput(e){let{onInput:t,validate:i}=this.props,r=i?i(e):void 0;this.setState({validationWarning:r,value:e}),typeof t=="function"&&t&&t({isValid:!r,value:e})}onKeyDown(e){let{target:t}=e,{value:i}=t,{onKeyDown:r,validate:o}=this.props,s=o?o(i):void 0;typeof r=="function"&&r({isValid:!s,value:i,event:e})}onKeyUp(e){let{target:t}=e,{value:i}=t,{onKeyUp:r,validate:o}=this.props,s=o?o(i):void 0;typeof r=="function"&&r({isValid:!s,value:i,event:e})}render(){let{placeholder:e,type:t,className:i,label:r}=this.props,{validationWarning:o,value:s}=this.state,a=["dms-validated-input",i].join(" "),l=[];return o&&l.push("invalid"),y(1,"div",a,[P(2,St,{className:l,label:r,onInput:this.onInput,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,placeholder:e||"",type:t,value:s||""}),o&&y(1,"p","dms-hint dms-validation-warning",o,0)],0)}};function Ly(n){if(!n||RW(n.trim()))return{values:[]};let e=n.split(","),t={values:[]},i="";if(e.forEach(r=>{i+=r,/^"[^"]*"$/.test(i.trim())?(t.values.push(i.trim()),i=""):i+=","}),!i)return t}function RW(n){return n===""}function l2(n){return n.map(e=>e.value)}var Jh=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"setPredefinedValues",t=>{let i=this.getAllowedValuesTarget();this.setState({values:t}),this._modeling.editAllowedValues(i,t&&l2(t))});M(this,"onListChange",t=>{this.setPredefinedValues(t)});M(this,"onInput",({isValid:t,value:i})=>{this.setState({inputValue:i})});M(this,"onKeyDown",({isValid:t,event:i})=>{if(AW(i.keyCode)&&(i.stopPropagation(),i.preventDefault(),t)){let{inputValue:r,values:o}=this.state,s=Ly(r);this.onListChange((o||[]).concat(s.values.map(a=>({value:a,isCheckable:!1,isRemovable:!0,group:this._translate("Predefined values")})))),this.setState({inputValue:""})}});M(this,"handleRemovePredifinedValuesClick",t=>{t.stopPropagation(),this.removePredefinedValues()});M(this,"removePredefinedValues",()=>{this.setPredefinedValues(null)});this._translate=i.injector.get("translate"),this._modeling=i.injector.get("modeling"),this._changeSupport=i.changeSupport;let r=this.getAllowedValuesTarget(),o=Ly(r.inputValues&&r.inputValues.text||r.outputValues&&r.outputValues.text||"");o?this.state={values:o.values.map(s=>({value:s,isCheckable:!1,isRemovable:!0,group:this._translate("Predefined values")})),inputValue:""}:this.state={values:null,inputValue:""}}componentWillMount(){let t=this.getAllowedValuesTarget();this._changeSupport.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){let t=this.getAllowedValuesTarget();this._changeSupport.offElementsChanged(t.id,this.onElementsChanged)}getAllowedValuesTarget(){let t=this.getElement();return O(t,"dmn:LiteralExpression")?t.$parent:t}getElement(){return this.props.context.output||this.props.context.input.inputExpression}render(){let t=this.getElement(),{inputValue:i,values:r}=this.state;return t.typeRef==="string"?y(1,"div","context-menu-container allowed-values-edit",y(1,"div","dms-form-control",[!J_(r)&&r.length>0&&P(2,Js,{labelComponent:TW,items:r,onChange:this.onListChange}),!J_(r)&&!r.length&&y(1,"div",null,[y(1,"label","dms-label",this._translate("Predefined values"),0),y(1,"span","placeholder",this._translate("No values"),0)],4),!J_(r)&&y(1,"p","dms-hint",y(1,"button","del-values",this._translate("Clear predefined values"),0,{type:"button",onClick:this.handleRemovePredifinedValuesClick}),2),y(1,"label","dms-label",this._translate("Add predefined values"),0),P(2,ot,{onInput:this.onInput,onKeyDown:this.onKeyDown,placeholder:this._translate('"value", "value", ...'),type:"text",validate:o=>{if(!Ly(o))return this._translate("Strings must be in double quotes")},value:i})],0),2):null}};function TW(n){return y(1,"label","dms-label",n,0)}function AW(n){return n===13}function J_(n){return n===null}var MW=500,Sc=class{constructor(e){e.onGetComponent("context-menu",MW,(t={})=>{let{contextMenuType:i}=t;if(i==="input-edit"||i==="output-edit")return Jh})}};Sc.$inject=["components"];var c2={__init__:["allowedValuesUpdateBehavior","allowedValuesEditingProvider"],allowedValuesUpdateBehavior:["type",Ec],allowedValuesEditingProvider:["type",Sc]};var ed=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"handleClick",t=>{t.stopPropagation(),this.add()});M(this,"add",()=>{this._eventBus.fire("addInput")});this._sheet=i.injector.get("sheet"),this._eventBus=i.injector.get("eventBus"),this._changeSupport=i.changeSupport,this._translate=i.injector.get("translate")}componentWillMount(){let t=this.getRoot();this._changeSupport.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){let t=this.getRoot();this._changeSupport.offElementsChanged(t.id,this.onElementsChanged)}getRoot(){return this._sheet.getRoot()}render(){return y(1,"div","add-input actionable",y(1,"button","dmn-icon-plus action-icon",null,1,{title:this._translate("Add input")}),2,{onClick:this.handleClick})}};var td=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"handleClick",t=>{t.stopPropagation(),this.add()});M(this,"add",()=>{this._eventBus.fire("addOutput")});this._sheet=i.injector.get("sheet"),this._eventBus=i.injector.get("eventBus"),this._changeSupport=i.changeSupport,this._translate=i.injector.get("translate")}componentWillMount(){let t=this.getRoot();this._changeSupport.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){let t=this.getRoot();this._changeSupport.offElementsChanged(t.id,this.onElementsChanged)}getRoot(){return this._sheet.getRoot()}render(){return y(1,"div","add-output actionable",y(1,"button","dmn-icon-plus action-icon",null,1,{title:this._translate("Add output")}),2,{onClick:this.handleClick})}};function By(n,e,t){n.onGetComponent("cell-inner",(i={})=>{let{cellType:r,index:o,inputsLength:s,outputsLength:a}=i;if(r==="input-cell"&&o===s-1)return ed;if(r==="output-cell"&&o===a-1)return td}),t.on("addInput",()=>{e.trigger("addInput")}),t.on("addOutput",()=>{e.trigger("addOutput")})}By.$inject=["components","editorActions","eventBus"];var u2={__depends__:[Jn],__init__:["addInputOutputProvider"],addInputOutputProvider:["type",By]};var f2="Keyboard binding is now implicit; explicit binding to an element got removed. For more information, see https://github.com/bpmn-io/diagram-js/pull/662",Oc=class{constructor(e,t,i,r,o){M(this,"_init",()=>{this._registerDefaultBindings(),this._fire("init")});M(this,"_destroy",()=>{this._fire("destroy"),this.unbind(),this._listeners=null});M(this,"_keyHandler",e=>{var t,i,r=this._listeners,o=e.keyCode||e.charCode||-1;for(t=0;i=r[t];t++)if(i(o,e)){e.preventDefault(),e.stopPropagation();return}});M(this,"unbind",()=>{var e=this._node;e&&(this._fire("unbind"),q.unbind(e,"keydown",this._keyHandler)),this._node=null});this._config=e||{},this._editorActions=i,this._eventBus=t,this._cellSelection=r,this._listeners=[],t.on("table.destroy",this._destroy),t.on("table.init",this._init),t.on("attach",()=>{this._config.bindTo&&console.error("unsupported configuration <keyboard.bindTo>",new Error(f2)),this._target=o.getContainer();var s=this._config&&this._config.bind!==!1;s&&this.bind()}),t.on("detach",this.unbind)}bind(e){e&&console.error("unsupported argument <node>",new Error(f2)),this.unbind(),e=this._node=this._target,q.bind(e,"keydown",this._keyHandler),this._fire("bind")}getBinding(){return this._node}_fire(e){this._eventBus.fire("keyboard."+e,{node:this._node,listeners:this._listeners})}_registerDefaultBindings(){var e=this._listeners,t=this._editorActions,i=this._cellSelection;function r(l,c){if(Ir(c)&&!Lr(c)&&l===90)return t.trigger("undo"),!0}function o(l,c){if(Ir(c)&&(l===89||l===90&&Lr(c)))return t.trigger("redo"),!0}e.push(r),e.push(o);function s(l,c){if(!(l!==13||Ir(c)||!Lr(c))&&lh(c.target))return t.trigger("selectCellAbove"),!0}e.push(s);function a(l,c){if(l!==13||Ir(c)||Lr(c)||!lh(c.target))return;let u=t.trigger("selectCellBelow"),f=i.getCellSelection();if(!u&&f&&!PW(f)){let h=t.trigger("addRule");return t.trigger("selectCellBelow"),h}return!0}e.push(a)}addListener(e){this._listeners.unshift(e)}removeListener(e){this._listeners=this._listeners.filter(t=>t!==e)}};Oc.$inject=["config.keyboard","eventBus","editorActions","cellSelection","renderer"];function PW(n){return n==="__decisionProperties_name"}var Bt={__depends__:[Jn],__init__:["keyboard"],keyboard:["type",Oc]};var h2={__depends__:[u2,c2,Gt,Kt,Qt,Yn,Bt,a2],__init__:["inputEditingProvider","outputEditingProvider"],inputEditingProvider:["type",wc],outputEditingProvider:["type",Vl]};function ew(n,e,t){return(e=DW(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function DW(n){var e=IW(n,"string");return typeof e=="symbol"?e:e+""}function IW(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var LW=`.dmn-decision-table-container td, 1935 .dmn-decision-table-container th`,kc=class{constructor(e,t,i,r){ew(this,"handleDragOver",o=>{Ny(o);let s=o.target,a=De(s,LW,!0),l=!!a,{hoverEl:c}=this._dragContext;c&&c!==a&&(this._emit("dragAndDrop.dragLeave",o),this._dragContext.targetEl=null,this._dragContext.hoverEl=null),a&&(a!==c&&(this._dragContext.hoverEl=a,l=this._emit("dragAndDrop.dragEnter",o),l!==!1&&(this._dragContext.targetEl=a)),l=this._emit("dragAndDrop.dragOver",o)),o.dataTransfer.dropEffect=l!==!1?"move":"none"}),ew(this,"handleDrop",o=>{Ny(o);let s=this._emit("dragAndDrop.drop",o);if(s){let{draggedElement:a}=this._dragContext;if(a instanceof pt){let{rows:l}=this._sheet.getRoot(),c=l.indexOf(s);this._modeling.moveRow(a,c)}else if(a instanceof mt){let{cols:l}=this._sheet.getRoot(),c=l.indexOf(s);this._modeling.moveCol(a,c)}}this.handleDragEnd(o)}),ew(this,"handleDragEnd",o=>{Ny(o),this._unbindListeners(),this._emit("dragAndDrop.dragEnd",o),this._dragContext=null}),this._eventBus=e,this._renderer=t,this._modeling=i,this._sheet=r,this._dragContext=null,e.on("table.destroy",()=>{this._unbindListeners()})}_bindListeners(){q.bind(document,"dragover",this.handleDragOver),q.bind(document,"drop",this.handleDrop),q.bind(document,"dragend",this.handleDragEnd)}_unbindListeners(){q.unbind(document,"dragover",this.handleDragOver),q.unbind(document,"drop",this.handleDrop),q.unbind(document,"dragend",this.handleDragEnd)}_emit(e,t){return this._eventBus.fire(e,{dragContext:this._dragContext,originalEvent:t})}startDrag(e,t){Ny(t,!0),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData&&t.dataTransfer.setData("text","__DUMMY"),this._dragContext={draggedElement:e},this._bindListeners(),this._emit("dragAndDrop.dragStart",t)}};kc.$inject=["eventBus","renderer","modeling","sheet"];function Ny(n,e){n.stopPropagation(),e!==!0&&n.preventDefault()}var d2={__init__:["dragAndDrop"],dragAndDrop:["type",kc]};var nw="top",BW="right",NW="bottom",iw="left",Rc=class{constructor(e,t,i,r,o,s,a,l){M(this,"_cleanup",()=>{let e=this._renderer.getContainer();tw(e),qW(e),this._dragImage&&(Qe(this._dragImage),this._dragImage=null)});this._elementRegistry=t,this._dragAndDrop=r,this._renderer=o,this._rules=s,this._sheet=a,this._translate=l,e.onGetComponent("cell-inner",({cellType:c,col:u,row:f})=>{if(c==="rule-index")return()=>y(1,"span","dmn-icon-drag vertical",Z("\xA0"),2,{draggable:"true",onDragStart:h=>this.startDrag(f,h),title:this._translate("Move rule")});if(c==="input-cell"||c==="output-cell"){let h=`Move ${ie(u)?"Input":"Output"}`;return()=>y(1,"span","dmn-icon-drag horizontal",null,1,{draggable:"true",onDragStart:d=>this.startDrag(u,d),title:h})}}),i.on("dragAndDrop.dragEnter",c=>{let{dragContext:u}=c,{draggedElement:f,hoverEl:h}=u;if(f instanceof pt)return!0;if(f instanceof mt){let d=$W(h,this._elementRegistry,this._sheet);return d===-1?!1:this._rules.allowed("col.move",{col:f,index:d})}return!1}),i.on("dragAndDrop.dragLeave",c=>{let{dragContext:u}=c,{targetEl:f}=u;if(!f)return;let h=this._renderer.getContainer();tw(h)}),i.on("dragAndDrop.dragOver",c=>{let{dragContext:u,originalEvent:f}=c,{draggedElement:h,lastPosition:d,targetEl:p}=u,m=this._renderer.getContainer();if(!p)return!1;let g;return h instanceof pt&&(g=y2(f,p)),h instanceof mt&&(g=g2(f,p)),d===g||(tw(m),h instanceof pt&&(g===nw?p2(p,m,"top"):p2(p,m,"bottom")),h instanceof mt&&(g===iw?m2(p,m,"left"):m2(p,m,"right")),u.lastPosition=g),!0}),i.on("dragAndDrop.drop",c=>{let{dragContext:u,originalEvent:f}=c,{draggedElement:h,targetEl:d}=u;if(!d)return!1;if(h instanceof pt){let p=y2(f,d),m=d.dataset.rowId,g=this._elementRegistry.get(m);if(!g||g===h)return;let b=VW(h,g,p,this._sheet.getRoot().rows);return b===h?void 0:b}if(h instanceof mt){let p=g2(f,d),m=d.dataset.colId,g=this._elementRegistry.get(m);if(!g||g===h)return;let b=HW(h,g,p,this._sheet.getRoot().cols);return b===h?void 0:b}}),i.on("dragAndDrop.dragEnd",this._cleanup)}startDrag(e,t){let i=this._renderer.getContainer();this._dragImage=te(`<span style=" 1936 visibility: hidden; 1937 position: fixed; 1938 top: -10000px 1939 "></span>`),document.body.appendChild(this._dragImage),t.dataTransfer.setDragImage&&t.dataTransfer.setDragImage(this._dragImage,0,0),e instanceof pt?jW(e,i):e instanceof mt&&FW(e,i),this._dragAndDrop.startDrag(e,t)}};Rc.$inject=["components","elementRegistry","eventBus","dragAndDrop","renderer","rules","sheet","translate"];function $W(n,e,t){let i=e.get(n.dataset.colId);if(!i)return-1;let{cols:r}=t.getRoot();return r.indexOf(i)}function p2(n,e,t){let i=n.dataset.rowId;if(!i)return;let r=pn(`[data-row-id=${i}]`,e);k(r,o=>{Tc(o)&&(ee(o).add("dragover"),ee(o).add(t))})}function m2(n,e,t){let i=n.dataset.colId;if(!i)return;let r=pn(`[data-col-id=${i}]`,e);k(r,o=>{Tc(o)&&(ee(o).add("dragover"),ee(o).add(t))})}function tw(n){let e=pn(".dragover",n);k(e,t=>{Tc(t)&&(ee(t).remove("dragover"),ee(t).remove("top"),ee(t).remove("right"),ee(t).remove("bottom"),ee(t).remove("left"))})}function jW(n,e){let t=pn(`[data-row-id=${n.id}]`,e);k(t,i=>{Tc(i)&&ee(i).add("dragged")})}function FW(n,e){let t=pn(`[data-col-id=${n.id}]`,e);k(t,i=>{Tc(i)&&ee(i).add("dragged")})}function qW(n){let e=pn(".dragged",n);k(e,t=>{Tc(t)&&ee(t).remove("dragged")})}function g2(n,e){let t=e.getBoundingClientRect();return n.clientX<t.left+t.width/2?iw:BW}function y2(n,e){let t=e.getBoundingClientRect();return n.clientY<t.top+t.height/2?nw:NW}function VW(n,e,t,i){return i.indexOf(n)>i.indexOf(e)&&(e=WW(e,i)),t===nw?zW(e,i):e}function HW(n,e,t,i){return i.indexOf(n)>i.indexOf(e)&&(e=QW(e,i)),t===iw?UW(e,i):e}function zW(n,e){let t=e.indexOf(n);return e[Math.max(0,t-1)]}function WW(n,e){let t=e.indexOf(n);return e[Math.min(e.length-1,t+1)]}function UW(n,e){let t=e.indexOf(n);if(Te(n)){let i=e.filter(o=>Te(o))[0],r=e.indexOf(i);return e[Math.max(r,t-1)]}return e[Math.max(0,t-1)]}function QW(n,e){let t=e.indexOf(n);if(ie(n)){let i=e.filter(s=>ie(s)),r=i[i.length-1],o=e.indexOf(r);return e[Math.min(o,t+1)]}return e[Math.min(e.length-1,t+1)]}function Tc(n){return n&&(n.nodeType===1||n.nodeType==11)}var v2={__depends__:[d2,El],__init__:["dmnDragAndDrop"],dmnDragAndDrop:["type",Rc]};var nd=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"changeDescription",t=>{this._modeling.updateProperties(this._element,{description:t})});this._elementRegistry=i.injector.get("elementRegistry"),this._modeling=i.injector.get("modeling"),this._changeSupport=this.context.changeSupport;let{id:r}=this.props.context;this._element=this._elementRegistry.get(r)}componentWillMount(){this._element&&this._changeSupport.onElementsChanged(this._element.id,this.onElementsChanged)}componentDidMount(){let{autoFocus:t}=this.props.context;t&&this.node&&KW(this.node).focus()}componentWillUnmount(){if(this._element){this._changeSupport.offElementsChanged(this._element.id,this.onElementsChanged);let{businessObject:t}=this._element,{description:i}=t;Ie(i)&&!i.length&&this.changeDescription(null)}}render(){if(!this._element)return;let{businessObject:t}=this._element,{description:i}=t;if(Ie(i))return y(1,"div","context-menu-container description-editor",P(2,rw,{className:"dms-input",onChange:this.changeDescription,value:i}),2,null,null,r=>this.node=r)}},rw=class extends an{render(){return y(1,"div",this.getClassName(),this.getEditor(),0)}};function KW(n){return X(".content-editable",n)}var GW=500,XW=750,x2=26,Ac=class{constructor(e,t,i,r,o,s,a){M(this,"addDescription",e=>{this._modeling.updateProperties(e,{description:""});let t=this._renderer.getContainer(),r=Gi(e.id,t).getBoundingClientRect(),o=b2(t,r);this._contextMenu.open(o,{contextMenuType:"cell-description",id:e.id,autoFocus:!0,offset:{x:4,y:4}})});M(this,"removeDescription",e=>{this._modeling.updateProperties(e,{description:null}),this._contextMenu.close()});this._contextMenu=t,this._modeling=o,this._renderer=s,this._translate=a,r.on("cell.click",XW,l=>{if(l.defaultPrevented)return;let{target:c,id:u}=l,f=i.get(u);if(!Ge(f,["dmn:UnaryTests","dmn:LiteralExpression"]))return;_2(f)||l.preventDefault();let d=s.getContainer(),p=c.getBoundingClientRect(),m=b2(d,p);t.open(m,{contextMenuType:"cell-description",autoFocus:!1,id:u,offset:{x:4,y:4}})}),e.onGetComponent("context-menu",(l={})=>{if(l.contextMenuType&&l.contextMenuType==="cell-description"){let c=i.get(l.id),u=_2(c);if(Ie(u))return nd}}),e.onGetComponent("context-menu-cell-additional",GW,(l={})=>{if(l.contextMenuType&&l.contextMenuType==="context-menu"){let{id:c}=l;if(!c)return;let u=i.get(c);if(!u)return;let{businessObject:f}=u,{description:h}=f,d=Ie(h),p=d?"remove-description":"add-description",m=d?()=>this.removeDescription(u):()=>this.addDescription(u);return y(1,"div",`context-menu-group-entry ${p}`,Ie(h)?this._translate("Remove cell description"):this._translate("Add cell description"),0,{onClick:m})}})}};Ac.$inject=["components","contextMenu","elementRegistry","eventBus","modeling","renderer","translate"];function b2(n,e){let{top:t,left:i,width:r,height:o}=e;return{x:i+n.parentNode.scrollLeft-x2,y:t+n.parentNode.scrollTop,width:r+2*x2,height:o}}function _2(n){return n&&n.businessObject&&n.businessObject.description}var w2={__depends__:[Gt,_l],__init__:["description"],description:["type",Ac]};var Mc=class{constructor(e,t,i,r,o,s){this._modeling=i,this._translate=o,this._expressionLanguages=r,e.onGetComponent("context-menu-cell-additional",(a={})=>{if(a.contextMenuType&&a.contextMenuType==="context-menu"){let{event:l,id:c}=a;if(!c)return;let u=t.get(c);if(!u||!this._shouldDisplayContextMenuEntry(u))return;let f=h=>{s.open({x:(l||h).pageX,y:(l||h).pageY},{contextMenuType:"expression-language",id:c})};return y(1,"div","context-menu-group-entry",this._translate("Change cell expression language"),0,{onClick:f})}}),e.onGetComponent("context-menu",(a={})=>{if(a.contextMenuType&&a.contextMenuType==="expression-language"){let{id:l}=a;if(!l)return;let c=t.get(l);if(!c)return;let u=this._getElementExpressionLanguage(c),f=r.getAll(),h="context-menu-group-entry context-menu-entry-set-expression-language",d=this._translate("Expression language");return()=>y(1,"div","context-menu-flex",y(1,"div","context-menu-group",y(1,"div",h,[y(1,"div",null,d,0),P(2,pe,{label:d,className:"expression-language",onChange:p=>this.onChange(c,p),options:f,value:u})],4),2),2)}}),e.onGetComponent("context-menu",(a={})=>{if(a.contextMenuType==="input-edit")return()=>{let{inputExpression:l}=a.input;if(!this._shouldDisplayContextMenuEntry(l))return;let c=this._getElementExpressionLanguage(l),u=r.getAll(),f=this._translate("Expression language");return y(1,"div","context-menu-container ref-language",y(1,"div","dms-form-control",[y(1,"label","dms-label",f,0),P(2,pe,{label:f,className:"ref-language",value:c||"",onChange:h=>this.onChange(l,h),options:u})],4),2)}})}onChange(e,t){this._modeling.editExpressionLanguage(e,t)}_shouldDisplayContextMenuEntry(e){return this._expressionLanguages.getAll().length>1?!0:this._getElementExpressionLanguage(e)!==this._getDefaultElementExpressionLanguage(e)}_getElementExpressionLanguage(e){return Ke(e).expressionLanguage||this._getDefaultElementExpressionLanguage(e)}_getDefaultElementExpressionLanguage(e){return this._expressionLanguages.getDefault(ie(e.col)?"inputCell":"outputCell").value}};Mc.$inject=["components","elementRegistry","modeling","expressionLanguages","translate","contextMenu"];var C2={__depends__:[Qt],__init__:["expressionLanguage"],expressionLanguage:["type",Mc]};var Pc=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"setDecisionTableName",t=>{this.modeling.editDecisionTableName(t)});Ce(this)}componentWillMount(){this.setupChangeListeners({bind:this.getBusinessObject().id})}componentWillUnmount(){this.setupChangeListeners({unbind:this.getBusinessObject().id})}setupChangeListeners({bind:t,unbind:i}){typeof i=="string"&&this.changeSupport.offElementsChanged(i,this.onElementsChanged),typeof t=="string"&&this.changeSupport.onElementsChanged(t,this.onElementsChanged)}getBusinessObject(){return this.sheet.getRoot().businessObject.$parent}render(){let t=this.getBusinessObject(),{name:i}=t,r=this.components.getComponent("hit-policy")||YW;return y(1,"div","decision-table-properties",[P(2,ow,{label:this.translate("Decision name"),className:"decision-table-name",value:i,ctrlForNewline:!0,onBlur:ZW,onChange:this.setDecisionTableName,elementId:"__decisionProperties_name",coords:"0:__decisionProperties"}),y(1,"div","decision-table-header-separator"),P(2,r)],4)}};Pc.$inject=["sheet","modeling","changeSupport","components","translate"];var ow=class extends an{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),Ut(this,Yf)}render(){let e=this.props.value,t=Ro(this.getSelectionClasses(),this.getClassName());return y(1,"div",t,this.getEditor(),0,{"data-element-id":this.props.elementId,"data-coords":this.props.coords,title:this._translate("Decision name: ")+e})}};function YW(){return null}function ZW(n){n.target.scroll(0,0)}var JW=500,Dc=class{constructor(e){e.onGetComponent("table.before",JW,()=>Pc)}};Dc.$inject=["components"];var E2={__depends__:[Kt],__init__:["decisionTableProperties"],decisionTableProperties:["type",Dc]};var Ic=class extends L{constructor(t,i){super(t,i);M(this,"onChange",({aggregation:t,hitPolicy:i})=>{this.modeling.editHitPolicy(i,t)});M(this,"onElementsChanged",()=>{this.forceUpdate()});this._translate=i.injector.get("translate"),Ce(this)}componentDidMount(){this.changeSupport.onElementsChanged(this.getRoot().id,this.onElementsChanged)}componentWillUnmount(){this.changeSupport.offElementsChanged(this.getRoot().id,this.onElementsChanged)}getRoot(){return this.sheet.getRoot()}render(){let t=this.getRoot(),i=t.businessObject,{aggregation:r,hitPolicy:o}=i,s=ye(oh,a=>e8(a.value,{aggregation:r,hitPolicy:o}));return y(1,"div","hit-policy",[y(1,"label","dms-label",this._translate("Hit policy:"),0),P(2,pe,{className:"hit-policy-edit-policy-select",label:this._translate("Hit policy"),onChange:this.onChange,options:oh.map(a=>({...a,label:this._translate(a.label)})),value:s.value,"data-hit-policy":"true",noInput:!0})],4,{title:this._translate(s.explanation)})}};Ic.$inject=["changeSupport","sheet","modeling"];function e8(n,e){return n.hitPolicy===e.hitPolicy&&n.aggregation===e.aggregation}function $y(n){n.onGetComponent("hit-policy",()=>Ic)}$y.$inject=["components"];var S2={__depends__:[Gt],__init__:["hitPolicyProvider"],hitPolicyProvider:["type",$y]};var Lc=class extends ae{constructor(e,t){super(e),this.executed(["row.add","row.remove","col.add","col.remove"],O2(i=>{var r=i.context,o=r.row||r.col;this.updateRoot(o,r.oldRoot)})),this.reverted(["row.add","row.remove","col.add","col.remove"],O2(i=>{var r=i.context,o=r.row||r.col;this.updateRoot(o,r.newRoot)}))}updateRoot(e,t){var i=e.root,r=e.businessObject;if(O(e,"dmn:DecisionRule")){if(t){let s=t.businessObject.get("rule"),a=s.indexOf(r);s.splice(a,1),r.$parent=null}if(i){let o=i.businessObject,s=i.rows.indexOf(e);o.get("rule").splice(s,0,r),r.$parent=o,e.cells.forEach((a,l)=>{this.wireCell(a,e,l)})}}if(O(e,"dmn:InputClause")||O(e,"dmn:OutputClause")){let o,s;if(t){let a=t.businessObject,l=a.get("input"),c=a.get("output");if(O(e,"dmn:InputClause")&&(o=l,s=l.indexOf(r)),O(e,"dmn:OutputClause")&&(o=c,s=c.indexOf(r)),s===-1)throw new Error("inconsistent model: clause not in table");o.splice(s,1),r.$parent=null,e.cells.forEach((u,f)=>{this.unwireCell(u,t.rows[f])})}if(i){let a=i.businessObject,l=a.get("input"),c=a.get("output"),u=i.cols.indexOf(e),f,h;O(e,"dmn:InputClause")&&(h=l,f=u),O(e,"dmn:OutputClause")&&(h=c,f=u-l.length),h.splice(f,0,r),r.$parent=a,e.cells.forEach((d,p)=>{this.wireCell(d,i.rows[p],u)})}}}unwireCell(e,t){var i=e.businessObject;let r=t.businessObject,o=r.get("inputEntry"),s=r.get("outputEntry"),a,l;if(O(e,"dmn:UnaryTests")&&(a=o),O(e,"dmn:LiteralExpression")&&(a=s),l=a.indexOf(i),l===-1)throw new Error("cell not in row");a.splice(l,1),i.$parent=null}wireCell(e,t,i){var r=e.businessObject;let o=t.businessObject,s=o.get("inputEntry"),a=o.get("outputEntry"),l,c;r.$parent!==o&&(O(e,"dmn:UnaryTests")&&(l=s,c=i),O(e,"dmn:LiteralExpression")&&(l=a,c=i-s.length),l.splice(c,0,r),r.$parent=o)}};Lc.$inject=["eventBus","sheet"];function O2(n){return function(e){var t=e.context,i=t.row||t.col;O(i,"dmn:DMNElement")&&n(e)}}var Bc=class{constructor(e){this._model=e}create(e,t={}){var i=this._model.create(e,t||{});return O(i,"dmn:InputClause")&&(t.inputExpression?i.inputExpression=t.inputExpression:(i.inputExpression=this.create("dmn:LiteralExpression",{typeRef:"string"}),i.inputExpression.$parent=i)),O(i,"dmn:OutputClause")&&(i.typeRef=t.typeRef||"string"),(O(i,"dmn:UnaryTests")||O(i,"dmn:LiteralExpression"))&&(i.text=t.text||""),this._ensureId(i),i}_needsId(e){return O(e,"dmn:DMNElement")}_ensureId(e){var t=(e.$type||"").replace(/^[^:]*:/g,"")+"_";!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e))}};Bc.$inject=["moddle"];var Nc=class extends As{constructor(e){super(),this._dmnFactory=e}create(e,t){let i=this._dmnFactory,{businessObject:r,type:o,...s}=t;if(!r){if(!o){if(e==="root")o="dmn:DecisionTable";else if(e==="cell"){let{col:a}=s;O(a,"dmn:OutputClause")&&(o="dmn:LiteralExpression"),O(a,"dmn:InputClause")&&(o="dmn:UnaryTests")}if(!o)throw new Error("cannot guess <type>")}r=i.create(o)}return super.create(e,{businessObject:r,id:r.id,...s})}};Nc.$inject=["dmnFactory"];var $c=class{constructor(e,t){this._sheet=e,this._elementFactory=t}execute(e){let t=this._sheet,i=this._elementFactory,r=t.getRoot(),{row:o,index:s}=e;return typeof s=="undefined"&&(s=e.index=r.rows.length),e.newRoot=r,o.cells.length||r.cols.forEach((a,l)=>{let c=i.create("cell",{row:o,col:a});o.cells[l]=c}),t.addRow(o,s),t.getRoot()}revert(e){let{row:t}=e,i=this._sheet;return i.removeRow(t),i.getRoot()}};$c.$inject=["sheet","elementFactory"];var jc=class{constructor(e){this._sheet=e}execute(e){let t=this._sheet,i=t.getRoot(),{row:r}=e,o=e.oldIndex=i.rows.indexOf(r);if(e.oldRoot=r.root,o===-1)throw new Error(`row#${r.id} not in sheet`);return t.removeRow(r),t.getRoot()}revert(e){let{row:t,oldIndex:i}=e,r=this._sheet;return r.addRow(t,i),r.getRoot()}};jc.$inject=["sheet"];var Fc=class{constructor(e){this._modeling=e}preExecute(e){let{row:t}=e;this._modeling.removeRow(t)}postExecute(e){let{row:t,index:i}=e;this._modeling.addRow(t,i)}};Fc.$inject=["modeling"];var qc=class{constructor(e,t){this._sheet=e,this._elementFactory=t}execute(e){let t=this._sheet,i=this._elementFactory,r=t.getRoot(),{col:o,index:s}=e;return typeof s=="undefined"&&(s=e.index=r.cols.length),e.newRoot=r,o.cells.length||r.rows.forEach((a,l)=>{let c=i.create("cell",{row:a,col:o});o.cells[l]=c}),t.addCol(o,s),t.getRoot()}revert(e){let{col:t}=e,i=this._sheet;return i.removeCol(t),i.getRoot()}};qc.$inject=["sheet","elementFactory"];var Vc=class{constructor(e,t){this._sheet=e,this._elementFactory=t}execute(e){let t=this._sheet,{col:i}=e,r=e.oldRoot=i.root;if((e.oldIndex=r.cols.indexOf(i))===-1)throw new Error(`col#${i.id} not in sheet`);return t.removeCol(i),t.getRoot()}revert(e){let{col:t,oldIndex:i}=e,r=this._sheet;return r.addCol(t,i),r.getRoot()}};Vc.$inject=["sheet","elementFactory"];var Hc=class{constructor(e){this._modeling=e}preExecute(e){let{col:t}=e;this._modeling.removeCol(t)}postExecute(e){let{col:t,index:i}=e;this._modeling.addCol(t,i)}};Hc.$inject=["modeling"];var id=class{execute(e){let{cell:t}=e;return t}revert(e){let{cell:t}=e;return t}};var zc=class n{constructor(e,t,i){this._eventBus=e,this._elementFactory=t,this._commandStack=i,e.on("table.init",()=>{t8(this.getHandlers(),i)})}getHandlers(){return n._getHandlers()}static _getHandlers(){return{"row.add":$c,"row.remove":jc,"row.move":Fc,"col.add":qc,"col.remove":Vc,"col.move":Hc,"cell.edit":id}}_create(e,t){return t instanceof Oo?t:this._elementFactory.create(e,t)}addRow(e,t){let i=this._create("row",e),r={row:i,index:t};return this._commandStack.execute("row.add",r),i}removeRow(e){this._commandStack.execute("row.remove",{row:e})}moveRow(e,t){let i={row:e,index:t};this._commandStack.execute("row.move",i)}addCol(e,t){let i=this._create("col",e),r={col:i,index:t};return this._commandStack.execute("col.add",r),i}removeCol(e){this._commandStack.execute("col.remove",{col:e})}moveCol(e,t){let i={col:e,index:t};this._commandStack.execute("col.move",i)}editCell(e,t){let i={cell:e,...t};this._commandStack.execute("cell.edit",i)}};zc.$inject=["eventBus","elementFactory","commandStack"];function t8(n,e){k(n,function(t,i){e.registerHandler(i,t)})}var Wc=class{constructor(e,t,i){this._dmnFactory=e,this._moddle=t,this._modeling=i}execute(e){let{element:t,allowedValues:i}=e;return O(t,"dmn:InputClause")?(t.inputValues?e.oldAllowedValues=t.inputValues.text:jy(i)||(t.inputValues=this._dmnFactory.create("dmn:UnaryTests",{text:""})),jy(i)?t.inputValues&&delete t.inputValues:t.inputValues.text=i.join(",")):(t.outputValues&&t?e.oldAllowedValues=t.outputValues.text:jy(i)||(t.outputValues=this._dmnFactory.create("dmn:UnaryTests",{text:""})),jy(i)?t.outputValues&&delete t.outputValues:t.outputValues.text=i.join(",")),t}revert(e){let{element:t,oldAllowedValues:i}=e;return O(t,"dmn:InputClause")?i?(t.inputValues||(t.inputValues=this._dmnFactory.create("dmn:UnaryTests",{text:""})),t.inputValues.text=i):delete t.inputValues:i?(t.outputValues||(t.outputValues=this._dmnFactory.create("dmn:UnaryTests",{text:""})),t.outputValues.text=i):delete t.outputValues,t}};Wc.$inject=["dmnFactory","moddle","modeling"];function jy(n){return n===null}var sw="id",sr=class{constructor(e,t){this._elementRegistry=e,this._moddle=t}execute(e){let{element:t,properties:i}=e,r=Ke(t),{changed:o,oldProperties:s}=this.updateProperties(r,i);return e.oldProperties=s,[...o,t]}revert(e){let{element:t,oldProperties:i}=e;var r=Ke(t),{changed:o}=this.updateProperties(r,i);return[...o,t]}updateProperties(e,t){let i=this._moddle.ids;return st(t,(r,o,s)=>{let a=e.get(s);if(k2(o)){if(!R2(a)&&!k2(a))throw new Error(`non-existing property <${s}>: cannot update values`);let{changed:l,oldProperties:c}=this.updateProperties(a,o);return{changed:[...r.changed,...l,a],oldProperties:{...r.oldProperties,[s]:c}}}return s===sw&&n8(e,o)&&(i.unclaim(e[sw]),this._elementRegistry.updateId(e,o),i.claim(o,e)),e.set(s,o),{changed:r.changed,oldProperties:{...r.oldProperties,[s]:a}}},{changed:[],oldProperties:{}})}};sr.$inject=["elementRegistry","moddle"];function n8(n,e){return n[sw]!==e}function k2(n){return Me(n)&&Pe(n)&&!R2(n)}function R2(n){return!!(n!=null&&n.$type)}var Uc=class{constructor(e){this._moddle=e}execute(e){let t=this._moddle.ids,i=e.id,r=e.element;e.claiming?t.claim(i,r):t.unclaim(i)}revert(e){let t=this._moddle.ids,i=e.id,r=e.element;e.claiming?t.unclaim(i):t.claim(i,r)}};Uc.$inject=["moddle"];var Qc=class n extends zc{constructor(e,t,i,r){super(e,t,i),this._eventBus=e,this._elementFactory=t,this._commandStack=i,this._sheet=r}getHandlers(){return n._getHandlers()}static _getHandlers(){return T({},super._getHandlers(),{editAllowedValues:Wc,"element.updateProperties":sr,"id.updateClaim":Uc})}editDecisionTableName(e){let o={element:this._sheet.getRoot().businessObject.$parent,properties:{name:e}};this._commandStack.execute("element.updateProperties",o)}editDecisionTableId(e){let o={element:this._sheet.getRoot().businessObject.$parent,properties:{id:e}};this._commandStack.execute("element.updateProperties",o)}editHitPolicy(e,t){let o={element:this._sheet.getRoot().businessObject,properties:{hitPolicy:e,aggregation:t}};this._commandStack.execute("element.updateProperties",o)}updateProperties(e,t){let i={element:e,properties:t};this._commandStack.execute("element.updateProperties",i)}editInputExpression(e,t){let i={element:e,properties:t};this._commandStack.execute("element.updateProperties",i)}editOutputName(e,t){let i={element:e,properties:{name:t}};this._commandStack.execute("element.updateProperties",i)}editInputExpressionTypeRef(e,t){let i={element:e,properties:{typeRef:t}};this._commandStack.execute("element.updateProperties",i)}editOutputTypeRef(e,t){let i={element:e,properties:{typeRef:t}};this._commandStack.execute("element.updateProperties",i)}editCell(e,t){let i={element:e,properties:{text:t}};this._commandStack.execute("element.updateProperties",i)}editAnnotation(e,t){let i={element:e,properties:{description:t}};this._commandStack.execute("element.updateProperties",i)}editAllowedValues(e,t){let i={element:e,allowedValues:t};this._commandStack.execute("editAllowedValues",i)}editExpressionLanguage(e,t){let i={element:e,properties:{expressionLanguage:t}};this._commandStack.execute("element.updateProperties",i)}claimId(e,t){let i={id:e,element:t,claiming:!0};this._commandStack.execute("id.updateClaim",i)}unclaimId(e,t){let i={id:e,element:t};this._commandStack.execute("id.updateClaim",i)}};Qc.$inject=["eventBus","elementFactory","commandStack","sheet"];var Kc=class extends ae{constructor(e,t,i){super(e),this._ids=t.ids,this._modeling=i,this.preExecute(["row.add","col.add"],r=>{let o=r.context,s=o.row||o.col;this.claimId(s.businessObject),s.cells&&s.cells.forEach(a=>this.claimId(a.businessObject))})}claimId(e){e.id&&!this._ids.assigned(e.id)&&this._modeling.claimId(e.id,e),e.$descriptor.properties.forEach(t=>{let i=e[t.name];i&&(F(i)&&i.forEach(r=>this.claimId(r)),i.$type&&this.claimId(i))})}};Kc.$inject=["eventBus","moddle","modeling"];var Gc=class extends ae{constructor(e,t){super(e),this._modeling=t,this.preExecute(["row.remove","col.remove"],i=>{let r=i.context,o=r.row||r.col;this.unclaimId(o.businessObject),o.cells&&o.cells.forEach(s=>this.unclaimId(s.businessObject))})}unclaimId(e){e.id&&this._modeling.unclaimId(e.id,e),e.$descriptor.properties.forEach(t=>{let i=e[t.name];i&&(F(i)&&i.forEach(r=>this.unclaimId(r)),i.$type&&this.unclaimId(i))})}};Gc.$inject=["eventBus","modeling"];var T2={__init__:["idClaimBehavior","idUnclaimBehavior"],idClaimBehavior:["type",Kc],idUnclaimBehavior:["type",Gc]};var A2={__init__:["dmnUpdater","idChangeBehavior","nameChangeBehavior","modeling"],__depends__:[T2,xs],dmnUpdater:["type",Lc],dmnFactory:["type",Bc],elementFactory:["type",Nc],idChangeBehavior:["type",Gn],nameChangeBehavior:["type",qi],modeling:["type",Qc]};var rd=class extends L{constructor(e,t){super(e,t),this.changeCellValue=this.changeCellValue.bind(this),this.onElementsChanged=this.onElementsChanged.bind(this)}onElementsChanged(){this.forceUpdate()}componentWillMount(){let{injector:e}=this.context,{cell:t}=this.props,i=this._changeSupport=this.context.changeSupport;this._modeling=e.get("modeling"),i.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){let{cell:e}=this.props;this._changeSupport.offElementsChanged(e.id,this.onElementsChanged)}changeCellValue(e){let{cell:t}=this.props;this._modeling.editCell(t.businessObject,e)}render(){let{cell:e,rowIndex:t,row:i,col:r,colIndex:o}=this.props,s=O(e,"dmn:UnaryTests"),a=e.businessObject;return P(2,Rn,{className:s?"input-cell":"output-cell",elementId:e.id,coords:`${t}:${o}`,"data-row-id":i.id,"data-col-id":r.id,children:P(2,lw,{placeholder:s?"-":"",onChange:this.changeCellValue,value:a.text,businessObject:a})})}},aw=class extends L{constructor(e,t){super(e,t),this.state={focussed:!1},this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this)}onFocus(){this.setState({focussed:!0})}onBlur(){this.setState({focussed:!1})}render(){let{focussed:e}=this.state;return y(1,"div",`feel-editor${e?" focussed":""}`,[e&&En(P(2,Ri,{...this.props,autoFocus:!0,onBlur:this.onBlur})),En(P(2,Tn,{...this.props,onInput:()=>{},onFocus:this.onFocus}))],0,{onClick:this.onFocus})}},lw=class extends L{constructor(e,t){super(e,t),this._expressionLanguages=t.injector.get("expressionLanguages"),this._translate=t.injector.get("translate"),this._variableResolver=t.injector.get("variableResolver",!1)}isDefaultExpressionLanguage(e){let{expressionLanguage:t}=e,i=this.getDefaultExpressionLanguage().value;return!t||t===i}getDescription(e){return e.description}getExpressionLanguageLabel(e){let{expressionLanguage:t}=e,i=this.getDefaultExpressionLanguage();return this._expressionLanguages.getLabel(t)||i.label}isScript(){let{businessObject:e}=this.props,t=this.getDefaultExpressionLanguage();return this._isInputCell()?e.text.indexOf(` 1940`)!==-1?!0:e.expressionLanguage&&e.expressionLanguage!==t:!1}_isInputCell(){return O(this.props.businessObject,"dmn:UnaryTests")}getDefaultExpressionLanguage(){let e=this._isInputCell()?"inputCell":"outputCell";return this._expressionLanguages.getDefault(e)}getEditor(){return this.isFEEL()?aw:Tn}isFEEL(){return this.getExpressionLanguage()==="feel"}getExpressionLanguage(){let{businessObject:e}=this.props;return e.expressionLanguage||this.getDefaultExpressionLanguage().value}_getVariables(){let{businessObject:e}=this.props;return this._variableResolver&&this._variableResolver.getVariables(e)}_getLabel(){return this._isInputCell()?this._translate("Input"):this._translate("Output")}render(){let{businessObject:e,placeholder:t,value:i,onChange:r}=this.props,o=this.getDescription(e),s=this.isDefaultExpressionLanguage(e),a=this.getExpressionLanguageLabel(e),l=this.isScript(),c=this.getEditor(),u=this._getVariables();return y(1,"div","cell-editor",[Ie(o)&&y(1,"div","description-indicator"),P(2,c,{label:this._getLabel(),className:l?"script-editor":"",ctrlForNewline:!0,onInput:r,value:i,placeholder:t,variables:u,feelLanguageDialect:"unaryTests"}),!s&&y(1,"span","dms-badge dmn-expression-language",[y(1,"span","dms-badge-icon dmn-icon-file-code"),y(1,"span","dms-badge-label",a,0)],4,{title:this._translate("Expression language: {expressionLanguageLabel}",{expressionLanguageLabel:a})})],0)}};var i8=1500,Xc=class{constructor(e){e.onGetComponent("cell",i8,({cellType:t})=>{if(t==="rule")return rd})}};Xc.$inject=["components"];var M2={__depends__:[Kt,tg],__init__:["decisionRulesEditor"],decisionRulesEditor:["type",Xc]};var Fy=4,Yc=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this.state={top:0,left:0,isVisible:!1,isDisabled:!1,selection:null},Ce(this);let{debounceInput:i}=this;this.onClick=this.onClick.bind(this),this.handleSelectionChanged=this.handleSelectionChanged.bind(this),this.hideAndShowDebounced=this.hideAndShowDebounced.bind(this),this.showDebounced=i(this.showDebounced.bind(this)),this.updatePosition=this.updatePosition.bind(this)}componentDidMount(){let{eventBus:e}=this;e.on("cellSelection.changed",this.handleSelectionChanged),e.on("commandStack.changed",this.updatePosition),e.on("sheet.scroll",this.hideAndShowDebounced)}componentWillUnmount(){let{eventBus:e}=this;e.off("cellSelection.changed",this.handleSelectionChanged),e.off("commandStack.changed",this.updatePosition),e.off("sheet.scroll",this.hideAndShowDebounced)}hideAndShowDebounced(){this.state.isVisible&&(this.hide(),this.showDebounced())}showDebounced(){this.show()}hide(e={}){this.setState({...e,isVisible:!1})}show(e={}){this.setState({...e,isVisible:!0}),this.updatePosition()}handleSelectionChanged({elementId:e}){let{elementRegistry:t,expressionLanguages:i,simpleMode:r}=this,o=t.get(e);if(!o||!r.canSimpleEdit(o)){this.hide({isDisabled:!1,selection:null});return}let s=r8(o),a=!o8(o,s,i);this.show({isDisabled:a,selection:o})}updatePosition(){let{selection:e}=this.state,{node:t}=this;if(!e||!t)return;let{renderer:i}=this,r=i.getContainer(),o=r.getBoundingClientRect(),a=Gi(e.id,r).getBoundingClientRect(),l=this.node.getBoundingClientRect(),{scrollLeft:c,scrollTop:u}=a8(t),f={};a.left+a.width/2>o.width/2?f.left=-o.left+a.left-l.width+Fy+c+"px":f.left=-o.left+a.left+a.width-Fy+c+"px",a.top+a.height/2>o.height/2?f.top=-o.top+a.top-l.height+Fy+u+"px":f.top=-o.top+a.top-Fy+u+"px",T(this.node.style,f)}onClick(){let{eventBus:e}=this,{isDisabled:t}=this.state;if(t)return;let{selection:i}=this,r=i.get();r&&(e.fire("simpleMode.open",{element:r,node:Gi(r.id,this._container)}),this.hide())}render(){let{isDisabled:e,isVisible:t,top:i,left:r}=this.state,o=["simple-mode-button","no-deselect"];return e&&o.push("disabled"),t?y(1,"div",o.join(" "),y(1,"span","dmn-icon-edit"),2,{onClick:this.onClick,style:{top:i,left:r},title:e?this._translate("Editing not supported for set expression language"):this._translate("Edit")},null,s=>this.node=s):null}};Yc.$inject=["debounceInput","elementRegistry","eventBus","expressionLanguages","renderer","selection","simpleMode"];function r8(n){return n.businessObject.expressionLanguage}function o8(n,e,t){return!e||e===s8(n,t)}function s8(n,e){if(ie(n.col))return e.getDefault("inputCell").value;if(Te(n.col))return e.getDefault("outputCell").value}function a8(n){let e=De(n,".tjs-table-container");if(!e)return{scrollTop:0,scrollLeft:0};let{scrollLeft:t,scrollTop:i}=e;return{scrollTop:i,scrollLeft:t}}var Zc=class{constructor(e,t,i,r,o){this._providers=[],e.onGetComponent("table.before",()=>Yc),r.on("simpleMode.open",({element:s,node:a})=>{let{left:l,top:c,width:u,height:f}=a.getBoundingClientRect(),h=o.getContainer();t.open({x:l+h.parentNode.scrollLeft,y:c+h.parentNode.scrollTop,width:u,height:f},{contextMenuType:"simple-mode-edit",element:s,offset:{x:4,y:4}})}),r.on("cell.click",s=>{let{event:a,node:l,id:c}=s;if(l8(a)){let u=i.get(c);u&&r.fire("simpleMode.open",{node:l,element:u}),s.preventDefault()}})}registerProvider(e){this._providers.push(e)}canSimpleEdit(e){return this._providers.reduce((t,i)=>t||i(e),!1)}};Zc.$inject=["components","contextMenu","elementRegistry","eventBus","renderer"];function l8(n){return n.altKey?!1:n.ctrlKey||n.metaKey}var en={__depends__:[Gt,Po,Qt],__init__:["simpleMode"],simpleMode:["type",Zc]};function P2(n){if(!n||c8(n))return"none";if(n.trim()==="true")return"true";if(n.trim()==="false")return"false"}function c8(n){return n===""}var u8="true",f8="false",cw="none",od=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=P2(i.businessObject.text);this.state={value:r||cw},this.editCell=this.editCell.bind(this),this.onChange=this.onChange.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onChange(e){let{element:t}=this.props.context;this.editCell(t.businessObject,e===cw?"":e),this.setState({value:e})}render(){let{value:e}=this.state,t=[{label:"-",value:cw},{label:this._translate("Yes"),value:u8},{label:this._translate("No"),value:f8}];return y(1,"div","simple-boolean-edit context-menu-container",[y(1,"h3","dms-heading",this._translate("Edit boolean"),0),y(1,"h4","dms-heading",this._translate("Set value"),0),P(2,pe,{label:this._translate("Boolean value"),noInput:!0,className:"dms-block",onChange:this.onChange,options:t,value:e})],4)}};var Jc=class{constructor(e,t){t.registerProvider(i=>(ie(i.col)||Te(i.col))&&D2(i)==="boolean"),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;if(D2(i.element)==="boolean")return od}})}};Jc.$inject=["components","simpleMode"];function D2(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}var I2={__depends__:[Bt,en],__init__:["simpleBooleanEdit"],simpleBooleanEdit:["type",Jc]};var h8=/^\d{4}(?:-\d\d){2}$/,d8=/^\[date\("([^"]*)"\)..date\("([^"]*)"\)\]$/,p8=/^(<|>)\s*date\("([^"]*)"\)$/,m8=/^date\("([^"]*)"\)$/,g8="exact",y8="before",v8="after",x8="between";function zo(n){if(!h8.test(n.trim()))return"Date must match pattern yyyy-MM-dd"}function Qr(n,e){if(n===g8)return`date("${e[0]}")`;if(n===y8)return`< date("${e[0]}")`;if(n===v8)return`> date("${e[0]}")`;if(n===x8)return`[date("${e[0]}")..date("${e[1]}")]`}function Bn(){let n=new Date;return n.setUTCHours(0,0,0,0),n.toISOString().slice(0,10)}function ea(n){if(!n||n.trim()==="")return{type:"exact",date:""};let e=n.match(d8);if(e)return{type:"between",dates:[e[1],e[2]]};if(e=n.match(p8),e)return{type:e[1]==="<"?"before":"after",date:e[2]};if(e=n.match(m8),e)return{type:"exact",date:e[1]}}var L2="exact",b8="before",_8="after",sd="between",ad=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=ea(i.businessObject.text);if(r){let s;r.date?s=[r.date,""]:r.dates?s=r.dates:s=["",""],this.state={type:r.type,dates:s}}else this.state={type:L2,dates:["",""]};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onTypeChange=this.onTypeChange.bind(this),this.onSetStartDateTodayClick=this.onSetStartDateTodayClick.bind(this),this.onSetEndDateTodayClick=this.onSetEndDateTodayClick.bind(this),this.onStartDateInput=this.onStartDateInput.bind(this),this.onEndDateInput=this.onEndDateInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onTypeChange(e){let{element:t}=this.props.context,{dates:i}=this.state;this.setState({type:e}),ea(Qr(e,i))&&this.editCell(t.businessObject,Qr(e,i))}onSetStartDateTodayClick(){let{element:e}=this.props.context,{dates:t,type:i}=this.state,r=Bn();this.setState({dates:[r,t[1]]}),ea(Qr(i,[r,t[1]]))&&this.editCell(e.businessObject,Qr(i,[r,t[1]]))}onSetEndDateTodayClick(){let{element:e}=this.props.context,{dates:t,type:i}=this.state,r=Bn();this.setState({dates:[t[0],r]}),ea(Qr(i,[t[0],r]))&&this.editCell(e.businessObject,Qr(i,[t[0],r]))}onStartDateInput({value:e}){let{element:t}=this.props.context,{dates:i,type:r}=this.state;this.setState({dates:[e,i[1]]}),this.debouncedEditCell(t.businessObject,Qr(r,[e,i[1]]))}onEndDateInput({value:e}){let{element:t}=this.props.context,{dates:i,type:r}=this.state;this.setState({dates:[i[0],e]}),this.debouncedEditCell(t.businessObject,Qr(r,[i[0],e]))}render(){let{dates:e,type:t}=this.state,i=[{label:this._translate("Exactly"),value:L2},{label:this._translate("Before"),value:b8},{label:this._translate("After"),value:_8},{label:this._translate("Between"),value:sd}];return y(1,"div","context-menu-container simple-date-edit",[y(1,"h3","dms-heading",this._translate("Edit date"),0),y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Test type"),noInput:!0,onChange:this.onTypeChange,options:i,value:t}),2),y(1,"h4","dms-heading",t===sd?this._translate("Edit start date"):this._translate("Set date"),0),y(1,"div",null,[P(2,ot,{label:t===sd?this._translate("Start date"):this._translate("Date"),className:"start-date-input dms-block",onInput:this.onStartDateInput,placeholder:this._translate("e.g. { sample }",{sample:Bn()}),validate:r=>zo(r)&&this._translate(zo(r)),value:e[0]}),y(1,"p","dms-hint",[y(1,"button","use-today",this._translate("Use today"),0,{type:"button",onClick:this.onSetStartDateTodayClick}),Z(".")],4)],4),t===sd&&y(1,"h4","dms-heading",this._translate("Edit end date"),0),t===sd&&y(1,"div",null,[P(2,ot,{label:this._translate("End date"),className:"end-date-input dms-block",onInput:this.onEndDateInput,placeholder:this._translate("e.g. { sample }",{sample:Bn()}),validate:r=>zo(r)&&this._translate(zo(r)),value:e[1]}),y(1,"p","dms-hint",[y(1,"button","use-today",this._translate("Use today"),0,{type:"button",onClick:this.onSetEndDateTodayClick}),Z(".")],4)],4)],0)}};var ld=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=ea(i.businessObject.text);this.state={date:r?r.date:""};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onClick=this.onClick.bind(this),this.onInput=this.onInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onClick(){let{element:e}=this.props.context,t=Bn();this.setState({date:t}),this.editCell(e.businessObject,`date("${t}")`)}onInput({value:e}){let{element:t}=this.props.context;this.setState({date:e}),this.debouncedEditCell(t.businessObject,`date("${e}")`)}render(){let{date:e}=this.state;return y(1,"div","context-menu-container simple-date-edit",[y(1,"h3","dms-heading",this._translate("Edit date"),0),y(1,"h4","dms-heading",this._translate("Set date"),0),y(1,"div",null,[P(2,ot,{label:this._translate("Date value"),onInput:this.onInput,placeholder:this._translate("e.g. { example } ",{example:Bn()}),validate:t=>zo(t)&&this._translate(zo(t)),value:e,className:"dms-block"}),y(1,"p","dms-hint",y(1,"button","use-today",this._translate("Use today"),0,{type:"button",onClick:this.onClick}),2)],4)],4)}};var eu=class{constructor(e,t){t.registerProvider(i=>{let r=B2(i);return(ie(i.col)||Te(i.col))&&N2(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=B2(i.element);if(N2(r)){if(ie(i.element.col))return ad;if(Te(i.element.col))return ld}}})}};eu.$inject=["components","simpleMode"];function B2(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}function N2(n){return n==="date"}var $2={__depends__:[Bt,en],__init__:["simpleDateEdit"],simpleDateEdit:["type",eu]};var w8=/^\d{4}(?:-\d\d){2}T(?:\d\d:){2}\d\d(?:Z|(?:[@+-][^")]+))?$/,C8=/^\[date and time\("([^"]*)"\)..date and time\("([^"]*)"\)\]$/,E8=/^(<|>)\s*date and time\("([^"]*)"\)$/,S8=/^date and time\("([^"]*)"\)$/,O8="exact",k8="before",R8="after",T8="between";function Wo(n){if(!w8.test(n.trim()))return"Date and time must match pattern yyyy-MM-ddTHH:mm:ss[time zone]"}function Kr(n,e){if(n===O8)return`date and time("${e[0]}")`;if(n===k8)return`< date and time("${e[0]}")`;if(n===R8)return`> date and time("${e[0]}")`;if(n===T8)return`[date and time("${e[0]}")..date and time("${e[1]}")]`}function Uo(){let n=new Date;return n.setUTCHours(0,0,0,0),n.toISOString().replace(".000Z","Z")}function ta(n){if(!n||n.trim()==="")return{type:"exact",date:""};let e=n.match(C8);if(e)return{type:"between",dates:[e[1],e[2]]};if(e=n.match(E8),e)return{type:e[1]==="<"?"before":"after",date:e[2]};if(e=n.match(S8),e)return{type:"exact",date:e[1]}}var j2="exact",A8="before",M8="after",cd="between",ud=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=ta(i.businessObject.text);if(r){let s;r.date?s=[r.date,""]:r.dates?s=r.dates:s=["",""],this.state={type:r.type,dates:s}}else this.state={type:j2,dates:["",""]};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onTypeChange=this.onTypeChange.bind(this),this.onSetStartDateTodayClick=this.onSetStartDateTodayClick.bind(this),this.onSetEndDateTodayClick=this.onSetEndDateTodayClick.bind(this),this.onStartDateInput=this.onStartDateInput.bind(this),this.onEndDateInput=this.onEndDateInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onTypeChange(e){let{element:t}=this.props.context,{dates:i}=this.state;this.setState({type:e}),ta(Kr(e,i))&&this.editCell(t.businessObject,Kr(e,i))}onSetStartDateTodayClick(){let{element:e}=this.props.context,{dates:t,type:i}=this.state,r=Uo();this.setState({dates:[r,t[1]]}),ta(Kr(i,[r,t[1]]))&&this.editCell(e.businessObject,Kr(i,[r,t[1]]))}onSetEndDateTodayClick(){let{element:e}=this.props.context,{dates:t,type:i}=this.state,r=Uo();this.setState({dates:[t[0],r]}),ta(Kr(i,[t[0],r]))&&this.editCell(e.businessObject,Kr(i,[t[0],r]))}onStartDateInput({value:e}){let{element:t}=this.props.context,{dates:i,type:r}=this.state;this.setState({dates:[e,i[1]]}),this.debouncedEditCell(t.businessObject,Kr(r,[e,i[1]]))}onEndDateInput({value:e}){let{element:t}=this.props.context,{dates:i,type:r}=this.state;this.setState({dates:[i[0],e]}),this.debouncedEditCell(t.businessObject,Kr(r,[i[0],e]))}render(){let{dates:e,type:t}=this.state,i=[{label:this._translate("Exactly"),value:j2},{label:this._translate("Before"),value:A8},{label:this._translate("After"),value:M8},{label:this._translate("Between"),value:cd}];return y(1,"div","context-menu-container simple-date-edit",[y(1,"h3","dms-heading",this._translate("Edit date and time"),0),y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Test type"),noInput:!0,onChange:this.onTypeChange,options:i,value:t}),2),y(1,"h4","dms-heading",t===cd?this._translate("Edit start date and time"):this._translate("Set date and time"),0),y(1,"div",null,[P(2,ot,{label:t===cd?this._translate("Start date and time"):this._translate("Date and time"),className:"start-date-input dms-block",onInput:this.onStartDateInput,placeholder:this._translate("e.g. { sample }",{sample:Uo()}),validate:r=>Wo(r)&&this._translate(Wo(r)),value:e[0]}),y(1,"p","dms-hint",y(1,"button","use-today",this._translate("Use today"),0,{type:"button",onClick:this.onSetStartDateTodayClick}),2)],4),t===cd&&y(1,"h4","dms-heading",this._translate("Edit end date and time"),0),t===cd&&y(1,"div",null,[P(2,ot,{label:this._translate("End date and time"),className:"end-date-input dms-block",onInput:this.onEndDateInput,placeholder:this._translate("e.g. { sample }",{sample:Uo()}),validate:r=>Wo(r)&&this._translate(Wo(r)),value:e[1]}),y(1,"p","dms-hint",y(1,"button","use-today",this._translate("Use today"),0,{type:"button",onClick:this.onSetEndDateTodayClick}),2)],4)],0)}};var fd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=ta(i.businessObject.text);this.state={date:r?r.date:""};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onClick=this.onClick.bind(this),this.onInput=this.onInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onClick(){let{element:e}=this.props.context,t=Uo();this.setState({date:t}),this.editCell(e.businessObject,`date and time("${t}")`)}onInput({value:e}){let{element:t}=this.props.context;this.setState({date:e}),this.debouncedEditCell(t.businessObject,`date and time("${e}")`)}render(){let{date:e}=this.state;return y(1,"div","context-menu-container simple-date-edit",[y(1,"h3","dms-heading",this._translate("Edit date and time"),0),y(1,"h4","dms-heading",this._translate("Set date and time"),0),y(1,"div",null,[P(2,ot,{label:this._translate("Date and time value"),onInput:this.onInput,placeholder:this._translate("e.g. { sample }",{sample:Uo()}),validate:t=>Wo(t)&&this._translate(Wo(t)),value:e,className:"dms-block"}),y(1,"p","dms-hint",y(1,"button","use-today",this._translate("Use today"),0,{type:"button",onClick:this.onClick}),2)],4)],4)}};var tu=class{constructor(e,t){t.registerProvider(i=>{let r=F2(i);return(ie(i.col)||Te(i.col))&&q2(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=F2(i.element);if(q2(r)){if(ie(i.element.col))return ud;if(Te(i.element.col))return fd}}})}};tu.$inject=["components","simpleMode"];function F2(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}function q2(n){return n==="dateTime"}var V2={__depends__:[Bt,en],__init__:["simpleDateTimeEdit"],simpleDateTimeEdit:["type",tu]};var uw={equals:"=",less:"<",lessEquals:"<=",greater:">",greaterEquals:">="};function P8(n){return di(uw).filter(e=>n===uw[e])[0]}function H2(n){if(!n||D8(n.trim()))return{type:"comparison",values:[]};let e=B8(n);if(e)return e;let t=N8(n);if(t)return t}function D8(n){return n===""}function qy(n,e){return n==="equals"?`duration("${e}")`:`${uw[n]} duration("${e}")`}function nu(n,e,t,i){return`${t==="exclude"?"]":"["}duration("${n}")..duration("${e}")${i==="exclude"?"[":"]"}`}function z2(n,e){if(n==="yearMonthDuration")return I8(e);if(n==="dayTimeDuration")return L8(e)}function I8(n){return/^P(\d+Y\d+M|\d+Y|\d+M)$/.test(n)}function L8(n){return/^P(\d+DT\d+H|\d+D|T\d+H)$/.test(n)}function fw(n){let e=/^duration\("([^"]*)"\)$/.exec(n);return e&&e[1]}function B8(n){let e=fw(n);if(e)return{type:"comparison",operator:"equals",values:[e]};let{operator:t,value:i}=W2(/^(?<operator>=|(:?<|>)=?)\s*duration\("(?<value>[^"]*)"\)$/,n);if(t&&i)return{type:"comparison",values:[i],operator:P8(t)}}function N8(n){let{start:e,end:t,firstValue:i,secondValue:r}=W2(/^(?<start>[[\]])duration\("(?<firstValue>[^"]*)"\)\.\.duration\("(?<secondValue>[^"]*)"\)(?<end>[[\]])$/,n);if(e&&t)return{type:"range",values:[i,r],start:e==="]"?"exclude":"include",end:t==="["?"exclude":"include"}}function W2(n,e){let{groups:t}=n.exec(e)||{groups:{}};return t}var $8={yearMonthDuration:"Must match PnYnM",dayTimeDuration:"Must match PnDTnH"},Qo=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._type=e.type,this.onInput=this.onInput.bind(this),this.validate=this.validate.bind(this),this.state={value:e.value}}onInput({value:e}){this.setState({value:e}),this.props.onInput(e)}validate(e){if(!z2(this._type,e))return this._translate($8[this._type])}_getPlaceholder(){if(this._type==="yearMonthDuration")return this._translate("e.g. { sample }",{sample:"P1Y2M"});this._type==="dayTimeDuration"&&this._translate("e.g. { sample }",{sample:"P1DT2H"})}render(){return P(2,ot,{label:this.props.label,type:"text",onInput:this.onInput,placeholder:this._getPlaceholder(),validate:this.validate,value:this.state.value,className:this.props.className})}};var iu="comparison",ru="range",hd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context;this._type=j8(i);let r=H2(i.businessObject.text,this._type);r?this.state={type:r.type,comparisonOperator:r.operator||"equals",startValue:r.values[0]||"",endValue:r.values[1]||"",rangeStartType:r.start||"include",rangeEndType:r.end||"include"}:this.state={type:iu,comparisonOperator:"equals",startValue:"",endValue:"",rangeStartType:"include",rangeEndType:"include"};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onComparisonOperatorChange=this.onComparisonOperatorChange.bind(this),this.onComparisonValueChange=this.onComparisonValueChange.bind(this),this.onTypeChange=this.onTypeChange.bind(this),this.onRangeStartTypeChange=this.onRangeStartTypeChange.bind(this),this.onRangeStartValueChange=this.onRangeStartValueChange.bind(this),this.onRangeEndTypeChange=this.onRangeEndTypeChange.bind(this),this.onRangeEndValueChange=this.onRangeEndValueChange.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onTypeChange(e){let{element:t}=this.props.context,{comparisonOperator:i,startValue:r,endValue:o,rangeStartType:s,rangeEndType:a}=this.state;e===iu?this.editCell(t.businessObject,qy(i,r)):this.editCell(t.businessObject,nu(r,o,s,a)),this.setState({type:e})}onComparisonOperatorChange(e){let{element:t}=this.props.context,{type:i,startValue:r}=this.state;i===iu&&(this.editCell(t.businessObject,qy(e,r)),this.setState({comparisonOperator:e}))}onComparisonValueChange(e){let{element:t}=this.props.context,{type:i,comparisonOperator:r}=this.state;i===iu&&(this.debouncedEditCell(t.businessObject,qy(r,e)),this.setState({startValue:e}))}onRangeStartTypeChange(e){let{element:t}=this.props.context,{type:i,startValue:r,endValue:o,rangeEndType:s}=this.state;i===ru&&(this.editCell(t.businessObject,nu(r,o,e,s)),this.setState({rangeStartType:e}))}onRangeStartValueChange(e){let{element:t}=this.props.context,{type:i,endValue:r,rangeStartType:o,rangeEndType:s}=this.state;i===ru&&(this.editCell(t.businessObject,nu(e,r,o,s)),this.setState({startValue:e}))}onRangeEndTypeChange(e){let{element:t}=this.props.context,{type:i,startValue:r,endValue:o,rangeStartType:s}=this.state;i===ru&&(this.editCell(t.businessObject,nu(r,o,s,e)),this.setState({rangeEndType:e}))}onRangeEndValueChange(e){let{element:t}=this.props.context,{type:i,startValue:r,rangeStartType:o,rangeEndType:s}=this.state;i===ru&&(this.editCell(t.businessObject,nu(r,e,o,s)),this.setState({endValue:e}))}renderComparison(e,t){let i=[{label:this._translate("Equals"),value:"equals"},{label:this._translate("Less"),value:"less"},{label:this._translate("Less or equals"),value:"lessEquals"},{label:this._translate("Greater"),value:"greater"},{label:this._translate("Greater or equals"),value:"greaterEquals"}];return y(1,"div","comparison",[y(1,"h4","dms-heading",Z("Value"),2),y(1,"div","dms-fill-row dms-input-duration-edit-row",[P(2,pe,{label:this._translate("Comparison operator"),noInput:!0,onChange:this.onComparisonOperatorChange,options:i,value:e}),Z("\xA0"),P(2,Qo,{label:this._translate("Duration value"),type:this._type,className:"comparison-duration-input",onInput:this.onComparisonValueChange,value:t})],4)],4)}renderRange(e,t,i,r){let o=[{label:this._translate("Include"),value:"include"},{label:this._translate("Exclude"),value:"exclude"}];return y(1,"div","range",[y(1,"h4","dms-heading",this._translate("Start value"),0),y(1,"div","dms-fill-row dms-input-duration-edit-row",[P(2,pe,{label:this._translate("Range start operator"),noInput:!0,onChange:this.onRangeStartTypeChange,options:o,value:i}),Z("\xA0"),P(2,Qo,{label:this._translate("Range start value"),type:this._type,className:"range-start-duration-input",onInput:this.onRangeStartValueChange,value:e})],4),y(1,"h4","dms-heading",this._translate("End value"),0),y(1,"div","dms-fill-row dms-input-duration-edit-row",[P(2,pe,{label:this._translate("Range end operator"),noInput:!0,onChange:this.onRangeEndTypeChange,options:o,value:r}),Z("\xA0"),P(2,Qo,{label:this._translate("Range end value"),type:this._type,className:"range-end-duration-input",onInput:this.onRangeEndValueChange,value:t})],4)],4)}render(){let{type:e,comparisonOperator:t,startValue:i,endValue:r,rangeStartType:o,rangeEndType:s}=this.state,a=[{label:this._translate("Comparison"),value:iu},{label:this._translate("Range"),value:ru}];return y(1,"div","context-menu-container simple-duration-edit",[y(1,"h3","dms-heading",this._translate("Edit duration"),0),y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Test type"),noInput:!0,onChange:this.onTypeChange,options:a,value:e}),2),e===iu&&this.renderComparison(t,i),e===ru&&this.renderRange(i,r,o,s)],0)}};function j8(n){return n.col.businessObject.inputExpression.typeRef}var dd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context;this._type=F8(i);let r=t.injector.get("debounceInput");this.debouncedEditCell=r(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onInput=this.onInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onInput(e){let{element:t}=this.props.context;this.debouncedEditCell(t.businessObject,`duration("${e}")`)}render(){let e=fw(this.props.context.element.businessObject.text,this._type);return y(1,"div","context-menu-container simple-duration-edit",[y(1,"h3","dms-heading",this._translate("Edit duration"),0),y(1,"h4","dms-heading",this._translate("Set duration"),0),P(2,Qo,{label:this._translate("Duration value"),onInput:this.onInput,value:e,type:this._type,className:"dms-block"})],4)}};function F8(n){return n.col.businessObject.typeRef}var ou=class{constructor(e,t){t.registerProvider(i=>{let r=U2(i);return(ie(i.col)||Te(i.col))&&Q2(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=U2(i.element);if(Q2(r)){if(ie(i.element.col))return hd;if(Te(i.element.col))return dd}}})}};ou.$inject=["components","simpleMode"];function U2(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}var q8=["yearMonthDuration","dayTimeDuration"];function Q2(n){return q8.includes(n)}var K2={__depends__:[Bt,en],__init__:["simpleDurationEdit"],simpleDurationEdit:["type",ou]};var V8=/^(-?(?:[0-9]|\.[0-9])+)$|^((?:<|>|=){0,2})\s*(-?(?:[0-9]|\.[0-9])+)$/,H8=/^(\[|\]){1}(-?(?:[0-9]|\.[0-9])+){1,}\.\.(-?(?:[0-9]|\.[0-9])+){1,}(\[|\]){1}$/,hw={equals:"=",less:"<",lessEquals:"<=",greater:">",greaterEquals:">="};function z8(n){return di(hw).filter(e=>n===hw[e])[0]}function Vy(n){if(!n||W8(n.trim()))return{type:"comparison"};let e=n.match(V8),t=n.match(H8);if(e){if(U8(e))return{type:"comparison",value:parseFloat(e[1]),operator:"equals"};if(Q8(e))return{type:"comparison",value:parseFloat(e[3]),operator:z8(e[2])}}else if(t)return{type:"range",values:[t[2],t[3]].map(i=>parseFloat(i)),start:t[1]==="]"?"exclude":"include",end:t[4]==="["?"exclude":"include"}}function W8(n){return n===""}function U8(n){return n[0]&&n[1]&&!n[2]&&!n[3]}function Q8(n){return n[0]&&!n[1]&&n[2]&&n[3]}function Hy(n,e){return n==="equals"?`${e}`:`${hw[n]} ${e}`}function su(n,e,t,i){return`${t==="exclude"?"]":"["}${n}..${e}${i==="exclude"?"[":"]"}`}var au="comparison",lu="range",pd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=Vy(i.businessObject.text);r?this.state={type:r.type,comparisonOperator:r.operator||"equals",comparisonValue:r.value||0,rangeStartValue:r.values?r.values[0]:0,rangeEndValue:r.values?r.values[1]:0,rangeStartType:r.start||"include",rangeEndType:r.end||"include"}:this.state={type:au,comparisonOperator:"equals",comparisonValue:0,rangeStartValue:0,rangeEndValue:0,rangeStartType:"include",rangeEndType:"include"};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onComparisonOperatorChange=this.onComparisonOperatorChange.bind(this),this.onComparisonValueChange=this.onComparisonValueChange.bind(this),this.onTypeChange=this.onTypeChange.bind(this),this.onRangeStartTypeChange=this.onRangeStartTypeChange.bind(this),this.onRangeStartValueChange=this.onRangeStartValueChange.bind(this),this.onRangeEndTypeChange=this.onRangeEndTypeChange.bind(this),this.onRangeEndValueChange=this.onRangeEndValueChange.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onTypeChange(e){let{element:t}=this.props.context,{comparisonOperator:i,comparisonValue:r,rangeStartValue:o,rangeEndValue:s,rangeStartType:a,rangeEndType:l}=this.state;e===au?this.editCell(t.businessObject,Hy(i,r)):this.editCell(t.businessObject,su(o,s,a,l)),this.setState({type:e})}onComparisonOperatorChange(e){let{element:t}=this.props.context,{type:i,comparisonValue:r}=this.state;i===au&&(this.editCell(t.businessObject,Hy(e,r)),this.setState({comparisonOperator:e}))}onComparisonValueChange(e){let{element:t}=this.props.context,{type:i,comparisonOperator:r}=this.state;i===au&&(this.debouncedEditCell(t.businessObject,Hy(r,e)),this.setState({comparisonValue:e}))}onRangeStartTypeChange(e){let{element:t}=this.props.context,{type:i,rangeStartValue:r,rangeEndValue:o,rangeEndType:s}=this.state;i===lu&&(this.editCell(t.businessObject,su(r,o,e,s)),this.setState({rangeStartType:e}))}onRangeStartValueChange(e){let{element:t}=this.props.context,{type:i,rangeEndValue:r,rangeStartType:o,rangeEndType:s}=this.state;i===lu&&(this.editCell(t.businessObject,su(e,r,o,s)),this.setState({rangeStartValue:e}))}onRangeEndTypeChange(e){let{element:t}=this.props.context,{type:i,rangeStartValue:r,rangeEndValue:o,rangeStartType:s}=this.state;i===lu&&(this.editCell(t.businessObject,su(r,o,s,e)),this.setState({rangeEndType:e}))}onRangeEndValueChange(e){let{element:t}=this.props.context,{type:i,rangeStartValue:r,rangeStartType:o,rangeEndType:s}=this.state;i===lu&&(this.editCell(t.businessObject,su(r,e,o,s)),this.setState({rangeEndValue:e}))}renderComparison(e,t){let i=[{label:this._translate("Equals"),value:"equals"},{label:this._translate("Less"),value:"less"},{label:this._translate("Less or equals"),value:"lessEquals"},{label:this._translate("Greater"),value:"greater"},{label:this._translate("Greater or equals"),value:"greaterEquals"}];return y(1,"div","comparison",[y(1,"h4","dms-heading",this._translate("Value"),0),y(1,"div","dms-fill-row",[P(2,pe,{label:this._translate("Comparison operator"),noInput:!0,onChange:this.onComparisonOperatorChange,options:i,value:e}),Z("\xA0"),P(2,St,{label:this._translate("Value"),className:"comparison-number-input",onInput:this.onComparisonValueChange,type:"number",value:t})],4)],4)}renderRange(e,t,i,r){let o=[{label:this._translate("Include"),value:"include"},{label:this._translate("Exclude"),value:"exclude"}];return y(1,"div","range",[y(1,"h4","dms-heading",this._translate("Start value"),0),y(1,"div","dms-fill-row",[P(2,pe,{label:this._translate("Start value"),noInput:!0,onChange:this.onRangeStartTypeChange,options:o,value:i}),Z("\xA0"),P(2,St,{className:"range-start-number-input",onInput:this.onRangeStartValueChange,type:"number",value:e})],4),y(1,"h4","dms-heading",this._translate("End value"),0),y(1,"div","dms-fill-row",[P(2,pe,{label:this._translate("End value"),noInput:!0,onChange:this.onRangeEndTypeChange,options:o,value:r}),Z("\xA0"),P(2,St,{className:"range-end-number-input",onInput:this.onRangeEndValueChange,type:"number",value:t})],4)],4)}render(){let{type:e,comparisonOperator:t,comparisonValue:i,rangeStartValue:r,rangeEndValue:o,rangeStartType:s,rangeEndType:a}=this.state,l=[{label:this._translate("Comparison"),value:au},{label:this._translate("Range"),value:lu}];return y(1,"div","context-menu-container simple-number-edit",[y(1,"h3","dms-heading",this._translate("Edit number"),0),y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Test type"),noInput:!0,onChange:this.onTypeChange,options:l,value:e}),2),e===au&&this.renderComparison(t,i),e===lu&&this.renderRange(r,o,s,a)],0)}};var md=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=Vy(i.businessObject.text);r?this.state={value:r.value}:this.state={value:""};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onInput=this.onInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onInput(e){let{element:t}=this.props.context;this.debouncedEditCell(t.businessObject,e),this.setState({value:e})}render(){let{value:e}=this.state;return y(1,"div","context-menu-container simple-number-edit",[y(1,"h3","dms-heading",this._translate("Edit number"),0),y(1,"h4","dms-heading",this._translate("Set value"),0),P(2,St,{onInput:this.onInput,type:"number",value:e})],4)}};var cu=class{constructor(e,t){t.registerProvider(i=>{let r=G2(i);return(ie(i.col)||Te(i.col))&&X2(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=G2(i.element);if(X2(r)){if(ie(i.element.col))return pd;if(Te(i.element.col))return md}}})}};cu.$inject=["components","simpleMode"];function G2(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}var K8=["number","integer","long","double"];function X2(n){return K8.includes(n)}var Y2={__depends__:[Bt,en],__init__:["simpleNumberEdit"],simpleNumberEdit:["type",cu]};function gd(n){if(!n||J2(n.trim()))return{type:"disjunction",values:[]};let e=n.split(","),t={type:"disjunction",values:[]},i="";if(e.forEach(o=>{i+=o,/^"[^"]*"$/.test(i.trim())?(t.values.push(i.trim()),i=""):i+=","}),!i)return t;t.type="negation",t.values=[],i="";let r=n.match(/^\s*not\((.*)\)\s*$/);if(r&&(e=r[1].split(","),e.forEach(o=>{i+=o,/^"[^"]*"$/.test(i.trim())?(t.values.push(i.trim()),i=""):i+=","}),!i))return t}function Z2(n){let e=ie(n)?n.inputValues:n.outputValues;return!e||J2(e.text)?[]:e.text.split(",").map(t=>t.trim())}function J2(n){return n===""}var na="disjunction",zy="negation",G8="Predefined values",X8="Predefined values",Y8="Custom values",yd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let i=gd(e.context.element.businessObject.text);i||(i={values:[],type:na});let r=Z2(e.context.element.col.businessObject),o=i.values.filter(u=>!pw(r,u)),s=ie(e.context.element.col),a=r.map(u=>({value:u,isChecked:pw(i.values,u),isRemovable:!1,group:s?this._translate(G8):this._translate(X8)}));s&&(a=a.concat(o.map(u=>({value:u,isChecked:!0,isRemovable:!0,group:this._translate(Y8)}))));let l="";!s&&i.values.length&&!pw(r,i.values[0])&&(l=i.values[0]),this.state={items:a,unaryTestsType:i.type,inputValue:l,isOutputValueInputChecked:l!==""};let c=t.injector.get("debounceInput");this.debouncedEditCell=c(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.addUnaryTestsListItem=this.addUnaryTestsListItem.bind(this),this.onInput=this.onInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onOutputValueInputClick=this.onOutputValueInputClick.bind(this),this.onUnaryTestsListChanged=this.onUnaryTestsListChanged.bind(this),this.onUnaryTestsTypeChange=this.onUnaryTestsTypeChange.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onUnaryTestsTypeChange(e){let{items:t}=this.state,i=dw(t),{element:r}=this.props.context;e===na?(this.editCell(r.businessObject,i.join(",")),this.setState({unaryTestsType:na})):(this.editCell(r.businessObject,`not(${i.join(",")})`),this.setState({unaryTestsType:zy}))}onUnaryTestsListChanged(e){let t=dw(e),{element:i}=this.props.context,{unaryTestsType:r}=this.state;r===na?this.editCell(i.businessObject,t.join(",")):this.editCell(i.businessObject,`not(${t.join(",")})`),this.setState({items:e,isOutputValueInputChecked:!1})}onOutputValueInputClick(){let{element:e}=this.props.context,{inputValue:t,items:i}=this.state,r=gd(t);!r||r.values.length>1||(this.editCell(e.businessObject,`${r.values.join("")}`),this.setState({items:i.map(o=>(o.isChecked=!1,o)),isOutputValueInputChecked:!0}))}onInput({isValid:e,value:t}){let{isOutputValueInputChecked:i}=this.state;this.setState({inputValue:t});let{element:r}=this.props.context;!ie(r)&&e&&i&&this.debouncedEditCell(r.businessObject,t)}onKeyDown({isValid:e,event:t}){if(!Z8(t.keyCode))return;let{element:i}=this.props.context,r=ie(i.col);(r||!e)&&(t.stopPropagation(),t.preventDefault()),e&&(r?this.addUnaryTestsListItem():this.onOutputValueInputClick())}addUnaryTestsListItem(){let{inputValue:e,items:t,unaryTestsType:i}=this.state,r=gd(e);if(!r)return;let{element:o}=this.props.context,s=dw(t),a=[].concat(s,r.values);i===na?this.editCell(o.businessObject,a.join(",")):this.editCell(o.businessObject,`not(${a.join(",")})`);let l=t.concat(r.values.map(c=>({value:c,isChecked:!0,isRemovable:!0,group:this._translate("Custom values")})));this.setState({items:l,inputValue:""})}render(){let{element:e}=this.props.context,{inputValue:t,isOutputValueInputChecked:i,items:r,unaryTestsType:o}=this.state,s=[{label:this._translate("Match one"),value:na},{label:this._translate("Match none"),value:zy}],a=ie(e.col),l=o===zy,c=!a&&r.length>0;return y(1,"div","simple-string-edit context-menu-container",[y(1,"h3","dms-heading",this._translate("Edit string"),0),a&&y(1,"p",null,P(2,pe,{label:this._translate("String value"),noInput:!0,onChange:this.onUnaryTestsTypeChange,options:s,value:l?zy:na},null,u=>this.selectNode=u),2),P(2,Js,{onChange:this.onUnaryTestsListChanged,items:r,type:a?"checkbox":"radio"}),a?y(1,"h4","dms-heading",this._translate("Add values"),0):y(1,"h4","dms-heading",this._translate("Set value"),0),y(1,"div","dms-fill-row",[c&&y(64,"input","cursor-pointer",null,1,{checked:i,onClick:this.onOutputValueInputClick,type:"radio",style:{marginRight:"8px"}}),P(2,ot,{label:a?this._translate("Values"):this._translate("Value"),className:"dms-block",onKeyDown:this.onKeyDown,onInput:this.onInput,placeholder:a?this._translate('"value", "value", ...'):this._translate('"value"'),type:"text",validate:u=>{if(!gd(u))return this._translate("Strings must be in double quotes")},value:t})],0)],0)}};function Z8(n){return n===13}function dw(n){return n.filter(e=>e.isChecked).map(e=>e.value)}function pw(n,e){return n.indexOf(e)!==-1}var uu=class{constructor(e,t){t.registerProvider(i=>(ie(i.col)||Te(i.col))&&eD(i)==="string"),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;if(eD(i.element)==="string")return yd}})}};uu.$inject=["components","simpleMode"];function eD(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}var tD={__depends__:[Bt,en],__init__:["simpleStringEdit"],simpleStringEdit:["type",uu]};var J8=/^(?:\d\d:){2}\d\d(?:Z|(?:[@+-][^")]+))?$/,e9=/^\[time\("([^"]*)"\)..time\("([^"]*)"\)\]$/,t9=/^(<|>)\s*time\("([^"]*)"\)$/,n9=/^time\("([^"]*)"\)$/,i9="exact",r9="before",o9="after",s9="between";function Ko(n){if(!J8.test(n.trim()))return"Time must match pattern hh:mm:ss[time zone]"}function Gr(n,e){if(n===i9)return`time("${e[0]}")`;if(n===r9)return`< time("${e[0]}")`;if(n===o9)return`> time("${e[0]}")`;if(n===s9)return`[time("${e[0]}")..time("${e[1]}")]`}function vd(){return new Date().toISOString().slice(11,-5)+"Z"}function ia(n){if(!n||n.trim()==="")return{type:"exact",time:""};let e=n.match(e9);if(e)return{type:"between",times:[e[1],e[2]]};if(e=n.match(t9),e)return{type:e[1]==="<"?"before":"after",time:e[2]};if(e=n.match(n9),e)return{type:"exact",time:e[1]}}var nD="exact",a9="before",l9="after",Wy="between",xd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=ia(i.businessObject.text);if(r){let s;r.time?s=[r.time,""]:r.times?s=r.times:s=["",""],this.state={type:r.type,times:s}}else this.state={type:nD,times:["",""]};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onTypeChange=this.onTypeChange.bind(this),this.onSetStartTimeNowClick=this.onSetStartTimeNowClick.bind(this),this.onSetEndTimeNowClick=this.onSetEndTimeNowClick.bind(this),this.onStartTimeInput=this.onStartTimeInput.bind(this),this.onEndTimeInput=this.onEndTimeInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onTypeChange(e){let{element:t}=this.props.context,{times:i}=this.state;this.setState({type:e}),ia(Gr(e,i))&&this.editCell(t.businessObject,Gr(e,i))}onSetStartTimeNowClick(){let{element:e}=this.props.context,{times:t,type:i}=this.state,r=vd();this.setState({times:[r,t[1]]}),ia(Gr(i,[r,t[1]]))&&this.editCell(e.businessObject,Gr(i,[r,t[1]]))}onSetEndTimeNowClick(){let{element:e}=this.props.context,{times:t,type:i}=this.state,r=vd();this.setState({times:[t[0],r]}),ia(Gr(i,[t[0],r]))&&this.editCell(e.businessObject,Gr(i,[t[0],r]))}onStartTimeInput({value:e}){let{element:t}=this.props.context,{times:i,type:r}=this.state;this.setState({times:[e,i[1]]}),this.debouncedEditCell(t.businessObject,Gr(r,[e,i[1]]))}onEndTimeInput({value:e}){let{element:t}=this.props.context,{times:i,type:r}=this.state;this.setState({times:[i[0],e]}),this.debouncedEditCell(t.businessObject,Gr(r,[i[0],e]))}render(){let{times:e,type:t}=this.state,i=[{label:this._translate("Exactly"),value:nD},{label:this._translate("Before"),value:a9},{label:this._translate("After"),value:l9},{label:this._translate("Between"),value:Wy}];return y(1,"div","context-menu-container simple-time-edit",[y(1,"h3","dms-heading",this._translate("Edit time"),0),y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Time"),noInput:!0,onChange:this.onTypeChange,options:i,value:t}),2),y(1,"h4","dms-heading",t===Wy?this._translate("Edit start time"):this._translate("Set time"),0),y(1,"div",null,[P(2,ot,{label:this._translate("Start time"),className:"start-time-input dms-block",onInput:this.onStartTimeInput,placeholder:this._translate("e.g. { example } ",{example:Bn()}),validate:r=>Ko(r)&&this._translate(Ko(r)),value:e[0]}),y(1,"p","dms-hint",[y(1,"button","use-now",this._translate("Use now"),0,{type:"button",onClick:this.onSetStartTimeNowClick}),Z(".")],4)],4),t===Wy&&y(1,"h4","dms-heading",this._translate("Edit end time"),0),t===Wy&&y(1,"div",null,[P(2,ot,{label:this._translate("End time"),className:"end-time-input dms-block",onInput:this.onEndTimeInput,placeholder:this._translate("e.g. { example } ",{example:Bn()}),validate:r=>Ko(r)&&this._translate(Ko(r)),value:e[1]}),y(1,"p","dms-hint",[y(1,"button","use-now",this._translate("Use now"),0,{type:"button",onClick:this.onSetEndTimeNowClick}),Z(".")],4)],4)],0)}};var bd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=ia(i.businessObject.text);this.state={date:r?r.date:""};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onClick=this.onClick.bind(this),this.onInput=this.onInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onClick(){let{element:e}=this.props.context,t=vd();this.setState({date:t}),this.editCell(e.businessObject,`time("${t}")`)}onInput({value:e}){let{element:t}=this.props.context;this.setState({date:e}),this.debouncedEditCell(t.businessObject,`time("${e}")`)}render(){let{date:e}=this.state;return y(1,"div","context-menu-container simple-time-edit",[y(1,"h3","dms-heading",this._translate("Edit time"),0),y(1,"h4","dms-heading",this._translate("Set time"),0),y(1,"div",null,[P(2,ot,{label:this._translate("Time value"),onInput:this.onInput,placeholder:this._translate("e.g. { example } ",{example:Bn()}),validate:t=>Ko(t)&&this._translate(Ko(t)),value:e,className:"dms-block"}),y(1,"p","dms-hint",[y(1,"button","use-now",this._translate("Use now"),0,{type:"button",onClick:this.onClick}),Z(".")],4)],4)],4)}};var fu=class{constructor(e,t){t.registerProvider(i=>{let r=iD(i);return(ie(i.col)||Te(i.col))&&rD(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=iD(i.element);if(rD(r)){if(ie(i.element.col))return xd;if(Te(i.element.col))return bd}}})}};fu.$inject=["components","simpleMode"];function iD(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}function rD(n){return n==="time"}var oD={__depends__:[Bt,en],__init__:["simpleTimeEdit"],simpleTimeEdit:["type",fu]};var hu=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"handleMouseDown",t=>{let i=De(t.target,"th",!1);c9({node:i,event:t,minWidth:this.props.minWidth||150,onEnd:this.saveWidth})});M(this,"saveWidth",t=>{let{col:i}=this.props,r={};O(i,"dmn:DecisionTable")?r.annotationsWidth=t:r.width=t,this.modeling.updateProperties(i,r)});Ce(this)}componentDidMount(){let t=this.getRoot();this.changeSupport.onElementsChanged(t,this.onElementsChanged)}componentWillUnmount(){let t=this.getRoot();this.changeSupport.offElementsChanged(t,this.onElementsChanged)}getRoot(){return this.sheet.getRoot()}isLastInputOrOutput(){let{col:t}=this.props,i=this.getRoot(),r=Ke(i);if(O(t,"dmn:InputClause")){let o=r.get("input");return o.indexOf(t)===o.length-1}else if(O(t,"dmn:OutputClause")){let o=r.get("output");return o.indexOf(t)===o.length-1}}render(){let t=this.isLastInputOrOutput()?{right:"-7px",width:"27px"}:null;return y(1,"div","resize-column-handle",null,1,{onMouseDown:this.handleMouseDown,title:this.translate("Resize"),style:t})}};hu.$inject=["sheet","changeSupport","translate","modeling"];function c9({node:n,event:e,minWidth:t,onEnd:i=u9}){e.preventDefault();let r=n.getBoundingClientRect().width,o=e.clientX,s;document.addEventListener("mousemove",a),document.addEventListener("mouseup",l);function a(u){u.preventDefault();let f=c(u.clientX);s&&cancelAnimationFrame(s),s=requestAnimationFrame(()=>{n.style.width=f+"px"})}function l(u){u.preventDefault(),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",l);let f=c(u.clientX);i(f)}function c(u){let f=u-o;return Math.max(r+f,t)}}function u9(){}function Uy(n){n.onGetComponent("cell-inner",(e={})=>{let{cellType:t}=e;if(t==="input-cell"||t==="output-cell"||t==="annotations")return hu})}Uy.$inject=["components"];var sD={__init__:["columnResizeProvider"],columnResizeProvider:["type",Uy]};var _d=class n extends Ao{getModules(){return[...Ao._getModules(),...n._getModules()]}static _getModules(){return[RR,DR,Po,Gt,lg,LR,BR,Xi,NR,Jn,h2,sD,v2,w2,C2,Qt,Yn,Bt,E2,cg,S2,_l,A2,M2,Mo,en,I2,$2,V2,K2,Y2,tD,oD,tl]}};var du=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;r<i;r++){let{id:o}=e[r];if(t[o])return;t[o]=!0;let s=this._listeners[o]&&this._listeners[o].length;if(s)for(let a=0;a<s;a++)this._listeners[o][a]&&this._listeners[o][a]()}}onElementsChanged(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e][this._listeners[e].length]=t}offElementsChanged(e,t){if(this._listeners[e])if(t){let i=this._listeners[e].indexOf(t);i!==-1&&this._listeners[e].splice(i,1)}else this._listeners[e].length=0}updateId(e,t){this._listeners[e]&&(this._listeners[t]=this._listeners[e],delete this._listeners[e])}};du.$inject=["eventBus"];var f9=1e3,wd=class{constructor(){this._listeners={}}getComponent(e,t){let i=this._listeners[e];if(!i)return;let r;for(let o=0;o<i.length&&(r=i[o].callback(t),!r);o++);return r}getComponents(e,t){let i=this._listeners[e];if(!i)return;let r=[];for(let o=0;o<i.length;o++){let s=i[o].callback(t);s&&r.push(s)}if(r.length)return r}onGetComponent(e,t,i){if(ge(t)&&(i=t,t=f9),!se(t))throw new Error("priority must be a number");let r=this._getListeners(e),o,s,a={priority:t,callback:i};for(s=0;o=r[s];s++)if(o.priority<t){r.splice(s,0,a);return}r.push(a)}offGetComponent(e,t){let i=this._getListeners(e),r,o,s;if(t)for(s=i.length-1;r=i[s];s--)o=r.callback,o===t&&i.splice(s,1);else i.length=0}_getListeners(e){let t=this._listeners[e];return t||(this._listeners[e]=t=[]),t}};var Cd=class extends L{constructor(e){super(e);let t=this._injector=e.injector;this._changeSupport=t.get("changeSupport"),this._components=t.get("components"),this._renderer=t.get("renderer")}getChildContext(){return{changeSupport:this._changeSupport,components:this._components,renderer:this._renderer,injector:this._injector}}render(){let e=this._components.getComponents("viewer");return y(1,"div","viewer-container",e&&e.map((t,i)=>P(2,t,null,i)),0)}};var pu=class{constructor(e,t,i,r,o){let{container:s}=i;this._container=s,r.on("renderer.mount",()=>{xa(P(2,Cd,{injector:o}),s)}),r.on("renderer.unmount",()=>{xa(null,s)})}getContainer(){return this._container}};pu.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var aD={__init__:["changeSupport","components","renderer"],changeSupport:["type",du],components:["type",wd],eventBus:["type",ut],renderer:["type",pu]};var ra=class{constructor(e={}){let{injector:t}=e;if(!t){let{modules:i,config:r}=this._init(e);t=h9(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 h9(n,e){let t=[{config:["value",n]},aD].concat(e||[]),i=new os(t);return i.init(),i}var mu=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}};mu.$inject=["viewer","eventBus"];var lD={__init__:["elementRegistry"],elementRegistry:["type",mu]};var Ed=class extends L{constructor(e,t){super(e,t),this._viewer=t.injector.get("viewer")}render(){let{name:e}=this._viewer.getDecision();return y(1,"div","decision-properties",y(1,"h3","decision-name",e,0),2)}};var d9=1500,gu=class{constructor(e){e.onGetComponent("viewer",d9,()=>Ed)}};gu.$inject=["components"];var cD={__init__:["decisionProperties"],decisionProperties:["type",gu]};var Sd=class extends L{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 y(1,"div","literal-expression-properties",y(1,"table",null,[y(1,"tr",null,[y(1,"td",null,this._translate("Variable name:"),0),y(1,"td",null,y(1,"span",null,t.name||"-",0),2)],4),y(1,"tr",null,[y(1,"td",null,this._translate("Variable type:"),0),y(1,"td",null,y(1,"span",null,this._translate(t.typeRef||"")||"-",0),2)],4),y(1,"tr",null,[y(1,"td",null,this._translate("Expression language:"),0),y(1,"td",null,y(1,"span",null,e.expressionLanguage||"-",0),2)],4)],4),2)}};var p9=500,yu=class{constructor(e){e.onGetComponent("viewer",p9,()=>Sd)}};yu.$inject=["components"];var uD={__depends__:[],__init__:["literalExpressionProperties"],literalExpressionProperties:["type",yu]};var m9=2e3,vu=class{constructor(e){e.onGetComponent("viewer",m9,()=>co)}};vu.$inject=["components"];var fD={__init__:["poweredBy"],poweredBy:["type",vu]};var Od=class extends L{constructor(e,t){super(e,t),this._viewer=t.injector.get("viewer")}render(){let{text:e}=this._viewer.getDecision().decisionLogic;return y(1,"div","textarea",y(1,"div","content",e,0),2)}};var xu=class{constructor(e){e.onGetComponent("viewer",()=>Od)}};xu.$inject=["components"];var hD={__init__:["textarea"],textarea:["type",xu]};var bu=class extends L{constructor(t,i){super(t,i);M(this,"onClick",()=>{this._eventBus.fire("showDrd")});let{injector:r}=i;this._translate=r.get("translate"),this._eventBus=r.get("eventBus")}render(){return y(1,"div","view-drd",y(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,t=>this.node=t)}};bu.$inject=["translate"];var g9=2e3,_u=class{constructor(e,t,i,r){this._injector=r,this._viewer=t,e.onGetComponent("viewer",g9,()=>{if(this.canViewDrd())return bu}),i.on("showDrd",()=>{let o=r.get("_parent",!1),s=this.getDefinitions(),a=o.getView(s);o.open(a)})}canViewDrd(){let e=this._injector.get("_parent",!1);if(!e)return;let t=this.getDefinitions();return!!e.getView(t)}getDefinitions(){return y9(this._viewer.getDecision())}};_u.$inject=["components","viewer","eventBus","injector"];function y9(n){return n.$parent}var dD={__init__:["viewDrd"],viewDrd:["type",_u]};var Go=class n extends ra{constructor(e={}){let t=n._createContainer();super(T(e,{renderer:{container:t}})),this._container=t}open(e){var t=this;return new Promise(function(i,r){var o;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(s){o=s}o?(o.warnings=o.warnings||[],r(o)):i({warnings:[]})})}_init(e){let{modules:t,additionalModules:i,...r}=e,o=t||this.getModules(),s=i||[],a=[{viewer:["value",this]}];return{modules:[...o,...s,...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",{}),Qe(e))}destroy(){super.destroy(),this.detach()}getModules(){return n._getModules()}static _getModules(){return[lD,qe,cD,uD,fD,hD,dD]}static _createContainer(){return te('<div class="dmn-literal-expression-container"></div>')}};var kd=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"setDecisionName",t=>{this._modeling.editDecisionName(t)});this._viewer=i.injector.get("viewer"),this._modeling=i.injector.get("modeling"),this._translate=i.injector.get("translate"),this.setupChangeListeners({bind:this.getDecision().id})}componentWillUnmount(){this.setupChangeListeners({unbind:this.getDecision().id})}getDecision(){return this._viewer.getDecision()}setupChangeListeners({bind:t,unbind:i}){let{changeSupport:r}=this.context;typeof i=="string"&&r.offElementsChanged(i,this.onElementsChanged),typeof t=="string"&&r.onElementsChanged(t,this.onElementsChanged)}render(){let{name:t}=this.getDecision();return y(1,"header","decision-properties",P(2,mw,{label:this._translate("Decision name"),className:"decision-name editor",value:t,onBlur:v9,onChange:this.setDecisionName}),2)}},mw=class extends an{render(){return y(1,"h3",this.getClassName(),this.getEditor(),0)}};function v9(n){n.target.scroll(0,0)}var x9=1500,wu=class{constructor(e){e.onGetComponent("viewer",x9,()=>kd)}};wu.$inject=["components"];var pD={__depends__:[Kt,qe],__init__:["decisionProperties"],decisionProperties:["type",wu]};var mD="is not a registered action",b9="is already registered",Cu=class{constructor(e,t){this._actions={undo(){e.undo()},redo(){e.redo()}}}trigger(e,t){if(!this._actions[e])throw gw(e,mD);return this._actions[e](t)}register(e,t){if(typeof e=="string")return this._registerAction(e,t);k(e,(i,r)=>{this._registerAction(r,i)},this)}_registerAction(e,t){if(this.isRegistered(e))throw gw(e,b9);this._actions[e]=t}unregister(e){if(!this.isRegistered(e))throw gw(e,mD);this._actions[e]=void 0}isRegistered(e){return!!this._actions[e]}};Cu.$inject=["commandStack","eventBus"];function gw(n,e){return new Error(n+" "+e)}var gD={__init__:["editorActions"],editorActions:["type",Cu]};function yw(n){return n.altKey?!1:n.ctrlKey||n.metaKey}function vw(n){return n.shiftKey}var yD="Keyboard binding is now implicit; explicit binding to an element got removed. For more information, see https://github.com/bpmn-io/diagram-js/pull/662",Eu=class{constructor(e,t,i,r){M(this,"_init",()=>{this._registerDefaultBindings(),this._fire("init")});M(this,"_destroy",()=>{this._fire("destroy"),this.unbind(),this._listeners=null});M(this,"_keyHandler",e=>{var t,i,r=this._listeners,o=e.keyCode||e.charCode||-1;for(t=0;i=r[t];t++)if(i(o,e)){e.preventDefault(),e.stopPropagation();return}});M(this,"unbind",()=>{var e=this._node;e&&(this._fire("unbind"),q.unbind(e,"keydown",this._keyHandler,!0)),this._node=null});this._config=e||{},this._eventBus=t,this._editorActions=i,this._listeners=[],t.on("viewer.destroy",this._destroy),t.on("viewer.init",this._init),t.on("attach",()=>{this._config.bindTo&&console.error("unsupported configuration <keyboard.bindTo>",new Error(yD)),this._target=r.getContainer();var o=this._config&&this._config.bind!==!1;o&&this.bind()}),t.on("detach",this.unbind)}bind(e){e&&console.error("unsupported argument <node>",new Error(yD)),this.unbind(),e=this._node=this._target,q.bind(e,"keydown",this._keyHandler,!0),this._fire("bind")}getBinding(){return this._node}_fire(e){this._eventBus.fire("keyboard."+e,{node:this._node,listeners:this._listeners})}_registerDefaultBindings(){var e=this._listeners,t=this._editorActions;function i(o,s){if(yw(s)&&!vw(s)&&o===90)return t.trigger("undo"),!0}function r(o,s){if(yw(s)&&(o===89||o===90&&vw(s)))return t.trigger("redo"),!0}e.push(i),e.push(r)}addListener(e){this._listeners.unshift(e)}removeListener(e){this._listeners=this._listeners.filter(t=>t!==e)}};Eu.$inject=["config.keyboard","eventBus","editorActions","renderer"];var Qy={__depends__:[gD],__init__:["keyboard"],keyboard:["type",Eu]};var Rd=class extends L{constructor(t,i){super(t,i);M(this,"onChange",()=>{let t=this._viewer.getDecision();t.variable&&this.setState({name:t.variable.name})});this._translate=i.injector.get("translate"),this._viewer=i.injector.get("viewer"),this._modeling=i.injector.get("modeling"),this._dataTypes=i.injector.get("dataTypes"),this._eventBus=i.injector.get("eventBus");let r=this._viewer.getDecision();this.state={name:r.variable.name,typeRef:r.variable.typeRef},this.setVariableName=this.setVariableName.bind(this),this.setVariableType=this.setVariableType.bind(this)}setVariableName(t){this._modeling.editVariableName(t),this.setState({name:t})}componentWillMount(){this._eventBus.on("elements.changed",this.onChange)}componentWillUnmount(){this._eventBus.off("elements.changed",this.onChange)}setVariableType(t){t===""?(this._modeling.editVariableType(void 0),this.setState({typeRef:void 0})):(this._modeling.editVariableType(t),this.setState({typeRef:t}))}render(){let{name:t,typeRef:i}=this.state,r=this._dataTypes.getAll().map(o=>({label:this._translate(o),value:o}));return y(1,"div","literal-expression-properties",y(1,"table","variables-table",[y(1,"tr",null,[y(1,"td",null,this._translate("Variable name:"),0),y(1,"td",null,P(2,St,{label:this._translate("Variable name"),className:"variable-name-input",onInput:this.setVariableName,placeholder:this._translate("name"),value:t||""}),2)],4),y(1,"tr",null,[y(1,"td",null,this._translate("Variable type:"),0),y(1,"td",null,y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Variable type"),onChange:this.setVariableType,options:r,value:i,className:"variable-type-select dms-block"}),2),2)],4),P(2,xw)],4),2)}},xw=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._viewer=t.injector.get("viewer"),this._modeling=t.injector.get("modeling"),this._expressionLanguages=t.injector.get("expressionLanguages"),this.setExpressionLanguage=this.setExpressionLanguage.bind(this)}setExpressionLanguage(e){e===""?this._modeling.editExpressionLanguage(void 0):this._modeling.editExpressionLanguage(e)}_getExpressionLanguage(){let t=this._viewer.getDecision().decisionLogic;return t&&t.expressionLanguage?t.expressionLanguage.toLowerCase():this._getDefaultExpressionLanguage()}_getDefaultExpressionLanguage(){return this._expressionLanguages.getDefault().value}_shouldRender(){return this._expressionLanguages.getAll().length>1?!0:this._getExpressionLanguage()!==this._getDefaultExpressionLanguage()}render(){if(!this._shouldRender())return null;let e=this._getExpressionLanguage(),t=this._expressionLanguages.getAll();return y(1,"tr",null,[y(1,"td",null,this._translate("Expression language:"),0),y(1,"td",null,y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Expression language"),onChange:this.setExpressionLanguage,options:t,value:e,className:"expression-language-select dms-block"}),2),2)],4)}};var _9=500,Su=class{constructor(e){e.onGetComponent("viewer",_9,()=>Rd)}};Su.$inject=["components"];var vD={__depends__:[Kt,Qy,Qt,Yn,Xi],__init__:["literalExpressionProperties"],literalExpressionProperties:["type",Su]};var Ou=class n{constructor(e,t,i){this._commandStack=e,this._viewer=t,this._eventBus=i,i.on("viewer.init",()=>{w9(this.getHandlers(),e)})}getHandlers(){return n._getHandlers()}static _getHandlers(){return{"element.updateProperties":sr}}getDecision(){return this._viewer.getDecision()}editDecisionName(e){let i={element:this.getDecision(),properties:{name:e}};this._commandStack.execute("element.updateProperties",i)}editDecisionId(e){let i={element:this.getDecision(),properties:{id:e}};this._commandStack.execute("element.updateProperties",i)}editLiteralExpressionText(e){let r={element:this.getDecision().decisionLogic,properties:{text:e}};this._commandStack.execute("element.updateProperties",r)}editExpressionLanguage(e){let r={element:this.getDecision().decisionLogic,properties:{expressionLanguage:e}};this._commandStack.execute("element.updateProperties",r)}editVariableName(e){let r={element:this.getDecision().variable,properties:{name:e}};this._commandStack.execute("element.updateProperties",r)}editVariableType(e){let r={element:this.getDecision().variable,properties:{typeRef:e}};this._commandStack.execute("element.updateProperties",r)}updateProperties(e,t){let i={element:e,properties:t};this._commandStack.execute("element.updateProperties",i)}};Ou.$inject=["commandStack","viewer","eventBus"];function w9(n,e){k(n,function(t,i){e.registerHandler(i,t)})}var xD={__init__:["idChangeBehavior","nameChangeBehavior","modeling"],commandStack:["type",ke],idChangeBehavior:["type",Gn],nameChangeBehavior:["type",qi],modeling:["type",Ou]};var Td=class extends L{constructor(e,t){super(e,t),this._modeling=t.injector.get("modeling"),this._viewer=t.injector.get("viewer"),this._expressionLanguages=t.injector.get("expressionLanguages"),this._variableResolver=t.injector.get("variableResolver",!1),this._translate=t.injector.get("translate"),this.editLiteralExpressionText=this.editLiteralExpressionText.bind(this),this.onElementsChanged=this.onElementsChanged.bind(this);let{id:i}=this.getLiteralExpression();t.changeSupport.onElementsChanged(i,this.onElementsChanged)}getLiteralExpression(){return this._viewer.getDecision().decisionLogic}onElementsChanged(){this.forceUpdate()}editLiteralExpressionText(e){this._modeling.editLiteralExpressionText(e)}getEditor(){return this.isFeel()?bw:_w}isFeel(){return this.getExpressionLanguage()==="feel"}getExpressionLanguage(){return this.getLiteralExpression().expressionLanguage||this._expressionLanguages.getDefault().value}_getVariables(){let e=this.getLiteralExpression();return this._variableResolver&&this._variableResolver.getVariables(e)}render(){let{text:e}=this.getLiteralExpression(),t=this.getEditor(),i=this._getVariables();return P(2,t,{label:this._translate("Literal expression editor"),className:"textarea editor",value:e,onChange:this.editLiteralExpressionText,variables:i})}},bw=class extends L{render(){return P(2,Ri,{label:this.props.label,className:this.props.className,value:this.props.value,onInput:this.props.onChange,variables:this.props.variables})}},_w=class extends an{render(){return y(1,"div",this.getClassName(),this.getEditor(),0)}};var ku=class{constructor(e){e.onGetComponent("viewer",()=>Td)}};ku.$inject=["components"];var bD={__depends__:[Kt,qe],__init__:["textarea"],textarea:["type",ku]};var Ad=class n extends Go{getModules(){return[...Go._getModules(),...n._getModules()]}static _getModules(){return[pD,Qy,vD,xD,Qt,Yn,Xi,bD,tl]}};var Md=class{constructor(e){e.onGetComponent("viewer",()=>C9),e.onGetComponent("viewer",()=>E9),e.onGetComponent("viewer",()=>S9)}};M(Md,"$inject",["components"]);function C9(n,{injector:e}){let i=e.get("components").getComponents("header");return y(1,"div","dmn-boxed-expression-section dmn-boxed-expression-header",i&&i.map((r,o)=>P(2,r,null,o)),0)}function E9(n,{injector:e}){let i=e.get("components").getComponents("body");return y(1,"div","dmn-boxed-expression-section dmn-boxed-expression-body",i&&i.map((r,o)=>P(2,r,null,o)),0)}function S9(n,{injector:e}){let i=e.get("components").getComponents("footer");return y(1,"div","dmn-boxed-expression-section dmn-boxed-expression-footer",i&&i.map((r,o)=>P(2,r,null,o)),0)}var Pd=class{constructor(e){e.onGetComponent("viewer",()=>{let t=e.getComponents("table.before")||[];return()=>y(1,"div",null,t.map((i,r)=>P(2,i,null,r)),0)})}};M(Pd,"$inject",["components"]);var _D={__init__:["viewRenderer","tableJsSupport"],viewRenderer:["type",Md],tableJsSupport:["type",Pd]};var O9=2e3,Ru=class{constructor(e){e.onGetComponent("viewer",O9,()=>co)}};Ru.$inject=["components"];var wD={__init__:["poweredBy"],poweredBy:["type",Ru]};var Dd=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(O(t,"dmn:LiteralExpression"))return k9})}};M(Dd,"$inject",["components"]);function k9({expression:n},e){let i=e.injector.get("literalExpression").getText(n);return y(1,"div","textarea",y(1,"div","content",i,0),2)}var oa=class{getText(e){return e.get("text")}};var CD={__init__:["literalExpressionComponent"],literalExpressionComponent:["type",Dd],literalExpression:["type",oa]};var Tu=class{getParameters(e){return e.get("formalParameter")}getBody(e){return e.get("body")}getKind(e){return e.get("kind")||"FEEL"}};var Id=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(O(t,"dmn:FunctionDefinition"))return R9})}};M(Id,"$inject",["components"]);function R9({expression:n},e){let t=e.injector.get("functionDefinition"),i=t.getKind(n),r=t.getParameters(n),o=t.getBody(n);return y(1,"div","function-definition",[P(2,A9,{kind:i}),P(2,M9,{parameters:r}),P(2,D9,{expression:o})],4)}var T9={FEEL:"F",Java:"J",PMML:"P"};function A9({kind:n},e){let t=e.injector.get("translate");return y(1,"div","function-definition-kind",T9[n],0,{title:t("Function kind: {kind}",{kind:n})})}function M9({parameters:n}){return y(1,"div","function-definition-parameters",y(1,"div",null,[Z("("),n.reduce((e,t)=>e.concat(P(2,P9,{parameter:t}),", "),[]).slice(0,-1),Z(")")],0),2)}function P9({parameter:n}){let{name:e,typeRef:t}=n,i=e||"<unnamed>";return y(1,"span",null,t?`${i}: ${t}`:i,0)}function D9({expression:n},e){let t=e.components.getComponent("expression",{expression:n});return y(1,"div","function-definition-body",P(2,t,{expression:n}),2)}var ED={__init__:["functionDefinitionComponent"],functionDefinition:["type",Tu],functionDefinitionComponent:["type",Id]};var Au=class extends L{constructor(t,i){super(t,i);M(this,"onClick",()=>{this._eventBus.fire("showDrd")});let{injector:r}=i;this._translate=r.get("translate"),this._eventBus=r.get("eventBus")}render(){return y(1,"div","view-drd",y(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,t=>this.node=t)}};Au.$inject=["translate"];var I9=2e3,Mu=class{constructor(e,t,i){this._injector=i,e.onGetComponent("viewer",I9,()=>{if(this.canViewDrd())return Au}),t.on("showDrd",()=>{let r=i.get("_parent",!1),o=r.getDefinitions(),s=r.getView(o);r.open(s)})}canViewDrd(){let e=this._injector.get("_parent",!1);if(!e)return;let t=e.getDefinitions();return!!e.getView(t)}};Mu.$inject=["components","eventBus","injector"];var SD={__init__:["viewDrd"],viewDrd:["type",Mu]};function ww(n,e){let t=e.injector.get("viewer"),{name:i}=t.getRootElement();return y(1,"div","element-properties",y(1,"h2","element-name",i,0),2)}var Pu=class{constructor(e){e.onGetComponent("header",()=>ww)}};Pu.$inject=["components"];var OD={__init__:["elementProperties"],elementProperties:["type",Pu]};var L9=100,Du=class{constructor(e){e.onGetComponent("body",()=>B9),e.onGetComponent("expression",L9,()=>$9)}};M(Du,"$inject",["components"]);function B9(n,{injector:e}){let t=e.get("components"),r=e.get("viewer").getRootElement(),o=N9(r),s=t.getComponent("expression",{expression:o});return P(2,s,{expression:o})}function N9(n){if(O(n,"dmn:Decision"))return n.get("decisionLogic");if(O(n,"dmn:BusinessKnowledgeModel"))return n.get("encapsulatedLogic")}function $9({expression:n}){return y(1,"div",null,y(1,"span",null,[Z("Expression of type "),n.$type,Z(" is not supported.")],0,{style:"color:red;"}),2)}var kD={__init__:["elementLogic"],elementLogic:["type",Du]};var Xo=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")}};M(Xo,"$inject",["viewer"]);var Iu=class{constructor(e){e.onGetComponent("footer",()=>j9)}};M(Iu,"$inject",["components"]);function j9(n,e){let t=e.injector.get("elementVariable"),i=e.injector.get("translate"),r=t.getName(),o=t.getType();return y(1,"div","element-variable",[y(1,"h2",null,Z("Result"),2),y(1,"div","element-variable-name",[y(1,"span","element-variable-name-label",i("Variable name"),0),y(1,"span",null,r,0)],4),y(1,"div","element-variable-type",[y(1,"span","element-variable-type-label",i("Variable type"),0),y(1,"span",null,o,0)],4)],4)}var RD={__init__:["elementVariableComponent"],elementVariable:["type",Xo],elementVariableComponent:["type",Iu]};var sa=class n extends ra{constructor(e={}){let t=n._createContainer();super(T(e,{renderer:{container:t}})),this._container=t}open(e){let t=this.get("eventBus");return new Promise((i,r)=>{let o;try{this.getRootElement()&&(this.clear(),t.fire("renderer.unmount")),this._setRootElement(e),t.fire("import",e),t.fire("renderer.mount")}catch(s){o=s}o?(o.warnings=o.warnings||[],r(o)):i({warnings:[]})})}_init(e){let{modules:t,additionalModules:i,...r}=e,o=t||this.getModules(),s=i||[],a=[{viewer:["value",this]}];return{modules:[...o,...s,...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",{}),Qe(e))}destroy(){super.destroy(),this.detach()}getModules(){return[_D,qe,wD,SD,OD,kD,ED,CD,RD]}static _createContainer(){return te('<div class="dmn-boxed-expression-container"></div>')}};var Ld=class{constructor(e,t){this.registerBindings(t,e)}registerBindings(e,t){function i(r,o){t.isRegistered(r)&&e.addListener(o)}i("undo",function(r){let o=r.keyEvent;if(Tp(o))return t.trigger("undo"),!0}),i("redo",function(r){let o=r.keyEvent;if(Ap(o))return t.trigger("redo"),!0})}};M(Ld,"$inject",["editorActions","keyboard"]);var TD={__depends__:[_o],__init__:["keyboardBindings"],keyboardBindings:["type",Ld]};var Lu=class extends ae{constructor(t,i){super(t);M(this,"updateName",({context:t})=>{let{element:i,properties:r}=t;this.isNameChanged(r)&&(this.isVariable(i)?this.handleVariableNameChange(i):this.isVariableContainer(i)&&this.handleVariableContainerNameChange(i))});this._modeling=i,this.postExecuted("element.updateProperties",this.updateName)}isNameChanged(t){return"name"in t}isVariable(t){let i=AD(t);return O(t,"dmn:InformationItem")&&i&&i.get("variable")===t}isVariableContainer(t){let i=t.get("variable");return i&&O(i,"dmn:InformationItem")}handleVariableNameChange(t){let i=AD(t),r=t.get("name");r!==i.get("name")&&this._modeling.updateProperties(i,{name:r})}handleVariableContainerNameChange(t){let i=t.get("variable"),r=t.get("name");i&&r!==i.get("name")&&this._modeling.updateProperties(i,{name:r})}};M(Lu,"$inject",["eventBus","modeling"]);function AD(n){return n.$parent}var Bu=class{constructor(e,t,i){this._commandStack=e,this._viewer=t,this._eventBus=i,F9(this._getHandlers(),e)}_getHandlers(){return{"element.updateProperties":sr}}updateProperties(e,t){let i={element:e,properties:t};this._commandStack.execute("element.updateProperties",i)}};Bu.$inject=["commandStack","viewer","eventBus"];function F9(n,e){k(n,function(t,i){e.registerHandler(i,t)})}var MD={__init__:["idChangeBehavior","modeling","nameChangeBehavior"],commandStack:["type",ke],idChangeBehavior:["type",Gn],modeling:["type",Bu],nameChangeBehavior:["type",Lu]};function Nn(n,e){return function(t){return En(P(2,Cw,{...t,_component:n,_selectDependencies:e}))}}var Cw=class extends L{constructor(t,i){super(t,i);M(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 En(P(2,t,{...this.props}))}};var Ew=class extends L{constructor(t,i){super(t,i);M(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()?q9:Sw}isFeel(){let t=this.getLiteralExpression();return h1(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(),o=this._translate("Literal expression");return P(2,i,{label:o,className:"textarea editor",value:t,onChange:this.editLiteralExpressionText,variables:r})}};function q9(n){return En(P(2,Ri,{...n,onChange:n.onChange}))}var Sw=class extends an{render(){return y(1,"div",this.getClassName(),this.getEditor(),0)}},V9=Nn(Ew,n=>[n.expression]),Bd=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(O(t,"dmn:LiteralExpression"))return V9})}};M(Bd,"$inject",["components"]);var Nu=class extends oa{constructor(e){super(),this._modeling=e}setText(e,t){this._modeling.updateProperties(e,{text:t})}};Nu.$inject=["modeling"];var PD={__init__:["literalExpressionComponent"],literalExpressionComponent:["type",Bd],literalExpression:["type",Nu]};var Nd=class extends Tu{constructor(e,t){super(),this._modeling=e,this._dmnFactory=t}addParameter(e){this._modeling.updateProperties(e,{formalParameter:[...this.getParameters(e),this._dmnFactory.create("dmn:InformationItem",{name:"",typeRef:""})]})}removeParameter(e,t){this._modeling.updateProperties(e,{formalParameter:this.getParameters(e).filter(i=>i!==t)})}updateParameter(e,t){this._modeling.updateProperties(e,t)}setKind(e,t){this._modeling.updateProperties(e,{kind:t})}};M(Nd,"$inject",["modeling","dmnFactory"]);function Ow({label:n,onClick:e}){return y(1,"button","edit-button dmn-icon-edit",null,1,{"aria-label":n,type:"button",onClick:e})}var $d=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(O(t,"dmn:FunctionDefinition"))return H9})}};M($d,"$inject",["components"]);var H9=Nn(z9,n=>[n.expression]);function z9({expression:n},e){let t=e.injector.get("functionDefinition"),i=e.injector.get("contextMenu"),r=t.getKind(n),o=t.getParameters(n),s=t.getBody(n),a=c=>{let u=DD(c);i.open(u,{contextMenuType:"kind-editor",expression:n})},l=c=>{let u=DD(c);i.open(u,{contextMenuType:"formal-parameters-editor",expression:n})};return y(1,"div","function-definition",[P(2,U9,{kind:r,openEditor:a}),P(2,Q9,{parameters:o,openEditor:l}),P(2,X9,{expression:s,parameters:o})],4)}var W9={FEEL:"F",Java:"J",PMML:"P"};function U9({kind:n,openEditor:e},t){let i=t.injector.get("translate");return y(1,"div","function-definition-kind",[W9[n],P(2,Ow,{label:i("Edit function kind"),onClick:e})],0)}function Q9({openEditor:n,parameters:e},t){let i=t.injector.get("translate");return y(1,"div","function-definition-parameters",[y(1,"div",null,[Z("("),e.reduce((r,o)=>r.concat(P(2,K9,{parameter:o}),", "),[]).slice(0,-1),Z(")")],0),P(2,Ow,{label:i("Edit formal parameters"),onClick:n})],4)}var K9=Nn(G9,n=>[n.parameter]);function G9({parameter:n}){let{name:e,typeRef:t}=n,i=e||"<unnamed>";return y(1,"span",null,t?`${i}: ${t}`:i,0)}var X9=Nn(Y9,n=>n.parameters);function Y9({expression:n,parameters:e},t){let i=t.components.getComponent("expression",{expression:n});return y(1,"div","function-definition-body",P(2,i,{expression:n,parameters:e}),2)}function DD(n){let e=n.target.parentElement,t=e.getBoundingClientRect();return{x:t.x,y:t.y}}var Z9=[{value:"FEEL",label:"FEEL"},{value:"Java",label:"Java"},{value:"PMML",label:"PMML"}],jd=class{constructor(e){e.onGetComponent("context-menu",(t={})=>{if(t.contextMenuType&&t.contextMenuType==="kind-editor")return J9})}};M(jd,"$inject",["components"]);function J9({context:{expression:n}},e){let t=e.injector.get("functionDefinition"),i=e.injector.get("translate"),r=t.getKind(n),o=s=>{t.setKind(n,s)};return y(1,"div","context-menu-container",[y(1,"h3",null,i("Edit function kind"),0),P(2,pe,{label:i("Kind"),options:Z9,value:r,onChange:o,noInput:!0})],4)}var Fd=class{constructor(e){e.onGetComponent("context-menu",(t={})=>{if(t.contextMenuType&&t.contextMenuType==="formal-parameters-editor")return eU})}};M(Fd,"$inject",["components"]);var eU=Nn(tU,n=>[n.context.expression]);function tU({context:{expression:n}},e){let t=e.injector.get("functionDefinition"),i=e.injector.get("translate"),r=t.getParameters(n),o=a=>{t.removeParameter(n,a)},s=()=>{t.addParameter(n)};return y(1,"div","context-menu-container formal-parameters",[y(1,"h3",null,i("Edit formal parameters"),0),r.length?y(1,"table",null,[y(1,"thead",null,y(1,"tr",null,[y(1,"th",null,Z("Name"),2),y(1,"th",null,Z("Type"),2)],4),2),y(1,"tbody",null,r.map((a,l)=>P(2,nU,{parameter:a,remove:()=>o(a)},l)),0)],4):null,y(1,"button","add-parameter",i("Add parameter"),0,{type:"button",onClick:s})],0)}var nU=Nn(function({parameter:n,remove:e},t){let i=t.injector.get("dataTypes"),r=t.injector.get("translate"),o=t.injector.get("functionDefinition"),{name:s,typeRef:a}=n,l=f=>{o.updateParameter(n,{name:f})},c=f=>{o.updateParameter(n,{typeRef:f})},u=i.getAll().map(f=>({label:r(f),value:f}));return y(1,"tr","function-definition-parameter",[y(1,"td",null,P(2,St,{onChange:l,value:s}),2),y(1,"td",null,P(2,pe,{onChange:c,value:a,options:u}),2),y(1,"td",null,y(1,"button","dmn-icon-trash",null,1,{type:"button",onClick:e,"aria-label":r("Remove parameter")}),2)],4)},n=>[n.parameter]);var ID={__init__:["formalParametersEditorComponent","functionDefinitionComponent","kindEditorComponent"],__depends__:[Gt],formalParametersEditorComponent:["type",Fd],functionDefinition:["type",Nd],functionDefinitionComponent:["type",$d],kindEditorComponent:["type",jd]};var iU=Nn(function(n,e){let{element:t}=n,i=e.injector.get("modeling"),r=e.injector.get("translate"),o=t.get("name"),s=a=>{i.updateProperties(t,{name:a})};return P(2,St,{label:r("Element name"),className:"element-name editor",value:o,onChange:s})},n=>[n.element]);function kw(n,e){let i=e.injector.get("viewer").getRootElement();return y(1,"div","element-properties",P(2,iU,{element:i}),2)}var $u=class{constructor(e){e.onGetComponent("header",()=>kw)}};$u.$inject=["components"];var LD={__depends__:[Kt],__init__:["elementProperties"],elementProperties:["type",$u]};var ju=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}};ju.$inject=["viewer","eventBus"];var qd=class{constructor(e){this._moddle=e}create(e,t={}){return this._moddle.create(e,t)}};M(qd,"$inject",["moddle"]);var BD={__init__:["elementRegistry"],elementRegistry:["type",ju],dmnFactory:["type",qd]};var Fu=class extends Xo{constructor(e,t,i){super(e),this._modeling=t,this._dmnFactory=i}setType(e){let t=this.getVariable();if(!t){let i=this._getElement(),r=this._dmnFactory.create("dmn:InformationItem",{name:i.get("name"),typeRef:e});r.$parent=i,this._modeling.updateProperties(i,{variable:r});return}this._modeling.updateProperties(t,{typeRef:e})}};M(Fu,"$inject",["viewer","modeling","dmnFactory"]);var ND="dmn-boxed-expression-variable-type",qu=class{constructor(e,t){let i=Nn(rU,()=>[t.getVariable()]);e.onGetComponent("footer",()=>i)}};M(qu,"$inject",["components","elementVariable"]);function rU(n,e){let t=e.injector.get("elementVariable"),i=e.injector.get("translate"),r=t.getName();return y(1,"div","element-variable",[y(1,"h2",null,Z("Result"),2),y(1,"div","element-variable-name",[y(1,"span","element-variable-name-label",i("Variable name"),0),y(1,"span",null,r,0)],4),y(1,"div","element-variable-type",[y(1,"label","element-variable-type-label",Z("Result type"),2,{for:ND}),P(2,oU)],4)],4)}function oU(n,e){let t=e.injector.get("elementVariable"),i=e.injector.get("dataTypes"),r=e.injector.get("translate"),o=t.getType(),s=l=>t.setType(l),a=i.getAll().map(l=>({label:r(l),value:l}));return P(2,pe,{value:o,onChange:s,options:a,id:ND})}var $D={__init__:["elementVariableComponent"],elementVariable:["type",Fu],elementVariableComponent:["type",qu]};var jD="is not a registered action",sU="is already registered",Vu=class{constructor(e,t){this._actions={undo(){e.undo()},redo(){e.redo()}}}trigger(e,t){if(!this._actions[e])throw Rw(e,jD);return this._actions[e](t)}register(e,t){if(typeof e=="string")return this._registerAction(e,t);k(e,(i,r)=>{this._registerAction(r,i)},this)}_registerAction(e,t){if(this.isRegistered(e))throw Rw(e,sU);this._actions[e]=t}unregister(e){if(!this.isRegistered(e))throw Rw(e,jD);this._actions[e]=void 0}isRegistered(e){return!!this._actions[e]}};Vu.$inject=["commandStack","eventBus"];function Rw(n,e){return new Error(n+" "+e)}var FD={__init__:["editorActions"],editorActions:["type",Vu]};var Vd=class extends sa{getModules(){return[...super.getModules(),BD,MD,FD,LD,ID,Qt,Yn,PD,TD,Xi,$D,tl]}};var Yo=class extends Yu{_getViewProviders(){return[{id:"drd",constructor:So,opens:"dmn:Definitions"},{id:"decisionTable",constructor:_d,opens(e){return O(e,"dmn:Decision")&&O(e.decisionLogic,"dmn:DecisionTable")}},{id:"literalExpression",constructor:Ad,opens(e){return O(e,"dmn:Decision")&&O(e.decisionLogic,"dmn:LiteralExpression")}},{id:"boxedExpression",constructor:Vd,opens(e){return O(e,"dmn:BusinessKnowledgeModel")&&dr(e)}}]}_getInitialView(e,...t){let i=super._getInitialView(e,...t);if(!i)return;let r=i.element;return O(r,"dmn:Definitions")&&!La(r)&&(i=ye(e,o=>!O(o.element,"dmn:Definitions"))||i),i}};var Hd=class extends rs{_getViewProviders(){return[{id:"drd",constructor:Et,opens(e){return O(e,"dmn:Definitions")&&La(e)}},{id:"decisionTable",constructor:Ao,opens(e){return O(e,"dmn:Decision")&&O(e.decisionLogic,"dmn:DecisionTable")}},{id:"literalExpression",constructor:Go,opens(e){return O(e,"dmn:Decision")&&O(e.decisionLogic,"dmn:LiteralExpression")}},{id:"boxedExpression",constructor:sa,opens(e){return O(e,"dmn:BusinessKnowledgeModel")&&dr(e)}}]}};var aU=globalThis;Object.assign(Yo,{Modeler:Yo,Viewer:Hd});aU.DmnJS=Yo;var UTe=Yo;})(); 1941