likec4 1.19.1 → 1.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +0,0 @@
1
- function ve(n,e){if(typeof n>"u"||n==null)throw new Error(e??`Expected defined value, but received ${n}`);return n}function re(n,e){if(!n)throw new Error(e??"Invariant failed")}function Be(n){throw new Error(`NonExhaustive value: ${n}`)}function es(n,e,t){let r=i=>n(i,...e);return t===void 0?r:Object.assign(r,{lazy:t,lazyArgs:e})}function ue(n,e,t){let r=n.length-e.length;if(r===0)return n(...e);if(r===1)return es(n,e,t);throw new Error("Wrong number of arguments")}function Tn(...n){return ue(ts,n,ns)}var ts=(n,e)=>n.length<e.length?n.map((t,r)=>[t,e[r]]):e.map((t,r)=>[n[r],t]),ns=n=>(e,t)=>({hasNext:!0,next:[e,n[t]],done:t>=n.length-1}),rs={done:!0,hasNext:!1},Bn={done:!1,hasNext:!1},is=()=>rs;function J(n,...e){let t=n,r=e.map(a=>"lazy"in a?os(a):void 0),i=0;for(;i<e.length;){if(r[i]===void 0||!ss(t)){let m=e[i];t=m(t),i+=1;continue}let a=[];for(let m=i;m<e.length;m++){let b=r[m];if(b===void 0||(a.push(b),b.isSingle))break}let f=[];for(let m of t)if(ei(m,f,a))break;let{isSingle:p}=a.at(-1);t=p?f[0]:f,i+=a.length}return t}function ei(n,e,t){if(t.length===0)return e.push(n),!1;let r=n,i=Bn,a=!1;for(let[f,p]of t.entries()){let{index:m,items:b}=p;if(b.push(r),i=p(r,m,b),p.index+=1,i.hasNext){if(i.hasMany??!1){for(let S of i.next)if(ei(S,e,t.slice(f+1)))return!0;return a}r=i.next}if(!i.hasNext)break;i.done&&(a=!0)}return i.hasNext&&e.push(r),a}function os(n){let{lazy:e,lazyArgs:t}=n,r=e(...t);return Object.assign(r,{isSingle:e.single??!1,index:0,items:[]})}function ss(n){return typeof n=="string"||typeof n=="object"&&n!==null&&Symbol.iterator in n}function Ze(...n){return ue(as,n)}var as=(n,e)=>n.length>=e;function ti(...n){return ue(us,n)}function us(n,e){let t=[];for(let[r,i]of n.entries()){if(!e(i,r,n))break;t.push(i)}return t}function be(...n){return ue(cs,n,ds)}var cs=(n,e)=>n.map(e),ds=n=>(e,t,r)=>({done:!1,hasNext:!0,next:n(e,t,r)});function yn(n){return typeof n=="string"}function Wn(n){return typeof n=="function"}function Fn(n){return n!=null}function wn(n){return n!==void 0}function wt(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Pn,ni;function ls(){if(ni)return Pn;ni=1;function n(e){if(typeof e!="function")throw new Error("mnemonist/DefaultMap.constructor: expecting a function.");this.items=new Map,this.factory=e,this.size=0}return n.prototype.clear=function(){this.items.clear(),this.size=0},n.prototype.get=function(e){var t=this.items.get(e);return typeof t>"u"&&(t=this.factory(e,this.size),this.items.set(e,t),this.size++),t},n.prototype.peek=function(e){return this.items.get(e)},n.prototype.set=function(e,t){return this.items.set(e,t),this.size=this.items.size,this},n.prototype.has=function(e){return this.items.has(e)},n.prototype.delete=function(e){var t=this.items.delete(e);return this.size=this.items.size,t},n.prototype.forEach=function(e,t){t=arguments.length>1?t:this,this.items.forEach(e,t)},n.prototype.entries=function(){return this.items.entries()},n.prototype.keys=function(){return this.items.keys()},n.prototype.values=function(){return this.items.values()},typeof Symbol<"u"&&(n.prototype[Symbol.iterator]=n.prototype.entries),n.prototype.inspect=function(){return this.items},typeof Symbol<"u"&&(n.prototype[Symbol.for("nodejs.util.inspect.custom")]=n.prototype.inspect),n.autoIncrement=function(){var e=0;return function(){return e++}},Pn=n,Pn}var hs=ls();const Oe=wt(hs);var qn,ri;function Kn(){if(ri)return qn;ri=1;function n(e){if(typeof e!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=e}return typeof Symbol<"u"&&(n.prototype[Symbol.iterator]=function(){return this}),n.of=function(){var e=arguments,t=e.length,r=0;return new n(function(){return r>=t?{done:!0}:{done:!1,value:e[r++]}})},n.empty=function(){var e=new n(function(){return{done:!0}});return e},n.fromSequence=function(e){var t=0,r=e.length;return new n(function(){return t>=r?{done:!0}:{done:!1,value:e[t++]}})},n.is=function(e){return e instanceof n?!0:typeof e=="object"&&e!==null&&typeof e.next=="function"},qn=n,qn}var Yn={},ii;function fs(){return ii||(ii=1,Yn.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u",Yn.SYMBOL_SUPPORT=typeof Symbol<"u"),Yn}var Vn,oi;function Xn(){if(oi)return Vn;oi=1;var n=fs(),e=n.ARRAY_BUFFER_SUPPORT,t=n.SYMBOL_SUPPORT;return Vn=function(r,i){var a,f,p,m,b;if(!r)throw new Error("obliterator/forEach: invalid iterable.");if(typeof i!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(r)||e&&ArrayBuffer.isView(r)||typeof r=="string"||r.toString()==="[object Arguments]"){for(p=0,m=r.length;p<m;p++)i(r[p],p);return}if(typeof r.forEach=="function"){r.forEach(i);return}if(t&&Symbol.iterator in r&&typeof r.next!="function"&&(r=r[Symbol.iterator]()),typeof r.next=="function"){for(a=r,p=0;b=a.next(),b.done!==!0;)i(b.value,p),p++;return}for(f in r)r.hasOwnProperty(f)&&i(r[f],f)},Vn}function ps(n,e,t){return n.length===0||e.length===0?[]:(t??=Object.is,J(Tn(n,e),ti(([r,i])=>t(r,i)),be(([r,i])=>r)))}var Hn={exports:{}},si;function gs(){if(si)return Hn.exports;si=1;var n=function(e,t){var r,i,a=1,f=0,p=0,m=String.alphabet;function b(S,C,G){if(G){for(r=C;G=b(S,r),G<76&&G>65;)++r;return+S.slice(C-1,r)}return G=m&&m.indexOf(S.charAt(C)),G>-1?G+76:(G=S.charCodeAt(C)||0,G<45||G>127?G:G<46?65:G<48?G-1:G<58?G+18:G<65?G-11:G<91?G+11:G<97?G-37:G<123?G+5:G-63)}if((e+="")!=(t+="")){for(;a;)if(i=b(e,f++),a=b(t,p++),i<76&&a<76&&i>66&&a>66&&(i=b(e,f,f),a=b(t,p,f=r),p=r),i!=a)return i<a?-1:1}return 0};try{Hn.exports=n}catch{String.naturalCompare=n}return Hn.exports}var ms=gs();const ys=wt(ms);function vn(n,e){return n===e?0:yn(n)?yn(e)?ys(n,e):1:yn(e)?-1:0}function ct(n){return n!=null&&typeof n=="string"}function Jn(n){return!!n&&Array.isArray(n)&&n.length>0}function at(n){const e=n.lastIndexOf(".");return e>0?n.slice(0,e):null}function ai(n){const e=n.lastIndexOf(".");return e>0?n.slice(e+1):n}const Jt=n=>ct(n)?n:n.id;function ye(n,e){const t=Jt(n);return e?Jt(e).startsWith(t+"."):r=>{const i=Jt(r);return t.startsWith(i+".")}}function Lt(n,e){if(!e)return i=>Lt(n,i);const t=Jt(n),r=Jt(e);return t===r||r.startsWith(t+".")||t.startsWith(r+".")}function dt(n,e){return e?ye(e,n):t=>ye(n,t)}function Dt(n){return(ct(n)?n:n.id).split(".").length}function ws(n,e){const t=ct(n)?n:n.id,r=ct(e)?e:e.id;if(t===r)return 0;const i=Dt(t),a=Dt(r);if(Lt(t,r))return Math.abs(i-a);const f=lt(t,r),p=f?Dt(f):0;return i+a-(2*p+1)}function lt(n,e){const t=n.split(".");if(t.length<2)return null;const r=e.split(".");if(r.length<2)return null;let i=[];for(let a=0;a<Math.min(t.length,r.length)-1&&t[a]===r[a];a++)i.push(t[a]);return i.length===0?null:i.join(".")}function ht(n){const e=n.split(".");return e.pop(),e.length===0?[]:e.reduce((t,r,i)=>i===0?(t.push(r),t):(t.unshift(`${t[0]}.${r}`),t),[])}function ui(n,e){const t=n.split(".").length,r=e.split(".").length;switch(!0){case t>r:return 1;case t<r:return-1;default:return 0}}function ci(n,e){return ui(n.id,e.id)}function Qn(n){return n.map(e=>({item:e,fqn:e.id.split(".")})).sort((e,t)=>e.fqn.length-t.fqn.length).map(({item:e})=>e)}function vs(n,e){let t=e;for(const r of n)ye(r,t)&&(t=r);return t!==e?t:null}function bn(n){const e=[],t=[...n];let r;for(;r=t.shift();){let i;for(;i=vs(t,r);)e.push(t.splice(t.indexOf(i),1)[0]);e.push(r)}return e}function xn(n,e){if(!n||ct(n)){const r=n??"asc";return i=>xn(i,r)}const t=e==="desc"?-1:1;return n.map(r=>({item:r,fqn:r.id.split(".")})).sort((r,i)=>{if(r.fqn.length!==i.fqn.length)return(r.fqn.length-i.fqn.length)*t;for(let a=0;a<r.fqn.length;a++){const f=vn(r.fqn[a],i.fqn[a]);if(f!==0)return f}return 0}).map(({item:r})=>r)}function Zn(n,e,t){let r=n.get(e);return r||(r=t(e),n.set(e,r)),r}function vt(n){return Fn(n)&&typeof n=="object"&&Symbol.iterator in n}function Me(n,e){const t=e??n;re(Wn(t));function*r(i){for(const a of i)t(a)&&(yield a)}return e?r(n):r}function bs(n){return n?di(n):di}function*di(n){for(const e of n)yield*e}function xs(n,e){const t=e??n;re(Wn(t));function*r(i){for(const a of i)yield t(a)}return e?r(n):r}function Qt(n,e){const t=e??n;re(Wn(t));function r(i){for(const a of i)if(t(a))return!0;return!1}return e?r(n):r}function ce(n){return n?Array.from(n):e=>Array.from(e)}function et(n){return n?new Set(n):e=>new Set(e)}function li(n){return n?function*(){yield*hi(n)}():hi}function*hi(n){const e=new Set;for(const t of n)e.has(t)||(e.add(t),yield t)}var fi={},pi;function Es(){return pi||(pi=1,function(n){n.intersection=function(){if(arguments.length<2)throw new Error("mnemonist/Set.intersection: needs at least two arguments.");var e=new Set,t=1/0,r=null,i,a,f=arguments.length;for(a=0;a<f;a++){if(i=arguments[a],i.size===0)return e;i.size<t&&(t=i.size,r=i)}for(var p=r.values(),m,b,S,C;m=p.next(),!m.done;){for(b=m.value,S=!0,a=0;a<f;a++)if(C=arguments[a],C!==r&&!C.has(b)){S=!1;break}S&&e.add(b)}return e},n.union=function(){if(arguments.length<2)throw new Error("mnemonist/Set.union: needs at least two arguments.");var e=new Set,t,r=arguments.length,i,a;for(t=0;t<r;t++)for(i=arguments[t].values();a=i.next(),!a.done;)e.add(a.value);return e},n.difference=function(e,t){if(!e.size)return new Set;if(!t.size)return new Set(e);for(var r=new Set,i=e.values(),a;a=i.next(),!a.done;)t.has(a.value)||r.add(a.value);return r},n.symmetricDifference=function(e,t){for(var r=new Set,i=e.values(),a;a=i.next(),!a.done;)t.has(a.value)||r.add(a.value);for(i=t.values();a=i.next(),!a.done;)e.has(a.value)||r.add(a.value);return r},n.isSubset=function(e,t){var r=e.values(),i;if(e===t)return!0;if(e.size>t.size)return!1;for(;i=r.next(),!i.done;)if(!t.has(i.value))return!1;return!0},n.isSuperset=function(e,t){return n.isSubset(t,e)},n.add=function(e,t){for(var r=t.values(),i;i=r.next(),!i.done;)e.add(i.value)},n.subtract=function(e,t){for(var r=t.values(),i;i=r.next(),!i.done;)e.delete(i.value)},n.intersect=function(e,t){for(var r=e.values(),i;i=r.next(),!i.done;)t.has(i.value)||e.delete(i.value)},n.disjunct=function(e,t){for(var r=e.values(),i,a=[];i=r.next(),!i.done;)t.has(i.value)&&a.push(i.value);for(r=t.values();i=r.next(),!i.done;)e.has(i.value)||e.add(i.value);for(var f=0,p=a.length;f<p;f++)e.delete(a[f])},n.intersectionSize=function(e,t){var r;if(e.size>t.size&&(r=e,e=t,t=r),e.size===0)return 0;if(e===t)return e.size;for(var i=e.values(),a,f=0;a=i.next(),!a.done;)t.has(a.value)&&f++;return f},n.unionSize=function(e,t){var r=n.intersectionSize(e,t);return e.size+t.size-r},n.jaccard=function(e,t){var r=n.intersectionSize(e,t);if(r===0)return 0;var i=e.size+t.size-r;return r/i},n.overlap=function(e,t){var r=n.intersectionSize(e,t);return r===0?0:r/Math.min(e.size,t.size)}}(fi)),fi}var _s=Es();function xe(...n){let e=new Set;for(const t of n)for(const r of t)e.add(r);return e}function Ce(n,...e){let t=new Set;if(n.size===0)return t;let r=e.length>1?_s.intersection(...e):e[0];if(r.size===0)return t;for(const i of n)r.has(i)&&t.add(i);return t}function pe(n,e){if(n.size===0)return new Set;if(e.size===0)return new Set(n);let t=new Set;for(const r of n)e.has(r)||t.add(r);return t}function er(n,e){return n.size===e.size&&[...n].every(t=>e.has(t))}function gi(n,e){if(n.size===0||e.size===0)return!1;e.size<n.size&&([n,e]=[e,n]);for(const t of n)if(e.has(t))return!0;return!1}function tr(n){let e=5381;const t=n.length;re(t>0,"stringHash: empty string");for(let r=0;r<t;r++)e=e*33^n.charCodeAt(r);return(e>>>0).toString(36)}function En(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var mi={exports:{}},yi;function ks(){return yi||(yi=1,function(n,e){(function(t){n.exports=t()})(function(){return function t(r,i,a){function f(b,S){if(!i[b]){if(!r[b]){var C=typeof En=="function"&&En;if(!S&&C)return C(b,!0);if(p)return p(b,!0);throw new Error("Cannot find module '"+b+"'")}S=i[b]={exports:{}},r[b][0].call(S.exports,function(G){var D=r[b][1][G];return f(D||G)},S,S.exports,t,r,i,a)}return i[b].exports}for(var p=typeof En=="function"&&En,m=0;m<a.length;m++)f(a[m]);return f}({1:[function(t,r,i){(function(a,f,p,m,b,S,C,G,D){var A=t("crypto");function U(_,M){M=V(_,M);var x;return(x=M.algorithm!=="passthrough"?A.createHash(M.algorithm):new X).write===void 0&&(x.write=x.update,x.end=x.update),F(M,x).dispatch(_),x.update||x.end(""),x.digest?x.digest(M.encoding==="buffer"?void 0:M.encoding):(_=x.read(),M.encoding!=="buffer"?_.toString(M.encoding):_)}(i=r.exports=U).sha1=function(_){return U(_)},i.keys=function(_){return U(_,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},i.MD5=function(_){return U(_,{algorithm:"md5",encoding:"hex"})},i.keysMD5=function(_){return U(_,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var I=A.getHashes?A.getHashes().slice():["sha1","md5"],W=(I.push("passthrough"),["buffer","hex","binary","base64"]);function V(_,M){var x={};if(x.algorithm=(M=M||{}).algorithm||"sha1",x.encoding=M.encoding||"hex",x.excludeValues=!!M.excludeValues,x.algorithm=x.algorithm.toLowerCase(),x.encoding=x.encoding.toLowerCase(),x.ignoreUnknown=M.ignoreUnknown===!0,x.respectType=M.respectType!==!1,x.respectFunctionNames=M.respectFunctionNames!==!1,x.respectFunctionProperties=M.respectFunctionProperties!==!1,x.unorderedArrays=M.unorderedArrays===!0,x.unorderedSets=M.unorderedSets!==!1,x.unorderedObjects=M.unorderedObjects!==!1,x.replacer=M.replacer||void 0,x.excludeKeys=M.excludeKeys||void 0,_===void 0)throw new Error("Object argument required.");for(var E=0;E<I.length;++E)I[E].toLowerCase()===x.algorithm.toLowerCase()&&(x.algorithm=I[E]);if(I.indexOf(x.algorithm)===-1)throw new Error('Algorithm "'+x.algorithm+'" not supported. supported values: '+I.join(", "));if(W.indexOf(x.encoding)===-1&&x.algorithm!=="passthrough")throw new Error('Encoding "'+x.encoding+'" not supported. supported values: '+W.join(", "));return x}function P(_){if(typeof _=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(_))!=null}function F(_,M,x){x=x||[];function E(w){return M.update?M.update(w,"utf8"):M.write(w,"utf8")}return{dispatch:function(w){return this["_"+((w=_.replacer?_.replacer(w):w)===null?"null":typeof w)](w)},_object:function(w){var O,z=Object.prototype.toString.call(w),ee=/\[object (.*)\]/i.exec(z);if(ee=(ee=ee?ee[1]:"unknown:["+z+"]").toLowerCase(),0<=(z=x.indexOf(w)))return this.dispatch("[CIRCULAR:"+z+"]");if(x.push(w),p!==void 0&&p.isBuffer&&p.isBuffer(w))return E("buffer:"),E(w);if(ee==="object"||ee==="function"||ee==="asyncfunction")return z=Object.keys(w),_.unorderedObjects&&(z=z.sort()),_.respectType===!1||P(w)||z.splice(0,0,"prototype","__proto__","constructor"),_.excludeKeys&&(z=z.filter(function(Q){return!_.excludeKeys(Q)})),E("object:"+z.length+":"),O=this,z.forEach(function(Q){O.dispatch(Q),E(":"),_.excludeValues||O.dispatch(w[Q]),E(",")});if(!this["_"+ee]){if(_.ignoreUnknown)return E("["+ee+"]");throw new Error('Unknown object type "'+ee+'"')}this["_"+ee](w)},_array:function(w,Q){Q=Q!==void 0?Q:_.unorderedArrays!==!1;var z=this;if(E("array:"+w.length+":"),!Q||w.length<=1)return w.forEach(function(ne){return z.dispatch(ne)});var ee=[],Q=w.map(function(ne){var H=new X,oe=x.slice();return F(_,H,oe).dispatch(ne),ee=ee.concat(oe.slice(x.length)),H.read().toString()});return x=x.concat(ee),Q.sort(),this._array(Q,!1)},_date:function(w){return E("date:"+w.toJSON())},_symbol:function(w){return E("symbol:"+w.toString())},_error:function(w){return E("error:"+w.toString())},_boolean:function(w){return E("bool:"+w.toString())},_string:function(w){E("string:"+w.length+":"),E(w.toString())},_function:function(w){E("fn:"),P(w)?this.dispatch("[native]"):this.dispatch(w.toString()),_.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(w.name)),_.respectFunctionProperties&&this._object(w)},_number:function(w){return E("number:"+w.toString())},_xml:function(w){return E("xml:"+w.toString())},_null:function(){return E("Null")},_undefined:function(){return E("Undefined")},_regexp:function(w){return E("regex:"+w.toString())},_uint8array:function(w){return E("uint8array:"),this.dispatch(Array.prototype.slice.call(w))},_uint8clampedarray:function(w){return E("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(w))},_int8array:function(w){return E("int8array:"),this.dispatch(Array.prototype.slice.call(w))},_uint16array:function(w){return E("uint16array:"),this.dispatch(Array.prototype.slice.call(w))},_int16array:function(w){return E("int16array:"),this.dispatch(Array.prototype.slice.call(w))},_uint32array:function(w){return E("uint32array:"),this.dispatch(Array.prototype.slice.call(w))},_int32array:function(w){return E("int32array:"),this.dispatch(Array.prototype.slice.call(w))},_float32array:function(w){return E("float32array:"),this.dispatch(Array.prototype.slice.call(w))},_float64array:function(w){return E("float64array:"),this.dispatch(Array.prototype.slice.call(w))},_arraybuffer:function(w){return E("arraybuffer:"),this.dispatch(new Uint8Array(w))},_url:function(w){return E("url:"+w.toString())},_map:function(w){return E("map:"),w=Array.from(w),this._array(w,_.unorderedSets!==!1)},_set:function(w){return E("set:"),w=Array.from(w),this._array(w,_.unorderedSets!==!1)},_file:function(w){return E("file:"),this.dispatch([w.name,w.size,w.type,w.lastModfied])},_blob:function(){if(_.ignoreUnknown)return E("[blob]");throw Error(`Hashing Blob objects is currently not supported
2
- (see https://github.com/puleos/object-hash/issues/26)
3
- Use "options.replacer" or "options.ignoreUnknown"
4
- `)},_domwindow:function(){return E("domwindow")},_bigint:function(w){return E("bigint:"+w.toString())},_process:function(){return E("process")},_timer:function(){return E("timer")},_pipe:function(){return E("pipe")},_tcp:function(){return E("tcp")},_udp:function(){return E("udp")},_tty:function(){return E("tty")},_statwatcher:function(){return E("statwatcher")},_securecontext:function(){return E("securecontext")},_connection:function(){return E("connection")},_zlib:function(){return E("zlib")},_context:function(){return E("context")},_nodescript:function(){return E("nodescript")},_httpparser:function(){return E("httpparser")},_dataview:function(){return E("dataview")},_signal:function(){return E("signal")},_fsevent:function(){return E("fsevent")},_tlswrap:function(){return E("tlswrap")}}}function X(){return{buf:"",write:function(_){this.buf+=_},end:function(_){this.buf+=_},read:function(){return this.buf}}}i.writeToStream=function(_,M,x){return x===void 0&&(x=M,M={}),F(M=V(_,M),x).dispatch(_)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(t,r,i){(function(a,f,p,m,b,S,C,G,D){(function(A){var U=typeof Uint8Array<"u"?Uint8Array:Array,I=43,W=47,V=48,P=97,F=65,X=45,_=95;function M(x){return x=x.charCodeAt(0),x===I||x===X?62:x===W||x===_?63:x<V?-1:x<V+10?x-V+26+26:x<F+26?x-F:x<P+26?x-P+26:void 0}A.toByteArray=function(x){var E,w;if(0<x.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var O=x.length,O=x.charAt(O-2)==="="?2:x.charAt(O-1)==="="?1:0,z=new U(3*x.length/4-O),ee=0<O?x.length-4:x.length,Q=0;function ne(H){z[Q++]=H}for(E=0;E<ee;E+=4,0)ne((16711680&(w=M(x.charAt(E))<<18|M(x.charAt(E+1))<<12|M(x.charAt(E+2))<<6|M(x.charAt(E+3))))>>16),ne((65280&w)>>8),ne(255&w);return O==2?ne(255&(w=M(x.charAt(E))<<2|M(x.charAt(E+1))>>4)):O==1&&(ne((w=M(x.charAt(E))<<10|M(x.charAt(E+1))<<4|M(x.charAt(E+2))>>2)>>8&255),ne(255&w)),z},A.fromByteArray=function(x){var E,w,O,z,ee=x.length%3,Q="";function ne(H){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(H)}for(E=0,O=x.length-ee;E<O;E+=3)w=(x[E]<<16)+(x[E+1]<<8)+x[E+2],Q+=ne((z=w)>>18&63)+ne(z>>12&63)+ne(z>>6&63)+ne(63&z);switch(ee){case 1:Q=(Q+=ne((w=x[x.length-1])>>2))+ne(w<<4&63)+"==";break;case 2:Q=(Q=(Q+=ne((w=(x[x.length-2]<<8)+x[x.length-1])>>10))+ne(w>>4&63))+ne(w<<2&63)+"="}return Q}})(i===void 0?this.base64js={}:i)}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(t,r,i){(function(a,f,I,m,b,S,C,G,D){var A=t("base64-js"),U=t("ieee754");function I(l,y,k){if(!(this instanceof I))return new I(l,y,k);var B,T,K,te,ge=typeof l;if(y==="base64"&&ge=="string")for(l=(te=l).trim?te.trim():te.replace(/^\s+|\s+$/g,"");l.length%4!=0;)l+="=";if(ge=="number")B=se(l);else if(ge=="string")B=I.byteLength(l,y);else{if(ge!="object")throw new Error("First argument needs to be a number, array or string.");B=se(l.length)}if(I._useTypedArrays?T=I._augment(new Uint8Array(B)):((T=this).length=B,T._isBuffer=!0),I._useTypedArrays&&typeof l.byteLength=="number")T._set(l);else if(le(te=l)||I.isBuffer(te)||te&&typeof te=="object"&&typeof te.length=="number")for(K=0;K<B;K++)I.isBuffer(l)?T[K]=l.readUInt8(K):T[K]=l[K];else if(ge=="string")T.write(l,0,y);else if(ge=="number"&&!I._useTypedArrays&&!k)for(K=0;K<B;K++)T[K]=0;return T}function W(l,y,k,B){return I._charsWritten=At(function(T){for(var K=[],te=0;te<T.length;te++)K.push(255&T.charCodeAt(te));return K}(y),l,k,B)}function V(l,y,k,B){return I._charsWritten=At(function(T){for(var K,te,ge=[],ke=0;ke<T.length;ke++)te=T.charCodeAt(ke),K=te>>8,te=te%256,ge.push(te),ge.push(K);return ge}(y),l,k,B)}function P(l,y,k){var B="";k=Math.min(l.length,k);for(var T=y;T<k;T++)B+=String.fromCharCode(l[T]);return B}function F(l,y,k,K){K||(L(typeof k=="boolean","missing or invalid endian"),L(y!=null,"missing offset"),L(y+1<l.length,"Trying to read beyond buffer length"));var T,K=l.length;if(!(K<=y))return k?(T=l[y],y+1<K&&(T|=l[y+1]<<8)):(T=l[y]<<8,y+1<K&&(T|=l[y+1])),T}function X(l,y,k,K){K||(L(typeof k=="boolean","missing or invalid endian"),L(y!=null,"missing offset"),L(y+3<l.length,"Trying to read beyond buffer length"));var T,K=l.length;if(!(K<=y))return k?(y+2<K&&(T=l[y+2]<<16),y+1<K&&(T|=l[y+1]<<8),T|=l[y],y+3<K&&(T+=l[y+3]<<24>>>0)):(y+1<K&&(T=l[y+1]<<16),y+2<K&&(T|=l[y+2]<<8),y+3<K&&(T|=l[y+3]),T+=l[y]<<24>>>0),T}function _(l,y,k,B){if(B||(L(typeof k=="boolean","missing or invalid endian"),L(y!=null,"missing offset"),L(y+1<l.length,"Trying to read beyond buffer length")),!(l.length<=y))return B=F(l,y,k,!0),32768&B?-1*(65535-B+1):B}function M(l,y,k,B){if(B||(L(typeof k=="boolean","missing or invalid endian"),L(y!=null,"missing offset"),L(y+3<l.length,"Trying to read beyond buffer length")),!(l.length<=y))return B=X(l,y,k,!0),2147483648&B?-1*(4294967295-B+1):B}function x(l,y,k,B){return B||(L(typeof k=="boolean","missing or invalid endian"),L(y+3<l.length,"Trying to read beyond buffer length")),U.read(l,y,k,23,4)}function E(l,y,k,B){return B||(L(typeof k=="boolean","missing or invalid endian"),L(y+7<l.length,"Trying to read beyond buffer length")),U.read(l,y,k,52,8)}function w(l,y,k,B,T){if(T||(L(y!=null,"missing value"),L(typeof B=="boolean","missing or invalid endian"),L(k!=null,"missing offset"),L(k+1<l.length,"trying to write beyond buffer length"),Vt(y,65535)),T=l.length,!(T<=k))for(var K=0,te=Math.min(T-k,2);K<te;K++)l[k+K]=(y&255<<8*(B?K:1-K))>>>8*(B?K:1-K)}function O(l,y,k,B,T){if(T||(L(y!=null,"missing value"),L(typeof B=="boolean","missing or invalid endian"),L(k!=null,"missing offset"),L(k+3<l.length,"trying to write beyond buffer length"),Vt(y,4294967295)),T=l.length,!(T<=k))for(var K=0,te=Math.min(T-k,4);K<te;K++)l[k+K]=y>>>8*(B?K:3-K)&255}function z(l,y,k,B,T){T||(L(y!=null,"missing value"),L(typeof B=="boolean","missing or invalid endian"),L(k!=null,"missing offset"),L(k+1<l.length,"Trying to write beyond buffer length"),It(y,32767,-32768)),l.length<=k||w(l,0<=y?y:65535+y+1,k,B,T)}function ee(l,y,k,B,T){T||(L(y!=null,"missing value"),L(typeof B=="boolean","missing or invalid endian"),L(k!=null,"missing offset"),L(k+3<l.length,"Trying to write beyond buffer length"),It(y,2147483647,-2147483648)),l.length<=k||O(l,0<=y?y:4294967295+y+1,k,B,T)}function Q(l,y,k,B,T){T||(L(y!=null,"missing value"),L(typeof B=="boolean","missing or invalid endian"),L(k!=null,"missing offset"),L(k+3<l.length,"Trying to write beyond buffer length"),$t(y,34028234663852886e22,-34028234663852886e22)),l.length<=k||U.write(l,y,k,B,23,4)}function ne(l,y,k,B,T){T||(L(y!=null,"missing value"),L(typeof B=="boolean","missing or invalid endian"),L(k!=null,"missing offset"),L(k+7<l.length,"Trying to write beyond buffer length"),$t(y,17976931348623157e292,-17976931348623157e292)),l.length<=k||U.write(l,y,k,B,52,8)}i.Buffer=I,i.SlowBuffer=I,i.INSPECT_MAX_BYTES=50,I.poolSize=8192,I._useTypedArrays=function(){try{var l=new ArrayBuffer(0),y=new Uint8Array(l);return y.foo=function(){return 42},y.foo()===42&&typeof y.subarray=="function"}catch{return!1}}(),I.isEncoding=function(l){switch(String(l).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},I.isBuffer=function(l){return!(l==null||!l._isBuffer)},I.byteLength=function(l,y){var k;switch(l+="",y||"utf8"){case"hex":k=l.length/2;break;case"utf8":case"utf-8":k=qe(l).length;break;case"ascii":case"binary":case"raw":k=l.length;break;case"base64":k=hn(l).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":k=2*l.length;break;default:throw new Error("Unknown encoding")}return k},I.concat=function(l,y){if(L(le(l),`Usage: Buffer.concat(list, [totalLength])
5
- list should be an Array.`),l.length===0)return new I(0);if(l.length===1)return l[0];if(typeof y!="number")for(T=y=0;T<l.length;T++)y+=l[T].length;for(var k=new I(y),B=0,T=0;T<l.length;T++){var K=l[T];K.copy(k,B),B+=K.length}return k},I.prototype.write=function(l,y,k,B){isFinite(y)?isFinite(k)||(B=k,k=void 0):(ke=B,B=y,y=k,k=ke),y=Number(y)||0;var T,K,te,ge,ke=this.length-y;switch((!k||ke<(k=Number(k)))&&(k=ke),B=String(B||"utf8").toLowerCase()){case"hex":T=function(je,ze,me,Se){me=Number(me)||0;var we=je.length-me;(!Se||we<(Se=Number(Se)))&&(Se=we),L((we=ze.length)%2==0,"Invalid hex string"),we/2<Se&&(Se=we/2);for(var ut=0;ut<Se;ut++){var Gt=parseInt(ze.substr(2*ut,2),16);L(!isNaN(Gt),"Invalid hex string"),je[me+ut]=Gt}return I._charsWritten=2*ut,ut}(this,l,y,k);break;case"utf8":case"utf-8":K=this,te=y,ge=k,T=I._charsWritten=At(qe(l),K,te,ge);break;case"ascii":case"binary":T=W(this,l,y,k);break;case"base64":K=this,te=y,ge=k,T=I._charsWritten=At(hn(l),K,te,ge);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":T=V(this,l,y,k);break;default:throw new Error("Unknown encoding")}return T},I.prototype.toString=function(l,y,k){var B,T,K,te,ge=this;if(l=String(l||"utf8").toLowerCase(),y=Number(y)||0,(k=k!==void 0?Number(k):ge.length)===y)return"";switch(l){case"hex":B=function(ke,je,ze){var me=ke.length;(!je||je<0)&&(je=0),(!ze||ze<0||me<ze)&&(ze=me);for(var Se="",we=je;we<ze;we++)Se+=de(ke[we]);return Se}(ge,y,k);break;case"utf8":case"utf-8":B=function(ke,je,ze){var me="",Se="";ze=Math.min(ke.length,ze);for(var we=je;we<ze;we++)ke[we]<=127?(me+=Yt(Se)+String.fromCharCode(ke[we]),Se=""):Se+="%"+ke[we].toString(16);return me+Yt(Se)}(ge,y,k);break;case"ascii":case"binary":B=P(ge,y,k);break;case"base64":T=ge,te=k,B=(K=y)===0&&te===T.length?A.fromByteArray(T):A.fromByteArray(T.slice(K,te));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":B=function(ke,je,ze){for(var me=ke.slice(je,ze),Se="",we=0;we<me.length;we+=2)Se+=String.fromCharCode(me[we]+256*me[we+1]);return Se}(ge,y,k);break;default:throw new Error("Unknown encoding")}return B},I.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},I.prototype.copy=function(l,y,k,B){if(y=y||0,(B=B||B===0?B:this.length)!==(k=k||0)&&l.length!==0&&this.length!==0){L(k<=B,"sourceEnd < sourceStart"),L(0<=y&&y<l.length,"targetStart out of bounds"),L(0<=k&&k<this.length,"sourceStart out of bounds"),L(0<=B&&B<=this.length,"sourceEnd out of bounds"),B>this.length&&(B=this.length);var T=(B=l.length-y<B-k?l.length-y+k:B)-k;if(T<100||!I._useTypedArrays)for(var K=0;K<T;K++)l[K+y]=this[K+k];else l._set(this.subarray(k,k+T),y)}},I.prototype.slice=function(l,y){var k=this.length;if(l=oe(l,k,0),y=oe(y,k,k),I._useTypedArrays)return I._augment(this.subarray(l,y));for(var B=y-l,T=new I(B,void 0,!0),K=0;K<B;K++)T[K]=this[K+l];return T},I.prototype.get=function(l){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(l)},I.prototype.set=function(l,y){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(l,y)},I.prototype.readUInt8=function(l,y){if(y||(L(l!=null,"missing offset"),L(l<this.length,"Trying to read beyond buffer length")),!(l>=this.length))return this[l]},I.prototype.readUInt16LE=function(l,y){return F(this,l,!0,y)},I.prototype.readUInt16BE=function(l,y){return F(this,l,!1,y)},I.prototype.readUInt32LE=function(l,y){return X(this,l,!0,y)},I.prototype.readUInt32BE=function(l,y){return X(this,l,!1,y)},I.prototype.readInt8=function(l,y){if(y||(L(l!=null,"missing offset"),L(l<this.length,"Trying to read beyond buffer length")),!(l>=this.length))return 128&this[l]?-1*(255-this[l]+1):this[l]},I.prototype.readInt16LE=function(l,y){return _(this,l,!0,y)},I.prototype.readInt16BE=function(l,y){return _(this,l,!1,y)},I.prototype.readInt32LE=function(l,y){return M(this,l,!0,y)},I.prototype.readInt32BE=function(l,y){return M(this,l,!1,y)},I.prototype.readFloatLE=function(l,y){return x(this,l,!0,y)},I.prototype.readFloatBE=function(l,y){return x(this,l,!1,y)},I.prototype.readDoubleLE=function(l,y){return E(this,l,!0,y)},I.prototype.readDoubleBE=function(l,y){return E(this,l,!1,y)},I.prototype.writeUInt8=function(l,y,k){k||(L(l!=null,"missing value"),L(y!=null,"missing offset"),L(y<this.length,"trying to write beyond buffer length"),Vt(l,255)),y>=this.length||(this[y]=l)},I.prototype.writeUInt16LE=function(l,y,k){w(this,l,y,!0,k)},I.prototype.writeUInt16BE=function(l,y,k){w(this,l,y,!1,k)},I.prototype.writeUInt32LE=function(l,y,k){O(this,l,y,!0,k)},I.prototype.writeUInt32BE=function(l,y,k){O(this,l,y,!1,k)},I.prototype.writeInt8=function(l,y,k){k||(L(l!=null,"missing value"),L(y!=null,"missing offset"),L(y<this.length,"Trying to write beyond buffer length"),It(l,127,-128)),y>=this.length||(0<=l?this.writeUInt8(l,y,k):this.writeUInt8(255+l+1,y,k))},I.prototype.writeInt16LE=function(l,y,k){z(this,l,y,!0,k)},I.prototype.writeInt16BE=function(l,y,k){z(this,l,y,!1,k)},I.prototype.writeInt32LE=function(l,y,k){ee(this,l,y,!0,k)},I.prototype.writeInt32BE=function(l,y,k){ee(this,l,y,!1,k)},I.prototype.writeFloatLE=function(l,y,k){Q(this,l,y,!0,k)},I.prototype.writeFloatBE=function(l,y,k){Q(this,l,y,!1,k)},I.prototype.writeDoubleLE=function(l,y,k){ne(this,l,y,!0,k)},I.prototype.writeDoubleBE=function(l,y,k){ne(this,l,y,!1,k)},I.prototype.fill=function(l,y,k){if(y=y||0,k=k||this.length,L(typeof(l=typeof(l=l||0)=="string"?l.charCodeAt(0):l)=="number"&&!isNaN(l),"value is not a number"),L(y<=k,"end < start"),k!==y&&this.length!==0){L(0<=y&&y<this.length,"start out of bounds"),L(0<=k&&k<=this.length,"end out of bounds");for(var B=y;B<k;B++)this[B]=l}},I.prototype.inspect=function(){for(var l=[],y=this.length,k=0;k<y;k++)if(l[k]=de(this[k]),k===i.INSPECT_MAX_BYTES){l[k+1]="...";break}return"<Buffer "+l.join(" ")+">"},I.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(I._useTypedArrays)return new I(this).buffer;for(var l=new Uint8Array(this.length),y=0,k=l.length;y<k;y+=1)l[y]=this[y];return l.buffer};var H=I.prototype;function oe(l,y,k){return typeof l!="number"?k:y<=(l=~~l)?y:0<=l||0<=(l+=y)?l:0}function se(l){return(l=~~Math.ceil(+l))<0?0:l}function le(l){return(Array.isArray||function(y){return Object.prototype.toString.call(y)==="[object Array]"})(l)}function de(l){return l<16?"0"+l.toString(16):l.toString(16)}function qe(l){for(var y=[],k=0;k<l.length;k++){var B=l.charCodeAt(k);if(B<=127)y.push(l.charCodeAt(k));else for(var T=k,K=(55296<=B&&B<=57343&&k++,encodeURIComponent(l.slice(T,k+1)).substr(1).split("%")),te=0;te<K.length;te++)y.push(parseInt(K[te],16))}return y}function hn(l){return A.toByteArray(l)}function At(l,y,k,B){for(var T=0;T<B&&!(T+k>=y.length||T>=l.length);T++)y[T+k]=l[T];return T}function Yt(l){try{return decodeURIComponent(l)}catch{return"\uFFFD"}}function Vt(l,y){L(typeof l=="number","cannot write a non-number as a number"),L(0<=l,"specified a negative value for writing an unsigned value"),L(l<=y,"value is larger than maximum value for type"),L(Math.floor(l)===l,"value has a fractional component")}function It(l,y,k){L(typeof l=="number","cannot write a non-number as a number"),L(l<=y,"value larger than maximum allowed value"),L(k<=l,"value smaller than minimum allowed value"),L(Math.floor(l)===l,"value has a fractional component")}function $t(l,y,k){L(typeof l=="number","cannot write a non-number as a number"),L(l<=y,"value larger than maximum allowed value"),L(k<=l,"value smaller than minimum allowed value")}function L(l,y){if(!l)throw new Error(y||"Failed assertion")}I._augment=function(l){return l._isBuffer=!0,l._get=l.get,l._set=l.set,l.get=H.get,l.set=H.set,l.write=H.write,l.toString=H.toString,l.toLocaleString=H.toString,l.toJSON=H.toJSON,l.copy=H.copy,l.slice=H.slice,l.readUInt8=H.readUInt8,l.readUInt16LE=H.readUInt16LE,l.readUInt16BE=H.readUInt16BE,l.readUInt32LE=H.readUInt32LE,l.readUInt32BE=H.readUInt32BE,l.readInt8=H.readInt8,l.readInt16LE=H.readInt16LE,l.readInt16BE=H.readInt16BE,l.readInt32LE=H.readInt32LE,l.readInt32BE=H.readInt32BE,l.readFloatLE=H.readFloatLE,l.readFloatBE=H.readFloatBE,l.readDoubleLE=H.readDoubleLE,l.readDoubleBE=H.readDoubleBE,l.writeUInt8=H.writeUInt8,l.writeUInt16LE=H.writeUInt16LE,l.writeUInt16BE=H.writeUInt16BE,l.writeUInt32LE=H.writeUInt32LE,l.writeUInt32BE=H.writeUInt32BE,l.writeInt8=H.writeInt8,l.writeInt16LE=H.writeInt16LE,l.writeInt16BE=H.writeInt16BE,l.writeInt32LE=H.writeInt32LE,l.writeInt32BE=H.writeInt32BE,l.writeFloatLE=H.writeFloatLE,l.writeFloatBE=H.writeFloatBE,l.writeDoubleLE=H.writeDoubleLE,l.writeDoubleBE=H.writeDoubleBE,l.fill=H.fill,l.inspect=H.inspect,l.toArrayBuffer=H.toArrayBuffer,l}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(t,r,i){(function(a,f,A,m,b,S,C,G,D){var A=t("buffer").Buffer,U=4,I=new A(U);I.fill(0),r.exports={hash:function(W,V,P,F){for(var X=V(function(w,O){w.length%U!=0&&(z=w.length+(U-w.length%U),w=A.concat([w,I],z));for(var z,ee=[],Q=O?w.readInt32BE:w.readInt32LE,ne=0;ne<w.length;ne+=U)ee.push(Q.call(w,ne));return ee}(W=A.isBuffer(W)?W:new A(W),F),8*W.length),V=F,_=new A(P),M=V?_.writeInt32BE:_.writeInt32LE,x=0;x<X.length;x++)M.call(_,X[x],4*x,!0);return _}}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(t,r,i){(function(a,f,A,m,b,S,C,G,D){var A=t("buffer").Buffer,U=t("./sha"),I=t("./sha256"),W=t("./rng"),V={sha1:U,sha256:I,md5:t("./md5")},P=64,F=new A(P);function X(w,O){var z=V[w=w||"sha1"],ee=[];return z||_("algorithm:",w,"is not yet supported"),{update:function(Q){return A.isBuffer(Q)||(Q=new A(Q)),ee.push(Q),Q.length,this},digest:function(Q){var ne=A.concat(ee),ne=O?function(H,oe,se){A.isBuffer(oe)||(oe=new A(oe)),A.isBuffer(se)||(se=new A(se)),oe.length>P?oe=H(oe):oe.length<P&&(oe=A.concat([oe,F],P));for(var le=new A(P),de=new A(P),qe=0;qe<P;qe++)le[qe]=54^oe[qe],de[qe]=92^oe[qe];return se=H(A.concat([le,se])),H(A.concat([de,se]))}(z,O,ne):z(ne);return ee=null,Q?ne.toString(Q):ne}}}function _(){var w=[].slice.call(arguments).join(" ");throw new Error([w,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
6
- `))}F.fill(0),i.createHash=function(w){return X(w)},i.createHmac=X,i.randomBytes=function(w,O){if(!O||!O.call)return new A(W(w));try{O.call(this,void 0,new A(W(w)))}catch(z){O(z)}};var M,x=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],E=function(w){i[w]=function(){_("sorry,",w,"is not implemented yet")}};for(M in x)E(x[M])}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(t,r,i){(function(a,f,p,m,b,S,C,G,D){var A=t("./helpers");function U(_,M){_[M>>5]|=128<<M%32,_[14+(M+64>>>9<<4)]=M;for(var x=1732584193,E=-271733879,w=-1732584194,O=271733878,z=0;z<_.length;z+=16){var ee=x,Q=E,ne=w,H=O,x=W(x,E,w,O,_[z+0],7,-680876936),O=W(O,x,E,w,_[z+1],12,-389564586),w=W(w,O,x,E,_[z+2],17,606105819),E=W(E,w,O,x,_[z+3],22,-1044525330);x=W(x,E,w,O,_[z+4],7,-176418897),O=W(O,x,E,w,_[z+5],12,1200080426),w=W(w,O,x,E,_[z+6],17,-1473231341),E=W(E,w,O,x,_[z+7],22,-45705983),x=W(x,E,w,O,_[z+8],7,1770035416),O=W(O,x,E,w,_[z+9],12,-1958414417),w=W(w,O,x,E,_[z+10],17,-42063),E=W(E,w,O,x,_[z+11],22,-1990404162),x=W(x,E,w,O,_[z+12],7,1804603682),O=W(O,x,E,w,_[z+13],12,-40341101),w=W(w,O,x,E,_[z+14],17,-1502002290),x=V(x,E=W(E,w,O,x,_[z+15],22,1236535329),w,O,_[z+1],5,-165796510),O=V(O,x,E,w,_[z+6],9,-1069501632),w=V(w,O,x,E,_[z+11],14,643717713),E=V(E,w,O,x,_[z+0],20,-373897302),x=V(x,E,w,O,_[z+5],5,-701558691),O=V(O,x,E,w,_[z+10],9,38016083),w=V(w,O,x,E,_[z+15],14,-660478335),E=V(E,w,O,x,_[z+4],20,-405537848),x=V(x,E,w,O,_[z+9],5,568446438),O=V(O,x,E,w,_[z+14],9,-1019803690),w=V(w,O,x,E,_[z+3],14,-187363961),E=V(E,w,O,x,_[z+8],20,1163531501),x=V(x,E,w,O,_[z+13],5,-1444681467),O=V(O,x,E,w,_[z+2],9,-51403784),w=V(w,O,x,E,_[z+7],14,1735328473),x=P(x,E=V(E,w,O,x,_[z+12],20,-1926607734),w,O,_[z+5],4,-378558),O=P(O,x,E,w,_[z+8],11,-2022574463),w=P(w,O,x,E,_[z+11],16,1839030562),E=P(E,w,O,x,_[z+14],23,-35309556),x=P(x,E,w,O,_[z+1],4,-1530992060),O=P(O,x,E,w,_[z+4],11,1272893353),w=P(w,O,x,E,_[z+7],16,-155497632),E=P(E,w,O,x,_[z+10],23,-1094730640),x=P(x,E,w,O,_[z+13],4,681279174),O=P(O,x,E,w,_[z+0],11,-358537222),w=P(w,O,x,E,_[z+3],16,-722521979),E=P(E,w,O,x,_[z+6],23,76029189),x=P(x,E,w,O,_[z+9],4,-640364487),O=P(O,x,E,w,_[z+12],11,-421815835),w=P(w,O,x,E,_[z+15],16,530742520),x=F(x,E=P(E,w,O,x,_[z+2],23,-995338651),w,O,_[z+0],6,-198630844),O=F(O,x,E,w,_[z+7],10,1126891415),w=F(w,O,x,E,_[z+14],15,-1416354905),E=F(E,w,O,x,_[z+5],21,-57434055),x=F(x,E,w,O,_[z+12],6,1700485571),O=F(O,x,E,w,_[z+3],10,-1894986606),w=F(w,O,x,E,_[z+10],15,-1051523),E=F(E,w,O,x,_[z+1],21,-2054922799),x=F(x,E,w,O,_[z+8],6,1873313359),O=F(O,x,E,w,_[z+15],10,-30611744),w=F(w,O,x,E,_[z+6],15,-1560198380),E=F(E,w,O,x,_[z+13],21,1309151649),x=F(x,E,w,O,_[z+4],6,-145523070),O=F(O,x,E,w,_[z+11],10,-1120210379),w=F(w,O,x,E,_[z+2],15,718787259),E=F(E,w,O,x,_[z+9],21,-343485551),x=X(x,ee),E=X(E,Q),w=X(w,ne),O=X(O,H)}return Array(x,E,w,O)}function I(_,M,x,E,w,O){return X((M=X(X(M,_),X(E,O)))<<w|M>>>32-w,x)}function W(_,M,x,E,w,O,z){return I(M&x|~M&E,_,M,w,O,z)}function V(_,M,x,E,w,O,z){return I(M&E|x&~E,_,M,w,O,z)}function P(_,M,x,E,w,O,z){return I(M^x^E,_,M,w,O,z)}function F(_,M,x,E,w,O,z){return I(x^(M|~E),_,M,w,O,z)}function X(_,M){var x=(65535&_)+(65535&M);return(_>>16)+(M>>16)+(x>>16)<<16|65535&x}r.exports=function(_){return A.hash(_,U,16)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(t,r,i){(function(a,f,p,m,b,S,C,G,D){r.exports=function(A){for(var U,I=new Array(A),W=0;W<A;W++)!(3&W)&&(U=4294967296*Math.random()),I[W]=U>>>((3&W)<<3)&255;return I}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(t,r,i){(function(a,f,p,m,b,S,C,G,D){var A=t("./helpers");function U(V,P){V[P>>5]|=128<<24-P%32,V[15+(P+64>>9<<4)]=P;for(var F,X,_,M=Array(80),x=1732584193,E=-271733879,w=-1732584194,O=271733878,z=-1009589776,ee=0;ee<V.length;ee+=16){for(var Q=x,ne=E,H=w,oe=O,se=z,le=0;le<80;le++){M[le]=le<16?V[ee+le]:W(M[le-3]^M[le-8]^M[le-14]^M[le-16],1);var de=I(I(W(x,5),(de=E,X=w,_=O,(F=le)<20?de&X|~de&_:!(F<40)&&F<60?de&X|de&_|X&_:de^X^_)),I(I(z,M[le]),(F=le)<20?1518500249:F<40?1859775393:F<60?-1894007588:-899497514)),z=O,O=w,w=W(E,30),E=x,x=de}x=I(x,Q),E=I(E,ne),w=I(w,H),O=I(O,oe),z=I(z,se)}return Array(x,E,w,O,z)}function I(V,P){var F=(65535&V)+(65535&P);return(V>>16)+(P>>16)+(F>>16)<<16|65535&F}function W(V,P){return V<<P|V>>>32-P}r.exports=function(V){return A.hash(V,U,20,!0)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(t,r,i){(function(a,f,p,m,b,S,C,G,D){function A(P,F){var X=(65535&P)+(65535&F);return(P>>16)+(F>>16)+(X>>16)<<16|65535&X}function U(P,F){var X,_=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),M=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),x=new Array(64);P[F>>5]|=128<<24-F%32,P[15+(F+64>>9<<4)]=F;for(var E,w,O=0;O<P.length;O+=16){for(var z=M[0],ee=M[1],Q=M[2],ne=M[3],H=M[4],oe=M[5],se=M[6],le=M[7],de=0;de<64;de++)x[de]=de<16?P[de+O]:A(A(A((w=x[de-2],W(w,17)^W(w,19)^V(w,10)),x[de-7]),(w=x[de-15],W(w,7)^W(w,18)^V(w,3))),x[de-16]),X=A(A(A(A(le,W(w=H,6)^W(w,11)^W(w,25)),H&oe^~H&se),_[de]),x[de]),E=A(W(E=z,2)^W(E,13)^W(E,22),z&ee^z&Q^ee&Q),le=se,se=oe,oe=H,H=A(ne,X),ne=Q,Q=ee,ee=z,z=A(X,E);M[0]=A(z,M[0]),M[1]=A(ee,M[1]),M[2]=A(Q,M[2]),M[3]=A(ne,M[3]),M[4]=A(H,M[4]),M[5]=A(oe,M[5]),M[6]=A(se,M[6]),M[7]=A(le,M[7])}return M}var I=t("./helpers"),W=function(P,F){return P>>>F|P<<32-F},V=function(P,F){return P>>>F};r.exports=function(P){return I.hash(P,U,32,!0)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(t,r,i){(function(a,f,p,m,b,S,C,G,D){i.read=function(A,U,I,W,O){var P,F,X=8*O-W-1,_=(1<<X)-1,M=_>>1,x=-7,E=I?O-1:0,w=I?-1:1,O=A[U+E];for(E+=w,P=O&(1<<-x)-1,O>>=-x,x+=X;0<x;P=256*P+A[U+E],E+=w,x-=8);for(F=P&(1<<-x)-1,P>>=-x,x+=W;0<x;F=256*F+A[U+E],E+=w,x-=8);if(P===0)P=1-M;else{if(P===_)return F?NaN:1/0*(O?-1:1);F+=Math.pow(2,W),P-=M}return(O?-1:1)*F*Math.pow(2,P-W)},i.write=function(A,U,I,W,V,z){var F,X,_=8*z-V-1,M=(1<<_)-1,x=M>>1,E=V===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=W?0:z-1,O=W?1:-1,z=U<0||U===0&&1/U<0?1:0;for(U=Math.abs(U),isNaN(U)||U===1/0?(X=isNaN(U)?1:0,F=M):(F=Math.floor(Math.log(U)/Math.LN2),U*(W=Math.pow(2,-F))<1&&(F--,W*=2),2<=(U+=1<=F+x?E/W:E*Math.pow(2,1-x))*W&&(F++,W/=2),M<=F+x?(X=0,F=M):1<=F+x?(X=(U*W-1)*Math.pow(2,V),F+=x):(X=U*Math.pow(2,x-1)*Math.pow(2,V),F=0));8<=V;A[I+w]=255&X,w+=O,X/=256,V-=8);for(F=F<<V|X,_+=V;0<_;A[I+w]=255&F,w+=O,F/=256,_-=8);A[I+w-O]|=128*z}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(t,r,i){(function(a,f,p,m,b,S,C,G,D){var A,U,I;function W(){}(a=r.exports={}).nextTick=(U=typeof window<"u"&&window.setImmediate,I=typeof window<"u"&&window.postMessage&&window.addEventListener,U?function(V){return window.setImmediate(V)}:I?(A=[],window.addEventListener("message",function(V){var P=V.source;P!==window&&P!==null||V.data!=="process-tick"||(V.stopPropagation(),0<A.length&&A.shift()())},!0),function(V){A.push(V),window.postMessage("process-tick","*")}):function(V){setTimeout(V,0)}),a.title="browser",a.browser=!0,a.env={},a.argv=[],a.on=W,a.addListener=W,a.once=W,a.off=W,a.removeListener=W,a.removeAllListeners=W,a.emit=W,a.binding=function(V){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(V){throw new Error("process.chdir is not supported")}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})}(mi)),mi.exports}var Ss=ks();const As=wt(Ss);function nr(n){return e=>!n(e)}function tt(n){return n==null}function Is(n){return Array.isArray(n)}function $s(...n){return ue(Gs,n)}var Gs=(n,e)=>e.every(t=>t(n));function He(...n){return ue(Os,n)}var Os=(n,e)=>e.some(t=>t(n)),_n;(n=>{n.isDeploymentNode=e=>"kind"in e&&!("element"in e),n.isInstance=e=>"element"in e&&!("kind"in e)})(_n||(_n={}));function Cs(n,e){return e?e+"."+n:n}var zt;(n=>{n.Group="@group"})(zt||(zt={}));const Zt="primary",kn="rectangle";function Ye(n){return"element"in n}function ft(n){return"expanded"in n}function Sn(n){return"custom"in n&&(rr(n.custom.expr)||An(n.custom.expr))}function Le(n){return"wildcard"in n}function Mt(n){return"elementKind"in n&&"isEqual"in n}function Rt(n){return"elementTag"in n&&"isEqual"in n}function rr(n){return Ye(n)||Le(n)||Mt(n)||Rt(n)||ft(n)}function An(n){return"where"in n&&rr(n.where.expr)}function Ls(n){return rr(n)||An(n)||Sn(n)}function ir(n){return"source"in n&&"target"in n}function or(n){return"inout"in n}function sr(n){return"incoming"in n}function ar(n){return"outgoing"in n}function wi(n){return ir(n)||or(n)||sr(n)||ar(n)}function ur(n){return"where"in n&&wi(n.where.expr)}function cr(n){return"customRelation"in n}function vi(n){return wi(n)||ur(n)||cr(n)}var en;(n=>{n.isInsideInstanceRef=e=>"deployment"in e&&"element"in e,n.isDeploymentElementRef=e=>"deployment"in e&&!("element"in e),n.isDeploymentRef=e=>!(0,n.isModelRef)(e),n.isModelRef=e=>"model"in e,n.toDeploymentRef=e=>(re((0,n.isDeploymentRef)(e),"Expected DeploymentRef"),(0,n.isInsideInstanceRef)(e)?{id:e.deployment,element:e.element}:{id:e.deployment})})(en||(en={}));var ie;(n=>{n.isWildcard=e=>"wildcard"in e&&e.wildcard===!0,n.isModelRef=e=>"ref"in e&&en.isModelRef(e.ref),n.isDeploymentRef=e=>"ref"in e&&en.isDeploymentRef(e.ref)})(ie||(ie={}));var nt;(n=>{n.isDirect=e=>"source"in e&&"target"in e,n.isIncoming=e=>"incoming"in e,n.isOutgoing=e=>"outgoing"in e,n.isInOut=e=>"inout"in e})(nt||(nt={}));var bi;(n=>{n.isFqnExpr=e=>ie.isWildcard(e)||ie.isModelRef(e)||ie.isDeploymentRef(e),n.isRelation=e=>nt.isDirect(e)||nt.isIncoming(e)||nt.isOutgoing(e)||nt.isInOut(e)})(bi||(bi={}));const Ds=n=>"tag"in n,zs=n=>"kind"in n,Ms=n=>"not"in n,xi=n=>"and"in n,Ei=n=>"or"in n;function bt(n){switch(!0){case Ds(n):{if("eq"in n.tag){const t=n.tag.eq;return r=>Array.isArray(r.tags)&&r.tags.includes(t)}const e=n.tag.neq;return t=>!Array.isArray(t.tags)||!t.tags.includes(e)}case zs(n):{if("eq"in n.kind){const t=n.kind.eq;return r=>r.kind===t}const e=n.kind.neq;return t=>tt(t.kind)||t.kind!==e}case Ms(n):{const e=bt(n.not);return nr(e)}case xi(n):{const e=n.and.map(bt);return $s(e)}case Ei(n):{const e=n.or.map(bt);return He(e)}default:Be(n)}}const _i="dashed",dr="normal",ki="gray";function In(n){return"include"in n&&Array.isArray(n.include)||"exclude"in n&&Array.isArray(n.exclude)}function Si(n){return"predicateId"in n}function Ai(n){return"style"in n&&"targets"in n&&Array.isArray(n.targets)}function Ii(n){return"styleId"in n}function Rs(n){return n==="TB"||n==="BT"||n==="LR"||n==="RL"}function lr(n){return"direction"in n}function $i(n){return"title"in n&&"groupRules"in n&&Array.isArray(n.groupRules)}function Us(n){return"__parallel"in n&&Is(n.__parallel)}function Gi(n){return n.__==="deployment"}function Oi(n){return n.__==="dynamic"}function tn(n){return tt(n.__)||n.__==="element"}function js(n){return tn(n)&&"extends"in n}function Ci(n){return tn(n)&&"viewOf"in n}function Li(n,e){const t=`step-${String(n).padStart(2,"0")}`;return e?`${t}.${e}`:t}function Di(n){return n.startsWith("step-")}function zi(n){if(!Di(n))throw new Error(`Invalid step edge id: ${n}`);return parseFloat(n.slice(5))}var rt;(n=>{function e(i){return i.modelRef===1?i.id:i.modelRef??null}n.modelRef=e;function t(i){return i.deploymentRef===1?i.id:i.deploymentRef??null}n.deploymentRef=t;function r(i){return i.kind===zt.Group}n.isNodesGroup=r})(rt||(rt={}));var hr;(n=>{function e(i){return i.__==="deployment"}n.isDeployment=e;function t(i){return i.__==="dynamic"}n.isDynamic=t;function r(i){return tt(i.__)||i.__==="element"}n.isElement=r})(hr||(hr={}));var fr;(n=>{function e(i){return i.modelRef===1?i.id:i.modelRef??null}n.modelRef=e;function t(i){return i.deploymentRef===1?i.id:i.deploymentRef??null}n.deploymentRef=t;function r(i){return i.kind===zt.Group}n.isNodesGroup=r})(fr||(fr={}));function xt(...n){return ue(Object.values,n)}function $n(...n){return n.length===2?(e,...t)=>Mi(e,...n,...t):Mi(...n)}var Mi=(n,e,t,...r)=>e(n,...r)?typeof t=="function"?t(n,...r):t.onTrue(n,...r):typeof t=="function"?n:t.onFalse(n,...r);function Ns(n,e){let t=e.length-n.length;if(t===1){let[r,...i]=e;return J(r,{lazy:n,lazyArgs:i})}if(t===0){let r={lazy:n,lazyArgs:e};return Object.assign(i=>J(i,r),r)}throw new Error("Wrong number of arguments")}function pt(...n){return Ns(Ts,n)}function Ts(){let n=new Set;return e=>n.has(e)?Bn:(n.add(e),{done:!1,hasNext:!0,next:e})}function Ri(...n){return ue(Bs,n,Ws)}var Bs=(n,e)=>e<0?[]:n.slice(0,e);function Ws(n){if(n<=0)return is;let e=n;return t=>(e-=1,{done:e<=0,hasNext:!0,next:t})}var Ui={asc:(n,e)=>n>e,desc:(n,e)=>n<e};function Fs(n,e){let[t,...r]=e;if(!Ps(t)){let a=pr(...r);return n(t,a)}let i=pr(t,...r);return a=>n(a,i)}function pr(n,e,...t){let r=typeof n=="function"?n:n[0],i=typeof n=="function"?"asc":n[1],{[i]:a}=Ui,f=e===void 0?void 0:pr(e,...t);return(p,m)=>{let b=r(p),S=r(m);return a(b,S)?1:a(S,b)?-1:f?.(p,m)??0}}function Ps(n){if(ji(n))return!0;if(typeof n!="object"||!Array.isArray(n))return!1;let[e,t,...r]=n;return ji(e)&&typeof t=="string"&&t in Ui&&r.length===0}var ji=n=>typeof n=="function"&&n.length===1;function gr(...n){return ue(qs,n)}function qs(n,e){let t=[...n];return t.sort(e),t}function Ks(...n){return Fs(Ys,n)}var Ys=(n,e)=>[...n].sort(e);function nn(...n){return ue(Vs,n)}var Vs=(n,e,t)=>n.reduce(e,t);function Ni(...n){return ue(Xs,n)}function Xs(n){return[...n].reverse()}function mr(...n){return ue(Hs,n)}function Hs(n,e){let t={};for(let r of e)r in n&&(t[r]=n[r]);return t}function Ti(...n){return ue(Js,n)}function Js(n,e){let t={};for(let[r,i]of Object.entries(n))e(i,r,n)&&(t[r]=i);return t}function rn(...n){return e=>J(e,...n)}function Je(...n){return ue(Qs,n)}var Qs=(n,e)=>n[e];function Bi(...n){return ue(Zs,n)}function Zs(n,e){let t={...n};for(let[r,i]of Object.entries(t))e(i,r,n)&&delete t[r];return t}function Ee(...n){return ue(ea,n)}var ea=n=>n.length===1?n[0]:void 0;function Gn(...n){return ue(ta,n)}var ta=(n,e)=>{let t=[[],[]];for(let[r,i]of n.entries())e(i,r,n)?t[0].push(i):t[1].push(i);return t};function na(...n){return ue(ra,n)}var ra=n=>n.at(-1);function Wi(...n){return ue(ia,n)}function ia(n,e){let t={};for(let[r,i]of n.entries()){let[a,f]=e(i,r,n);t[a]=f}return t}function On(...n){return ue(oa,n)}function oa(n,e){let t={};for(let[r,i]of Object.entries(n)){let a=e(i,r,n);t[r]=a}return t}function _e(n){return!!n}function sa(n){return typeof n=="number"&&!Number.isNaN(n)}function aa(n){return typeof n=="boolean"}function gt(n){return n===void 0?!0:typeof n=="string"||Array.isArray(n)?n.length===0:Object.keys(n).length===0}function ua(...n){return ue(on,n)}function on(n,e){if(n===e||Object.is(n,e))return!0;if(typeof n!="object"||typeof e!="object"||n===null||e===null||Object.getPrototypeOf(n)!==Object.getPrototypeOf(e))return!1;if(Array.isArray(n))return ca(n,e);if(n instanceof Map)return da(n,e);if(n instanceof Set)return la(n,e);if(n instanceof Date)return n.getTime()===e.getTime();if(n instanceof RegExp)return n.toString()===e.toString();if(Object.keys(n).length!==Object.keys(e).length)return!1;for(let[t,r]of Object.entries(n))if(!(t in e)||!on(r,e[t]))return!1;return!0}function ca(n,e){if(n.length!==e.length)return!1;for(let[t,r]of n.entries())if(!on(r,e[t]))return!1;return!0}function da(n,e){if(n.size!==e.size)return!1;for(let[t,r]of n.entries())if(!e.has(t)||!on(r,e.get(t)))return!1;return!0}function la(n,e){if(n.size!==e.size)return!1;let t=[...e];for(let r of n){let i=!1;for(let[a,f]of t.entries())if(on(r,f)){i=!0,t.splice(a,1);break}if(!i)return!1}return!0}function Qe(...n){return ue(ha,n,fa)}var ha=(n,e)=>n.flatMap(e),fa=n=>(e,t,r)=>{let i=n(e,t,r);return Array.isArray(i)?{done:!1,hasNext:!0,hasMany:!0,next:i}:{done:!1,hasNext:!0,next:i}};function We(...n){return ue(pa,n,ga)}function pa(n,e){return n.forEach(e),n}var ga=n=>(e,t,r)=>(n(e,t,r),{done:!1,hasNext:!0,next:e});function Cn(...n){return ue(ma,n)}var ma=(n,e)=>{let t={};for(let[r,i]of n.entries()){let a=e(i,r,n);if(a!==void 0){let{[a]:f}=t;f===void 0&&(f=[],t[a]=f),f.push(i)}}return t};function Ue(...n){return ue(ya,n,wa)}var ya=(n,e)=>n.filter(e),wa=n=>(e,t,r)=>n(e,t,r)?{done:!1,hasNext:!0,next:e}:Bn;function yr(...n){return ue(va,n)}var va=(n,e)=>{for(let t=n.length-1;t>=0;t--){let r=n[t];if(e(r,t,n))return r}};function wr(...n){return ue(ba,n)}function ba(n,e){for(let[t,r]of n.entries())if(!e(r,t,n))return n.slice(t);return[]}function vr(...n){return ue(Object.entries,n)}function Fi(...n){return ue(xa,n)}var xa=(n,e)=>[...n,...e];function Ln(n){return()=>n}class br{constructor(e,t){this.$model=e,this.$element=t,this.id=this.$element.id,this.hierarchyLevel=Dt(this.id)}id;hierarchyLevel;get parent(){return this.$model.parent(this)}get kind(){return this.$element.kind}get shape(){return this.$element.shape??kn}get color(){return this.$element.color??Zt}get tags(){return this.$element.tags??[]}get title(){return this.$element.title}get description(){return this.$element.description}get technology(){return this.$element.technology}get links(){return this.$element.links??[]}get defaultView(){return this.scopedViews().next().value??null}isAncestorOf(e){return ye(this,e)}isDescendantOf(e){return ye(e,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){const t=lt(this.id,e.id);return t?this.$model.element(t):null}children(){return this.$model.children(this)}descendants(e){return e?xn([...this.$model.descendants(this)],e)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(const e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(const e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e="all"){return this.$model.incoming(this,e)}*incomers(e="all"){const t=new Set;for(const r of this.incoming(e))t.has(r.source.id)||(t.add(r.source.id),yield r.source)}outgoing(e="all"){return this.$model.outgoing(this,e)}*outgoers(e="all"){const t=new Set;for(const r of this.outgoing(e))t.has(r.target.id)||(t.add(r.target.id),yield r.target)}cachedOutgoing=null;cachedIncoming=null;get allOutgoing(){return this.cachedOutgoing??=new Set(this.outgoing()),this.cachedOutgoing}get allIncoming(){return this.cachedIncoming??=new Set(this.incoming()),this.cachedIncoming}*views(){for(const e of this.$model.views())e.includesElement(this.id)&&(yield e)}*scopedViews(){for(const e of this.$model.views())e.isElementView()&&e.$view.viewOf===this.id&&(yield e)}isDeployed(){return _e(this.deployments().next().value)}deployments(){return this.$model.deployment.instancesOf(this)}}function xr(n){return J(n,Cn(Je("notation")),On(rn(Cn(Je("shape")),On(rn(Cn(Je("color")),On(rn(be(Je("kind")),pt())),vr(),be(([e,t])=>({kinds:t,color:e})))),vr(),Qe(([e,t])=>t.map(({color:r,kinds:i})=>({shape:e,color:r,kinds:i}))))),vr(),Qe(([e,t])=>t.map(({shape:r,color:i,kinds:a})=>({title:e,shape:r,color:i,kinds:a}))),Ks(Je("shape"),Je("title"),[e=>e.kinds.length,"desc"]))}function Er(n,e){const t=[];let r=n.parent;for(;r;){const i=ve(e.get(r),`Parent node ${r} not found`);t.push(i),r=i.parent}return t}function Pi(n,e){for(const t of e){const r=n.get(t.source),i=n.get(t.target);re(r,`Source node ${t.source} not found`),re(i,`Target node ${t.target} not found`),r.outEdges.push(t.id),i.inEdges.push(t.id);const a=Er(r,n),f=Er(i,n),p=a.length>0&&f.length>0?na(ps(Ni(a),Ni(f))):null;t.parent=p?p.id:null;for(const m of a){if(m===p)break;m.outEdges.push(t.id)}for(const m of f){if(m===p)break;m.inEdges.push(t.id)}}}var _r={exports:{}},Ea=_r.exports,qi;function _a(){return qi||(qi=1,function(n,e){(function(t,r){n.exports=r()})(Ea,function(){function t(u){return t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},t(u)}function r(u,h){u.prototype=Object.create(h.prototype),u.prototype.constructor=u,a(u,h)}function i(u){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},i(u)}function a(u,h){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,o){return c.__proto__=o,c},a(u,h)}function f(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function p(u,h,c){return p=f()?Reflect.construct.bind():function(o,s,d){var g=[null];g.push.apply(g,s);var v=new(Function.bind.apply(o,g));return d&&a(v,d.prototype),v},p.apply(null,arguments)}function m(u){var h=typeof Map=="function"?new Map:void 0;return m=function(c){if(c===null||(o=c,Function.toString.call(o).indexOf("[native code]")===-1))return c;var o;if(typeof c!="function")throw new TypeError("Super expression must either be null or a function");if(h!==void 0){if(h.has(c))return h.get(c);h.set(c,s)}function s(){return p(c,arguments,i(this).constructor)}return s.prototype=Object.create(c.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),a(s,c)},m(u)}function b(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}var S=function(){for(var u=arguments[0],h=1,c=arguments.length;h<c;h++)if(arguments[h])for(var o in arguments[h])u[o]=arguments[h][o];return u};function C(u,h,c,o){var s=u._nodes.get(h),d=null;return s?d=o==="mixed"?s.out&&s.out[c]||s.undirected&&s.undirected[c]:o==="directed"?s.out&&s.out[c]:s.undirected&&s.undirected[c]:d}function G(u){return t(u)==="object"&&u!==null}function D(u){var h;for(h in u)return!1;return!0}function A(u,h,c){Object.defineProperty(u,h,{enumerable:!1,configurable:!1,writable:!0,value:c})}function U(u,h,c){var o={enumerable:!0,configurable:!0};typeof c=="function"?o.get=c:(o.value=c,o.writable=!1),Object.defineProperty(u,h,o)}function I(u){return!!G(u)&&!(u.attributes&&!Array.isArray(u.attributes))}typeof Object.assign=="function"&&(S=Object.assign);var W,V={exports:{}},P=typeof Reflect=="object"?Reflect:null,F=P&&typeof P.apply=="function"?P.apply:function(u,h,c){return Function.prototype.apply.call(u,h,c)};W=P&&typeof P.ownKeys=="function"?P.ownKeys:Object.getOwnPropertySymbols?function(u){return Object.getOwnPropertyNames(u).concat(Object.getOwnPropertySymbols(u))}:function(u){return Object.getOwnPropertyNames(u)};var X=Number.isNaN||function(u){return u!=u};function _(){_.init.call(this)}V.exports=_,V.exports.once=function(u,h){return new Promise(function(c,o){function s(g){u.removeListener(h,d),o(g)}function d(){typeof u.removeListener=="function"&&u.removeListener("error",s),c([].slice.call(arguments))}H(u,h,d,{once:!0}),h!=="error"&&function(g,v,$){typeof g.on=="function"&&H(g,"error",v,$)}(u,s,{once:!0})})},_.EventEmitter=_,_.prototype._events=void 0,_.prototype._eventsCount=0,_.prototype._maxListeners=void 0;var M=10;function x(u){if(typeof u!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof u)}function E(u){return u._maxListeners===void 0?_.defaultMaxListeners:u._maxListeners}function w(u,h,c,o){var s,d,g,v;if(x(c),(d=u._events)===void 0?(d=u._events=Object.create(null),u._eventsCount=0):(d.newListener!==void 0&&(u.emit("newListener",h,c.listener?c.listener:c),d=u._events),g=d[h]),g===void 0)g=d[h]=c,++u._eventsCount;else if(typeof g=="function"?g=d[h]=o?[c,g]:[g,c]:o?g.unshift(c):g.push(c),(s=E(u))>0&&g.length>s&&!g.warned){g.warned=!0;var $=new Error("Possible EventEmitter memory leak detected. "+g.length+" "+String(h)+" listeners added. Use emitter.setMaxListeners() to increase limit");$.name="MaxListenersExceededWarning",$.emitter=u,$.type=h,$.count=g.length,v=$,console&&console.warn&&console.warn(v)}return u}function O(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function z(u,h,c){var o={fired:!1,wrapFn:void 0,target:u,type:h,listener:c},s=O.bind(o);return s.listener=c,o.wrapFn=s,s}function ee(u,h,c){var o=u._events;if(o===void 0)return[];var s=o[h];return s===void 0?[]:typeof s=="function"?c?[s.listener||s]:[s]:c?function(d){for(var g=new Array(d.length),v=0;v<g.length;++v)g[v]=d[v].listener||d[v];return g}(s):ne(s,s.length)}function Q(u){var h=this._events;if(h!==void 0){var c=h[u];if(typeof c=="function")return 1;if(c!==void 0)return c.length}return 0}function ne(u,h){for(var c=new Array(h),o=0;o<h;++o)c[o]=u[o];return c}function H(u,h,c,o){if(typeof u.on=="function")o.once?u.once(h,c):u.on(h,c);else{if(typeof u.addEventListener!="function")throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof u);u.addEventListener(h,function s(d){o.once&&u.removeEventListener(h,s),c(d)})}}function oe(u){if(typeof u!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=u}Object.defineProperty(_,"defaultMaxListeners",{enumerable:!0,get:function(){return M},set:function(u){if(typeof u!="number"||u<0||X(u))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+u+".");M=u}}),_.init=function(){this._events!==void 0&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(u){if(typeof u!="number"||u<0||X(u))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+u+".");return this._maxListeners=u,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(u){for(var h=[],c=1;c<arguments.length;c++)h.push(arguments[c]);var o=u==="error",s=this._events;if(s!==void 0)o=o&&s.error===void 0;else if(!o)return!1;if(o){var d;if(h.length>0&&(d=h[0]),d instanceof Error)throw d;var g=new Error("Unhandled error."+(d?" ("+d.message+")":""));throw g.context=d,g}var v=s[u];if(v===void 0)return!1;if(typeof v=="function")F(v,this,h);else{var $=v.length,N=ne(v,$);for(c=0;c<$;++c)F(N[c],this,h)}return!0},_.prototype.addListener=function(u,h){return w(this,u,h,!1)},_.prototype.on=_.prototype.addListener,_.prototype.prependListener=function(u,h){return w(this,u,h,!0)},_.prototype.once=function(u,h){return x(h),this.on(u,z(this,u,h)),this},_.prototype.prependOnceListener=function(u,h){return x(h),this.prependListener(u,z(this,u,h)),this},_.prototype.removeListener=function(u,h){var c,o,s,d,g;if(x(h),(o=this._events)===void 0)return this;if((c=o[u])===void 0)return this;if(c===h||c.listener===h)--this._eventsCount==0?this._events=Object.create(null):(delete o[u],o.removeListener&&this.emit("removeListener",u,c.listener||h));else if(typeof c!="function"){for(s=-1,d=c.length-1;d>=0;d--)if(c[d]===h||c[d].listener===h){g=c[d].listener,s=d;break}if(s<0)return this;s===0?c.shift():function(v,$){for(;$+1<v.length;$++)v[$]=v[$+1];v.pop()}(c,s),c.length===1&&(o[u]=c[0]),o.removeListener!==void 0&&this.emit("removeListener",u,g||h)}return this},_.prototype.off=_.prototype.removeListener,_.prototype.removeAllListeners=function(u){var h,c,o;if((c=this._events)===void 0)return this;if(c.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):c[u]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete c[u]),this;if(arguments.length===0){var s,d=Object.keys(c);for(o=0;o<d.length;++o)(s=d[o])!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(typeof(h=c[u])=="function")this.removeListener(u,h);else if(h!==void 0)for(o=h.length-1;o>=0;o--)this.removeListener(u,h[o]);return this},_.prototype.listeners=function(u){return ee(this,u,!0)},_.prototype.rawListeners=function(u){return ee(this,u,!1)},_.listenerCount=function(u,h){return typeof u.listenerCount=="function"?u.listenerCount(h):Q.call(u,h)},_.prototype.listenerCount=Q,_.prototype.eventNames=function(){return this._eventsCount>0?W(this._events):[]},typeof Symbol<"u"&&(oe.prototype[Symbol.iterator]=function(){return this}),oe.of=function(){var u=arguments,h=u.length,c=0;return new oe(function(){return c>=h?{done:!0}:{done:!1,value:u[c++]}})},oe.empty=function(){return new oe(function(){return{done:!0}})},oe.fromSequence=function(u){var h=0,c=u.length;return new oe(function(){return h>=c?{done:!0}:{done:!1,value:u[h++]}})},oe.is=function(u){return u instanceof oe||typeof u=="object"&&u!==null&&typeof u.next=="function"};var se=oe,le={};le.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u",le.SYMBOL_SUPPORT=typeof Symbol<"u";var de=se,qe=le,hn=qe.ARRAY_BUFFER_SUPPORT,At=qe.SYMBOL_SUPPORT,Yt=function(u){var h=function(c){return typeof c=="string"||Array.isArray(c)||hn&&ArrayBuffer.isView(c)?de.fromSequence(c):typeof c!="object"||c===null?null:At&&typeof c[Symbol.iterator]=="function"?c[Symbol.iterator]():typeof c.next=="function"?c:null}(u);if(!h)throw new Error("obliterator: target is not iterable nor a valid iterator.");return h},Vt=Yt,It=function(u,h){for(var c,o=arguments.length>1?h:1/0,s=o!==1/0?new Array(o):[],d=0,g=Vt(u);;){if(d===o)return s;if((c=g.next()).done)return d!==h&&(s.length=d),s;s[d++]=c.value}},$t=function(u){function h(c){var o;return(o=u.call(this)||this).name="GraphError",o.message=c,o}return r(h,u),h}(m(Error)),L=function(u){function h(c){var o;return(o=u.call(this,c)||this).name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(b(o),h.prototype.constructor),o}return r(h,u),h}($t),l=function(u){function h(c){var o;return(o=u.call(this,c)||this).name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(b(o),h.prototype.constructor),o}return r(h,u),h}($t),y=function(u){function h(c){var o;return(o=u.call(this,c)||this).name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(b(o),h.prototype.constructor),o}return r(h,u),h}($t);function k(u,h){this.key=u,this.attributes=h,this.clear()}function B(u,h){this.key=u,this.attributes=h,this.clear()}function T(u,h){this.key=u,this.attributes=h,this.clear()}function K(u,h,c,o,s){this.key=h,this.attributes=s,this.undirected=u,this.source=c,this.target=o}k.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},B.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},T.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},K.prototype.attach=function(){var u="out",h="in";this.undirected&&(u=h="undirected");var c=this.source.key,o=this.target.key;this.source[u][o]=this,this.undirected&&c===o||(this.target[h][c]=this)},K.prototype.attachMulti=function(){var u="out",h="in",c=this.source.key,o=this.target.key;this.undirected&&(u=h="undirected");var s=this.source[u],d=s[o];if(d===void 0)return s[o]=this,void(this.undirected&&c===o||(this.target[h][c]=this));d.previous=this,this.next=d,s[o]=this,this.target[h][c]=this},K.prototype.detach=function(){var u=this.source.key,h=this.target.key,c="out",o="in";this.undirected&&(c=o="undirected"),delete this.source[c][h],delete this.target[o][u]},K.prototype.detachMulti=function(){var u=this.source.key,h=this.target.key,c="out",o="in";this.undirected&&(c=o="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[c][h],delete this.target[o][u]):(this.next.previous=void 0,this.source[c][h]=this.next,this.target[o][u]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};function te(u,h,c,o,s,d,g){var v,$,N,j;if(o=""+o,c===0){if(!(v=u._nodes.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" node in the graph.'));N=s,j=d}else if(c===3){if(s=""+s,!($=u._edges.get(s)))throw new l("Graph.".concat(h,': could not find the "').concat(s,'" edge in the graph.'));var R=$.source.key,q=$.target.key;if(o===R)v=$.target;else{if(o!==q)throw new l("Graph.".concat(h,': the "').concat(o,'" node is not attached to the "').concat(s,'" edge (').concat(R,", ").concat(q,")."));v=$.source}N=d,j=g}else{if(!($=u._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'));v=c===1?$.source:$.target,N=s,j=d}return[v,N,j]}var ge=[{name:function(u){return"get".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g=te(this,h,c,o,s,d),v=g[0],$=g[1];return v.attributes[$]}}},{name:function(u){return"get".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s){return te(this,h,c,o,s)[0].attributes}}},{name:function(u){return"has".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g=te(this,h,c,o,s,d),v=g[0],$=g[1];return v.attributes.hasOwnProperty($)}}},{name:function(u){return"set".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d,g){var v=te(this,h,c,o,s,d,g),$=v[0],N=v[1],j=v[2];return $.attributes[N]=j,this.emit("nodeAttributesUpdated",{key:$.key,type:"set",attributes:$.attributes,name:N}),this}}},{name:function(u){return"update".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d,g){var v=te(this,h,c,o,s,d,g),$=v[0],N=v[1],j=v[2];if(typeof j!="function")throw new L("Graph.".concat(h,": updater should be a function."));var R=$.attributes,q=j(R[N]);return R[N]=q,this.emit("nodeAttributesUpdated",{key:$.key,type:"set",attributes:$.attributes,name:N}),this}}},{name:function(u){return"remove".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g=te(this,h,c,o,s,d),v=g[0],$=g[1];return delete v.attributes[$],this.emit("nodeAttributesUpdated",{key:v.key,type:"remove",attributes:v.attributes,name:$}),this}}},{name:function(u){return"replace".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g=te(this,h,c,o,s,d),v=g[0],$=g[1];if(!G($))throw new L("Graph.".concat(h,": provided attributes are not a plain object."));return v.attributes=$,this.emit("nodeAttributesUpdated",{key:v.key,type:"replace",attributes:v.attributes}),this}}},{name:function(u){return"merge".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g=te(this,h,c,o,s,d),v=g[0],$=g[1];if(!G($))throw new L("Graph.".concat(h,": provided attributes are not a plain object."));return S(v.attributes,$),this.emit("nodeAttributesUpdated",{key:v.key,type:"merge",attributes:v.attributes,data:$}),this}}},{name:function(u){return"update".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g=te(this,h,c,o,s,d),v=g[0],$=g[1];if(typeof $!="function")throw new L("Graph.".concat(h,": provided updater is not a function."));return v.attributes=$(v.attributes),this.emit("nodeAttributesUpdated",{key:v.key,type:"update",attributes:v.attributes}),this}}}],ke=[{name:function(u){return"get".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+o,v=""+s;if(s=arguments[2],!(d=C(this,g,v,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(d=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}return d.attributes[s]}}},{name:function(u){return"get".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o){var s;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var d=""+o,g=""+arguments[1];if(!(s=C(this,d,g,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(d,'" - "').concat(g,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(s=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}return s.attributes}}},{name:function(u){return"has".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+o,v=""+s;if(s=arguments[2],!(d=C(this,g,v,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(d=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}return d.attributes.hasOwnProperty(s)}}},{name:function(u){return"set".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var v=""+o,$=""+s;if(s=arguments[2],d=arguments[3],!(g=C(this,v,$,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(v,'" - "').concat($,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(g=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}return g.attributes[s]=d,this.emit("edgeAttributesUpdated",{key:g.key,type:"set",attributes:g.attributes,name:s}),this}}},{name:function(u){return"update".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var v=""+o,$=""+s;if(s=arguments[2],d=arguments[3],!(g=C(this,v,$,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(v,'" - "').concat($,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(g=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}if(typeof d!="function")throw new L("Graph.".concat(h,": updater should be a function."));return g.attributes[s]=d(g.attributes[s]),this.emit("edgeAttributesUpdated",{key:g.key,type:"set",attributes:g.attributes,name:s}),this}}},{name:function(u){return"remove".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+o,v=""+s;if(s=arguments[2],!(d=C(this,g,v,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(d=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}return delete d.attributes[s],this.emit("edgeAttributesUpdated",{key:d.key,type:"remove",attributes:d.attributes,name:s}),this}}},{name:function(u){return"replace".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+o,v=""+s;if(s=arguments[2],!(d=C(this,g,v,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(d=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}if(!G(s))throw new L("Graph.".concat(h,": provided attributes are not a plain object."));return d.attributes=s,this.emit("edgeAttributesUpdated",{key:d.key,type:"replace",attributes:d.attributes}),this}}},{name:function(u){return"merge".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+o,v=""+s;if(s=arguments[2],!(d=C(this,g,v,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(d=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}if(!G(s))throw new L("Graph.".concat(h,": provided attributes are not a plain object."));return S(d.attributes,s),this.emit("edgeAttributesUpdated",{key:d.key,type:"merge",attributes:d.attributes,data:s}),this}}},{name:function(u){return"update".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+o,v=""+s;if(s=arguments[2],!(d=C(this,g,v,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(d=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}if(typeof s!="function")throw new L("Graph.".concat(h,": provided updater is not a function."));return d.attributes=s(d.attributes),this.emit("edgeAttributesUpdated",{key:d.key,type:"update",attributes:d.attributes}),this}}}],je=se,ze=Yt,me=function(){var u=arguments,h=null,c=-1;return new je(function(){for(var o=null;;){if(h===null){if(++c>=u.length)return{done:!0};h=ze(u[c])}if((o=h.next()).done!==!0)break;h=null}return o})},Se=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function we(u,h,c,o){var s=!1;for(var d in h)if(d!==o){var g=h[d];if(s=c(g.key,g.attributes,g.source.key,g.target.key,g.source.attributes,g.target.attributes,g.undirected),u&&s)return g.key}}function ut(u,h,c,o){var s,d,g,v=!1;for(var $ in h)if($!==o){s=h[$];do{if(d=s.source,g=s.target,v=c(s.key,s.attributes,d.key,g.key,d.attributes,g.attributes,s.undirected),u&&v)return s.key;s=s.next}while(s!==void 0)}}function Gt(u,h){var c,o=Object.keys(u),s=o.length,d=0;return new se(function(){do if(c)c=c.next;else{if(d>=s)return{done:!0};var g=o[d++];if(g===h){c=void 0;continue}c=u[g]}while(!c);return{done:!1,value:{edge:c.key,attributes:c.attributes,source:c.source.key,target:c.target.key,sourceAttributes:c.source.attributes,targetAttributes:c.target.attributes,undirected:c.undirected}}})}function Uo(u,h,c,o){var s=h[c];if(s){var d=s.source,g=s.target;return o(s.key,s.attributes,d.key,g.key,d.attributes,g.attributes,s.undirected)&&u?s.key:void 0}}function jo(u,h,c,o){var s=h[c];if(s){var d=!1;do{if(d=o(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),u&&d)return s.key;s=s.next}while(s!==void 0)}}function Rn(u,h){var c=u[h];return c.next!==void 0?new se(function(){if(!c)return{done:!0};var o={edge:c.key,attributes:c.attributes,source:c.source.key,target:c.target.key,sourceAttributes:c.source.attributes,targetAttributes:c.target.attributes,undirected:c.undirected};return c=c.next,{done:!1,value:o}}):se.of({edge:c.key,attributes:c.attributes,source:c.source.key,target:c.target.key,sourceAttributes:c.source.attributes,targetAttributes:c.target.attributes,undirected:c.undirected})}function No(u,h){if(u.size===0)return[];if(h==="mixed"||h===u.type)return typeof Array.from=="function"?Array.from(u._edges.keys()):It(u._edges.keys(),u._edges.size);for(var c,o,s=h==="undirected"?u.undirectedSize:u.directedSize,d=new Array(s),g=h==="undirected",v=u._edges.values(),$=0;(c=v.next()).done!==!0;)(o=c.value).undirected===g&&(d[$++]=o.key);return d}function Fr(u,h,c,o){if(h.size!==0){for(var s,d,g=c!=="mixed"&&c!==h.type,v=c==="undirected",$=!1,N=h._edges.values();(s=N.next()).done!==!0;)if(d=s.value,!g||d.undirected===v){var j=d,R=j.key,q=j.attributes,Y=j.source,Z=j.target;if($=o(R,q,Y.key,Z.key,Y.attributes,Z.attributes,d.undirected),u&&$)return R}}}function To(u,h){if(u.size===0)return se.empty();var c=h!=="mixed"&&h!==u.type,o=h==="undirected",s=u._edges.values();return new se(function(){for(var d,g;;){if((d=s.next()).done)return d;if(g=d.value,!c||g.undirected===o)break}return{value:{edge:g.key,attributes:g.attributes,source:g.source.key,target:g.target.key,sourceAttributes:g.source.attributes,targetAttributes:g.target.attributes,undirected:g.undirected},done:!1}})}function Un(u,h,c,o,s,d){var g,v=h?ut:we;if(c!=="undirected"&&(o!=="out"&&(g=v(u,s.in,d),u&&g)||o!=="in"&&(g=v(u,s.out,d,o?void 0:s.key),u&&g))||c!=="directed"&&(g=v(u,s.undirected,d),u&&g))return g}function Bo(u,h,c,o){var s=[];return Un(!1,u,h,c,o,function(d){s.push(d)}),s}function Wo(u,h,c){var o=se.empty();return u!=="undirected"&&(h!=="out"&&c.in!==void 0&&(o=me(o,Gt(c.in))),h!=="in"&&c.out!==void 0&&(o=me(o,Gt(c.out,h?void 0:c.key)))),u!=="directed"&&c.undirected!==void 0&&(o=me(o,Gt(c.undirected))),o}function jn(u,h,c,o,s,d,g){var v,$=c?jo:Uo;if(h!=="undirected"&&(s.in!==void 0&&o!=="out"&&(v=$(u,s.in,d,g),u&&v)||s.out!==void 0&&o!=="in"&&(o||s.key!==d)&&(v=$(u,s.out,d,g),u&&v))||h!=="directed"&&s.undirected!==void 0&&(v=$(u,s.undirected,d,g),u&&v))return v}function Fo(u,h,c,o,s){var d=[];return jn(!1,u,h,c,o,s,function(g){d.push(g)}),d}function Po(u,h,c,o){var s=se.empty();return u!=="undirected"&&(c.in!==void 0&&h!=="out"&&o in c.in&&(s=me(s,Rn(c.in,o))),c.out!==void 0&&h!=="in"&&o in c.out&&(h||c.key!==o)&&(s=me(s,Rn(c.out,o)))),u!=="directed"&&c.undirected!==void 0&&o in c.undirected&&(s=me(s,Rn(c.undirected,o))),s}var qo=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function fn(){this.A=null,this.B=null}function Xt(u,h,c,o,s){for(var d in o){var g=o[d],v=g.source,$=g.target,N=v===c?$:v;if(!h||!h.has(N.key)){var j=s(N.key,N.attributes);if(u&&j)return N.key}}}function Nn(u,h,c,o,s){if(h!=="mixed"){if(h==="undirected")return Xt(u,null,o,o.undirected,s);if(typeof c=="string")return Xt(u,null,o,o[c],s)}var d,g=new fn;if(h!=="undirected"){if(c!=="out"){if(d=Xt(u,null,o,o.in,s),u&&d)return d;g.wrap(o.in)}if(c!=="in"){if(d=Xt(u,g,o,o.out,s),u&&d)return d;g.wrap(o.out)}}if(h!=="directed"&&(d=Xt(u,g,o,o.undirected,s),u&&d))return d}function Ht(u,h,c){var o=Object.keys(c),s=o.length,d=0;return new se(function(){var g=null;do{if(d>=s)return u&&u.wrap(c),{done:!0};var v=c[o[d++]],$=v.source,N=v.target;g=$===h?N:$,u&&u.has(g.key)&&(g=null)}while(g===null);return{done:!1,value:{neighbor:g.key,attributes:g.attributes}}})}function Ko(u,h){var c=h.name,o=h.type,s=h.direction;u.prototype[c]=function(d){if(o!=="mixed"&&this.type!=="mixed"&&o!==this.type)return[];d=""+d;var g=this._nodes.get(d);if(g===void 0)throw new l("Graph.".concat(c,': could not find the "').concat(d,'" node in the graph.'));return function(v,$,N){if(v!=="mixed"){if(v==="undirected")return Object.keys(N.undirected);if(typeof $=="string")return Object.keys(N[$])}var j=[];return Nn(!1,v,$,N,function(R){j.push(R)}),j}(o==="mixed"?this.type:o,s,g)}}function Yo(u,h){var c=h.name,o=h.type,s=h.direction,d=c.slice(0,-1)+"Entries";u.prototype[d]=function(g){if(o!=="mixed"&&this.type!=="mixed"&&o!==this.type)return se.empty();g=""+g;var v=this._nodes.get(g);if(v===void 0)throw new l("Graph.".concat(d,': could not find the "').concat(g,'" node in the graph.'));return function($,N,j){if($!=="mixed"){if($==="undirected")return Ht(null,j,j.undirected);if(typeof N=="string")return Ht(null,j,j[N])}var R=se.empty(),q=new fn;return $!=="undirected"&&(N!=="out"&&(R=me(R,Ht(q,j,j.in))),N!=="in"&&(R=me(R,Ht(q,j,j.out)))),$!=="directed"&&(R=me(R,Ht(q,j,j.undirected))),R}(o==="mixed"?this.type:o,s,v)}}function pn(u,h,c,o,s){for(var d,g,v,$,N,j,R,q=o._nodes.values(),Y=o.type;(d=q.next()).done!==!0;){var Z=!1;if(g=d.value,Y!=="undirected")for(v in $=g.out){N=$[v];do j=N.target,Z=!0,R=s(g.key,j.key,g.attributes,j.attributes,N.key,N.attributes,N.undirected),N=N.next;while(N)}if(Y!=="directed"){for(v in $=g.undirected)if(!(h&&g.key>v)){N=$[v];do(j=N.target).key!==v&&(j=N.source),Z=!0,R=s(g.key,j.key,g.attributes,j.attributes,N.key,N.attributes,N.undirected),N=N.next;while(N)}}c&&!Z&&(R=s(g.key,null,g.attributes,null,null,null,null))}}function Vo(u){if(!G(u))throw new L('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in u))throw new L("Graph.import: serialized node is missing its key.");if("attributes"in u&&(!G(u.attributes)||u.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Xo(u){if(!G(u))throw new L('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in u))throw new L("Graph.import: serialized edge is missing its source.");if(!("target"in u))throw new L("Graph.import: serialized edge is missing its target.");if("attributes"in u&&(!G(u.attributes)||u.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in u&&typeof u.undirected!="boolean")throw new L("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}fn.prototype.wrap=function(u){this.A===null?this.A=u:this.B===null&&(this.B=u)},fn.prototype.has=function(u){return this.A!==null&&u in this.A||this.B!==null&&u in this.B};var Pr,Ho=(Pr=255&Math.floor(256*Math.random()),function(){return Pr++}),Jo=new Set(["directed","undirected","mixed"]),qr=new Set(["domain","_events","_eventsCount","_maxListeners"]),Qo={allowSelfLoops:!0,multi:!1,type:"mixed"};function Kr(u,h,c){var o=new u.NodeDataClass(h,c);return u._nodes.set(h,o),u.emit("nodeAdded",{key:h,attributes:c}),o}function Yr(u,h,c,o,s,d,g,v){if(!o&&u.type==="undirected")throw new y("Graph.".concat(h,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(o&&u.type==="directed")throw new y("Graph.".concat(h,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(v&&!G(v))throw new L("Graph.".concat(h,': invalid attributes. Expecting an object but got "').concat(v,'"'));if(d=""+d,g=""+g,v=v||{},!u.allowSelfLoops&&d===g)throw new y("Graph.".concat(h,': source & target are the same ("').concat(d,`"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`));var $=u._nodes.get(d),N=u._nodes.get(g);if(!$)throw new l("Graph.".concat(h,': source node "').concat(d,'" not found.'));if(!N)throw new l("Graph.".concat(h,': target node "').concat(g,'" not found.'));var j={key:null,undirected:o,source:d,target:g,attributes:v};if(c)s=u._edgeKeyGenerator();else if(s=""+s,u._edges.has(s))throw new y("Graph.".concat(h,': the "').concat(s,'" edge already exists in the graph.'));if(!u.multi&&(o?$.undirected[g]!==void 0:$.out[g]!==void 0))throw new y("Graph.".concat(h,': an edge linking "').concat(d,'" to "').concat(g,`" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`));var R=new K(o,s,$,N,v);u._edges.set(s,R);var q=d===g;return o?($.undirectedDegree++,N.undirectedDegree++,q&&($.undirectedLoops++,u._undirectedSelfLoopCount++)):($.outDegree++,N.inDegree++,q&&($.directedLoops++,u._directedSelfLoopCount++)),u.multi?R.attachMulti():R.attach(),o?u._undirectedSize++:u._directedSize++,j.key=s,u.emit("edgeAdded",j),s}function Zo(u,h,c,o,s,d,g,v,$){if(!o&&u.type==="undirected")throw new y("Graph.".concat(h,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(o&&u.type==="directed")throw new y("Graph.".concat(h,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(v){if($){if(typeof v!="function")throw new L("Graph.".concat(h,': invalid updater function. Expecting a function but got "').concat(v,'"'))}else if(!G(v))throw new L("Graph.".concat(h,': invalid attributes. Expecting an object but got "').concat(v,'"'))}var N;if(d=""+d,g=""+g,$&&(N=v,v=void 0),!u.allowSelfLoops&&d===g)throw new y("Graph.".concat(h,': source & target are the same ("').concat(d,`"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`));var j,R,q=u._nodes.get(d),Y=u._nodes.get(g);if(!c&&(j=u._edges.get(s))){if(!(j.source.key===d&&j.target.key===g||o&&j.source.key===g&&j.target.key===d))throw new y("Graph.".concat(h,': inconsistency detected when attempting to merge the "').concat(s,'" edge with "').concat(d,'" source & "').concat(g,'" target vs. ("').concat(j.source.key,'", "').concat(j.target.key,'").'));R=j}if(R||u.multi||!q||(R=o?q.undirected[g]:q.out[g]),R){var Z=[R.key,!1,!1,!1];if($?!N:!v)return Z;if($){var ae=R.attributes;R.attributes=N(ae),u.emit("edgeAttributesUpdated",{type:"replace",key:R.key,attributes:R.attributes})}else S(R.attributes,v),u.emit("edgeAttributesUpdated",{type:"merge",key:R.key,attributes:R.attributes,data:v});return Z}v=v||{},$&&N&&(v=N(v));var fe={key:null,undirected:o,source:d,target:g,attributes:v};if(c)s=u._edgeKeyGenerator();else if(s=""+s,u._edges.has(s))throw new y("Graph.".concat(h,': the "').concat(s,'" edge already exists in the graph.'));var Ge=!1,$e=!1;q||(q=Kr(u,d,{}),Ge=!0,d===g&&(Y=q,$e=!0)),Y||(Y=Kr(u,g,{}),$e=!0),j=new K(o,s,q,Y,v),u._edges.set(s,j);var Ne=d===g;return o?(q.undirectedDegree++,Y.undirectedDegree++,Ne&&(q.undirectedLoops++,u._undirectedSelfLoopCount++)):(q.outDegree++,Y.inDegree++,Ne&&(q.directedLoops++,u._directedSelfLoopCount++)),u.multi?j.attachMulti():j.attach(),o?u._undirectedSize++:u._directedSize++,fe.key=s,u.emit("edgeAdded",fe),[s,!0,Ge,$e]}function Ot(u,h){u._edges.delete(h.key);var c=h.source,o=h.target,s=h.attributes,d=h.undirected,g=c===o;d?(c.undirectedDegree--,o.undirectedDegree--,g&&(c.undirectedLoops--,u._undirectedSelfLoopCount--)):(c.outDegree--,o.inDegree--,g&&(c.directedLoops--,u._directedSelfLoopCount--)),u.multi?h.detachMulti():h.detach(),d?u._undirectedSize--:u._directedSize--,u.emit("edgeDropped",{key:h.key,attributes:s,source:c.key,target:o.key,undirected:d})}var he=function(u){function h(o){var s;if(s=u.call(this)||this,typeof(o=S({},Qo,o)).multi!="boolean")throw new L(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "`.concat(o.multi,'".'));if(!Jo.has(o.type))throw new L(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "`.concat(o.type,'".'));if(typeof o.allowSelfLoops!="boolean")throw new L(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "`.concat(o.allowSelfLoops,'".'));var d=o.type==="mixed"?k:o.type==="directed"?B:T;A(b(s),"NodeDataClass",d);var g="geid_"+Ho()+"_",v=0;return A(b(s),"_attributes",{}),A(b(s),"_nodes",new Map),A(b(s),"_edges",new Map),A(b(s),"_directedSize",0),A(b(s),"_undirectedSize",0),A(b(s),"_directedSelfLoopCount",0),A(b(s),"_undirectedSelfLoopCount",0),A(b(s),"_edgeKeyGenerator",function(){var $;do $=g+v++;while(s._edges.has($));return $}),A(b(s),"_options",o),qr.forEach(function($){return A(b(s),$,s[$])}),U(b(s),"order",function(){return s._nodes.size}),U(b(s),"size",function(){return s._edges.size}),U(b(s),"directedSize",function(){return s._directedSize}),U(b(s),"undirectedSize",function(){return s._undirectedSize}),U(b(s),"selfLoopCount",function(){return s._directedSelfLoopCount+s._undirectedSelfLoopCount}),U(b(s),"directedSelfLoopCount",function(){return s._directedSelfLoopCount}),U(b(s),"undirectedSelfLoopCount",function(){return s._undirectedSelfLoopCount}),U(b(s),"multi",s._options.multi),U(b(s),"type",s._options.type),U(b(s),"allowSelfLoops",s._options.allowSelfLoops),U(b(s),"implementation",function(){return"graphology"}),s}r(h,u);var c=h.prototype;return c._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},c.hasNode=function(o){return this._nodes.has(""+o)},c.hasDirectedEdge=function(o,s){if(this.type==="undirected")return!1;if(arguments.length===1){var d=""+o,g=this._edges.get(d);return!!g&&!g.undirected}if(arguments.length===2){o=""+o,s=""+s;var v=this._nodes.get(o);return!!v&&v.out.hasOwnProperty(s)}throw new L("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},c.hasUndirectedEdge=function(o,s){if(this.type==="directed")return!1;if(arguments.length===1){var d=""+o,g=this._edges.get(d);return!!g&&g.undirected}if(arguments.length===2){o=""+o,s=""+s;var v=this._nodes.get(o);return!!v&&v.undirected.hasOwnProperty(s)}throw new L("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},c.hasEdge=function(o,s){if(arguments.length===1){var d=""+o;return this._edges.has(d)}if(arguments.length===2){o=""+o,s=""+s;var g=this._nodes.get(o);return!!g&&(g.out!==void 0&&g.out.hasOwnProperty(s)||g.undirected!==void 0&&g.undirected.hasOwnProperty(s))}throw new L("Graph.hasEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},c.directedEdge=function(o,s){if(this.type!=="undirected"){if(o=""+o,s=""+s,this.multi)throw new y("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var d=this._nodes.get(o);if(!d)throw new l('Graph.directedEdge: could not find the "'.concat(o,'" source node in the graph.'));if(!this._nodes.has(s))throw new l('Graph.directedEdge: could not find the "'.concat(s,'" target node in the graph.'));var g=d.out&&d.out[s]||void 0;return g?g.key:void 0}},c.undirectedEdge=function(o,s){if(this.type!=="directed"){if(o=""+o,s=""+s,this.multi)throw new y("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var d=this._nodes.get(o);if(!d)throw new l('Graph.undirectedEdge: could not find the "'.concat(o,'" source node in the graph.'));if(!this._nodes.has(s))throw new l('Graph.undirectedEdge: could not find the "'.concat(s,'" target node in the graph.'));var g=d.undirected&&d.undirected[s]||void 0;return g?g.key:void 0}},c.edge=function(o,s){if(this.multi)throw new y("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.edge: could not find the "'.concat(o,'" source node in the graph.'));if(!this._nodes.has(s))throw new l('Graph.edge: could not find the "'.concat(s,'" target node in the graph.'));var g=d.out&&d.out[s]||d.undirected&&d.undirected[s]||void 0;if(g)return g.key},c.areDirectedNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areDirectedNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="undirected"&&(s in d.in||s in d.out)},c.areOutNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areOutNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="undirected"&&s in d.out},c.areInNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areInNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="undirected"&&s in d.in},c.areUndirectedNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areUndirectedNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="directed"&&s in d.undirected},c.areNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="undirected"&&(s in d.in||s in d.out)||this.type!=="directed"&&s in d.undirected},c.areInboundNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areInboundNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="undirected"&&s in d.in||this.type!=="directed"&&s in d.undirected},c.areOutboundNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areOutboundNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="undirected"&&s in d.out||this.type!=="directed"&&s in d.undirected},c.inDegree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.inDegree: could not find the "'.concat(o,'" node in the graph.'));return this.type==="undirected"?0:s.inDegree},c.outDegree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.outDegree: could not find the "'.concat(o,'" node in the graph.'));return this.type==="undirected"?0:s.outDegree},c.directedDegree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.directedDegree: could not find the "'.concat(o,'" node in the graph.'));return this.type==="undirected"?0:s.inDegree+s.outDegree},c.undirectedDegree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.undirectedDegree: could not find the "'.concat(o,'" node in the graph.'));return this.type==="directed"?0:s.undirectedDegree},c.inboundDegree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.inboundDegree: could not find the "'.concat(o,'" node in the graph.'));var d=0;return this.type!=="directed"&&(d+=s.undirectedDegree),this.type!=="undirected"&&(d+=s.inDegree),d},c.outboundDegree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.outboundDegree: could not find the "'.concat(o,'" node in the graph.'));var d=0;return this.type!=="directed"&&(d+=s.undirectedDegree),this.type!=="undirected"&&(d+=s.outDegree),d},c.degree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.degree: could not find the "'.concat(o,'" node in the graph.'));var d=0;return this.type!=="directed"&&(d+=s.undirectedDegree),this.type!=="undirected"&&(d+=s.inDegree+s.outDegree),d},c.inDegreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));return this.type==="undirected"?0:s.inDegree-s.directedLoops},c.outDegreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));return this.type==="undirected"?0:s.outDegree-s.directedLoops},c.directedDegreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));return this.type==="undirected"?0:s.inDegree+s.outDegree-2*s.directedLoops},c.undirectedDegreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));return this.type==="directed"?0:s.undirectedDegree-2*s.undirectedLoops},c.inboundDegreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));var d=0,g=0;return this.type!=="directed"&&(d+=s.undirectedDegree,g+=2*s.undirectedLoops),this.type!=="undirected"&&(d+=s.inDegree,g+=s.directedLoops),d-g},c.outboundDegreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));var d=0,g=0;return this.type!=="directed"&&(d+=s.undirectedDegree,g+=2*s.undirectedLoops),this.type!=="undirected"&&(d+=s.outDegree,g+=s.directedLoops),d-g},c.degreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.degreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));var d=0,g=0;return this.type!=="directed"&&(d+=s.undirectedDegree,g+=2*s.undirectedLoops),this.type!=="undirected"&&(d+=s.inDegree+s.outDegree,g+=2*s.directedLoops),d-g},c.source=function(o){o=""+o;var s=this._edges.get(o);if(!s)throw new l('Graph.source: could not find the "'.concat(o,'" edge in the graph.'));return s.source.key},c.target=function(o){o=""+o;var s=this._edges.get(o);if(!s)throw new l('Graph.target: could not find the "'.concat(o,'" edge in the graph.'));return s.target.key},c.extremities=function(o){o=""+o;var s=this._edges.get(o);if(!s)throw new l('Graph.extremities: could not find the "'.concat(o,'" edge in the graph.'));return[s.source.key,s.target.key]},c.opposite=function(o,s){o=""+o,s=""+s;var d=this._edges.get(s);if(!d)throw new l('Graph.opposite: could not find the "'.concat(s,'" edge in the graph.'));var g=d.source.key,v=d.target.key;if(o===g)return v;if(o===v)return g;throw new l('Graph.opposite: the "'.concat(o,'" node is not attached to the "').concat(s,'" edge (').concat(g,", ").concat(v,")."))},c.hasExtremity=function(o,s){o=""+o,s=""+s;var d=this._edges.get(o);if(!d)throw new l('Graph.hasExtremity: could not find the "'.concat(o,'" edge in the graph.'));return d.source.key===s||d.target.key===s},c.isUndirected=function(o){o=""+o;var s=this._edges.get(o);if(!s)throw new l('Graph.isUndirected: could not find the "'.concat(o,'" edge in the graph.'));return s.undirected},c.isDirected=function(o){o=""+o;var s=this._edges.get(o);if(!s)throw new l('Graph.isDirected: could not find the "'.concat(o,'" edge in the graph.'));return!s.undirected},c.isSelfLoop=function(o){o=""+o;var s=this._edges.get(o);if(!s)throw new l('Graph.isSelfLoop: could not find the "'.concat(o,'" edge in the graph.'));return s.source===s.target},c.addNode=function(o,s){var d=function(g,v,$){if($&&!G($))throw new L('Graph.addNode: invalid attributes. Expecting an object but got "'.concat($,'"'));if(v=""+v,$=$||{},g._nodes.has(v))throw new y('Graph.addNode: the "'.concat(v,'" node already exist in the graph.'));var N=new g.NodeDataClass(v,$);return g._nodes.set(v,N),g.emit("nodeAdded",{key:v,attributes:$}),N}(this,o,s);return d.key},c.mergeNode=function(o,s){if(s&&!G(s))throw new L('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(s,'"'));o=""+o,s=s||{};var d=this._nodes.get(o);return d?(s&&(S(d.attributes,s),this.emit("nodeAttributesUpdated",{type:"merge",key:o,attributes:d.attributes,data:s})),[o,!1]):(d=new this.NodeDataClass(o,s),this._nodes.set(o,d),this.emit("nodeAdded",{key:o,attributes:s}),[o,!0])},c.updateNode=function(o,s){if(s&&typeof s!="function")throw new L('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(s,'"'));o=""+o;var d=this._nodes.get(o);if(d){if(s){var g=d.attributes;d.attributes=s(g),this.emit("nodeAttributesUpdated",{type:"replace",key:o,attributes:d.attributes})}return[o,!1]}var v=s?s({}):{};return d=new this.NodeDataClass(o,v),this._nodes.set(o,d),this.emit("nodeAdded",{key:o,attributes:v}),[o,!0]},c.dropNode=function(o){o=""+o;var s,d=this._nodes.get(o);if(!d)throw new l('Graph.dropNode: could not find the "'.concat(o,'" node in the graph.'));if(this.type!=="undirected"){for(var g in d.out){s=d.out[g];do Ot(this,s),s=s.next;while(s)}for(var v in d.in){s=d.in[v];do Ot(this,s),s=s.next;while(s)}}if(this.type!=="directed")for(var $ in d.undirected){s=d.undirected[$];do Ot(this,s),s=s.next;while(s)}this._nodes.delete(o),this.emit("nodeDropped",{key:o,attributes:d.attributes})},c.dropEdge=function(o){var s;if(arguments.length>1){var d=""+arguments[0],g=""+arguments[1];if(!(s=C(this,d,g,this.type)))throw new l('Graph.dropEdge: could not find the "'.concat(d,'" -> "').concat(g,'" edge in the graph.'))}else if(o=""+o,!(s=this._edges.get(o)))throw new l('Graph.dropEdge: could not find the "'.concat(o,'" edge in the graph.'));return Ot(this,s),this},c.dropDirectedEdge=function(o,s){if(arguments.length<2)throw new y("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new y("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var d=C(this,o=""+o,s=""+s,"directed");if(!d)throw new l('Graph.dropDirectedEdge: could not find a "'.concat(o,'" -> "').concat(s,'" edge in the graph.'));return Ot(this,d),this},c.dropUndirectedEdge=function(o,s){if(arguments.length<2)throw new y("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new y("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var d=C(this,o,s,"undirected");if(!d)throw new l('Graph.dropUndirectedEdge: could not find a "'.concat(o,'" -> "').concat(s,'" edge in the graph.'));return Ot(this,d),this},c.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},c.clearEdges=function(){for(var o,s=this._nodes.values();(o=s.next()).done!==!0;)o.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},c.getAttribute=function(o){return this._attributes[o]},c.getAttributes=function(){return this._attributes},c.hasAttribute=function(o){return this._attributes.hasOwnProperty(o)},c.setAttribute=function(o,s){return this._attributes[o]=s,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:o}),this},c.updateAttribute=function(o,s){if(typeof s!="function")throw new L("Graph.updateAttribute: updater should be a function.");var d=this._attributes[o];return this._attributes[o]=s(d),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:o}),this},c.removeAttribute=function(o){return delete this._attributes[o],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:o}),this},c.replaceAttributes=function(o){if(!G(o))throw new L("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=o,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},c.mergeAttributes=function(o){if(!G(o))throw new L("Graph.mergeAttributes: provided attributes are not a plain object.");return S(this._attributes,o),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:o}),this},c.updateAttributes=function(o){if(typeof o!="function")throw new L("Graph.updateAttributes: provided updater is not a function.");return this._attributes=o(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},c.updateEachNodeAttributes=function(o,s){if(typeof o!="function")throw new L("Graph.updateEachNodeAttributes: expecting an updater function.");if(s&&!I(s))throw new L("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var d,g,v=this._nodes.values();(d=v.next()).done!==!0;)(g=d.value).attributes=o(g.key,g.attributes);this.emit("eachNodeAttributesUpdated",{hints:s||null})},c.updateEachEdgeAttributes=function(o,s){if(typeof o!="function")throw new L("Graph.updateEachEdgeAttributes: expecting an updater function.");if(s&&!I(s))throw new L("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var d,g,v,$,N=this._edges.values();(d=N.next()).done!==!0;)v=(g=d.value).source,$=g.target,g.attributes=o(g.key,g.attributes,v.key,$.key,v.attributes,$.attributes,g.undirected);this.emit("eachEdgeAttributesUpdated",{hints:s||null})},c.forEachAdjacencyEntry=function(o){if(typeof o!="function")throw new L("Graph.forEachAdjacencyEntry: expecting a callback.");pn(!1,!1,!1,this,o)},c.forEachAdjacencyEntryWithOrphans=function(o){if(typeof o!="function")throw new L("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");pn(!1,!1,!0,this,o)},c.forEachAssymetricAdjacencyEntry=function(o){if(typeof o!="function")throw new L("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");pn(!1,!0,!1,this,o)},c.forEachAssymetricAdjacencyEntryWithOrphans=function(o){if(typeof o!="function")throw new L("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");pn(!1,!0,!0,this,o)},c.nodes=function(){return typeof Array.from=="function"?Array.from(this._nodes.keys()):It(this._nodes.keys(),this._nodes.size)},c.forEachNode=function(o){if(typeof o!="function")throw new L("Graph.forEachNode: expecting a callback.");for(var s,d,g=this._nodes.values();(s=g.next()).done!==!0;)o((d=s.value).key,d.attributes)},c.findNode=function(o){if(typeof o!="function")throw new L("Graph.findNode: expecting a callback.");for(var s,d,g=this._nodes.values();(s=g.next()).done!==!0;)if(o((d=s.value).key,d.attributes))return d.key},c.mapNodes=function(o){if(typeof o!="function")throw new L("Graph.mapNode: expecting a callback.");for(var s,d,g=this._nodes.values(),v=new Array(this.order),$=0;(s=g.next()).done!==!0;)d=s.value,v[$++]=o(d.key,d.attributes);return v},c.someNode=function(o){if(typeof o!="function")throw new L("Graph.someNode: expecting a callback.");for(var s,d,g=this._nodes.values();(s=g.next()).done!==!0;)if(o((d=s.value).key,d.attributes))return!0;return!1},c.everyNode=function(o){if(typeof o!="function")throw new L("Graph.everyNode: expecting a callback.");for(var s,d,g=this._nodes.values();(s=g.next()).done!==!0;)if(!o((d=s.value).key,d.attributes))return!1;return!0},c.filterNodes=function(o){if(typeof o!="function")throw new L("Graph.filterNodes: expecting a callback.");for(var s,d,g=this._nodes.values(),v=[];(s=g.next()).done!==!0;)o((d=s.value).key,d.attributes)&&v.push(d.key);return v},c.reduceNodes=function(o,s){if(typeof o!="function")throw new L("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new L("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");for(var d,g,v=s,$=this._nodes.values();(d=$.next()).done!==!0;)v=o(v,(g=d.value).key,g.attributes);return v},c.nodeEntries=function(){var o=this._nodes.values();return new se(function(){var s=o.next();if(s.done)return s;var d=s.value;return{value:{node:d.key,attributes:d.attributes},done:!1}})},c.export=function(){var o=this,s=new Array(this._nodes.size),d=0;this._nodes.forEach(function(v,$){s[d++]=function(N,j){var R={key:N};return D(j.attributes)||(R.attributes=S({},j.attributes)),R}($,v)});var g=new Array(this._edges.size);return d=0,this._edges.forEach(function(v,$){g[d++]=function(N,j,R){var q={key:j,source:R.source.key,target:R.target.key};return D(R.attributes)||(q.attributes=S({},R.attributes)),N==="mixed"&&R.undirected&&(q.undirected=!0),q}(o.type,$,v)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:s,edges:g}},c.import=function(o){var s,d,g,v,$,N=this,j=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(o instanceof h)return o.forEachNode(function(Te,Xe){j?N.mergeNode(Te,Xe):N.addNode(Te,Xe)}),o.forEachEdge(function(Te,Xe,gn,mn,Bu,Wu,Zr){j?Zr?N.mergeUndirectedEdgeWithKey(Te,gn,mn,Xe):N.mergeDirectedEdgeWithKey(Te,gn,mn,Xe):Zr?N.addUndirectedEdgeWithKey(Te,gn,mn,Xe):N.addDirectedEdgeWithKey(Te,gn,mn,Xe)}),this;if(!G(o))throw new L("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(o.attributes){if(!G(o.attributes))throw new L("Graph.import: invalid attributes. Expecting a plain object.");j?this.mergeAttributes(o.attributes):this.replaceAttributes(o.attributes)}if(o.nodes){if(g=o.nodes,!Array.isArray(g))throw new L("Graph.import: invalid nodes. Expecting an array.");for(s=0,d=g.length;s<d;s++){Vo(v=g[s]);var R=v,q=R.key,Y=R.attributes;j?this.mergeNode(q,Y):this.addNode(q,Y)}}if(o.edges){var Z=!1;if(this.type==="undirected"&&(Z=!0),g=o.edges,!Array.isArray(g))throw new L("Graph.import: invalid edges. Expecting an array.");for(s=0,d=g.length;s<d;s++){Xo($=g[s]);var ae=$,fe=ae.source,Ge=ae.target,$e=ae.attributes,Ne=ae.undirected,Ke=Ne===void 0?Z:Ne;"key"in $?(j?Ke?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:Ke?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,$.key,fe,Ge,$e):(j?Ke?this.mergeUndirectedEdge:this.mergeDirectedEdge:Ke?this.addUndirectedEdge:this.addDirectedEdge).call(this,fe,Ge,$e)}}return this},c.nullCopy=function(o){var s=new h(S({},this._options,o));return s.replaceAttributes(S({},this.getAttributes())),s},c.emptyCopy=function(o){var s=this.nullCopy(o);return this._nodes.forEach(function(d,g){var v=S({},d.attributes);d=new s.NodeDataClass(g,v),s._nodes.set(g,d)}),s},c.copy=function(o){if(typeof(o=o||{}).type=="string"&&o.type!==this.type&&o.type!=="mixed")throw new y('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(o.type,'" because this would mean losing information about the current graph.'));if(typeof o.multi=="boolean"&&o.multi!==this.multi&&o.multi!==!0)throw new y("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof o.allowSelfLoops=="boolean"&&o.allowSelfLoops!==this.allowSelfLoops&&o.allowSelfLoops!==!0)throw new y("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");for(var s,d,g=this.emptyCopy(o),v=this._edges.values();(s=v.next()).done!==!0;)Yr(g,"copy",!1,(d=s.value).undirected,d.key,d.source.key,d.target.key,S({},d.attributes));return g},c.toJSON=function(){return this.export()},c.toString=function(){return"[object Graph]"},c.inspect=function(){var o=this,s={};this._nodes.forEach(function(N,j){s[j]=N.attributes});var d={},g={};this._edges.forEach(function(N,j){var R,q=N.undirected?"--":"->",Y="",Z=N.source.key,ae=N.target.key;N.undirected&&Z>ae&&(R=Z,Z=ae,ae=R);var fe="(".concat(Z,")").concat(q,"(").concat(ae,")");j.startsWith("geid_")?o.multi&&(g[fe]===void 0?g[fe]=0:g[fe]++,Y+="".concat(g[fe],". ")):Y+="[".concat(j,"]: "),d[Y+=fe]=N.attributes});var v={};for(var $ in this)this.hasOwnProperty($)&&!qr.has($)&&typeof this[$]!="function"&&t($)!=="symbol"&&(v[$]=this[$]);return v.attributes=this._attributes,v.nodes=s,v.edges=d,A(v,"constructor",this.constructor),v},h}(V.exports.EventEmitter);typeof Symbol<"u"&&(he.prototype[Symbol.for("nodejs.util.inspect.custom")]=he.prototype.inspect),[{name:function(u){return"".concat(u,"Edge")},generateKey:!0},{name:function(u){return"".concat(u,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(u){return"".concat(u,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(u){return"".concat(u,"EdgeWithKey")}},{name:function(u){return"".concat(u,"DirectedEdgeWithKey")},type:"directed"},{name:function(u){return"".concat(u,"UndirectedEdgeWithKey")},type:"undirected"}].forEach(function(u){["add","merge","update"].forEach(function(h){var c=u.name(h),o=h==="add"?Yr:Zo;u.generateKey?he.prototype[c]=function(s,d,g){return o(this,c,!0,(u.type||this.type)==="undirected",null,s,d,g,h==="update")}:he.prototype[c]=function(s,d,g,v){return o(this,c,!1,(u.type||this.type)==="undirected",s,d,g,v,h==="update")}})}),function(u){ge.forEach(function(h){var c=h.name,o=h.attacher;o(u,c("Node"),0),o(u,c("Source"),1),o(u,c("Target"),2),o(u,c("Opposite"),3)})}(he),function(u){ke.forEach(function(h){var c=h.name,o=h.attacher;o(u,c("Edge"),"mixed"),o(u,c("DirectedEdge"),"directed"),o(u,c("UndirectedEdge"),"undirected")})}(he),function(u){Se.forEach(function(h){(function(c,o){var s=o.name,d=o.type,g=o.direction;c.prototype[s]=function(v,$){if(d!=="mixed"&&this.type!=="mixed"&&d!==this.type)return[];if(!arguments.length)return No(this,d);if(arguments.length===1){v=""+v;var N=this._nodes.get(v);if(N===void 0)throw new l("Graph.".concat(s,': could not find the "').concat(v,'" node in the graph.'));return Bo(this.multi,d==="mixed"?this.type:d,g,N)}if(arguments.length===2){v=""+v,$=""+$;var j=this._nodes.get(v);if(!j)throw new l("Graph.".concat(s,': could not find the "').concat(v,'" source node in the graph.'));if(!this._nodes.has($))throw new l("Graph.".concat(s,': could not find the "').concat($,'" target node in the graph.'));return Fo(d,this.multi,g,j,$)}throw new L("Graph.".concat(s,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}})(u,h),function(c,o){var s=o.name,d=o.type,g=o.direction,v="forEach"+s[0].toUpperCase()+s.slice(1,-1);c.prototype[v]=function(R,q,Y){if(d==="mixed"||this.type==="mixed"||d===this.type){if(arguments.length===1)return Fr(!1,this,d,Y=R);if(arguments.length===2){R=""+R,Y=q;var Z=this._nodes.get(R);if(Z===void 0)throw new l("Graph.".concat(v,': could not find the "').concat(R,'" node in the graph.'));return Un(!1,this.multi,d==="mixed"?this.type:d,g,Z,Y)}if(arguments.length===3){R=""+R,q=""+q;var ae=this._nodes.get(R);if(!ae)throw new l("Graph.".concat(v,': could not find the "').concat(R,'" source node in the graph.'));if(!this._nodes.has(q))throw new l("Graph.".concat(v,': could not find the "').concat(q,'" target node in the graph.'));return jn(!1,d,this.multi,g,ae,q,Y)}throw new L("Graph.".concat(v,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var $="map"+s[0].toUpperCase()+s.slice(1);c.prototype[$]=function(){var R,q=Array.prototype.slice.call(arguments),Y=q.pop();if(q.length===0){var Z=0;d!=="directed"&&(Z+=this.undirectedSize),d!=="undirected"&&(Z+=this.directedSize),R=new Array(Z);var ae=0;q.push(function(fe,Ge,$e,Ne,Ke,Te,Xe){R[ae++]=Y(fe,Ge,$e,Ne,Ke,Te,Xe)})}else R=[],q.push(function(fe,Ge,$e,Ne,Ke,Te,Xe){R.push(Y(fe,Ge,$e,Ne,Ke,Te,Xe))});return this[v].apply(this,q),R};var N="filter"+s[0].toUpperCase()+s.slice(1);c.prototype[N]=function(){var R=Array.prototype.slice.call(arguments),q=R.pop(),Y=[];return R.push(function(Z,ae,fe,Ge,$e,Ne,Ke){q(Z,ae,fe,Ge,$e,Ne,Ke)&&Y.push(Z)}),this[v].apply(this,R),Y};var j="reduce"+s[0].toUpperCase()+s.slice(1);c.prototype[j]=function(){var R,q,Y=Array.prototype.slice.call(arguments);if(Y.length<2||Y.length>4)throw new L("Graph.".concat(j,": invalid number of arguments (expecting 2, 3 or 4 and got ").concat(Y.length,")."));if(typeof Y[Y.length-1]=="function"&&typeof Y[Y.length-2]!="function")throw new L("Graph.".concat(j,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));Y.length===2?(R=Y[0],q=Y[1],Y=[]):Y.length===3?(R=Y[1],q=Y[2],Y=[Y[0]]):Y.length===4&&(R=Y[2],q=Y[3],Y=[Y[0],Y[1]]);var Z=q;return Y.push(function(ae,fe,Ge,$e,Ne,Ke,Te){Z=R(Z,ae,fe,Ge,$e,Ne,Ke,Te)}),this[v].apply(this,Y),Z}}(u,h),function(c,o){var s=o.name,d=o.type,g=o.direction,v="find"+s[0].toUpperCase()+s.slice(1,-1);c.prototype[v]=function(j,R,q){if(d!=="mixed"&&this.type!=="mixed"&&d!==this.type)return!1;if(arguments.length===1)return Fr(!0,this,d,q=j);if(arguments.length===2){j=""+j,q=R;var Y=this._nodes.get(j);if(Y===void 0)throw new l("Graph.".concat(v,': could not find the "').concat(j,'" node in the graph.'));return Un(!0,this.multi,d==="mixed"?this.type:d,g,Y,q)}if(arguments.length===3){j=""+j,R=""+R;var Z=this._nodes.get(j);if(!Z)throw new l("Graph.".concat(v,': could not find the "').concat(j,'" source node in the graph.'));if(!this._nodes.has(R))throw new l("Graph.".concat(v,': could not find the "').concat(R,'" target node in the graph.'));return jn(!0,d,this.multi,g,Z,R,q)}throw new L("Graph.".concat(v,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var $="some"+s[0].toUpperCase()+s.slice(1,-1);c.prototype[$]=function(){var j=Array.prototype.slice.call(arguments),R=j.pop();return j.push(function(q,Y,Z,ae,fe,Ge,$e){return R(q,Y,Z,ae,fe,Ge,$e)}),!!this[v].apply(this,j)};var N="every"+s[0].toUpperCase()+s.slice(1,-1);c.prototype[N]=function(){var j=Array.prototype.slice.call(arguments),R=j.pop();return j.push(function(q,Y,Z,ae,fe,Ge,$e){return!R(q,Y,Z,ae,fe,Ge,$e)}),!this[v].apply(this,j)}}(u,h),function(c,o){var s=o.name,d=o.type,g=o.direction,v=s.slice(0,-1)+"Entries";c.prototype[v]=function($,N){if(d!=="mixed"&&this.type!=="mixed"&&d!==this.type)return se.empty();if(!arguments.length)return To(this,d);if(arguments.length===1){$=""+$;var j=this._nodes.get($);if(!j)throw new l("Graph.".concat(v,': could not find the "').concat($,'" node in the graph.'));return Wo(d,g,j)}if(arguments.length===2){$=""+$,N=""+N;var R=this._nodes.get($);if(!R)throw new l("Graph.".concat(v,': could not find the "').concat($,'" source node in the graph.'));if(!this._nodes.has(N))throw new l("Graph.".concat(v,': could not find the "').concat(N,'" target node in the graph.'));return Po(d,g,R,N)}throw new L("Graph.".concat(v,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(u,h)})}(he),function(u){qo.forEach(function(h){Ko(u,h),function(c,o){var s=o.name,d=o.type,g=o.direction,v="forEach"+s[0].toUpperCase()+s.slice(1,-1);c.prototype[v]=function(R,q){if(d==="mixed"||this.type==="mixed"||d===this.type){R=""+R;var Y=this._nodes.get(R);if(Y===void 0)throw new l("Graph.".concat(v,': could not find the "').concat(R,'" node in the graph.'));Nn(!1,d==="mixed"?this.type:d,g,Y,q)}};var $="map"+s[0].toUpperCase()+s.slice(1);c.prototype[$]=function(R,q){var Y=[];return this[v](R,function(Z,ae){Y.push(q(Z,ae))}),Y};var N="filter"+s[0].toUpperCase()+s.slice(1);c.prototype[N]=function(R,q){var Y=[];return this[v](R,function(Z,ae){q(Z,ae)&&Y.push(Z)}),Y};var j="reduce"+s[0].toUpperCase()+s.slice(1);c.prototype[j]=function(R,q,Y){if(arguments.length<3)throw new L("Graph.".concat(j,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));var Z=Y;return this[v](R,function(ae,fe){Z=q(Z,ae,fe)}),Z}}(u,h),function(c,o){var s=o.name,d=o.type,g=o.direction,v=s[0].toUpperCase()+s.slice(1,-1),$="find"+v;c.prototype[$]=function(R,q){if(d==="mixed"||this.type==="mixed"||d===this.type){R=""+R;var Y=this._nodes.get(R);if(Y===void 0)throw new l("Graph.".concat($,': could not find the "').concat(R,'" node in the graph.'));return Nn(!0,d==="mixed"?this.type:d,g,Y,q)}};var N="some"+v;c.prototype[N]=function(R,q){return!!this[$](R,q)};var j="every"+v;c.prototype[j]=function(R,q){return!this[$](R,function(Y,Z){return!q(Y,Z)})}}(u,h),Yo(u,h)})}(he);var Vr=function(u){function h(c){var o=S({type:"directed"},c);if("multi"in o&&o.multi!==!1)throw new L("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(o.type!=="directed")throw new L('DirectedGraph.from: inconsistent "'+o.type+'" type in given options!');return u.call(this,o)||this}return r(h,u),h}(he),Xr=function(u){function h(c){var o=S({type:"undirected"},c);if("multi"in o&&o.multi!==!1)throw new L("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(o.type!=="undirected")throw new L('UndirectedGraph.from: inconsistent "'+o.type+'" type in given options!');return u.call(this,o)||this}return r(h,u),h}(he),Hr=function(u){function h(c){var o=S({multi:!0},c);if("multi"in o&&o.multi!==!0)throw new L("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return u.call(this,o)||this}return r(h,u),h}(he),Jr=function(u){function h(c){var o=S({type:"directed",multi:!0},c);if("multi"in o&&o.multi!==!0)throw new L("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(o.type!=="directed")throw new L('MultiDirectedGraph.from: inconsistent "'+o.type+'" type in given options!');return u.call(this,o)||this}return r(h,u),h}(he),Qr=function(u){function h(c){var o=S({type:"undirected",multi:!0},c);if("multi"in o&&o.multi!==!0)throw new L("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(o.type!=="undirected")throw new L('MultiUndirectedGraph.from: inconsistent "'+o.type+'" type in given options!');return u.call(this,o)||this}return r(h,u),h}(he);function Ct(u){u.from=function(h,c){var o=S({},h.options,c),s=new u(o);return s.import(h),s}}return Ct(he),Ct(Vr),Ct(Xr),Ct(Hr),Ct(Jr),Ct(Qr),he.Graph=he,he.DirectedGraph=Vr,he.UndirectedGraph=Xr,he.MultiGraph=Hr,he.MultiDirectedGraph=Jr,he.MultiUndirectedGraph=Qr,he.InvalidArgumentsGraphError=L,he.NotFoundGraphError=l,he.UsageGraphError=y,he})}(_r)),_r.exports}var ka=_a();const Ki=wt(ka);var Ut={},Yi,Vi;function Xi(){return Vi||(Vi=1,Yi=function(n){return n!==null&&typeof n=="object"&&typeof n.addUndirectedEdgeWithKey=="function"&&typeof n.dropNode=="function"&&typeof n.multi=="boolean"}),Yi}var jt={},Hi={},Ji;function Sa(){return Ji||(Ji=1,function(n){var e=Math.pow(2,8)-1,t=Math.pow(2,16)-1,r=Math.pow(2,32)-1,i=Math.pow(2,7)-1,a=Math.pow(2,15)-1,f=Math.pow(2,31)-1;n.getPointerArray=function(m){var b=m-1;if(b<=e)return Uint8Array;if(b<=t)return Uint16Array;if(b<=r)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},n.getSignedPointerArray=function(m){var b=m-1;return b<=i?Int8Array:b<=a?Int16Array:b<=f?Int32Array:Float64Array},n.getNumberType=function(m){return m===(m|0)?Math.sign(m)===-1?m<=127&&m>=-128?Int8Array:m<=32767&&m>=-32768?Int16Array:Int32Array:m<=255?Uint8Array:m<=65535?Uint16Array:Uint32Array:Float64Array};var p={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};n.getMinimalRepresentation=function(m,b){var S=null,C=0,G,D,A,U,I;for(U=0,I=m.length;U<I;U++)A=b?b(m[U]):m[U],D=n.getNumberType(A),G=p[D.name],G>C&&(C=G,S=D);return S},n.isTypedArray=function(m){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(m)},n.concat=function(){var m=0,b,S,C;for(b=0,C=arguments.length;b<C;b++)m+=arguments[b].length;var G=new arguments[0].constructor(m);for(b=0,S=0;b<C;b++)G.set(arguments[b],S),S+=arguments[b].length;return G},n.indices=function(m){for(var b=n.getPointerArray(m),S=new b(m),C=0;C<m;C++)S[C]=C;return S}}(Hi)),Hi}var Qi;function Aa(){if(Qi)return jt;Qi=1;var n=Xn(),e=Sa();function t(f){return Array.isArray(f)||e.isTypedArray(f)}function r(f){if(typeof f.length=="number")return f.length;if(typeof f.size=="number")return f.size}function i(f){var p=r(f),m=typeof p=="number"?new Array(p):[],b=0;return n(f,function(S){m[b++]=S}),m}function a(f){var p=r(f),m=typeof p=="number"?e.getPointerArray(p):Array,b=typeof p=="number"?new Array(p):[],S=typeof p=="number"?new m(p):[],C=0;return n(f,function(G){b[C]=G,S[C]=C++}),[b,S]}return jt.isArrayLike=t,jt.guessLength=r,jt.toArray=i,jt.toArrayWithIndices=a,jt}var kr,Zi;function Ia(){if(Zi)return kr;Zi=1;var n=Aa(),e=Kn();function t(r,i){if(arguments.length<2)throw new Error("mnemonist/fixed-deque: expecting an Array class and a capacity.");if(typeof i!="number"||i<=0)throw new Error("mnemonist/fixed-deque: `capacity` should be a positive number.");this.ArrayClass=r,this.capacity=i,this.items=new r(this.capacity),this.clear()}return t.prototype.clear=function(){this.start=0,this.size=0},t.prototype.push=function(r){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.push: deque capacity ("+this.capacity+") exceeded!");var i=this.start+this.size;return i>=this.capacity&&(i-=this.capacity),this.items[i]=r,++this.size},t.prototype.unshift=function(r){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.unshift: deque capacity ("+this.capacity+") exceeded!");var i=this.start-1;return this.start===0&&(i=this.capacity-1),this.items[i]=r,this.start=i,++this.size},t.prototype.pop=function(){if(this.size!==0){this.size--;var r=this.start+this.size;return r>=this.capacity&&(r-=this.capacity),this.items[r]}},t.prototype.shift=function(){if(this.size!==0){var r=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[r]}},t.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]},t.prototype.peekLast=function(){if(this.size!==0){var r=this.start+this.size-1;return r>=this.capacity&&(r-=this.capacity),this.items[r]}},t.prototype.get=function(r){if(!(this.size===0||r>=this.capacity))return r=this.start+r,r>=this.capacity&&(r-=this.capacity),this.items[r]},t.prototype.forEach=function(r,i){i=arguments.length>1?i:this;for(var a=this.capacity,f=this.size,p=this.start,m=0;m<f;)r.call(i,this.items[p],m,this),p++,m++,p===a&&(p=0)},t.prototype.toArray=function(){var r=this.start+this.size;if(r<this.capacity)return this.items.slice(this.start,r);for(var i=new this.ArrayClass(this.size),a=this.capacity,f=this.size,p=this.start,m=0;m<f;)i[m]=this.items[p],p++,m++,p===a&&(p=0);return i},t.prototype.values=function(){var r=this.items,i=this.capacity,a=this.size,f=this.start,p=0;return new e(function(){if(p>=a)return{done:!0};var m=r[f];return f++,p++,f===i&&(f=0),{value:m,done:!1}})},t.prototype.entries=function(){var r=this.items,i=this.capacity,a=this.size,f=this.start,p=0;return new e(function(){if(p>=a)return{done:!0};var m=r[f];return f++,f===i&&(f=0),{value:[p++,m],done:!1}})},typeof Symbol<"u"&&(t.prototype[Symbol.iterator]=t.prototype.values),t.prototype.inspect=function(){var r=this.toArray();return r.type=this.ArrayClass.name,r.capacity=this.capacity,Object.defineProperty(r,"constructor",{value:t,enumerable:!1}),r},typeof Symbol<"u"&&(t.prototype[Symbol.for("nodejs.util.inspect.custom")]=t.prototype.inspect),t.from=function(r,i,a){if(arguments.length<3&&(a=n.guessLength(r),typeof a!="number"))throw new Error("mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.");var f=new t(i,a);if(n.isArrayLike(r)){var p,m;for(p=0,m=r.length;p<m;p++)f.items[p]=r[p];return f.size=m,f}return n.forEach(r,function(b){f.push(b)}),f},kr=t,kr}var eo;function $a(){if(eo)return Ut;eo=1;const n=Xi(),e=Ia();function t(p,m){let b=0;return p.forEachInNeighbor(m,()=>{b++}),b}function r(p,m){if(!n(p))throw new Error("graphology-dag/topological-sort: the given graph is not a valid graphology instance.");if(p.type==="undirected"||p.undirectedSize!==0)throw new Error("graphology-dag/topological-sort: cannot work if graph is not directed.");if(p.order===0)return;const b=new e(Array,p.order),S={};let C=0;p.forEachNode((A,U)=>{const I=p.multi?t(p,A):p.inDegree(A);I===0?b.push([A,U,0]):(S[A]=I,C+=I)});let G=0;function D(A,U){const I=--S[A];C--,I===0&&b.push([A,U,G+1]),S[A]=I}for(;b.size!==0;){const[A,U,I]=b.shift();G=I,m(A,U,I),p.forEachOutNeighbor(A,D)}if(C!==0)throw new Error("graphology-dag/topological-sort: given graph is not acyclic.")}function i(p){if(!n(p))throw new Error("graphology-dag/topological-sort: the given graph is not a valid graphology instance.");const m=new Array(p.order);let b=0;return r(p,S=>{m[b++]=S}),m}function a(p,m){if(!n(p))throw new Error("graphology-dag/topological-generations: the given graph is not a valid graphology instance.");if(p.order===0)return;let b=0,S=[];r(p,(C,G,D)=>{D>b&&(m(S),b=D,S=[]),S.push(C)}),m(S)}function f(p){if(!n(p))throw new Error("graphology-dag/topological-generations: the given graph is not a valid graphology instance.");const m=[];return a(p,b=>{m.push(b)}),m}return Ut.topologicalSort=i,Ut.forEachNodeInTopologicalOrder=r,Ut.topologicalGenerations=f,Ut.forEachTopologicalGeneration=a,Ut}var to=$a(),Sr,no;function Ga(){if(no)return Sr;no=1;const n=Xi();return Sr=function(e,t,r){if(!n(e))throw new Error("graphology-dag/will-create-cycle: the given graph is not a valid graphology instance.");if(t=""+t,r=""+r,t===r)return!0;if(!e.hasNode(t)||!e.hasNode(r)||e.hasDirectedEdge(t,r))return!1;if(e.hasDirectedEdge(r,t))return!0;const i=e.outNeighbors(r);function a(f){i.push(f)}for(;i.length!==0;){const f=i.pop();if(f===t)return!0;e.forEachOutNeighbor(f,a)}return!1},Sr}var Oa=Ga();const Nt=wt(Oa);function ro(n){const e=[],t=[...n];let r;for(;r=t.shift();){let i=r.parent;if(i){const a=[];for(;i;){const f=t.findIndex(m=>m.id===i);if(f<0)break;const[p]=t.splice(f,1);if(!p)throw new Error("Invalid state, should not happen");a.unshift(p),i=p.parent}e.push(...a)}e.push(r)}return e}function Ca(n){return n.forEach(e=>{e.children.length>0&&(e.children=n.reduce((t,r)=>(r.parent===e.id&&t.push(r.id),t),[]))}),n}function io(n){let e=ro([...n.nodes.values()]),t=[...n.edges];if(e.length<2||t.length===0)return{nodes:e,edges:t};const r=D=>ve(n.nodes.get(D)),i=new Ki({multi:!0,allowSelfLoops:!0,type:"directed"}),a=J(t,be((D,A)=>{const U=r(D.source),I=r(D.target),W=D.parent?r(D.parent):null;return{id:D.id,edge:D,parent:W,source:U,target:I}})),[f,p]=Gn(a,({source:D,target:A})=>D.children.length===0&&A.children.length===0),m=[],b=D=>{i.mergeNode(D.source),i.mergeNode(D.target),m.push(D),Nt(i,D.source,D.target)||i.mergeDirectedEdge(D.source,D.target)};for(const{edge:D,source:A,target:U}of f)if(b(D),U.parent&&U.parent!==D.parent&&J(Er(U,n.nodes),ti(I=>I.inEdges.includes(D.id)),We(I=>{i.mergeNode(I.id),Nt(i,D.source,I.id)||i.mergeDirectedEdge(D.source,I.id),Nt(i,I.id,D.target)||i.mergeDirectedEdge(I.id,D.target)})),A.parent){const I=r(A.parent);i.mergeNode(I.id),Nt(i,I.id,A.id)||i.mergeDirectedEdge(I.id,A.id),U.parent&&U.parent!==A.parent&&(Nt(i,I.id,U.parent)||i.mergeDirectedEdge(I.id,U.parent))}for(const{edge:D}of p)b(D);re(m.length===t.length,"Not all edges were added to the graph");const S=to.topologicalSort(i);let C=[],G=e.slice();for(const D of S){const A=G.findIndex(U=>U.id===D);re(A>=0,`Node "${D}" not found`),C.push(...G.splice(A,1))}return G.length>0&&C.length>0&&(C=C.flatMap(D=>{if(G.length===0)return D;const A=e.slice(0,e.indexOf(D)).filter(U=>G.includes(U));return A.length>0?(G=G.filter(U=>!A.includes(U)),[...A,D]):D})),C.push(...G),{nodes:Ca(ro(C)),edges:m}}function Ar(n){const e={id:n.id,__:n.__??"element",autoLayout:n.autoLayout,nodes:J(n.nodes,be(mr(["id","title","description","technology","shape","icon","children"])),Wi(({id:t,icon:r,...i})=>[t,{...i,icon:_e(r)?"Y":"N"}])),edges:J(n.edges,be(mr(["source","target","label","description","technology","dir","head","tail","line"])),Wi(({source:t,target:r,...i})=>[`${t}:${r}`,i]))};return n.hash=As(e,{ignoreUnknown:!0,respectType:!1}),n}class oo{constructor(e){this.state=e}get Ctx(){throw new Error("Should not be called in runtime")}get elements(){return this.state.elements}get explicits(){return this.state.explicits}get final(){return this.state.final}get connections(){return this.state.connections}isEmpty(){return this.elements.size===0&&this.connections.length===0&&this.explicits.size===0&&this.final.size===0}}var Re;(n=>{n.isInside=e=>t=>ye(e,t.source.id)&&ye(e,t.target.id),n.isDirectedBetween=(e,t)=>r=>(r.source.id===e||ye(e,r.source.id))&&(r.target.id===t||ye(t,r.target.id)),n.isAnyBetween=(e,t)=>{const r=(0,n.isDirectedBetween)(e,t),i=(0,n.isDirectedBetween)(t,e);return a=>r(a)||i(a)},n.isIncoming=e=>t=>(t.target.id===e||ye(e,t.target.id))&&!ye(e,t.source.id),n.isOutgoing=e=>t=>(t.source.id===e||ye(e,t.source.id))&&!ye(e,t.target.id),n.isAnyInOut=e=>{const t=(0,n.isIncoming)(e),r=(0,n.isOutgoing)(e);return i=>t(i)||r(i)}})(Re||(Re={}));const Ir=Symbol.for("nodejs.util.inspect.custom");class so{get style(){return{shape:kn,color:Zt,...this.$node.style}}get shape(){return this.$node.style?.shape??kn}get color(){return this.$node.style?.color??Zt}get tags(){return this.$node.tags??[]}get description(){return this.$node.description??null}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){const t=lt(this.id,e.id);return t?this.$model.node(t):null}siblings(){return this.$model.siblings(this)}isSibling(e){return this.parent===e.parent}*ascendingSiblings(){yield*this.siblings();for(const e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(const e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e="all"){return this.$model.incoming(this,e)}outgoing(e="all"){return this.$model.outgoing(this,e)}*incomers(e="all"){const t=new Set;for(const r of this.incoming(e))t.has(r.source.id)||(t.add(r.source.id),yield r.source)}*outgoers(e="all"){const t=new Set;for(const r of this.outgoing(e))t.has(r.target.id)||(t.add(r.target.id),yield r.target)}*views(){for(const e of this.$model.views())e.isDeploymentView()&&e.includesDeployment(this.id)&&(yield e)}isDeploymentNode(){return!1}isInstance(){return!1}cachedOutgoing=null;cachedIncoming=null;get allOutgoing(){return this.cachedOutgoing??=st.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())),this.cachedOutgoing}get allIncoming(){return this.cachedIncoming??=st.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())),this.cachedIncoming}}class $r extends so{constructor(e,t){super(),this.$model=e,this.$node=t,this.id=t.id,this.title=t.title,this.hierarchyLevel=Dt(t.id)}id;title;hierarchyLevel;get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}children(){return this.$model.children(this)}descendants(e="desc"){return this.$model.descendants(this,e)}isDeploymentNode(){return!0}*instances(){for(const e of this.descendants("desc"))e.isInstance()&&(yield e)}onlyOneInstance(){const e=this.children();if(e.size!==1)return null;const t=Ee([...e]);return t?.isInstance()?t:null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;const{outgoing:e,incoming:t}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(const r of this.instances()){for(const i of r.element.outgoing())e.add(i);for(const i of r.element.incoming())t.add(i)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){const{outgoing:e,incoming:t}=this.relationshipsFromInstances();return Ce(t,e)}}class Gr extends so{constructor(e,t,r){super(),this.$model=e,this.$instance=t,this.element=r,this.id=t.id,this.title=t.title??r.title,this.hierarchyLevel=Dt(t.id)}id;title;hierarchyLevel;get $node(){return this.$instance}get parent(){return ve(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){const{icon:e,style:t}=this.element.$element;return{shape:this.element.shape,color:this.element.color,...e&&{icon:e},...t,...this.$instance.style}}get shape(){return this.$instance.style?.shape??this.element.shape}get color(){return this.$instance.style?.color??this.element.color}get tags(){return this.$instance.tags??[]}get description(){return this.$instance.description??this.element.description}get technology(){return this.$instance.technology??this.element.technology}get links(){return this.$instance.links??this.element.links}isInstance(){return!0}outgoingModelRelationships(){return this.element.outgoing()}incomingModelRelationships(){return this.element.incoming()}*views(){for(const e of this.$model.views())if(e.isDeploymentView()){if(e.includesDeployment(this.id)){yield e;continue}e.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield e)}}}class La{constructor(e,t){this.instance=e,this.element=t}get id(){return this.instance.id}get style(){const{icon:e,style:t}=this.element.$element;return{shape:this.element.shape,color:this.element.color,...e&&{icon:e},...t}}get shape(){return this.element.shape}get color(){return this.element.color}get title(){return this.element.title}get description(){return this.element.description}get technology(){return this.element.technology}isDeploymentNode(){return!1}isInstance(){return!1}}class ao{constructor(e,t){this.$model=e,this.$relationship=t,this.source=e.deploymentRef(t.source),this.target=e.deploymentRef(t.target);const r=lt(this.source.id,this.target.id);this.boundary=r?this.$model.node(r):null}boundary;source;target;get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return gt(this.$relationship.title)?null:this.$relationship.title}get technology(){return gt(this.$relationship.technology)?null:this.$relationship.technology}get description(){return gt(this.$relationship.description)?null:this.$relationship.description}get tags(){return this.$relationship.tags??[]}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}*views(){for(const e of this.$model.views())e.includesRelation(this.id)&&(yield e)}}class st{constructor(e=new Set,t=new Set){this.model=e,this.deployment=t}static empty(){return new st}static from(e,t){return new st(new Set(e),new Set(t))}get isEmpty(){return this.model.size===0&&this.deployment.size===0}get nonEmpty(){return this.model.size>0||this.deployment.size>0}get size(){return this.model.size+this.deployment.size}intersect(e){return st.from(Ce(this.model,e.model),Ce(this.deployment,e.deployment))}difference(e){return st.from(pe(this.model,e.model),pe(this.deployment,e.deployment))}union(e){return st.from(xe(this.model,e.model),xe(this.deployment,e.deployment))}}class ot{constructor(e,t,r){this.source=e,this.target=t,this.relations=r,this.id=tr(`deployment:${e.id}:${t.id}`)}id;get expression(){return`${this.source.id} -> ${this.target.id}`}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target),this._boundary}nonEmpty(){return this.relations.nonEmpty}[Ir](e,t,r){const i=this.toString();return Object.defineProperty(i,"constructor",{value:ot,enumerable:!1}),i}toString(){const e=[...this.relations.model].map(r=>" "+r.expression);e.length?e.unshift(" model:"):e.unshift(" model: []");const t=[...this.relations.deployment].map(r=>" "+r.expression);return t.length?t.unshift(" deployment:"):t.unshift(" deployment: []"),[this.expression,...e,...t].join(`
7
- `)}hasDirectDeploymentRelation(){for(const e of this.relations.deployment)if(e.source.id===this.source.id||e.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(e){return re(this.source.id===e.source.id,"Cannot merge connections with different sources"),re(this.target.id===e.target.id,"Cannot merge connections with different targets"),new ot(this.source,this.target,this.relations.union(e.relations))}difference(e){return new ot(this.source,this.target,this.relations.difference(e.relations))}intersect(e){return new ot(this.source,this.target,this.relations.intersect(e.relations))}equals(e){return re(e instanceof ot,"Other should ne DeploymentConnectionModel"),this.id===e.id&&this.source.id===e.source.id&&this.target.id===e.target.id&&er(this.relations.model,e.relations.model)&&er(this.relations.deployment,e.relations.deployment)}update(e){return e&&(e={model:this.relations.model,deployment:this.relations.deployment,...e}),new ot(this.source,this.target,e?new st(e.model??new Set,e.deployment??new Set):this.relations)}}function Tt(n,e){if(!e){const f=n;return p=>Tt(p,f)}const t=n.source===e.source,r=n.target===e.target;if(t&&r)return!1;const i=ye(e.source.id,n.source.id),a=ye(e.target.id,n.target.id);return i&&a||t&&a||r&&i}function Or(n,e){let t=e;for(const r of n)Tt(r,t)&&(t=r);return t!==e?t:null}function Da(n){const e=[],t=n.slice();let r;for(;r=t.shift();){let i;for(;i=Or(t,r);){const a=t.indexOf(i);e.push(t.splice(a,1)[0])}e.push(r)}return e}const za=n=>n.boundary?.id?`.${n.boundary.id}`:"";function uo(n,e){if(!n||ct(n)){const t=n??"asc";return r=>co(r,t)}return co(n,e??"asc")}function co(n,e){return J(n,be(t=>({id:za(t),conn:t})),xn(e),be(Je("conn")))}function lo(n,e){return n.filter(t=>Tt(e,t))}function ho(n,e){return n.filter(Tt(e))}function Bt(n){const e=new Map;for(const t of n){const r=e.get(t.id);r?e.set(t.id,t.mergeWith(r)):e.set(t.id,t)}return[...e.values()]}function Wt(n,e){const t=new Map([...e].map(r=>[r.id,r]));return[...n].reduce((r,i)=>{const a=t.get(i.id);if(!a)return r.push(i),r;const f=i.difference(a);return f.nonEmpty()&&r.push(f),r},[])}function Cr(n,e){return e?n.source===e.source&&n.target===e.target:t=>n.source===t.source&&n.target===t.target}function Ma(n,e){return e?n.source===e.source:t=>n.source===t.source}function Ra(n,e){return e?n.target===e.target:t=>n.target===t.target}function Lr(n,e){if(!e){const r=n;return i=>Lr(i,r)}const t=n;return dt(t.source,e)&&!dt(t.target,e)}function Dr(n,e){if(!e){const r=n;return i=>Dr(i,r)}const t=n;return dt(t.target,e)&&!dt(t.source,e)}function Dn(n,e){if(!e){const r=n;return i=>Dn(i,r)}const t=n;return dt(t.source,e)!==dt(t.target,e)}function Ft(n,e,t="directed"){if(n===e)return[];if(Lt(n,e))return[];const r=Ce(n.allOutgoing,e.allIncoming),i=r.size>0?new Ie(n,e,r):null;if(t==="directed")return i?[i]:[];const a=Ce(n.allIncoming,e.allOutgoing),f=a.size>0?new Ie(e,n,a):null;return i&&f?[i,f]:i?[i]:f?[f]:[]}function De(n,e,t="both"){if(n.allIncoming.size===0&&n.allOutgoing.size===0)return[];const r=[],i=[];for(const a of e)if(n!==a)for(const f of Ft(n,a,t))f.source===n?r.push(f):i.push(f);return[...r,...i]}function mt(n){return[...n].reduce((e,t,r,i)=>(r===i.length-1||e.push(...De(t,i.slice(r+1),"both")),e),[])}const Ua={__proto__:null,findConnection:Ft,findConnectionsBetween:De,findConnectionsWithin:mt};class Ie{constructor(e,t,r=new Set){this.source=e,this.target=t,this.relations=r,this.id=tr(`model:${e.id}:${t.id}`)}id;_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target)}get expression(){return`${this.source.id} -> ${this.target.id}`}get isDirect(){return this.nonEmpty()&&!this.isImplicit}get isImplicit(){return this.nonEmpty()&&Qt(this.relations,nr(Cr(this)))}get directRelations(){return new Set(Me(this.relations,Cr(this)))}nonEmpty(){return this.relations.size>0}mergeWith(e){return re(this.source.id===e.source.id,"Cannot merge connections with different sources"),re(this.target.id===e.target.id,"Cannot merge connections with different targets"),new Ie(this.source,this.target,xe(this.relations,e.relations))}difference(e){return new Ie(this.source,this.target,pe(this.relations,e.relations))}intersect(e){return re(e instanceof Ie,"Cannot intersect connection with different type"),new Ie(this.source,this.target,Ce(this.relations,e.relations))}equals(e){return re(e instanceof Ie,"Cannot merge connection with different type"),this.id===e.id&&this.source.id===e.source.id&&this.target.id===e.target.id&&er(this.relations,e.relations)}update(e){return new Ie(this.source,this.target,e)}[Ir](e,t,r){const i=this.toString();return Object.defineProperty(i,"constructor",{value:Ie,enumerable:!1}),i}toString(){return[this.expression,this.relations.size?" relations:":" relations: [ ]",...[...this.relations].map(e=>" "+e.expression)].join(`
8
- `)}reversed(e=!1){if(!e)return new Ie(this.target,this.source);const[t]=Ft(this.target,this.source,"directed");return t??new Ie(this.target,this.source,new Set)}}function Et(n,e,t="directed"){if(n===e)return[];if(Lt(n,e))return[];const r=n.allOutgoing.intersect(e.allIncoming),i=r.nonEmpty?[new ot(n,e,r)]:[];return t==="directed"?i:[...i,...Et(e,n,"directed")]}function Fe(n,e,t="both"){if(n.allIncoming.isEmpty&&n.allOutgoing.isEmpty)return[];const r=[],i=[];for(const a of e)if(n!==a)for(const f of Et(n,a,t))f.source===n?r.push(f):i.push(f);return[...r,...i]}function Pt(n){return[...n].reduce((e,t,r,i)=>(r===i.length-1||e.push(...Fe(t,i.slice(r+1),"both")),e),[])}const ja={__proto__:null,findConnection:Et,findConnectionsBetween:Fe,findConnectionsWithin:Pt};class fo{constructor(e,t){this.memory=e,this.expression=t}excluded={elements:new Set,connections:[]};markedToMoveExplicitToImplicit=!1;_removeElement(e){this.excluded.elements.add(e)}exclude(e){if(!e)return this;if(vt(e)){for(const t of e)this._removeElement(t);return this}return this._removeElement(e),this}_removeConnection(e){this.excluded.connections.push(e)}excludeConnections(e,t){if(aa(t)&&(re(!this.markedToMoveExplicitToImplicit,"Already marked to move explicits"),this.markedToMoveExplicitToImplicit=t),vt(e)){for(const r of e)this._removeConnection(r);return this}return this._removeConnection(e),this}isDirty(){return this.excluded.elements.size>0||this.excluded.connections.length>0}isEmpty(){return!this.isDirty()}filterForMoveToImplicits(e){return this.markedToMoveExplicitToImplicit||this.excluded.elements.size>0?e:new Set}moveDisconnectedExplicitsToImplicits(e){let t=pe(new Set(this.memory.connections.flatMap(r=>[r.source,r.target])),new Set(e.connections.flatMap(r=>[r.source,r.target])));return t=Ce(t,e.elements),t=J(t,Me(r=>e.explicits.has(r)&&!Qt(e.final,dt(r))),et()),t.size>0&&(t=this.filterForMoveToImplicits(t),e.explicits=pe(e.explicits,t),e.final=pe(e.final,t)),e}removeElements(e){return e.elements=pe(e.elements,this.excluded.elements),e.explicits=pe(e.explicits,this.excluded.elements),e.final=pe(e.final,this.excluded.elements),e}removeConnections(e){const t=this.excluded.connections.reduce((i,a)=>{const f=i.get(a.id);return f?i.set(a.id,f.mergeWith(a)):i.set(a.id,a),i},new Map);let r=new Set;e.connections=e.connections.reduce((i,a)=>{const f=t.get(a.id);if(f){r.add(a.source),r.add(a.target);const p=a.difference(f);p.nonEmpty()&&i.push(p)}else i.push(a);return i},[]);for(const i of e.connections)r.delete(i.source),r.delete(i.target),i.boundary&&e.elements.has(i.boundary)&&r.delete(i.boundary);return r.size===0||(r=pe(r,e.explicits),e.final=pe(e.final,r)),e}precommit(e){return e}postcommit(e){return re(pe(e.explicits,e.elements).size===0,"Explicits must be subset of elements"),re(pe(e.final,e.elements).size===0,"Final elements must be subset of elements"),e}commit(){let e=this.precommit(this.memory.mutableState());if(this.excluded.elements.size>0){const t=e.connections.filter(r=>this.excluded.elements.has(r.source)||this.excluded.elements.has(r.target)).flatMap(r=>[r,...lo(e.connections,r).map(i=>i.intersect(r))]).filter(r=>r.nonEmpty());this.excludeConnections(t)}return this.excluded.connections.length>0&&(e=this.removeConnections(e)),this.excluded.elements.size>0&&(e=this.removeElements(e)),e=this.moveDisconnectedExplicitsToImplicits(e),this.memory.update(this.postcommit(e))}}class po{constructor(e,t){this.memory=e,this.expression=t}explicits=new Set;implicits=new Set;_ordered=new Set;_connections=[];get elements(){return this.explicits}get connections(){return this._connections}mergedConnections(){return Bt([...this.memory.connections,...this._connections])}connectWithExisting(e,t){throw new Error("Method not implements, depends on the model")}_addExplicit(e){this._ordered.add(e),this.explicits.add(e),this.implicits.delete(e)}addExplicit(e){if(!e)return this;if(vt(e)){for(const t of e)this._addExplicit(t);return this}return this._addExplicit(e),this}_addImplicit(e){this.explicits.has(e)||(this._ordered.add(e),this.implicits.add(e))}addImplicit(e){if(!e)return this;if(vt(e)){for(const t of e)this._addImplicit(t);return this}return this._addImplicit(e),this}_addConnection(e){this._connections.push(e),this._addImplicit(e.source),this._addImplicit(e.target)}addConnections(e){if(vt(e)){for(const t of e)this._addConnection(t);return this}return this._addConnection(e),this}isDirty(){return this.explicits.size>0||this.implicits.size>0||this._connections.length>0}isEmpty(){return!this.isDirty()}precommit(e){return e}postcommit(e){return e}processConnections(e){return e}commit(){let e=this.precommit(this.memory.mutableState()),t=new Set;if(this._connections.length>0){const[r,i]=Gn(this._connections,a=>e.final.has(a.source));e.connections=this.processConnections(Bt([...e.connections,...r,...i])),t=new Set(e.connections.flatMap(a=>[a.source,a.target]))}return e.elements=xe(e.elements,this._ordered,this.explicits,t,this.implicits),e.explicits=Ce(e.elements,xe(e.explicits,this.explicits)),e.final=Ce(e.elements,xe(e.final,this.explicits,t)),this.memory.update(this.postcommit(e))}}function go(n,e="final"){const t=bn(ce(e==="final"?n.final:n.elements)),r=new Set(n.connections.flatMap(p=>[p.source,p.target])),i=new Set(t),a=new Oe(()=>null),f=t.reduce((p,m,b,S)=>(p.set(m,S.slice(b+1).filter(C=>ye(m,C)).map(C=>(i.delete(C),C)).reduce((C,G)=>(C.some(D=>ye(D,G))||(C.push(G),a.set(G,m)),C),[])),p),new Oe(()=>[]));return{root:i,connected:r,hasInOut:p=>n.connections.some(Re.isAnyInOut(p.id)),parent:p=>a.get(p),children:p=>f.get(p)}}let Na=class extends fo{};Ue(n=>n.nonEmpty());function Ta(n){const e=new Oe(()=>[]);for(const r of n)for(const i of r.relations.model)e.get(i).push(r);const t=new Oe(()=>new Set);for(const[r,i]of e)Ze(i,2)&&J(i,Qe(a=>[{group:`$source-${a.source.id}`,conn:a},{group:`$target-${a.target.id}`,conn:a}]),Cn(Je("group")),xt(),Ue(Ze(2)),We(rn(be(Je("conn")),uo("desc"),wr((a,f,p)=>f===0||a.boundary===p[f-1].boundary),We(a=>{t.get(a).add(r)}))));return t}function Ba(n){n=Bt(n);const e=Ta(n);for(const t of n){const{source:r,target:i}=t,a=t.relations.model;if(r.isDeploymentNode()!==i.isDeploymentNode()){const f=r.isDeploymentNode()?r:t.target;re(f.isDeploymentNode());const p=f.internalModelRelationships(),m=Ce(a,p);for(const b of m)e.get(t).add(b);continue}if(r.isDeploymentNode()&&i.isDeploymentNode()){const f=xe(Ce(t.relations.model,r.internalModelRelationships()),Ce(t.relations.model,i.internalModelRelationships()));for(const p of f)e.get(t).add(p)}}return J(e.entries(),xs(([t,r])=>t.update({model:r,deployment:null})),ce())}function zr(n){return Wt(n,Ba(n))}function Wa(n){return J(n,Bt,nn((e,t)=>{const{source:r,target:i,relations:a}=t;if(r.isInstance()&&i.isInstance())return e;let f=st.empty();if(r.isDeploymentNode()&&i.isDeploymentNode()){const[p]=Et(i,r,"directed");p&&(f=a.intersect(p.relations))}for(const p of n)Tt(p,t)&&(f=f.union(a.intersect(p.relations)));return f.nonEmpty&&e.push(new ot(r,i,f)),e},[]))}function Mr(n){return Wt(n,Wa(n))}let Fa=class extends po{connectWithExisting(n,e="both"){const t=this._connections.length,r=()=>this._connections.length>t;if(!vt(n)){if(e==="in"||e==="both")for(const a of this.memory.elements)this.addConnections(Et(a,n,"directed"));return(e==="out"||e==="both")&&this.addConnections(Fe(n,this.memory.elements,"directed")),r()}const i=[...n];if(e==="in"||e==="both")for(const a of this.memory.elements)this.addConnections(Fe(a,i,"directed"));if(e==="out"||e==="both")for(const a of i)this.addConnections(Fe(a,this.memory.elements,"directed"));return r()}processConnections(n){const e=J(n,zr,Mr);return J(e,We(({source:t,target:r,boundary:i})=>{J(Tn([...ce(t.ancestors()).reverse(),t],[...ce(r.ancestors()).reverse(),r]),wr(([a,f])=>a===f),Ri(1),We(([a,f])=>{if(t===a&&r===f){this.addImplicit(i);return}a!==t&&a.isDeploymentNode()&&!a.onlyOneInstance()&&this.addImplicit(a),f!==r&&f.isDeploymentNode()&&!f.onlyOneInstance()&&this.addImplicit(f)}))})),e}},Pa=class Mn extends oo{static empty(){return new Mn({elements:new Set,explicits:new Set,final:new Set,connections:[]})}stageInclude(e){return new Fa(this,e)}stageExclude(e){return new Na(this,e)}mutableState(){return{elements:new Set(this.state.elements),explicits:new Set(this.state.explicits),final:new Set(this.state.final),connections:[...this.state.connections]}}update(e){return new Mn({...this.state,...e})}equals(e){return e instanceof Mn&&ua(this.state,e.state)}diff(e){const t=this;return{added:{elements:ce(pe(e.elements,t.elements)),explicits:ce(pe(e.explicits,t.explicits)),final:ce(pe(e.final,t.final)),connections:ce(Wt(e.connections,t.connections))},removed:{elements:ce(pe(t.elements,e.elements)),explicits:ce(pe(t.explicits,e.explicits)),final:ce(pe(t.final,e.final)),connections:Wt(t.connections,e.connections)}}}toString(){return["final:",...[...this.final].map(e=>" "+e.id),"connections:",...this.connections.map(e=>" "+e.expression)].join(`
9
- `)}[Ir](e,t,r){return this.toString()}};function Ve(n){if(An(n)){const e=Ve(n.where.expr),t=bt(n.where.condition);return r=>e(r)&&t(r)}if(Le(n))return()=>!0;if(Mt(n))return n.isEqual?e=>e.kind===n.elementKind:e=>e.kind!==n.elementKind;if(Rt(n))return n.isEqual?({tags:e})=>!!e&&e.includes(n.elementTag):({tags:e})=>tt(e)||!e.includes(n.elementTag);if(ft(n))return e=>e.id===n.expanded||at(e.id)===n.expanded;if(Ye(n)){const{element:e,isChildren:t,isDescendants:r}=n;return t||r?i=>i.id.startsWith(e+"."):i=>i.id===e}if(Sn(n))return Ve(n.custom.expr);Be(n)}function mo(n,e,t){J(t,Ue(nr(rt.isNodesGroup)),Ue(He(e)),We(r=>{r.shape=n.style.shape??r.shape,r.color=n.style.color??r.color,wn(n.style.icon)&&(r.icon=n.style.icon),wn(n.notation)&&(r.notation=n.notation);let i;wn(n.style.border)&&(i={border:n.style.border}),wn(n.style.opacity)&&(i={...i,opacity:n.style.opacity}),i&&(r.style={...r.style,...i})}))}function yo(n,e){for(const t of n){if(!Ai(t)||t.targets.length===0)continue;const r=t.targets.map(Ve);mo(t,r,e)}return e}function qa(n,e){let t;for(;n.parent&&(t=e.get(n.parent));){const r=t.depth??1;if(t.depth=Math.max(r,(n.depth??0)+1),t.depth===r)break;n=t}}const Ka=n=>({...n,modelRef:1});function Ya(n,e){return Rr(n.map(Ka),e)}function Rr(n,e){const t=new Map,r=new Map;e?.forEach(({id:a,parent:f,viewRule:p,elements:m})=>{f&&ve(t.get(f),`Parent group node ${f} not found`).children.push(a),t.set(a,{id:a,parent:f,kind:zt.Group,title:p.title??"",color:p.color??"muted",shape:"rectangle",children:[],inEdges:[],outEdges:[],level:0,depth:0,description:null,technology:null,tags:null,links:null,style:{border:p.border??"dashed",opacity:p.opacity??0}});for(const b of m)r.set(b.id,a)}),Array.from(n).sort(ci).forEach(({id:a,style:f,kind:p,title:m,color:b,shape:S,...C})=>{let G=at(a),D=0,A;for(;G&&(A=t.get(G),!A);)G=at(G);!A&&r.has(a)&&(G=r.get(a),A=t.get(G)),A&&(A.children.length==0&&(A.depth=1,qa(A,t)),A.children.push(a),D=A.level+1);const U={id:a,parent:G,kind:p,title:m,level:D,color:b??Zt,shape:S??kn,description:null,technology:null,tags:null,links:null,children:[],inEdges:[],outEdges:[],...C,style:{...f}};t.set(a,U)});const i=new Map;return e?.forEach(({id:a})=>{i.set(a,ve(t.get(a)))}),n.forEach(({id:a})=>{i.set(a,ve(t.get(a)))}),i}function Va(n){const{title:e,description:t=null,technology:r=null,kind:i=null,color:a=null,line:f=null,head:p=null,tail:m=null,navigateTo:b=null}=n;return{...e&&{title:e,description:t},technology:r,kind:i,color:a,line:f,head:p,tail:m,navigateTo:b}}function wo(n,e){const t=J(n,nn((p,m)=>(_e(m.title)&&!p.title.includes(m.title)&&p.title.push(m.title),_e(m.description)&&!p.description.includes(m.description)&&p.description.push(m.description),_e(m.technology)&&!p.technology.includes(m.technology)&&p.technology.push(m.technology),_e(m.kind)&&!p.kind.includes(m.kind)&&p.kind.push(m.kind),_e(m.color)&&!p.color.includes(m.color)&&p.color.push(m.color),_e(m.line)&&!p.line.includes(m.line)&&p.line.push(m.line),_e(m.head)&&!p.head.includes(m.head)&&p.head.push(m.head),_e(m.tail)&&!p.tail.includes(m.tail)&&p.tail.push(m.tail),_e(m.navigateTo)&&!p.navigateTo.includes(m.navigateTo)&&p.navigateTo.push(m.navigateTo),m.tags&&p.tags.push(...m.tags),m.links&&p.links.push(...m.links),p),{title:[],description:[],technology:[],kind:[],head:[],tail:[],color:[],tags:[],links:[],line:[],navigateTo:[]}));let r=Ee(t.technology),i=Ee(t.title)??(t.title.length>1?"[...]":null);const a=pt(t.tags);let f=Ti({title:i??(r?`[${r}]`:null),description:Ee(t.description),technology:r,kind:Ee(t.kind),head:Ee(t.head),tail:Ee(t.tail),color:Ee(t.color),line:Ee(t.line),navigateTo:Ee(t.navigateTo),...Jn(t.links)&&{links:t.links},...Jn(a)&&{tags:a}},_e);return e?{...f,...Ti(Va(e),_e)}:f}function Xa(n){const e=J(n,Qe(t=>t.tags??[]),pt(),gr(vn));return Ze(e,1)?e:null}function it(n,e){const t=n.element(e.ref.deployment);if(t.isDeploymentNode()){if(e.selector==="children")return[...t.children()];if(e.selector==="expanded")return[t,...t.children()];if(e.selector==="descendants")return[...t.descendants()]}return[t]}function sn(n,e){const t=n.$model.element(e.ref.model);return e.selector==="children"?[...t.children()]:e.selector==="expanded"?[t,...t.children()]:e.selector==="descendants"?[...t.descendants()]:[t]}function qt(n){if(ie.isWildcard(n))return()=>!0;if(ie.isDeploymentRef(n)){const e=n.ref.deployment;if(n.selector==="expanded"){const t=e+".";return r=>r.id===e||r.id.startsWith(t)}if(n.selector==="descendants"){const t=e+".";return r=>r.id.startsWith(t)}return n.selector==="children"?t=>at(t.id)===e:t=>t.id===e}if(ie.isModelRef(n)){const e=r=>yn(r.modelRef)?r.modelRef:sa(r.modelRef)?r.id:null,t=n.ref.model;if(n.selector==="expanded"){const r=t+".";return i=>{const a=e(i);return a?a===t||a.startsWith(r):!0}}if(n.selector==="descendants"){const r=t+".";return i=>{const a=e(i);return a?a.startsWith(r):!0}}return n.selector==="children"?r=>{const i=e(r);return i?at(i)===t:!0}:r=>{const i=e(r);return i?i===t:!0}}Be(n)}function vo(n){if(n.isDeploymentNode()){const b=n.onlyOneInstance();let{title:S,kind:C,id:G,...D}=n.$node;const{icon:A,color:U,shape:I,...W}=n.$node.style??{};return b&&S===ai(n.id)&&(S=b.title),{...b&&{...vo(b),modelRef:b.element.id},title:S,...D,...A&&{icon:A},...U&&{color:U},...I&&{shape:I},style:{...W},deploymentRef:1,kind:C,id:G}}re(n.isInstance(),"Expected Instance");const e=n.$instance,t=n.element.$element,r=e.style?.icon??t.icon,i=e.style?.color??t.color,a=e.style?.shape??t.shape,f=[...t.links??[],...e.links??[]],p={...t.metadata,...e.metadata},m=e.notation??t.notation;return{id:n.id,kind:"instance",title:e.title??t.title,description:e.description??t.description,technology:e.technology??t.technology,tags:Xa([t,e]),links:Ze(f,1)?f:null,...r&&{icon:r},...i&&{color:i},...a&&{shape:a},style:{...t.style,...e.style},deploymentRef:n.id===e.id?1:e.id,modelRef:n.id===t.id?1:t.id,...m&&{notation:m},...!gt(p)&&{metadata:p}}}function Ha(n){return n.reduce((e,t)=>{const r=[...t.relations.model,...t.relations.deployment];re(Ze(r,1),"Edge must have at least one relation");const i=t.source.id,a=t.target.id,{title:f,...p}=wo(r.map(S=>S.$relationship)),m={id:t.id,parent:t.boundary?.id??null,source:i,target:a,label:f??null,relations:r.map(S=>S.id),...p},b=e.find(S=>S.source===a&&S.target===i);if(b&&m.label===b.label){b.dir="both";const S=b.head??m.head??dr;return b.head??=S,b.tail??=S,m.color&&(b.color??=m.color),m.line&&(b.line??=m.line),e}return e.push(m),e},[])}function Ja(n){return Rr([...n.final].map(vo))}function Qa(n,e){for(const t of n){if(!Ai(t)||t.targets.length===0)continue;const r=t.targets.map(qt);mo(t,r,e)}return e}const Za={include:n=>{const{expr:e}=n,t=n.model.element(e.ref.deployment);if(Tu(t))return n.stage.addExplicit(t),n.stage.connectWithExisting(t),n.stage;switch(!0){case e.selector==="expanded":tu(t,n);break;case e.selector==="children":eu(t,n);break;case e.selector==="descendants":nu(t,n);break;default:n.stage.addExplicit(t),n.stage.connectWithExisting(t)}return n.stage},exclude:({expr:n,stage:e,memory:t})=>{const r=qt(n);return e.exclude([...t.elements].filter(r)),e}};function eu(n,{stage:e}){const t=[...n.children()];t.length!==0&&(e.addImplicit(n),e.addConnections(Pt(t)),e.connectWithExisting(t),e.addExplicit(t))}function tu(n,{memory:e,stage:t}){const r=[...n.children()];t.addImplicit(n),t.connectWithExisting(n);let i=!1;for(const a of r)if(Fe(a,e.elements).length>0){i=!0;break}i&&(t.connectWithExisting(r,"in"),t.addConnections(Pt(r)),t.connectWithExisting(r,"out")),t.addImplicit(r),t.connections.length>0&&t.addExplicit(n)}function nu(n,{stage:e}){const t=a=>{const f=[];for(const p of a.children())p.isDeploymentNode()&&f.push(...t(p)),f.push(p);return e.connectWithExisting(f,"in"),e.addConnections(Pt(f)),e.addImplicit(f),f},r=t(n);if(r.length===0)return;e.connectWithExisting(r,"out");const i=ru(e);r.forEach(a=>{i.has(a)&&e.addExplicit(a)})}function ru(n){return J(n.mergedConnections(),zr,Mr,nn((e,t)=>(e.add(t.source),e.add(t.target),e),new Set))}const iu={include:({expr:n,model:e,memory:t,stage:r})=>{const i=[...t.elements];if(ie.isWildcard(n.incoming)){for(const f of i){if(f.allOutgoing.isEmpty)continue;const p=[...cn(f)];r.addConnections(Fe(f,p,"directed"))}return r}re(ie.isDeploymentRef(n.incoming),"Only deployment refs are supported in include");const a=it(e,n.incoming);for(const f of i)r.addConnections(Fe(f,a,"directed"));return r},exclude:({expr:n,model:e,memory:t,stage:r})=>{if(ie.isModelRef(n.incoming)){const f=bo(e,n.incoming);return _t(f,{stage:r,memory:t})}if(ie.isWildcard(n.incoming))return r;const i=an(it(e,n.incoming)),a=t.connections.filter(i);return r.excludeConnections(a),r}};function an(n){return He(n.map(e=>{const t=r=>r===e||ye(e,r);return r=>!t(r.source)&&t(r.target)}))}function bo(n,e){const t=sn(n,e);return new Set(t.flatMap(r=>[...r.allIncoming]))}const ou={include:({expr:n,model:e,memory:t,stage:r})=>{const i=[...t.elements];if(ie.isWildcard(n.outgoing)){for(const f of i)if(!f.allIncoming.isEmpty)for(const p of cn(f))r.addConnections(Et(p,f,"directed"));return r}re(ie.isDeploymentRef(n.outgoing),"Only deployment refs are supported in include");const a=it(e,n.outgoing);for(const f of a)r.addConnections(Fe(f,i,"directed"));return r},exclude:({expr:n,model:e,memory:t,stage:r})=>{if(ie.isModelRef(n.outgoing)){const f=Ur(e,n.outgoing);return _t(f,{stage:r,memory:t})}if(ie.isWildcard(n.outgoing))return r;const i=un(it(e,n.outgoing)),a=t.connections.filter(i);return r.excludeConnections(a),r}};function un(n){return He(n.map(e=>{const t=r=>r===e||ye(e,r);return r=>t(r.source)&&!t(r.target)}))}function Ur(n,e){const t=sn(n,e);return new Set(t.flatMap(r=>[...r.allOutgoing]))}const cn=n=>{const e=new Set;for(let t of n.descendingSiblings())e.add(t);return e},su={include:({expr:{source:n,target:e,isBidirectional:t=!1},model:r,stage:i})=>{re(!ie.isModelRef(n),"Invalid source model ref in direct relation"),re(!ie.isModelRef(e),"Invalid target model ref in direct relation");const a=ie.isWildcard(n),f=ie.isWildcard(e),p=t?"both":"directed";let m;switch(!0){case(a&&f):{m=Pt(r.instances()).map(b=>(i.addImplicit(b.boundary),b));break}case(!a&&f):{const b=it(r,n),S=un(b);let C=S;if(t){const G=an(b);C=D=>S(D)!==G(D)}m=b.flatMap(G=>{const D=cn(G);return Fe(G,D,p)}).filter(C);break}case(a&&!f):{const b=it(r,e),S=an(b);let C=S;if(t){const G=un(b);C=D=>G(D)!==S(D)}m=b.flatMap(G=>[...cn(G)].flatMap(D=>Et(D,G,p))).filter(C);break}default:{re(!a,"Inferrence failed - source should be a deployment ref"),re(!f,"Inferrence failed - target should be a deployment ref");const b=it(r,n),S=it(r,e),C=un(b),G=an(S);m=J(b,Qe(D=>Fe(D,S,p)),Ue(D=>C(D)&&G(D)))}}return i.addConnections(m),ie.isDeploymentRef(n)&&Fn(n.selector)&&i.addImplicit(r.element(n.ref.deployment)),ie.isDeploymentRef(e)&&Fn(e.selector)&&i.addImplicit(r.element(e.ref.deployment)),i},exclude:({expr:n,model:e,memory:t,stage:r})=>{if(ie.isWildcard(n.source)&&ie.isWildcard(n.target))return r.excludeConnections(t.connections),r;if(ie.isModelRef(n.source)&&ie.isModelRef(n.target)){const m=au({source:n.source,target:n.target,expr:n,model:e});return _t(m,{stage:r,memory:t})}if(ie.isModelRef(n.source)){if(ie.isWildcard(n.target)){const S=Ur(e,n.source);return _t(S,{stage:r,memory:t})}const m=Ur(e,n.source),b=qt(n.target);return _t(m,{stage:r,memory:t},S=>b(S.target))}if(ie.isModelRef(n.target)){const m=bo(e,n.target),b=qt(n.source);return _t(m,{stage:r,memory:t},S=>b(S.source))}const i=qt(n.source),a=qt(n.target),f=m=>i(m.source)&&a(m.target)||n.isBidirectional&&i(m.target)&&a(m.source),p=t.connections.filter(f);return r.excludeConnections(p),r}};function _t(n,{stage:e,memory:t},r=()=>!0){if(n.size===0)return e;const i=J(t.connections,Ue(a=>r(a)&&gi(a.relations.model,n)),be(a=>a.update({deployment:null,model:Ce(a.relations.model,n)})));return i.length===0?e:e.excludeConnections(i)}function au({source:n,target:e,expr:t,model:r}){const i=sn(r,n),a=sn(r,e),f=t.isBidirectional?"both":"directed",p=[];for(const m of i)p.push(...De(m,a,f));return new Set(p.flatMap(m=>[...m.relations]))}const uu={include:({expr:n,model:e,memory:t,stage:r})=>{const i=[...t.elements];if(ie.isWildcard(n.inout)){for(const f of i){const p=[...cn(f)];r.addConnections(Fe(f,p,"both"))}return r}re(ie.isDeploymentRef(n.inout),"Only deployment refs are supported in include");const a=it(e,n.inout);for(const f of i)r.addConnections(Fe(f,a,"both"));return r},exclude:({expr:n,model:e,memory:t,stage:r})=>{if(ie.isModelRef(n.inout)){const m=sn(e,n.inout);if(m.length===0)return r;const b=xe(new Set,...m.flatMap(S=>[S.allIncoming,S.allOutgoing]));return _t(b,{stage:r,memory:t})}if(ie.isWildcard(n.inout))return r;const i=it(e,n.inout),a=an(i),f=un(i),p=t.connections.filter(m=>a(m)!==f(m));return r.excludeConnections(p),r}},cu={include:({model:n,stage:e})=>{const t=[],r=[...n.roots()].map(i=>(i.onlyOneInstance()||t.push(...i.children()),i));return e.addExplicit(r),t.length>1&&e.addConnections(Pt([...r,...t])),e},exclude:({stage:n,memory:e})=>(n.exclude(e.elements),n)};let du=class Ro{constructor(e){this.memory=e}static for(e){return new Ro(e)}step1CleanConnections(e){if(e.connections.length<2)return e;const t=J(e.connections,zr,Mr),r=Wt(e.connections,t);if(r.length===0)return e;const i=e.stageExclude({});return i.excludeConnections(r,!0),i.commit()}step2ProcessImplicits(e){const t=xe(this.memory.elements,e.elements),r=xe(e.final,this.memory.explicits),i=new Oe(()=>new Set);for(const p of e.connections)if(p.boundary)for(const m of p.relations.model)i.get(m).add(p.boundary);for(const[p,m]of i)if(!(m.size<2))for(const b of m)t.delete(b)&&r.add(b);const a=new Set(r),f=p=>{for(const m of a)if(p===m||ye(p,m))return!0;return!1};return J(pe(t,a),Me(p=>p.isDeploymentNode()),ce(),Qn,We(p=>{const m=[...p.children()].filter(f).length;if(m>=2){r.add(p);return}m===1&&Qt(p.siblings(),f)&&r.add(p)})),e.update({final:r})}step3ProcessBoundaries(e){const t=new Set;for(const p of e.connections)p.boundary&&t.add(p.boundary);const r=go(e,"final"),i=e.stageExclude({}),a=p=>!(t.has(p)||e.explicits.has(p)||r.hasInOut(p)||r.root.has(p)),f=Ee([...r.root]);f&&!e.explicits.has(f)&&i.exclude(f);for(const p of e.final){const m=Ee(r.children(p));m&&!r.hasInOut(m)&&a(p)&&i.exclude(p)}return i.isDirty()?i.commit():e}commit(){const e=this.step1CleanConnections(this.memory),t=this.step2ProcessImplicits(e);return this.step3ProcessBoundaries(t)}};function lu(n,e){let t=Pa.empty();for(const r of e)if(In(r)){const i="include"in r?"include":"exclude",a=r.include??r.exclude;for(const f of a){let p=i==="include"?t.stageInclude(f):t.stageExclude(f);const m={model:n,stage:p,memory:t};switch(!0){case ie.isModelRef(f):break;case ie.isDeploymentRef(f):p=Za[i]({...m,expr:f})??p;break;case ie.isWildcard(f):p=cu[i]({...m,expr:f})??p;break;case nt.isDirect(f):p=su[i]({...m,expr:f})??p;break;case nt.isInOut(f):p=uu[i]({...m,expr:f})??p;break;case nt.isOutgoing(f):p=ou[i]({...m,expr:f})??p;break;case nt.isIncoming(f):p=iu[i]({...m,expr:f})??p;break;default:Be(f)}t=p.commit()}}return du.for(t).commit()}function hu(n,{docUri:e,rules:t,...r}){let i=lu(n.deployment,t);const a=Ja(i),f=Ha(i.connections);Pi(a,f);const p=io({nodes:a,edges:f}),m=Qa(t,p.nodes),b=yr(t,lr),S=xr(m);return Ar({...r,autoLayout:{direction:b?.direction??"TB",...b?.nodeSep&&{nodeSep:b.nodeSep},...b?.rankSep&&{rankSep:b.rankSep}},edges:p.edges,nodes:be(m,C=>(delete C.notation,C.icon==="none"&&delete C.icon,C)),...S.length>0&&{notation:{elements:S}}})}function jr(n){return e=>$i(e)?e.groupRules.flatMap(jr(n)):In(e)?"include"in e?e.include.filter(n):[]:[]}function xo(n,e){const t=n.flatMap(jr(Sn));if(t.length===0)return e;const r=[...e];for(const{custom:{expr:i,...a}}of t){const{border:f,opacity:p,...m}=Bi(a,tt),b=!gt(m),S=Ve(i);r.forEach((C,G)=>{if(rt.isNodesGroup(C)||!S(C))return;b&&(C={...C,isCustomized:!0,...m});let D;f!==void 0&&(D={border:f}),p!==void 0&&(D={...D,opacity:p}),D&&(C={...C,isCustomized:!0,style:{...C.style,...D}}),r[G]=C})}return r}function fu(n,e){return n.reduce((t,r)=>{if(Si(r)){const i=e.predicates[r.predicateId];return tt(i)?t:t.concat(i)}if(Ii(r)){const i=e.styles[r.styleId];return tt(i)?t:t.concat(i)}return t.push(r),t},[])}function pu(n,e){return n.reduce((t,r)=>{if(Si(r)){const i=e.dynamicPredicates[r.predicateId];return tt(i)?t:t.concat(i)}if(Ii(r)){const i=e.styles[r.styleId];return tt(i)?t:t.concat(i)}return t.push(r),t},[])}class gu{constructor(e,t){this.model=e,this.view=t}explicits=new Set;steps=[];addStep({source:e,target:t,title:r,isBackward:i,navigateTo:a,...f},p,m){const b=m?Li(m,p):Li(p),S=this.model.element(e),C=this.model.element(t);this.explicits.add(S),this.explicits.add(C);const{title:G,relations:D,tags:A,navigateTo:U,head:I,tail:W,color:V,line:P,notation:F}=this.findRelations(S,C),X=_e(a)&&a!==this.view.id?a:U;this.steps.push({id:b,...f,source:S,target:C,title:r??G,relations:D??[],isBackward:i??!1,...X?{navigateTo:X}:{},...A?{tags:A}:{},...I?{head:I}:{},...W?{tail:W}:{},...V?{color:V}:{},...P?{line:P}:{},...F?{notation:F}:{}})}compute(){const{docUri:e,rules:t,steps:r,...i}=this.view;let a=1;for(const D of r){if(Us(D)){if(D.__parallel.length===0)continue;D.__parallel.length===1?this.addStep(D.__parallel[0],a):D.__parallel.forEach((A,U)=>this.addStep(A,U+1,a))}else this.addStep(D,a);a++}const f=pu(t,this.model.globals());for(const D of f)if(In(D))for(const A of D.include){const U=Ve(A);for(const I of this.model.elements())U(I)&&this.explicits.add(I)}const p=[...this.explicits].map(D=>D.$element),m=Ya(p),b=this.steps.map(({source:D,target:A,relations:U,title:I,isBackward:W,...V})=>{const P=ve(m.get(D.id),`Source node ${D.id} not found`),F=ve(m.get(A.id),`Target node ${A.id} not found`),X={parent:lt(D.id,A.id),source:D.id,target:A.id,label:I,relations:U,color:ki,line:_i,head:dr,...V};for(W&&(X.dir="back");X.parent&&!m.has(X.parent);)X.parent=at(X.parent);P.outEdges.push(X.id),F.inEdges.push(X.id);for(const _ of ht(X.source)){if(_===X.parent)break;m.get(_)?.outEdges.push(X.id)}for(const _ of ht(X.target)){if(_===X.parent)break;m.get(_)?.inEdges.push(X.id)}return X}),S=xo(f,yo(f,p.map(D=>ve(m.get(D.id))))),C=yr(f,lr),G=xr(S);return Ar({...i,autoLayout:{direction:C?.direction??"LR",...C?.nodeSep&&{nodeSep:C.nodeSep},...C?.rankSep&&{rankSep:C.rankSep}},nodes:be(S,D=>(delete D.notation,D.icon==="none"&&delete D.icon,D)),edges:b,...G.length>0&&{notation:{elements:G}}})}findRelations(e,t){const r=Ft(e,t,"directed").flatMap(S=>[...S.relations]);if(r.length===0)return{title:null,tags:null,relations:null,navigateTo:null,tail:null,head:null,color:null,line:null,notation:null};const i=J(r,Qe(S=>S.tags),Ue(_e),pt()),a=Ze(i,1)?i:null,f=Ze(r,1)?be(r,S=>S.id):null,p=(Ee(r)||r.find(S=>S.source===e&&S.target===t))?.$relationship.navigateTo??null,m=p&&p!==this.view.id?p:J(r,be(S=>S.$relationship.navigateTo),Ue(_e),Ue(S=>S!==this.view.id),pt(),Ee()),b=J(r,nn((S,{title:C,$relationship:G})=>(_e(C)&&S.title.add(C),_e(G.tail)&&S.tail.add(G.tail),_e(G.head)&&S.head.add(G.head),_e(G.color)&&S.color.add(G.color),_e(G.line)&&S.line.add(G.line),S),{tail:new Set,head:new Set,color:new Set,line:new Set,notation:new Set,title:new Set}));return{tags:a,relations:f,navigateTo:m??null,title:Ee([...b.title])??null,tail:Ee([...b.tail])??null,head:Ee([...b.head])??null,color:Ee([...b.color])??null,line:Ee([...b.line])??null,notation:Ee([...b.notation])??null}}}function mu(n,e){return new gu(n,e).compute()}function Eo(n){switch(!0){case ur(n):{const e=Eo(n.where.expr),t=bt(n.where.condition);return r=>e(r)&&t(r)}case ir(n):{const e=Ve(n.source),t=Ve(n.target);return r=>e(r.source)&&t(r.target)||!!n.isBidirectional&&e(r.target)&&t(r.source)}case or(n):{const e=Ve(n.inout);return t=>e(t.source)||e(t.target)}case sr(n):{const e=Ve(n.incoming);return t=>e(t.target)}case ar(n):{const e=Ve(n.outgoing);return t=>e(t.source)}default:Be(n)}}function yu(n,e,t){const r=n.flatMap(jr(cr)),i=Array.from(t);if(r.length===0||i.length===0)return i;for(const{customRelation:{relation:a,title:f,...p}}of r){const m=Bi(p,tt),b=Eo(a);i.forEach((S,C)=>{const G=e.find(A=>A.id===S.source),D=e.find(A=>A.id===S.target);!G||!D||b({source:G,target:D,...mr(S,["kind","tags"])})&&(i[C]={...S,...m,label:f??S.label,isCustomized:!0})})}return i}var Nr,_o;function wu(){if(_o)return Nr;_o=1;var n=Kn(),e=Xn();function t(){this.clear()}return t.prototype.clear=function(){this.items=[],this.size=0},t.prototype.push=function(r){return this.items.push(r),++this.size},t.prototype.pop=function(){if(this.size!==0)return this.size--,this.items.pop()},t.prototype.peek=function(){return this.items[this.size-1]},t.prototype.forEach=function(r,i){i=arguments.length>1?i:this;for(var a=0,f=this.items.length;a<f;a++)r.call(i,this.items[f-a-1],a,this)},t.prototype.toArray=function(){for(var r=new Array(this.size),i=this.size-1,a=this.size;a--;)r[a]=this.items[i-a];return r},t.prototype.values=function(){var r=this.items,i=r.length,a=0;return new n(function(){if(a>=i)return{done:!0};var f=r[i-a-1];return a++,{value:f,done:!1}})},t.prototype.entries=function(){var r=this.items,i=r.length,a=0;return new n(function(){if(a>=i)return{done:!0};var f=r[i-a-1];return{value:[a++,f],done:!1}})},typeof Symbol<"u"&&(t.prototype[Symbol.iterator]=t.prototype.values),t.prototype.toString=function(){return this.toArray().join(",")},t.prototype.toJSON=function(){return this.toArray()},t.prototype.inspect=function(){var r=this.toArray();return Object.defineProperty(r,"constructor",{value:t,enumerable:!1}),r},typeof Symbol<"u"&&(t.prototype[Symbol.for("nodejs.util.inspect.custom")]=t.prototype.inspect),t.from=function(r){var i=new t;return e(r,function(a){i.push(a)}),i},t.of=function(){return t.from(arguments)},Nr=t,Nr}var vu=wu();const ko=wt(vu);class ln{constructor(e,t,r=null,i=new Set){this.id=e,this.viewRule=t,this.parent=r,this.elements=i}static kind=zt.Group;isEmpty(){return this.elements.size===0}update(e){return new ln(this.id,this.viewRule,this.parent,e)}clone(){return new ln(this.id,this.viewRule,this.parent,new Set(this.elements))}}class So extends fo{excludeRelations(e){return J(this.memory.connections,Ue(t=>gi(t.relations,e)),We(t=>{this.excludeConnections(t.update(Ce(t.relations,e)))})),this}precommit(e){if(this.excluded.elements.size>0){const t=new Set([...this.excluded.elements].flatMap(r=>[...r.incoming("direct"),...r.outgoing("direct")]));this.excludeRelations(t)}return e}postcommit(e){const t=pe(this.memory.explicits,e.explicits);for(const i of t)e.explicitFirstSeenIn.delete(i);const r=pe(this.memory.elements,e.elements);for(const i of r)e.lastSeenIn.delete(i);return e}}class bu extends So{constructor(e,t){super(e,t),this.memory=e,this.expression=t}}class Ao extends po{connectWithExisting(e,t="both"){const r=this._connections.length,i=()=>this._connections.length>r;if(!vt(e)){if(t==="in"||t==="both")for(const f of this.memory.elements)this.addConnections(Ft(f,e,"directed"));return(t==="out"||t==="both")&&this.addConnections(De(e,this.memory.elements,"directed")),i()}const a=[...e];if(t==="in"||t==="both")for(const f of this.memory.elements)this.addConnections(De(f,a,"directed"));if(t==="out"||t==="both")for(const f of a)this.addConnections(De(f,this.memory.elements,"directed"));return i()}addImplicitWithinScope(e){e&&(!this.memory.scope||ye(this.memory.scope,e))&&this.addImplicit(e)}processConnections(e){return vi(this.expression)||J(e,We(({source:t,target:r,boundary:i})=>{J(Tn([...ce(t.ancestors()).reverse(),t],[...ce(r.ancestors()).reverse(),r]),wr(([a,f])=>a===f),Ri(1),We(([a,f])=>{if(a===t&&f===r){this.addImplicitWithinScope(i);return}a!==t&&this.addImplicitWithinScope(a),f!==r&&this.addImplicitWithinScope(f)}))})),e}postcommit(e){const t=pe(e.explicits,this.memory.explicits);for(const r of t)e.explicitFirstSeenIn.set(r,"@root");return e}}class xu extends Ao{constructor(e,t){super(e,t),this.memory=e,this.expression=t}postcommit(e){const t=pe(e.explicits,this.memory.explicits);for(const r of t)e.explicitFirstSeenIn.set(r,this.memory.activeGroupId);for(const r of[...this.explicits,...this.implicits])e.lastSeenIn.set(r,this.memory.activeGroupId);return e}}class St extends oo{constructor(e,t){super(e),this.state=e,this.scope=t}static empty(e){return new St({elements:new Set,explicits:new Set,final:new Set,connections:[],groups:[],explicitFirstSeenIn:new Map,lastSeenIn:new Map},e)}get groups(){return this.state.groups}get explicitFirstSeenIn(){return this.state.explicitFirstSeenIn}get lastSeenIn(){return this.state.lastSeenIn}stageInclude(e){return new Ao(this,e)}stageExclude(e){return new So(this,e)}mutableState(){return{elements:new Set(this.state.elements),explicits:new Set(this.state.explicits),final:new Set(this.state.final),connections:[...this.state.connections],groups:this.state.groups.map(e=>e.clone()),explicitFirstSeenIn:new Map(this.state.explicitFirstSeenIn),lastSeenIn:new Map(this.state.lastSeenIn)}}update(e){return new St({...this.state,...e},this.scope)}}class yt extends St{constructor(e,t,r){super(e,t),this.state=e,this.scope=t,this.stack=r}static enter(e,t){const r=`@gr${e.groups.length+1}`;if(e instanceof yt){const f=ko.from(e.stack),p=e.mutableState();return p.groups.push(new ln(r,t,e.activeGroupId)),f.push(r),new yt(p,e.scope,f)}const i=e.mutableState();i.groups.push(new ln(r,t,null));const a=ko.of(r);return new yt(i,e.scope,a)}get activeGroupId(){return ve(this.stack.peek(),"Stack must not be empty")}mutableState(){return{...super.mutableState()}}update(e){const t={...this.state,...e};return new yt(t,this.scope,this.stack)}stageInclude(e){return new xu(this,e)}stageExclude(e){return new bu(this,e)}leave(){const e=this.mutableState();return this.stack.pop(),this.stack.peek()?new yt(e,this.scope,this.stack):new St(e,this.scope)}}function Eu(n){return J([...n],Bt,nn((e,t,r,i)=>{const a=ho(i,t),f=xe(...a.map(Je("relations")));let p=Ce(t.relations,f);if(a.length>0&&(p=xe(p,t.directRelations)),Or(i,t.reversed(!1))&&(p=xe(p,t.directRelations)),p.size<t.relations.size){const m=i.some(Dn(t.source)),b=i.some(Dn(t.target));m&&(p=xe(p,et(Me(t.relations,Lr(t.source))))),b&&(p=xe(p,et(Me(t.relations,Dr(t.target)))))}return p.size>0&&e.push(t.update(p)),e},[]))}class Wr{constructor(e){this.memory=e}static for(e){return new Wr(e)}step1CleanConnections(e){if(e.connections.length<2)return e;const t=Eu(e.connections);if(t.length===0)return e;const r=e.stageExclude({});return r.excludeConnections(t,!0),r.commit()}step2ProcessImplicits(e){const t=xe(this.memory.elements,e.elements),r=xe(e.final,this.memory.explicits),i=new Set(r),a=f=>{for(const p of i)if(f===p||ye(f,p))return!0;return!1};return J(pe(t,i),ce(),Qn,We(f=>{const p=[...f.children()].filter(a).length;if(p>=2){r.add(f);return}p===1&&Qt(f.siblings(),a)&&r.add(f)})),e.update({final:r})}step3ProcessBoundaries(e){const t=new Set;for(const p of e.connections)p.boundary&&p.boundary!==p.source&&p.boundary!==p.target&&t.add(p.boundary);const r=go(e,"final"),i=e.stageExclude({}),a=p=>!(t.has(p)||e.explicits.has(p)||r.hasInOut(p)||r.root.has(p)),f=Ee([...r.root]);f&&!e.explicits.has(f)&&i.exclude(f);for(const p of e.final){const m=Ee(r.children(p));m&&!r.hasInOut(m)&&a(p)&&i.exclude(p)}return i.isDirty()?i.commit():e}commit(){const e=this.step1CleanConnections(this.memory),t=this.step2ProcessImplicits(e);return this.step3ProcessBoundaries(t)}}const _u={include:({expr:n,model:e,stage:t,where:r})=>{const i=e.element(n.expanded);r(i)&&(t.addExplicit(i),t.connectWithExisting(i));const a=[...i.children()].filter(r),f=[];for(const p of a)t.addImplicit(p),t.connectWithExisting(p)&&f.push(p);return t.addConnections(mt(f)),t},exclude:({expr:n,model:e,stage:t,where:r})=>{const i=e.element(n.expanded),a=[i,...i.children()].filter(r);return t.exclude(a),t}};function Pe(n,e){switch(!0){case ft(e):{const t=n.element(e.expanded);return[t,...t.children()]}case Ye(e):{const t=n.element(e.element);let r;return e.isChildren?r=ce(t.children()):e.isDescendants&&(r=ce(t.descendants())),r&&r.length>0?r:[t]}case Mt(e):return[...Me(n.elements(),t=>e.isEqual===(t.kind===e.elementKind))];case Rt(e):return[...Me(n.elements(),t=>e.isEqual===t.tags.includes(e.elementTag))];default:Be(e)}}function zn(n,e){if(e.isEmpty()||n.length===0)return n;const t=He(n.map(i=>dt(i))),r=ce(Me(e.elements,i=>!n.includes(i)&&t(i)));return[...n,...r]}function dn(n,{memory:e,model:t}){const r=Pe(t,n);return ft(n)||Ye(n)?n.isDescendants===!0?r:zn(r,e):r}const ku={include:({expr:n,model:e,stage:t,filterWhere:r})=>{const i=r(Pe(e,n));if(i.length!==0)return t.addExplicit(i),t.connectWithExisting(i),t.addConnections(mt(i)),t},exclude:({expr:n,model:e,stage:t,filterWhere:r})=>{const i=r(Pe(e,n));return t.exclude(i),t}};function Io(n,e){let t;return e.isChildren?t=[...n.children()]:e.isDescendants&&(t=[...n.descendants()]),t&&t.length>0?t:[n]}const Su={include:({expr:n,model:e,stage:t,where:r})=>{const i=e.element(n.element),a=Io(i,n).filter(r);if(a.length!==0)return t.addExplicit(a),t.connectWithExisting(a),t.addConnections(mt(a)),t},exclude:({expr:n,model:e,stage:t,filterWhere:r})=>{const i=e.element(n.element),a=r(Io(i,n));return t.exclude(a),t}},Kt=()=>!0,Au=n=>n;function Iu(n){return{...n.$element,modelRef:1}}function $u(n){return n.reduce((e,t)=>{const r=[...t.relations];re(Ze(r,1),"Edge must have at least one relation");const i=t.source.id,a=t.target.id,{title:f,...p}=wo(r.map(b=>b.$relationship),r.find(b=>b.source.id===i&&b.target.id===a)?.$relationship),m={id:t.id,parent:t.boundary?.id??null,source:i,target:a,label:f??null,relations:r.map(b=>b.id),...p};return e.push(m),e},[])}function Gu(n){return Rr([...n.final].map(Iu),n.groups)}const Ou={include:({expr:{source:n,target:e,isBidirectional:t=!1},memory:r,model:i,stage:a,where:f,filterWhere:p})=>{const m=Le(n),b=Le(e),S=[];switch(!0){case(m&&b&&r.isEmpty()&&f!==Kt):{const C=J(i.relationships(),Me(f),ce(),be(G=>new Ie(G.source,G.target,new Set([G]))));return a.addConnections(C),a}case(m&&b&&!r.isEmpty()&&f!==Kt):{S.push(...mt(r.elements));break}case(m&&b):{S.push(...mt(i.roots()));break}case(!m&&b&&f!==Kt):{const C=Pe(i,n),G=J(C,Qe(D=>J(D,$n(Ln(t===!0),{onTrue:A=>xe(A.allIncoming,A.allOutgoing),onFalse:A=>A.allOutgoing}),Me(f),li(),ce(),Gn(A=>A.source===D),([A,U])=>Fi(J(A,be(I=>new Ie(D,I.target,new Set([I])))),J(U,be(I=>new Ie(I.source,D,new Set([I]))))))));return a.addConnections(G),a}case(!m&&b):{const[C,G]=$o(n,{memory:r,model:i}),D=t?"both":"directed";for(const A of C)S.push(...De(A,G,D));break}case(m&&!b&&f!==Kt):{const C=Pe(i,e),G=J(C,Qe(D=>J(D,$n(Ln(t===!0),{onTrue:A=>xe(A.allIncoming,A.allOutgoing),onFalse:A=>A.allIncoming}),Me(f),ce(),Gn(A=>A.target===D),([A,U])=>Fi(J(U,be(I=>new Ie(D,I.target,new Set([I])))),J(A,be(I=>new Ie(I.source,D,new Set([I]))))))));return a.addConnections(G),a}case(m&&!b):{const[C,G]=$o(e,{memory:r,model:i}),D=t?"both":"directed";for(const A of G)S.push(...De(A,C,D));break}default:{re(!Le(n),"Inference failed - source must be not a wildcard"),re(!Le(e),"Inference failed - target must be not a wildcard");const C=dn(n,{memory:r,model:i}),G=dn(e,{memory:r,model:i}),D=t?"both":"directed";for(const A of C)S.push(...De(A,G,D))}}return a.addConnections(p(S)),a},exclude:({expr:{source:n,target:e,isBidirectional:t},model:r,memory:i,stage:a,where:f})=>{const p=Le(n),m=Le(e);let b;switch(!0){case(p&&m):{b=J(i.connections,Qe(rn(Je("relations"),Me(f),ce())),et());break}case(!p&&m):{const S=Pe(r,n);b=J(S,Qe(C=>J(C,$n(Ln(t===!0),{onTrue:G=>xe(G.allIncoming,G.allOutgoing),onFalse:G=>G.allOutgoing}),Me(f),ce())),et());break}case(p&&!m):{const S=Pe(r,e);b=J(S,Qe(C=>J(C,$n(Ln(t===!0),{onTrue:G=>xe(G.allIncoming,G.allOutgoing),onFalse:G=>G.allIncoming}),Me(f),ce())),et());break}default:{re(!Le(n),"Inferrence failed - source must be not a wildcard"),re(!Le(e),"Inferrence failed - target must be not a wildcard");const S=Pe(r,n),C=Pe(r,e);let G=new Set;for(const D of S)for(const A of C)Lt(D,A)||(G=xe(G,Ce(D.allOutgoing,A.allIncoming),t?Ce(A.allOutgoing,D.allIncoming):new Set));b=et(Me(G,f))}}return a.excludeRelations(b),a}};function $o(n,{memory:e,model:t}){let r=Pe(t,n);if(!Ze(r,1))return[[],[]];if(ft(n)||Ye(n)){const a=t.element(n.element??n.expanded),f=ce(a.ascendingSiblings());return[zn(r,e),zn(f,e)]}const i=J(r,be(a=>a.ascendingSiblings()),bs(),li(),ce(),a=>zn(a,e));return[r,i]}const Cu={include:({expr:n,scope:e,model:t,memory:r,stage:i,filterWhere:a})=>{const f=n.incoming,p=[];if(Le(f)){if(!e)return;for(const m of e.ascendingSiblings())p.push(...Ft(m,e,"directed"))}else{const m=dn(f,{memory:r,model:t}),b=[...r.elements];b.length===0&&b.push(...pt(m.flatMap(C=>[...C.ascendingSiblings()])));const S=Lu(t,f);for(const C of b)p.push(...De(C,m,"directed").filter(S))}return i.addConnections(a(p)),i},exclude:({expr:{incoming:n},model:e,scope:t,stage:r,where:i})=>{const a=[];if(Le(n)){if(!t)return;a.push(...t.allIncoming)}else{const f=Pe(e,n);a.push(...f.flatMap(p=>[...p.allIncoming]))}return r.excludeRelations(new Set(a.filter(i))),r}};function Lu(n,e){switch(!0){case Mt(e):case Rt(e):{const t=Ve(e);return r=>t(r.target)}case(Ye(e)&&e.isChildren):return He([...n.children(e.element)].map(t=>Re.isIncoming(t.id)));case(Ye(e)&&e.isDescendants):return He([Re.isInside(e.element),...[...n.children(e.element)].map(t=>Re.isIncoming(t.id))]);case ft(e):return He([Re.isIncoming(e.expanded),Re.isInside(e.expanded)]);case Ye(e):return Re.isIncoming(e.element);default:Be(e)}}const Du={include:({expr:{inout:n},scope:e,model:t,memory:r,stage:i,filterWhere:a})=>{const f=[];if(Le(n)){if(!e)return;f.push(...De(e,e.ascendingSiblings()))}else{const p=dn(n,{memory:r,model:t});let m=[...r.elements];m.length===0&&(m=pt(p.flatMap(b=>ce(b.ascendingSiblings()))));for(const b of p)f.push(...De(b,m))}return i.addConnections(a(f)),i},exclude:({expr:{inout:n},model:e,scope:t,stage:r,where:i})=>{const a=[];if(Le(n)){if(!t)return;a.push(...t.allOutgoing),a.push(...t.allIncoming)}else{const f=Pe(e,n);a.push(...f.flatMap(p=>[...p.allOutgoing,...p.allIncoming]))}return r.excludeRelations(et(a.filter(i))),r}},zu={include:({expr:n,scope:e,model:t,memory:r,stage:i,filterWhere:a})=>{const f=n.outgoing,p=[];if(Le(f)){if(!e)return;p.push(...De(e,e.ascendingSiblings(),"directed"))}else{const m=dn(f,{memory:r,model:t}),b=[...r.elements];b.length===0&&b.push(...pt(m.flatMap(C=>[...C.ascendingSiblings()])));const S=Mu(t,f);for(const C of m)p.push(...De(C,b,"directed").filter(S))}return i.addConnections(a(p)),i},exclude:({expr:{outgoing:n},model:e,scope:t,stage:r,where:i})=>{const a=[];if(Le(n)){if(!t)return;a.push(...t.allOutgoing)}else{const f=Pe(e,n);a.push(...f.flatMap(p=>[...p.allOutgoing]))}return r.excludeRelations(et(a.filter(i))),r}};function Mu(n,e){switch(!0){case Mt(e):case Rt(e):{const t=Ve(e);return r=>t(r.source)}case(Ye(e)&&e.isChildren):return He([...n.children(e.element)].map(t=>Re.isOutgoing(t.id)));case(Ye(e)&&e.isDescendants):return He([Re.isInside(e.element),...[...n.children(e.element)].map(t=>Re.isOutgoing(t.id))]);case ft(e):return He([Re.isOutgoing(e.expanded),Re.isInside(e.expanded)]);case Ye(e):return Re.isOutgoing(e.element);default:Be(e)}}const Ru={include:({scope:n,model:e,stage:t,memory:r,where:i})=>{if(!n){const b=[...e.roots()].filter(i);return b.length===0?void 0:(t.addExplicit(b),t.addConnections(mt(b)),t.connectWithExisting(b),t)}const a=i(n)?n:null,f=ce(Me(n.children(),i)),p=f.length>0;if(!p)if(a){if(De(a,a.siblings()).length===0){const b=a.parent;b&&i(b)&&t.addExplicit(b)}f.push(a)}else return t;a&&t.addExplicit(a);const m=et([...r.elements,...n.descendingSiblings()]);for(const b of m)t.addConnections(De(b,f,"directed"));p&&(t.addConnections(mt(f)),t.addExplicit(f));for(const b of f)t.addConnections(De(b,m,"directed"));return t},exclude:({scope:n,memory:e,stage:t,where:r})=>r!==Kt?(t.exclude(Ue([...e.elements],r)),t):n?(t.exclude([n,...n.descendants()]),t):St.empty(e.scope).stageExclude(t.expression)};function Tr(n,e,t){switch(!0){case Sn(n):return e==="include"?Tr(n.custom.expr,e,t):t.stage;case An(n):{const r=bt(n.where.condition),i=Ue(r);return Tr(n.where.expr,e,{...t,where:r,filterWhere:i})}case ft(n):return _u[e]({...t,expr:n})??t.stage;case Ye(n):return Su[e]({...t,expr:n})??t.stage;case Le(n):return Ru[e]({...t,expr:n})??t.stage;case Mt(n):case Rt(n):return ku[e]({...t,expr:n})??t.stage;default:Be(n)}}function Br(n,e,t){switch(!0){case cr(n):return e==="include"?Br(n.customRelation.relation,e,t):t.stage;case ur(n):{const r=bt(n.where.condition),i=f=>new Set(Ue([...f],r)),a=f=>J(f,be(p=>new Ie(p.source,p.target,i(p.relations))),Ue(p=>p.nonEmpty()));return Br(n.where.expr,e,{...t,where:r,filterWhere:a})}case or(n):return Du[e]({...t,expr:n})??t.stage;case ir(n):return Ou[e]({...t,expr:n})??t.stage;case ar(n):return zu[e]({...t,expr:n})??t.stage;case sr(n):return Cu[e]({...t,expr:n})??t.stage;default:Be(n)}}function Go(n,e,t){const r={model:n,scope:e.scope,where:Kt,filterWhere:Au};for(const i of t){if($i(i)){const a=yt.enter(e,i);e=Go(n,a,i.groupRules),re(e instanceof yt,"processPredicates must return ActiveGroupMemory"),e=e.leave();continue}if(In(i)){const a="include"in i?"include":"exclude",f=i.include??i.exclude;for(const p of f){let m=a==="include"?e.stageInclude(p):e.stageExclude(p);switch(!0){case Ls(p):m=Tr(p,a,{...r,stage:m,memory:e})??m;break;case vi(p):m=Br(p,a,{...r,stage:m,memory:e})??m;break;default:Be(p)}e=m.commit()}}}return Wr.for(e).commit()}function Uu(n,{docUri:e,rules:t,...r}){t=fu(t,n.globals());const i=r.viewOf?n.element(r.viewOf):null;let a=Go(n,St.empty(i),t);a.isEmpty()&&i&&(a=a.update({final:new Set([i])})),a=ju(a);const f=Gu(a),p=$u(a.connections);Pi(f,p);const m=io({nodes:f,edges:p}),b=xo(t,yo(t,m.nodes)),S=yr(t,lr),C=xr(b);return Ar({...r,autoLayout:{direction:S?.direction??"TB",...S?.nodeSep&&{nodeSep:S.nodeSep},...S?.rankSep&&{rankSep:S.rankSep}},edges:yu(t,b,m.edges),nodes:be(b,G=>(delete G.notation,G.icon==="none"&&delete G.icon,G)),...C.length>0&&{notation:{elements:C}}})}function ju(n){if(n.groups.length===0)return n;const e=new Oe(()=>new Set),t=new Map,r=f=>{for(const p of f.ancestors()){const m=t.get(p);if(m)return t.set(f,m),e.get(m).add(f),!0}return!1},i=f=>{for(const p of f.descendants("asc")){const m=t.get(p);if(m)return t.set(f,m),e.get(m).add(f),!0}return!1};if(J(bn([...n.explicitFirstSeenIn.keys()]),We(f=>{if(!r(f)){const p=ve(n.explicitFirstSeenIn.get(f));t.set(f,p),e.get(p).add(f)}})),J(bn([...n.lastSeenIn.keys()]),Ue(f=>!t.has(f)),We(f=>{if(r(f)||i(f))return;const p=ve(n.lastSeenIn.get(f));t.set(f,p),e.get(p).add(f)})),e.size===0)return n;let a=n.groups.map(f=>{const p=e.get(f.id);return p?f.update(p):f});return n.update({groups:a})}function Oo(n,e){switch(!0){case Gi(n):return hu(e,n);case Oi(n):return mu(e,n);case tn(n):return Uu(e,n);default:Be(n)}}function Nu(n,e){try{return{isSuccess:!0,view:Oo(n,e)}}catch(t){return{isSuccess:!1,error:t instanceof Error?t:new Error(`Unknown error: ${t}`),view:void 0}}}function Ae(n){return ct(n)?n:n.id}class Co{constructor(e,t){this.$model=e,this.$deployments=t;for(const r of bn(xt(t.elements))){const i=this.addElement(r);for(const a of i.tags)this.#u.get(a).add(i);i.isInstance()&&this.#s.get(i.element.id).add(i)}for(const r of xt(t.relations)){const i=this.addRelation(r);for(const a of i.tags)this.#u.get(a).add(i)}}#e=new Map;#t=new Map;#n=new Oe(()=>new Set);#s=new Oe(()=>new Set);#i=new Set;#r=new Map;#o=new Oe(()=>new Set);#c=new Oe(()=>new Set);#a=new Oe(()=>new Set);#u=new Oe(()=>new Set);#d=new Map;element(e){if(e instanceof $r||e instanceof Gr)return e;const t=Ae(e);return ve(this.#e.get(t),`Element ${t} not found`)}findElement(e){return this.#e.get(e)??null}node(e){const t=this.element(e);return re(t.isDeploymentNode(),`Element ${t.id} is not a deployment node`),t}findNode(e){const t=this.findElement(e);return t?(re(t.isDeploymentNode(),`Element ${t?.id} is not a deployment node`),t):null}instance(e){const t=this.element(e);return re(t.isInstance(),`Element ${t.id} is not a deployed instance`),t}findInstance(e){const t=this.findElement(e);return t?(re(t.isInstance(),`Element ${t?.id} is not a deployed instance`),t):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(const e of this.#e.values())e.isDeploymentNode()&&(yield e)}*instances(){for(const e of this.#e.values())e.isInstance()&&(yield e)}*instancesOf(e){const t=Ae(e),r=this.#s.get(t);r&&(yield*r)}deploymentRef(e){if("element"in e){const{id:t,element:r}=e;return Zn(this.#d,`${t}@${r}`,()=>new La(this.instance(t),this.$model.element(r)))}return this.element(e)}relationships(){return this.#r.values()}relationship(e){return ve(this.#r.get(e),`DeploymentRelationModel ${e} not found`)}findRelationship(e){return this.#r.get(e)??null}*views(){for(const e of this.$model.views())e.isDeploymentView()&&(yield e)}parent(e){const t=Ae(e);return this.#t.get(t)||null}children(e){const t=Ae(e);return this.#n.get(t)}*siblings(e){const t=Ae(e),r=this.parent(e)?.children()??this.roots();for(const i of r)i.id!==t&&(yield i)}*ancestors(e){let t=ct(e)?e:e.id,r;for(;r=this.#t.get(t);)yield r,t=r.id}*descendants(e,t="desc"){for(const r of this.children(e))t==="asc"?(yield r,yield*this.descendants(r.id)):(yield*this.descendants(r.id),yield r)}*incoming(e,t="all"){const r=Ae(e);for(const i of this.#o.get(r))switch(!0){case t==="all":case(t==="direct"&&i.target.id===r):case(t==="to-descendants"&&i.target.id!==r):yield i;break}}*outgoing(e,t="all"){const r=Ae(e);for(const i of this.#c.get(r))switch(!0){case t==="all":case(t==="direct"&&i.source.id===r):case(t==="from-descendants"&&i.source.id!==r):yield i;break}}addElement(e){if(this.#e.has(e.id))throw new Error(`Element ${e.id} already exists`);const t=_n.isDeploymentNode(e)?new $r(this,Object.freeze(e)):new Gr(this,Object.freeze(e),this.$model.element(e.element));this.#e.set(t.id,t);const r=at(t.id);return r?(re(this.#e.has(r),`Parent ${r} of ${t.id} not found`),this.#t.set(t.id,this.node(r)),this.#n.get(r).add(t)):(re(t.isDeploymentNode(),`Root element ${t.id} is not a deployment node`),this.#i.add(t)),t}addRelation(e){if(this.#r.has(e.id))throw new Error(`Relation ${e.id} already exists`);const t=new ao(this,Object.freeze(e));this.#r.set(t.id,t),this.#o.get(t.target.id).add(t),this.#c.get(t.source.id).add(t);const r=t.boundary?.id??null;if(r)for(const i of[r,...ht(r)])this.#a.get(i).add(t);for(const i of ht(t.source.id)){if(i===r)break;this.#c.get(i).add(t)}for(const i of ht(t.target.id)){if(i===r)break;this.#o.get(i).add(t)}return t}}class Lo{constructor(e,t){this.model=e,this.$relationship=t,this.source=e.element(t.source),this.target=e.element(t.target);const r=lt(this.source.id,this.target.id);this.boundary=r?this.model.element(r):null}source;target;boundary;get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return gt(this.$relationship.title)?null:this.$relationship.title}get technology(){return gt(this.$relationship.technology)?null:this.$relationship.technology}get description(){return gt(this.$relationship.description)?null:this.$relationship.description}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get links(){return this.$relationship.links??[]}*views(){for(const e of this.model.views())e.includesRelation(this.id)&&(yield e)}}class Do{constructor(e,t,r,i){this.view=e,this.$edge=t,this.source=r,this.target=i}get id(){return this.$edge.id}get parent(){return this.$edge.parent?this.view.node(this.$edge.parent):null}get label(){return this.$edge.label}get description(){return this.$edge.description??null}get technology(){return this.$edge.technology??null}hasParent(){return this.$edge.parent!==null}get tags(){return this.$edge.tags??[]}get stepNumber(){return this.isStep()?zi(this.id):null}get navigateTo(){return this.$edge.navigateTo?this.view.$model.view(this.$edge.navigateTo):null}isStep(){return Di(this.id)}*relationships(e){for(const t of this.$edge.relations)if(e){const r=this.view.$model.findRelationship(t,e);r&&(yield r)}else yield this.view.$model.relationship(t)}includesRelation(e){return this.$edge.relations.includes(e)}}class zo{constructor(e,t){this.$view=e,this.$node=t}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return this.$node.description}get technology(){return this.$node.technology}get parent(){return this.$node.parent?this.$view.node(this.$node.parent):null}get element(){const e=rt.modelRef(this.$node);return e?this.$view.$model.element(e):null}get deployment(){const e=rt.deploymentRef(this.$node);return e?this.$view.$model.deployment.element(e):null}get shape(){return this.$node.shape}get color(){return this.$node.color}get tags(){return this.$node.tags??[]}get links(){return this.$node.links??[]}get navigateTo(){return this.$node.navigateTo?this.$view.$model.view(this.$node.navigateTo):null}*ancestors(){let e=this.parent;for(;e;)yield e,e=e.parent}*children(){for(const e of this.$node.children)yield this.$view.node(e)}*sublings(){const e=this.parent?.children()??this.$view.roots();for(const t of e)t.id!==this.id&&(yield t)}*incoming(e="all"){for(const t of this.$node.inEdges){const r=this.$view.edge(t);switch(!0){case e==="all":case(e==="direct"&&r.target.id===this.id):case(e==="to-descendants"&&r.target.id!==this.id):yield r;break}}}*incomers(e="all"){const t=new Set;for(const r of this.incoming(e))t.has(r.source.id)||(t.add(r.source.id),yield r.source)}*outgoing(e="all"){for(const t of this.$node.outEdges){const r=this.$view.edge(t);switch(!0){case e==="all":case(e==="direct"&&r.source.id===this.id):case(e==="from-descendants"&&r.source.id!==this.id):yield r;break}}}*outgoers(e="all"){const t=new Set;for(const r of this.outgoing(e))t.has(r.target.id)||(t.add(r.target.id),yield r.target)}isDiagramNode(){return"width"in this.$node&&"height"in this.$node}hasChildren(){return this.$node.children.length>0}hasParent(){return this.$node.parent!==null}hasElement(){return rt.modelRef(this.$node)!==null}hasDeployment(){return rt.deploymentRef(this.$node)!==null}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return rt.isNodesGroup(this.$node)}}class Mo{constructor(e,t){this.$model=e,this.$view=t;for(const r of gr(t.nodes,ci)){const i=new zo(this,Object.freeze(r));this.#t.set(r.id,i),r.parent||this.#e.add(i),i.hasDeployment()&&this.#i.add(i.deployment.id),i.hasElement()&&this.#s.add(i.element.id);for(const a of i.tags)Zn(this.#o,a,()=>new Set).add(i)}for(const r of t.edges){const i=new Do(this,Object.freeze(r),this.node(r.source),this.node(r.target));for(const a of i.tags)Zn(this.#o,a,()=>new Set).add(i);for(const a of r.relations)this.#r.add(a);this.#n.set(r.id,i)}}#e=new Set;#t=new Map;#n=new Map;#s=new Set;#i=new Set;#r=new Set;#o=new Map;get __(){return this.$view.__??"element"}get id(){return this.$view.id}get title(){return this.$view.title}get tags(){return this.$view.tags??[]}get links(){return this.$view.links??[]}get viewOf(){const e=this.$view;return Ci(e)?this.$model.element(e.viewOf):null}get includedTags(){return[...this.#o.keys()]}roots(){return this.#e.values()}*compounds(){for(const e of this.#t.values())e.hasChildren()&&(yield e)}node(e){const t=Ae(e);return ve(this.#t.get(t),`Node ${t} not found in view ${this.$view.id}`)}findNode(e){return this.#t.get(Ae(e))??null}nodes(){return this.#t.values()}edge(e){const t=Ae(e);return ve(this.#n.get(t),`Edge ${t} not found in view ${this.$view.id}`)}findEdge(e){return this.#n.get(Ae(e))??null}edges(){return this.#n.values()}*edgesWithRelation(e){for(const t of this.#n.values())t.includesRelation(e)&&(yield t)}*elements(){for(const e of this.#t.values())e.hasElement()&&(yield e)}includesElement(e){return this.#s.has(e)}includesDeployment(e){return this.#i.has(e)}includesRelation(e){return this.#r.has(e)}isComputed(){return!0}isDiagram(){return"bounds"in this.$view}isElementView(){return tn(this.$view)}isDeploymentView(){return Gi(this.$view)}isDynamicView(){return Oi(this.$view)}}class kt{constructor(e){this.$model=e;for(const r of xt(e.elements)){const i=this.addElement(r);for(const a of i.tags)this.#u.get(a).add(i)}for(const r of xt(e.relations)){const i=this.addRelation(r);for(const a of i.tags)this.#u.get(a).add(i)}this.deployment=new Co(this,e.deployments);const t=J(xt(e.views),gr((r,i)=>vn(r.title??"untitled",i.title??"untitled")));for(const r of t){const i=new Mo(this,Object.freeze(r));this.#a.set(r.id,i);for(const a of i.tags)this.#u.get(a).add(i)}}Aux;#e=new Map;#t=new Map;#n=new Oe(()=>new Set);#s=new Set;#i=new Map;#r=new Oe(()=>new Set);#o=new Oe(()=>new Set);#c=new Oe(()=>new Set);#a=new Map;#u=new Oe(()=>new Set);deployment;static compute(e){let{views:t,...r}=e;const i=new kt({...r,views:{}});return new kt({...r,views:On(t,a=>Oo(a,i))})}static makeCompute(e){let{views:t,...r}=e;const i=new kt(structuredClone({...r,views:{}}));return a=>Nu(a,i)}static create(e){return new kt(e)}static fromDump(e){return new kt(e)}get type(){return this.$model.__??"computed"}element(e){if(e instanceof br)return e;const t=Ae(e);return ve(this.findElement(t),`Element ${Ae(e)} not found`)}findElement(e){return this.#e.get(e)??null}roots(){return this.#s.values()}elements(){return this.#e.values()}relationships(){return this.#i.values()}relationship(e,t){if(t==="deployment")return this.deployment.relationship(e);let r=this.#i.get(e)??null;return r||t==="model"?ve(r,`Model relation ${e} not found`):ve(this.deployment.findRelationship(e),`No model/deployment relation ${e} not found`)}findRelationship(e,t){if(t==="deployment")return this.deployment.findRelationship(e);let r=this.#i.get(e)??null;return r||t==="model"?r:this.deployment.findRelationship(e)}views(){return this.#a.values()}view(e){return ve(this.#a.get(e),`View ${e} not found`)}findView(e){return ve(this.#a.get(e),`View ${e} not found`)}parent(e){const t=Ae(e);return this.#t.get(t)||null}children(e){const t=Ae(e);return this.#n.get(t)}*siblings(e){const t=Ae(e),r=this.#t.get(t),i=r?this.#n.get(r.id).values():this.roots();for(const a of i)a.id!==t&&(yield a)}*ancestors(e){let t=Ae(e),r;for(;r=this.#t.get(t);)yield r,t=r.id}*descendants(e){for(const t of this.children(e))yield t,yield*this.descendants(t.id)}*incoming(e,t="all"){const r=Ae(e);for(const i of this.#r.get(r))switch(!0){case t==="all":case(t==="direct"&&i.target.id===r):case(t==="to-descendants"&&i.target.id!==r):yield i;break}}*outgoing(e,t="all"){const r=Ae(e);for(const i of this.#o.get(r))switch(!0){case t==="all":case(t==="direct"&&i.source.id===r):case(t==="from-descendants"&&i.source.id!==r):yield i;break}}globals(){return{predicates:{...this.$model.globals?.predicates},dynamicPredicates:{...this.$model.globals?.dynamicPredicates},styles:{...this.$model.globals?.styles}}}addElement(e){if(this.#e.has(e.id))throw new Error(`Element ${e.id} already exists`);const t=new br(this,Object.freeze(structuredClone(e)));this.#e.set(t.id,t);const r=at(t.id);return r?(re(this.#e.has(r),`Parent ${r} of ${t.id} not found`),this.#t.set(t.id,this.element(r)),this.#n.get(r).add(t)):this.#s.add(t),t}addRelation(e){if(this.#i.has(e.id))throw new Error(`Relation ${e.id} already exists`);const t=new Lo(this,Object.freeze(structuredClone(e))),{source:r,target:i}=t;this.#i.set(t.id,t),this.#r.get(i.id).add(t),this.#o.get(r.id).add(t);const a=lt(r.id,i.id);if(a)for(const f of[a,...ht(a)])this.#c.get(f).add(t);for(const f of ht(e.source)){if(f===a)break;this.#o.get(f).add(t)}for(const f of ht(e.target)){if(f===a)break;this.#r.get(f).add(t)}return t}}function Tu(n){return n.isInstance()}export{Gr as $,Ma as A,dr as B,Ua as C,Lr as D,Qt as E,Dn as F,ot as G,zi as H,Or as I,ve as J,ws as K,Lo as L,Co as M,ai as N,Ra as O,Mo as P,Ze as Q,ja as R,at as S,Do as T,Zt as U,_i as V,fr as W,Cs as X,Ki as Y,Ie as Z,$r as _,Re as a,xt as a0,js as a1,Nt as a2,to as a3,tn as a4,Qn as a5,Ci as a6,_n as a7,en as a8,Lt as a9,ye as aa,ie as ab,Jn as ac,tr as ad,Rs as ae,Ei as af,xi as ag,Wt as b,lo as c,Cr as d,Dr as e,ao as f,Da as g,rt as h,xn as i,kt as j,vn as k,Be as l,br as m,wt as n,Tt as o,uo as p,Kn as q,Xn as r,Bt as s,lt as t,re as u,hr as v,ui as w,ki as x,ho as y,zo as z};