UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

51 lines 503 kB
/* @license */
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("kendo.data.min.js"),require("kendo.draganddrop.min.js"),require("kendo.userevents.min.js"),require("kendo.mobile.scroller.min.js"),require("kendo.drawing.min.js"),require("kendo.toolbar.min.js"),require("kendo.tooltip.min.js"),require("kendo.editable.min.js"),require("kendo.window.min.js"),require("kendo.dropdownlist.min.js"),require("kendo.dataviz.core.min.js"),require("kendo.dataviz.themes.min.js"),require("kendo.html.button.min.js")):typeof define==`function`&&define.amd?define([`exports`,`kendo.data.min`,`kendo.draganddrop.min`,`kendo.userevents.min`,`kendo.mobile.scroller.min`,`kendo.drawing.min`,`kendo.toolbar.min`,`kendo.tooltip.min`,`kendo.editable.min`,`kendo.window.min`,`kendo.dropdownlist.min`,`kendo.dataviz.core.min`,`kendo.dataviz.themes.min`,`kendo.html.button.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.DatavizDiagram={}),e.kendo._globals.Data,e.kendo._globals.Draganddrop,e.kendo._globals.Userevents,e.kendo._globals.MobileScroller,e.kendo._globals.Drawing,e.kendo._globals.Toolbar,e.kendo._globals.Tooltip,e.kendo._globals.Editable,e.kendo._globals.Window,e.kendo._globals.Dropdownlist,e.kendo._globals.DatavizCore,e.kendo._globals.DatavizThemes,e.kendo._globals.HtmlButton))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var m=Object.defineProperty,h=(e,t)=>{let n={};for(var r in e)m(n,r,{get:e[r],enumerable:!0});return t||m(n,Symbol.toStringTag,{value:`Module`}),n};let g=`transparent`,_=`start`,v=`center`,y=`wrap`,b=`text`,x={none:`none`,arrowStart:`ArrowStart`,filledCircle:`FilledCircle`,arrowEnd:`ArrowEnd`};var S;(function(e){e.None=`none`,e.ArrowStart=`ArrowStart`,e.FilledCircle=`FilledCircle`,e.ArrowEnd=`ArrowEnd`})(S||={});let ee=Math.PI/180,te=`change`,C={arrow:`default`,grip:`pointer`,cross:`pointer`,add:`pointer`,move:`move`,select:`pointer`,south:`s-resize`,east:`e-resize`,west:`w-resize`,north:`n-resize`,rowresize:`row-resize`,colresize:`col-resize`,grabbing:`grabbing`},w=`Auto`,ne=`Right`,re=`Left`,ie=`Bottom`,ae=`dragStart`,oe=`drag`,se=`dragEnd`,ce=`itemRotate`,le=`itemBoundsChange`,ue=`mouseEnter`,de=`mouseLeave`,fe=`zoomStart`,pe=`zoomEnd`,me=`tooltipShow`,he=`tooltipHide`,ge=`rotated`,_e=`source`,ve=`target`,ye={"-1":_e,1:ve},be=`Connection Editing`,xe={left:4,right:4,top:2,bottom:2},Se=9007199254740992,Ce=`select`,we=`none`,Te=Number.MAX_VALUE,Ee=-Number.MAX_VALUE,De=`transformed`,Oe=`k-focus`,ke=`aria-activedescendant`,Ae=`keydown`,je=`mousedown`,Me=`touchstart`,Ne=`pointerdown`,Pe=`focus`,Fe=`blur`,Ie=`ArrowRight`,Le=`ArrowLeft`,Re=`Shape`,ze=`Connection`,Be=`className`,Ve=e=>Math.abs(e)<1e-6,T=e=>e!==void 0,E=T,He=e=>typeof e==`function`,D=e=>e==null,Ue=e=>e===Object(e),We=(e,t)=>Object.hasOwnProperty.call(e,t),O=e=>Object.prototype.toString.call(e)===`[object String]`,Ge=e=>Object.prototype.toString.call(e)===`[object Boolean]`,Ke=(e,t)=>Object.prototype.toString.call(e)===`[object `+t+`]`,qe=e=>!isNaN(parseFloat(e))&&isFinite(e),Je=e=>{if(e===null)return!0;if(Array.isArray(e)||O(e))return e.length===0;for(let t in e)if(We(e,t))return!1;return!0},Ye=(e,t)=>{if(Ue(t))for(let n in t)n&&(e[n]=t[n])},Xe=(e,t)=>{let n=[];for(let r=0;r<e;++r)n[r]=t;return n},Ze=e=>{let t=[];for(let n=0;n<e.length;n++){let r=e[n];t.push(r.x+`;`+r.y)}return t.join(`;`)},Qe=e=>{let t=e.split(`;`),n=[];if(t.length%2!=0)throw Error(`Not an array of points.`);for(let e=0;e<t.length;e+=2)n.push({x:parseInt(t[e],10),y:parseInt(t[e+1],10)});return n},$e=(e,t)=>{let n=Math.floor(Math.random()*t)+e;return parseInt(n.toString(),10)},et=(e,t)=>{if(t(e),e.childNodes)for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n];et(r,t)}},tt=e=>e===null||e.d===0?0:Math.atan2(e.b,e.d)*180/Math.PI,nt=e=>[Math.sqrt(e.a*e.a+e.c*e.c),Math.sqrt(e.b*e.b+e.d*e.d)],rt=(e,t)=>{if(e===t)return 0;let n=t.x-e.x,r=e.y-t.y,i=Math.atan(n/r);return r>=0?n<0?i+2*Math.PI:i:i+Math.PI},it=e=>e?e<0?-1:1:0,at=(e,t)=>rt(e,t)*180/Math.PI,k=(e,t,n)=>{for(let r=0;r<e.length;r++)t.call(n,e[r],r,e)},ot=(e,t)=>{for(let n=0;n<e.length;++n)if(t(e[n]))return e[n];return null},A=(e,t)=>{let n=e.indexOf(t);for(;n!==-1;)e.splice(n,1),n=e.indexOf(t);return e},j=(e,t)=>(e||[]).includes(t),st=(e,t)=>e.indexOf(t),ct=(e,t)=>t.indexOf(e),lt=(e,t)=>e.filter(t),ut=(e,t,n,r)=>{let i=n!==void 0;for(let a=0;a<e.length;a++){let o=e[a];i?n=t.call(r,n,o,a,e):(n=o,i=!0)}if(!i)throw Error(`Reduce of empty array with no initial value`);return n},dt=(e,t,n)=>e.find(t.bind(n))||void 0,ft=(e,t,n)=>e.length===0?null:D(t)?e[0]:dt(e,t,n),pt=(e,t,n)=>(e.splice(n,0,t),e),mt=(e,t,n)=>{let r=!0,i;for(let a=0;a<e.length&&(i=e[a],r&&=t.call(n,i,a,e),r);a++);return r},ht=e=>{e.splice(0,e.length)},gt=(e,t,n)=>{if(D(e))throw Error(`First array is not specified.`);if(D(t))throw Error(`Second array is not specified.`);if(e.length!==t.length)throw Error(`The two arrays should have equal length`);let r=[];for(let n=0;n<e.length;n++)r.push({x:e[n],y:t[n]});D(n)?r.sort((e,t)=>e.x-t.x):r.sort((e,t)=>n(e.x,t.x)),ht(e),ht(t);for(let n=0;n<r.length;n++)e.push(r[n].x),t.push(r[n].y)},_t=(e,t)=>{e.push(...t)},vt=()=>{},yt=`string`,bt=`function`,xt=function(){this._defaultPrevented=!0},St=function(){return this._defaultPrevented===!0};var Ct=class{constructor(){this.options={},this.events=[],this._events={}}destroy(){this.unbind()}bind(e,t,n){if(!t&&Ue(e)&&!Array.isArray(e)){for(let t in e)e[t]&&this.bind(t,e[t]);return this}let r=typeof e==yt?[e]:e,i=typeof t==bt,a,o;for(let e=0,s=r.length;e<s;e++){let s=r[e];o=i?t:t[s],o&&(n&&(a=o,o=(...e)=>{this.unbind(s,o),a.apply(this,e)},o.original=a),this._events[s]=this._events[s]||[],this._events[s].push(o))}return this}one(e,t){return this.bind(e,t,!0)}first(e,t){let n=typeof e==yt?[String(e)]:Array.from(e),r=typeof t==bt,i;for(let e=0,a=n.length;e<a;e++){let a=n[e];i=r?t:t[a],i&&(this._events[a]=this._events[a]||[],this._events[a].unshift(i))}return this}trigger(e,t){let n=this._events[e];if(n){let e=t||{};e.sender=this,e._defaultPrevented=!1,e.preventDefault=xt,e.isDefaultPrevented=St,n=n.slice();for(let t=0,r=n.length;t<r;t++)n[t].call(this,e);return e._defaultPrevented===!0}return!1}unbind(e,t){let n=this._events[e];if(e===void 0)this._events={};else if(n)if(t)for(let e=n.length-1;e>=0;e--)(n[e]===t||n[e].original===t)&&n.splice(e,1);else this._events[e]=[];return this}_setEvents(e){let t=(this.events||[]).length;for(let n=0;n<t;n++){let t=this.events[n];this.options[t]&&e[t]&&(this.unbind(t,this.options[t]),this._events&&this._events[t]&&delete this._events[t])}this.bind(this.events,e)}},wt=h({DFT:()=>et,Observable:()=>Ct,addRange:()=>_t,all:()=>mt,bisort:()=>gt,clear:()=>ht,contains:()=>j,defined:()=>E,deserializePoints:()=>Qe,find:()=>dt,findAngle:()=>at,findRadian:()=>rt,first:()=>ft,fold:()=>ut,forEach:()=>k,getAny:()=>ot,getMatrixAngle:()=>tt,getMatrixScaling:()=>nt,grep:()=>lt,has:()=>We,inArray:()=>ct,indexOf:()=>st,initArray:()=>Xe,insert:()=>pt,isBoolean:()=>Ge,isDefined:()=>T,isEmpty:()=>Je,isFunction:()=>He,isNearZero:()=>Ve,isNumber:()=>qe,isObject:()=>Ue,isString:()=>O,isType:()=>Ke,isUndefined:()=>D,noop:()=>vt,randomInteger:()=>$e,remove:()=>A,serializePoints:()=>Ze,sign:()=>it,simpleExtend:()=>Ye});function Tt(e,t,n){if(e===void 0||t===void 0)return[];if(n&&it(t-e)!==it(n))throw Error(`The sign of the increment should allow to reach the stop-value.`);if(n||=1,e||=0,t||=e,(t-e)/n===1/0)throw Error(`Infinite range defined.`);let r=[],i=-1,a;function o(e){let t=1;for(;e*t%1;)t*=10;return t}let s=o(Math.abs(n));if(e*=s,t*=s,n*=s,e>t&&n>0&&(n=-n),n<0)for(;(a=e+n*++i)>=t;)r.push(a/s);else for(;(a=e+n*++i)<=t;)r.push(a/s);return r}let Et={easeInOut(e){return-Math.cos(e*Math.PI)/2+.5}};var Dt=class{constructor(){this.adapters=[],this.target=0,this.tick=0,this.interval=20,this.duration=800,this.lastTime=null,this.handlers=[],this.timerDelegate=()=>{},this.intervalId=null,this.caller=null,this.timerDelegate=()=>{this.onTimerEvent()}}addAdapter(e){this.adapters.push(e)}onComplete(e){this.handlers.push(e)}removeHandler(e){this.handlers=this.handlers.filter(t=>t!==e)}trigger(){this.handlers&&k(this.handlers,e=>e.call(this.caller===null?this:this.caller))}onStep(){}seekTo(e){this.seekFromTo(this.tick,e)}seekFromTo(e,t){this.target=Math.max(0,Math.min(1,t)),this.tick=Math.max(0,Math.min(1,e)),this.lastTime=new Date().getTime(),this.intervalId||=window.setInterval(this.timerDelegate,this.interval)}stop(){this.intervalId&&(window.clearInterval(this.intervalId),this.intervalId=null,this.trigger())}play(e){this.adapters.length!==0&&(e!==null&&(this.caller=e),this.initState(),this.seekFromTo(0,1))}reverse(){this.seekFromTo(1,0)}initState(){if(this.adapters.length!==0)for(let e=0;e<this.adapters.length;e++)this.adapters[e].initState()}propagate(){let e=Et.easeInOut(this.tick);for(let t=0;t<this.adapters.length;t++)this.adapters[t].update(e)}onTimerEvent(){let e=new Date().getTime(),t=e-this.lastTime;this.lastTime=e;let n=t/this.duration*(this.tick<this.target?1:-1);Math.abs(n)>=Math.abs(this.tick-this.target)?this.tick=this.target:this.tick+=n;try{this.propagate()}finally{this.onStep.call(this),this.target===this.tick&&this.stop()}}};function Ot(e){D(e)&&(e=10);let t=``;for(let n=e;n>0;--n)t+=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`.charAt(Math.round(Math.random()*61));return t}var kt=class e{constructor(){this._buckets={},this.length=0,this._stringsMap=new Map,this._stringsCounter=0}add(e,t){let n=this._createGetBucket(e);return T(t)&&(n.value=t),n}get(e){return this._bucketExists(e)?this._createGetBucket(e):null}set(e,t){this.add(e,t)}containsKey(e){return this._bucketExists(e)}remove(e){if(this._bucketExists(e)){let t=this._hash(e);return delete this._buckets[t],this.length--,e}}forEach(e){let t=this._hashes();for(let n=0,r=t.length;n<r;n++){let r=t[n],i=this._buckets[r];D(i)||e(i)}}clone(){let t=new e,n=this._hashes();for(let e=0,r=n.length;e<r;e++){let r=n[e],i=this._buckets[r];D(i)||t.add(i.key,i.value)}return t}_hashes(){let e=[];for(let t in this._buckets)Object.prototype.hasOwnProperty.call(this._buckets,t)&&e.push(t);return e}_bucketExists(e){let t=this._hash(e);return T(this._buckets[t])}_createGetBucket(e){let t=this._hash(e),n=this._buckets[t];return D(n)&&(n={key:e},this._buckets[t]=n,this.length++),n}_hash(e){if(O(e)||qe(e))return this._hashString(String(e));if(Ue(e))return this._objectHashId(e);throw Error(`Unsupported key type.`)}_hashString(e){let t=0;return e.length===0?t:this._stringsMap.has(e)?this._stringsMap.get(e):(this._stringsCounter++,this._stringsMap.set(e,this._stringsCounter),t=this._stringsCounter,t)}_objectHashId(e){let t=e._hashId;return D(t)&&(t=Ot(),e._hashId=t),t}},M=class extends Ct{constructor(e){if(super(),this._hashTable=new kt,this.length=0,T(e))if(Array.isArray(e))for(let t=0;t<e.length;t++)this.add(e[t]);else e.forEach(function(e,t){this.add(e,t)},this)}add(e,t){let n=this._hashTable.get(e);n||(n=this._hashTable.add(e),this.length++,this.trigger(`changed`)),n.value=t}set(e,t){this.add(e,t)}get(e){let t=this._hashTable.get(e);if(t)return t.value;throw Error(`Cannot find key `+e)}containsKey(e){return this._hashTable.containsKey(e)}remove(e){if(this.containsKey(e))return this.trigger(`changed`),this.length--,this._hashTable.remove(e)}forEach(e,t){this._hashTable.forEach(function(n){e.call(t,n.key,n.value)})}forEachValue(e,t){this._hashTable.forEach(function(n){e.call(t,n.value)})}forEachKey(e,t){this._hashTable.forEach(function(n){e.call(t,n.key)})}keys(){let e=[];return this.forEachKey(function(t){e.push(t)}),e}};let At={_distanceToLineSquared:function(e,t,n){function r(e,t){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)}if(t===n)return r(e,t);let i=n.x-t.x,a=n.y-t.y,o=(e.x-t.x)*i+(e.y-t.y)*a;return o<0?r(t,e):(o=(n.x-e.x)*i+(n.y-e.y)*a,o<0?r(n,e):(o=(n.x-e.x)*a-(n.y-e.y)*i,o*o/(i*i+a*a)))},distanceToLine:function(e,t,n){return Math.sqrt(this._distanceToLineSquared(e,t,n))},distanceToPolyline:function(e,t){let n=Number.MAX_VALUE;if(D(t)||t.length===0)return Number.MAX_VALUE;for(let r=0;r<t.length-1;r++){let i=t[r],a=t[r+1],o=this._distanceToLineSquared(e,i,a);o<n&&(n=o)}return Math.sqrt(n)}};var jt=class{},Mt=class extends jt{constructor(){super(),this._events={}}bind(e,t,n){let r=Pt(e),i=Nt(t),a=r.length;if(t===void 0){for(let t in e)this.bind(t,e[t]);return this}for(let e=0;e<a;e++){let a=r[e],o=i?t:t[a];if(o){if(n){let e=o;o=()=>{this.unbind(a,o),e.apply(this,arguments)},o.original=e}(this._events[a]=this._events[a]||[]).push(o)}}return this}one(e,t){return this.bind(e,t,!0)}first(e,t){let n=Pt(e),r=Nt(t);for(let e=0,i=n.length;e<i;e++){let i=n[e],a=r?t:t[i];a&&(this._events[i]=this._events[i]||[]).unshift(a)}return this}trigger(e,t={}){let n=this._events[e];if(n){let e=n.length;t.sender=this,t._defaultPrevented=!1,t.preventDefault=Ft,t.isDefaultPrevented=It,n=n.slice();for(let r=0;r<e;r++)n[r].call(this,t);return t._defaultPrevented===!0}return!1}unbind(e,t){let n=this._events[e];if(e===void 0)this._events={};else if(n)if(t)for(let e=n.length-1;e>=0;e--)(n[e]===t||n[e].original===t)&&n.splice(e,1);else this._events[e]=[];return this}};function Nt(e){return typeof e==`function`}function Pt(e){return typeof e==`string`?[e]:e}function Ft(){this._defaultPrevented=!0}function It(){return this._defaultPrevented===!0}let Lt=e=>{let t=typeof window<`u`?window:{},n=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)};Lt=e=>n.call(t,e),Lt(e)};var Rt=Lt;let zt=/&/g,Bt=/</g,Vt=/"/g,Ht=/'/g,Ut=/>/g;function Wt(e){return String(e).replace(zt,`&amp;`).replace(Bt,`&lt;`).replace(Ut,`&gt;`).replace(Vt,`&quot;`).replace(Ht,`&#39;`)}function Gt(e){let t=window.console;t!==void 0&&t.log&&t.log(e)}function Kt(e){let t={edge:/(edge)[ \/]([\w.]+)/i,webkit:/(chrome)[ \/]([\w.]+)/i,safari:/(webkit)[ \/]([\w.]+)/i,opera:/(opera)(?:.*version|)[ \/]([\w.]+)/i,msie:/(msie\s|trident.*? rv:)([\w.]+)/i,mozilla:/(mozilla)(?:.*? rv:([\w.]+))/i},n={};for(let r in t)if(t.hasOwnProperty(r)){let i=e.match(t[r]);if(i){n[r]=!0,n[i[1].toLowerCase().split(` `)[0].split(`/`)[0]]=!0,n.version=parseInt(document.documentMode||i[2],10);break}}return n}let qt=null,Jt={get browser(){return typeof window>`u`||qt||(qt=Kt(window.navigator.userAgent)),qt}},Yt=Date.now||function(){return new Date().getTime()};function Xt(e,t){let n=0,r;if(!t||t<=0)return e;let i=function(){let i=Yt()-n,a=arguments,o=function(){e.apply(null,a),n=Yt()};if(!n)return o();r&&clearTimeout(r),i>t?o():r=setTimeout(o,t-i)};return i.cancel=function(){clearTimeout(r)},i}let Zt={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`00ffff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000000`,blanchedalmond:`ffebcd`,blue:`0000ff`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`00ffff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgrey:`a9a9a9`,darkgreen:`006400`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`ff00ff`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,grey:`808080`,green:`008000`,greenyellow:`adff2f`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgrey:`d3d3d3`,lightgreen:`90ee90`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`778899`,lightslategrey:`778899`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`00ff00`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`ff00ff`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370d8`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`d87093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,red:`ff0000`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`ffffff`,whitesmoke:`f5f5f5`,yellow:`ffff00`,yellowgreen:`9acd32`},Qt=Jt.browser,$t=e=>{let t=Object.keys(Zt);t.push(`transparent`);let n=RegExp(`^(`+t.join(`|`)+`)(\\W|$)`,`i`);return $t=e=>n.exec(e),n.exec(e)};var en=class extends jt{constructor(){super()}toHSV(){return this}toRGB(){return this}toHex(e){return this.toBytes().toHex(e)}toBytes(){return this}toCss(e){return`#`+this.toHex(e)}toCssRgba(){let e=this.toBytes();return`rgba(${e.r}, ${e.g}, ${e.b}, ${parseFloat(Number(this.a).toFixed(3))})`}toCssHex(){return this.a===1?`#`+this.toHex():`#`+this.toHex({alpha:!0})}toDisplay(){return Qt.msie&&Qt.version<9?this.toCss():this.toCssRgba()}equals(e){return e===this||e!=null&&this.toCssRgba()===ln(e).toCssRgba()}diff(e){if(e===null)return NaN;let t=this.toBytes(),n=e.toBytes();return Math.sqrt(((t.r-n.r)*.3)**2+((t.g-n.g)*.59)**2+((t.b-n.b)*.11)**2)}clone(){let e=this.toBytes();return e===this&&(e=new nn(e.r,e.g,e.b,e.a)),e}},tn=class extends en{constructor(e,t,n,r){super(),this.r=e,this.g=t,this.b=n,this.a=r}toHSV(){let{r:e,g:t,b:n}=this,r=Math.min(e,t,n),i=Math.max(e,t,n),a=i-r,o=i,s,c;return a===0?new an(0,0,o,this.a):(i===0?(c=0,s=-1):(c=a/i,s=e===i?(t-n)/a:t===i?2+(n-e)/a:4+(e-t)/a,s*=60,s<0&&(s+=360)),new an(s,c,o,this.a))}toHSL(){let{r:e,g:t,b:n}=this,r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=(r+i)/2;if(r===i)a=o=0;else{let c=r-i;switch(o=s>.5?c/(2-r-i):c/(r+i),r){case e:a=(t-n)/c+(t<n?6:0);break;case t:a=(n-e)/c+2;break;case n:a=(e-t)/c+4;break;default:break}}return new on(a*60,o*100,s*100,this.a)}toBytes(){return new nn(this.r*255,this.g*255,this.b*255,this.a)}},nn=class extends tn{constructor(e,t,n,r){super(Math.round(e),Math.round(t),Math.round(n),r)}toRGB(){return new tn(this.r/255,this.g/255,this.b/255,this.a)}toHSV(){return this.toRGB().toHSV()}toHSL(){return this.toRGB().toHSL()}toHex(e){let t=rn(this.r,2)+rn(this.g,2)+rn(this.b,2);return e&&e.alpha&&(t+=rn(Math.round(this.a*255),2)),t}toBytes(){return this}};function rn(e,t,n=`0`){let r=e.toString(16);for(;t>r.length;)r=n+r;return r}var an=class extends en{constructor(e,t,n,r){super(),this.h=e,this.s=t,this.v=n,this.a=r}toRGB(){let{h:e,s:t,v:n}=this,r,i,a;if(t===0)r=i=a=n;else{e/=60;let o=Math.floor(e),s=e-o,c=n*(1-t),l=n*(1-t*s),u=n*(1-t*(1-s));switch(o){case 0:r=n,i=u,a=c;break;case 1:r=l,i=n,a=c;break;case 2:r=c,i=n,a=u;break;case 3:r=c,i=l,a=n;break;case 4:r=u,i=c,a=n;break;default:r=n,i=c,a=l;break}}return new tn(r,i,a,this.a)}toHSL(){return this.toRGB().toHSL()}toBytes(){return this.toRGB().toBytes()}},on=class extends en{constructor(e,t,n,r){super(),this.h=e,this.s=t,this.l=n,this.a=r}toRGB(){let e=this.h/360,t=this.s/100,n=this.l/100,r,i,a;if(t===0)r=i=a=n;else{let o=n<.5?n*(1+t):n+t-n*t,s=2*n-o;r=sn(s,o,e+1/3),i=sn(s,o,e),a=sn(s,o,e-1/3)}return new tn(r,i,a,this.a)}toHSV(){return this.toRGB().toHSV()}toBytes(){return this.toRGB().toBytes()}};function sn(e,t,n){let r=n;return r<0&&(r+=1),r>1&&--r,r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e}function cn(e){return parseFloat(parseFloat(parseInt(e,16)/255).toFixed(3))}function ln(e,t){let n,r;if(!e||e===`none`)return null;if(e instanceof en)return e;let i=e.toLowerCase();if(n=$t(i))return i=n[1]===`transparent`?new tn(1,1,1,0):ln(Zt[n[1]],t),i.match=[n[1]],i;if((n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})\b/i.exec(i))?r=new nn(parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16),1):(n=/^#?([0-9a-f])([0-9a-f])([0-9a-f])\b/i.exec(i))?r=new nn(parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16),1):(n=/^#?([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])\b/i.exec(i))?r=new nn(parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16),cn(n[4]+n[4])):(n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})\b/i.exec(i))?r=new nn(parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16),cn(n[4])):(n=/^rgb\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/.exec(i))?r=new nn(parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3],10),1):(n=/^rgba\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9.]+)\s*\)/.exec(i))?r=new nn(parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3],10),parseFloat(n[4])):(n=/^rgb\(\s*([0-9]*\.?[0-9]+)%\s*,\s*([0-9]*\.?[0-9]+)%\s*,\s*([0-9]*\.?[0-9]+)%\s*\)/.exec(i))?r=new tn(parseFloat(n[1])/100,parseFloat(n[2])/100,parseFloat(n[3])/100,1):(n=/^rgba\(\s*([0-9]*\.?[0-9]+)%\s*,\s*([0-9]*\.?[0-9]+)%\s*,\s*([0-9]*\.?[0-9]+)%\s*,\s*([0-9.]+)\s*\)/.exec(i))?r=new tn(parseFloat(n[1])/100,parseFloat(n[2])/100,parseFloat(n[3])/100,parseFloat(n[4])):(n=/^color\(\s*srgb\s*([0-9]*\.?[0-9]+)\s+([0-9]*\.?[0-9]+)\s+([0-9]*\.?[0-9]+)\s*(\/\s+([0-9]*\.?[0-9]+))?\)/.exec(i))&&(r=new tn(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]),parseFloat(n[5]||`1`))),r)r.match=n;else if(!t)throw Error(`Cannot parse color: `+i);return r}var un=class e extends jt{constructor(t){if(super(),arguments.length===1){let n=e.formats,r=this.resolveColor(t);for(let e=0;e<n.length;e++){let t=n[e].re,i=n[e].process,a=t.exec(r);if(a){let e=i(a);this.r=e[0],this.g=e[1],this.b=e[2]}}}else this.r=arguments[0],this.g=arguments[1],this.b=arguments[2];this.r=this.normalizeByte(this.r),this.g=this.normalizeByte(this.g),this.b=this.normalizeByte(this.b)}toHex(){let e=this.padDigit,t=this.r.toString(16),n=this.g.toString(16),r=this.b.toString(16);return`#`+e(t)+e(n)+e(r)}resolveColor(t){let n=t||`black`;return n.charAt(0)===`#`&&(n=n.substr(1,6)),n=n.replace(/ /g,``),n=n.toLowerCase(),n=e.namedColors[n]||n,n}normalizeByte(e){return e<0||isNaN(e)?0:e>255?255:e}padDigit(e){return e.length===1?`0`+e:e}brightness(e){let t=Math.round;return this.r=t(this.normalizeByte(this.r*e)),this.g=t(this.normalizeByte(this.g*e)),this.b=t(this.normalizeByte(this.b*e)),this}percBrightness(){return Math.sqrt(.241*this.r*this.r+.691*this.g*this.g+.068*this.b*this.b)}isDark(){return this.percBrightness()<180}static fromBytes(e,t,n,r){return new nn(e,t,n,r??1)}static fromRGB(e,t,n,r){return new tn(e,t,n,r??1)}static fromHSV(e,t,n,r){return new an(e,t,n,r??1)}static fromHSL(e,t,n,r){return new on(e,t,n,r??1)}};un.formats=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,process:function(e){return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10)]}},{re:/^(\w{2})(\w{2})(\w{2})$/,process:function(e){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,process:function(e){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}}],un.namedColors=Zt;let dn=e=>e.ownerDocument.defaultView.getComputedStyle(e),fn=(e,t)=>{let n=document.createElement(`div`);e.parentElement?e.parentElement.appendChild(n):e.appendChild(n),n.style.color=`rgb(from ${t} clamp(0, r, 255) clamp(0, g, 255) clamp(0, b, 255))`;let r=ln(dn(n).color,!0);return n.remove(),r?r.toCssHex():`#000000`};function pn(e,t){let n=dn(e).getPropertyValue(t),r=ln(n,!0);return r?r.toCssHex():fn(e,n)}var mn=class extends jt{observers(){return this._observers=this._observers||[],this._observers}addObserver(e){return this._observers?this._observers.push(e):this._observers=[e],this}removeObserver(e){let t=this.observers(),n=t.indexOf(e);return n!==-1&&t.splice(n,1),this}trigger(e,t){let n=this._observers;if(n&&!this._suspended)for(let r=0;r<n.length;r++){let i=n[r];i[e]&&i[e](t)}return this}optionsChange(e={}){e.element=this,this.trigger(`optionsChange`,e)}geometryChange(){this.trigger(`geometryChange`,{element:this})}suspend(){return this._suspended=(this._suspended||0)+1,this}resume(){return this._suspended=Math.max((this._suspended||0)-1,0),this}_observerField(e,t){this[e]&&this[e].removeObserver(this),this[e]=t,t.addObserver(this)}};let hn={}.toString;var gn=class e extends mn{constructor(e,t=``){super(),this.prefix=t;for(let t in e){let n=e[t];n=this._wrap(n,t),this[t]=n}}get(e){let t=e.split(`.`),n=this;for(;t.length&&n;){let e=t.shift();n=n[e]}return n}set(e,t){this.get(e)!==t&&(this._set(e,this._wrap(t,e)),this.optionsChange({field:this.prefix+e,value:t}))}_set(t,n){let r=t.indexOf(`.`)>=0,i=this,a=t;if(r){let t=a.split(`.`),n=this.prefix;for(;t.length>1;){a=t.shift(),n+=a+`.`;let r=i[a];r||(r=new e({},n),r.addObserver(this),i[a]=r),i=r}a=t[0]}i._clear(a),i[a]=n}_clear(e){let t=this[e];t&&t.removeObserver&&t.removeObserver(this)}_wrap(t,n){let r=hn.call(t),i=t;return i!=null&&r===`[object Object]`&&(!(t instanceof e)&&!(t instanceof jt)&&(i=new e(i,this.prefix+n+`.`)),i.addObserver(this)),i}};function _n(e){return function(t){return this[e]!==t&&(this[e]=t,this.geometryChange()),this}}function vn(e){return function(){return this[e]}}function yn(e,t){for(let n=0;n<t.length;n++){let r=t[n],i=r.charAt(0).toUpperCase()+r.substring(1,r.length);e[`set`+i]=_n(r),e[`get`+i]=vn(r)}}let bn=(e,t)=>{let n=class extends e{};return yn(n.prototype,t),n};function xn(e,t){return e.push.apply(e,t),e}let Sn={1:`i`,10:`x`,100:`c`,2:`ii`,20:`xx`,200:`cc`,3:`iii`,30:`xxx`,300:`ccc`,4:`iv`,40:`xl`,400:`cd`,5:`v`,50:`l`,500:`d`,6:`vi`,60:`lx`,600:`dc`,7:`vii`,70:`lxx`,700:`dcc`,8:`viii`,80:`lxxx`,800:`dccc`,9:`ix`,90:`xc`,900:`cm`,1e3:`m`};function Cn(e){let t=[1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],n=``;for(;e>0;)e<t[0]?t.shift():(n+=Sn[t[0]],e-=t[0]);return n}function wn(){let e,t,n=new Promise((r,i)=>{e=e=>(n._state=`resolved`,r(e),n),t=e=>(n._state=`rejected`,i(e),n)});return n._state=`pending`,n.resolve=e,n.reject=t,n.state=()=>n._state,n}let Tn=1;function En(){return`kdef`+Tn++}let Dn=Math.PI/180,On=Number.MAX_VALUE,kn=-Number.MAX_VALUE;function An(e){return e/Dn}let jn=String.fromCharCode;function Mn(e){let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(55296<=r&&r<=56319){let t=r,i=e.charCodeAt(++n);isNaN(i)||(r=(t-55296)*1024+(i-56320)+65536)}r<128?t+=jn(r):r<2048?(t+=jn(192|r>>>6),t+=jn(128|r&63)):r<65536?(t+=jn(224|r>>>12),t+=jn(128|r>>>6&63),t+=jn(128|r&63)):r<1114111&&(t+=jn(240|r>>>18),t+=jn(128|r>>>12&63),t+=jn(128|r>>>6&63),t+=jn(128|r&63))}return t}function Nn(e){return jn(e>>8)+jn(e&255)}function Pn(e){let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<65535)t+=Nn(r);else{let e=(r-65536>>10)+55296,n=(r-65536&1023)+56320;t+=Nn(e),t+=Nn(n)}}return t}let Fn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`;function In(e){let t=``,n=0,r=Mn(e);for(;n<r.length;){let e=r.charCodeAt(n++),i=r.charCodeAt(n++),a=r.charCodeAt(n++),o=e>>2,s=(e&3)<<4|i>>4,c=(i&15)<<2|a>>6,l=a&63;isNaN(i)?c=l=64:isNaN(a)&&(l=64),t=t+Fn.charAt(o)+Fn.charAt(s)+Fn.charAt(c)+Fn.charAt(l)}return t}function Ln(e){return(e.x||{}).location===void 0?{x:e.pageX||e.clientX||0,y:e.pageY||e.clientY||0}:{x:e.x.location,y:e.y.location}}function Rn(e={}){return e.touch?e.touch.initialTouch:e.target}function zn(e){return e===``||e===null||e===`none`||e===`transparent`||e===void 0}function Bn(e){if(e)return e[e.length-1]}function Vn(e,t,n){return Math.max(Math.min(e,n),t)}function Hn(e,t){if(e.length<2)return e.slice();function n(e,n){for(var r=[],i=0,a=0,o=0;i<e.length&&a<n.length;)t(e[i],n[a])<=0?r[o++]=e[i++]:r[o++]=n[a++];return i<e.length&&r.push.apply(r,e.slice(i)),a<n.length&&r.push.apply(r,n.slice(a)),r}return(function e(t){if(t.length<=1)return t;var r=Math.floor(t.length/2),i=t.slice(0,r),a=t.slice(r);return i=e(i),a=e(a),n(i,a)})(e)}function Un(e){return Promise.all(e)}function Wn(e){return e*Dn}function Gn(e){return e?10**e:1}function N(e,t){let n=Gn(t);return Math.round(e*n)/n}function Kn(e,t){return e===void 0?t:e}function qn(e,t){for(let n in t){let r=n.trim().split(` `);for(let i=0;i<r.length;i++)e.addEventListener(r[i],t[n],!1)}}function Jn(e){let t=e.getBoundingClientRect(),n=document.documentElement;return{top:t.top+(window.pageYOffset||n.scrollTop)-(n.clientTop||0),left:t.left+(window.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}}function Yn(e,t){let n={},r=window.getComputedStyle(e)||{},i=Array.isArray(t)?t:[t];for(let e=0;e<i.length;e++){let t=i[e];n[t]=r[t]}return n}function Xn(e){return isNaN(e)?e:e+`px`}function Zn(e,t){if(t){let{width:n,height:r}=t;n!==void 0&&(e.style.width=Xn(n)),r!==void 0&&(e.style.height=Xn(r))}else{let t=Yn(e,[`width`,`height`]);return{width:parseInt(t.width,10),height:parseInt(t.height,10)}}}function Qn(e,t={}){for(let n in t){let r=n.trim().split(` `);for(let i=0;i<r.length;i++)e.removeEventListener(r[i],t[n],!1)}}function $n(e){let{paddingLeft:t,paddingTop:n}=Yn(e,[`paddingLeft`,`paddingTop`]);return{top:parseFloat(n),left:parseFloat(t)}}var er=class e extends jt{constructor(e=0,t=0,n=0,r=0,i=0,a=0){super(),this.a=e,this.b=t,this.c=n,this.d=r,this.e=i,this.f=a}multiplyCopy(t){return new e(this.a*t.a+this.c*t.b,this.b*t.a+this.d*t.b,this.a*t.c+this.c*t.d,this.b*t.c+this.d*t.d,this.a*t.e+this.c*t.f+this.e,this.b*t.e+this.d*t.f+this.f)}invert(){let{a:t,b:n,c:r,d:i,e:a,f:o}=this,s=t*i-n*r;return s===0?null:new e(i/s,-n/s,-r/s,t/s,(r*o-i*a)/s,(n*a-t*o)/s)}clone(){return new e(this.a,this.b,this.c,this.d,this.e,this.f)}equals(e){return e?this.a===e.a&&this.b===e.b&&this.c===e.c&&this.d===e.d&&this.e===e.e&&this.f===e.f:!1}round(e){return this.a=N(this.a,e),this.b=N(this.b,e),this.c=N(this.c,e),this.d=N(this.d,e),this.e=N(this.e,e),this.f=N(this.f,e),this}toArray(e){let t=[this.a,this.b,this.c,this.d,this.e,this.f];if(e!==void 0)for(let n=0;n<t.length;n++)t[n]=N(t[n],e);return t}toString(e,t=`,`){return this.toArray(e).join(t)}static translate(t,n){return new e(1,0,0,1,t,n)}static unit(){return new e(1,0,0,1,0,0)}static rotate(t,n,r){let i=new e;return i.a=Math.cos(Wn(t)),i.b=Math.sin(Wn(t)),i.c=-i.b,i.d=i.a,i.e=n-n*i.a+r*i.b||0,i.f=r-r*i.a-n*i.b||0,i}static scale(t,n){return new e(t,0,0,n,0,0)}};er.IDENTITY=er.unit();let tr=/matrix\((.*)\)/;function nr(e){let t=e.match(tr);return t===null||t.length!==2?er.unit():new er(...t[1].split(`,`).map(e=>parseFloat(e)))}function rr(e){let t=getComputedStyle(e).transform;return t===`none`?er.unit():nr(t)}function ir(e){if(!e)return er.unit();let t=rr(e),n=e.parentElement;for(;n;){let e=rr(n);t=t.multiplyCopy(e),n=n.parentElement}return t.b=t.c=t.e=t.f=0,t}var ar=class extends jt{constructor(e){super(),this._size=e,this._length=0,this._map={}}put(e,t){let n=this._map,r={key:e,value:t};n[e]=r,this._head?(this._tail.newer=r,r.older=this._tail,this._tail=r):this._head=this._tail=r,this._length>=this._size?(n[this._head.key]=null,this._head=this._head.newer,this._head.older=null):this._length++}get(e){let t=this._map[e];if(t)return t===this._head&&t!==this._tail&&(this._head=t.newer,this._head.older=null),t!==this._tail&&(t.older&&(t.older.newer=t.newer,t.newer.older=t.older),t.older=this._tail,t.newer=null,this._tail.newer=t,this._tail=t),t.value}};let or=/\r?\n|\r|\t/g;function sr(e){return String(e).replace(or,` `)}function cr(e){let t=[];for(let n in e)t.push(n+e[n]);return t.sort().join(``)}function lr(e){let t=2166136261;for(let n=0;n<e.length;++n)t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24),t^=e.charCodeAt(n);return t>>>0}function ur(){return{width:0,height:0,baseline:0}}let dr={baselineMarkerSize:1},fr;typeof document<`u`&&(fr=document.createElement(`div`),fr.style.setProperty(`position`,`absolute`,`important`),fr.style.setProperty(`top`,`-4000px`,`important`),fr.style.setProperty(`width`,`auto`,`important`),fr.style.setProperty(`height`,`auto`,`important`),fr.style.setProperty(`padding`,`0`,`important`),fr.style.setProperty(`margin`,`0`,`important`),fr.style.setProperty(`border`,`0`,`important`),fr.style.setProperty(`line-height`,`normal`,`important`),fr.style.setProperty(`visibility`,`hidden`,`important`),fr.style.setProperty(`white-space`,`pre`,`important`));var pr=class extends jt{constructor(e){super(),this._cache=new ar(1e3),this.options=Object.assign({},dr,e)}measure(e,t,n={}){if(e==null)return ur();let r=lr(e+cr(t)),i=this._cache.get(r);if(i)return i;let a=ur(),o=n.box||fr,s=this._baselineMarker().cloneNode(!1);for(let e in t){let n=t[e];n!==void 0&&(o.style[e]=n)}let c=n.normalizeText===!1?String(e):sr(e);return o.textContent=c,o.appendChild(s),document.body.appendChild(o),c.length&&(a.width=o.offsetWidth-this.options.baselineMarkerSize,a.height=o.offsetHeight,a.baseline=s.offsetTop+this.options.baselineMarkerSize),a.width>0&&a.height>0&&this._cache.put(r,a),o.parentNode.removeChild(o),a}_baselineMarker(){let e=document.createElement(`div`);return e.style.display=`inline-block`,e.style.verticalAlign=`baseline`,e.style.width=this.options.baselineMarkerSize+`px`,e.style.height=this.options.baselineMarkerSize+`px`,e.style.overflow=`hidden`,e}};pr.current=new pr;function mr(e,t,n){return pr.current.measure(e,t,n)}let hr=()=>typeof window<`u`,gr={wp:/(Windows Phone(?: OS)?)\s(\d+)\.(\d+(\.\d+)?)/,fire:/(Silk)\/(\d+)\.(\d+(\.\d+)?)/,android:/(Android|Android.*(?:Opera|Firefox).*?\/)\s*(\d+)(\.(\d+(\.\d+)?))?/,iphone:/(iPhone|iPod).*OS\s+(\d+)[\._]([\d\._]+)/,ipad:/(iPad).*OS\s+(\d+)[\._]([\d_]+)/,meego:/(MeeGo).+NokiaBrowser\/(\d+)\.([\d\._]+)/,webos:/(webOS)\/(\d+)\.(\d+(\.\d+)?)/,blackberry:/(BlackBerry|BB10).*?Version\/(\d+)\.(\d+(\.\d+)?)/,playbook:/(PlayBook).*?Tablet\s*OS\s*(\d+)\.(\d+(\.\d+)?)/,windows:/(MSIE)\s+(\d+)\.(\d+(\.\d+)?)/,tizen:/(tizen).*?Version\/(\d+)\.(\d+(\.\d+)?)/i,sailfish:/(sailfish).*rv:(\d+)\.(\d+(\.\d+)?).*firefox/i,ffos:/(Mobile).*rv:(\d+)\.(\d+(\.\d+)?).*Firefox/},_r={ios:/^i(phone|pad|pod)$/i,android:/^android|fire$/i,blackberry:/^blackberry|playbook/i,windows:/windows/,wp:/wp/,flat:/sailfish|ffos|tizen/i,meego:/meego/},vr={edge:/(edge)[ \/]([\w.]+)/i,webkit:/(chrome)[ \/]([\w.]+)/i,safari:/(webkit)[ \/]([\w.]+)/i,opera:/(opera)(?:.*version|)[ \/]([\w.]+)/i,msie:/(msie\s|trident.*? rv:)([\w.]+)/i,mozilla:/(mozilla)(?:.*? rv:([\w.]+)|)/i},yr={omini:/Opera\sMini/i,omobile:/Opera\sMobi/i,firefox:/Firefox|Fennec/i,mobilesafari:/version\/.*safari/i,ie:/MSIE|Windows\sPhone/i,chrome:/chrome|crios/i,webkit:/webkit/i},br=(e,t,n)=>{for(let n in t)if(t.hasOwnProperty(n)&&t[n].test(e))return n;return n===void 0?e:n},xr=e=>{let t,n=[];for(let r in gr)if(gr.hasOwnProperty(r)){if(n=e.match(gr[r]),!n)continue;if(r===`windows`&&`plugins`in window.navigator)return null;let i={};return i.device=r,i.browser=br(e,yr,`default`),i.name=br(r,_r),i[i.name]=!0,i.majorVersion=n[2],i.minorVersion=n[3]?n[3].replace(`_`,`.`):`.0`,t=i.minorVersion.replace(`.`,``).substr(0,2),i.flatVersion=i.majorVersion+t+Array(3-(t.length<3?t.length:2)).join(`0`),i.cordova=!0,i.appMode=window.navigator.standalone||/file|local|wmapp/.test(window.location.protocol)||i.cordova,i}return null},Sr=e=>{let t=null,n=[];for(let r in vr)if(vr.hasOwnProperty(r)&&(n=e.match(vr[r]),n)){t={},t[r]=!0,t[n[1].toLowerCase().split(` `)[0].split(`/`)[0]]=!0,t.version=parseInt(document.documentMode||n[2],10);break}return t},Cr=hr()&&window.navigator?window.navigator.userAgent:null,wr=Cr?Sr(Cr):null,Tr=Cr?xr(Cr):null;hr()&&`ontouchstart`in window,wr&&!wr.chrome&&window.MSPointerEvent,wr&&!wr.chrome&&window.PointerEvent;let Er={};Er.undefined=e=>e;let Dr={};Dr.undefined=e=>e;let Or=/\/\*[\s\S]*?\*\//g,kr=/([^\s:;]+?)\s*:\s*((?:(?:url\(\s*(?:(?:[^"')\\]|\\.)*|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*\)|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^;"'])*?)\s*)(?=;|$)/gi,Ar=/&quot;|&#34;|&#x22;/gi,jr=/&apos;|&#39;|&#x27;/gi;function Mr(e){return e.replace(Ar,`"`).replace(jr,`'`)}function Nr(e){let t={},n=Mr((e||``).replace(Or,``)),r=kr.exec(n),i,a;for(;r!==null;)i=r[1].trim(),a=r[2].trim(),t[i]=a,r=kr.exec(n);return t}let Pr=(e,t)=>{let n=Nr(t);Object.keys(n).forEach(t=>{e.style[t]=n[t]})},Fr=`data-style`,Ir=e=>(e||``).replace(/\sstyle=/g,` data-style=`),Lr=e=>{Array.from(e.querySelectorAll(`[data-style]`)).forEach(e=>{let t=e.getAttribute(Fr);e.removeAttribute(Fr),Pr(e,t)})},Rr=(e,t)=>{e.innerHTML=Ir(t),Lr(e)},zr=(e,t)=>{let n=document.createElement(`div`);Rr(n,t),n.firstElementChild&&e.insertBefore(n.firstElementChild,e.firstChild)};function Br(e){return e&&typeof e.matrix==`function`?e.matrix():e}var P=class e extends bn(mn,[`x`,`y`]){constructor(e,t){super(),this.x=e||0,this.y=t||0}equals(e){return e&&e.x===this.x&&e.y===this.y}clone(){return new e(this.x,this.y)}rotate(t,n){let r=e.create(n)||e.ZERO;return this.transform(er.rotate(t,r.x,r.y))}translate(e,t){return this.x+=e,this.y+=t,this.geometryChange(),this}translateWith(e){return this.translate(e.x,e.y)}move(e,t){return this.x=this.y=0,this.translate(e,t)}scale(e,t=e){return this.x*=e,this.y*=t,this.geometryChange(),this}scaleCopy(e,t){return this.clone().scale(e,t)}transform(e){let t=Br(e),{x:n,y:r}=this;return this.x=t.a*n+t.c*r+t.e,this.y=t.b*n+t.d*r+t.f,this.geometryChange(),this}transformCopy(e){let t=this.clone();return e&&t.transform(e),t}distanceTo(e){let t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}round(e){return this.x=N(this.x,e),this.y=N(this.y,e),this.geometryChange(),this}toArray(e){let t=e!==void 0;return[t?N(this.x,e):this.x,t?N(this.y,e):this.y]}toString(e,t=` `){let{x:n,y:r}=this;return e!==void 0&&(n=N(n,e),r=N(r,e)),n+t+r}static create(t,n){if(t!==void 0)return t instanceof e?t:arguments.length===1&&t.length===2?new e(t[0],t[1]):new e(t,n)}static min(){let t=On,n=On;for(let e=0;e<arguments.length;e++){let r=arguments[e];t=Math.min(r.x,t),n=Math.min(r.y,n)}return new e(t,n)}static max(){let t=kn,n=kn;for(let e=0;e<arguments.length;e++){let r=arguments[e];t=Math.max(r.x,t),n=Math.max(r.y,n)}return new e(t,n)}static minPoint(){return new e(kn,kn)}static maxPoint(){return new e(On,On)}static get ZERO(){return new e(0,0)}},Vr=class e extends bn(mn,[`width`,`height`]){constructor(e,t){super(),this.width=e||0,this.height=t||0}equals(e){return e&&e.width===this.width&&e.height===this.height}clone(){return new e(this.width,this.height)}toArray(e){let t=e!==void 0;return[t?N(this.width,e):this.width,t?N(this.height,e):this.height]}static create(t,n){if(t!==void 0)return t instanceof e?t:arguments.length===1&&t.length===2?new e(t[0],t[1]):new e(t,n)}static get ZERO(){return new e(0,0)}},F=class e extends mn{constructor(e=new P,t=new Vr,n=0){super(),this.setOrigin(e),this.setSize(t),this.setCornerRadius(n)}clone(){return new e(this.origin.clone(),this.size.clone())}equals(e){return e&&e.origin.equals(this.origin)&&e.size.equals(this.size)}setOrigin(e){return this._observerField(`origin`,P.create(e)),this.geometryChange(),this}getOrigin(){return this.origin}setCornerRadius(e){return this.cornerRadius=Array.isArray(e)?e:[e,e],this.geometryChange(),this}getCornerRadius(){return this.cornerRadius}setSize(e){return this._observerField(`size`,Vr.create(e)),this.geometryChange(),this}getSize(){return this.size}width(){return this.size.width}height(){return this.size.height}topLeft(){return this.origin.clone()}bottomRight(){return this.origin.clone().translate(this.width(),this.height())}topRight(){return this.origin.clone().translate(this.width(),0)}bottomLeft(){return this.origin.clone().translate(0,this.height())}center(){return this.origin.clone().translate(this.width()/2,this.height()/2)}bbox(t){let n=this.topLeft().transformCopy(t),r=this.topRight().transformCopy(t),i=this.bottomRight().transformCopy(t),a=this.bottomLeft().transformCopy(t);return e.fromPoints(n,r,i,a)}transformCopy(t){return e.fromPoints(this.topLeft().transform(t),this.bottomRight().transform(t))}expand(e,t=e){return this.size.width+=2*e,this.size.height+=2*t,this.origin.translate(-e,-t),this}expandCopy(e,t){return this.clone().expand(e,t)}containsPoint(e){let t=this.origin,n=this.bottomRight();return!(e.x<t.x||e.y<t.y||n.x<e.x||n.y<e.y)}_isOnPath(e,t){let n=this.expandCopy(t,t),r=this.expandCopy(-t,-t);return n.containsPoint(e)&&!r.containsPoint(e)}static fromPoints(){let t=P.min.apply(null,arguments),n=P.max.apply(null,arguments),r=new Vr(n.x-t.x,n.y-t.y);return new e(t,r)}static union(t,n){return e.fromPoints(P.min(t.topLeft(),n.topLeft()),P.max(t.bottomRight(),n.bottomRight()))}static intersect(t,n){let r={left:t.topLeft().x,top:t.topLeft().y,right:t.bottomRight().x,bottom:t.bottomRight().y},i={left:n.topLeft().x,top:n.topLeft().y,right:n.bottomRight().x,bottom:n.bottomRight().y};if(r.left<=i.right&&i.left<=r.right&&r.top<=i.bottom&&i.top<=r.bottom)return e.fromPoints(new P(Math.max(r.left,i.left),Math.max(r.top,i.top)),new P(Math.min(r.right,i.right),Math.min(r.bottom,i.bottom)))}},Hr=class e extends mn{constructor(e=er.unit()){super(),this._matrix=e}clone(){return new e(this._matrix.clone())}equals(e){return e&&e._matrix.equals(this._matrix)}translate(e,t){return this._matrix=this._matrix.multiplyCopy(er.translate(e,t)),this._optionsChange(),this}scale(e,t=e,n=null){let r=n;return r&&(r=P.create(r),this._matrix=this._matrix.multiplyCopy(er.translate(r.x,r.y))),this._matrix=this._matrix.multiplyCopy(er.scale(e,t)),r&&(this._matrix=this._matrix.multiplyCopy(er.translate(-r.x,-r.y))),this._optionsChange(),this}rotate(e,t){let n=P.create(t)||P.ZERO;return this._matrix=this._matrix.multiplyCopy(er.rotate(e,n.x,n.y)),this._optionsChange(),this}multiply(e){let t=Br(e);return this._matrix=this._matrix.multiplyCopy(t),this._optionsChange(),this}matrix(e){return e?(this._matrix=e,this._optionsChange(),this):this._matrix}_optionsChange(){this.optionsChange({field:`transform`,value:this})}};function Ur(e){return e===null?null:e instanceof Hr?e:new Hr(e)}let Wr={dot:[1.5,3.5],dash:[4,3.5],longdash:[8,3.5],dashdot:[3.5,3.5,1.5,3.5],longdashdot:[8,3.5,1.5,3.5],longdashdotdot:[8,3.5,1.5,3.5,1.5,3.5]},Gr=`butt`;var Kr=class extends mn{get nodeType(){return`Rect`}constructor(e){super(),this._initOptions(e)}_initOptions(e={}){let{clip:t,transform:n}=e;n&&(e.transform=Ur(n)),t&&!t.id&&(t.id=En()),this.options=new gn(e),this.options.addObserver(this)}transform(e){if(e!==void 0)this.options.set(`transform`,Ur(e));else return this.options.get(`transform`)}parentTransform(){let e=this,t;for(;e.parent;){e=e.parent;let n=e.transform();n&&(t=n.matrix().multiplyCopy(t||er.unit()))}if(t)return Ur(t)}currentTransform(e=this.parentTransform()){let t=Br(this.transform()),n=Br(e),r;if(r=t&&n?n.multiplyCopy(t):t||n,r)return Ur(r)}visible(e){return e===void 0?this.options.get(`visible`)!==!1:(this.options.set(`visible`,e),this)}clip(e){let t=this.options;return e===void 0?t.get(`clip`):(e&&!e.id&&(e.id=En()),t.set(`clip`,e),this)}opacity(e){return e===void 0?Kn(this.options.get(`opacity`),1):(this.options.set(`opacity`,e),this)}className(e){return e===void 0?this.options.get(`className`):(this.options.set(`className`,e),this)}clippedBBox(e){let t=this._clippedBBox(e);if(t){let n=this.clip();return n?F.intersect(t,n.bbox(e)):t}}containsPoint(e,t){if(this.visible()){let n=this.currentTransform(t),r=e;return n&&(r=e.transformCopy(n.matrix().invert())),this._hasFill()&&this._containsPoint(r)||this._isOnPath&&this._hasStroke()&&this._isOnPath(r)}return!1}_hasFill(){let e=this.options.fill;return e&&(e.nodeType===`Pattern`||!zn(e.color))}_hasStroke(){let e=this.options.stroke;return e&&e.width>0&&!zn(e.color)}_clippedBBox(e){return this.bbox(e)}};function qr(e,t,n,r){let i=0,a=0;return r&&(i=Math.atan2(r.c*n,r.a*t),r.b!==0&&(a=Math.atan2(r.d*n,r.b*t))),{x:i,y:a}}let Jr=Math.PI/2;var Yr=class e extends bn(mn,[`radius`]){constructor(e=new P,t=0){super(),this.setCenter(e),this.setRadius(t)}setCenter(e){return this._observerField(`center`,P.create(e)),this.geometryChange(),this}getCenter(){return this.center}equals(e){return e&&e.center.equals(this.center)&&e.radius===this.radius}clone(){return new e(this.center.clone(),this.radius)}pointAt(e){return this._pointAt(Wn(e))}bbox(e){let t=qr(this.center,this.radius,this.radius,e),n=P.maxPoint(),r=P.minPoint();for(let i=0;i<4;i++){let a=this._pointAt(t.x+i*Jr).transformCopy(e),o=this._pointAt(t.y+i*Jr).transformCopy(e),s=new P(a.x,o.y);n=P.min(n,s),r=P.max(r,s)}return F.fromPoints(n,r)}_pointAt(e){let{center:t,radius:n}=this;return new P(t.x+n*Math.cos(e),t.y+n*Math.sin(e))}containsPoint(e){let{center:t,radius:n}=this;return(e.x-t.x)**2+(e.y-t.y)**2<=n**2}_isOnPath(e,t){let{center:n,radius:r}=this,i=n.distanceTo(e);return r-t<=i&&i<=r+t}};let Xr=e=>class extends e{fill(e,t){let n=this.options;if(e!==void 0){if(e&&e.nodeType!==`Gradient`){let r={color:e};t!==void 0&&(r.opacity=t),n.set(`fill`,r)}else n.set(`fill`,e);return this}return n.get(`fill`)}stroke(e,t,n){return e===void 0?this.options.get(`stroke`):(this.options.set(`stroke.color`,e),t!==void 0&&this.options.set(`stroke.width`,t),n!==void 0&&this.options.set(`stroke.opacity`,n),this)}},Zr=er.IDENTITY.toString(),Qr=e=>class extends e{bbox(e){let t=Br(this.currentTransform(e)),n=t?t.toString():Zr,r;this._bboxCache&&this._matrixHash===n?r=this._bboxCache.clone():(r=this._bbox(t),this._bboxCache=r?r.clone():null,this._matrixHash=n);let i=this.options.get(`stroke.width`);return i&&r&&r.expand(i/2),r}geometryChange(){delete this._bboxCache,this.trigger(`geometryChange`,{element:this})}};function $r(e){let t=`_`+e;return function(e){return e===void 0?this[t]:(this._observerField(t,e),this.geometryChange(),this)}}function ei(e,t){for(let n=0;n<t.length;n++)e[t[n]]=$r(t[n])}let ti=(e,t=[`geometry`])=>{let n=class extends e{};return ei(n.prototype,t),n};var ni=class extends Xr(Qr(ti(Kr))){get nodeType(){return`Circle`}constructor(e=new Yr,t={}){super(t),this.geometry(e),this.options.stroke===void 0&&this.stroke(`#000`)}rawBBox(){return this._geometry.bbox()}_bbox(e){return this._geometry.bbox(e)}_containsPoint(e){return this.geometry().containsPoint(e)}_isOnPath(e){return this.geometry()._isOnPath(e,this.options.stroke.width/2)}};function ri(e,t,n=10){return N(Math.abs(e-t),n)===0}function ii(e,t,n){return e<t||ri(e,t,n)}function ai(e,t,n,r){let i=t.x-e.x,a=r.x-n.x,o=t.y-e.y,s=r.y-n.y,c=e.x-n.x,l=e.y-n.y,u=i*s-a*o,d=(i*l-o*c)/u,f=(a*l-s*c)/u;if(d>=0&&d<=1&&f>=0&&f<=1)return new P(e.x+f*i,e.y+f*o)}let oi=Math.pow,si=[`radiusX`,`radiusY`,`startAngle`,`endAngle`,`anticlockwise`];var ci=class e extends bn(mn,si){constructor(e=new P,t={}){super(),this.setCenter(e),this.radiusX=t.radiusX,this.radiusY=t.radiusY||t.radiusX,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.anticlockwise=t.anticlockwise||!1,this.xRotation=t.xRotation}clone(){return new e(this.center,{radiusX:this.radiusX,radiusY:this.radiusY,startAngle:this.startAngle,endAngle:this.endAngle,anticlockwise:this.anticlockwise})}setCenter(e){return this._observerField(`center`,P.create(e)),this.geometryChange(),this}getCenter(){return this.center}pointAt(e){let t=this.center,n=Wn(e);return new P(t.x+this.radiusX*Math.cos(n),t.y+this.radiusY*Math.sin(n))}curvePoints(){let e=this.startAngle,t=this.anticlockwise?-1:1,n=[this.pointAt(e)],r=this._arcInterval(),i=r.endAngle-r.startAngle,a=Math.ceil(i/45),o=i/a,s=e,c;this.xRotation&&(c=Ur().rotate(this.xRotation,this.center));for(let e=1;e<=a;e++){let e=s+t*o,r=this._intervalCurvePoints(s,e,c);n.push(r.cp1,r.cp2,r.p2),s=e}return n}bbox(e){let t=this._arcInterval(),n=t.startAngle,r=t.endAngle,i=qr(this.center,this.radiusX,this.radiusY,e),a=An(i.x),o=An(i.y),s=this.pointAt(r).transformCopy(e),c=di(a,n),l=di(o,n),u=this.pointAt(n).transformCopy(e),d=P.min(u,s),f=P.max(u,s);for(;c<r||l<r;){let t;c<r&&(t=this.pointAt(c).transformCopy(e),c+=90);let n;l<r&&(n=this.pointAt(l).transformCopy(e),l+=90),u=new P(t.x,n.y),d=P.min(d,u),f=P.max(f,u)}return F.fromPoints(d,f)}_arcInterval(){let{startAngle:e,endAngle:t,anticlockwise:n}=this;if(n){let n=e;e=t,t=n}return(e>t||n&&e===t)&&(t+=360),{startAngle:e,endAngle:t}}_intervalCurvePoints(e,t,n){let r=this.pointAt(e),i=this.pointAt(t),a=this._derivativeAt(e),o=this._derivativeAt(t),s=(Wn(t)-Wn(e))/3,c=new P(r.x+s*a.x,r.y+s*a.y),l=new P(i.x-s*o.x,i.y-s*o.y);return n&&(r.transform(n),i.transform(n),c.transform(n),l.transform(n)),{p1:r,cp1:c,cp2:l,p2:i}}_derivativeAt(e){let t=Wn(e);return new P(-this.radiusX*Math.sin(t),this.radiusY*Math.cos(t))}containsPoint(e){let t=this._arcInterval(),n=t.endAngle-t.startAngle,{center:r,radiusX:i,radiusY:a}=this,o=r.distanceTo(e),s=Math.atan2(e.y-r.y,e.x-r.x),c=i*a/Math.sqrt(oi(i,2)*oi(Math.sin(s),2)+oi(a,2)*oi(Math.cos(s),2)),l=this.pointAt(this.startAngle).round(10),u=this.pointAt(this.endAngle).round(10),d=ai(r,e.round(10),l,u),f;if(n<180)f=d&&ii(r.distanceTo(d),o)&&ii(o,c);else{let n=li(r.x,r.y,i,a,e.x,e.y);n!==360&&(n=(360+n)%360);let s=t.startAngle<=n&&n<=t.endAngle;f=s&&ii(o,c)||!s&&(!d||d.equals(e))}return f}_isOnPath(e,t){let n=this._arcInterval(),r=this.center,i=li(r.x,r.y,this.radiusX,this.radiusY,e.x,e.y);return i!==360&&(i=(360+i)%360),n.startAngle<=i&&i<=n.endAngle&&this.pointAt(i).distanceTo(e)<=t}static fromPoints(t,n,r,i,a,o,s){let c=ui({x1:t.x,y1:t.y,x2:n.x,y2:n.y,rx:r,ry:i,largeArc:a,swipe:o,rotation:s});return new e(c.center,{startAngle:c.startAngle,endAngle:c.endAngle,radiusX:c.radiusX,radiusY:c.radiusY,xRotation:c.xRotation,anticlockwise:o===0})}};function li(e,t,n,r,i,a){let o=N((i-e)/n,3),s=N((a-t)/r,3);return N(An(Math.atan2(s,o)))}function ui(e){let{x1:t,y1:n,x2:r,y2:i,rx:a,ry:o,largeArc:s,swipe:c,rotation:l=0}=e,u=Wn(l),d=Math.cos(u),f=Math.sin(u),p=d*(t-r)/2+f*(n-i)/2,m=-f*(t-r)/2+d*(n-i)/2,h=s===c?-1:1,g=p**2,_=m**2,v=a**2,y=o**2,b=g/v+_/y;b>1&&(b=Math.sqrt(g/v+_/y),a=b*a,v=a**2,o=b*o,y=o**2);let x=h*Math.sqrt((v*y-v*_-y*g)/(v*_+y*g));isNaN(x)&&(x=0);let S=a*m*x/o,ee=-x*(o*p)/a,te=d*S-f*ee+(t+r)/2,C=f*S+d*ee+(n+i)/2,w=(p-S)/a,ne=(m-ee)/o,re=-(p+S)/a,ie=-(m+ee)/o,ae=(ne>=0?1:-1)*An(Math.acos(w/Math.sqrt(w*w+ne*ne))),oe=N((w*re+ne*ie)/(Math.sqrt(w*w+ne*ne)*Math.sqrt(re*re+ie*ie)),10),se=(w*ie-ne*re>=0?1:-1)*An(Math.acos(oe));!c&&se>0&&(se-=360),c&&se<0&&(se+=360);let ce=ae+se,le=ce>=0?1:-1;return ce=Math.abs(ce)%360*le,{center:new P(te,C),startAngle:ae,endAngle:ce,radiusX:a,radiusY:o,xRotation:l}}function di(e,t){let n=e;for(;n<t;)n+=90;return n}let fi=[].splice,pi=[].slice;var mi=class extends mn{constructor(e=[]){super(),this.length=0,this._splice(0,e.length,e)}elements(e){return e?(this._splice(0,this.length,e),this._change(),this):this.slice(0)}push(...e){let t=this.length,n=e.length;for(let r=0;r<n;r++)this[t+r]=e[r],e[r].addObserver(this);return this.length=t+n,this._change(),this.length}slice(){return pi.call(this)}pop(){if(this.length>0){let e=this[this.length-1];return this.length--,e.removeObserver(this),this._change(),e}}splice(e,t,...n){let r=this._splice(e,t,n);return this._change(),r}shift(){if(this.length>0){let e=this[0];for(let e=1;e<this.length;e++)this[e-1]=this[e];return this.length--,e.removeObserver(this),this._change(),e}}unshift(...e){let t=e.length;for(let e=this.length-1;e>=0;e--)this[e+t]=this[e];for(let n=0;n<t;n++)this[n]=e[n],e[n].addObserver(this);return this.length+=t,this._change(),this.length}indexOf(e){let t=this.length;for(let n=0;n<t;n++)if(this[n]===e)return n;return-1}_splice(e,t,n){let r=fi.apply(this,[e,t].concat(n));return this._clearObserver(r),this._setObserver(n),r}_add(e){this._setObserver(e),this._change()}_remove(e){this._clearObserver(e),this._change()}_setObserver(e){for(let t=0;t<e.length;t++)e[t].addObserver(this)}_clearObserver(e){for(let t=0;t<e.length;t++)e[t].removeObserver(this)}_change(){}},hi=class extends mi{_change(){this.geometryChange()}};function gi(e,t,n){let r=An(Math.atan2(t.y-e.y,t.x-e.x));return n.transformCopy(Ur().rotate(-r,e)).x<e.x}function _i(e,t,n){let r=1-e;return r**3*n[0][t]+3*r**2*e*n[1][t]+3*e**2*r*n[2][t]+e**3*n[3][t]}function vi(e,t){return[-e[0][t]+3*e[1][t]-3*e[2][t]+e[3][t],3*(e[0][t]-2*e[1][t]+e[2][t]),3*(-e[0][t]+e[1][t]),e[0][t]]}var yi=class e extends jt{constructor(e=0,t=0){super(),this.real=e,this.img=t}add(t){return new e(N(this.real+t.real,10),N(this.img+t.img,10))}addConstant(t){return new e(this.real+t,this.img)}negate(){return new e(-this.real,-this.img)}multiply(t){return new e(this.real*t.real-this.img*t.img,this.real*t.img+this.img*t.real)}multiplyConstant(t){return new e(this.real*t,this.img*t)}nthRoot(t){let n=Math.atan2(this.img,this.real),r=Math.sqrt(this.img**2+this.real**2)**(1/t);return new e(r*Math.cos(n/t),r*Math.sin(n/t))}equals(e){return this.real===e.real&&this.img===e.img}isReal(){return this.img===0}};function bi(e){return e<0?-1:1}function xi(e,t,n){let r=Math.sqrt(t**2-4*e*n);return[(-t+r)/(2*e),(-t-r)/(2*e)]}function Si(e,t,n,r){if(e===0)return xi(t,n,r);let i=(3*e*n-t**2)/(3*e**2),a=(2*t**3-9*e*t*n+27*e**2*r)/(27*e**3),o=(i/3)**3+(a/2)**2,s=new yi(0,1),c=-t/(3*e),l,u,d,f,p,m,h;o<0?(l=new yi(-a/2,Math.sqrt(-o)).nthRoot(3),u=new yi(-a/2,-Math.sqrt(-o)).nthRoot(3)):(l=-a/2+Math.sqrt(o),l=new yi(bi(l)*Math.abs(l)**(1/3)),u=-a/2-Math.sqrt(o),u=new yi(bi(u)*Math.abs(u)**(1/3))),d=l.add(u),m=l.add(u).multiplyConstant(-1/2),h=l.add(u.negate()).multiplyConstant(Math.sqrt(3)/2),f=m.add(s.multiply(h)),p=m.add(s.negate().multiply(h));let g=[];return d.isReal()&&g.push(N(d.real+c,10)),f.isReal()&&g.push(N(f.real+c,10)),p.isReal()&&g.push(N(p.real+c,10)),g}function Ci(e,t,n,r,i){let a=vi(e,r),o=Si(a[0],a[1],a[2],a[3]-t[r]),s;for(let r=0;r<o.length;r++)if(0<=o[r]&&o[r]<=1&&(s=_i(o[r],n,e),Math.abs(s-t[n])<=i))return!0}function wi(e,t,n){let r=vi(e,`x`),i=Si(r[0],r[1],r[2],r[3]-t.x),a,o,s=0;for(let r=0;r<i.length;r++)a=_i(i[r],`y`,e),o=ri(a,t.y)||a>t.y,o&&((i[r]===0||i[r]===1)&&n.bottomRight().x>t.x||0<i[r]&&i[r]<1)&&s++;return s}function Ti(e,t,n){let r;if(e.x!==t.x){let i=Math.min(e.x,t.x),a=Math.max(e.x,t.x),o=Math.min(e.y,t.y),s=Math.max(e.y,t.y),c=i<=n.x&&n.x<a;r=o===s?n.y<=o&&c:c&&(s-o)*((e.x-t.x)*(e.y-t.y)>0?n.x-i:a-n.x)/(a-i)+o-n.y>=0}return+!!r}function Ei(e){let t=`_`+e;return function(e){return e===void 0?this[t]:(this._observerField(t,P.create(e)),this.geometryChange(),this)}}function Di(e,t){for(let n=0;n<t.length;n++)e[t[n]]=Ei(t[n])}let Oi=(e,t)=>{let n=class extends e{};return Di(n.prototype,t),n},ki=[`anchor`,`controlIn`,`controlOut`];var Ai=class extends Oi(mn,ki){constructor(e,t,n){super(),this.anchor(e||new P),this.controlIn(t),this.controlOut(n)}bboxTo(e,t){let n=this.anchor().transformCopy(t),r=e.anchor().transformCopy(t),i;return i=this.controlOut()&&e.controlIn()?this._curveBoundingBox(n,this.controlOut().transformCopy(t),e.controlIn().transformCopy(t),r):this._lineBoundingBox(n,r),i}_lineBoundingBox(e,t){return F.fromPoints(e,t)}_curveBoundingBox(e,t,n,r){let i=[e,t,n,r],a=this._curveExtremesFor(i,`x`),o=this._curveExtremesFor(i,`y`),s=ji([a.min,a.max,e.x,r.x]),c=ji([o.min,o.max,e.y,r.y]);return F.fromPoints(new P(s.min,c.min),new P(s.max,c.max))}_curveExtremesFor(e,t){let n=this._curveExtremes(e[0][t],e[1][t],e[2][t],e[3][t]);return{min:_i(n.min,t,e),max:_i(n.max,t,e)}}_curveExtremes(e,t,n,r){let i=e-3*t+3*n-r,a=-2*(e-2*t+n),o=e-t,s=Math.sqrt(a*a-4*i*o),c=0,l=1;i===0?a!==0&&(c=l=-o/a):isNaN(s)||(c=(-a+s)/(2*i),l=(-a-s)/(2*i));let u=Math.max(Math.min(c,l),0);(u<0||u>1)&&(u=0);let d=Math.min(Math.max(c,l),1);return(d>1||d<0)&&(d=1),{min:u,max:d}}_intersectionsTo(e,t){let n;return n=this.controlOut()&&e.controlIn()?wi([this.anchor(),this.controlOut(),e.controlIn(),e.anchor()],t,this.bboxTo(e)):Ti(this.anchor(),e.anchor(),t),n}_isOnCurveTo(e,t,n,r){if(this.bboxTo(e).expand(n,n).containsPoint(t)){let i=this.anchor(),a=this.controlOut(),o=e.controlIn(),s=e.anchor();if(r===`start`&&i.distanceTo(t)<=n)return!gi(i,a,t);if(r===`end`&&s.distanceTo(t)<=n)return!gi(s,o,t);let c=[i,a,o,s];if(Ci(c,t,`x`,`y`,n)||Ci(c,t,`y`,`x`,n))return!0;let l=Ur().rotate(45,t),u=[i.transformCopy(l),a.transformCopy(l),o.transformCopy(l),s.transformCopy(l)];return Ci(u,t,`x`,`y`,n)||Ci(u,t,`y`,`x`,n)}}_isOnLineTo(e,t,n){let r=this.anchor(),i=e.anchor(),a=An(Math.atan2(i.y-r.y,i.x-r.x));return new F([r.x,r.y-n/2],[r.distanceTo(i),n]).containsPoint(t.transformCopy(Ur().rotate(-a,r)))}_isOnPathTo(e,t,n,r){let i;return i=this.controlOut()&&e.controlIn()?this._isOnCurveTo(e,t,n/2,r):this._isOnLineTo(e,t,n),i}};function ji(e){let t=e.length,n=On,r=kn;for(let i=0;i<t;i++)r=Math.max(r,e[i]),n=Math.min(n,e[i]);return{min:n,max:r}}let Mi=.333;function Ni(e,t){let n=e.slice(0),r=[],i=n.length;if(i>2&&(Pi(0,n),i=n.length),i<2||i===2&&n[0].equals(n[1]))return r;let a=n[0],o=n[1],s=n[2];for(r.push(new Ai(a));a.equals(n[i-1]);)t=!0,n.pop(),i--;if(i===2){let e=Bi(a,o,`x`,`y`);return Bn(r).controlOut(Hi(e,a,o,`x`,`y`)),r.push(new Ai(o,Ui(e,a,o,`x`,`y`))),r}let c,l;if(t){a=n[i-1],o=n[0],s=n[1];let e=Ri(a,o,s);c=e[1],l=e[0]}else c=Hi(Bi(a,o,`x`,`y`),a,o,`x`,`y`);let u=c;for(let e=0;e<=i-3;e++)if(Pi(e,n),i=n.length,e+3<=i){a=n[e],o=n[e+1],s=n[e+2];let t=Ri(a,o,s);Bn(r).controlOut(u),u=t[1];let i=t[0];r.push(new Ai(o,i))}if(t){a=n[i-2],o=n[i-1],s=n[0];let e=Ri(a,o,s);Bn(r).controlOut(u),r.push(new Ai(o,e[0])),Bn(r).controlOut(e[1]),r.push(new Ai(s,l))}else{let e=Bi(o,s,`x`,`y`);Bn(r).controlOut(u),r.push(new Ai(s,Ui(e,o,s,`x`,`y`)))}return r}function Pi(e,t){for(;t[e+1]&&(t[e].equals(t[e+1])||t[e+1].equals(t[e+2]));)t.splice(e+1,1)}function Fi(e,t,n){let r=!1;if(e.x===t.x)r=!0;else if(t.x===n.x)(t.y<n.y&&e.y<=t.y||n.y<t.y&&t.y<=e.y)&&(r=!0);else{let i=Gi(Li(e,t),n.x);!(e.y<=t.y&&n.y<=i)&&!(t.y<=e.y&&n.y>=i)&&(r=!0)}return r}function Ii(e,t,n){let r=Gi(Li(e,t),n.x);return e.x===t.x&&t.x===n.x||N(r,1)===N(n.y,1)}function Li(e,t){let n=(t.y-e.y)/(t.x-e.x);return[e.y-n*e.x,n]}function Ri(e,t,n){let r=`x`,i=`y`,a=!1,o=!1,s;if(Ii(e,t,n))s=Bi(e,t,`x`,`y`);else{let c={x:Vi(e,t,n,`x`),y:Vi(e,t,n,`y`)};if(c.x&&c.y)s=Bi(e,n,`x`,`y`),a=!0;else if(Fi(e,t,n)&&(r=`y`,i=`x`),c[r])s=0;else{let a;a=n[i]<e[i]&&e[i]<=t[i]||e[i]<n[i]&&t[i]<=e[i]?Ki((n[i]-e[i])*(t[r]-e[r])):-Ki((n[r]-e[r])*(t[i]-e[i])),s=.01*a,o=!0}}let c=Ui(s,e,t,r,i);if(o){let e=r;r=i,i=e}let l=Hi(s,t,n,r,i);return a&&(zi(e,t,c,s),zi(t,n,l,s)),[c,l]}function zi(e,t,n,r){e.y<t.y?t.y<n.y?(n.x=e.x+(t.y-e.y)/r,n.y=t.y):n.y<e.y&&(n.x=t.x-(t.y-e.y)/r,n.y=e.y):n.y<t.y?(n.x=e.x-(e.y-t.y)/r,n.y=t.y):e.y<n.y&&(n.x=t.x+(e.y-t.y)/r,n.y=e.y)}function Bi(e,t,n,r){let i=t[n]-e[n],a=t[r]-e[r],o;return o=i===0?0:a/i,o}function Vi(e,t,n,r){return n[r]>t[r]&&t[r]>e[r]||n[r]<t[r]&&t[r]<e[r]}function Hi(e,t,n,r,i){let a=t[r],o=(n[r]-a)*Mi;return Wi(a+o,t[i]+o*e,r,i)}function Ui(e,t,n,r,i){let a=t[r],o=n[r],s=(o-a)*Mi;return Wi(o-s,n[i]-s*e,r,i)}function Wi(e,t,n,r){let i=new P;return i[n]=e,i[r]=t,i}function Gi(e,t){let n=e.length,r=0;for(let i=0;i<n;i++)r+=t**+i*e[i];return r}function Ki(e){return e<=0?-1:1}let qi={l:function(e,t){let{parameters:n,position:r}=t;for(let i=0;i<n.length;i+=2){let a=new P(n[i],n[i+1]);t.isRelative&&a.translateWith(r),e.lineTo(a.x,a.y),r.x=a.x,r.y=a.y}},c:function(e,t){let{parameters:n,position:r}=t;for(let i=0;i<n.length;i+=6){let a=new P(n[i],n[i+1]),o=new P(n[i+2],n[i+3]),s=new P(n[i+4],n[i+5]);t.isRelative&&(o.translateWith(r),a.translateWith(r),s.translateWith(r)),e.curveTo(a,o,s),r.x=s.x,r.y=s.y}},v:function(e,t){let n=t.isRelative?0:t.position.x;Ji(t.parameters,!0,n),this.l(e,t)},h:function(e,t){let n=t.isRelative?0:t.position.y;Ji(t.parameters,!1,n),this.l(e,t)},a:function(e,t){let{parameters:n,position:r}=t;for(let i=0;i<n.length;i+=7){let a=n[i],o=n[i+1],s=n[i+2],c=n[i+3],l=n[i+4],u=new P(n[i+5],n[i+6]);t.isRelative&&u.translateWith(r),(r.x!==u.x||r.y!==u.y)&&(e.arcTo(u,a,o,c,l,s),r.x=u.x,r.y=u.y)}},s:function(e,t){let{parameters:n,position:r,previousCommand:i}=t,a;(i===`s`||i===`c`)&&(a=Bn(Bn(e.paths).segments).controlIn());for(let i=0;i<n.length;i+=4){let o=new P(n[i],n[i+1]),s=new P(n[i+2],n[i+3]),c;t.isRelative&&(o.translateWith(r),s.translateWith(r)),c=a?Yi(a,r):r.clone(),a=o,e.curveTo(c,o,s),r.x=s.x,r.y=s.y}},q:function(e,t){let{parameters:n,position:r}=t;for(let i=0;i<n.length;i+=4){let a=new P(n[i],n[i+1]),o=new P(n[i+2],n[i+3]);t.isRelative&&(a.translateWith(r),o.translateWith(r));let s=Zi(r,a,o);e.curveTo(s.controlOut,s.controlIn,o),r.x=o.x,r.y=o.y}},t:function(e,t){let{parameters:n,position:r,previousCommand:i}=t,a;(i===`q`||i===`t`)&&(a=Bn(Bn(e.paths).segments).controlIn().clone().translateWith(r.scaleCopy(-1/3)).scale(3/2));for(let i=0;i<n.length;i+=2){let o=new P(n[i],n[i+1]);t.isRelative&&o.translateWith(r),a=a?Yi(a,r):r.clone();let s=Zi(r,a,o);e.curveTo(s.controlOut,s.controlIn,o),r.x=o.x,r.y=o.y}}};function Ji(e,t,n){let r=+!t;for(let t=0;t<e.length;t+=2)e.splice(t+r,0,n)}function Yi(e,t){if(e&&t)return t.scaleCopy(2).translate(-e.x,-e.y)}let Xi=1/3;function Zi(e,t,n){let r=t.clone().scale(2/3);return{controlOut:r.clone().translateWith(e.scaleCopy(Xi)),controlIn:r.translateWith(n.scaleCopy(Xi))}}let Qi=/([a-df-z]{1})([^a-df-z]*)(z)?/gi,$i=/[,\s]?([+\-]?(?:\d*\.\d+|\d+)(?:[eE][+\-]?\d+)?)/g;function ea(e){let t=[];return e.replace($i,function(e,n){t.push(parseFloat(n))}),t}function ta(e,t){let n=new P,r;return t.replace(Qi,(t,i,a,o)=>{let s=i.toLowerCase(),c=s===i,l=ea(a.trim());if(s===`m`&&(c?(n.x+=l[0],n.y+=l[1]):(n.x=l[0],n.y=l[1]),e.moveTo(n.x,n.y),l.length>2&&(s=`l`,l.splice(0,2))),qi[s])qi[s](e,{parameters:l,position:n,isRelative:c,previousCommand:r}),o&&o.toLowerCase()===`z`&&e.close();else if(s!==`m`)throw Error(`Error while parsing SVG path. Unsupported command: `+s);r=s}),e}function na(e,t,n){let r;for(let i=0;i<e.length;i++){let a=e[i];if(a.visible()){let e=t?a.bbox(n):a.rawBBox();e&&(r=r?F.union(r,e):e)}}return r}function ra(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r];if(i.visible()){let e=i.clippedBBox(t);e&&(n=n?F.union(n,e):e)}}return n}let ia=e=>(...t)=>t.map(t=>t.toString(e)).join(` `),aa=(e,t)=>e.controlOut()&&t.controlIn()?`C`:`L`;var I=class e extends Xr(Qr(Kr)){get nodeType(){return`Path`}constructor(e){super(e),this.segments=new hi,this.segments.addObserver(this),this.options.stroke===void 0&&(this.stroke(`#000`),this.options.stroke.lineJoin===void 0&&this.options.set(`stroke.lineJoin`,`miter`))}moveTo(e,t){return this.suspend(),this.segments.elements([]),this.resume(),this.lineTo(e,t),this}lineTo(e,t){let n=new Ai(t===void 0?e:new P(e,t));return this.segments.push(n),this}curveTo(e,t,n){if(this.segments.length>0){let r=Bn(this.segments),i=new Ai(n,t);this.suspend(),r.controlOut(e),this.resume(),this.segments.push(i)}return this}arc(e,t,n,r,i){if(this.segments.length>0){let a=Bn(this.segments).anchor(),o=Wn(e),s=new ci(new P(a.x-n*Math.cos(o),a.y-r*Math.sin(o)),{startAngle:e,endAngle:t,radiusX:n,radiusY:r,anticlockwise:i});this._addArcSegments(s)}return this}arcTo(e,t,n,r,i,a){if(this.segments.length>0){let o=Bn(this.segments).anchor(),s=ci.fromPoints(o,P.create(e),t,n,r,i,a);this._addArcSegments(s)}return this}_addArcSegments(e){this.suspend();let t=e.curvePoints();for(let e=1;e<t.length;e+=3)this.curveTo(t[e],t[e+1],t[e+2]);this.resume(),this.geometryChange()}close(){return this.options.closed=!0,this.geometryChange(),this}rawBBox(){return this._bbox()}toString(e){let t=``,n=this.segments,r=n.length;if(r>0){let i=[],a=ia(e),o;for(let e=1;e<r;e++){let t=aa(n[e-1],n[e]);t!==o&&(o=t,i.push(t)),t===`L`?i.push(a(n[e].anchor())):i.push(a(n[e-1].controlOut(),n[e].controlIn(),n[e].anchor()))}t=`M`+a(n[0].anchor())+` `+i.join(` `),this.options.closed&&(t+=`Z`)}return t}_containsPoint(e){let t=this.segments,n=t.length,r=0,i,a;for(let o=1;o<n;o++)i=t[o-1],a=t[o],r+=i._intersectionsTo(a,e);return(this.options.closed||!t[0].anchor().equals(t[n-1].anchor()))&&(r+=Ti(t[0].anchor(),t[n-1].anchor(),e)),r%2!=0}_isOnPath(e,t){let n=this.segments,r=n.length,i=t||this.options.stroke.width;if(r>1){if(n[0]._isOnPathTo(n[1],e,i,`start`))return!0;for(let t=2;t<=r-2;t++)if(n[t-1]._isOnPathTo(n[t],e,i))return!0;if(n[r-2]._isOnPathTo(n[r-1],e,i,`end`))return!0}return!1}_bbox(e){let t=this.segments,n=t.length,r;if(n===1)r=new F(t[0].anchor().transformCopy(e),Vr.ZERO);else if(n>0)for(let i=1;i<n;i++){let n=t[i-1].bboxTo(t[i],e);r=r?F.union(r,n):n}return r}static parse(e,t){return oa.parse(e,t)}static fromRect(t,n){let r=new e(n),[i,a]=t.cornerRadius;if(i===0&&a===0)r.moveTo(t.topLeft()).lineTo(t.topRight()).lineTo(t.bottomRight()).lineTo(t.bottomLeft()).close();else{let{x:e,y:n}=t.origin,o=t.width(),s=t.height();i=Vn(i,0,o/2),a=Vn(a,0,s/2),r.moveTo(e+i,n).lineTo(e+o-i,n).arcTo([e+o,n+a],i,a,!1).lineTo(e+o,n+s-a).arcTo([e+o-i,n+s],i,a,!1).lineTo(e+i,n+s).arcTo([e,n+s-a],i,a,!1).lineTo(e,n+a).arcTo([e+i,n],i,a,!1)}return r}static fromPoints(t,n){if(t){let r=new e(n);for(let e=0;e<t.length;e++){let n=P.create(t[e]);n&&(e===0?r.moveTo(n):r.lineTo(n))}return r}}static curveFromPoints(t,n){if(t){let r=Ni(t),i=new e(n);return i.segments.push.apply(i.segments,r),i}}static fromArc(t,n){let r=new e(n),i=t.startAngle,a=t.pointAt(i);return r.moveTo(a.x,a.y),r.arc(i,t.endAngle,t.radiusX,t.radiusY,t.anticlockwise),r}},oa=class e extends Xr(Qr(Kr)){static parse(t,n){return ta(new e(n),t)}toString(e){let t=this.paths,n=``;if(t.length>0){let r=[];for(let n=0;n<t.length;n++)r.push(t[n].toString(e));n=r.join(` `)}return n}get nodeType(){return`MultiPath`}constructor(e){super(e),this.paths=new hi,this.paths.addObserver(this),this.options.stroke===void 0&&this.stroke(`#000`)}moveTo(e,t){let n=new I;return n.moveTo(e,t),this.paths.push(n),this}lineTo(e,t){return this.paths.length>0&&Bn(this.paths).lineTo(e,t),this}curveTo(e,t,n){return this.paths.length>0&&Bn(this.paths).curveTo(e,t,n),this}arc(e,t,n,r,i){return this.paths.length>0&&Bn(this.paths).arc(e,t,n,r,i),this}arcTo(e,t,n,r,i,a){return this.paths.length>0&&Bn(this.paths).arcTo(e,t,n,r,i,a),this}close(){return this.paths.length>0&&Bn(this.paths).close(),this}_bbox(e){return na(this.paths,!0,e)}rawBBox(){return na(this.paths,!1)}_containsPoint(e){let t=this.paths;for(let n=0;n<t.length;n++)if(t[n]._containsPoint(e))return!0;return!1}_isOnPath(e){let t=this.paths,n=this.options.stroke.width;for(let r=0;r<t.length;r++)if(t[r]._isOnPath(e,n))return!0;return!1}_clippedBBox(e){return ra(this.paths,this.currentTransform(e))}};ti(Kr);var sa=class extends Xr(Oi(Kr,[`position`])){get nodeType(){return`Text`}constructor(e,t=new P,n={}){super(n),this.content(e),this.position(t),this.options.font||(this.options.font=`12px sans-serif`),this.options.fill===void 0&&this.fill(`#000`)}content(e){return e===void 0?this.options.get(`content`):(this.options.set(`content`,e),this)}measure(){return mr(this.content(),{font:this.options.get(`font`)})}rect(){let e=this.measure();return new F(this.position().clone(),[e.width,e.height])}bbox(e){let t=Br(this.currentTransform(e));return this.rect().bbox(t)}rawBBox(){return this.rect().bbox()}_containsPoint(e){return this.rect().containsPoint(e)}},ca=class extends ti(Kr,[`rect`]){get nodeType(){return`Image`}constructor(e,t=new F,n={}){super(n),this.src(e),this.rect(t)}src(e){return e===void 0?this.options.get(`src`):(this.options.set(`src`,e),this)}bbox(e){let t=Br(this.currentTransform(e));return this._rect.bbox(t)}rawBBox(){return this._rect.bbox()}_containsPoint(e){return this._rect.containsPoint(e)}_hasFill(){return this.src()}};let la=(e,t)=>class extends e{traverse(e){let n=this[t];for(let t=0;t<n.length;t++){let r=n[t];r.traverse?r.traverse(e):e(r)}return this}};var L=class extends la(Kr,`children`){get nodeType(){return`Group`}constructor(e){super(e),this.children=[]}childrenChange(e,t,n){this.trigger(`childrenChange`,{action:e,items:t,index:n})}append(){return xn(this.children,arguments),this._reparent(arguments,this),this.childrenChange(`add`,arguments),this}insert(e,t){return this.children.splice(e,0,t),t.parent=this,this.childrenChange(`add`,[t],e),this}insertAt(e,t){return this.insert(t,e)}remove(e){let t=this.children.indexOf(e);return t>=0&&(this.children.splice(t,1),e.parent=null,this.childrenChange(`remove`,[e],t)),this}removeAt(e){if(0<=e&&e<this.children.length){let t=this.children[e];this.children.splice(e,1),t.parent=null,this.childrenChange(`remove`,[t],e)}return this}clear(){let e=this.children;return this.children=[],this._reparent(e,null),this.childrenChange(`remove`,e,0),this}bbox(e){return na(this.children,!0,this.currentTransform(e))}rawBBox(){return na(this.children,!1)}_clippedBBox(e){return ra(this.children,this.currentTransform(e))}currentTransform(e){return Kr.prototype.currentTransform.call(this,e)||null}containsPoint(e,t){if(this.visible()){let n=this.children,r=this.currentTransform(t);for(let t=0;t<n.length;t++)if(n[t].containsPoint(e,r))return!0}return!1}_reparent(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=r.parent;i&&i!==this&&i.remove&&i.remove(r),r.parent=t}}};function ua(e,t,n){let r=n.transform()||Ur(),i=r.matrix();i.e+=e.x-t.origin.x,i.f+=e.y-t.origin.y,r.matrix(i),n.transform(r)}function da(e,t,n,r,i){let a;return a=n===`start`?t.origin[r]:n===`end`?t.origin[r]+t.size[i]-e:t.origin[r]+(t.size[i]-e)/2,a}function fa(e,t,n,r,i){let a;return a=n===`start`?t.origin[r]+t.size[i]-e:n===`end`?t.origin[r]:t.origin[r]+(t.size[i]-e)/2,a}let pa={alignContent:`start`,justifyContent:`start`,alignItems:`start`,spacing:0,orientation:`horizontal`,lineSpacing:0,wrap:!0,revers:!1},ma=(e,t)=>{e.forEach(t)},ha=(e,t)=>{let n=e.length;for(let r=n-1;r>=0;r--)t(e[r],r)};var ga=class extends L{constructor(e,t){super(Object.assign({},pa,t)),this._rect=e,this._fieldMap={}}rect(e){return e?(this._rect=e,this):this._rect}appendBreak(){let e=new L;return e._isBreakMarker=!0,this.append(e),this}_initMap(){let e=this.options,t=this._fieldMap;e.orientation===`horizontal`?(t.sizeField=`width`,t.groupsSizeField=`height`,t.groupAxis=`x`,t.groupsAxis=`y`):(t.sizeField=`height`,t.groupsSizeField=`width`,t.groupAxis=`y`,t.groupsAxis=`x`),e.reverse?(this.forEach=ha,this.justifyAlign=fa):(this.forEach=ma,this.justifyAlign=da)}reflow(){if(!this._rect||this.children.length===0)return;this._initMap(),this.options.transform&&this.transform(null);let e=this.options,t=this._rect,{groups:n,groupsSize:r}=this._initGroups(),{sizeField:i,groupsSizeField:a,groupAxis:o,groupsAxis:s}=this._fieldMap,c=new P,l=new P,u=new Vr,d=da(r,t,e.alignContent,s,a),f,p,m,h=(t,n)=>{let r=p.elements[n];l[o]=f,l[s]=da(t.size[a],m,e.alignItems,s,a),ua(l,t,r),f+=t.size[i]+e.spacing};for(let r=0;r<n.length;r++)p=n[r],c[o]=f=this.justifyAlign(p.size,t,e.justifyContent,o,i),c[s]=d,u[i]=p.size,u[a]=p.lineSize,m=new F(c,u),this.forEach(p.bboxes,h),d+=p.lineSize+e.lineSpacing;if(!e.wrap&&p.size>t.size[i]){let n=t.size[i]/m.size[i],r=m.topLeft().scale(n,n),c=da(m.size[a]*n,t,e.alignContent,s,a),l=Ur();o===`x`?l.translate(t.origin.x-r.x,c-r.y):l.translate(c-r.x,t.origin.y-r.y),l.scale(n,n),this.transform(l)}}_initGroups(){let{options:e,children:t}=this,{lineSpacing:n,wrap:r,spacing:i}=e,a=this._fieldMap.sizeField,o=this._newGroup(),s=[],c=function(){s.push(o),l+=o.lineSize+n},l=-n;for(let e=0;e<t.length;e++){let n=t[e],s=t[e].clippedBBox();if(n._isBreakMarker){o.bboxes.length>0&&(c(),o=this._newGroup());continue}n.visible()&&s&&(r&&o.size+s.size[a]+i>this._rect.size[a]?o.bboxes.length===0?(this._addToGroup(o,s,n),c(),o=this._newGroup()):(c(),o=this._newGroup(),this._addToGroup(o,s,n)):this._addToGroup(o,s,n))}return o.bboxes.length&&c(),{groups:s,groupsSize:l}}_addToGroup(e,t,n){e.size+=t.size[this._fieldMap.sizeField]+this.options.spacing,e.lineSize=Math.max(t.size[this._fieldMap.groupsSizeField],e.lineSize),e.bboxes.push(t),e.elements.push(n)}_newGroup(){return{lineSize:0,size:-this.options.spacing,bboxes:[],elements:[]}}},_a=class extends Xr(Qr(ti(Kr))){get nodeType(){return`Rect`}constructor(e=new F,t={}){super(t),this.geometry(e),this.options.stroke===void 0&&this.stroke(`#000`)}_bbox(e){return this._geometry.bbox(e)}rawBBox(){return this._geometry.bbox()}_containsPoint(e){return this._geometry.containsPoint(e)}_isOnPath(e){return this.geometry()._isOnPath(e,this.options.stroke.width/2)}},va=class extends mi{_change(){this.optionsChange({field:`stops`})}};function ya(e){return function(t){return t===void 0?this.options.get(e):(this.options.set(e,t),this)}}function ba(e,t){for(let n=0;n<t.length;n++)e[t[n]]=ya(t[n])}let xa=(e,t)=>{let n=class extends e{};return ba(n.prototype,t),n},Sa=[`offset`,`color`,`opacity`];var Ca=class e extends xa(mn,Sa){constructor(e,t,n){super(),this.options=new gn({offset:e,color:t,opacity:n===void 0?1:n}),this.options.addObserver(this)}static create(t){if(t!==void 0){let n;return n=t instanceof e?t:t.length>1?new e(t[0],t[1],t[2]):new e(t.offset,t.color,t.opacity),n}}},wa=class extends mn{get nodeType(){return`Gradient`}constructor(e={}){super(),this.stops=new va(this._createStops(e.stops)),this.stops.addObserver(this),this._userSpace=e.userSpace,this.id=En()}userSpace(e){return e===void 0?this._userSpace:(this._userSpace=e,this.optionsChange(),this)}_createStops(e=[]){let t=[];for(let n=0;n<e.length;n++)t.push(Ca.create(e[n]));return t}addStop(e,t,n){this.stops.push(new Ca(e,t,n))}removeStop(e){let t=this.stops.indexOf(e);t>=0&&this.stops.splice(t,1)}optionsChange(e){this.trigger(`optionsChange`,{field:`gradient`+(e?`.`+e.field:``),value:this})}geometryChange(){this.optionsChange()}};let Ta=[`start`,`end`];var Ea=class extends Oi(wa,Ta){constructor(e={}){super(e),this.start(e.start||new P),this.end(e.end||new P(1,0))}},Da=class extends Oi(wa,[`center`]){constructor(e={}){super(e),this.center(e.center||new P),this._radius=e.radius===void 0?1:e.radius,this._fallbackFill=e.fallbackFill}radius(e){return e===void 0?this._radius:(this._radius=e,this.geometryChange(),this)}fallbackFill(e){return e===void 0?this._fallbackFill:(this._fallbackFill=e,this.optionsChange(),this)}},Oa=class extends L{get nodeType(){return`Pattern`}constructor(e){super();let{width:t,height:n}=e;this._size=Vr.create([t,n]),this.id=En()}size(e){return e?(this._size=Vr.create(e),this):this._size}},ka=h({easeInOutBack:()=>Ha,easeInOutCubic:()=>Pa,easeInOutExpo:()=>Ba,easeInOutQuad:()=>Ia,easeInOutQuint:()=>Wa,easeInOutSine:()=>Ra,easeOutBack:()=>Va,easeOutCirc:()=>La,easeOutCubic:()=>Na,easeOutElastic:()=>Ma,easeOutExpo:()=>za,easeOutQuad:()=>Fa,easeOutQuint:()=>Ua,linear:()=>ja,swing:()=>Aa});function Aa(e){return .5-Math.cos(e*Math.PI)/2}function ja(e){return e}function Ma(e){return e===0||e===1?e:2**(-10*e)*Math.sin((e-.125)*(1.1*Math.PI)/.5)+1}function Na(e){return 1-(1-e)**3}function Pa(e){return e<.5?4*e*e*e:1-(-2*e+2)**3/2}function Fa(e){return 1-(1-e)**2}function Ia(e){return e<.5?2*e*e:1-(-2*e+2)**2/2}function La(e){return Math.sqrt(1-(e-1)**2)}function Ra(e){return-(Math.cos(Math.PI*e)-1)/2}function za(e){return e===1?1:1-2**(-10*e)}function Ba(e){return e===0||e===1?e:e<.5?2**(20*e-10)/2:(2-2**(-20*e+10))/2}function Va(e){return 1+2.70158*(e-1)**3+1.70158*(e-1)**2}function Ha(e){let t=1.70158*1.525;return e<.5?(2*e)**2*(3.5949095*2*e-t)/2:((2*e-2)**2*(3.5949095*(e*2-2)+t)+2)/2}function Ua(e){return 1-(1-e)**5}function Wa(e){return e<.5?16*e**5:1-(-2*e+2)**5/2}let Ga;var Ka=class e extends jt{static get current(){return Ga||=new e,Ga}constructor(){super(),this._items=[]}register(e,t){this._items.push({name:e,type:t})}create(e,t){let n=this._items,r;if(t&&t.type){let e=t.type.toLowerCase();for(let t=0;t<n.length;t++)if(n[t].name.toLowerCase()===e){r=n[t];break}}if(r)return new r.type(e,t)}};function qa(e){return Math.min(1,Math.max(0,e))}function Ja(e,t,n,r){let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c;function u(e){return((o*e+a)*e+i)*e}function d(e){return((l*e+c)*e+s)*e}function f(e){return(3*o*e+2*a)*e+i}function p(e){let t=e;for(let n=0;n<8;n++){let n=u(t)-e,r=f(t);if(Math.abs(n)<1e-7)return t;if(Math.abs(r)<1e-7)break;t-=n/r}let n=0,r=1;t=e;for(let t=0;t<24;t++){let t=(n+r)/2,i=u(t);if(Math.abs(i-e)<1e-7)return t;i<e?n=t:r=t}return(n+r)/2}return e=>{let t=qa(e);return t===0||t===1?t:d(p(t))}}let Ya={duration:500,easing:`swing`};(class extends jt{static create(e,t,n){return Ka.current.create(e,t,n)}get options(){return this._options||Ya}set options(e){this._options=e}constructor(e,t){super(),this.options=Object.assign({},this.options,t),this.element=e}setup(){}step(){}play(){let e=this.options;typeof e.easing==`string`&&ka[e.easing]?e.easing=ka[e.easing]:Array.isArray(e.easing)&&e.easing.length===4?e.easing=Ja(...e.easing):e.easing=ka[Ya.easing];let{duration:t,delay:n=0,easing:r}=e,i=Yt()+n,a=i+t;t===0?(this.step(1),this.abort()):setTimeout(()=>{let e=()=>{if(this._stopped)return;let n=Yt(),o=Vn(n-i,0,t),s=r(o/t);this.step(s),n<a?Rt(e):this.abort()};e()},n)}abort(){this._stopped=!0}destroy(){this.abort()}});let Xa;(class e extends jt{static get current(){return Xa||=new e,Xa}parse(e,t){return ta(new oa(t),e)}});var Za=class extends jt{constructor(e){super(),this.childNodes=[],this.parent=null,e&&(this.srcElement=e,this.observe())}destroy(){this.srcElement&&this.srcElement.removeObserver(this);let e=this.childNodes;for(let t=0;t<e.length;t++)this.childNodes[t].destroy();this.parent=null}load(){}observe(){this.srcElement&&this.srcElement.addObserver(this)}append(e){this.childNodes.push(e),e.parent=this}insertAt(e,t){this.childNodes.splice(t,0,e),e.parent=this}remove(e,t){let n=e+t;for(let t=e;t<n;t++)this.childNodes[t].removeSelf();this.childNodes.splice(e,t)}removeSelf(){this.clear(),this.destroy()}clear(){this.remove(0,this.childNodes.length)}invalidate(){this.parent&&this.parent.invalidate()}geometryChange(){this.invalidate()}optionsChange(){this.invalidate()}childrenChange(e){e.action===`add`?this.load(e.items,e.index):e.action===`remove`&&this.remove(e.index,e.items.length),this.invalidate()}};let Qa=[`click`,`mouseenter`,`mouseleave`,`mousemove`,`resize`];var $a=class extends Mt{constructor(e,t){super(),this.options=Object.assign({},t),this.element=e,this.element._kendoExportVisual=this.exportVisual.bind(this),this._click=this._handler(`click`),this._mouseenter=this._handler(`mouseenter`),this._mouseleave=this._handler(`mouseleave`),this._mousemove=this._handler(`mousemove`),this._visual=new L,Zn(e,this.options),this.bind(Qa,this.options),this._enableTracking()}draw(e){this._visual.children.push(e)}clear(){this._visual.children=[]}destroy(){this._visual=null,this.element._kendoExportVisual=null,this.unbind()}eventTarget(e){let t=Rn(e),n;for(;!n&&t&&(n=t._kendoNode,t!==this.element);)t=t.parentElement;if(n)return n.srcElement}exportVisual(){return this._visual}getSize(){return Zn(this.element)}currentSize(e){if(e)this._size=e;else return this._size}setSize(e){Zn(this.element,e),this.currentSize(e),this._resize()}resize(e){let t=this.getSize(),n=this.currentSize();(e||(t.width>0||t.height>0)&&(!n||t.width!==n.width||t.height!==n.height))&&(this.currentSize(t),this._resize(t,e),this.trigger(`resize`,t))}size(e){if(!e)return this.getSize();this.setSize(e)}suspendTracking(){this._suspendedTracking=!0}resumeTracking(){this._suspendedTracking=!1}_enableTracking(){}_resize(){}_handler(e){return t=>{let n=this.eventTarget(t);n&&!this._suspendedTracking&&this.trigger(e,{element:n,originalEvent:t,type:e})}}_elementOffset(){let e=this.element,t=$n(e),{left:n,top:r}=Jn(e);return{left:n+t.left,top:r+t.top}}_surfacePoint(e){let t=this._elementOffset(),n=Ln(e),r=n.x-t.left,i=n.y-t.top,a=ir(this.element).invert();return new P(r,i).transform(a)}};function eo(e,t){return t==null?``:` ${e}="${t}" `}function to(e){let t=``;for(let n=0;n<e.length;n++)t+=eo(e[n][0],e[n][1]);return t}function no(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n][1];r!==void 0&&(t+=e[n][0]+`:`+r+`;`)}if(t!==``)return t}let ro={},io=`none`,ao=(e,t)=>{zr(e,t)},oo=(e,t)=>{let n=new DOMParser().parseFromString(Ir(t),`text/xml`);Lr(n);let r=document.adoptNode(n.documentElement);e.insertBefore(r,e.firstChild)},so,co=(e,t)=>{if(so)return so(e,t);if(so=ao,typeof document<`u`){let e=document.createElement(`div`),t=typeof DOMParser<`u`;e.innerHTML=`<svg xmlns='http://www.w3.org/2000/svg'></svg>`,t&&e.firstChild.namespaceURI!==`http://www.w3.org/2000/svg`&&(so=oo)}return so(e,t)},lo=`transform`,uo={clip:`clip-path`,fill:`fill`};function fo(e,t){return e===`clip`||e===`fill`&&(!t||t.nodeType===`Gradient`||t.nodeType===`Pattern`)}var po=class extends Za{constructor(e,t){super(e),this.definitions={},this.options=t}destroy(){this.element&&=(this.element._kendoNode=null,null),this.clearDefinitions(),super.destroy()}load(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=r.children,a=new ro[r.nodeType](r,this.options);t===void 0?this.append(a):this.insertAt(a,t),a.createDefinitions(),i&&i.length>0&&a.load(i);let o=this.element;o&&a.attachTo(o,t)}}root(){let e=this;for(;e.parent;)e=e.parent;return e}attachTo(e,t){let n=document.createElement(`div`);co(n,`<svg xmlns='http://www.w3.org/2000/svg' version='1.1'>`+this.render()+`</svg>`);let r=n.firstChild.firstChild;r&&(t===void 0?e.appendChild(r):e.insertBefore(r,e.childNodes[t]||null),this.setElement(r))}setElement(e){this.element&&(this.element._kendoNode=null),this.element=e,this.element._kendoNode=this;let t=this.childNodes;for(let n=0;n<t.length;n++){let r=e.childNodes[n];t[n].setElement(r)}}clear(){this.clearDefinitions(),this.element&&(this.element.innerHTML=``);let e=this.childNodes;for(let t=0;t<e.length;t++)e[t].destroy();this.childNodes=[]}removeSelf(){if(this.element){let e=this.element.parentNode;e&&e.removeChild(this.element),this.element=null}super.removeSelf()}template(){return this.renderChildren()}render(){return this.template()}renderChildren(){let e=this.childNodes,t=``;for(let n=0;n<e.length;n++)t+=e[n].render();return t}optionsChange(e){let{field:t,value:n}=e;t===`visible`?this.css(`display`,n?``:io):uo[t]&&fo(t,n)?this.updateDefinition(t,n):t===`opacity`?this.attr(`opacity`,n):t===`cursor`?this.css(`cursor`,n):t===`id`&&(n?this.attr(`id`,n):this.removeAttr(`id`)),super.optionsChange(e)}accessibilityOptionsChange(e){let{field:t,value:n}=e;t===`role`?n?this.attr(`role`,n):this.removeAttr(`role`):t===`ariaLabel`?n?this.attr(`aria-label`,Wt(n)):this.removeAttr(`aria-label`):t===`ariaRoleDescription`?n?this.attr(`aria-roledescription`,Wt(n)):this.removeAttr(`aria-roledescription`):t===`ariaChecked`?n===void 0?this.removeAttr(`aria-checked`):this.attr(`aria-checked`,n):t===`className`&&this.className(n)}attr(e,t){this.element&&this.element.setAttribute(e,t)}allAttr(e){for(let t=0;t<e.length;t++)this.attr(e[t][0],e[t][1])}toggleAttr(e,t){t?this.attr(e,t):this.removeAttr(e)}css(e,t){this.element&&(this.element.style[e]=t)}allCss(e){for(let t=0;t<e.length;t++)this.css(e[t][0],e[t][1])}className(e){this.element&&(this.element.classList.remove(...this.element.classList),e&&e.split(` `).forEach(e=>{e&&this.element.classList.add(e)}))}removeAttr(e){this.element&&this.element.removeAttribute(e)}mapTransform(e){let t=[];return e&&t.push([lo,`matrix(`+e.matrix().toString(6)+`)`]),t}renderTransform(){return to(this.mapTransform(this.srcElement.transform()))}transformChange(e){e?this.allAttr(this.mapTransform(e)):this.removeAttr(lo)}mapStyle(){let e=this.srcElement.options,t=[[`cursor`,e.cursor]];return e.visible===!1&&t.push([`display`,io]),t}renderStyle(){return eo(`style`,no(this.mapStyle(!0)))}renderOpacity(){return eo(`opacity`,this.srcElement.options.opacity)}renderId(){return eo(`id`,this.srcElement.options.id)}renderClassName(){return eo(`class`,this.srcElement.options.className)}renderRole(){return eo(`role`,this.srcElement.options.role)}renderAriaLabel(){let e=this.srcElement.options.ariaLabel;return e&&=Wt(e),eo(`aria-label`,e)}renderAriaRoleDescription(){let e=this.srcElement.options.ariaRoleDescription;return e&&=Wt(e),eo(`aria-roledescription`,e)}renderAriaChecked(){return eo(`aria-checked`,this.srcElement.options.ariaChecked)}createDefinitions(){let e=this.srcElement,t=this.definitions;if(e){let n=e.options,r;for(let e in uo){let i=n.get(e);i&&fo(e,i)&&(t[e]=i,r=!0)}r&&this.definitionChange({action:`add`,definitions:t})}}definitionChange(e){this.parent&&this.parent.definitionChange(e)}updateDefinition(e,t){let n=this.definitions,r=n[e],i=uo[e],a={};r&&(a[e]=r,this.definitionChange({action:`remove`,definitions:a}),delete n[e]),t?(a[e]=t,this.definitionChange({action:`add`,definitions:a}),n[e]=t,this.attr(i,this.refUrl(t.id))):r&&this.removeAttr(i)}clearDefinitions(){let e=this.definitions;this.definitionChange({action:`remove`,definitions:e}),this.definitions={}}renderDefinitions(){return to(this.mapDefinitions())}mapDefinitions(){let e=this.definitions,t=[];for(let n in e){let r=e[n];t.push([uo[n],this.refUrl(r.id)])}return t}refUrl(e){return`url(#${e})`}},mo=class extends po{template(){return`<stop ${this.renderOffset()} ${this.renderStyle()} />`}renderOffset(){return eo(`offset`,this.srcElement.offset())}mapStyle(){let e=this.srcElement;return[[`stop-color`,e.color()],[`stop-opacity`,e.opacity()]]}optionsChange(e){e.field===`offset`?this.attr(e.field,e.value):(e.field===`color`||e.field===`opacity`)&&this.css(`stop-`+e.field,e.value)}},ho=class extends po{constructor(e){super(e),this.id=e.id,this.loadStops()}loadStops(){let e=this.srcElement.stops,t=this.element;for(let n=0;n<e.length;n++){let r=new mo(e[n]);this.append(r),t&&r.attachTo(t)}}optionsChange(e){e.field===`gradient.stops`?(Za.prototype.clear.call(this),this.loadStops()):e.field===`gradient`&&this.allAttr(this.mapCoordinates())}renderCoordinates(){return to(this.mapCoordinates())}mapSpace(){return[`gradientUnits`,this.srcElement.userSpace()?`userSpaceOnUse`:`objectBoundingBox`]}},go=class extends ho{template(){return`<linearGradient id='${this.id}' ${this.renderCoordinates()}>${this.renderChildren()}</linearGradient>`}mapCoordinates(){let e=this.srcElement,t=e.start(),n=e.end();return[[`x1`,t.x],[`y1`,t.y],[`x2`,n.x],[`y2`,n.y],this.mapSpace()]}},_o=class extends ho{template(){return`<radialGradient id='${this.id}' ${this.renderCoordinates()}>${this.renderChildren()}</radialGradient>`}mapCoordinates(){let e=this.srcElement,t=e.center(),n=e.radius();return[[`cx`,t.x],[`cy`,t.y],[`r`,n],this.mapSpace()]}},vo=class extends po{constructor(e){super(e),this.id=e.id,this.load(e.children)}template(){let e=this.srcElement.size().getWidth(),t=this.srcElement.size().getHeight();return`<pattern id='${this.srcElement.id}' width='${e}' height='${t}' patternUnits='userSpaceOnUse'>${this.renderChildren()}</pattern>`}},yo=class extends po{constructor(e){super(),this.srcElement=e,this.id=e.id,this.load([e])}renderClipRule(){return eo(`clip-rule`,`evenodd`)}template(){return`<clipPath ${this.renderClipRule()} id='${this.id}'>${this.renderChildren()}</clipPath>`}},bo=class extends po{constructor(){super(),this.definitionMap={}}attachTo(e){this.element=e}template(){return`<defs>${this.renderChildren()}</defs>`}definitionChange(e){let{definitions:t,action:n}=e;n===`add`?this.addDefinitions(t):n===`remove`&&this.removeDefinitions(t)}createDefinition(e,t){let n;return e===`clip`?n=yo:e===`fill`&&(t instanceof Ea?n=go:t instanceof Da?n=_o:t.nodeType===`Pattern`&&(n=vo)),new n(t)}addDefinitions(e){for(let t in e)this.addDefinition(t,e[t])}addDefinition(e,t){let{element:n,definitionMap:r}=this,i=t.id,a=r[i];if(a)a.count++;else{let a=this.createDefinition(e,t);r[i]={element:a,count:1},this.append(a),n&&a.attachTo(this.element)}}removeDefinitions(e){for(let t in e)this.removeDefinition(e[t])}removeDefinition(e){let t=this.definitionMap,n=e.id,r=t[n];r&&(r.count--,r.count===0&&(this.remove(this.childNodes.indexOf(r.element),1),delete t[n]))}},xo=class extends po{constructor(e){super(),this.options=e,this.defs=new bo}attachTo(e){this.element=e,this.defs.attachTo(e.firstElementChild)}clear(){Za.prototype.clear.call(this)}template(){return this.defs.render()+this.renderChildren()}definitionChange(e){this.defs.definitionChange(e)}};let So={"fill.opacity":`fill-opacity`,"stroke.color":`stroke`,"stroke.width":`stroke-width`,"stroke.opacity":`stroke-opacity`};var Co=class extends po{geometryChange(){this.attr(`d`,this.renderData()),this.invalidate()}optionsChange(e){switch(e.field){case`fill`:e.value?this.allAttr(this.mapFill(e.value)):this.removeAttr(`fill`);break;case`fill.color`:this.allAttr(this.mapFill({color:e.value}));break;case`stroke`:e.value?this.allAttr(this.mapStroke(e.value)):this.removeAttr(`stroke`);break;case`transform`:this.transformChange(e.value);break;default:{let t=So[e.field];t&&this.attr(t,e.value);break}}this.accessibilityOptionsChange(e),super.optionsChange(e)}content(){this.element&&(this.element.textContent=this.srcElement.content())}renderData(){return this.srcElement.toString(3)||void 0}mapStroke(e){let t=[];return e&&!zn(e.color)?(t.push([`stroke`,e.color]),t.push([`stroke-width`,e.width]),t.push([`stroke-linecap`,this.renderLinecap(e)]),t.push([`stroke-linejoin`,e.lineJoin]),e.opacity!==void 0&&t.push([`stroke-opacity`,e.opacity]),e.dashType!==void 0&&t.push([`stroke-dasharray`,this.renderDashType(e)])):t.push([`stroke`,io]),t}renderStroke(){return to(this.mapStroke(this.srcElement.options.stroke))}renderDashType(e){let{dashType:t,width:n=1}=e;if(t&&t!==`solid`){let e=Wr[t.toLowerCase()],r=[];for(let t=0;t<e.length;t++)r.push(e[t]*n);return r.join(` `)}}renderLinecap(e){let{dashType:t,lineCap:n}=e;return t&&t!==`solid`?Gr:n}mapFill(e){let t=[];return e&&(e.nodeType===`Gradient`||e.nodeType===`Pattern`)||(e&&!zn(e.color)?(t.push([`fill`,e.color]),e.opacity!==void 0&&t.push([`fill-opacity`,e.opacity])):t.push([`fill`,io])),t}renderFill(){return to(this.mapFill(this.srcElement.options.fill))}template(){return`<path ${this.renderId()} ${this.renderStyle()} ${this.renderOpacity()} ${eo(`d`,this.renderData())}${this.renderStroke()}${this.renderFill()}${this.renderDefinitions()}${this.renderTransform()}${this.renderClassName()} ${this.renderRole()}${this.renderAriaLabel()} ${this.renderAriaRoleDescription()}${this.renderAriaChecked()} ></path>`}},wo=class extends Co{renderData(){return this.srcElement.toPath().toString(3)}},To=class extends Co{geometryChange(){let e=this.center();this.attr(`cx`,e.x),this.attr(`cy`,e.y),this.attr(`r`,this.radius()),this.invalidate()}center(){return this.srcElement.geometry().center}radius(){return this.srcElement.geometry().radius}template(){return`<circle ${this.renderId()} ${this.renderStyle()} ${this.renderOpacity()}cx='${this.center().x}' cy='${this.center().y}' r='${this.radius()}'${this.renderStroke()} ${this.renderFill()} ${this.renderDefinitions()}${this.renderClassName()} ${this.renderRole()}${this.renderAriaLabel()} ${this.renderAriaRoleDescription()}${this.renderAriaChecked()} ${this.renderTransform()} ></circle>`}},Eo=class extends po{template(){return`<g${this.renderId()+this.renderTransform()+this.renderClassName()+this.renderStyle()+this.renderOpacity()+this.renderRole()+this.renderAriaLabel()+this.renderAriaRoleDescription()+this.renderAriaChecked()+this.renderDefinitions()}>${this.renderChildren()}</g>`}optionsChange(e){let{field:t,value:n}=e;t===`transform`&&this.transformChange(n),this.accessibilityOptionsChange(e),super.optionsChange(e)}},Do=class extends Co{geometryChange(){this.allAttr(this.mapPosition()),this.invalidate()}optionsChange(e){e.field===`src`&&this.allAttr(this.mapSource()),super.optionsChange(e)}mapPosition(){let e=this.srcElement.rect(),t=e.topLeft();return[[`x`,t.x],[`y`,t.y],[`width`,e.width()+`px`],[`height`,e.height()+`px`]]}renderPosition(){return to(this.mapPosition())}mapSource(e){let t=this.srcElement.src();return e&&(t=Wt(t)),[[`xlink:href`,t]]}renderSource(){return to(this.mapSource(!0))}template(){return`<image preserveAspectRatio='none' ${this.renderId()} ${this.renderStyle()} ${this.renderTransform()} ${this.renderOpacity()}${this.renderPosition()} ${this.renderSource()} ${this.renderDefinitions()}${this.renderClassName()} ${this.renderRole()}${this.renderAriaLabel()} ${this.renderAriaRoleDescription()}${this.renderAriaChecked()} ></image>`}},Oo=class extends Co{renderData(){return this.srcElement.toString(3)||`undefined`}},ko=class extends Co{geometryChange(){let e=this.srcElement.geometry();this.attr(`x`,e.origin.x),this.attr(`y`,e.origin.y),this.attr(`width`,e.size.width),this.attr(`height`,e.size.height),this.attr(`rx`,e.cornerRadius[0]),this.attr(`ry`,e.cornerRadius[1]),this.invalidate()}size(){return this.srcElement.geometry().size}origin(){return this.srcElement.geometry().origin}rx(){return this.srcElement.geometry().cornerRadius[0]}ry(){return this.srcElement.geometry().cornerRadius[1]}template(){return`<rect ${this.renderId()} ${this.renderStyle()} ${this.renderOpacity()} x='${this.origin().x}' y='${this.origin().y}' rx='${this.rx()}' ry='${this.ry()}' width='${this.size().width}' height='${this.size().height}' ${this.renderStroke()} ${this.renderFill()} ${this.renderDefinitions()} ${this.renderTransform()}${this.renderClassName()} ${this.renderRole()}${this.renderAriaLabel()} ${this.renderAriaRoleDescription()}${this.renderAriaChecked()} />`}};let Ao=/&(?:[a-zA-Z]+|#\d+);/g;function jo(e){if(!e||typeof e!=`string`||!Ao.test(e))return e;let t=jo._element;return Ao.lastIndex=0,e.replace(Ao,e=>(t.innerHTML=e,t.textContent||t.innerText))}typeof document<`u`&&(jo._element=document.createElement(`span`));var Mo=class extends Co{geometryChange(){let e=this.pos();this.attr(`x`,e.x),this.attr(`y`,e.y),this.invalidate()}optionsChange(e){e.field===`font`?(this.attr(`style`,no(this.mapStyle())),this.geometryChange()):e.field===`content`&&super.content(this.srcElement.content()),super.optionsChange(e)}mapStyle(e){let t=super.mapStyle(e),n=this.srcElement.options.font;return e&&(n=Wt(n)),t.push([`font`,n],[`white-space`,`pre`]),t}pos(){let e=this.srcElement.position(),t=this.srcElement.measure();return e.clone().setY(e.y+t.baseline)}renderContent(){let e=this.srcElement.content();return e=jo(e),e=Wt(e),sr(e)}renderTextAnchor(){let e;return(this.options||{}).rtl&&!(Jt.browser.msie||Jt.browser.edge)&&(e=`end`),eo(`text-anchor`,e)}renderPaintOrder(){let e=this.srcElement.options.paintOrder;return e?eo(`paint-order`,e):``}template(){return`<text ${this.renderId()} ${this.renderTextAnchor()} ${this.renderStyle()} ${this.renderOpacity()}x='${this.pos().x}' y='${this.pos().y}' ${this.renderStroke()} ${this.renderTransform()} ${this.renderDefinitions()}${this.renderPaintOrder()}${this.renderFill()}${this.renderClassName()} ${this.renderRole()}${this.renderAriaLabel()} ${this.renderAriaRoleDescription()}${this.renderAriaChecked()}>${this.renderContent()}</text>`}};ro.Arc=wo,ro.Circle=To,ro.Group=Eo,ro.Image=Do,ro.MultiPath=Oo,ro.Path=Co,ro.Rect=ko,ro.Text=Mo;function No(e){let t;try{t=e.getScreenCTM?e.getScreenCTM():null}catch{}if(t){let n=-t.e%1,r=-t.f%1,i=e.style;(n!==0||r!==0)&&(i.left=n+`px`,i.top=r+`px`)}}var Po=class extends $a{get type(){return`svg`}constructor(e,t){super(e,t),this._root=new xo(Object.assign({rtl:Yn(e,`direction`).direction===`rtl`},this.options)),co(this.element,this._template(``)),this._rootElement=this.element.firstElementChild,this._rootElement.style.width=`100%`,this._rootElement.style.height=`100%`,this._rootElement.style.overflow=`hidden`,No(this._rootElement),this._root.attachTo(this._rootElement),qn(this.element,{click:this._click,mouseover:this._mouseenter,mouseout:this._mouseleave,mousemove:this._mousemove}),this.resize()}destroy(){this._root&&(this._root.destroy(),this._root=null,this._rootElement&&this._rootElement.parentNode&&this._rootElement.parentNode.removeChild(this._rootElement),this._rootElement=null,Qn(this.element,{click:this._click,mouseover:this._mouseenter,mouseout:this._mouseleave,mousemove:this._mousemove})),super.destroy()}translate(e){let t=`${Math.round(e.x)} ${Math.round(e.y)} ${this._size.width} ${this._size.height}`;this._offset=e,this._rootElement.setAttribute(`viewBox`,t)}draw(e){super.draw(e),this._root.load([e])}clear(){super.clear(),this._root.clear()}svg(){return`<?xml version='1.0' ?>`+this._template()}exportVisual(){let{_visual:e,_offset:t}=this;if(t){let n=new L;n.children.push(e),n.transform(Ur().translate(-t.x,-t.y)),e=n}return e}_resize(){this._offset&&this.translate(this._offset)}_template(e){return`<svg ${typeof e==`string`?e:`style='width: 100%; height: 100%; overflow: hidden;' `}xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1'>${this._root.render()}</svg>`}};let Fo={};var Io=class extends Za{constructor(e){super(e),e&&this.initClip()}initClip(){let e=this.srcElement.clip();e&&(this.clip=e,e.addObserver(this))}clear(){this.srcElement&&this.srcElement.removeObserver(this),this.clearClip(),super.clear()}clearClip(){this.clip&&(this.clip.removeObserver(this),delete this.clip)}setClip(e){this.clip&&(e.beginPath(),new Fo[this.clip.nodeType](this.clip).renderPoints(e,this.clip),e.clip(`evenodd`))}optionsChange(e){e.field===`clip`&&(this.clearClip(),this.initClip()),super.optionsChange(e)}setTransform(e){if(this.srcElement){let t=this.srcElement.transform();t&&e.transform.apply(e,t.matrix().toArray(6))}}loadElements(e,t,n){for(let r=0;r<e.length;r++){let i=e[r],a=i.children,o=new Fo[i.nodeType](i,n);a&&a.length>0&&o.load(a,t,n),t===void 0?this.append(o):this.insertAt(o,t)}}load(e,t,n){this.loadElements(e,t,n),this.invalidate()}setOpacity(e){if(this.srcElement){let t=this.srcElement.opacity();t!==void 0&&this.globalAlpha(e,t)}}globalAlpha(e,t){let n=t;n&&e.globalAlpha&&(n*=e.globalAlpha),e.globalAlpha=n}visible(){let e=this.srcElement;return!e||e&&e.options.visible!==!1}},Lo=class extends la(Io,`childNodes`){renderTo(e){if(!this.visible())return;e.save(),this.setTransform(e),this.setClip(e),this.setOpacity(e);let t=this.childNodes;for(let n=0;n<t.length;n++){let r=t[n];r.visible()&&r.renderTo(e)}e.restore()}},Ro=class extends la(Lo,`childNodes`){constructor(e,t){super(),this.canvas=e,this.size=t,this.ctx=e.getContext(`2d`);let n=this._invalidate.bind(this);this.invalidate=Xt(()=>{Rt(n)},16.666666666666668)}destroy(){super.destroy(),this.canvas=null,this.ctx=null}load(e,t,n){this.loadElements(e,t,n),this._invalidate()}_rescale(e){let{canvas:t,size:n}=this;t.width=n.width*e,t.height=n.height*e,this.ctx.scale(e,e)}_devicePixelRatio(){return typeof window.devicePixelRatio==`number`?window.devicePixelRatio:1}_invalidate(e){if(!this.ctx)return;let t=e&&e.fixedScale?1:this._devicePixelRatio();this._rescale(t),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.renderTo(this.ctx)}},zo=class extends jt{constructor(){super(),this.shapes=[]}_add(e,t){this.shapes.push({bbox:t,shape:e}),e._quadNode=this}pointShapes(e){let t=this.shapes,n=t.length,r=[];for(let i=0;i<n;i++)t[i].bbox.containsPoint(e)&&r.push(t[i].shape);return r}insert(e,t){this._add(e,t)}remove(e){let t=this.shapes,n=t.length;for(let r=0;r<n;r++)if(t[r].shape===e){t.splice(r,1);break}}},Bo=class e extends zo{constructor(e){super(),this.children=[],this.rect=e}inBounds(e){let t=this.rect,n=t.bottomRight(),r=e.bottomRight();return t.origin.x<=e.origin.x&&t.origin.y<=e.origin.y&&r.x<=n.x&&r.y<=n.y}pointShapes(e){let t=this.children,n=t.length,r=super.pointShapes(e);for(let i=0;i<n;i++)xn(r,t[i].pointShapes(e));return r}insert(e,t){let n=this.children,r=!1;if(this.inBounds(t)){if(this.shapes.length<4)this._add(e,t);else{n.length||this._initChildren();for(let i=0;i<n.length;i++)if(n[i].insert(e,t)){r=!0;break}r||this._add(e,t)}r=!0}return r}_initChildren(){let{rect:t,children:n}=this,r=t.center(),i=t.width()/2,a=t.height()/2;n.push(new e(new F([t.origin.x,t.origin.y],[i,a])),new e(new F([r.x,t.origin.y],[i,a])),new e(new F([t.origin.x,r.y],[i,a])),new e(new F([r.x,r.y],[i,a])))}};let Vo=3e3,Ho=BigInt(1e4);var Uo=class extends jt{constructor(){super(),this.initRoots()}initRoots(){this.rootMap={},this.root=new zo,this.rootElements=[]}clear(){let e=this.rootElements;for(let t=0;t<e.length;t++)this.remove(e[t]);this.initRoots()}pointShape(e){let t=(this.rootMap[Math.floor(e.x/Vo)]||{})[Math.floor(e.y/Vo)],n=this.root.pointShapes(e);t&&(n=n.concat(t.pointShapes(e)));let r=qo(n);this.assignZindex(n,r),n.sort(Wo);for(let t=0;t<n.length;t++)if(n[t].containsPoint(e))return n[t]}assignZindex(e,t){let n=Ko(Ho,BigInt(t)),r=[],i=BigInt(0);for(let t=0;t<e.length;t++){let a=e[t],o=i,s=n,c=[];for(;a;)c.push(a),a=a.parent;for(;c.length;)a=c.pop(),o+=BigInt((a.parent?a.parent.children:this.rootElements).indexOf(a)+1)*s,s/=Ho;e[t]._zIndex=o,r.push(o)}r.sort(Go);for(let t=0;t<e.length;t++)e[t]._zIndex=r.indexOf(e[t]._zIndex)}optionsChange(e){(e.field===`transform`||e.field===`stroke.width`)&&this.bboxChange(e.element)}geometryChange(e){this.bboxChange(e.element)}bboxChange(e){if(e.nodeType===`Group`)for(let t=0;t<e.children.length;t++)this.bboxChange(e.children[t]);else e._quadNode&&e._quadNode.remove(e),this._insertShape(e)}add(e){let t=Array.isArray(e)?e.slice(0):[e];xn(this.rootElements,t),this._insert(t)}childrenChange(e){if(e.action===`remove`)for(let t=0;t<e.items.length;t++)this.remove(e.items[t]);else this._insert(Array.prototype.slice.call(e.items,0))}_insert(e){let t;for(;e.length>0;)t=e.pop(),t.addObserver(this),t.nodeType===`Group`?xn(e,t.children):this._insertShape(t)}_insertShape(e){let t=e.bbox();if(t){let n=this.getSectors(t),r=n[0][0],i=n[1][0];if(this.inRoot(n))this.root.insert(e,t);else{let n=this.rootMap;n[r]||(n[r]={}),n[r][i]||(n[r][i]=new Bo(new F([r*Vo,i*Vo],[Vo,Vo]))),n[r][i].insert(e,t)}}}remove(e){if(e.removeObserver(this),e.nodeType===`Group`){let t=e.children;for(let e=0;e<t.length;e++)this.remove(t[e])}else e._quadNode&&(e._quadNode.remove(e),delete e._quadNode)}inRoot(e){return e[0].length>1||e[1].length>1}getSectors(e){let t=e.bottomRight(),n=Math.floor(t.x/Vo),r=Math.floor(t.y/Vo),i=[[],[]];for(let t=Math.floor(e.origin.x/Vo);t<=n;t++)i[0].push(t);for(let t=Math.floor(e.origin.y/Vo);t<=r;t++)i[1].push(t);return i}};function Wo(e,t){return e._zIndex<t._zIndex?1:e._zIndex>t._zIndex?-1:0}function Go(e,t){return e<t?-1:+(e>t)}function Ko(e,t){let n=e,r=t,i=BigInt(1),a=i;for(;r;)r&i&&(a*=n),r>>=i,r&&(n*=n);return a}function qo(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n],i=[];for(;r;)i.push(r),r=r.parent;t=Math.max(t,i.length)}return t+1}var Jo=class{constructor(e){e.bind(`mouseenter`,this._mouseenter.bind(this)),e.bind(`mouseleave`,this._mouseleave.bind(this)),this.element=e.element}clear(){this._resetCursor()}destroy(){this._resetCursor(),delete this.element}_mouseenter(e){let t=this._shapeCursor(e);t?(this._current||(this._defaultCursor=this._getCursor()),this._setCursor(t)):this._resetCursor()}_mouseleave(){this._resetCursor()}_shapeCursor(e){let t=e.element;for(;t&&t.options.cursor===void 0;)t=t.parent;if(t)return t.options.cursor}_getCursor(){if(this.element)return this.element.style.cursor}_setCursor(e){this.element&&(this.element.style.cursor=e,this._current=e)}_resetCursor(){this._current&&(this._setCursor(this._defaultCursor||``),delete this._current)}};function Yo(e,t){let n=t.segments;if(n.length===0)return;let r=n[0],i=r.anchor();e.moveTo(i.x,i.y);for(let t=1;t<n.length;t++){r=n[t],i=r.anchor();let a=n[t-1].controlOut(),o=r.controlIn();a&&o?e.bezierCurveTo(a.x,a.y,o.x,o.y,i.x,i.y):e.lineTo(i.x,i.y)}t.options.closed&&e.closePath()}function Xo(e,t){for(let n=0;n<t.length;n++){let r=t[n],i=ln(r.color());i.a*=r.opacity(),e.addColorStop(r.offset(),i.toCssRgba())}}var Zo=class extends Io{renderTo(e){e.save(),this.setTransform(e),this.setClip(e),this.setOpacity(e),e.beginPath(),this.renderPoints(e,this.srcElement),this.setLineDash(e),this.setLineCap(e),this.setLineJoin(e),this.setFill(e),this.setStroke(e),e.restore()}setFill(e){let t=this.srcElement.options.fill,n=!1;return t&&(t.nodeType===`Gradient`?(this.setGradientFill(e,t),n=!0):t.nodeType===`Pattern`?(this.setPatternFill(e,t),n=!0):zn(t.color)||(e.fillStyle=t.color,e.save(),this.globalAlpha(e,t.opacity),e.fill(),e.restore(),n=!0)),n}setGradientFill(e,t){let n=this.srcElement.rawBBox(),r;if(t instanceof Ea){let n=t.start(),i=t.end();r=e.createLinearGradient(n.x,n.y,i.x,i.y)}else if(t instanceof Da){let n=t.center();r=e.createRadialGradient(n.x,n.y,0,n.x,n.y,t.radius())}Xo(r,t.stops),e.save(),t.userSpace()||e.transform(n.width(),0,0,n.height(),n.origin.x,n.origin.y),e.fillStyle=r,e.fill(),e.restore()}setPatternFill(e,t){let n=t.size(),r=document.createElement(`canvas`),i=r.getContext(`2d`);r.width=n.getWidth(),r.height=n.getHeight(),this.childNodes.length=0,this.loadElements(t.children);let a=this.childNodes;for(let e=0;e<a.length;e++)a[e].renderTo(i);e.save(),e.fillStyle=e.createPattern(r,`repeat`),e.fill(),e.restore()}setStroke(e){let t=this.srcElement.options.stroke;if(t&&!zn(t.color)&&t.width>0)return e.strokeStyle=t.color,e.lineWidth=Kn(t.width,1),e.lineJoin=Kn(t.lineJoin,e.lineJoin),e.save(),this.globalAlpha(e,t.opacity),e.stroke(),e.restore(),!0}dashType(){let e=this.srcElement.options.stroke;if(e&&e.dashType)return e.dashType.toLowerCase()}setLineDash(e){let t=this.dashType();if(t&&t!==`solid`){let n=Wr[t];e.setLineDash?e.setLineDash(n):(e.mozDash=n,e.webkitLineDash=n)}}setLineCap(e){let t=this.dashType(),n=this.srcElement.options.stroke;t&&t!==`solid`?e.lineCap=Gr:n&&n.lineCap&&(e.lineCap=n.lineCap)}setLineJoin(e){let t=this.srcElement.options.stroke;t&&t.lineJoin&&(e.lineJoin=t.lineJoin)}renderPoints(e,t){Yo(e,t)}},Qo=class extends Zo{renderPoints(e){Yo(e,this.srcElement.toPath())}},$o=class extends Zo{renderPoints(e){let{center:t,radius:n}=this.srcElement.geometry();e.arc(t.x,t.y,n,0,Math.PI*2)}},es=class extends Zo{constructor(e,t){super(e),this.onLoad=this.onLoad.bind(this),this.onError=this.onError.bind(this),this.loading=wn();let n=this.img=new Image,r=e.src();t&&!/^data:/i.test(r)&&(n.crossOrigin=t),r&&(n.src=r),n.complete?this.onLoad():(n.onload=this.onLoad,n.onerror=this.onError)}renderTo(e){this.loading.state()===`resolved`&&(e.save(),this.setTransform(e),this.setClip(e),this.drawImage(e),e.restore())}optionsChange(e){e.field===`src`?(this.loading=wn(),this.img.src=this.srcElement.src()):super.optionsChange(e)}onLoad(){this.loading.resolve(),this.invalidate()}onError(){this.loading.reject(Error(`Unable to load image '`+this.img.src+`'. Check for connectivity and verify CORS headers.`))}drawImage(e){let t=this.srcElement.rect(),n=t.topLeft();e.drawImage(this.img,n.x,n.y,t.width(),t.height())}},ts=class extends Zo{renderPoints(e){let t=this.srcElement.paths;for(let n=0;n<t.length;n++)Yo(e,t[n])}},ns=class extends Zo{renderPoints(e){let t=this.srcElement.geometry(),[n,r]=t.cornerRadius;if(n===0&&r===0){let{origin:n,size:r}=t;e.rect(n.x,n.y,r.width,r.height)}else super.renderPoints(e,I.fromRect(t))}},rs=class extends Zo{renderTo(e){let t=this.srcElement,n=t.position(),r=t.measure();e.save(),this.setTransform(e),this.setClip(e),this.setOpacity(e),e.beginPath(),e.font=t.options.font,e.textAlign=`left`,t.options.paintOrder===`stroke`?(this.stroke(e,t,n,r),this.fill(e,t,n,r)):(this.fill(e,t,n,r),this.stroke(e,t,n,r)),e.restore()}stroke(e,t,n,r){this.setStroke(e)&&(this.setLineDash(e),e.strokeText(t.content(),n.x,n.y+r.baseline))}fill(e,t,n,r){this.setFill(e)&&e.fillText(t.content(),n.x,n.y+r.baseline)}};Fo.Arc=Qo,Fo.Circle=$o,Fo.Group=Lo,Fo.Image=es,Fo.MultiPath=ts,Fo.Path=Zo,Fo.Rect=ns,Fo.Text=rs;var is=class extends $a{get type(){return`canvas`}constructor(e,t){super(e,t),zr(this.element,this._template(this));let n=this.element.firstElementChild;n.style.width=`100%`,n.style.height=`100%`;let r=Zn(e);n.width=r.width,n.height=r.height,this._rootElement=n,this._root=new Ro(n,r),this._mouseTrackHandler=this._trackMouse.bind(this),qn(this.element,{click:this._mouseTrackHandler,mousemove:this._mouseTrackHandler})}destroy(){super.destroy(),this._root&&=(this._root.destroy(),null),this._searchTree&&(this._searchTree.clear(),delete this._searchTree),this._cursor&&(this._cursor.destroy(),delete this._cursor),Qn(this.element,{click:this._mouseTrackHandler,mousemove:this._mouseTrackHandler}),this._rootElement&&this._rootElement.parentNode&&this._rootElement.parentNode.removeChild(this._rootElement),this._rootElement=null}draw(e){super.draw(e),this._root.load([e],void 0,this.options.cors),this._searchTree&&this._searchTree.add([e])}clear(){super.clear(),this._root.clear(),this._searchTree&&this._searchTree.clear(),this._cursor&&this._cursor.clear()}eventTarget(e){if(this._searchTree){let t=this._surfacePoint(e);return this._searchTree.pointShape(t)}}image(){let{_root:e,_rootElement:t}=this,n=[];e.traverse(e=>{e.loading&&n.push(e.loading)});let r=wn(),i=()=>{e._invalidate({fixedScale:!0});try{let e=t.toDataURL();r.resolve(e)}catch(e){r.reject(e)}};return Un(n).then(i,i),r}suspendTracking(){super.suspendTracking(),this._searchTree&&(this._searchTree.clear(),delete this._searchTree)}resumeTracking(){if(super.resumeTracking(),!this._searchTree){this._searchTree=new Uo;let e=this._root.childNodes,t=[];for(let n=0;n<e.length;n++)t.push(e[n].srcElement);this._searchTree.add(t)}}_resize(){this._rootElement.width=this._size.width,this._rootElement.height=this._size.height,this._root.size=this._size,this._root.invalidate()}_template(){return`<canvas></canvas>`}_enableTracking(){this._searchTree=new Uo,this._cursor=new Jo(this),super._enableTracking()}_trackMouse(e){if(this._suspendedTracking)return;let t=this.eventTarget(e);if(e.type!==`click`){let n=this._currentShape;n&&n!==t&&this.trigger(`mouseleave`,{element:n,originalEvent:e,type:`mouseleave`}),t&&n!==t&&this.trigger(`mouseenter`,{element:t,originalEvent:e,type:`mouseenter`}),this.trigger(`mousemove`,{element:t,originalEvent:e,type:`mousemove`}),this._currentShape=t}else t&&this.trigger(`click`,{element:t,originalEvent:e,type:`click`})}};let as,os,ss=()=>typeof document<`u`,cs=()=>ss()&&document.createElement(`canvas`).getContext,ls=()=>ss()&&document.implementation.hasFeature(`http://www.w3.org/TR/SVG11/feature#BasicStructure`,`1.1`);var us=class e extends jt{static get support(){return os||={canvas:cs(),svg:ls()},os}static get current(){return as||=new e,as}constructor(){super(),this._items=[{name:`svg`,type:Po},{name:`canvas`,type:is}]}create(e,t){let n=this._items,r=n[0];if(t&&t.type){let e=t.type.toLowerCase();for(let t=0;t<n.length;t++)if(n[t].name===e){r=n[t];break}}if(r)return new r.type(e,t);Gt(`Warning: Unable to create Kendo UI Drawing Surface. Possible causes:
- The browser does not support SVG and Canvas. User agent: ${navigator.userAgent}`)}},ds=class extends $a{static get support(){return us.support}static create(e,t){return us.current.create(e,t)}};let fs=typeof Uint8Array<`u`&&Jt.browser&&(!Jt.browser.msie||Jt.browser.version>9),ps=function(){var e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`;return{decode:function(t){for(var n=t.replace(/[^A-Za-z0-9\+\/\=]/g,``),r=0,i=n.length,a=[];r<i;){var o=e.indexOf(n.charAt(r++)),s=e.indexOf(n.charAt(r++)),c=e.indexOf(n.charAt(r++)),l=e.indexOf(n.charAt(r++)),u=o<<2|s>>>4,d=(s&15)<<4|c>>>2,f=(c&3)<<6|l;a.push(u),c!=64&&a.push(d),l!=64&&a.push(f)}return a},encode:function(t){for(var n=0,r=t.length,i=``;n<r;){var a=t[n++],o=t[n++],s=t[n++],c=a>>>2,l=(a&3)<<4|o>>>4,u=(o&15)<<2|s>>>6,d=s&63;n-r==2?u=d=64:n-r==1&&(d=64),i+=e.charAt(c)+e.charAt(l)+e.charAt(u)+e.charAt(d)}return i}}}();function ms(e){var t=0,n=0;e==null?e=fs?new Uint8Array(256):[]:n=e.length;var r=fs?function(t){if(t>=e.length){var n=new Uint8Array(Math.max(t+256,e.length*2));n.set(e,0),e=n}}:function(){},i=fs?function(){return new Uint8Array(e.buffer,0,n)}:function(){return e},a=fs?function(i){if(typeof i==`string`)return te(i);var a=i.length;r(t+a),e.set(i,t),t+=a,t>n&&(n=t)}:function(e){if(typeof e==`string`)return te(e);for(var t=0;t<e.length;++t)l(e[t])},o=fs?function(t,n){if(e.buffer.slice)return new Uint8Array(e.buffer.slice(t,t+n));var r=new Uint8Array(n);return r.set(new Uint8Array(e.buffer,t,n)),r}:function(t,n){return e.slice(t,t+n)};function s(){return t>=n}function c(){return t<n?e[t++]:0}function l(i){r(t),e[t++]=i&255,t>n&&(n=t)}function u(){return c()<<8|c()}function d(e){l(e>>8),l(e)}function f(){var e=u();return e>=32768?e-65536:e}function p(e){d(e<0?e+65536:e)}function m(){return u()*65536+u()}function h(e){d(e>>>16&65535),d(e&65535)}function g(){var e=m();return e>=2147483648?e-4294967296:e}function _(e){h(e<0?e+4294967296:e)}function v(){return m()/65536}function y(e){h(Math.round(e*65536))}function b(){return g()/65536}function x(e){_(Math.round(e*65536))}function S(e){return C(e,c)}function ee(e){return String.fromCharCode.apply(String,S(e))}function te(e){for(var t=0;t<e.length;++t)l(e.charCodeAt(t))}function C(e,t){for(var n=Array(e),r=0;r<e;++r)n[r]=t();return n}var w={eof:s,readByte:c,writeByte:l,readShort:u,writeShort:d,readLong:m,writeLong:h,readFixed:v,writeFixed:y,readShort_:f,writeShort_:p,readLong_:g,writeLong_:_,readFixed_:b,writeFixed_:x,read:S,write:a,readString:ee,writeString:te,times:C,get:i,slice:o,offset:function(e){return e==null?t:(t=e,w)},skip:function(e){t+=e},toString:function(){throw Error(`FIX CALLER.  BinaryStream is no longer convertible to string!`)},length:function(){return n},saveExcursion:function(e){var n=t;try{return e()}finally{t=n}},writeBase64:function(e){window.atob?te(window.atob(e)):a(ps.decode(e))},base64:function(){return ps.encode(i())}};return w}function hs(e){return e.map(function(e){var t=``;return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),t+=String.fromCharCode(e),t}).join(``)}var gs=class{constructor(e,t){this.definition=t,this.length=t.length,this.offset=t.offset,this.file=e,this.rawData=e.raw,this.parse(e.raw)}raw(){return this.rawData.slice(this.offset,this.length)}parse(){}};(class extends gs{parse(e){e.offset(this.offset),this.version=e.readLong(),this.revision=e.readLong(),this.checkSumAdjustment=e.readLong(),this.magicNumber=e.readLong(),this.flags=e.readShort(),this.unitsPerEm=e.readShort(),this.created=e.read(8),this.modified=e.read(8),this.xMin=e.readShort_(),this.yMin=e.readShort_(),this.xMax=e.readShort_(),this.yMax=e.readShort_(),this.macStyle=e.readShort(),this.lowestRecPPEM=e.readShort(),this.fontDirectionHint=e.readShort_(),this.indexToLocFormat=e.readShort_(),this.glyphDataFormat=e.readShort_()}render(e){var t=ms();return t.writeLong(this.version),t.writeLong(this.revision),t.writeLong(0),t.writeLong(this.magicNumber),t.writeShort(this.flags),t.writeShort(this.unitsPerEm),t.write(this.created),t.write(this.modified),t.writeShort_(this.xMin),t.writeShort_(this.yMin),t.writeShort_(this.xMax),t.writeShort_(this.yMax),t.writeShort(this.macStyle),t.writeShort(this.lowestRecPPEM),t.writeShort_(this.fontDirectionHint),t.writeShort_(e),t.writeShort_(this.glyphDataFormat),t.get()}}),class extends gs{parse(e){e.offset(this.offset),this.file.head.indexToLocFormat===0?this.offsets=e.times(this.length/2,function(){return 2*e.readShort()}):this.offsets=e.times(this.length/4,e.readLong)}offsetOf(e){return this.offsets[e]}lengthOf(e){return this.offsets[e+1]-this.offsets[e]}render(e){for(var t=ms(),n=e[e.length-1]>65535,r=0;r<e.length;++r)n?t.writeLong(e[r]):t.writeShort(e[r]/2);return{format:+!!n,table:t.get()}}},class extends gs{parse(e){e.offset(this.offset),this.version=e.readLong(),this.ascent=e.readShort_(),this.descent=e.readShort_(),this.lineGap=e.readShort_(),this.advanceWidthMax=e.readShort(),this.minLeftSideBearing=e.readShort_(),this.minRightSideBearing=e.readShort_(),this.xMaxExtent=e.readShort_(),this.caretSlopeRise=e.readShort_(),this.caretSlopeRun=e.readShort_(),this.caretOffset=e.readShort_(),e.skip(8),this.metricDataFormat=e.readShort_(),this.numOfLongHorMetrics=e.readShort()}render(e){var t=ms();return t.writeLong(this.version),t.writeShort_(this.ascent),t.writeShort_(this.descent),t.writeShort_(this.lineGap),t.writeShort(this.advanceWidthMax),t.writeShort_(this.minLeftSideBearing),t.writeShort_(this.minRightSideBearing),t.writeShort_(this.xMaxExtent),t.writeShort_(this.caretSlopeRise),t.writeShort_(this.caretSlopeRun),t.writeShort_(this.caretOffset),t.write([0,0,0,0,0,0,0,0]),t.writeShort_(this.metricDataFormat),t.writeShort(e.length),t.get()}},class extends gs{parse(e){e.offset(this.offset),this.version=e.readLong(),this.numGlyphs=e.readShort(),this.maxPoints=e.readShort(),this.maxContours=e.readShort(),this.maxComponentPoints=e.readShort(),this.maxComponentContours=e.readShort(),this.maxZones=e.readShort(),this.maxTwilightPoints=e.readShort(),this.maxStorage=e.readShort(),this.maxFunctionDefs=e.readShort(),this.maxInstructionDefs=e.readShort(),this.maxStackElements=e.readShort(),this.maxSizeOfInstructions=e.readShort(),this.maxComponentElements=e.readShort(),this.maxComponentDepth=e.readShort()}render(e){var t=ms();return t.writeLong(this.version),t.writeShort(e.length),t.writeShort(this.maxPoints),t.writeShort(this.maxContours),t.writeShort(this.maxComponentPoints),t.writeShort(this.maxComponentContours),t.writeShort(this.maxZones),t.writeShort(this.maxTwilightPoints),t.writeShort(this.maxStorage),t.writeShort(this.maxFunctionDefs),t.writeShort(this.maxInstructionDefs),t.writeShort(this.maxStackElements),t.writeShort(this.maxSizeOfInstructions),t.writeShort(this.maxComponentElements),t.writeShort(this.maxComponentDepth),t.get()}},class extends gs{parse(e){e.offset(this.offset);var t=this.file,n=t.hhea;this.metrics=e.times(n.numOfLongHorMetrics,function(){return{advance:e.readShort(),lsb:e.readShort_()}});var r=t.maxp.numGlyphs-t.hhea.numOfLongHorMetrics;this.leftSideBearings=e.times(r,e.readShort_)}forGlyph(e){var t=this.metrics,n=t.length;return e<n?t[e]:{advance:t[n-1].advance,lsb:this.leftSideBearings[e-n]}}render(e){for(var t=ms(),n=0;n<e.length;++n){var r=this.forGlyph(e[n]);t.writeShort(r.advance),t.writeShort_(r.lsb)}return t.get()}},(function(){var e=`.notdef .null nonmarkingreturn space exclam quotedbl numbersign dollar percent ampersand quotesingle parenleft parenright asterisk plus comma hyphen period slash zero one two three four five six seven eight nine colon semicolon less equal greater question at A B C D E F G H I J K L M N O P Q R S T U V W X Y Z bracketleft backslash bracketright asciicircum underscore grave a b c d e f g h i j k l m n o p q r s t u v w x y z braceleft bar braceright asciitilde Adieresis Aring Ccedilla Eacute Ntilde Odieresis Udieresis aacute agrave acircumflex adieresis atilde aring ccedilla eacute egrave ecircumflex edieresis iacute igrave icircumflex idieresis ntilde oacute ograve ocircumflex odieresis otilde uacute ugrave ucircumflex udieresis dagger degree cent sterling section bullet paragraph germandbls registered copyright trademark acute dieresis notequal AE Oslash infinity plusminus lessequal greaterequal yen mu partialdiff summation product pi integral ordfeminine ordmasculine Omega ae oslash questiondown exclamdown logicalnot radical florin approxequal Delta guillemotleft guillemotright ellipsis nonbreakingspace Agrave Atilde Otilde OE oe endash emdash quotedblleft quotedblright quoteleft quoteright divide lozenge ydieresis Ydieresis fraction currency guilsinglleft guilsinglright fi fl daggerdbl periodcentered quotesinglbase quotedblbase perthousand Acircumflex Ecircumflex Aacute Edieresis Egrave Iacute Icircumflex Idieresis Igrave Oacute Ocircumflex apple Ograve Uacute Ucircumflex Ugrave dotlessi circumflex tilde macron breve dotaccent ring cedilla hungarumlaut ogonek caron Lslash lslash Scaron scaron Zcaron zcaron brokenbar Eth eth Yacute yacute Thorn thorn minus multiply onesuperior twosuperior threesuperior onehalf onequarter threequarters franc Gbreve gbreve Idotaccent Scedilla scedilla Cacute cacute Ccaron ccaron dcroat`.split(/\s+/g);return class extends gs{parse(e){e.offset(this.offset),this.format=e.readLong(),this.italicAngle=e.readFixed_(),this.underlinePosition=e.readShort_(),this.underlineThickness=e.readShort_(),this.isFixedPitch=e.readLong(),this.minMemType42=e.readLong(),this.maxMemType42=e.readLong(),this.minMemType1=e.readLong(),this.maxMemType1=e.readLong();var t;switch(this.format){case 65536:case 196608:break;case 131072:t=e.readShort(),this.glyphNameIndex=e.times(t,e.readShort),this.names=[];for(var n=this.offset+this.length;e.offset()<n;)this.names.push(e.readString(e.readByte()));break;case 151552:t=e.readShort(),this.offsets=e.read(t);break;case 262144:this.map=e.times(this.file.maxp.numGlyphs,e.readShort);break}}glyphFor(t){switch(this.format){case 65536:return e[t]||`.notdef`;case 131072:var n=this.glyphNameIndex[t];return n<e.length?e[n]:this.names[n-e.length]||`.notdef`;case 151552:case 196608:return`.notdef`;case 262144:return this.map[t]||65535}}render(t){if(this.format==196608)return this.raw();var n=ms(this.rawData.slice(this.offset,32));n.writeLong(131072),n.offset(32);for(var r=[],i=[],a=0;a<t.length;++a){var o=t[a],s=this.glyphFor(o),c=e.indexOf(s);c>=0?r.push(c):(r.push(e.length+i.length),i.push(s))}for(n.writeShort(t.length),a=0;a<r.length;++a)n.writeShort(r[a]);for(a=0;a<i.length;++a)n.writeByte(i[a].length),n.writeString(i[a]);return n.get()}}})(),class extends gs{parse(e){e.offset(this.offset),this.version=e.readShort(),this.averageCharWidth=e.readShort_(),this.weightClass=e.readShort(),this.widthClass=e.readShort(),this.type=e.readShort(),this.ySubscriptXSize=e.readShort_(),this.ySubscriptYSize=e.readShort_(),this.ySubscriptXOffset=e.readShort_(),this.ySubscriptYOffset=e.readShort_(),this.ySuperscriptXSize=e.readShort_(),this.ySuperscriptYSize=e.readShort_(),this.ySuperscriptXOffset=e.readShort_(),this.ySuperscriptYOffset=e.readShort_(),this.yStrikeoutSize=e.readShort_(),this.yStrikeoutPosition=e.readShort_(),this.familyClass=e.readShort_(),this.panose=e.times(10,e.readByte),this.charRange=e.times(4,e.readLong),this.vendorID=e.readString(4),this.selection=e.readShort(),this.firstCharIndex=e.readShort(),this.lastCharIndex=e.readShort(),this.version>0&&(this.ascent=e.readShort_(),this.descent=e.readShort_(),this.lineGap=e.readShort_(),this.winAscent=e.readShort(),this.winDescent=e.readShort(),this.codePageRange=e.times(2,e.readLong),this.version>1&&(this.xHeight=e.readShort(),this.capHeight=e.readShort(),this.defaultChar=e.readShort(),this.breakChar=e.readShort(),this.maxContext=e.readShort()))}render(){return this.raw()}};function _s(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function vs(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if(typeof n!=`object`)throw TypeError(n+`must be non-object`);for(var r in n)_s(n,r)&&(e[r]=n[r])}}return e}function ys(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)}var bs={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray){e.set(t.subarray(n,n+r),i);return}for(var a=0;a<r;a++)e[i+a]=t[n+a]},flattenChunks:function(e){var t,n,r=0,i,a,o;for(t=0,n=e.length;t<n;t++)r+=e[t].length;for(o=new Uint8Array(r),i=0,t=0,n=e.length;t<n;t++)a=e[t],o.set(a,i),i+=a.length;return o},Buf8:function(e){return new Uint8Array(e)},Buf16:function(e){return new Uint16Array(e)},Buf32:function(e){return new Int32Array(e)}},xs={arraySet:function(e,t,n,r,i){for(var a=0;a<r;a++)e[i+a]=t[n+a]},flattenChunks:function(e){return[].concat.apply([],e)},Buf8:function(e){return Array(e)},Buf16:function(e){return Array(e)},Buf32:function(e){return Array(e)}};let Ss=()=>{let e=typeof Uint8Array<`u`&&typeof Uint16Array<`u`&&typeof Int32Array<`u`;return Ss=()=>e,e},Cs=(e,t,n,r,i)=>(Cs=Ss()?bs.arraySet:xs.arraySet,Cs(e,t,n,r,i)),ws=e=>(ws=Ss()?bs.flattenChunks:xs.flattenChunks,ws(e)),Ts=e=>(Ts=Ss()?bs.Buf8:xs.Buf8,Ts(e)),Es=e=>(Es=Ss()?bs.Buf16:xs.Buf16,Es(e)),Ds=e=>(Ds=Ss()?bs.Buf32:xs.Buf32,Ds(e)),Os=function(){let e=!0;try{String.fromCharCode.apply(null,[0])}catch{e=!1}return Os=()=>e,e},ks=function(){let e=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{e=!1}return ks=()=>e,e},As=function(e){for(var t=Ts(256),n=0;n<256;n++)t[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;return t[254]=t[254]=1,As=e=>t[e],t[e]};function js(e){var t,n,r,i,a,o=e.length,s=0;for(i=0;i<o;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(s),a=0,i=0;a<s;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?t[a++]=n:n<2048?(t[a++]=192|n>>>6,t[a++]=128|n&63):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|n&63):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|n&63);return t}function Ms(e,t){if(t<65534&&(e.subarray&&ks()||!e.subarray&&Os()))return String.fromCharCode.apply(null,ys(e,t));for(var n=``,r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n}function Ns(e){return Ms(e,e.length)}function Ps(e,t,n,r){for(var i=e&65535|0,a=e>>>16&65535|0,o=0;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+t[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0}function Fs(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}let Is=function(){let e=Fs();return Is=()=>e,e};function Ls(e,t,n,r){var i=Is(),a=r+n;e^=-1;for(var o=r;o<a;o++)e=e>>>8^i[(e^t[o])&255];return e^-1}var Rs={2:`need dictionary`,1:`stream end`,0:``,"-1":`file error`,"-2":`stream error`,"-3":`data error`,"-4":`insufficient memory`,"-5":`buffer error`,"-6":`incompatible version`};function zs(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=``,this.state=null,this.data_type=2,this.adler=0}function Bs(e){for(var t=e.length;--t>=0;)e[t]=0}var Vs=0,Hs=1,Us=2,Ws=3,Gs=258,Ks=29,qs=256,Js=qs+1+Ks,Ys=30,Xs=19,Zs=2*Js+1,Qs=15,$s=16,ec=7,tc=256,nc=16,rc=17,ic=18,ac=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],oc=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],sc=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],cc=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],lc=512,uc,dc,fc,pc,mc,hc;function gc(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}var _c,vc,yc;function bc(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function xc(e){return e<256?fc[e]:fc[256+(e>>>7)]}function Sc(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function Cc(e,t,n){e.bi_valid>$s-n?(e.bi_buf|=t<<e.bi_valid&65535,Sc(e,e.bi_buf),e.bi_buf=t>>$s-e.bi_valid,e.bi_valid+=n-$s):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function wc(e,t,n){Cc(e,n[t*2],n[t*2+1])}function Tc(e,t){var n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1}function Ec(e){e.bi_valid===16?(Sc(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function Dc(e,t){var n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,d,f,p,m,h=0;for(f=0;f<=Qs;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<Zs;l++)u=e.heap[l],f=n[n[u*2+1]*2+1]+1,f>c&&(f=c,h++),n[u*2+1]=f,!(u>r)&&(e.bl_count[f]++,p=0,u>=s&&(p=o[u-s]),m=n[u*2],e.opt_len+=m*(f+p),a&&(e.static_len+=m*(i[u*2+1]+p)));if(h!==0){do{for(f=c-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(f=c;f!==0;f--)for(u=e.bl_count[f];u!==0;)d=e.heap[--l],!(d>r)&&(n[d*2+1]!==f&&(e.opt_len+=(f-n[d*2+1])*n[d*2],n[d*2+1]=f),u--)}}function Oc(e,t,n){var r=Array(Qs+1),i=0,a,o;for(a=1;a<=Qs;a++)r[a]=i=i+n[a-1]<<1;for(o=0;o<=t;o++){var s=e[o*2+1];s!==0&&(e[o*2]=Tc(r[s]++,s))}}function kc(){var e,t,n,r,i,a=Array(Qs+1);for(uc=Array((Js+2)*2),Bs(uc),dc=Array(Ys*2),Bs(dc),fc=Array(lc),Bs(fc),pc=Array(Gs-Ws+1),Bs(pc),mc=Array(Ks),Bs(mc),hc=Array(Ys),Bs(hc),n=0,r=0;r<Ks-1;r++)for(mc[r]=n,e=0;e<1<<ac[r];e++)pc[n++]=r;for(pc[n-1]=r,i=0,r=0;r<16;r++)for(hc[r]=i,e=0;e<1<<oc[r];e++)fc[i++]=r;for(i>>=7;r<Ys;r++)for(hc[r]=i<<7,e=0;e<1<<oc[r]-7;e++)fc[256+i++]=r;for(t=0;t<=Qs;t++)a[t]=0;for(e=0;e<=143;)uc[e*2+1]=8,e++,a[8]++;for(;e<=255;)uc[e*2+1]=9,e++,a[9]++;for(;e<=279;)uc[e*2+1]=7,e++,a[7]++;for(;e<=287;)uc[e*2+1]=8,e++,a[8]++;for(Oc(uc,Js+1,a),e=0;e<Ys;e++)dc[e*2+1]=5,dc[e*2]=Tc(e,5);_c=new gc(uc,ac,qs+1,Js,Qs),vc=new gc(dc,oc,0,Ys,Qs),yc=new gc([],sc,0,Xs,ec)}function Ac(e){var t;for(t=0;t<Js;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Ys;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Xs;t++)e.bl_tree[t*2]=0;e.dyn_ltree[tc*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function jc(e){e.bi_valid>8?Sc(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Mc(e,t,n,r){jc(e),r&&(Sc(e,n),Sc(e,~n)),Cs(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function Nc(e,t,n,r){var i=t*2,a=n*2;return e[i]<e[a]||e[i]===e[a]&&r[t]<=r[n]}function Pc(e,t,n){for(var r=e.heap[n],i=n<<1;i<=e.heap_len&&(i<e.heap_len&&Nc(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!Nc(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r}function Fc(e,t,n){var r,i,a=0,o,s;if(e.last_lit!==0)do r=e.pending_buf[e.d_buf+a*2]<<8|e.pending_buf[e.d_buf+a*2+1],i=e.pending_buf[e.l_buf+a],a++,r===0?wc(e,i,t):(o=pc[i],wc(e,o+qs+1,t),s=ac[o],s!==0&&(i-=mc[o],Cc(e,i,s)),r--,o=xc(r),wc(e,o,n),s=oc[o],s!==0&&(r-=hc[o],Cc(e,r,s)));while(a<e.last_lit);wc(e,tc,t)}function Ic(e,t){var n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,c=-1,l;for(e.heap_len=0,e.heap_max=Zs,o=0;o<a;o++)n[o*2]===0?n[o*2+1]=0:(e.heap[++e.heap_len]=c=o,e.depth[o]=0);for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,n[l*2]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=r[l*2+1]);for(t.max_code=c,o=e.heap_len>>1;o>=1;o--)Pc(e,n,o);l=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Pc(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[l*2]=n[o*2]+n[s*2],e.depth[l]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[o*2+1]=n[s*2+1]=l,e.heap[1]=l++,Pc(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Dc(e,t),Oc(n,c,e.bl_count)}function Lc(e,t,n){var r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)&&(s<l?e.bl_tree[a*2]+=s:a===0?s<=10?e.bl_tree[rc*2]++:e.bl_tree[ic*2]++:(a!==i&&e.bl_tree[a*2]++,e.bl_tree[nc*2]++),s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4))}function Rc(e,t,n){var r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),r=0;r<=n;r++)if(a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)){if(s<l)do wc(e,a,e.bl_tree);while(--s!==0);else a===0?s<=10?(wc(e,rc,e.bl_tree),Cc(e,s-3,3)):(wc(e,ic,e.bl_tree),Cc(e,s-11,7)):(a!==i&&(wc(e,a,e.bl_tree),s--),wc(e,nc,e.bl_tree),Cc(e,s-3,2));s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4)}}function zc(e){var t;for(Lc(e,e.dyn_ltree,e.l_desc.max_code),Lc(e,e.dyn_dtree,e.d_desc.max_code),Ic(e,e.bl_desc),t=Xs-1;t>=3&&e.bl_tree[cc[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function Bc(e,t,n,r){var i;for(Cc(e,t-257,5),Cc(e,n-1,5),Cc(e,r-4,4),i=0;i<r;i++)Cc(e,e.bl_tree[cc[i]*2+1],3);Rc(e,e.dyn_ltree,t-1),Rc(e,e.dyn_dtree,n-1)}function Vc(e){var t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return 0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return 1;for(n=32;n<qs;n++)if(e.dyn_ltree[n*2]!==0)return 1;return 0}var Hc=!1;function Uc(e){Hc||=(kc(),!0),e.l_desc=new bc(e.dyn_ltree,_c),e.d_desc=new bc(e.dyn_dtree,vc),e.bl_desc=new bc(e.bl_tree,yc),e.bi_buf=0,e.bi_valid=0,Ac(e)}function Wc(e,t,n,r){Cc(e,(Vs<<1)+ +!!r,3),Mc(e,t,n,!0)}function Gc(e){Cc(e,Hs<<1,3),wc(e,tc,uc),Ec(e)}function Kc(e,t,n,r){var i,a,o=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=Vc(e)),Ic(e,e.l_desc),Ic(e,e.d_desc),o=zc(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=n+5,n+4<=i&&t!==-1?Wc(e,t,n,r):e.strategy===4||a===i?(Cc(e,(Hs<<1)+ +!!r,3),Fc(e,uc,dc)):(Cc(e,(Us<<1)+ +!!r,3),Bc(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),Fc(e,e.dyn_ltree,e.dyn_dtree)),Ac(e),r&&jc(e)}function qc(e,t,n){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(pc[n]+qs+1)*2]++,e.dyn_dtree[xc(t)*2]++),e.last_lit===e.lit_bufsize-1}var Jc=9,Yc=286,Xc=30,Zc=19,Qc=2*Yc+1,$c=15,R=3,el=258,tl=el+R+1,nl=32,rl=42,il=69,al=73,ol=91,sl=103,cl=113,ll=666,ul=1,dl=2,fl=3,pl=4,ml=3;function hl(e,t){return e.msg=Rs[t],t}function gl(e){return(e<<1)-(e>4?9:0)}function _l(e){for(var t=e.length;--t>=0;)e[t]=0}function vl(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(Cs(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function yl(e,t){Kc(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,vl(e.strm)}function z(e,t){e.pending_buf[e.pending++]=t}function bl(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function xl(e,t,n,r){var i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,Cs(t,e.input,e.next_in,i,n),e.state.wrap===1?e.adler=Ps(e.adler,t,i,n):e.state.wrap===2&&(e.adler=Ls(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)}function Sl(e,t){var n=e.max_chain_length,r=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-tl?e.strstart-(e.w_size-tl):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+el,p=l[r+o-1],m=l[r+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(i=t,l[i+o]!==m||l[i+o-1]!==p||l[i]!==l[r]||l[++i]!==l[r+1])continue;r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<f);if(a=el-(f-r),r=f-el,a>o){if(e.match_start=t,o=a,a>=s)break;p=l[r+o-1],m=l[r+o]}}while((t=d[t&u])>c&&--n!==0);return o<=e.lookahead?o:e.lookahead}function Cl(e){var t=e.w_size,n,r,i,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-tl)){Cs(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,n=r;do i=e.head[--n],e.head[n]=i>=t?i-t:0;while(--r);r=t,n=r;do i=e.prev[--n],e.prev[n]=i>=t?i-t:0;while(--r);a+=t}if(e.strm.avail_in===0)break;if(r=xl(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=r,e.lookahead+e.insert>=R)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+R-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<R)););}while(e.lookahead<tl&&e.strm.avail_in!==0)}function wl(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Cl(e),e.lookahead===0&&t===0)return ul;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,yl(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-tl&&(yl(e,!1),e.strm.avail_out===0))return ul}return e.insert=0,t===4?(yl(e,!0),e.strm.avail_out===0?fl:pl):(e.strstart>e.block_start&&(yl(e,!1),e.strm.avail_out),ul)}function Tl(e,t){for(var n,r;;){if(e.lookahead<tl){if(Cl(e),e.lookahead<tl&&t===0)return ul;if(e.lookahead===0)break}if(n=0,e.lookahead>=R&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+R-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-tl&&(e.match_length=Sl(e,n)),e.match_length>=R)if(r=qc(e,e.strstart-e.match_start,e.match_length-R),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=R){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+R-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=qc(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(yl(e,!1),e.strm.avail_out===0))return ul}return e.insert=e.strstart<R-1?e.strstart:R-1,t===4?(yl(e,!0),e.strm.avail_out===0?fl:pl):e.last_lit&&(yl(e,!1),e.strm.avail_out===0)?ul:dl}function El(e,t){for(var n,r,i;;){if(e.lookahead<tl){if(Cl(e),e.lookahead<tl&&t===0)return ul;if(e.lookahead===0)break}if(n=0,e.lookahead>=R&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+R-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=R-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-tl&&(e.match_length=Sl(e,n),e.match_length<=5&&(e.strategy===1||e.match_length===R&&e.strstart-e.match_start>4096)&&(e.match_length=R-1)),e.prev_length>=R&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-R,r=qc(e,e.strstart-1-e.prev_match,e.prev_length-R),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+R-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=R-1,e.strstart++,r&&(yl(e,!1),e.strm.avail_out===0))return ul}else if(e.match_available){if(r=qc(e,0,e.window[e.strstart-1]),r&&yl(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return ul}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&=(r=qc(e,0,e.window[e.strstart-1]),0),e.insert=e.strstart<R-1?e.strstart:R-1,t===4?(yl(e,!0),e.strm.avail_out===0?fl:pl):e.last_lit&&(yl(e,!1),e.strm.avail_out===0)?ul:dl}function Dl(e,t){for(var n,r,i,a,o=e.window;;){if(e.lookahead<=el){if(Cl(e),e.lookahead<=el&&t===0)return ul;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=R&&e.strstart>0&&(i=e.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){a=e.strstart+el;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<a);e.match_length=el-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=R?(n=qc(e,1,e.match_length-R),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=qc(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(yl(e,!1),e.strm.avail_out===0))return ul}return e.insert=0,t===4?(yl(e,!0),e.strm.avail_out===0?fl:pl):e.last_lit&&(yl(e,!1),e.strm.avail_out===0)?ul:dl}function Ol(e,t){for(var n;;){if(e.lookahead===0&&(Cl(e),e.lookahead===0)){if(t===0)return ul;break}if(e.match_length=0,n=qc(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(yl(e,!1),e.strm.avail_out===0))return ul}return e.insert=0,t===4?(yl(e,!0),e.strm.avail_out===0?fl:pl):e.last_lit&&(yl(e,!1),e.strm.avail_out===0)?ul:dl}function kl(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}let Al=function(){let e=[new kl(0,0,0,0,wl),new kl(4,4,8,4,Tl),new kl(4,5,16,8,Tl),new kl(4,6,32,32,Tl),new kl(4,4,16,16,El),new kl(8,16,32,32,El),new kl(8,16,128,128,El),new kl(8,32,128,256,El),new kl(32,128,258,1024,El),new kl(32,258,258,4096,El)];return Al=()=>e,e};function jl(e){e.window_size=2*e.w_size,_l(e.head);let t=Al();e.max_lazy_match=t[e.level].max_lazy,e.good_match=t[e.level].good_length,e.nice_match=t[e.level].nice_length,e.max_chain_length=t[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=R-1,e.match_available=0,e.ins_h=0}function Ml(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=Es(Qc*2),this.dyn_dtree=Es((2*Xc+1)*2),this.bl_tree=Es((2*Zc+1)*2),_l(this.dyn_ltree),_l(this.dyn_dtree),_l(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=Es($c+1),this.heap=Es(2*Yc+1),_l(this.heap),this.heap_len=0,this.heap_max=0,this.depth=Es(2*Yc+1),_l(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Nl(e){var t;return!e||!e.state?hl(e,-2):(e.total_in=e.total_out=0,e.data_type=2,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?rl:cl,e.adler=t.wrap===2?0:1,t.last_flush=0,Uc(t),0)}function Pl(e){var t=Nl(e);return t===0&&jl(e.state),t}function Fl(e,t){return!e||!e.state||e.state.wrap!==2?-2:(e.state.gzhead=t,0)}function Il(e,t,n,r,i,a){if(!e)return-2;var o=1;if(t===-1&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>Jc||n!==8||r<8||r>15||t<0||t>9||a<0||a>4)return hl(e,-2);r===8&&(r=9);var s=new Ml;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=r,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+R-1)/R),s.window=Ts(s.w_size*2),s.head=Es(s.hash_size),s.prev=Es(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=Ts(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=a,s.method=n,Pl(e)}function Ll(e,t){var n,r,i,a;if(!e||!e.state||t>5||t<0)return e?hl(e,-2):-2;if(r=e.state,!e.output||!e.input&&e.avail_in!==0||r.status===ll&&t!==4)return hl(e,e.avail_out===0?-5:-2);if(r.strm=e,n=r.last_flush,r.last_flush=t,r.status===rl)if(r.wrap===2)e.adler=0,z(r,31),z(r,139),z(r,8),r.gzhead?(z(r,+!!r.gzhead.text+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),z(r,r.gzhead.time&255),z(r,r.gzhead.time>>8&255),z(r,r.gzhead.time>>16&255),z(r,r.gzhead.time>>24&255),z(r,r.level===9?2:r.strategy>=2||r.level<2?4:0),z(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(z(r,r.gzhead.extra.length&255),z(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Ls(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=il):(z(r,0),z(r,0),z(r,0),z(r,0),z(r,0),z(r,r.level===9?2:r.strategy>=2||r.level<2?4:0),z(r,ml),r.status=cl);else{var o=8+(r.w_bits-8<<4)<<8,s=-1;s=r.strategy>=2||r.level<2?0:r.level<6?1:r.level===6?2:3,o|=s<<6,r.strstart!==0&&(o|=nl),o+=31-o%31,r.status=cl,bl(r,o),r.strstart!==0&&(bl(r,e.adler>>>16),bl(r,e.adler&65535)),e.adler=1}if(r.status===il)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(r.gzhead.extra.length&65535)&&!(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=Ls(e.adler,r.pending_buf,r.pending-i,i)),vl(e),i=r.pending,r.pending===r.pending_buf_size));)z(r,r.gzhead.extra[r.gzindex]&255),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(e.adler=Ls(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=al)}else r.status=al;if(r.status===al)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=Ls(e.adler,r.pending_buf,r.pending-i,i)),vl(e),i=r.pending,r.pending===r.pending_buf_size)){a=1;break}a=r.gzindex<r.gzhead.name.length?r.gzhead.name.charCodeAt(r.gzindex++)&255:0,z(r,a)}while(a!==0);r.gzhead.hcrc&&r.pending>i&&(e.adler=Ls(e.adler,r.pending_buf,r.pending-i,i)),a===0&&(r.gzindex=0,r.status=ol)}else r.status=ol;if(r.status===ol)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=Ls(e.adler,r.pending_buf,r.pending-i,i)),vl(e),i=r.pending,r.pending===r.pending_buf_size)){a=1;break}a=r.gzindex<r.gzhead.comment.length?r.gzhead.comment.charCodeAt(r.gzindex++)&255:0,z(r,a)}while(a!==0);r.gzhead.hcrc&&r.pending>i&&(e.adler=Ls(e.adler,r.pending_buf,r.pending-i,i)),a===0&&(r.status=sl)}else r.status=sl;if(r.status===sl&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&vl(e),r.pending+2<=r.pending_buf_size&&(z(r,e.adler&255),z(r,e.adler>>8&255),e.adler=0,r.status=cl)):r.status=cl),r.pending!==0){if(vl(e),e.avail_out===0)return r.last_flush=-1,0}else if(e.avail_in===0&&gl(t)<=gl(n)&&t!==4)return hl(e,-5);if(r.status===ll&&e.avail_in!==0)return hl(e,-5);if(e.avail_in!==0||r.lookahead!==0||t!==0&&r.status!==ll){var c=r.strategy===2?Ol(r,t):r.strategy===3?Dl(r,t):Al()[r.level].func(r,t);if((c===fl||c===pl)&&(r.status=ll),c===ul||c===fl)return e.avail_out===0&&(r.last_flush=-1),0;if(c===dl&&(t===1?Gc(r):t!==5&&(Wc(r,0,0,!1),t===3&&(_l(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),vl(e),e.avail_out===0))return r.last_flush=-1,0}return t===4?r.wrap<=0?1:(r.wrap===2?(z(r,e.adler&255),z(r,e.adler>>8&255),z(r,e.adler>>16&255),z(r,e.adler>>24&255),z(r,e.total_in&255),z(r,e.total_in>>8&255),z(r,e.total_in>>16&255),z(r,e.total_in>>24&255)):(bl(r,e.adler>>>16),bl(r,e.adler&65535)),vl(e),r.wrap>0&&(r.wrap=-r.wrap),+(r.pending===0)):0}function Rl(e){var t;return!e||!e.state?-2:(t=e.state.status,t!==rl&&t!==il&&t!==al&&t!==ol&&t!==sl&&t!==cl&&t!==ll?hl(e,-2):(e.state=null,t===cl?hl(e,-3):0))}function zl(e,t){var n=t.length,r,i,a,o,s,c,l,u;if(!e||!e.state||(r=e.state,o=r.wrap,o===2||o===1&&r.status!==rl||r.lookahead))return-2;for(o===1&&(e.adler=Ps(e.adler,t,n,0)),r.wrap=0,n>=r.w_size&&(o===0&&(_l(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=Ts(r.w_size),Cs(u,t,n-r.w_size,r.w_size,0),t=u,n=r.w_size),s=e.avail_in,c=e.next_in,l=e.input,e.avail_in=n,e.next_in=0,e.input=t,Cl(r);r.lookahead>=R;){i=r.strstart,a=r.lookahead-(R-1);do r.ins_h=(r.ins_h<<r.hash_shift^r.window[i+R-1])&r.hash_mask,r.prev[i&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=i,i++;while(--a);r.strstart=i,r.lookahead=R-1,Cl(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=R-1,r.match_available=0,e.next_in=c,e.input=l,e.avail_in=s,r.wrap=o,0}var Bl=Object.prototype.toString,Vl=class{constructor(e){this.options=vs({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:``},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new zs,this.strm.avail_out=0;var n=Il(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==0)throw Error(Rs[n]);if(t.header&&Fl(this.strm,t.header),t.dictionary){var r=typeof t.dictionary==`string`?js(t.dictionary):Bl.call(t.dictionary)===`[object ArrayBuffer]`?new Uint8Array(t.dictionary):t.dictionary;if(n=zl(this.strm,r),n!==0)throw Error(Rs[n]);this._dict_set=!0}}push(e,t){var n=this.strm,r=this.options.chunkSize,i,a;if(this.ended)return!1;a=t===~~t?t:t===!0?4:0,typeof e==`string`?n.input=js(e):Bl.call(e)===`[object ArrayBuffer]`?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=Ts(r),n.next_out=0,n.avail_out=r),i=Ll(n,a),i!==1&&i!==0)return this.onEnd(i),this.ended=!0,!1;(n.avail_out===0||n.avail_in===0&&(a===4||a===2))&&(this.options.to===`string`?this.onData(Ns(ys(n.output,n.next_out))):this.onData(ys(n.output,n.next_out)))}while((n.avail_in>0||n.avail_out===0)&&i!==1);return a===4?(i=Rl(this.strm),this.onEnd(i),this.ended=!0,i===0):a===2?(this.onEnd(0),n.avail_out=0,!0):!0}onData(e){this.chunks.push(e)}onEnd(e){e===0&&(this.options.to===`string`?this.result=this.chunks.join(``):this.result=ws(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg}};function Hl(e,t){var n=new Vl(t);if(n.push(e,!0),n.err)throw n.msg||Rs[n.err];return n.result}let Ul=Hl;function Wl(){return!0}Jt.browser;var Gl=0;let Kl=0;function ql(){var e=0,t=ms();function n(){for(var e=0;e<arguments.length;++e){var r=arguments[e];if(r===void 0)throw Error(`Cannot output undefined to PDF`);if(r instanceof tu)r.beforeRender(n),r.render(n);else if(Zl(r))$l(r,n);else if(Ql(r))eu(r,n);else if(typeof r==`number`){if(isNaN(r))throw Error(`Cannot output NaN to PDF`);var i=r.toFixed(7);i.indexOf(`.`)>=0&&(i=i.replace(/\.?0+$/,``)),i==`-0`&&(i=`0`),t.writeString(i)}else/string|boolean/.test(typeof r)?t.writeString(String(r)):typeof r.get==`function`?t.write(r.get()):typeof r==`object`&&(r?n(new V(r)):t.writeString(`null`))}}return n.writeData=function(e){t.write(e)},n.withIndent=function(t){++e,t(n),--e},n.indent=function(){n(`
`,Jl(``,e*2,`  `)),n.apply(null,arguments)},n.offset=function(){return t.offset()},n.toString=function(){throw Error(`FIX CALLER`)},n.get=function(){return t.get()},n.stream=function(){return t},n}function Jl(e,t,n){for(;e.length<t;)e=n+e;return e}function Yl(e,t){return Jl(String(e),t,`0`)}function Xl(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Zl=Array.isArray||function(e){return e instanceof Array};function Ql(e){return e instanceof Date}function $l(e,t){t(`[`),e.length>0&&t.withIndent(function(){for(var n=0;n<e.length;++n)n>0&&n%8==0?t.indent(e[n]):t(` `,e[n])}),t(` ]`)}function eu(e,t){t(`(D:`,Yl(e.getUTCFullYear(),4),Yl(e.getUTCMonth()+1,2),Yl(e.getUTCDate(),2),Yl(e.getUTCHours(),2),Yl(e.getUTCMinutes(),2),Yl(e.getUTCSeconds(),2),`Z)`)}var tu=class{beforeRender(){}},nu=class extends tu{constructor(e,t){super(),this.value=e,this.utf16be=!!t}render(e){let t=this.value;if(this.utf16be)t=`þÿ`+Pn(t),t=t.replace(/([\(\)\\])/g,`\\$1`),e(`(`,t,`)`);else{let r=[40];for(var n=0;n<t.length;++n){let e=t.charCodeAt(n)&255;(e==40||e==41||e==92)&&r.push(92),r.push(e)}r.push(41),e.writeData(r)}}toString(){return this.value}},ru=class extends nu{constructor(e){super(e),this.value=e}render(e){e(`<`);for(var t=0;t<this.value.length;++t)e(Yl(this.value.charCodeAt(t).toString(16),4));e(`>`)}},iu=class extends tu{static get(e){return B(e)}constructor(e){super(),this.name=e}render(e){e(`/`+this.escape())}escape(){return this.name.replace(/[^\x21-\x7E]/g,function(e){return`#`+Yl(e.charCodeAt(0).toString(16),2)})}toString(){return this.name}};function B(e){return new iu(e)}var V=class extends tu{constructor(e){super(),this.props=e}render(e){var t=this.props,n=!0;e(`<<`),e.withIndent(function(){for(var r in t)Xl(t,r)&&!/^_/.test(r)&&(n=!1,e.indent(B(r),` `,t[r]))}),n||e.indent(),e(`>>`)}},au=class extends tu{constructor(e,t,n){if(super(),typeof e==`string`){var r=ms();r.write(e),e=r}this.data=e,this.props=t||{},this.compress=n}render(e){var t=this.data.get(),n=this.props;this.compress&&Wl()&&(n.Filter?n.Filter instanceof Array||(n.Filter=[n.Filter]):n.Filter=[],n.Filter.unshift(B(`FlateDecode`)),t=Ul(t)),n.Length=t.length,e(new V(n),` stream`,`
`),e.writeData(t),e(`
`,`endstream`)}};(class extends V{constructor(){super({Type:B(`Catalog`)})}setPages(e){this.props.Pages=e}}),class extends V{constructor(){super({Type:B(`Pages`),Kids:[],Count:0})}addPage(e){this.props.Kids.push(e),this.props.Count++}},class extends V{constructor(e,t,n){let{width:r,height:i}=e.size(),a=new hu(t._pdf,{});a._content=new au(ql(),null,!0),n(e,a,{}),t._xResources=Object.assign(t._xResources,a._xResources),t._fontResources=Object.assign(t._fontResources,a._fontResources),t._gsResources=Object.assign(t._gsResources,a._gsResources),super({Type:B(`Pattern`),PatternType:1,PaintType:1,TilingType:1,BBox:[0,0,r,i],XStep:r,YStep:i,Matrix:[1,0,0,-1,0,i],Resources:{ExtGState:new V(a._gsResources),XObject:new V(a._xResources),Font:new V(a._fontResources)}}),this._resourceName=B(`P`+ ++Kl),this.data=a._content.data,this.compress=!0}render(e){au.prototype.render.call(this,e)}},class extends V{constructor(e){super({Type:B(`Font`),Subtype:B(`Type1`),BaseFont:B(e)}),this._resourceName=B(`F`+ ++Gl)}encodeText(e){return new nu(String(e))}};var ou=class extends V{constructor(e,t,n){super({}),n=this.props,n.Type=B(`Font`),n.Subtype=B(`Type0`),n.Encoding=B(`Identity-H`),this._pdf=e,this._font=t,this._sub=t.makeSubset(),this._resourceName=B(`F`+ ++Gl);var r=t.head;this.name=t.psName;var i=this.scale=t.scale;this.bbox=[r.xMin*i,r.yMin*i,r.xMax*i,r.yMax*i],this.italicAngle=t.post.italicAngle,this.ascent=t.ascent*i,this.descent=t.descent*i,this.lineGap=t.lineGap*i,this.capHeight=t.os2.capHeight||this.ascent,this.xHeight=t.os2.xHeight||0,this.stemV=0,this.familyClass=(t.os2.familyClass||0)>>8,this.isSerif=this.familyClass>=1&&this.familyClass<=7,this.isScript=this.familyClass==10,this.flags=!!t.post.isFixedPitch|(this.isSerif?2:0)|(this.isScript?8:0)|(this.italicAngle===0?0:64)|32}encodeText(e){return new ru(this._sub.encodeText(String(e)))}getTextWidth(e,t){for(var n=0,r=this._font.cmap.codeMap,i=0;i<t.length;++i){var a=r[t.charCodeAt(i)];n+=this._font.widthOfGlyph(a||0)}return n*e/1e3}beforeRender(){var e=this,t=e._sub,n=t.render(),r=new au(ms(n),{Length1:n.length},!0),i=e._pdf.attach(new V({Type:B(`FontDescriptor`),FontName:B(e._sub.psName),FontBBox:e.bbox,Flags:e.flags,StemV:e.stemV,ItalicAngle:e.italicAngle,Ascent:e.ascent,Descent:e.descent,CapHeight:e.capHeight,XHeight:e.xHeight,FontFile2:e._pdf.attach(r)})),a=t.ncid2ogid,o=t.firstChar,s=t.lastChar,c=[];(function t(n,r){if(n<=s){var i=a[n];i==null?t(n+1):(r||c.push(n,r=[]),r.push(e._font.widthOfGlyph(i)),t(n+1,r))}})(o);var l=new V({Type:B(`Font`),Subtype:B(`CIDFontType2`),BaseFont:B(e._sub.psName),CIDSystemInfo:new V({Registry:new nu(`Adobe`),Ordering:new nu(`Identity`),Supplement:0}),FontDescriptor:i,FirstChar:o,LastChar:s,DW:Math.round(e._font.widthOfGlyph(0)),W:c,CIDToGIDMap:e._pdf.attach(e._makeCidToGidMap())}),u=e.props;u.BaseFont=B(e._sub.psName),u.DescendantFonts=[e._pdf.attach(l)];var d=new su(o,s,t.subset),f=new au(ql(),null,!0);f.data(d),u.ToUnicode=e._pdf.attach(f)}_makeCidToGidMap(){return new au(ms(this._sub.cidToGidMap()),null,!0)}},su=class extends tu{constructor(e,t,n){super(),this.firstChar=e,this.lastChar=t,this.map=n}render(e){e.indent(`/CIDInit /ProcSet findresource begin`),e.indent(`12 dict begin`),e.indent(`begincmap`),e.indent(`/CIDSystemInfo <<`),e.indent(`  /Registry (Adobe)`),e.indent(`  /Ordering (UCS)`),e.indent(`  /Supplement 0`),e.indent(`>> def`),e.indent(`/CMapName /Adobe-Identity-UCS def`),e.indent(`/CMapType 2 def`),e.indent(`1 begincodespacerange`),e.indent(`  <0000><ffff>`),e.indent(`endcodespacerange`);var t=this;e.indent(t.lastChar-t.firstChar+1,` beginbfchar`),e.withIndent(function(){for(var n=t.firstChar;n<=t.lastChar;++n){var r=t.map[n],i=hs([r]);e.indent(`<`,Yl(n.toString(16),4),`>`,`<`);for(var a=0;a<i.length;++a)e(Yl(i.charCodeAt(a).toString(16),4));e(`>`)}}),e.indent(`endbfchar`),e.indent(`endcmap`),e.indent(`CMapName currentdict /CMap defineresource pop`),e.indent(`end`),e.indent(`end`)}};function cu(e){return e.map(function(e){return Zl(e)?cu(e):typeof e==`number`?(Math.round(e*1e3)/1e3).toFixed(3):e}).join(` `)}function lu(e,t,n,r,i,a,o){var s=cu([t,n,r,i,a,o]),c=e.GRAD_COL_FUNCTIONS[s];return c||=e.GRAD_COL_FUNCTIONS[s]=e.attach(new V({FunctionType:2,Domain:[0,1],Range:[0,1,0,1,0,1],N:1,C0:[t,n,r],C1:[i,a,o]})),c}function uu(e,t,n){var r=cu([t,n]),i=e.GRAD_OPC_FUNCTIONS[r];return i||=e.GRAD_OPC_FUNCTIONS[r]=e.attach(new V({FunctionType:2,Domain:[0,1],Range:[0,1],N:1,C0:[t],C1:[n]})),i}function du(e,t){var n=!1,r=[],i=[],a=[],o=[],s,c,l,u,d;for(s=1;s<t.length;++s)c=t[s-1],l=t[s],u=c.color,d=l.color,i.push(lu(e,u.r,u.g,u.b,d.r,d.g,d.b)),(u.a<1||d.a<1)&&(n=!0),a.push(l.offset),o.push(0,1);if(n)for(s=1;s<t.length;++s)c=t[s-1],l=t[s],u=c.color,d=l.color,r.push(uu(e,u.a,d.a));return a.pop(),{hasAlpha:n,colors:f(i),opacities:n?f(r):null};function f(e){return e.length==1?e[0]:{FunctionType:3,Functions:e,Domain:[0,1],Bounds:a,Encode:o}}}function fu(e,t,n,r,i,a){var o,s;if(!a){var c=[t].concat(r);n.forEach(function(e){c.push(e.offset,e.color.r,e.color.g,e.color.b)}),s=cu(c),o=e.GRAD_COL[s]}return o||(o=new V({Type:B(`Shading`),ShadingType:t?3:2,ColorSpace:B(`DeviceRGB`),Coords:r,Domain:[0,1],Function:i,Extend:[!0,!0]}),e.attach(o),o._resourceName=`S`+ ++Gl,s&&(e.GRAD_COL[s]=o)),o}function pu(e,t,n,r,i,a){var o,s;if(!a){var c=[t].concat(r);n.forEach(function(e){c.push(e.offset,e.color.a)}),s=cu(c),o=e.GRAD_OPC[s]}return o||(o=new V({Type:B(`ExtGState`),AIS:!1,CA:1,ca:1,SMask:{Type:B(`Mask`),S:B(`Luminosity`),G:e.attach(new au(`/a0 gs /s0 sh`,{Type:B(`XObject`),Subtype:B(`Form`),FormType:1,BBox:a?[a.left,a.top+a.height,a.left+a.width,a.top]:[0,1,1,0],Group:{Type:B(`Group`),S:B(`Transparency`),CS:B(`DeviceGray`),I:!0},Resources:{ExtGState:{a0:{CA:1,ca:1}},Shading:{s0:{ColorSpace:B(`DeviceGray`),Coords:r,Domain:[0,1],ShadingType:t?3:2,Function:i,Extend:[!0,!0]}}}}))}}),e.attach(o),o._resourceName=`O`+ ++Gl,s&&(e.GRAD_OPC[s]=o)),o}function mu(e,t,n){var r=t.type==`radial`,i=du(e,t.stops),a=r?[t.start.x,t.start.y,t.start.r,t.end.x,t.end.y,t.end.r]:[t.start.x,t.start.y,t.end.x,t.end.y],o=fu(e,r,t.stops,a,i.colors,t.userSpace&&n),s=i.hasAlpha?pu(e,r,t.stops,a,i.opacities,t.userSpace&&n):null;return{hasAlpha:i.hasAlpha,shading:o,opacity:s}}var hu=class extends V{constructor(e,t){super(t),this._pdf=e,this._rcount=0,this._textMode=!1,this._fontResources={},this._gsResources={},this._xResources={},this._patResources={},this._shResources={},this._opacity=1,this._matrix=[1,0,0,1,0,0],this._annotations=[],this._font=null,this._fontSize=null,this._contextStack=[],t=this.props,t.Type=B(`Page`),t.ProcSet=[B(`PDF`),B(`Text`),B(`ImageB`),B(`ImageC`),B(`ImageI`)],t.Resources=new V({Font:new V(this._fontResources),ExtGState:new V(this._gsResources),XObject:new V(this._xResources),Pattern:new V(this._patResources),Shading:new V(this._shResources)}),t.Annots=this._annotations}_out(){this._content.data.apply(null,arguments)}transform(e,t,n,r,i,a){Su(arguments)||(this._matrix=xu(arguments,this._matrix),this._out(e,` `,t,` `,n,` `,r,` `,i,` `,a,` cm`),this._out(`
`))}translate(e,t){this.transform(1,0,0,1,e,t)}scale(e,t){this.transform(e,0,0,t,0,0)}rotate(e){var t=Math.cos(e),n=Math.sin(e);this.transform(t,n,-n,t,0,0)}beginText(){this._textMode=!0,this._out(`BT`,`
`)}endText(){this._textMode=!1,this._out(`ET`,`
`)}_requireTextMode(){if(!this._textMode)throw Error(`Text mode required; call page.beginText() first`)}_requireFont(){if(!this._font)throw Error(`No font selected; call page.setFont() first`)}setFont(e,t){this._requireTextMode(),e==null?e=this._font:e instanceof ou||(e=this._pdf.getFont(e)),t??=this._fontSize,this._fontResources[e._resourceName]=e,this._font=e,this._fontSize=t,this._out(e._resourceName,` `,t,` Tf`,`
`)}setTextLeading(e){this._requireTextMode(),this._out(e,` TL`,`
`)}setTextRenderingMode(e){this._requireTextMode(),this._out(e,` Tr`,`
`)}showText(e,t){if(this._requireFont(),e.length>1&&t&&this._font instanceof ou){var n=t/this._font.getTextWidth(this._fontSize,e)*100;this._out(n,` Tz `)}this._out(this._font.encodeText(e),` Tj`,`
`)}showTextNL(e){this._requireFont(),this._out(this._font.encodeText(e),` '`,`
`)}addLink(e,t){var n=this._toPage({x:t.left,y:t.bottom}),r=this._toPage({x:t.right,y:t.top});this._annotations.push(new V({Type:B(`Annot`),Subtype:B(`Link`),Rect:[n.x,n.y,r.x,r.y],Border:[0,0,0],A:new V({Type:B(`Action`),S:B(`URI`),URI:new nu(e)})}))}setStrokeColor(e,t,n){this._out(e,` `,t,` `,n,` RG`,`
`)}setOpacity(e){this.setFillOpacity(e),this.setStrokeOpacity(e),this._opacity*=e}setStrokeOpacity(e){if(e<1){var t=this._pdf.getOpacityGS(this._opacity*e,!0);this._gsResources[t._resourceName]=t,this._out(t._resourceName,` gs`,`
`)}}setFillColor(e,t,n){this._out(e,` `,t,` `,n,` rg`,`
`)}pattern(e,t,n){let r=this._pdf.getPattern(e,this,n);this._patResources[r._resourceName]=r,this._out(`/Pattern cs`,`
`),this._out(r._resourceName,` scn`,`
`),this.rect(t.left,t.top,t.width,t.height),this.fill()}setFillOpacity(e){if(e<1){var t=this._pdf.getOpacityGS(this._opacity*e,!1);this._gsResources[t._resourceName]=t,this._out(t._resourceName,` gs`,`
`)}}gradient(e,t){this.save(),this.rect(t.left,t.top,t.width,t.height),this.clip(),e.userSpace||this.transform(t.width,0,0,t.height,t.left,t.top);var n=mu(this._pdf,e,t),r=n.shading._resourceName,i;this._shResources[r]=n.shading,n.hasAlpha&&(i=n.opacity._resourceName,this._gsResources[i]=n.opacity,this._out(`/`+i+` gs `)),this._out(`/`+r+` sh`,`
`),this.restore()}setDashPattern(e,t){this._out(e,` `,t,` d`,`
`)}setLineWidth(e){this._out(e,` w`,`
`)}setLineCap(e){this._out(e,` J`,`
`)}setLineJoin(e){this._out(e,` j`,`
`)}setMitterLimit(e){this._out(e,` M`,`
`)}save(){this._contextStack.push(this._context()),this._out(`q`,`
`)}restore(){this._out(`Q`,`
`),this._context(this._contextStack.pop())}moveTo(e,t){this._out(e,` `,t,` m`,`
`)}lineTo(e,t){this._out(e,` `,t,` l`,`
`)}bezier(e,t,n,r,i,a){this._out(e,` `,t,` `,n,` `,r,` `,i,` `,a,` c`,`
`)}bezier1(e,t,n,r){this._out(e,` `,t,` `,n,` `,r,` y`,`
`)}bezier2(e,t,n,r){this._out(e,` `,t,` `,n,` `,r,` v`,`
`)}close(){this._out(`h`,`
`)}rect(e,t,n,r){this._out(e,` `,t,` `,n,` `,r,` re`,`
`)}ellipse(e,t,n,r){function i(t){return e+t}function a(e){return t+e}var o=.5522847498307936;this.moveTo(i(0),a(r)),this.bezier(i(n*o),a(r),i(n),a(r*o),i(n),a(0)),this.bezier(i(n),a(-r*o),i(n*o),a(-r),i(0),a(-r)),this.bezier(i(-n*o),a(-r),i(-n),a(-r*o),i(-n),a(0)),this.bezier(i(-n),a(r*o),i(-n*o),a(r),i(0),a(r))}circle(e,t,n){this.ellipse(e,t,n,n)}stroke(){this._out(`S`,`
`)}nop(){this._out(`n`,`
`)}clip(){this._out(`W n`,`
`)}clipStroke(){this._out(`W S`,`
`)}closeStroke(){this._out(`s`,`
`)}fill(){this._out(`f`,`
`)}fillStroke(){this._out(`B`,`
`)}drawImage(e){var t=this._pdf.getImage(e);t&&(this._xResources[t._resourceName]=t,this._out(t._resourceName,` Do`,`
`))}comment(e){var t=this;e.split(/\r?\n/g).forEach(function(e){t._out(`% `,e,`
`)})}_context(e){if(e!=null)this._opacity=e.opacity,this._matrix=e.matrix;else return{opacity:this._opacity,matrix:this._matrix}}_toPage(e){var t=this._matrix,n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5];return{x:n*e.x+i*e.y+o,y:r*e.x+a*e.y+s}}};function gu(e){return e.replace(/^\s*(['"])(.*)\1\s*$/,`$2`)}function _u(e){var t=/^\s*((normal|italic)\s+)?(([a-z0-9-]+)\s+)?((normal|bold|\d+)\s+)?(([0-9.]+)(px|pt))(\/(([0-9.]+)(px|pt)|normal))?\s+(.*?)\s*$/i.exec(e);if(!t)return{fontSize:12,fontFamily:`sans-serif`};var n=t[8]?parseInt(t[8],10):12;return{italic:t[2]&&t[2].toLowerCase()==`italic`,variant:t[4],bold:t[6]&&/bold|[6789]00/i.test(t[6]),fontSize:n,lineHeight:t[12]?t[12]==`normal`?n:parseInt(t[12],10):null,fontFamily:t[14].split(/\s*,\s*/g).map(gu)}}function vu(e){function t(t){return e.bold&&(t+=`|bold`),e.italic&&(t+=`|italic`),t.toLowerCase()}var n=e.fontFamily,r,i;if(n instanceof Array)for(var a=0;a<n.length&&(r=t(n[a]),i=H[r],!i);++a);else i=H[n.toLowerCase()];for(;typeof i==`function`;)i=i();return i||=`Times-Roman`,i}var H={serif:`Times-Roman`,"serif|bold":`Times-Bold`,"serif|italic":`Times-Italic`,"serif|bold|italic":`Times-BoldItalic`,"sans-serif":`Helvetica`,"sans-serif|bold":`Helvetica-Bold`,"sans-serif|italic":`Helvetica-Oblique`,"sans-serif|bold|italic":`Helvetica-BoldOblique`,monospace:`Courier`,"monospace|bold":`Courier-Bold`,"monospace|italic":`Courier-Oblique`,"monospace|bold|italic":`Courier-BoldOblique`,zapfdingbats:`ZapfDingbats`,"zapfdingbats|bold":`ZapfDingbats`,"zapfdingbats|italic":`ZapfDingbats`,"zapfdingbats|bold|italic":`ZapfDingbats`};function yu(e,t){e=e.toLowerCase(),H[e]=function(){return H[t]},H[e+`|bold`]=function(){return H[t+`|bold`]},H[e+`|italic`]=function(){return H[t+`|italic`]},H[e+`|bold|italic`]=function(){return H[t+`|bold|italic`]}}yu(`Times New Roman`,`serif`),yu(`Courier New`,`monospace`),yu(`Arial`,`sans-serif`),yu(`Helvetica`,`sans-serif`),yu(`Verdana`,`sans-serif`),yu(`Tahoma`,`sans-serif`),yu(`Georgia`,`sans-serif`),yu(`Monaco`,`monospace`),yu(`Andale Mono`,`monospace`);function bu(e,t){if(arguments.length==1)for(var n in e)Xl(e,n)&&bu(n,e[n]);else switch(e=e.toLowerCase(),H[e]=t,e){case`dejavu sans`:H[`sans-serif`]=t;break;case`dejavu sans|bold`:H[`sans-serif|bold`]=t;break;case`dejavu sans|italic`:H[`sans-serif|italic`]=t;break;case`dejavu sans|bold|italic`:H[`sans-serif|bold|italic`]=t;break;case`dejavu serif`:H.serif=t;break;case`dejavu serif|bold`:H[`serif|bold`]=t;break;case`dejavu serif|italic`:H[`serif|italic`]=t;break;case`dejavu serif|bold|italic`:H[`serif|bold|italic`]=t;break;case`dejavu mono`:H.monospace=t;break;case`dejavu mono|bold`:H[`monospace|bold`]=t;break;case`dejavu mono|italic`:H[`monospace|italic`]=t;break;case`dejavu mono|bold|italic`:H[`monospace|bold|italic`]=t;break}}function xu(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=t[0],l=t[1],u=t[2],d=t[3],f=t[4],p=t[5];return[n*c+r*u,n*l+r*d,i*c+a*u,i*l+a*d,o*c+s*u+f,o*l+s*d+p]}function Su(e){return e[0]===1&&e[1]===0&&e[2]===0&&e[3]===1&&e[4]===0&&e[5]===0}let Cu={fill:0,stroke:1,fillAndStroke:2,invisible:3,fillAndClip:4,strokeAndClip:5,fillStrokeClip:6,clip:7},wu={dash:[4],dashDot:[4,2,1,2],dot:[1,2],longDash:[8,2],longDashDot:[8,2,1,2],longDashDotDot:[8,2,1,2,1,2],solid:[]},Tu={butt:0,round:1,square:2},Eu={miter:0,round:1,bevel:2};function Du(e,t){var n=e[t.nodeType];return n?n.call.apply(n,arguments):t}function Ou(e,t,n){e.options._pdfDebug&&t.comment(`BEGIN: `+e.options._pdfDebug);var r=e.transform(),i=e.opacity();if(t.save(),i!=null&&i<1&&t.setOpacity(i),ku(e,t,n),Au(e,t,n),r){var a=r.matrix();t.transform(a.a,a.b,a.c,a.d,a.e,a.f)}ju(e,t,n),Du({Path:Ru,MultiPath:zu,Circle:Bu,Arc:Vu,Text:Hu,Image:Gu,Group:Wu,Rect:Ku},e,t,n),t.restore(),e.options._pdfDebug&&t.comment(`END: `+e.options._pdfDebug)}function ku(e,t){var n=e.stroke&&e.stroke();if(n){var r=n.color;if(r){if(r=qu(r),r==null)return;t.setStrokeColor(r.r,r.g,r.b),r.a!=1&&t.setStrokeOpacity(r.a)}var i=n.width;if(i!=null){if(i===0)return;t.setLineWidth(i)}var a=n.dashType;a&&t.setDashPattern(wu[a],0);var o=n.lineCap;o&&t.setLineCap(Tu[o]);var s=n.lineJoin;s&&t.setLineJoin(Eu[s]);var c=n.opacity;c!=null&&t.setStrokeOpacity(c)}}function Au(e,t){var n=e.fill&&e.fill();if(n&&!(n instanceof wa||n instanceof Oa)){var r=n.color;if(r){if(r=qu(r),r==null)return;t.setFillColor(r.r,r.g,r.b),r.a!=1&&t.setFillOpacity(r.a)}var i=n.opacity;i!=null&&t.setFillOpacity(i)}}function ju(e,t,n){var r=e.clip();r&&(Lu(r,t,n),t.clip())}function Mu(e){return e&&(e instanceof wa||e instanceof Oa||e.color&&!/^(none|transparent)$/i.test(e.color)&&(e.width==null||e.width>0)&&(e.opacity==null||e.opacity>0))}function Nu(e,t,n,r){var i=e.fill();if(i instanceof wa){r?t.clipStroke():t.clip();var a=i instanceof Da,o,s;a?(o={x:i.center().x,y:i.center().y,r:0},s={x:i.center().x,y:i.center().y,r:i.radius()}):(o={x:i.start().x,y:i.start().y},s={x:i.end().x,y:i.end().y});var c=i.stops.elements().map(function(e){var t=e.offset();t=/%$/.test(t)?parseFloat(t)/100:parseFloat(t);var n=qu(e.color());return n.a*=e.opacity(),{offset:t,color:n}});c.unshift(c[0]),c.push(c[c.length-1]);var l={userSpace:i.userSpace(),type:a?`radial`:`linear`,start:o,end:s,stops:c},u=e.rawBBox(),d=u.topLeft(),f=u.getSize();return u={left:d.x,top:d.y,width:f.width,height:f.height},t.gradient(l,u),!0}}function Pu(e,t,n,r){let i=e.fill();if(i instanceof Oa){r?t.clipStroke():t.clip();let n=e.rawBBox(),a=n.topLeft(),o=n.getSize(),s=e.stroke()?e.stroke().width:0;return t.pattern(i,{left:a.x+s/2,top:a.y+s/2,width:o.width-s,height:o.height-s},Uu),!0}}function Fu(e,t,n){Mu(e.fill())&&Mu(e.stroke())?!Nu(e,t,n,!0)&&!Pu(e,t,n,!0)&&t.fillStroke():Mu(e.fill())?!Nu(e,t,n,!1)&&!Pu(e,t,n,!1)&&t.fill():Mu(e.stroke())?t.stroke():t.nop()}function Iu(e,t){var n=e.segments;if(n.length==4&&e.options.closed){for(var r=[],i=0;i<n.length;++i){if(n[i].controlIn())return!1;r[i]=n[i].anchor()}if(r[0].y==r[1].y&&r[1].x==r[2].x&&r[2].y==r[3].y&&r[3].x==r[0].x||r[0].x==r[1].x&&r[1].y==r[2].y&&r[2].x==r[3].x&&r[3].y==r[0].y)return t.rect(r[0].x,r[0].y,r[2].x-r[0].x,r[2].y-r[0].y),!0}}function Lu(e,t,n){var r=e.segments;if(r.length!==0&&!Iu(e,t,n)){for(var i,a=0;a<r.length;++a){var o=r[a],s=o.anchor();if(!i)t.moveTo(s.x,s.y);else{var c=i.controlOut(),l=o.controlIn();c&&l?t.bezier(c.x,c.y,l.x,l.y,s.x,s.y):t.lineTo(s.x,s.y)}i=o}e.options.closed&&t.close()}}function Ru(e,t,n){Lu(e,t,n),Fu(e,t,n)}function zu(e,t,n){for(var r=e.paths,i=0;i<r.length;++i)Lu(r[i],t,n);Fu(e,t,n)}function Bu(e,t,n){var r=e.geometry();t.circle(r.center.x,r.center.y,r.radius),Fu(e,t,n)}function Vu(e,t,n){var r=e.geometry().curvePoints();t.moveTo(r[0].x,r[0].y);for(var i=1;i<r.length;)t.bezier(r[i].x,r[i++].y,r[i].x,r[i++].y,r[i].x,r[i++].y);Fu(e,t,n)}function Hu(e,t){var n=_u(e.options.font),r=e._position,i;t.transform(1,0,0,-1,r.x,r.y+n.fontSize);let a=r=>{t.beginText(),t.setFont(vu(n),n.fontSize),t.setTextRenderingMode(r),t.showText(e.content(),e._pdfRect?e._pdfRect.width():null)};e.fill()&&e.stroke()?(i=Cu.fillAndStroke,e.options.paintOrder===`stroke`&&(a(Cu.stroke),i=Cu.fill)):e.fill()?i=Cu.fill:e.stroke()&&(i=Cu.stroke),a(i),t.endText()}function Uu(e,t,n){for(var r=e.children,i=0;i<r.length;++i)Ou(r[i],t,n)}function Wu(e,t,n){e._pdfLink&&t.addLink(e._pdfLink.url,e._pdfLink);for(var r=e.children,i=0;i<r.length;++i)Ou(r[i],t,n)}function Gu(e,t){var n=e.src();if(n){var r=e.rect(),i=r.getOrigin(),a=r.getSize();t.transform(a.width,0,0,-a.height,i.x,i.y+a.height),t.drawImage(n)}}function Ku(e,t,n){var r=e.geometry();let[i,a]=r.cornerRadius;i===0&&a===0?(t.rect(r.origin.x,r.origin.y,r.size.width,r.size.height),Fu(e,t,n)):Ru(I.fromRect(r,e.options),t,n)}function qu(e){var t=ln(e,!0);return t?t.toRGB():null}let Ju=Jt.browser||{};function Yu(e){return Array.prototype.slice.call(e)}var Xu=`KENDO-PSEUDO-ELEMENT`;let Zu=`data-kendo-bullet-type`;var Qu={},U={};U._root=U;let $u=typeof window<`u`?Ju.msie||Ju.edge:!1;var ed=class extends sa{constructor(e,t,n){super(e,t.getOrigin(),n),this._pdfRect=t}rect(){return this._pdfRect}rawBBox(){return this._pdfRect}},td=typeof Element<`u`&&Element.prototype&&(function(e){return e.matches?function(e,t){return e.matches(t)}:e.webkitMatchesSelector?function(e,t){return e.webkitMatchesSelector(t)}:e.mozMatchesSelector?function(e,t){return e.mozMatchesSelector(t)}:e.msMatchesSelector?function(e,t){return e.msMatchesSelector(t)}:function(e){return[].indexOf.call(document.querySelectorAll(e),this)!==-1}})(Element.prototype);(function(e){return e?function t(n){var r=n.cloneNode(!1);if(n.nodeType==1){var i=e(n),a=e(r),o,s=i.data();for(o in s)a.data(o,s[o]);for(/^canvas$/i.test(n.tagName)?r.getContext(`2d`).drawImage(n,0,0):/^(?:input|select|textarea|option)$/i.test(n.tagName)?(r.removeAttribute(`id`),r.removeAttribute(`name`),/^textarea$/i.test(n.tagName)||(r.value=n.value),r.checked=n.checked,r.selected=n.selected):/^img$/i.test(n.tagName)&&r.removeAttribute(`loading`),n._kendoExportVisual&&(r._kendoExportVisual=n._kendoExportVisual),o=n.firstChild;o;o=o.nextSibling)r.appendChild(t(o))}return r}:function(e){let t=(function e(t){let n=t.cloneNode(!1);t._kendoExportVisual&&(n._kendoExportVisual=t._kendoExportVisual);for(let r=t.firstChild;r;r=r.nextSibling)n.appendChild(e(r));return n})(e),n=e.querySelectorAll(`canvas`);n.length&&Yu(t.querySelectorAll(`canvas`)).forEach((e,t)=>{e.getContext(`2d`).drawImage(n[t],0,0)});let r=e.querySelectorAll(`input, select, textarea, option`);return Yu(t.querySelectorAll(`input, select, textarea, option`)).forEach((e,t)=>{e.removeAttribute(`id`),e.removeAttribute(`name`),/^textarea$/i.test(e.tagName)||(e.value=r[t].value),e.checked=r[t].checked,e.selected=r[t].selected}),Yu(t.querySelectorAll(`img`)).forEach(e=>{e.removeAttribute(`loading`)}),t}})(typeof window<`u`&&window.kendo&&window.kendo.jQuery);var nd=(function(){var e=/^((-webkit-|-moz-|-o-|-ms-)?linear-gradient\s*)\(/,t=/^([-0-9.]+%)/,n=/^([-0-9.]+px)/,r=/^(left|right|top|bottom|to|center)\W/,i=/^([-0-9.]+(deg|grad|rad|turn)|0)/,a=/^(\s+)/,o=/^(\()/,s=/^(\))/,c=/^(,)/,l=/^(url)\(/,u=/^(.*?)\)/,d={},f={};function p(f){var p=f;if(ad(d,p))return d[p];function m(){var e=a.exec(f);e&&(f=f.substr(e[1].length))}function h(e){m();var t=e.exec(f);if(t)return f=f.substr(t[1].length),t[1]}function g(){var e=ln(f,!0),r,i;if(e){let a=/^#[0-9a-f]+/i.exec(f)||/^rgba?\(.*?\)/i.exec(f)||/^..*?\b/.exec(f);return f=f.substr(a[0].length),e=e.toRGB(),(r=h(n))||(i=h(t)),{color:e,length:r,percent:i}}}function _(e){var n,a,l,u=[],d=!1;if(h(o)){if(n=h(i),n==`0`&&(n=`0deg`),n?(n=Od(n),h(c)):(a=h(r),a==`to`?a=h(r):a&&/^-/.test(e)&&(d=!0),l=h(r),h(c)),/-moz-/.test(e)&&n==null&&a==null){var p=h(t),m=h(t);d=!0,p==`0%`?a=`left`:p==`100%`&&(a=`right`),m==`0%`?l=`top`:m==`100%`&&(l=`bottom`),h(c)}for(;f&&!h(s);){var _=g();if(!_)break;u.push(_),h(c)}return{type:`linear`,angle:n,to:a&&l?a+` `+l:a||l||null,stops:u,reverse:d}}}function v(){if(h(o)){var e=h(u);return e=e.replace(/^['"]+|["']+$/g,``),h(s),{type:`url`,url:e}}}var y;return(y=h(e))?y=_(y):(y=h(l))&&(y=v()),d[p]=y||{type:`none`}}return function(e){return ad(f,e)?f[e]:f[e]=rd(e).map(p)}})(),rd=(function(){var e={};return function(t,n){n||=/^\s*,\s*/;var r=t+n;if(ad(e,r))return e[r];var i=[],a=0,o=0,s=0,c=!1,l;function u(e){return l=e.exec(t.substr(o))}function d(e){return e.replace(/^\s+|\s+$/g,``)}for(;o<t.length;)!c&&u(/^[\(\[\{]/)?(s++,o++):!c&&u(/^[\)\]\}]/)?(s--,o++):!c&&u(/^[\"\']/)?(c=l[0],o++):c==`'`&&u(/^\\\'/)||c==`"`&&u(/^\\\"/)?o+=2:c==`'`&&u(/^\'/)||c==`"`&&u(/^\"/)?(c=!1,o++):u(n)?(!c&&!s&&o>a&&(i.push(d(t.substring(a,o))),a=o+l[0].length),o+=l[0].length):o++;return a<o&&i.push(d(t.substring(a,o))),e[r]=i}})(),id=(function(e){return function(t){var n=e[t];return n??=e[t]=mr(`Mapq`,{font:t}).height,n}})(Object.create(null));function ad(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function od(e){return e=`_counter_`+e,U[e]}function sd(e){var t=[],n=U;for(e=`_counter_`+e;n;)ad(n,e)&&t.push(n[e]),n=Object.getPrototypeOf(n);return t.reverse()}function cd(e,t){var n=U;for(e=`_counter_`+e;n&&!ad(n,e);)n=Object.getPrototypeOf(n);n||=U._root,n[e]=(n[e]||0)+(t??1)}function ld(e,t){e=`_counter_`+e,U[e]=t??0}function ud(e,t,n){for(var r=0;r<e.length;){var i=e[r++],a=parseFloat(e[r]);isNaN(a)?t(i,n):(t(i,a),++r)}}function dd(e){var t=W(e,`counter-reset`);t&&ud(rd(t,/^\s+/),ld,0);var n=W(e,`counter-increment`);n&&ud(rd(n,/^\s+/),cd,1)}function fd(e,t){var n=ln(e,!0);return n&&(n=n.toRGB(),t?n=n.toCssRgba():n.a===0&&(n=null)),n}function pd(e){var t=``;do{var n=e%26;t=String.fromCharCode(97+n)+t,e=Math.floor(e/26)}while(e>0);return t}function md(e,t,n){U=Object.create(U),U[e.tagName.toLowerCase()]={element:e,style:t};let r=W(t,`text-decoration`);if(r&&r!=`none`){let n=pn(e,`text-decoration-color`);r.split(/\s+/g).forEach(function(e){if(!U[e]&&(U[e]=n,e==`underline`)){let e=W(t,`text-underline-offset`);e!=`auto`&&(U[`underline-offset`]=parseFloat(e))}})}vd(t)&&(U._stackingContext={element:e,group:n})}function hd(){U=Object.getPrototypeOf(U)}function gd(e){if(U._clipbox!=null){var t=e.bbox(U._matrix);U._clipbox?U._clipbox=F.intersect(U._clipbox,t):U._clipbox=t}}function _d(){var e=U._clipbox;if(e==null)return!0;if(e)return e.width()===0||e.height()===0}function vd(e){function t(t){return W(e,t)}if(t(`transform`)!=`none`||t(`position`)!=`static`||t(`z-index`)!=`auto`||t(`opacity`)<1)return!0}function yd(e,t){return window.getComputedStyle(e,t||null)}function W(e,t,n){var r=e.getPropertyValue(t);return(r==null||r===``)&&(Ju.webkit?r=e.getPropertyValue(`-webkit-`+t):Ju.mozilla?r=e.getPropertyValue(`-moz-`+t):Ju.opera?r=e.getPropertyValue(`-o-`+t):$u&&(r=e.getPropertyValue(`-ms-`+t))),arguments.length>2&&(r==null||r===``)?n:r}function bd(e,t,n,r){e.setProperty(t,n,r),Ju.webkit?e.setProperty(`-webkit-`+t,n,r):Ju.mozilla?e.setProperty(`-moz-`+t,n,r):Ju.opera?e.setProperty(`-o-`+t,n,r):$u&&(e.setProperty(`-ms-`+t,n,r),t=`ms`+t.replace(/(^|-)([a-z])/g,function(e,t,n){return t+n.toUpperCase()}),e[t]=n)}function xd(e,t,n){return n=`border-`+n,{width:parseFloat(W(t,n+`-width`)),style:W(t,n+`-style`),color:pn(e,n+`-color`)}}function Sd(e,t){var n=e.style.cssText,r=t();return Pr(e,n),r}function Cd(e,t){var n=W(e,`border-`+t+`-radius`).split(/\s+/g).map(parseFloat);return n.length==1&&n.push(n[0]),Md({x:n[0],y:n[1]})}function wd(e){var t=e.getBoundingClientRect();return t=Td(t,`border-*-width`,e),t=Td(t,`padding-*`,e),t}function Td(e,t,n){var r,i,a,o,s;return typeof t==`string`?(r=yd(n),i=parseFloat(W(r,t.replace(`*`,`top`))),a=parseFloat(W(r,t.replace(`*`,`right`))),o=parseFloat(W(r,t.replace(`*`,`bottom`))),s=parseFloat(W(r,t.replace(`*`,`left`)))):typeof t==`number`&&(i=a=o=s=t),{top:e.top+i,right:e.right-a,bottom:e.bottom-o,left:e.left+s,width:e.right-e.left-a-s,height:e.bottom-e.top-o-i}}function Ed(e){var t=W(e,`transform`);if(t==`none`)return null;var n=/^\s*matrix\(\s*(.*?)\s*\)\s*$/.exec(t);if(n){var r=W(e,`transform-origin`);return n=n[1].split(/\s*,\s*/g).map(parseFloat),r=r.split(/\s+/g).map(parseFloat),{matrix:n,origin:r}}}function Dd(e){return 180*e/Math.PI%360}function Od(e){var t=parseFloat(e);if(/grad$/.test(e))return Math.PI*t/200;if(/rad$/.test(e))return t;if(/turn$/.test(e))return Math.PI*t*2;if(/deg$/.test(e))return Math.PI*t/180}function kd(e,t){return t=new er(t[0],t[1],t[2],t[3],t[4],t[5]),e.transform(t),t}function Ad(e,t){e.clip(t)}function jd(e,t,n,r){for(var i=new ci([t,n],r).curvePoints(),a=1;a<i.length;)e.curveTo(i[a++],i[a++],i[a++])}function Md(e){return(e.x<=0||e.y<=0)&&(e.x=e.y=0),e}function Nd(e,t,n,r,i){var a=Math.max(0,t.x),o=Math.max(0,t.y),s=Math.max(0,n.x),c=Math.max(0,n.y),l=Math.max(0,r.x),u=Math.max(0,r.y),d=Math.max(0,i.x),f=Math.max(0,i.y),p=Math.min(e.width/(a+s),e.height/(c+u),e.width/(l+d),e.height/(f+o));return p<1&&(a*=p,o*=p,s*=p,c*=p,l*=p,u*=p,d*=p,f*=p),{tl:{x:a,y:o},tr:{x:s,y:c},br:{x:l,y:u},bl:{x:d,y:f}}}function Pd(e,t,n){var r=yd(e),i=Cd(r,`top-left`),a=Cd(r,`top-right`),o=Cd(r,`bottom-left`),s=Cd(r,`bottom-right`);if(n==`padding`||n==`content`){var c=xd(e,r,`top`),l=xd(e,r,`right`),u=xd(e,r,`bottom`),d=xd(e,r,`left`);if(i.x-=d.width,i.y-=c.width,a.x-=l.width,a.y-=c.width,s.x-=l.width,s.y-=u.width,o.x-=d.width,o.y-=u.width,n==`content`){var f=parseFloat(W(r,`padding-top`)),p=parseFloat(W(r,`padding-right`)),m=parseFloat(W(r,`padding-bottom`)),h=parseFloat(W(r,`padding-left`));i.x-=h,i.y-=f,a.x-=p,a.y-=f,s.x-=p,s.y-=m,o.x-=h,o.y-=m}}return typeof n==`number`&&(i.x-=n,i.y-=n,a.x-=n,a.y-=n,s.x-=n,s.y-=n,o.x-=n,o.y-=n),Fd(t,i,a,s,o)}function Fd(e,t,n,r,i){var a=Nd(e,t,n,r,i),o=a.tl,s=a.tr,c=a.br,l=a.bl,u=new I({fill:null,stroke:null});return u.moveTo(e.left,e.top+o.y),o.x&&jd(u,e.left+o.x,e.top+o.y,{startAngle:-180,endAngle:-90,radiusX:o.x,radiusY:o.y}),u.lineTo(e.right-s.x,e.top),s.x&&jd(u,e.right-s.x,e.top+s.y,{startAngle:-90,endAngle:0,radiusX:s.x,radiusY:s.y}),u.lineTo(e.right,e.bottom-c.y),c.x&&jd(u,e.right-c.x,e.bottom-c.y,{startAngle:0,endAngle:90,radiusX:c.x,radiusY:c.y}),u.lineTo(e.left+l.x,e.bottom),l.x&&jd(u,e.left+l.x,e.bottom-l.y,{startAngle:90,endAngle:180,radiusX:l.x,radiusY:l.y}),u.close()}function Id(e,t){var n=String(parseFloat(e));switch(t){case`decimal-leading-zero`:return n.length<2&&(n=`0`+n),n;case`lower-roman`:return Cn(e).toLowerCase();case`upper-roman`:return Cn(e).toUpperCase();case`lower-latin`:case`lower-alpha`:return pd(e-1);case`upper-latin`:case`upper-alpha`:return pd(e-1).toUpperCase();default:return n}}function Ld(e,t){function n(e,t,n){return n?(n=n.replace(/^\s*(["'])(.*)\1\s*$/,`$2`),sd(e).map(function(e){return Id(e,t)}).join(n)):Id(od(e)||0,t)}var r=rd(t,/^\s+/),i=[],a;return r.forEach(function(t){var r;(a=/^\s*(["'])(.*)\1\s*$/.exec(t))?i.push(a[2].replace(/\\([0-9a-f]{4})/gi,function(e,t){return String.fromCharCode(parseInt(t,16))})):(a=/^\s*counter\((.*?)\)\s*$/.exec(t))?(r=rd(a[1]),i.push(n(r[0],r[1]))):(a=/^\s*counters\((.*?)\)\s*$/.exec(t))?(r=rd(a[1]),i.push(n(r[0],r[2],r[1]))):(a=/^\s*attr\((.*?)\)\s*$/.exec(t))?i.push(e.getAttribute(a[1])||``):i.push(t)}),i.join(``)}function Rd(e){if(e.cssText)return e.cssText;for(var t=[],n=0;n<e.length;++n)t.push(e[n]+`: `+W(e,e[n]));return t.join(`;
`)}function zd(e,t){if(e.tagName==Xu){Bd(e,t);return}let n=[];function r(t,r){let i=yd(e,t),a=i.content;if(dd(i),a&&a!=`normal`&&a!=`none`&&i.width!=`0px`){let t=e.ownerDocument.createElement(Xu);Pr(t,Rd(i)),t.textContent=Ld(e,a),e.insertBefore(t,r),n.push(t)}}if(r(`:before`,e.firstChild),r(`:after`,null),n.length>0){let r=e.className;e.className+=` kendo-pdf-hide-pseudo-elements`,Bd(e,t),e.className=r,n.forEach(function(t){e.removeChild(t)})}else Bd(e,t)}function Bd(e,t){var n=yd(e),r=xd(e,n,`top`),i=xd(e,n,`right`),a=xd(e,n,`bottom`),o=xd(e,n,`left`),s=Cd(n,`top-left`),c=Cd(n,`top-right`),l=Cd(n,`bottom-left`),u=Cd(n,`bottom-right`),d=W(n,`direction`),f=fd(pn(e,`background-color`)),p=nd(W(n,`background-image`)),m=rd(W(n,`background-repeat`)),h=rd(W(n,`background-position`)),g=rd(W(n,`background-origin`)),_=rd(W(n,`background-size`)),v,y;$u&&(v=n.textOverflow,v==`ellipsis`&&(y=e.style.textOverflow,e.style.textOverflow=`clip`)),Ju.msie&&Ju.version<10&&(h=rd(e.currentStyle.backgroundPosition));var b=Td(e.getBoundingClientRect(),`border-*-width`,e);(function(){var e=W(n,`clip`),r=/^\s*rect\((.*)\)\s*$/.exec(e);if(r){var i=r[1].split(/[ ,]+/g),a=i[0]==`auto`?b.top:parseFloat(i[0])+b.top,o=i[1]==`auto`?b.right:parseFloat(i[1])+b.left,s=i[2]==`auto`?b.bottom:parseFloat(i[2])+b.top,c=i[3]==`auto`?b.left:parseFloat(i[3])+b.left,l=new L,u=new I().moveTo(c,a).lineTo(o,a).lineTo(o,s).lineTo(c,s).close();Ad(l,u),t.append(l),t=l,gd(u)}})();var x,S,ee,te=W(n,`display`);if(te==`table-row`)for(x=[],S=0,ee=e.children;S<ee.length;++S)x.push(ee[S].getBoundingClientRect());else x=e.getClientRects(),x.length==1&&(x=[e.getBoundingClientRect()]);for(x=C(x),S=0;S<x.length;++S)ae(x[S],S===0,S==x.length-1);if(e.tagName==`A`&&e.href&&!/^#?$/.test(e.getAttribute(`href`))&&(!U._avoidLinks||!td(e,U._avoidLinks))){let n=document.createRange();n.selectNodeContents(e),Yu(n.getClientRects()).forEach(function(n){let r=new L;r._pdfLink={url:e.href,top:n.top,right:n.right,bottom:n.bottom,left:n.left},t.append(r)})}return x.length>0&&te==`list-item`&&!e.getAttribute(`kendo-no-bullet`)&&ie(x[0]),(function(){function r(){var n=Pd(e,b,`padding`),r=new L;Ad(r,n),t.append(r),t=r,gd(n)}(Kd(e)||/^(hidden|auto|scroll)/.test(W(n,`overflow`))||/^(hidden|auto|scroll)/.test(W(n,`overflow-x`))||/^(hidden|auto|scroll)/.test(W(n,`overflow-y`)))&&r()})(),!Hd(e,t)&&!Ud(e,t)&&Zd(e,t),$u&&v==`ellipsis`&&(e.style.textOverflow=y),t;function C(t){if(/^td$/i.test(e.tagName)){var n=U.table;if(n&&W(n.style,`border-collapse`)==`collapse`){var r=xd(n.element,n.style,`left`).width,i=xd(n.element,n.style,`top`).width;if(r===0&&i===0)return t;var a=n.element.getBoundingClientRect(),o=n.element.rows[0].cells[0].getBoundingClientRect();if(o.top==a.top||o.left==a.left)return Yu(t).map(function(e){return{left:e.left+r,top:e.top+i,right:e.right+r,bottom:e.bottom+i,height:e.height,width:e.width}})}}return t}function w(e,n,r,i,a,o,s,c){if(r<=0)return;var l,u=new L;kd(u,c),t.append(u),Md(o),Md(s),l=new I({fill:{color:e},stroke:null}),u.append(l),l.moveTo(o.x?Math.max(o.x,i):0,0).lineTo(n-(s.x?Math.max(s.x,a):0),0).lineTo(n-Math.max(s.x,a),r).lineTo(Math.max(o.x,i),r).close(),o.x&&d(i,o,[-1,0,0,1,o.x,0]),s.x&&d(a,s,[1,0,0,1,n-s.x,0]);function d(t,n,i){var a=Math.PI/2*t/(t+r),o={x:n.x-t,y:n.y-r},s=new I({fill:{color:e},stroke:null}).moveTo(0,0);kd(s,i),jd(s,0,n.y,{startAngle:-90,endAngle:-Dd(a),radiusX:n.x,radiusY:n.y}),o.x>0&&o.y>0?(s.lineTo(o.x*Math.cos(a),n.y-o.y*Math.sin(a)),jd(s,0,n.y,{startAngle:-Dd(a),endAngle:-90,radiusX:o.x,radiusY:o.y,anticlockwise:!0})):o.x>0?s.lineTo(o.x,r).lineTo(0,r):s.lineTo(o.x,r).lineTo(o.x,0),u.append(s.close())}}function ne(e){var n=new L;if(Ad(n,Fd(e,s,c,u,l)),t.append(n),f){var r=new I({fill:{color:f.toCssRgba()},stroke:null});r.moveTo(e.left,e.top).lineTo(e.right,e.top).lineTo(e.right,e.bottom).lineTo(e.left,e.bottom).close(),n.append(r)}for(var i=p.length;--i>=0;)re(n,e,p[i],m[i%m.length],h[i%h.length],g[i%g.length],_[i%_.length])}function re(t,n,r,i,a,o,s){if(!r||r==`none`)return;if(r.type==`url`){var c=Qu[r.url];c&&c.width>0&&c.height>0&&l(t,n,c.width,c.height,function(e,t){e.append(new ca(r.url,t))})}else if(r.type==`linear`)l(t,n,n.width,n.height,Vd(r));else return;function l(t,n,r,c,l){var u=r/c,d,f=n;if(o==`content-box`?(f=Td(f,`border-*-width`,e),f=Td(f,`padding-*`,e)):o==`padding-box`&&(f=Td(f,`border-*-width`,e)),!/^\s*auto(\s+auto)?\s*$/.test(s))if(s==`contain`)d=Math.min(f.width/r,f.height/c),r*=d,c*=d;else if(s==`cover`)d=Math.max(f.width/r,f.height/c),r*=d,c*=d;else{var p=s.split(/\s+/g);r=/%$/.test(p[0])?f.width*parseFloat(p[0])/100:parseFloat(p[0]),c=p.length==1||p[1]==`auto`?r/u:/%$/.test(p[1])?f.height*parseFloat(p[1])/100:parseFloat(p[1])}var m=String(a);switch(m){case`bottom`:m=`50% 100%`;break;case`top`:m=`50% 0`;break;case`left`:m=`0 50%`;break;case`right`:m=`100% 50%`;break;case`center`:m=`50% 50%`;break}m=m.split(/\s+/),m.length==1&&(m[1]=`50%`),/%$/.test(m[0])?m[0]=parseFloat(m[0])/100*(f.width-r):m[0]=parseFloat(m[0]),/%$/.test(m[1])?m[1]=parseFloat(m[1])/100*(f.height-c):m[1]=parseFloat(m[1]);var h=new F([f.left+m[0],f.top+m[1]],[r,c]);function g(){for(;h.origin.x>n.left;)h.origin.x-=r}function _(){for(;h.origin.y>n.top;)h.origin.y-=c}function v(){for(;h.origin.x<n.right;)l(t,h.clone()),h.origin.x+=r}if(i==`no-repeat`)l(t,h);else if(i==`repeat-x`)g(),v();else if(i==`repeat-y`)for(_();h.origin.y<n.bottom;)l(t,h.clone()),h.origin.y+=c;else if(i==`repeat`){g(),_();for(var y=h.origin.clone();h.origin.y<n.bottom;)h.origin.x=y.x,v(),h.origin.y+=c}}}function ie(){var r=W(n,`list-style-type`);if(r==`none`)return;var i=W(n,`list-style-position`);function a(n){Sd(e,function(){e.style.position=`relative`;var r=e.ownerDocument.createElement(Xu);r.style.position=`absolute`,r.style.boxSizing=`border-box`,i==`outside`?(r.style.width=`6em`,r.style.left=`-6.8em`,r.style.textAlign=`right`):r.style.left=`0px`,n(r),e.insertBefore(r,e.firstChild),ef(r,t),e.removeChild(r)})}function o(t){var n=e.parentNode.children,r=e.getAttribute(`kendo-split-index`);if(r!=null)return t(r|0,n.length);for(var i=0;i<n.length;++i)if(n[i]===e)return t(i,n.length)}switch(r){case`circle`:case`disc`:case`square`:a(function(e){e.innerHTML=`&nbsp;`,e.setAttribute(Zu,r)});break;case`decimal`:case`decimal-leading-zero`:a(function(e){o(function(t){++t,r==`decimal-leading-zero`&&t<10&&(t=`0`+t),e.innerHTML=t+`.`})});break;case`lower-roman`:case`upper-roman`:a(function(e){o(function(t){t=Cn(t+1),r==`upper-roman`&&(t=t.toUpperCase()),e.innerHTML=t+`.`})});break;case`lower-latin`:case`lower-alpha`:case`upper-latin`:case`upper-alpha`:a(function(e){o(function(t){t=pd(t),/^upper/i.test(r)&&(t=t.toUpperCase()),e.innerHTML=t+`.`})});break}}function ae(n,f,p){if(n.width===0||n.height===0)return;ne(n);var m=o.width>0&&(f&&d==`ltr`||p&&d==`rtl`),h=i.width>0&&(p&&d==`ltr`||f&&d==`rtl`);if(r.width===0&&o.width===0&&i.width===0&&a.width===0)return;if(r.color==i.color&&r.color==a.color&&r.color==o.color&&r.width==i.width&&r.width==a.width&&r.width==o.width&&m&&h){n=Td(n,r.width/2);var g=Pd(e,n,r.width/2);g.options.stroke={color:r.color,width:r.width},t.append(g);return}if(s.x===0&&c.x===0&&u.x===0&&l.x===0&&r.width<2&&o.width<2&&i.width<2&&a.width<2){r.width>0&&t.append(new I({stroke:{width:r.width,color:r.color}}).moveTo(n.left,n.top+r.width/2).lineTo(n.right,n.top+r.width/2)),a.width>0&&t.append(new I({stroke:{width:a.width,color:a.color}}).moveTo(n.left,n.bottom-a.width/2).lineTo(n.right,n.bottom-a.width/2)),m&&t.append(new I({stroke:{width:o.width,color:o.color}}).moveTo(n.left+o.width/2,n.top).lineTo(n.left+o.width/2,n.bottom)),h&&t.append(new I({stroke:{width:i.width,color:i.color}}).moveTo(n.right-i.width/2,n.top).lineTo(n.right-i.width/2,n.bottom));return}var _=Nd(n,s,c,u,l),v=_.tl,y=_.tr,b=_.br,x=_.bl;w(r.color,n.width,r.width,o.width,i.width,v,y,[1,0,0,1,n.left,n.top]),w(a.color,n.width,a.width,i.width,o.width,b,x,[-1,0,0,-1,n.right,n.bottom]);function S(e){return{x:e.y,y:e.x}}w(o.color,n.height,o.width,a.width,r.width,S(x),S(v),[0,-1,1,0,n.left,n.bottom]),w(i.color,n.height,i.width,r.width,a.width,S(y),S(b),[0,1,-1,0,n.right,n.top])}}function Vd(e){return function(t,n){var r=n.width(),i=n.height();switch(e.type){case`linear`:var a=e.angle==null?Math.PI:e.angle;switch(e.to){case`top`:a=0;break;case`left`:a=-Math.PI/2;break;case`bottom`:a=Math.PI;break;case`right`:a=Math.PI/2;break;case`top left`:case`left top`:a=-Math.atan2(i,r);break;case`top right`:case`right top`:a=Math.atan2(i,r);break;case`bottom left`:case`left bottom`:a=Math.PI+Math.atan2(i,r);break;case`bottom right`:case`right bottom`:a=Math.PI-Math.atan2(i,r);break}e.reverse&&(a-=Math.PI),a%=2*Math.PI,a<0&&(a+=2*Math.PI);var o=Math.abs(r*Math.sin(a))+Math.abs(i*Math.cos(a)),s=Math.atan(r*Math.tan(a)/i),c=Math.sin(s),l=Math.cos(s),u=Math.abs(c)+Math.abs(l),d=u/2*c,f=u/2*l;a>Math.PI/2&&a<=3*Math.PI/2&&(d=-d,f=-f);var p=[],m=0,h=e.stops.map(function(t,n){var r=t.percent;r?r=parseFloat(r)/100:t.length?r=parseFloat(t.length)/o:n===0?r=0:n==e.stops.length-1&&(r=1);var i={color:t.color.toCssRgba(),offset:r};return r==null?p.push({left:m,stop:i}):(m=r,p.forEach(function(e,t){var n=e.stop;n.offset=e.left+(m-e.left)*(t+1)/(p.length+1)}),p=[]),i}),g=[.5-d,.5+f],_=[.5+d,.5-f];t.append(I.fromRect(n).stroke(null).fill(new Ea({start:g,end:_,stops:h,userSpace:!1})));break;case`radial`:window.console&&window.console.log&&window.console.log(`Radial gradients are not yet supported in HTML renderer`);break}}}function Hd(e,t){let n=null;if(window.kendo&&window.kendo.jQuery&&e.getAttribute(window.kendo.attr(`role`))){let t=window.kendo.widgetInstance(window.kendo.jQuery(e));t&&(t.exportDOMVisual||t.exportVisual)&&(n=t.exportDOMVisual?t.exportDOMVisual():t.exportVisual())}if(n===null&&e._kendoExportVisual){let t=e.getBoundingClientRect(),r={width:t.width,height:t.height};n=e._kendoExportVisual(r)}if(!n)return!1;let r=new L;r.children.push(n);let i=e.getBoundingClientRect();return r.transform(Ur().translate(i.left,i.top)),t.append(r),!0}function Ud(e,t){let n=e.getAttribute(Zu);if(!n)return!1;var r=e.getBoundingClientRect();let i=pn(e,`color`);if(n===`square`){let e=r.height/5;t.append(new _a(new F([r.right-e,r.top+r.height/2.1],[e,e])).fill(i).stroke(i))}else{let e=r.height/7,a=new ni(new Yr([r.right-e,r.top+(r.height+e)/2],e));n===`circle`?a.stroke(i,.5):a.fill(i).stroke(null),t.append(a)}return!0}function Wd(e,t,n){var r=wd(e),i=new ca(t,new F([r.left,r.top],[r.width,r.height]));Ad(i,Pd(e,r,`content`)),n.append(i)}function Gd(e,t){var n=yd(e),r=yd(t),i=parseFloat(W(n,`z-index`)),a=parseFloat(W(r,`z-index`)),o=W(n,`position`),s=W(r,`position`);return isNaN(i)&&isNaN(a)?/static|absolute/.test(o)&&/static|absolute/.test(s)?0:o==`static`?-1:+(s==`static`):isNaN(i)?a===0?0:a>0?-1:1:isNaN(a)?i===0?0:i>0?1:-1:parseFloat(i)-parseFloat(a)}function Kd(e){return/^(?:textarea|select|input)$/i.test(e.tagName)}function qd(e){return e.selectedOptions&&e.selectedOptions.length>0?e.selectedOptions[0]:e.options[e.selectedIndex]}function Jd(e,t){yd(e);var n=pn(e,`color`),r=e.getBoundingClientRect();e.type==`checkbox`?(t.append(I.fromRect(new F([r.left+1,r.top+1],[r.width-2,r.height-2])).stroke(n,1)),e.checked&&t.append(new I().stroke(n,1.2).moveTo(r.left+.22*r.width,r.top+.55*r.height).lineTo(r.left+.45*r.width,r.top+.75*r.height).lineTo(r.left+.78*r.width,r.top+.22*r.width))):(t.append(new ni(new Yr([(r.left+r.right)/2,(r.top+r.bottom)/2],Math.min(r.width-2,r.height-2)/2)).stroke(n,1)),e.checked&&t.append(new ni(new Yr([(r.left+r.right)/2,(r.top+r.bottom)/2],Math.min(r.width-8,r.height-8)/2)).fill(n).stroke(null)))}function Yd(e,t){var n=e.tagName.toLowerCase();if(n==`input`&&(e.type==`checkbox`||e.type==`radio`))return Jd(e,t);var r=e.parentNode,i=e.ownerDocument,a=i.createElement(Xu),o;if(Pr(a,Rd(yd(e))),n==`input`&&(a.style.whiteSpace=`pre`),(n==`select`||n==`textarea`)&&(a.style.overflow=`auto`),n==`select`)if(e.multiple)for(var s=0;s<e.options.length;++s)o=i.createElement(Xu),Pr(o,Rd(yd(e.options[s]))),o.style.display=`block`,o.textContent=e.options[s].textContent,a.appendChild(o);else o=qd(e),o&&(a.textContent=o.textContent);else a.textContent=e.value;r.insertBefore(a,e),a.scrollLeft=e.scrollLeft,a.scrollTop=e.scrollTop,e.style.display=`none`,Zd(a,t),e.style.display=``,r.removeChild(a)}function Xd(e){let t=new window.XMLSerializer,n=t.serializeToString(e);if(Ju.mozilla&&!(e.getAttribute(`width`)&&e.getAttribute(`height`))){let r=new window.DOMParser().parseFromString(n,`image/svg+xml`).documentElement,i=wd(e);r.setAttribute(`width`,i.width),r.setAttribute(`height`,i.height),n=t.serializeToString(r)}return n}function Zd(e,t){switch(U._stackingContext.element===e&&(U._stackingContext.group=t),e.tagName.toLowerCase()){case`img`:Wd(e,e.src,t);break;case`svg`:Wd(e,`data:image/svg+xml;base64,${In(Xd(e))}`,t);break;case`canvas`:try{Wd(e,e.toDataURL(`image/png`),t)}catch{}break;case`textarea`:case`input`:case`select`:Yd(e,t);break;default:for(var n=[],r=[],i=[],a=e.firstChild;a;a=a.nextSibling)switch(a.nodeType){case 3:/\S/.test(a.data)&&Qd(e,a,t);break;case 1:var o=yd(a),s=W(o,`float`);W(o,`position`)==`static`?s==`none`?n.push(a):r.push(a):i.push(a);break}Hn(n,Gd).forEach(function(e){ef(e,t)}),Hn(r,Gd).forEach(function(e){ef(e,t)}),Hn(i,Gd).forEach(function(e){ef(e,t)})}}function Qd(e,t,n){if(_d())return;var r=yd(e);if(parseFloat(W(r,`text-indent`))<-500)return;var i=t.data,a=0,o=i.search(/\S\s*$/)+1;if(!o)return;var s=W(r,`font-size`),c=W(r,`line-height`),l=[W(r,`font-style`),W(r,`font-variant`),W(r,`font-weight`),s,W(r,`font-family`)].join(` `);if(s=parseFloat(s),c=parseFloat(c),s===0||isNaN(s))return;var u=pn(e,`color`),d=e.ownerDocument.createRange(),f=W(r,`text-align`)==`justify`,p=W(r,`column-count`,1),m=W(r,`white-space`),h=W(r,`text-transform`),g=e.getBoundingClientRect().width/s*5;g===0&&(g=500);var _=null,v=U.underline,y=U[`line-through`],b=U.overline,x=U[`underline-offset`];for(v&&S(re);!te(););(y||b)&&S(ne);return;function S(e){d.selectNode(t);let n=Yu(d.getClientRects());S=e=>n.forEach(e),S(e)}function ee(e){if($u||Ju.chrome||Ju.safari){for(var t=e.getClientRects(),n={top:1/0,right:-1/0,bottom:-1/0,left:1/0},r=!1,i=0;i<t.length;++i){var a=t[i];a.width<=1||a.bottom===_||(n.left=Math.min(a.left,n.left),n.top=Math.min(a.top,n.top),n.right=Math.max(a.right,n.right),n.bottom=Math.max(a.bottom,n.bottom),r=!0)}return r?(n.width=n.right-n.left,n.height=n.bottom-n.top,n):e.getBoundingClientRect()}return e.getBoundingClientRect()}function te(){var e=a,n,r=i.substr(a).search(/\S/);if(a+=r,r<0||a>=o)return!0;d.setStart(t,a),d.setEnd(t,a+1),n=ee(d);var s=!1;if((f||p>1)&&(r=i.substr(a).search(/\s/),r>=0)){d.setEnd(t,a+r);var c=ee(d);c.bottom==n.bottom&&(n=c,s=!0,a+=r)}if(!s){if(r=(function e(r,i,a){d.setEnd(t,i);var o=ee(d);return o.bottom!=n.bottom&&r<i?e(r,r+i>>1,i):o.right==n.right?i:(n=o,i<a?e(i,i+a>>1,a):i)})(a,Math.min(o,a+g),o),r==a)return!0;if(a=r,r=d.toString().search(/\s+$/),r===0)return!1;r>0&&(d.setEnd(t,d.startOffset+r),n=ee(d))}$u&&(n=d.getClientRects()[0]);var l=d.toString();if(!/^(?:pre|pre-wrap)$/i.test(m))l=l.replace(/\s+/g,` `);else if(/\t/.test(l)){var u=0;for(r=e;r<d.startOffset;++r){var h=i.charCodeAt(r);h==9?u+=8-u%8:h==10||h==13?u=0:u++}for(;(r=l.search(`	`))>=0;){var v=`        `.substr(0,8-(u+r)%8);l=l.substr(0,r)+v+l.substr(r+1)}}s||(_=n.bottom),C(l,n)}function C(e,t){if($u&&!isNaN(c)){var r=id(l),i=(t.top+t.bottom-r)/2;t={top:i,right:t.right,bottom:i+r,left:t.left,height:r,width:t.right-t.left}}switch(h){case`uppercase`:e=e.toUpperCase();break;case`lowercase`:e=e.toLowerCase();break;case`capitalize`:e=e.replace(/(?:^|\s)\S/g,e=>e.toUpperCase());break}var a=new ed(e,new F([t.left,t.top],[t.width,t.height]),{font:l,fill:{color:u}});n.append(a)}function w(e,t,r,i){if(r){var a=new I({stroke:{width:e,color:r}});i-=e,a.moveTo(t.left,i).lineTo(t.right,i),n.append(a)}}function ne(e){let t=s/12;w(t,e,y,e.bottom-e.height/2.7),w(t,e,b,e.top)}function re(e){let t=s/12,n=e.bottom;x==null?n+=t:n+=x,w(t,e,v,n)}}function $d(e,t,n){var r;n==`auto`?(r=t,n=0):(r=U._stackingContext.group,n=parseFloat(n));for(var i=r.children,a=0;a<i.length&&!(i[a]._dom_zIndex!=null&&i[a]._dom_zIndex>n);++a);var o=new L;if(r.insert(a,o),o._dom_zIndex=n,r!==t&&U._clipbox){var s=U._matrix.invert(),c=U._clipbox.transformCopy(s);Ad(o,I.fromRect(c))}return o}function ef(e,t){var n=yd(e);if(dd(n),!/^(style|script|link|meta|iframe|col|colgroup)$/i.test(e.tagName)&&U._clipbox!=null){var r=parseFloat(W(n,`opacity`)),i=W(n,`visibility`),a=W(n,`display`);if(r!==0&&i!=`hidden`&&a!=`none`){var o=Ed(n),s,c=W(n,`z-index`);(o||r<1)&&c==`auto`&&(c=0),s=$d(e,t,c),r<1&&s.opacity(r*s.opacity()),md(e,n,s),o?Sd(e,function(){bd(e.style,`transform`,`none`,`important`),bd(e.style,`transition`,`none`,`important`),W(n,`position`)==`static`&&bd(e.style,`position`,`relative`,`important`);var t=e.getBoundingClientRect(),r=t.left+o.origin[0],i=t.top+o.origin[1],a=[1,0,0,1,-r,-i];a=tf(a,o.matrix),a=tf(a,[1,0,0,1,r,i]),a=kd(s,a),U._matrix=U._matrix.multiplyCopy(a),zd(e,s)}):zd(e,s),hd()}}}function tf(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=t[0],l=t[1],u=t[2],d=t[3],f=t[4],p=t[5];return[n*c+r*u,n*l+r*d,i*c+a*u,i*l+a*d,o*c+s*u+f,o*l+s*d+p]}var nf=class{constructor(e,t){this.r=e,this.angle=t}},G=class e extends P{constructor(e,t){super(e,t)}clone(){return new e(this.x,this.y)}plus(t){return new e(this.x+t.x,this.y+t.y)}minus(t){return new e(this.x-t.x,this.y-t.y)}offset(t){return new e(this.x-t,this.y-t)}times(t){return new e(this.x*t,this.y*t)}normalize(){return this.length()===0?new e:this.times(1/this.length())}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}toString(){return`(`+this.x+`,`+this.y+`)`}lengthSquared(){return this.x*this.x+this.y*this.y}middleOf(t,n){return new e(n.x-t.x,n.y-t.y).times(.5).plus(t)}toPolar(e){let t=1;e&&(t=180/Math.PI);let n=Math.atan2(Math.abs(this.y),Math.abs(this.x)),r=Math.PI/2,i=this.length();if(this.x===0){if(this.y===0)return new nf(0,0);if(this.y>0)return new nf(i,t*r);if(this.y<0)return new nf(i,t*3*r)}else if(this.x>0){if(this.y===0)return new nf(i,0);if(this.y>0)return new nf(i,t*n);if(this.y<0)return new nf(i,t*(4*r-n))}else{if(this.y===0)return new nf(i,2*r);if(this.y>0)return new nf(i,t*(2*r-n));if(this.y<0)return new nf(i,t*(2*r+n))}}isOnLine(e,t){if(e.x>t.x){let n=t;t=e,e=n}let n=new K(e.x,e.y).inflate(3,3),r=new K(t.x,t.y).inflate(3,3),i,a;return n.union(r).contains(this)?e.x===t.x||e.y===t.y?!0:(e.y<t.y?(i=n.x+(r.x-n.x)*(this.y-(n.y+n.height))/(r.y+r.height-(n.y+n.height)),a=n.x+n.width+(r.x+r.width-(n.x+n.width))*(this.y-n.y)/(r.y-n.y)):(i=n.x+(r.x-n.x)*(this.y-n.y)/(r.y-n.y),a=n.x+n.width+(r.x+r.width-(n.x+n.width))*(this.y-(n.y+n.height))/(r.y+r.height-(n.y+n.height))),this.x>i&&this.x<a):!1}parse(t){let n=t.slice(1,t.length-1).split(`,`),r=parseInt(n[0],10),i=parseInt(n[1],10);if(!isNaN(r)&&!isNaN(i))return new e(r,i)}},K=class e{constructor(e,t,n,r){this.x=e||0,this.y=t||0,this.width=n||0,this.height=r||0}contains(e){return e.x>=this.x&&e.x<=this.x+this.width&&e.y>=this.y&&e.y<=this.y+this.height}inflate(e,t){return t===void 0&&(t=e),this.x-=e,this.y-=t,this.width+=2*e+1,this.height+=2*t+1,this}offset(e,t){let n=e,r=t;return e instanceof G&&(n=e.x,r=e.y),this.x+=n,this.y+=r,this}union(t){let n=Math.min(this.x,t.x),r=Math.min(this.y,t.y),i=Math.max(this.x+this.width,t.x+t.width),a=Math.max(this.y+this.height,t.y+t.height);return new e(n,r,i-n,a-r)}center(){return new G(this.x+this.width/2,this.y+this.height/2)}top(){return new G(this.x+this.width/2,this.y)}right(){return new G(this.x+this.width,this.y+this.height/2)}bottom(){return new G(this.x+this.width/2,this.y+this.height)}left(){return new G(this.x,this.y+this.height/2)}topLeft(){return new G(this.x,this.y)}topRight(){return new G(this.x+this.width,this.y)}bottomLeft(){return new G(this.x,this.y+this.height)}bottomRight(){return new G(this.x+this.width,this.y+this.height)}clone(){return new e(this.x,this.y,this.width,this.height)}isEmpty(){return!this.width&&!this.height}equals(e){return this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height}rotatedBounds(e){let t=this.clone(),n=this.rotatedPoints(e),r=n[0],i=n[1],a=n[2],o=n[3];return t.x=Math.min(a.x,r.x,i.x,o.x),t.y=Math.min(a.y,r.y,i.y,o.y),t.width=Math.max(a.x,r.x,i.x,o.x)-t.x,t.height=Math.max(a.y,r.y,i.y,o.y)-t.y,t}rotatedPoints(e){let t=this.center(),n=this.bottomRight().rotate(e,t);return[this.topLeft().rotate(e,t),this.topRight().rotate(e,t),n,this.bottomLeft().rotate(e,t)]}toString(e){return e||=` `,this.x+e+this.y+e+this.width+e+this.height}scale(e,t,n,r,i){let a=this.topLeft(),o=this.center();a.rotate(i,o).rotate(i,r);let s=n.minus(a),c=new G(s.x*e,s.y*t),l=s.minus(c);a=a.plus(l),a.rotate(i,r).rotate(i,o),this.x=a.x,this.y=a.y,this.width*=e,this.height*=t}zoom(e){return this.x*=e,this.y*=e,this.width*=e,this.height*=e,this}overlaps(e){let t=this.bottomRight(),n=e.bottomRight();return!(t.x<e.x||t.y<e.y||n.x<this.x||n.y<this.y)}static toRect(t){return t instanceof e||(t=new e(t.x,t.y,t.width,t.height)),t}static empty(){return new e(0,0,0,0)}static fromPoints(t,n){if(isNaN(t.x)||isNaN(t.y)||isNaN(n.x)||isNaN(n.y))throw Error(`Some values are NaN.`);return new e(Math.min(t.x,n.x),Math.min(t.y,n.y),Math.abs(t.x-n.x),Math.abs(t.y-n.y))}},rf=class{constructor(e){this.container=K.toRect(e)}align(e,t){let n=t.toLowerCase().split(` `);for(let t=0;t<n.length;t++)e=this._singleAlign(e,n[t]);return e}_singleAlign(e,t){return He(this[t])?this[t](e):e}left(e){return this._align(e,this._left)}center(e){return this._align(e,this._center)}right(e){return this._align(e,this._right)}stretch(e){return this._align(e,this._stretch)}top(e){return this._align(e,this._top)}middle(e){return this._align(e,this._middle)}bottom(e){return this._align(e,this._bottom)}_left(e,t){t.x=e.x}_center(e,t){t.x=(e.width-t.width)/2||0}_right(e,t){t.x=e.width-t.width}_top(e,t){t.y=e.y}_middle(e,t){t.y=(e.height-t.height)/2||0}_bottom(e,t){t.y=e.height-t.height}_stretch(e,t){t.x=0,t.y=0,t.height=e.height,t.width=e.width}_align(e,t){return e=K.toRect(e),t(this.container,e),e}},af=class{constructor(){this._tail=null,this._head=null,this.length=0}enqueue(e){let t={value:e,next:null};this._head?(this._tail.next=t,this._tail=this._tail.next):(this._head=t,this._tail=this._head),this.length++}dequeue(){if(this.length<1)throw Error(`The queue is empty.`);let e=this._head.value;return this._head=this._head.next,this.length--,e}contains(e){let t=this._head;for(;t;){if(t.value===e)return!0;t=t.next}return!1}};let of=e=>typeof e==`function`;function sf(e,t){for(let n in t){if(n===`__proto__`||n===`constructor`)continue;let r=t[n],i=typeof r,a;if(a=i===`object`&&r!==null?r.constructor:null,a&&a!==Array)if(r instanceof Date)e[n]=new Date(r.getTime());else if(of(r.clone))e[n]=r.clone();else{let t=e[n];typeof t==`object`?e[n]=t||{}:e[n]={},sf(e[n],r)}else i!==`undefined`&&(e[n]=r)}return e}function q(e,...t){let n=t.length;for(let r=0;r<n;r++)sf(e,t[r]);return e}let cf={type:`Tree`,subtype:`Down`,roots:null,animate:!1,limitToView:!1,friction:.9,nodeDistance:50,iterations:300,horizontalSeparation:90,verticalSeparation:50,underneathVerticalTopOffset:15,underneathHorizontalOffset:15,underneathVerticalSeparation:15,grid:{width:1500,offsetX:50,offsetY:50,componentSpacingX:20,componentSpacingY:20},layerSeparation:50,layeredIterations:2,startRadialAngle:0,endRadialAngle:360,radialSeparation:150,radialFirstLevelSeparation:200,keepComponentsInOneRadialLayout:!1,ignoreContainers:!0,layoutContainerChildren:!1,ignoreInvisible:!0,animateTransitions:!1};var lf=class{constructor(){this.defaultOptions={...cf,grid:{...cf.grid}}}gridLayoutComponents(e){if(!e)throw Error(`No components supplied.`);k(e,function(e){e.calcBounds()}),e.sort(function(e,t){return t.bounds.width-e.bounds.width});let t=this.options.grid.width,n=this.options.grid.componentSpacingX,r=this.options.grid.componentSpacingY,i=this.options.grid.offsetX,a=this.options.grid.offsetY,o=[],s=[],c=0,l=i,u=a;for(;e.length>0;){l>=t&&(l=i,u+=c+r,c=0);let a=e.pop();this.moveToOffset(a,new G(l,u));for(let e=0;e<a.nodes.length;e++)s.push(a.nodes[e]);for(let e=0;e<a.links.length;e++)o.push(a.links[e]);let d=a.bounds,f=d.height;(f<=0||isNaN(f))&&(f=0);let p=d.width;(p<=0||isNaN(p))&&(p=0),f>=c&&(c=f),l+=p+n}return{nodes:s,links:o}}moveToOffset(e,t){let n,r,i=e.bounds,a=t.x-i.x,o=t.y-i.y;for(n=0;n<e.nodes.length;n++){let t=e.nodes[n],r=t.bounds();r.width===0&&r.height===0&&r.x===0&&r.y===0&&(r=new K(0,0,0,0)),r.x+=a,r.y+=o,t.bounds(r)}for(n=0;n<e.links.length;n++){let t=e.links[n];if(t.points){let e=[],n=t.points;for(r=0;r<n.length;r++){let t=n[r];t.x+=a,t.y+=o,e.push(t)}t.points=e}}return this.currentHorizontalOffset+=i.width+this.options.grid.offsetX,new G(a,o)}transferOptions(e){this.options=q({},this.defaultOptions),!D(e)&&(this.options=q(this.options,e||{}))}},uf=class{constructor(e,t){if(D(e))throw Error(`No diagram given`);this.diagram=e,this.nodeMap=new M,this.linkMap=new M,this.capture(t||e)}capture(e){let t,n,r,i,a,o,s;if(e&&e.type===`Graph`){for(i=0;i<e.nodes.length;i++)t=e.nodes[i],r=t.associatedShape,this.nodeMap.set(r.visual.id,new K(t.x,t.y,t.width,t.height));for(i=0;i<e.links.length;i++)o=e.links[i],a=o.associatedConnection,this.linkMap.set(a.visual.id,o.points())}else if(e instanceof Array)for(n=e,i=0;i<n.length;i++)t=n[i],r=t.associatedShape,r&&this.nodeMap.set(r.visual.id,new K(t.x,t.y,t.width,t.height));else if(Object.prototype.hasOwnProperty.call(e,`links`)&&Object.prototype.hasOwnProperty.call(e,`nodes`)){for(n=e.nodes,s=e.links,i=0;i<n.length;i++)t=n[i],r=t.associatedShape,r&&this.nodeMap.set(r.visual.id,new K(t.x,t.y,t.width,t.height));for(i=0;i<s.length;i++)o=s[i],a=o.associatedConnection,a&&this.linkMap.set(a.visual.id,o.points)}else{let e=this.diagram.shapes,t=this.diagram.connections;for(i=0;i<e.length;i++)r=e[i],this.nodeMap.set(r.visual.id,r.bounds());for(i=0;i<t.length;i++)a=t[i],this.linkMap.set(a.visual.id,a.points())}}},df=class e{constructor(e,t){if(this.links=[],this.outgoing=[],this.incoming=[],this.weight=1,this.data=null,this.type=`Node`,this.isVirtual=!1,T(e)?this.id=e:this.id=Ot(),T(t)){this.associatedShape=t;let e=t.bounds();this.width=e.width,this.height=e.height,this.x=e.x,this.y=e.y}else this.associatedShape=null;this.shortForm=`Node '`+this.id+`'`}isIsolated(){return Je(this.links)}bounds(e){if(!T(e))return new K(this.x,this.y,this.width,this.height);this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height}isLinkedTo(e){return ot(this.links,t=>t.getComplement(this)===e)}getChildren(){if(this.outgoing.length===0)return[];let e=[];for(let t=0,n=this.outgoing.length;t<n;t++){let n=this.outgoing[t];e.push(n.getComplement(this))}return e}getParents(){if(this.incoming.length===0)return[];let e=[];for(let t=0,n=this.incoming.length;t<n;t++){let n=this.incoming[t];e.push(n.getComplement(this))}return e}clone(){let t=new e;return T(this.weight)&&(t.weight=this.weight),T(this.balance)&&(t.balance=this.balance),T(this.owner)&&(t.owner=this.owner),t.associatedShape=this.associatedShape,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}adjacentTo(e){return this.isLinkedTo(e)!==null}removeLink(e){e.source===this&&(A(this.links,e),A(this.outgoing,e),e.source=null),e.target===this&&(A(this.links,e),A(this.incoming,e),e.target=null)}hasLinkTo(e){return ot(this.outgoing,function(t){return t.target===e})}degree(){return this.links.length}incidentWith(e){return j(this.links,e)}getLinksWith(e){return mt(this.links,function(t){return t.getComplement(this)===e},this)}getNeighbors(){let e=[];return k(this.incoming,function(t){e.push(t.getComplement(this))},this),k(this.outgoing,function(t){e.push(t.getComplement(this))},this),e}},ff=class e{constructor(e,t,n,r){if(D(e))throw Error(`The source of the new link is not set.`);if(D(t))throw Error(`The target of the new link is not set.`);let i,a;i=O(e)?new df(e):e,a=O(t)?new df(t):t,this.source=i,this.target=a,this.source.links.push(this),this.target.links.push(this),this.source.outgoing.push(this),this.target.incoming.push(this),T(n)?this.id=n:this.id=Ot(),T(r)?this.associatedConnection=r:this.associatedConnection=null,this.type=`Link`,this.shortForm=`Link '`+this.source.id+`->`+this.target.id+`'`}getComplement(e){if(this.source!==e&&this.target!==e)throw Error(`The given node is not incident with this link.`);return this.source===e?this.target:this.source}getCommonNode(e){return this.source===e.source||this.source===e.target?this.source:this.target===e.source||this.target===e.target?this.target:null}isBridging(e,t){return this.source===e&&this.target===t||this.source===t&&this.target===e}getNodes(){return[this.source,this.target]}incidentWith(e){return this.source===e||this.target===e}adjacentTo(e){return j(this.source.links,e)||j(this.target.links,e)}changeSource(e){A(this.source.links,this),A(this.source.outgoing,this),e.links.push(this),e.outgoing.push(this),this.source=e}changeTarget(e){A(this.target.links,this),A(this.target.incoming,this),e.links.push(this),e.incoming.push(this),this.target=e}changesNodes(e,t){this.source===e?this.changeSource(t):this.target===e&&this.changeTarget(t)}reverse(){let e=this.source,t=this.target;return this.source=t,A(e.outgoing,this),this.source.outgoing.push(this),this.target=e,A(t.incoming,this),this.target.incoming.push(this),this}directTo(e){if(this.source!==e&&this.target!==e)throw Error(`The given node is not incident with this link.`);this.target!==e&&this.reverse()}createReverseEdge(){let e=this.clone();return e.reverse(),e.reversed=!0,e}clone(){return new e(this.source,this.target)}},J=class e{constructor(e){this.links=[],this.nodes=[],this._nodeMap=new M,this.diagram=null,this._root=null,this.bounds=new K,this._hasCachedRelationships=!1,this.type=`Graph`,this.componentIndex=0,T(e)?O(e)?this.id=e:(this.diagram=e,this.id=e.id):this.id=Ot()}cacheRelationships(e){if(D(e)&&(e=!1),!(this._hasCachedRelationships&&!e)){for(let e=0,t=this.nodes.length;e<t;e++){let t=this.nodes[e];t.children=this.getChildren(t),t.parents=this.getParents(t)}this._hasCachedRelationships=!0}}assignLevels(e,t,n){if(!e)throw Error(`Start node not specified.`);D(t)&&(t=0),this.cacheRelationships(),D(n)&&(n=new M,k(this.nodes,function(e){n.add(e,!1)})),n.set(e,!0),e.level=t;let r=e.children;for(let e=0,i=r.length;e<i;e++){let i=r[e];!i||n.get(i)||this.assignLevels(i,t+1,n)}}root(e){if(D(e))return this._root?this._root:ft(this.nodes,function(e){return e.incoming.length===0})||ft(this.nodes);this._root=e}getConnectedComponents(){this.componentIndex=0,this.setItemIndices();let t=Xe(this.nodes.length,-1);for(let e=0;e<this.nodes.length;e++)t[e]===-1&&(this._collectConnectedNodes(t,e),this.componentIndex++);let n=[],r;for(r=0;r<this.componentIndex;++r)n[r]=new e;for(r=0;r<t.length;++r)n[t[r]].addNodeAndOutgoings(this.nodes[r]);return n.sort(function(e,t){return t.nodes.length-e.nodes.length}),n}_collectConnectedNodes(e,t){e[t]=this.componentIndex;let n=this.nodes[t];k(n.links,function(t){let r=t.getComplement(n).index;e[r]===-1&&this._collectConnectedNodes(e,r)},this)}calcBounds(){if(this.isEmpty())return this.bounds=new K,this.bounds;let e=null;for(let t=0,n=this.nodes.length;t<n;t++){let n=this.nodes[t];e=e?e.union(n.bounds()):n.bounds()}return this.bounds=e,this.bounds}getSpanningTree(t){let n=new e,r=new M,i,a,o=t.clone();n.root(o),o.level=0,o.id=t.id,r.add(t,n.root()),t.level=0;let s=[],c=[];n._addNode(n.root()),s.push(t),c.push(t);let l=1;for(;c.length>0;){let e=c.pop();for(let t=0;t<e.links.length;t++){let o=e.links[t].getComplement(e);if(j(s,o))continue;o.level=e.level+1,l<o.level+1&&(l=o.level+1),j(c,o)||c.push(o),j(s,o)||s.push(o),r.containsKey(e)?i=r.get(e):(i=e.clone(),i.level=e.level,i.id=e.id,r.add(e,i)),r.containsKey(o)?a=r.get(o):(a=o.clone(),a.level=o.level,a.id=o.id,r.add(o,a));let u=new ff(i,a);n.addLink(u)}}let u=[];for(let e=0;e<l;e++)u.push([]);return k(n.nodes,function(e){u[e.level].push(e)}),n.treeLevels=u,n.cacheRelationships(),n}takeRandomNode(e,t){if(D(e)&&(e=[]),D(t)&&(t=4),this.nodes.length===0)return null;if(this.nodes.length===1)return j(e,this.nodes[0])?null:this.nodes[0];let n=this.nodes.filter(function(n){return!j(e,n)&&n.degree()<=t});return Je(n)?null:n[$e(0,n.length)]}isEmpty(){return Je(this.nodes)}isHealthy(){return mt(this.links,function(e){return j(this.nodes,e.source)&&j(this.nodes,e.target)},this)}getParents(e){if(!this.hasNode(e))throw Error(`The given node is not part of this graph.`);return e.getParents()}getChildren(e){if(!this.hasNode(e))throw Error(`The given node is not part of this graph.`);return e.getChildren()}addLink(e,t,n){if(D(e))throw Error(`The source of the link is not defined.`);if(D(t))if(T(e.type)&&e.type===`Link`){this.addExistingLink(e);return}else throw Error(`The target of the link is not defined.`);let r=this.getNode(e);D(r)&&(r=this.addNode(e));let i=this.getNode(t);D(i)&&(i=this.addNode(t));let a=new ff(r,i);return T(n)&&(a.owner=n),this.links.push(a),a}removeAllLinks(){for(;this.links.length>0;){let e=this.links[0];this.removeLink(e)}}addExistingLink(e){if(!this.hasLink(e)){if(this.links.push(e),this.hasNode(e.source.id)){let t=this.getNode(e.source.id);e.changeSource(t)}else this.addNode(e.source);if(this.hasNode(e.target.id)){let t=this.getNode(e.target.id);e.changeTarget(t)}else this.addNode(e.target)}}hasLink(e){if(O(e))return ot(this.links,function(t){return t.id===e});if(e.type===`Link`)return j(this.links,e);throw Error(`The given object is neither an identifier nor a Link.`)}getNode(e){let t=e.id||e;if(this._nodeMap.containsKey(t))return this._nodeMap.get(t)}hasNode(e){let t=e.id||e;return this._nodeMap.containsKey(t)}_addNode(e){this.nodes.push(e),this._nodeMap.add(e.id,e)}_removeNode(e){A(this.nodes,e),this._nodeMap.remove(e.id)}removeNode(e){let t=e;if(O(e)&&(t=this.getNode(e)),T(t)){let e=t.links;t.links=[];for(let t=0,n=e.length;t<n;t++){let n=e[t];this.removeLink(n)}this._removeNode(t)}else throw Error(`The identifier should be a Node or the Id (string) of a node.`)}areConnected(e,t){return ot(this.links,function(n){return n.source===e&&n.target===t||n.source===t&&n.target===e})}removeLink(e){A(this.links,e),A(e.source.outgoing,e),A(e.source.links,e),A(e.target.incoming,e),A(e.target.links,e)}addNode(e,t,n){let r=null;if(!T(e))throw Error(`No Node or identifier for a new Node is given.`);if(O(e)){if(this.hasNode(e))return this.getNode(e);r=new df(e)}else{if(this.hasNode(e))return this.getNode(e);r=e}return T(t)&&r.bounds(t),T(n)&&(r.owner=n),this._addNode(r),r}addNodeAndOutgoings(e){this.hasNode(e)||this._addNode(e);let t=e.outgoing;e.outgoing=[],k(t,function(e){this.addExistingLink(e)},this)}setItemIndices(){let e;for(e=0;e<this.nodes.length;++e)this.nodes[e].index=e;for(e=0;e<this.links.length;++e)this.links[e].index=e}clone(t){let n=new e,r=T(t)&&t===!0;r&&(n.nodeMap=new M,n.linkMap=new M);let i=new M;return k(this.nodes,function(e){let t=e.clone();i.set(e,t),n._addNode(t),r&&n.nodeMap.set(t,e)}),k(this.links,function(e){if(i.containsKey(e.source)&&i.containsKey(e.target)){let t=n.addLink(i.get(e.source),i.get(e.target));r&&n.linkMap.set(t,e)}}),n}linearize(t){return e.Utils.linearize(this,t)}depthFirstTraversal(e,t){if(D(e))throw Error(`You need to supply a starting node.`);if(D(t))throw Error(`You need to supply an action.`);if(!this.hasNode(e))throw Error(`The given start-node is not part of this graph`);let n=this.getNode(e);this._dftIterator(n,t,[])}_dftIterator(e,t,n){t(e),n.push(e);let r=e.getChildren();for(let e=0,i=r.length;e<i;e++){let i=r[e];j(n,i)||this._dftIterator(i,t,n)}}breadthFirstTraversal(e,t){if(D(e))throw Error(`You need to supply a starting node.`);if(D(t))throw Error(`You need to supply an action.`);if(!this.hasNode(e))throw Error(`The given start-node is not part of this graph`);let n=this.getNode(e),r=new af,i=[];for(r.enqueue(n);r.length>0;){let e=r.dequeue();t(e),i.push(e);let n=e.getChildren();for(let e=0,t=n.length;e<t;e++){let t=n[e];j(i,t)||r.contains(t)||r.enqueue(t)}}}_stronglyConnectedComponents(e,t,n,r,i,a,o){n.add(t,o),r.add(t,o),o++,a.push(t);let s=t.getChildren(),c;for(let l=0,u=s.length;l<u;l++)c=s[l],n.containsKey(c)?j(a,c)&&r.add(t,Math.min(r.get(t),n.get(c))):(this._stronglyConnectedComponents(e,c,n,r,i,a,o),r.add(t,Math.min(r.get(t),r.get(c))));if(r.get(t)===n.get(t)){let n=[];do c=a.pop(),n.push(c);while(c!==t);(!e||n.length>1)&&i.push(n)}}findCycles(e){D(e)&&(e=!0);let t=new M,n=new M,r=[],i=[];for(let a=0,o=this.nodes.length;a<o;a++){let o=this.nodes[a];t.containsKey(o)||this._stronglyConnectedComponents(e,o,t,n,r,i,0)}return r}isAcyclic(){return Je(this.findCycles())}isSubGraph(e){let t=e.linearize(),n=this.linearize();return mt(t,function(e){return j(n,e)})}makeAcyclic(){if(this.isEmpty()||this.nodes.length<=1||this.links.length<=1)return[];if(this.nodes.length===2){let e=[];if(this.links.length>1){let t=this.links[0].source;for(let n=0,r=this.links.length;n<r;n++){let r=this.links[n];if(r.source===t)continue;let i=r.reverse();e.push(i)}}return e}let e=this.clone(!0),t=this.nodes.length,n=new M,r=function(e){return e.outgoing.length===0?2-t:e.incoming.length===0?t-2:e.outgoing.length-e.incoming.length},i=function(e){let t=r(e);n.containsKey(t)||n.set(t,[]),n.get(t).push(e)};k(e.nodes,function(e){i(e)});let a=[],o=[];for(;e.nodes.length>0;){let s,c,l;if(n.containsKey(2-t)){let a=n.get(2-t);for(;a.length>0;){c=a.pop();for(let e=0;e<c.links.length;e++){let t=c.links[e];s=t.getComplement(c),l=r(s),A(n.get(l),s),s.removeLink(t),i(s)}e._removeNode(c),o.unshift(c)}}if(n.containsKey(t-2)){let o=n.get(t-2);for(;o.length>0;){s=o.pop();for(let e=0;e<s.links.length;e++){let t=s.links[e];c=t.getComplement(s),l=r(c),A(n.get(l),c),c.removeLink(t),i(c)}a.push(s),e._removeNode(s)}}if(e.nodes.length>0){for(let o=t-3;o>2-t;o--)if(n.containsKey(o)&&n.get(o).length>0){let t=n.get(o).pop();for(let e=0;e<t.links.length;e++){let a=t.links[e],o=a.getComplement(t);l=r(o),A(n.get(l),o),o.removeLink(a),i(o)}a.push(t),e._removeNode(t);break}}}a=a.concat(o);let s=new M;for(let t=0;t<this.nodes.length;t++)s.set(e.nodeMap.get(a[t]),t);let c=[];return k(this.links,function(e){s.get(e.source)>s.get(e.target)&&(e.reverse(),c.push(e))}),c}};J.Predefined={EightGraph(){return J.Utils.parse([`1->2`,`2->3`,`3->4`,`4->1`,`3->5`,`5->6`,`6->7`,`7->3`])},Mindmap(){return J.Utils.parse(`0->1.0->2.0->3.0->4.0->5.1->6.1->7.7->8.2->9.9->10.9->11.3->12.12->13.13->14.4->15.4->16.15->17.15->18.18->19.18->20.14->21.14->22.5->23.23->24.23->25.6->26`.split(`.`))},ThreeGraph(){return J.Utils.parse([`1->2`,`2->3`,`3->1`])},BinaryTree(e){return D(e)&&(e=5),J.Utils.createBalancedTree(e,2)},Linear(e){return D(e)&&(e=10),J.Utils.createBalancedTree(e,1)},Tree(e,t){return J.Utils.createBalancedTree(e,t)},Forest(e,t,n){return J.Utils.createBalancedForest(e,t,n)},Workflow(){return J.Utils.parse([`0->1`,`1->2`,`2->3`,`1->4`,`4->3`,`3->5`,`5->6`,`6->3`,`6->7`,`5->4`])},Grid(e,t){let n=new J;if(e<=0&&t<=0)return n;for(let r=0;r<e+1;r++){let e=null;for(let i=0;i<t+1;i++){let t=new df(r.toString()+`.`+i.toString());if(n.addNode(t),e&&n.addLink(e,t),r>0){let e=n.getNode((r-1).toString()+`.`+i.toString());n.addLink(e,t)}e=t}}return n}},J.Utils={parse(e){let t,n=new J,r=e.slice();for(let e=0,i=r.length;e<i;e++){let i=r[e];if(O(i)){if(i.indexOf(`->`)<0)throw Error(`The link should be specified as 'a->b'.`);let e=i.split(`->`);if(e.length!==2)throw Error(`The link should be specified as 'a->b'.`);t=new ff(e[0],e[1]),n.addLink(t)}if(Ue(i)){if(!t)throw Error(`Specification found before Link definition.`);q(t,i)}}return n},linearize(e,t){if(D(e))throw Error(`Expected an instance of a Graph object in slot one.`);D(t)&&(t=!1);let n=[];for(let r=0,i=e.links.length;r<i;r++){let i=e.links[r];n.push(i.source.id+`->`+i.target.id),t&&n.push({id:i.id})}return n},_addShape(e,t,n,r){return D(t)&&(t=new G(0,0)),D(n)&&(n=Ot()),r=q({width:20,height:20,id:n,radius:10,fill:`#778899`,data:`circle`,undoable:!1,x:t.x,y:t.y},r),e.addShape(r)},_addConnection(e,t,n,r){return e.connect(t,n,r)},createDiagramFromGraph(e,t,n,r){if(D(e))throw Error(`The diagram surface is undefined.`);if(D(t))throw Error(`No graph specification defined.`);D(n)&&(n=!0),D(r)&&(r=!1);let i=e.element.clientWidth||200,a=e.element.clientHeight||200,o=[],s,c;for(let n=0,l=t.nodes.length;n<l;n++){s=t.nodes[n];let l=s.position;D(l)&&(l=T(s.x)&&T(s.y)?new G(s.x,s.y):new G($e(10,i-20),$e(10,a-20)));let u={};s.id===`0`||r&&q(u,{width:Math.random()*150+20,height:Math.random()*80+50,data:`rectangle`,fill:{color:`#778899`}}),c=this._addShape(e,l,s.id,u);let d=c.bounds();T(d)&&(s.x=d.x,s.y=d.y,s.width=d.width,s.height=d.height),o[s.id]=c}for(let n=0;n<t.links.length;n++){let r=t.links[n],i=o[r.source.id];if(D(i))continue;let a=o[r.target.id];D(a)||this._addConnection(e,i,a,{id:r.id})}if(n){new pf(e).layoutGraph(t,{limitToView:!1});for(let e=0;e<t.nodes.length;e++)s=t.nodes[e],c=o[s.id],c.bounds(new K(s.x,s.y,s.width,s.height))}},createBalancedTree(e,t){D(e)&&(e=3),D(t)&&(t=3);let n=new J,r,i=-1,a=[];if(e<=0||t<=0)return n;let o=new df((++i).toString());n.addNode(o),n.root(o),a.push(o);for(let o=0;o<e;o++){r=[];for(let e=0;e<a.length;e++){let o=a[e];for(let e=0;e<t;e++){let e=new df((++i).toString());n.addLink(o,e),r.push(e)}}a=r}return n},createBalancedForest(e,t,n){D(e)&&(e=3),D(t)&&(t=3),D(n)&&(n=5);let r=new J,i=-1,a=[],o;if(e<=0||t<=0||n<=0)return r;for(let s=0;s<n;s++){let n=new df((++i).toString());r.addNode(n),a=[n];for(let n=0;n<e;n++){o=[];for(let e=0;e<a.length;e++){let n=a[e];for(let e=0;e<t;e++){let e=new df((++i).toString());r.addLink(n,e),o.push(e)}}a=o}}return r},createRandomConnectedGraph(e,t,n){D(e)&&(e=40),D(t)&&(t=4),D(n)&&(n=!1);let r=new J,i=-1;if(e<=0)return r;let a=new df((++i).toString());if(r.addNode(a),e===1)return r;if(e>1){for(let n=1;n<e;n++){let e=r.takeRandomNode([],t);if(!e)break;let i=r.addNode(n.toString());r.addLink(e,i)}if(!n&&e>1){let n=$e(1,e);for(let e=0;e<n;e++){let e=r.takeRandomNode([],t),n=r.takeRandomNode([],t);e&&n&&!r.areConnected(e,n)&&r.addLink(e,n)}}return r}},randomDiagram(e,t,n,r,i){let a=J.Utils.createRandomConnectedGraph(t,n,r);J.Utils.createDiagramFromGraph(e,a,!1,i)}};var pf=class extends lf{constructor(e){if(super(),D(e))throw Error(`Diagram is not specified.`);this.diagram=e}layout(e){this.transferOptions(e);let t=new mf(this.diagram).convert(e);if(t.isEmpty())return;let n=t.getConnectedComponents();if(Je(n))return;for(let t=0;t<n.length;t++){let r=n[t];this.layoutGraph(r,e)}let r=this.gridLayoutComponents(n);return new uf(this.diagram,r)}layoutGraph(e,t){T(t)&&this.transferOptions(t),this.graph=e;let n=this.options.nodeDistance*9;this.temperature=n;let r=this._expectedBounds();this.width=r.width,this.height=r.height;for(let e=0;e<this.options.iterations;e++)this.refineStage=e>=this.options.iterations*5/6,this.tick(),this.temperature=this.refineStage?n/30:n*(1-e/(2*this.options.iterations))}tick(){let e;for(e=0;e<this.graph.nodes.length;e++)this._repulsion(this.graph.nodes[e]);for(e=0;e<this.graph.links.length;e++)this._attraction(this.graph.links[e]);for(e=0;e<this.graph.nodes.length;e++){let t=this.graph.nodes[e],n=Math.sqrt(t.dx*t.dx+t.dy*t.dy);if(n===0)return;t.x+=Math.min(n,this.temperature)*t.dx/n,t.y+=Math.min(n,this.temperature)*t.dy/n,this.options.limitToView&&(t.x=Math.min(this.width,Math.max(t.width/2,t.x)),t.y=Math.min(this.height,Math.max(t.height/2,t.y)))}}_shake(e){let t=Math.random()*this.options.nodeDistance/4,n=Math.random()*2*Math.PI;e.x+=t*Math.cos(n),e.y-=t*Math.sin(n)}_InverseSquareForce(e,t,n){let r;if(!this.refineStage)r=e**2/this.options.nodeDistance**2;else{let e=t.x-n.x,i=t.y-n.y,a=t.width/2,o=t.height/2,s=n.width/2,c=n.height/2;r=e**2/(a+s+this.options.nodeDistance)**2+i**2/(o+c+this.options.nodeDistance)**2}return r*4/3}_SquareForce(e,t,n){return 1/this._InverseSquareForce(e,t,n)}_repulsion(e){e.dx=0,e.dy=0,k(this.graph.nodes,function(t){if(t===e)return;for(;e.x===t.x&&e.y===t.y;)this._shake(t);let n=e.x-t.x,r=e.y-t.y,i=Math.sqrt(n*n+r*r),a=this._SquareForce(i,e,t)*2;e.dx+=n/i*a,e.dy+=r/i*a},this)}_attraction(e){let t=e.target,n=e.source;if(n===t)return;for(;n.x===t.x&&n.y===t.y;)this._shake(t);let r=n.x-t.x,i=n.y-t.y,a=Math.sqrt(r*r+i*i),o=this._InverseSquareForce(a,n,t)*5,s=r/a*o,c=i/a*o;t.dx+=s,t.dy+=c,n.dx-=s,n.dy-=c}_expectedBounds(){let e=this.graph.nodes.length,t=1.5;if(e===0)return;let n=ut(this.graph.nodes,function(e,t){let n=t.width*t.height;return n>0?(e+=Math.sqrt(n),e):0},0,this)/e*Math.ceil(Math.sqrt(e)),r=n*Math.sqrt(t),i=n/Math.sqrt(t);return{width:r*4,height:i*4}}},mf=class{constructor(e){this.nodeMap=new M,this.shapeMap=new M,this.nodes=[],this.edges=[],this.edgeMap=new M,this.finalNodes=[],this.finalLinks=[],this.ignoredConnections=[],this.ignoredShapes=[],this.hyperMap=new M,this.hyperTree=new J,this.finalGraph=null,this.diagram=e}convert(e){if(D(this.diagram))throw Error(`No diagram to convert.`);return this.options=q({ignoreInvisible:!0,ignoreContainers:!0,layoutContainerChildren:!1},e||{}),this.clear(),this._renormalizeShapes(),this._renormalizeConnections(),this.finalNodes=new M(this.nodes),this.finalLinks=new M(this.edges),this.finalGraph=new J,this.finalNodes.forEach(function(e){this.finalGraph.addNode(e)},this),this.finalLinks.forEach(function(e){this.finalGraph.addExistingLink(e)},this),this.finalGraph}mapConnection(e){return this.edgeMap.get(e.id)}mapShape(e){return this.nodeMap.get(e.id)}getEdge(e,t){return ft(e.links,function(n){return n.getComplement(e)===t})}clear(){this.finalGraph=null,this.hyperTree=!this.options.ignoreContainers&&this.options.layoutContainerChildren?new J:null,this.hyperMap=!this.options.ignoreContainers&&this.options.layoutContainerChildren?new M:null,this.nodeMap=new M,this.shapeMap=new M,this.nodes=[],this.edges=[],this.edgeMap=new M,this.ignoredConnections=[],this.ignoredShapes=[],this.finalNodes=[],this.finalLinks=[]}listToRoot(e){let t=[],n=e.container;if(!n)return t;for(t.push(n);n.parentContainer;)n=n.parentContainer,t.push(n);return t.reverse(),t}firstNonIgnorableContainer(e){return e.isContainer&&!this.isIgnorableItem(e)?e:e.parentContainer?this.firstNonIgnorableContainer(e.parentContainer):null}isContainerConnection(e,t){return e.isContainer&&this.isDescendantOf(e,t)?!0:t.isContainer&&this.isDescendantOf(t,e)}isDescendantOf(e,t){if(!e.isContainer)throw Error(`Expecting a container.`);if(e===t)return!1;if(j(e.children,t))return!0;let n=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];i.isContainer&&this.isDescendantOf(i,t)&&n.push(i)}return n.length>0}isIgnorableItem(e){return this.options.ignoreInvisible?!(e.isCollapsed&&this._isVisible(e)||!e.isCollapsed&&this._isVisible(e)):e.isCollapsed&&!this._isTop(e)}isShapeMapped(e){return e.isCollapsed&&!this._isVisible(e)&&!this._isTop(e)}leastCommonAncestor(e,t){if(!e||!t)throw Error(`Parameter should not be null.`);if(!this.hyperTree)throw Error(`No hypertree available.`);let n=this.listToRoot(e),r=this.listToRoot(t),i=null;if(Je(n)||Je(r))return this.hyperTree.root().data;let a=n[0],o=r[0],s=0;for(;a===o&&(i=n[s],s++,!(s>=n.length||s>=r.length));)a=n[s],o=r[s];return i?this.hyperTree.nodes.filter(function(e){return e.data.container===i}):this.hyperTree.root().data}_isTop(e){return!e.parentContainer}_isVisible(e){return e.visible()?e.parentContainer?this._isVisible(e.parentContainer):e.visible():!1}_isCollapsed(e){return e.isContainer&&e.isCollapsed?!0:e.parentContainer&&this._isCollapsed(e.parentContainer)}_renormalizeShapes(){if(this.options.ignoreContainers)for(let e=0,t=this.diagram.shapes.length;e<t;e++){let t=this.diagram.shapes[e];if(this.options.ignoreInvisible&&!this._isVisible(t)||t.isContainer){this.ignoredShapes.push(t);continue}let n=new df(t.id,t);n.isVirtual=!1,this.nodeMap.add(t.id,n),this.nodes.push(n)}else throw Error(`Containers are not supported yet, but stay tuned.`)}_renormalizeConnections(){if(this.diagram.connections.length!==0)for(let e=0,t=this.diagram.connections.length;e<t;e++){let t=this.diagram.connections[e];if(this.isIgnorableItem(t)){this.ignoredConnections.push(t);continue}let n=t.sourceConnector?t.sourceConnector.shape:null,r=t.targetConnector?t.targetConnector.shape:null;if(!n||!r){this.ignoredConnections.push(t);continue}if(j(this.ignoredShapes,n)&&!this.shapeMap.containsKey(n)){this.ignoredConnections.push(t);continue}if(j(this.ignoredShapes,r)&&!this.shapeMap.containsKey(r)){this.ignoredConnections.push(t);continue}this.shapeMap.containsKey(n)&&(n=this.shapeMap[n]),this.shapeMap.containsKey(r)&&(r=this.shapeMap[r]);let i=this.mapShape(n),a=this.mapShape(r);if(i===a||this.areConnectedAlready(i,a)){this.ignoredConnections.push(t);continue}if(i===null||a===null)throw Error(`A shape was not mapped to a node.`);if(this.options.ignoreContainers){if(i.isVirtual||a.isVirtual){this.ignoredConnections.push(t);continue}let e=new ff(i,a,t.id,t);this.edgeMap.add(t.id,e),this.edges.push(e)}else throw Error(`Containers are not supported yet, but stay tuned.`)}}areConnectedAlready(e,t){return ot(this.edges,function(n){return n.source===e&&n.target===t||n.source===t&&n.target===e})}};function hf(e,t,n,r,i){let a=(t.x-e.x)*(r.y-n.y)-(t.y-e.y)*(r.x-n.x);if(Ve(a))return;let o=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y),s=(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y),c=o/a,l=s/a;if(!(i&&(c<0||c>1||l<0||l>1)))return new G(e.x+c*(t.x-e.x),e.y+c*(t.y-e.y))}let gf={lines(e,t,n,r){return hf(e,t,n,r)},segments(e,t,n,r){return hf(e,t,n,r,!0)},rectWithLine(e,t,n){return gf.segments(t,n,e.topLeft(),e.topRight())||gf.segments(t,n,e.topRight(),e.bottomRight())||gf.segments(t,n,e.bottomLeft(),e.bottomRight())||gf.segments(t,n,e.topLeft(),e.bottomLeft())},rects(e,t,n){let r=t.topLeft(),i=t.topRight(),a=t.bottomLeft(),o=t.bottomRight(),s=t.center();n&&(r=r.rotate(n,s),i=i.rotate(n,s),a=a.rotate(n,s),o=o.rotate(n,s));let c=e.contains(r)||e.contains(i)||e.contains(a)||e.contains(o)||gf.rectWithLine(e,r,i)||gf.rectWithLine(e,r,a)||gf.rectWithLine(e,i,o)||gf.rectWithLine(e,a,o);if(!c){if(r=e.topLeft(),i=e.topRight(),a=e.bottomLeft(),o=e.bottomRight(),n){let e=360-n;r=r.rotate(e,s),i=i.rotate(e,s),a=a.rotate(e,s),o=o.rotate(e,s)}c=t.contains(r)||t.contains(i)||t.contains(a)||t.contains(o)}return c}},_f=(e,t)=>e.map(t);var vf=class e{constructor(e,t,n,r,i,a){this.a=e||0,this.b=t||0,this.c=n||0,this.d=r||0,this.e=i||0,this.f=a||0}fromMatrix(t){let n=new e;return n.a=t.a,n.b=t.b,n.c=t.c,n.d=t.d,n.e=t.e,n.f=t.f,n}},yf=class e{constructor(e,t,n,r,i,a){this.a=e||0,this.b=t||0,this.c=n||0,this.d=r||0,this.e=i||0,this.f=a||0}plus(e){this.a+=e.a,this.b+=e.b,this.c+=e.c,this.d+=e.d,this.e+=e.e,this.f+=e.f}minus(e){this.a-=e.a,this.b-=e.b,this.c-=e.c,this.d-=e.d,this.e-=e.e,this.f-=e.f}times(t){return new e(this.a*t.a+this.c*t.b,this.b*t.a+this.d*t.b,this.a*t.c+this.c*t.d,this.b*t.c+this.d*t.d,this.a*t.e+this.c*t.f+this.e,this.b*t.e+this.d*t.f+this.f)}apply(e){return new G(this.a*e.x+this.c*e.y+this.e,this.b*e.x+this.d*e.y+this.f)}applyRect(e){return K.fromPoints(this.apply(e.topLeft()),this.apply(e.bottomRight()))}toString(){return`matrix(`+this.a+` `+this.b+` `+this.c+` `+this.d+` `+this.e+` `+this.f+`)`}static fromSVGMatrix(t){let n=new e;return n.a=t.a,n.b=t.b,n.c=t.c,n.d=t.d,n.e=t.e,n.f=t.f,n}static fromMatrixVector(t){let n=new e;return n.a=t.a,n.b=t.b,n.c=t.c,n.d=t.d,n.e=t.e,n.f=t.f,n}static fromList(t){if(t.length!==6)throw Error(`The given list should consist of six elements.`);let n=new e;return n.a=t[0],n.b=t[1],n.c=t[2],n.d=t[3],n.e=t[4],n.f=t[5],n}static translation(t,n){let r=new e;return r.a=1,r.b=0,r.c=0,r.d=1,r.e=t,r.f=n,r}static unit(){return new e(1,0,0,1,0,0)}static rotation(t,n,r){let i=new e;return i.a=Math.cos(t*Math.PI/180),i.b=Math.sin(t*Math.PI/180),i.c=-i.b,i.d=i.a,i.e=n-n*i.a+r*i.b||0,i.f=r-r*i.a-n*i.b||0,i}static scaling(t,n){let r=new e;return r.a=t,r.b=0,r.c=0,r.d=n,r.e=0,r.f=0,r}static parse(t){let n,r;return t&&(t=t.trim(),t.slice(0,6).toLowerCase()===`matrix`&&(r=t.slice(7,t.length-1).trim(),n=r.split(`,`),n.length===6||(n=r.split(` `),n.length===6))||(t.slice(0,1)===`(`&&t.slice(t.length-1)===`)`&&(t=t.substr(1,t.length-1)),t.indexOf(`,`)>0&&(n=t.split(`,`),n.length===6))||t.indexOf(` `)>0&&(n=t.split(` `),n.length===6))?e.fromList(_f(n,function(e){return parseFloat(e)})):n}};function bf(e,t){let n,r,i;do n=Math.random()*2-1,r=Math.random()*2-1,i=n*n+r*r;while(!i||i>1);return e+t*n*Math.sqrt(-2*Math.log(i)/i)}var xf=class{constructor(e,t,n){this.point=e,this.left=t,this.right=n}},Sf=class extends Ct{constructor(e){super(),this._hashTable=new kt,this.length=0,T(e)&&(e instanceof kt?e.forEach(function(e){this.add(e)}):e instanceof M&&e.forEach(function(e,t){this.add({key:e,value:t})},this))}contains(e){return this._hashTable.containsKey(e)}add(e){this._hashTable.get(e)||(this._hashTable.add(e,e),this.length++,this.trigger(`changed`))}get(e){return this.contains(e)?this._hashTable.get(e).value:null}hash(e){return this._hashTable._hash(e)}remove(e){this.contains(e)&&(this._hashTable.remove(e),this.length--,this.trigger(`changed`))}forEach(e,t){let n=t?e.bind(t):e;this._hashTable.forEach(function(e){n(e.value)})}toArray(){let e=[];return this.forEach(function(t){e.push(t)}),e}},Cf=class e{constructor(e,t){this.width=e,this.height=t}static Empty(){return new e(0,0)}},wf=class e{constructor(e,t,n){this.x=t||0,this.y=n||0,this.angle=e}toString(){return this.x&&this.y?`rotate(${this.angle},${this.x},${this.y})`:`rotate(${this.angle})`}toMatrix(){return yf.rotation(this.angle,this.x,this.y)}center(){return new G(this.x,this.y)}invert(){return new e(360-this.angle,this.x,this.y)}static create(t){return new e(t.angle,t.x,t.y)}static parse(t){let n=t.slice(1,t.length-1).split(`,`),r=parseFloat(n[0]),i=parseFloat(n[1]),a=parseFloat(n[2]);return new e(r,i,a)}};wf.ZERO=new wf(0);var Tf=class e{constructor(e,t){this.x=e,this.y=t}toMatrix(){return yf.scaling(this.x,this.y)}toString(){return`scale(${this.x},${this.y})`}invert(){return new e(1/this.x,1/this.y)}},Ef=class e{constructor(e,t){this.x=e,this.y=t}toMatrixVector(){return new vf(0,0,0,0,this.x,this.y)}toMatrix(){return yf.translation(this.x,this.y)}toString(){return`translate(${this.x},${this.y})`}plus(e){this.x+=e.x,this.y+=e.y}times(e){this.x*=e,this.y*=e}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){this.Length!==0&&this.times(1/this.length())}invert(){return new e(-this.x,-this.y)}},Df=class e{constructor(e,t,n,r,i,a){this.translate=new Ef(e,t),n!==void 0&&r!==void 0&&(this.scale=new Tf(n,r)),i!==void 0&&(this.rotate=a?new wf(i,a.x,a.y):new wf(i))}toString(){let e=function(e){return e?e.toString():``};return e(this.translate)+e(this.rotate)+e(this.scale)}render(e){e._transform=this,e._renderTransform()}toMatrix(){let e=yf.unit();return this.translate&&(e=e.times(this.translate.toMatrix())),this.rotate&&(e=e.times(this.rotate.toMatrix())),this.scale&&(e=e.times(this.scale.toMatrix())),e}invert(){let t=this.rotate?this.rotate.invert():void 0,n=t?t.toMatrix():yf.unit(),r=this.scale?this.scale.invert():void 0,i=r?r.toMatrix():yf.unit(),a=new G(-this.translate.x,-this.translate.y);a=n.times(i).apply(a);let o=new Ef(a.x,a.y),s=new e;return s.translate=o,s.rotate=t,s.scale=r,s}};function Of(e,t){let n=this.options,r=!1,i,a;for(let o=0;o<t.length;o++)a=t[o],i=e[a],qe(i)&&n[a]!==i&&(n[a]=i,r=!0);return r}var kf=class{constructor(e){this.options=q({},this.options,e),this.id=this.options.id,this._originSize=K.empty(),this._transform=new Df}visible(e){return this.drawingContainer().visible(e)}redraw(e){e&&e.id&&(this.id=e.id)}position(e,t){let n=this.options;if(!E(e))return new G(n.x,n.y);E(t)?(n.x=e,n.y=t):e instanceof G&&(n.x=e.x,n.y=e.y),this._transform.translate=new Ef(n.x,n.y),this._renderTransform()}rotate(e,t){return E(e)&&(this._transform.rotate=new wf(e,t.x,t.y),this._renderTransform()),this._transform.rotate||wf.ZERO}drawingContainer(){return this.drawingElement}_renderTransform(){let e=this._transform.toMatrix();this.drawingContainer().transform(new er(e.a,e.b,e.c,e.d,e.e,e.f))}_hover(){}_diffNumericOptions(e,t){return Of.call(this,e,t)}_measure(e){let t;if(!this._measured||e){let e=this._boundingBox()||new F([0,0],[0,0]),n=e.topLeft();t=new K(n.x,n.y,e.width(),e.height()),this._originSize=t,this._originWidth=t.width,this._originHeight=t.height,this._measured=!0}else t=this._originSize;return t}_boundingBox(){return this.drawingElement.rawBBox()}_initAccessibility(){let e=this.options.accessibility;e&&(this.drawingElement.options.set(`role`,e.role),this.drawingElement.options.set(`ariaRoleDescription`,e.ariaRoleDescription),this.drawingElement.options.set(`ariaLabel`,e.ariaLabel),this.drawingElement.options.set(`id`,this.options.id))}};function Y(e){return{x:e.x||0,y:e.y||0,width:e.width||0,height:e.height||0}}function Af(e){if(e){let t=e;return O(t)&&(t={color:t}),t.color&&=jf(t.color),t}}function jf(e){let t;return t=e===`transparent`?e:new un(e).toHex(),t}function Mf(e,t){let n=t.x-e.x,r=t.y-e.y;return An(Math.atan2(r,n))}function Nf(e,t){return new Ai(new P(e,t))}function Pf(e){if(e)return new F([e.x,e.y],[e.width,e.height])}function Ff(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function If(e,t=0){let n={top:0,right:0,bottom:0,left:0};return typeof e==`number`?n.top=n.right=n.bottom=n.left=e:(n.top=e.top||t,n.right=e.right||t,n.bottom=e.bottom||t,n.left=e.left||t),n}let Lf=(e,t,n)=>{let r=t.length;for(let i=0;i<r;i++){let a=t[(i+r-1)%r],o=t[i],s=t[(i+1)%r],c=Array.isArray(n)?n[i]:n,l={x:a.x-o.x,y:a.y-o.y},u={x:s.x-o.x,y:s.y-o.y},d=Math.hypot(l.x,l.y),f=Math.hypot(u.x,u.y),p=(l.x*u.x+l.y*u.y)/(d*f),m=c/Math.tan(Math.acos(Math.max(-1,Math.min(1,p)))/2),h=Math.min(m,d-.001,f-.001),g={x:o.x+l.x/d*h,y:o.y+l.y/d*h},_={x:o.x+u.x/f*h,y:o.y+u.y/f*h};i===0?e.moveTo(g.x,g.y):e.lineTo(g.x,g.y);let v=l.x*u.y-l.y*u.x<0;e.arcTo([_.x,_.y],c,c,!1,v)}e.close()},Rf=(e,t)=>{let n=t.length;for(let r=0;r<n;r++){let n=t[r];r===0?e.moveTo(n.x,n.y):e.lineTo(n.x,n.y)}e.close()},zf=e=>{let{width:t,height:n}=Y(e),r=e.stroke?.width||0,i=r/2,a=r/2,o=Math.max(i,t-r/2),s=Math.max(a,n-r/2),c=Math.max(0,(o-i)/2),l=Math.max(0,(s-a)/2);return{left:i,top:a,right:o,bottom:s,cx:i+c,cy:a+l,rx:c,ry:l}},Bf=(e,t)=>{e.moveTo(t.cx,t.top).arcTo([t.cx,t.bottom],t.rx,t.ry,!1,!0).arcTo([t.cx,t.top],t.rx,t.ry,!1,!0)},Vf=(e,t,n,r)=>{let i=e.rawBBox();if(!i.size.width||!i.size.height)return;let a=Math.max(0,t-r),o=Math.max(0,n-r),s=a/i.size.width,c=o/i.size.height,l=r/2;e.transform(new Hr(new er(s,0,0,c,-i.origin.x*s+l,-i.origin.y*c+l)))};function Hf(e,t){let n=e.length,r=[];for(let i=0;i<n;i++){let a=e[(i+n-1)%n],o=e[i],s=e[(i+1)%n],c=Array.isArray(t)?t[i]:t,l={x:a.x-o.x,y:a.y-o.y},u={x:s.x-o.x,y:s.y-o.y},d=Math.hypot(l.x,l.y),f=Math.hypot(u.x,u.y),p={x:l.x/d,y:l.y/d},m={x:u.x/f,y:u.y/f},h=Math.acos(Math.max(-1,Math.min(1,p.x*m.x+p.y*m.y))),g=c/Math.sin(h/2)-c,_={x:p.x+m.x,y:p.y+m.y},v=Math.hypot(_.x,_.y);_={x:_.x/v,y:_.y/v};let y={x:-_.x,y:-_.y};r.push({x:o.x+y.x*g,y:o.y+y.y*g})}return r}let Uf={stroke:{color:`gray`,width:1},fill:{color:g}};var Wf=class extends kf{constructor(e){e=q({},Uf,e),super(e),e=this.options,e.fill=Af(e.fill),e.stroke=Af(e.stroke)}fill(e,t){this._fill({color:jf(e),opacity:t})}stroke(e,t,n){this._stroke({color:jf(e),width:t,opacity:n})}redraw(e){if(e){let t=e.stroke,n=e.fill;t&&this._stroke(Af(t)),n&&this._fill(Af(n)),super.redraw(e)}}_hover(e){let t=this.options,n=t.hover;if(n&&n.fill){let r=e?Af(n.fill):t.fill;this._setFill(r)}}_setFill(e){this.drawingElement.fill(e.color,e.opacity)}_evalStrokeOptions(e){let t=this.options;q(t,{stroke:e}),e=t.stroke;let n=null;return e.width>0&&(n={color:e.color,width:e.width,opacity:e.opacity,dashType:e.dashType}),n}_evalFillOptions(e){let t=this.options;return q(t,{fill:e||{}}),t.fill}_stroke(e){let t=this._evalStrokeOptions(e);this.drawingElement.options.set(`stroke`,t)}_fill(e){let t=this._evalFillOptions(e);if(t.gradient){let e=t.gradient,n=e.type===`radial`?Da:Ea;this.drawingElement.fill(new n(e))}else this.drawingElement.fill(t.color,t.opacity)}};let Gf={stroke:{color:g,width:0},fill:{color:`black`}};var Kf=class extends Wf{constructor(e){e=q({},Gf,e),super(e);let t=this.options.anchor||{};this.anchor=new P(t.x,t.y),this.createElement()}createElement(){}_transformToPath(e,t){let n=t.transform();return e&&n&&(e=e.transformCopy(n)),e}redraw(e){e&&(e.position&&(this.options.position=e.position),super.redraw(e))}};let qf={path:`M 0 0 L 10 5 L 0 10 L 3 5 z`,anchor:{x:10,y:5}};var Jf=class extends Kf{constructor(e){e=q({},qf,e),super(e)}createElement(){let e=this.options;this.drawingElement=I.parse(e.path,{fill:e.fill,stroke:e.stroke})}positionMarker(e){let t=this._linePoints(e),n=t.start,r=t.end,i=Ur();if(n&&i.rotate(Mf(n,r),r),r){let e=this.anchor,t=r.clone().translate(-e.x,-e.y);i.translate(t.x,t.y)}this.drawingElement.transform(i)}_linePoints(e){let t=this.options,n=e.segments,r,i,a;if(t.position===`start`){if(a=n[0],a){i=a.anchor(),r=a.controlOut();let e=n[1];!r&&e&&(r=e.anchor())}}else if(a=n[n.length-1],a){i=a.anchor(),r=a.controlIn();let e=n[n.length-2];!r&&e&&(r=e.anchor())}if(i)return{start:this._transformToPath(r,e),end:this._transformToPath(i,e)}}},Yf=class{constructor(e,t){this._translate=(e,t)=>{let n=this._viewBox;return E(e)&&E(t)&&(n.x=e,n.y=t,this.surface.translate({x:e,y:t})),{x:n.x,y:n.y}},this.element=e,this.surface=ds.create(e,t),He(this.surface.translate)&&(this.translate=this._translate),this.drawingElement=new L,this._viewBox=new K(0,0,t.width,t.height),this.size(this._viewBox)}bounds(){let e=this.drawingElement.clippedBBox();return new K(0,0,e.width(),e.height())}size(e){let t=this._viewBox;return E(e)&&(t.width=e.width,t.height=e.height,this.surface.setSize(e)),{width:t.width,height:t.height}}draw(){this.surface.draw(this.drawingElement)}append(e){return this.drawingElement.append(e.drawingContainer()),this}remove(e){this.drawingElement.remove(e.drawingContainer())}insertBefore(){}clear(){this.drawingElement.clear()}destroy(e){this.surface.destroy(),e&&(Ff(this.element),this.element.remove())}};let Xf={_setScale:function(){let e=this.options,t=this._originWidth,n=this._originHeight,r=e.width/t,i=e.height/n;qe(r)||(r=1),qe(i)||(i=1),this._transform.scale=new Tf(r,i)},_setTranslate:function(){let e=this.options,t=e.x||0,n=e.y||0;if(e.compensateOriginOnScale!==!0){this._transform.translate=new Ef(t,n);return}let r=this._transform.scale,i=r?r.x:1,a=r?r.y:1,o=this._originSize?.x||0,s=this._originSize?.y||0;this._transform.translate=new Ef(t-o*(i-1),n-s*(a-1))},_initSize:function(){let e=this.options,t=!1,n=e.autoSize!==!1&&(T(e.width)||T(e.height));n&&(this._measure(!0),this._setScale(),t=!0),(n||T(e.x)||T(e.y))&&(this._setTranslate(),t=!0),t&&this._renderTransform()},_updateSize:function(e){let t=!1,n=!1,r=!1;return this.options.autoSize!==!1&&this._diffNumericOptions(e,[`width`,`height`])&&(t=!0,n=!0,this._measure(!0),this._setScale()),r=this._diffNumericOptions(e,[`x`,`y`]),(n||r)&&(t=!0,this._setTranslate()),t&&this._renderTransform(),t}};var Zf=class extends Wf{constructor(e){super(e),this._useEllipsePath=!1,this._setScale=Xf._setScale.bind(this),this._setTranslate=Xf._setTranslate.bind(this),this._initSize=Xf._initSize.bind(this),this._updateSize=Xf._updateSize.bind(this),this._initCircle(),this._useEllipsePath?this._updateEllipsePosition():this._initSize(),this._initAccessibility()}redraw(e){if(e){let t=this.options;if(this._useEllipsePath){super.redraw.call(this,e),(this._diffNumericOptions(e,[`width`,`height`])||e.stroke)&&this._replaceEllipsePathGeometry(),this._diffNumericOptions(e,[`x`,`y`])&&this._updateEllipsePosition();return}e.center&&(q(t,{center:e.center}),this._center.move(t.center.x,t.center.y)),this._diffNumericOptions(e,[`radius`])&&this._circle.setRadius(t.radius),this._updateSize(e),super.redraw.call(this,e)}}_initCircle(){let e=this.options,t=e.width,n=e.height,r=e.radius;if(E(t)&&E(n)&&t!==n&&!E(e.radius)&&!E(e.center)){this._useEllipsePath=!0,this.drawingElement=new I({stroke:e.stroke,id:e.id}),this._fill(),Bf(this.drawingElement,zf(e));return}let i=e.stroke?.width||0;E(r)||(E(t)||(t=n),E(n)||(n=t),e.radius=r=Math.max(0,Math.min(t,n)-i)/2);let a=r+i/2,o={x:e.center?.x??a,y:e.center?.y??a};this._center=new P(o.x,o.y),this._circle=new Yr(this._center,r),this.drawingElement=new ni(this._circle,{stroke:e.stroke,id:e.id}),this._fill()}_replaceEllipsePathGeometry(){let e=new I;Bf(e,zf(this.options));let t=e,n=this.drawingElement,r=t.segments.slice(0);t.segments.elements([]),n.segments.elements(r)}_updateEllipsePosition(){this.position(this.options.x||0,this.options.y||0)}};let Qf={radius:4,anchor:{x:0,y:0}};var $f=class extends Kf{constructor(e){e=q({},Qf,e),super(e)}createElement(){let e=this.options;this.drawingElement=new ni(new Yr(this.anchor,e.radius),{fill:e.fill,stroke:e.stroke})}positionMarker(e){let t=this.options.position,n=e.segments,r,i;r=t===`start`?n[0]:n[n.length-1],r&&(i=this._transformToPath(r.anchor(),e),this.drawingElement.transform(Ur().translate(i.x,i.y)))}},X=class extends Wf{constructor(e){super(e),this._renderContent=!0,this._initPath(),this._setPosition(),this._initAccessibility()}_setPosition(){let e=this.options,t=e.x,n=e.y;(E(t)||E(n))&&this.position(t||0,n||0)}redraw(e){if(e){if(super.redraw(e),this._diffNumericOptions(e,[`width`,`height`])){let e=this._createGeometryPath();if(e){let t=this.drawingElement;try{this.drawingElement=e,this._drawPath()}finally{this.drawingElement=t}this._replacePathGeometry(e)}else this._drawPath()}this._diffNumericOptions(e,[`x`,`y`])&&this._setPosition()}}_initPath(){let e=this.options;this.drawingElement=new I({stroke:e.stroke,id:e.id}),this._fill(),this._drawPath()}_drawPath(){let{width:e,height:t}=Y(this.options),n=this.drawingElement,r=this.options.stroke?.width||0,i=Math.max(0,e-r),a=Math.max(0,t-r),o=r/2,s=[{x:o,y:o},{x:o+i,y:o},{x:o+i,y:o+a},{x:o,y:o+a}];this.options.cornerRadius>0?Lf(n,s,Math.min(this.options.cornerRadius,i/2,a/2)):Rf(n,s)}_createGeometryPath(){let e=this.drawingElement;return e?.segments&&typeof e.segments.elements==`function`?new I:e?.paths&&typeof e.paths.elements==`function`?new oa:null}_replacePathGeometry(e){let t=e,n=this.drawingElement,r=typeof t.transform==`function`?t.transform():null;if(t.segments&&n.segments){let e=t.segments.slice(0);t.segments.elements([]),n.segments.elements(e),this._replacePathTransform(n,r);return}if(t.paths&&n.paths){let e=t.paths.slice(0);t.paths.elements([]),n.paths.elements(e),this._replacePathTransform(n,r)}}_replacePathTransform(e,t){if(typeof e.transform!=`function`||!t)return;let n=t.matrix();e.transform(new Hr(new er(n.a,n.b,n.c,n.d,n.e,n.f)))}},ep=class extends X{_initPath(){let e=this.options;this.drawingElement=new oa({stroke:e.stroke,id:e.id}),this._fill(),this._drawPath()}};let tp={shapesOffsetRatio:.025};var np=class extends ep{constructor(e){super({...tp,...e}),this._renderContent=!1}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.cornerRadius,i=this.options.stroke.width||0,a=n*this.options.shapesOffsetRatio-r/2,o=t/2,s=n/2,c=[{x:o,y:s-a},{x:0,y:0},{x:t,y:0}];Lf(e,c,[r/3,r,r]);let l=[{x:o,y:s+a},{x:t,y:n},{x:0,y:n}];Lf(e,l,[r/3,r,r]),Vf(e,t,n,i)}},rp=class extends X{_drawPath(){let e=this.drawingElement;Bf(e,zf(this.options))}};let ip={slantRatio:.15};var ap=class extends X{constructor(e){super({...ip,...e})}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.stroke.width||0,{slantRatio:i,cornerRadius:a}=this.options,o=t*i,s=[{x:o,y:0},{x:t,y:0},{x:t-o,y:n},{x:0,y:n}];Lf(e,s,a),Vf(e,t,n,r)}};let op={ellipseRxRatio:.5,ellipseRyRatio:.2};var sp=class extends X{constructor(e){super({...op,...e})}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.stroke.width||0,i=t*this.options.ellipseRxRatio,a=n*this.options.ellipseRyRatio,o=a,s=a;e.moveTo([t,o]).arcTo([0,o],i,s,!1,!0).arcTo([t,o],i,s,!1,!0).lineTo([t,n]).arcTo([0,n],i,s,!1,!0).lineTo([0,o]),Vf(this.drawingElement,t,n,r)}};let cp={ellipseRadiusXRatio:.165,ellipseRadiusYRatio:.5};var lp=class extends ep{constructor(e){super({...cp,...e})}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=t*this.options.ellipseRadiusXRatio,i=r,a=n*this.options.ellipseRadiusYRatio,o=r;e.moveTo(o,0).lineTo(t,0).arc(270,90,i,a,!0).lineTo(o,n).arcTo([o,0],i,a,!1,!0).close()}},up=class extends X{_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.stroke.width||0,i=Hf([{x:0,y:n/2},{x:t/2,y:0},{x:t,y:n/2},{x:t/2,y:n}],this.options.cornerRadius);Lf(e,i,this.options.cornerRadius),Vf(e,t,n,r)}};let dp={arcRadiusXRatio:.17,arcRadiusYRatio:.3};var fp=class extends X{constructor(e){super({...dp,...e})}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.stroke.width||0,{arcRadiusXRatio:i,arcRadiusYRatio:a,cornerRadius:o}=this.options,s=t*i,c=n*a;e.moveTo([0,o]).arcTo([o,0],o,o,!0,!1).lineTo([t-s,0]).arcTo([t-s,n],s,c,!1,!1).lineTo([o,n]).arcTo([0,n-o],o,o,!0,!1).close(),Vf(this.drawingElement,t,n,r)}};let pp={ellipseRatio:.1407};var mp=class extends X{constructor(e){super({...pp,...e})}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=t*this.options.ellipseRatio,i=r,a=r,o=n/2;e.moveTo([t-i,n]).arcTo([t-i,0],a,o,!1,!0).arcTo([t-i,n],a,o,!1,!0).lineTo([i,n]).arcTo([i,0],a,o,!1,!0).lineTo([t-i,0])}};let hp={sideCutRatio:.35,arcRadiusYRatio:.3,arcRadiusXRatio:.08};var gp=class extends X{constructor(e){super({...hp,...e})}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.stroke.width||0,i=n*this.options.arcRadiusYRatio,a=t*this.options.arcRadiusXRatio,o=t-a,s=t*this.options.sideCutRatio;e.moveTo([s,0]).lineTo([o,0]).arcTo([o,n],a,i,!1,!0).lineTo([o,n]).lineTo([s,n]).lineTo([0,n/2]).close(),Vf(this.drawingElement,t,n,r)}};let _p={waveRatio:.37},vp={..._p,docsXRatio:.14,docsYRatio:.2},yp=(e,t,n,r,i,a)=>{let o=r*i;e.moveTo(t[0]+n,t[1]+r).curveTo([t[0]+n,t[1]+r],[t[0]+n*.8333333333333334,t[1]+r-o],[t[0]+n/2,t[1]+r]).curveTo([t[0]+n*.16666666666666666,t[1]+r+o],[t[0],t[1]+r],[t[0],t[1]+r]).lineTo(t[0],t[1]+a).arcTo([t[0]+a,t[1]],a,a,!0,!1).lineTo(t[0]+n-a,t[1]).arcTo([t[0]+n,t[1]+a],a,a,!0,!1).lineTo(t[0]+n,t[1]+r).close()};var bp=class extends X{constructor(e){super({..._p,...e})}_drawPath(){let{width:e,height:t}=Y(this.options),n=this.options.stroke.width||0,{waveRatio:r,cornerRadius:i}=this.options,a=t*r*.5;yp(this.drawingElement,[0,0],e,t-a,r,i),Vf(this.drawingElement,e,t,n)}},xp=class extends bp{constructor(e){super({...vp,...e})}_initPath(){this.drawingElement=new L({id:this.options.id}),this._fill(),this._drawPath()}_fill(e){let t=this._evalFillOptions(e);if(t.gradient){let e=t.gradient,n=e.type===`radial`?Da:Ea;this.drawingElement.children.forEach(t=>{t.fill(new n(e))})}else this.drawingElement.children.forEach(e=>{e.fill(t.color,t.opacity)})}_drawPath(){let{width:e,height:t}=Y(this.options),n=this.options.stroke.width||0,{waveRatio:r,docsXRatio:i,docsYRatio:a,stroke:o,fill:s,cornerRadius:c}=this.options,l=e*i,u=t*a,d=this.drawingElement;d.clear();let f=new oa({stroke:o,fill:s}),p=new oa({stroke:o,fill:s}),m=t*r*.5;yp(f,[l,0],e-l,t-u-m,r,c),yp(p,[0,u],e-l,t-u-m,r,c),d.append(f),d.append(p),Vf(this.drawingElement,e,t,n)}},Sp=class extends X{_drawPath(){let{width:e,height:t}=Y(this.options),n=this.drawingElement,r=this.options.stroke?.width||0,i=r/2,a=Math.max(0,e-r),o=Math.max(0,t-r),s=o/2,c=i+s,l=i+a-s,u=i,d=i+o;n.moveTo(c,u).lineTo(l,u).arcTo([l,d],s,s,!1,!1).lineTo(c,d).arcTo([c,u],s,s,!1,!1).close()}},Cp=class extends X{_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.stroke.width||0,i=this.options.cornerRadius||0,a=Hf([{x:t/2,y:0},{x:t,y:n},{x:0,y:n}],i);Lf(e,a,i),Vf(e,t,n,r)}},wp=class extends kf{constructor(e){e=q({autoSize:!1},e),super(e),this.children=[],this._childrenChange=!1,this._setScale=Xf._setScale.bind(this),this._setTranslate=Xf._setTranslate.bind(this),this._initSize=Xf._initSize.bind(this),this._updateSize=Xf._updateSize.bind(this),this.drawingElement=new L,this._initSize()}append(e){this.drawingElement.append(e.drawingContainer()),this.children.push(e),this._childrenChange=!0}remove(e){this._remove(e)&&(this._childrenChange=!0)}_remove(e){let t=this.children.indexOf(e);if(t>=0)return this.drawingElement.removeAt(t),this.children.splice(t,1),!0}clear(){this.drawingElement.clear(),this.children=[],this._childrenChange=!0}toFront(e){let t;for(let n=0;n<e.length;n++)t=e[n],this._remove(t)&&this.append(t)}toBack(e){this._reorderChildren(e,0)}toIndex(e,t){this._reorderChildren(e,t)}_reorderChildren(e,t){let n=this.drawingElement,r=n.children.slice(0),i=this.children,a=qe(t),o,s,c,l,u;for(o=0;o<e.length;o++)u=e[o],l=u.drawingContainer(),s=i.indexOf(u),s>=0&&(r.splice(s,1),i.splice(s,1),c=a?t:t[o],r.splice(c,0,l),i.splice(c,0,u));n.clear(),n.append(...r)}redraw(e){e&&(this._childrenChange?(this._childrenChange=!1,this._updateSize(e)||this._initSize()):this._updateSize(e),super.redraw(e))}_boundingBox(){let e=this.children,t,n,r;for(let i=0;i<e.length;i++)n=e[i],n.visible()&&n._includeInBBox!==!1&&(r=n.drawingContainer().clippedBBox(null),r&&(t=t?F.union(t,r):r));return t}},Tp=class extends kf{constructor(e){super(e),this._initImage(),this._initAccessibility()}redraw(e){e&&(e.source&&this.drawingElement.src(e.source),this._diffNumericOptions(e,[`width`,`height`,`x`,`y`])&&this.drawingElement.rect(this._rect()),super.redraw(e))}_initImage(){let e=this.options,t=this._rect();this.drawingElement=new ca(e.source,t),this.drawingElement.options.set(`id`,e.id)}_rect(){let e=Y(this.options);return new F(new P(e.x,e.y),new Vr(e.width,e.height))}};let Ep={leftLineOffsetRatio:.13,topLineOffsetRatio:.23};var Dp=class extends ep{constructor(e){super({...Ep,...e})}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),{leftLineOffsetRatio:r,topLineOffsetRatio:i}=this.options,a=t*r,o=n*i;Lf(e,[{x:0,y:0},{x:t,y:0},{x:t,y:n},{x:0,y:n}],this.options.cornerRadius),e.moveTo(a,0).lineTo(a,n).moveTo(0,o).lineTo(t,o)}},Op=class extends wp{constructor(e,t){super(t),this.drawingElement=new ga(Pf(e),t),this._initSize()}rect(e){if(e)this.drawingElement.rect(Pf(e));else{let e=this.drawingElement.rect();if(e)return new K(e.origin.x,e.origin.y,e.size.width,e.size.height)}}reflow(){this.drawingElement.reflow()}redraw(e){q(this.drawingElement.options,e),super.redraw.call(this,e)}};let Z={_getPath:function(e){let t=this.drawingElement;if(t instanceof oa&&(t=e===`start`?t.paths[0]:t.paths[t.paths.length-1]),t&&t.segments.length)return t},_normalizeMarkerOptions:function(e){let t=e.startCap,n=e.endCap;O(t)&&(e.startCap={type:t}),O(n)&&(e.endCap={type:n})},_removeMarker:function(e){let t=this._markers[e];t&&(this.drawingContainer().remove(t.drawingElement),delete this._markers[e])},_createMarkers:function(){let e=this.options;this._normalizeMarkerOptions(e),this._markers={},this._markers[_]=this._createMarker(e.startCap,_),this._markers.end=this._createMarker(e.endCap,`end`)},_createMarker:function(e,t){let n=(e||{}).type,r=this._getPath(t),i,a;if(!r){this._removeMarker(t);return}if(n===S.FilledCircle?i=$f:n===S.ArrowStart||n===S.ArrowEnd?i=Jf:this._removeMarker(t),i)return a=new i(q({},e,{position:t})),a.positionMarker(r),this.drawingContainer().append(a.drawingElement),a},_positionMarker:function(e){let t=this._markers[e];if(t){let n=this._getPath(e);n?t.positionMarker(n):this._removeMarker(e)}},_capMap:{start:`startCap`,end:`endCap`},_redrawMarker:function(e,t,n){this._normalizeMarkerOptions(n);let r=this.options,i=this._capMap[t],a=(r[i]||{}).type,o=n[i],s=!1;return o?(r[i]=q({},r[i],o),o.type&&a!==o.type?(this._removeMarker(t),this._markers[t]=this._createMarker(r[i],t),s=!0):this._markers[t]&&this._markers[t].redraw(o)):e&&!this._markers[t]&&r[i]&&(this._markers[t]=this._createMarker(r[i],t),s=!0),s},_redrawMarkers:function(e,t){!this._redrawMarker(e,`start`,t)&&e&&this._positionMarker(_),!this._redrawMarker(e,`end`,t)&&e&&this._positionMarker(`end`)}};var kp=class extends Wf{constructor(e){super(e),this._capMap=Z._capMap,this.container=new L,this._getPath=Z._getPath.bind(this),this._normalizeMarkerOptions=Z._normalizeMarkerOptions.bind(this),this._removeMarker=Z._removeMarker.bind(this),this._createMarkers=Z._createMarkers.bind(this),this._createMarker=Z._createMarker.bind(this),this._positionMarker=Z._positionMarker.bind(this),this._redrawMarker=Z._redrawMarker.bind(this),this._redrawMarkers=Z._redrawMarkers.bind(this),this._initPath(),this._createMarkers(),this._initAccessibility()}drawingContainer(){return this.container}redraw(e){if(e){e||={};let t=e.from,n=e.to;t&&(this.options.from=t),n&&(this.options.to=n),t||n?(this._drawPath(),this._redrawMarkers(!0,e)):this._redrawMarkers(!1,e),super.redraw(e)}}_initPath(){let e=this.options,t=this.drawingElement=new I({stroke:e.stroke});this._fill(),this._drawPath(),this.container.append(t)}_drawPath(){let e=this.options,t=this.drawingElement,n=e.from||new G,r=e.to||new G;t.segments.elements([Nf(n.x,n.y),Nf(r.x,r.y)])}};let Ap={topSlantRatio:.2};var jp=class extends X{constructor(e){super({...Ap,...e})}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.stroke.width||0,{topSlantRatio:i,cornerRadius:a}=this.options,o=[{x:0,y:n*i},{x:t,y:0},{x:t,y:n},{x:0,y:n}];Lf(e,o,a),Vf(e,t,n,r)}};let Mp={baseShrinkRatio:.5};var Np=class extends X{constructor(e){super({...Mp,...e})}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.stroke.width||0,i=t*this.options.baseShrinkRatio,a=[{x:0,y:0},{x:t,y:0},{x:t-i/2,y:n},{x:i/2,y:n}];Lf(e,a,this.options.cornerRadius),Vf(e,t,n,r)}},Pp=class extends X{_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.stroke.width||0,i=Hf([{x:0,y:0},{x:t,y:0},{x:t/2,y:n}],this.options.cornerRadius);Lf(e,i,this.options.cornerRadius),Vf(e,t,n,r)}},Fp=class extends ep{constructor(){super(...arguments),this._renderContent=!1}_drawPath(){let e=this.drawingElement,t=zf(this.options);Bf(e,t),e.moveTo(t.left,t.cy).lineTo(t.right,t.cy).moveTo(t.cx,t.top).lineTo(t.cx,t.bottom)}};let Ip={ellipseRxRatio:.5,ellipseRyRatio:.13,bottomEdgeYRatio:.76};var Lp=class extends X{constructor(e){super({...Ip,...e})}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.stroke.width||0,i=t*this.options.ellipseRxRatio,a=n*this.options.ellipseRyRatio,o=a,s=o,c=o,l=n*this.options.bottomEdgeYRatio,u=t/2,d=n;e.moveTo([0,o]).arcTo([t,c],i,a,!1,!1).lineTo([t,l]).lineTo([u,d]).lineTo([0,l]).lineTo([0,s]).close(),Vf(this.drawingElement,t,n,r)}},Rp=class extends Wf{constructor(e){e=q({autoSize:!0},e),super(e),this._capMap=Z._capMap,this.container=new L,this._setScale=Xf._setScale.bind(this),this._setTranslate=Xf._setTranslate.bind(this),this._initSize=Xf._initSize.bind(this),this._updateSize=Xf._updateSize.bind(this),this._getPath=Z._getPath.bind(this),this._normalizeMarkerOptions=Z._normalizeMarkerOptions.bind(this),this._removeMarker=Z._removeMarker.bind(this),this._createMarkers=Z._createMarkers.bind(this),this._createMarker=Z._createMarker.bind(this),this._positionMarker=Z._positionMarker.bind(this),this._redrawMarker=Z._redrawMarker.bind(this),this._redrawMarkers=Z._redrawMarkers.bind(this),this._createElements(),this._initSize()}drawingContainer(){return this.container}data(e){let t=this.options;if(e)t.data!==e&&(t.data=e,this._setData(e),this._initSize(),this._redrawMarkers(!0,{}));else return t.data}redraw(e){if(e){super.redraw(e);let t=this.options,n=e.data;E(n)&&t.data!==n?(t.data=n,this._setData(n),this._updateSize(e)||this._initSize(),this._redrawMarkers(!0,e)):(this._updateSize(e),this._redrawMarkers(!1,e))}}_createElements(){let e=this.options;this.drawingElement=I.parse(e.data||``,{stroke:e.stroke}),this._fill(),this.container.append(this.drawingElement),this._createMarkers()}_setData(e){let t=this.drawingElement,n=I.parse(e||``),r=n.paths.slice(0);n.paths.elements([]),t.paths.elements(r)}},zp=class extends Wf{constructor(e){e=q({points:[]},e),super(e),this._capMap=Z._capMap,this.container=new L,this._getPath=Z._getPath.bind(this),this._normalizeMarkerOptions=Z._normalizeMarkerOptions.bind(this),this._removeMarker=Z._removeMarker.bind(this),this._createMarkers=Z._createMarkers.bind(this),this._createMarker=Z._createMarker.bind(this),this._positionMarker=Z._positionMarker.bind(this),this._redrawMarker=Z._redrawMarker.bind(this),this._redrawMarkers=Z._redrawMarkers.bind(this),this._initPath(),this._createMarkers(),this._initAccessibility()}drawingContainer(){return this.container}points(e){let t=this.options;if(e)t.points=e,this._updatePath();else return t.points}redraw(e){if(e){let t=e.points;super.redraw.call(this,e),t&&this._pointsDiffer(t)?(this.points(t),this._redrawMarkers(!0,e)):this._redrawMarkers(!1,e)}}_initPath(){let e=this.options;this.drawingElement=new I({stroke:e.stroke,id:e.id}),this._fill(),this.container.append(this.drawingElement),e.points&&this._updatePath()}_pointsDiffer(e){let t=this.options.points,n=t.length!==e.length;if(!n){for(let r=0;r<e.length;r++)if(t[r].x!==e[r].x||t[r].y!==e[r].y){n=!0;break}}return n}_updatePath(){let e=this.drawingElement,t=this.options,n=t.points;if(t.cornerRadius>0)Up(e,n,t.cornerRadius);else{let t=[],r;for(let e=0;e<n.length;e++)r=n[e],t.push(Nf(r.x,r.y));e.segments.elements(t)}}};let Bp=1e-6;function Vp(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Hp(e,t=Bp){if(e.length===0)return e;let n=[e[0]];for(let r=1;r<e.length;r++)Vp(e[r],n[n.length-1])>t&&n.push(e[r]);return n}function Up(e,t,n){let r=Hp(t);if(r.length<2)return e;if(e.moveTo(r[0].x,r[0].y),r.length===2)return e.lineTo(r[1].x,r[1].y),e;for(let t=1;t<r.length-1;t++){let i=r[t-1],a=r[t],o=r[t+1],s={x:a.x-i.x,y:a.y-i.y},c={x:o.x-a.x,y:o.y-a.y},l=Math.hypot(s.x,s.y),u=Math.hypot(c.x,c.y);if(l<Bp||u<Bp){e.lineTo(a.x,a.y);continue}let d=s.x*c.y-s.y*c.x,f=(s.x*c.x+s.y*c.y)/(l*u);if(Math.abs(d)<Bp&&f>.999)continue;let p=Math.min(n,l/2,u/2);if(p<=Bp){e.lineTo(a.x,a.y);continue}let m={x:s.x/l,y:s.y/l},h={x:c.x/u,y:c.y/u},g={x:a.x-m.x*p,y:a.y-m.y*p},_={x:a.x+h.x*p,y:a.y+h.y*p},v=Math.abs(f)<=.05;if(e.lineTo(g.x,g.y),v){let t=.5522847498307936*p,n={x:g.x+m.x*t,y:g.y+m.y*t},r={x:_.x-h.x*t,y:_.y-h.y*t};e.curveTo(new P(n.x,n.y),new P(r.x,r.y),new P(_.x,_.y))}else e.curveTo(new P(a.x,a.y),new P(a.x,a.y),new P(_.x,_.y))}let i=r[r.length-1];return e.lineTo(i.x,i.y),e}let Wp={sideLineOffsetRatio:.1};var Gp=class extends ep{constructor(e){super({...Wp,...e})}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=t*this.options.sideLineOffsetRatio,i=r,a=t-r;Lf(e,[{x:0,y:0},{x:t,y:0},{x:t,y:n},{x:0,y:n}],this.options.cornerRadius),e.moveTo(i,0).lineTo(i,n).moveTo(a,0).lineTo(a,n)}};let Kp={horizontalInsetRatio:1/6};var qp=class extends X{constructor(e){super({...Kp,...e})}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.stroke.width||0,i=t*this.options.horizontalInsetRatio,a=[{x:i,y:0},{x:t-i,y:0},{x:t,y:n/2},{x:t-i,y:n},{x:i,y:n},{x:0,y:n/2}];Lf(e,a,this.options.cornerRadius),Vf(e,t,n,r)}},Jp=class extends X{},Yp=class{constructor(e,t,n,r){this.x1=e,this.y1=t,this.x2=n,this.y2=r}width(){return this.x2-this.x1}height(){return this.y2-this.y1}pad(e){let t={...e};return this.x1-=t.left,this.x2+=t.right,this.y1-=t.top,this.y2+=t.bottom,this}unpad(e){let t={...e};return t.left=-t.left||0,t.top=-t.top||0,t.right=-t.right||0,t.bottom=-t.bottom||0,this.pad(t)}toRect(){return new F([this.x1,this.y1],[this.width(),this.height()])}};let Xp=(e=``)=>{let t={justifyContent:v,alignContent:v};return e.includes(`left`)&&(t.justifyContent=_),e.includes(`right`)&&(t.justifyContent=`end`),e.includes(`top`)&&(t.alignContent=_),e.includes(`bottom`)&&(t.alignContent=`end`),t};function Zp(e,t){let n=If(t||0,0);return{left:e.width*n.left,top:e.height*n.top,right:e.width*n.right,bottom:e.height*n.bottom}}function Qp(e){let t=e.shapeSize,{padding:n,relativePadding:r}=e,i=If(n===void 0?Q.padding:n,0),a=Zp(t,r===void 0?Q.relativePadding:r);return{left:i.left+a.left,top:i.top+a.top,right:i.right+a.right,bottom:i.bottom+a.bottom}}let $p=e=>(e&&e.color&&(e=q({},e,{fill:{color:e.color}})),e),Q={fontSize:15,fontFamily:`sans-serif`,lineSpacing:0,textWrap:`nowrap`,padding:If(0),relativePadding:If(0),stroke:{width:0},fill:{color:`black`}};var em=class extends Wf{constructor(e){e=q({},Q,e),e=$p(e),super(e),this.textElements=[],this.alignable=!0,this.name=`TextBlock`,this._setScale=Xf._setScale.bind(this),this._setTranslate=Xf._setTranslate.bind(this),this._initSize=Xf._initSize.bind(this),this._updateSize=Xf._updateSize.bind(this),this._font(),this._initText(),this._initSize()}_initText(){let e=this.options;this.textElements.length=0,this.drawingElement=new sa(E(e.text)?e.text:``,new P,{font:e.font}),this.textElements.push(this.drawingElement),this._fill(),this._stroke()}_fill(e){let t=this._evalFillOptions(e);if(t.gradient){let e=t.gradient,n=e.type===`radial`?Da:Ea;this.textElements.forEach(t=>{t.fill(new n(e))})}else this._setFill(t)}_setFill(e){this.textElements.forEach(t=>{t.fill(e.color,e.opacity)})}_stroke(e){let t=this._evalStrokeOptions(e);this.textElements.forEach(e=>e.options.set(`stroke`,t))}_font(){let e=this.options;if(e.fontFamily&&E(e.fontSize)){let t=[];e.fontStyle&&t.push(e.fontStyle),e.fontWeight&&t.push(e.fontWeight),t.push(e.fontSize+(qe(e.fontSize)?`px`:``)),t.push(e.fontFamily),e.font=t.join(` `)}else delete e.font}padding(){return Qp(this.options)}content(e){return this.drawingElement.content(e)}redraw(e){if(e){let t=!1,n=this.options;e=$p(e),super.redraw(e),(e.fontFamily||E(e.fontSize)||e.fontStyle||e.fontWeight)&&(q(n,{fontFamily:e.fontFamily,fontSize:e.fontSize,fontStyle:e.fontStyle,fontWeight:e.fontWeight}),this._font(),this.drawingElement.options.set(`font`,n.font),t=!0),e.text&&(this.content(e.text),t=!0),!this._updateSize(e)&&t&&this._initSize()}}};let tm=/[\r\n\t]/g,nm=/[ ]{2,}/g,rm=e=>(e||``).replace(tm,` `).replace(nm,` `),im=(e,t)=>{let n=0;return(e.children||[]).forEach(e=>{e.type!==`break`&&e.type!==`image`&&(n=Math.max(n,E(e.fontSize)?e.fontSize:t))}),n||t};function am(e){if(e.blocks&&e.blocks.length>0){let t=e.fontSize||Q.fontSize,n;if(e.margin!==void 0)if(typeof e.margin==`number`){let t=If(e.margin,0);n={top:t.top,bottom:t.bottom}}else n={top:e.margin.top===void 0?t:e.margin.top,bottom:e.margin.bottom===void 0?t:e.margin.bottom};return e.blocks.map(e=>{let r;if(n)r={...n};else{let n=im(e,t);r={top:n,bottom:n}}return{...e,margin:r}})}return[]}let om=(e,t)=>{let n=E(e.fontSize)?e.fontSize:t.fontSize||Q.fontSize,r=e.fontFamily||t.fontFamily||Q.fontFamily,i=[],a=e.italic?`italic`:t.fontStyle||Q.fontStyle;a&&i.push(a);let o=e.bold?`bold`:t.fontWeight||Q.fontWeight;return o&&i.push(o),i.push(n+(qe(n)?`px`:``)),i.push(r),i.join(` `)},sm=e=>{let t=e.shapeSize;if(!t){let n=0,r=0,i=am(e),a=0;i.forEach((t,i)=>{let o=t.margin,s=t.fontSize||e.fontSize||Q.fontSize,c=mr(`M`,{font:om({fontSize:s},e),lineHeight:e&&e.lineHeight?String(e.lineHeight):`normal`}).height||s,l=()=>c,u=0,d=0,f=0,p=0;(t.children||[]).forEach(t=>{if(t.type===`break`)u=Math.max(u,d),p+=Math.max(f,l())+(e.lineSpacing||0),d=0,f=0;else if(t.type===`image`){let e=t;d+=e.width||s||16,f=Math.max(f,e.height||s||16)}else{let n=t,r={font:om(n,e),lineHeight:e&&e.lineHeight?String(e.lineHeight):`normal`};[rm(n.text)].forEach((t,n)=>{if(n>0&&(u=Math.max(u,d),p+=Math.max(f,l())+(e.lineSpacing||0),d=0,f=0),t){let e=mr(t,r);d+=e.width,f=Math.max(f,e.height||0)}})}}),u=Math.max(u,d),p+=Math.max(f,l()),n=Math.max(n,u);let m=Math.max(a,o.top);r+=m+p+(i>0&&e.lineSpacing||0),a=o.bottom}),i.length>0&&(r+=a),t={width:n,height:r}}let{padding:n,relativePadding:r}=e,i=Qp({padding:n,relativePadding:r,shapeSize:t}),a=new Yp(0,0,t.width,t.height);return a.unpad(i),a.toRect()};var cm=class extends em{constructor(){super(...arguments),this.alignable=!1,this.name=`RichTextBlock`}content(e){return e!==void 0&&((e.blocks||e.margin!==void 0)&&(this.options={...this.options,...e}),this._initText()),this.options.blocks}redraw(e){if(e){kf.prototype.redraw.call(this,e);let t=!1,n=this.options;(e.fontFamily||E(e.fontSize)||e.fontStyle||e.fontWeight)&&(q(n,{fontFamily:e.fontFamily,fontSize:e.fontSize,fontStyle:e.fontStyle,fontWeight:e.fontWeight}),this._font(),this.drawingElement.options.set(`font`,n.font),t=!0),e.blocks&&(this.content(e),t=!0),!this._updateSize(e)&&t&&this._initSize()}}_initText(){var e,t;this.textElements.length=0,this.alignable=!1;let n=this.drawingElement=this.drawingElement||new L;n.children.length&&n.clear(),n.transform(null);let r=this.options,i=am(r),a=sm(r),o=new ga(a,{orientation:`horizontal`,...Xp(r.align),lineSpacing:r.lineSpacing}),s=this._wrapParagraphs(i,a?a.size.width:void 0),c=0;if(s.forEach((e,t)=>{let n=i[t].margin,a=i[t].fontSize||r.fontSize||Q.fontSize,s=mr(`M`,{font:om({fontSize:a},r),lineHeight:r&&r.lineHeight?String(r.lineHeight):`normal`}),l=s.height||a,u=s.baseline||a*.8,d=()=>l,f=Math.max(c,n.top);if(f>0){let e=new ga(new F([0,0],[1,f])),t=new _a(new F([0,0],[1,f]),{stroke:{width:0,color:`none`},fill:{opacity:0,color:`none`}});e.append(t),o.append(e),o.appendBreak()}e.forEach(e=>{if(e.length===0){let e=d(),t=new _a(new F([0,0],[1,e]),{stroke:{width:0,color:`none`},fill:{opacity:0,color:`none`}}),n=new ga(new F([0,0],[1,e])),r=new L;r.append(t),n.append(r),o.append(n),o.appendBreak();return}let t=new L,n=0,i=u,s=l;if(e.forEach(e=>{i=Math.max(i,e.baseline),s=Math.max(s,e.height)}),e.forEach(e=>{let o=i-e.baseline;if(e.type===`image`){let r=e.run,i=new ca(r.src,new F([n,Math.round(o)],[e.width,e.height]));t.append(i),n+=e.width}else if(e.type===`text`){let i=e.run,s=new sa(e.text,new P(n,o),{font:e.font}),c=i.color||r.color||this.options.fill?.color||`black`;if((i.color||r.color)&&s.fill(c),i.underline){let r=E(i.fontSize)?i.fontSize:a,s=Math.max(1,Math.round(r/15)),l=Math.round(o+e.baseline+s),u=new I({stroke:{color:c,width:s}});u.moveTo(n,l).lineTo(n+e.width,l),t.append(u)}this.textElements.push(s),t.append(s),n+=e.width}}),n>0||s>0){let e=new _a(new F([0,0],[n||1,s||1]),{stroke:{width:0,color:`none`},fill:{opacity:0,color:`none`}});t.append(e);let r=new ga(new F([0,0],[n||1,s||1]));r.append(t),o.append(r),o.appendBreak()}}),c=n.bottom}),i.length>0&&c>0){let e=new ga(new F([0,0],[1,c])),t=new _a(new F([0,0],[1,c]),{stroke:{width:0,color:`none`},fill:{opacity:0,color:`none`}});e.append(t),o.append(e),o.appendBreak()}o.reflow(),n.append(o);let l=(e=o).clippedBBox?.call(e,null)||(t=n).clippedBBox?.call(t,null);(!l||l.size.width<=1&&l.size.height<=0)&&(l=o.clippedBBox()||this.drawingElement.clippedBBox());let u=r.background;u===void 0&&r.bgColor!==void 0&&(u=r.bgColor);let d=u!==void 0,f=r.border!==void 0;if(d||f){let e=l;if(e){this._textOnlyRect=e.clone();let t=r.textPadding===void 0?xe:r.textPadding;t=typeof t==`number`?If(t,0):{...xe,...t};let i=new _a(new F([e.origin.x-t.left,e.origin.y-t.top],[e.size.width+t.left+t.right,e.size.height+t.top+t.bottom]),{stroke:{color:g,...r.border},fill:{color:u}});n.insert(0,i)}}else l&&(this._textOnlyRect=l.clone());r.color||(this._fill(),this._stroke())}_wrapParagraphs(e,t){let n=[],r=(e,t)=>mr(e||``,t);return e.forEach(e=>{let i=t,a=[],o=[],s=0;(e.children||[]).forEach(e=>{if(e.type===`break`)a.push(o),o=[],s=0;else if(e.type===`image`){let t=e,n=t.width||this.options.fontSize||16,r=t.height||this.options.fontSize||16;i!==void 0&&i>0&&s+n>i&&o.length>0&&(a.push(o),o=[],s=0),o.push({type:`image`,run:t,width:n,height:r,baseline:r}),s+=n}else{let t=e,n=om(t,this.options),c={font:n,lineHeight:this.options&&this.options.lineHeight?String(this.options.lineHeight):`normal`};[rm(t.text)].forEach((e,l)=>{if(l>0&&(a.push(o),o=[],s=0),e)if(i===void 0||i<=0){let i=r(e,c);o.push({type:b,text:e,run:t,width:i.width,height:i.height||0,baseline:i.baseline||0,font:n}),s+=i.width}else{let l=e.split(` `),u=``,d=!0;if(l.forEach(e=>{for(;e.length>0&&r(e,c).width>i;){let l=``;for(let t=1;t<=e.length;t++){let n=e.substring(0,t);if(r(n,c).width>i&&t>1)break;l=n}if(!l)break;if(u){let e=r(u,c);o.push({type:b,text:u,run:t,width:e.width,height:e.height||0,baseline:e.baseline||0,font:n}),s+=e.width,u=``}o.length>0&&(a.push(o),o=[],s=0);let f=r(l,c);o.push({type:b,text:l,run:t,width:f.width,height:f.height||0,baseline:f.baseline||0,font:n}),a.push(o),o=[],s=0,e=e.substring(l.length),d=!0}let l=u+(d?``:` `)+e,f=r(l,c).width;if(s+f>i&&(o.length>0||u)){if(u){let e=r(u,c);o.push({type:b,text:u,run:t,width:e.width,height:e.height||0,baseline:e.baseline||0,font:n})}a.push(o),o=[],s=0,u=e,d=!1}else u=l,d=!1}),u){let e=r(u,c);o.push({type:b,text:u,run:t,width:e.width,height:e.height||0,baseline:e.baseline||0,font:n}),s+=e.width}}})}}),(o.length>0||!e.children||e.children.length===0||e.children[e.children.length-1].type===`break`)&&a.push(o),n.push(a)}),n}};let lm=(e,t)=>{let n=E(e.fontSize)?e.fontSize:t.fontSize||Q.fontSize,r=e.fontFamily||t.fontFamily||Q.fontFamily,i=[],a=e.italic?`italic`:t.fontStyle||Q.fontStyle;a&&i.push(a);let o=e.bold?`bold`:t.fontWeight||Q.fontWeight;return o&&i.push(o),i.push(n+(qe(n)?`px`:``)),i.push(r),i.join(` `)};var um=class e extends cm{static measureHeightForWidth(t,n){return new e(t).measureHeightForWidth(n)}measureHeightForWidth(e){let t=If(this.options.padding===void 0?Q.padding:this.options.padding,0),n=If(this.options.relativePadding===void 0?Q.relativePadding:this.options.relativePadding,0),r=Math.max(1,e-t.left-t.right-e*(n.left+n.right)),i=am(this.options),a=this._wrapParagraphs(i,r),o=[],s=this.options.lineSpacing||0,c=0;a.forEach((e,t)=>{let n=i[t],r=n.margin,a=n.fontSize||this.options.fontSize||Q.fontSize,s=mr(`M`,{font:lm({fontSize:a},this.options),lineHeight:this.options&&this.options.lineHeight?String(this.options.lineHeight):`normal`}).height||a,l=Math.max(c,r.top);l>0&&o.push(l),e.forEach(e=>{if(e.length===0){o.push(s);return}let t=s;e.forEach(e=>{t=Math.max(t,e.height)}),o.push(t)}),c=r.bottom}),i.length>0&&c>0&&o.push(c);let l=o.reduce((e,t)=>e+t,0)+Math.max(0,o.length-1)*s,u=t.top+t.bottom,d=n.top+n.bottom,f=Math.max(1e-4,1-d);return(l+u)/f}};let dm={shapesOffsetRatio:.015};var fm=class extends ep{constructor(e){super({...dm,...e}),this._renderContent=!1}_drawPath(){let e=this.drawingElement,{width:t,height:n}=Y(this.options),r=this.options.stroke.width||0,i=this.options.cornerRadius,a=this.options.shapesOffsetRatio*n,o=n/2,s=[{x:t/2,y:0},{x:t,y:o-a},{x:0,y:o-a}];Lf(e,s,[i/3,i,i]);let c=[{x:t/2,y:n},{x:0,y:o+a},{x:t,y:o+a}];Lf(e,c,[i/3,i,i]),Vf(e,t,n,r)}},pm=class extends ep{constructor(){super(...arguments),this._renderContent=!1}_drawPath(){let e=this.drawingElement,t=zf(this.options),n=t.cx-t.rx/Math.SQRT2,r=t.cy-t.ry/Math.SQRT2,i=t.cx+t.rx/Math.SQRT2,a=t.cy+t.ry/Math.SQRT2;Bf(e,t),e.moveTo(n,r).lineTo(i,a).moveTo(i,r).lineTo(n,a)}},mm=class extends ga{measure(){if(!this._rect||this.children.length===0)return new Vr(0,0);this._initMap();let{groups:e,groupsSize:t}=this._initGroups();if(e.length===0)return new Vr(0,0);let{sizeField:n,groupsSizeField:r}=this._fieldMap,i=0;for(let t=0;t<e.length;t++)i=Math.max(i,e[t].size);let a=new Vr;return a[n]=i,a[r]=t,a}rawBBox(){if(!this._rect||this.children.length===0)return new F(this._rect.origin,new Vr);let e=this.measure();return new F(this._rect.origin,e)}bbox(e){if(!this._rect||this.children.length===0){let t=new F(this._rect.origin,new Vr),n=this.currentTransform(e);return n?t.bbox(n.matrix()):t}let t=this.rawBBox(),n=this.currentTransform(e);return n?t.bbox(n.matrix()):t}};let hm={fill:{color:`transparent`},stroke:{color:`transparent`,width:0}};var gm=class extends X{constructor(e){super(q({},hm,e)),this.name=`TextShapeVisual`}};let _m=e=>{let t=e.shapeSize;if(!t){let n=(e.text||``).split(`
`),r=vm(e),i=n.map(e=>mr(e,r));t={width:i.reduce((e,t)=>Math.max(e,t.width),0),height:i.reduce((e,t)=>e+t.height,0)+(n.length-1)*(e.lineSpacing||0)}}let{padding:n,relativePadding:r}=e,i=Qp({padding:n,relativePadding:r,shapeSize:t}),a=new Yp(0,0,t.width,t.height);return a.unpad(i),a.toRect()},vm=e=>{let t={fontSize:E(e.fontSize)?e.fontSize:Q.fontSize,fontFamily:e.fontFamily||Q.fontFamily};return(e.fontWeight||Q.fontWeight)&&(t.fontWeight=e.fontWeight||Q.fontWeight),(e.fontStyle||Q.fontStyle)&&(t.fontStyle=e.fontStyle||Q.fontStyle),t};var ym=class extends em{constructor(){super(...arguments),this.alignable=!1,this.name=`MultiLineTextBlock`}content(e){return e!==void 0&&(this.options.text=e,this._initText()),this.options.text}_initText(){this.textElements.length=0,this.alignable=!1;let e=this.drawingElement=this.drawingElement||new L;e.children.length&&e.clear();let t=this.options,n=_m(t),r=new mm(n,{...Xp(t.align),lineSpacing:t.lineSpacing});this._textLines(n?n.size.width:void 0).forEach(e=>{let n=new sa(e,new P(0,0),{font:t.font});this.textElements.push(n),r.append(n),r.appendBreak()}),r.reflow();let i=t.background!==void 0,a=t.border!==void 0;if(i||a){let n=r.clippedBBox();if(n){this._textOnlyRect=n.clone();let r=t.textPadding===void 0?xe:t.textPadding;r=typeof r==`number`?If(r,0):{...xe,...r};let i=new _a(new F([n.origin.x-r.left,n.origin.y-r.top],[n.size.width+r.left+r.right,n.size.height+r.top+r.bottom]),{stroke:{color:g,...t.border},fill:{color:t.background}});e.insert(0,i)}}e.append(r),t.color?this.textElements.forEach(e=>{e.fill(t.color)}):!i&&!a&&(this._fill(),this._stroke())}_textLines(e){let{text:t=``}=this.options;if(e===void 0)return t.split(`
`);let n=vm(this.options),r=mr,i=[];return t.split(`
`).forEach(t=>{let a=t.split(` `),o=``;a.forEach(t=>{for(;r(t,n).width>e;){let a=``;for(let i=1;i<=t.length;i++){let o=t.substring(0,i);if(r(o,n).width>e)break;a=o}if(!a)break;o&&=(i.push(o),``),i.push(a),t=t.substring(a.length)}let a=o?`${o} ${t}`:t;r(a,n).width>e&&o?(i.push(o),o=t):o=a}),i.push(o||` `)}),i}},bm=class extends lf{constructor(e){if(super(),D(e))throw Error(`Diagram is not specified.`);this.diagram=e}layout(e){this.transferOptions(e);let t=new mf(this.diagram).convert(e);if(t.isEmpty())return;let n=t.getConnectedComponents();if(Je(n))return;for(let t=0;t<n.length;t++){let r=n[t];this.layoutGraph(r,e)}let r=this.gridLayoutComponents(n);return new uf(this.diagram,r)}_initRuntimeProperties(){for(let e=0;e<this.graph.nodes.length;e++){let t=this.graph.nodes[e];t.layer=-1,t.downstreamLinkCount=0,t.upstreamLinkCount=0,t.isVirtual=!1,t.uBaryCenter=0,t.dBaryCenter=0,t.upstreamPriority=0,t.downstreamPriority=0,t.gridPosition=0}}_prepare(e){let t=[],n,r,i,a=new M,o=0,s,c,l;for(k(e.nodes,function(e){e.incoming.length===0&&(a.set(e,0),t.push(e))});t.length>0;)for(c=t.shift(),n=0;n<c.outgoing.length;n++)i=c.outgoing[n],l=i.target,s=a.containsKey(l)?Math.max(a.get(c)+1,a.get(l)):a.get(c)+1,a.set(l,s),s>o&&(o=s),j(t,l)||t.push(l);let u=a.keys();u.sort(function(e,t){let n=a.get(e),r=a.get(t);return it(r-n)});for(let e=0;e<u.length;++e){let t=u[e],n=Number.MAX_VALUE;if(t.outgoing.length!==0){for(r=0;r<t.outgoing.length;++r)i=t.outgoing[r],n=Math.min(n,a.get(i.target));n>1&&a.set(t,n-1)}}this.layers=[];let d;for(n=0;n<o+1;n++)d=[],d.linksTo={},this.layers.push(d);for(a.forEach(function(e,t){e.layer=t,this.layers[t].push(e)},this),r=0;r<this.layers.length;r++)for(d=this.layers[r],n=0;n<d.length;n++)d[n].gridPosition=n}layoutGraph(e,t){if(D(e))throw Error(`No graph given or graph analysis of the diagram failed.`);T(t)&&this.transferOptions(t),this.graph=e,e.setItemIndices();let n=e.makeAcyclic();this._initRuntimeProperties(),this._prepare(e),this._dummify(),this._optimizeCrossings(),this._swapPairs(),this.arrangeNodes(),this._moveThingsAround(),this._dedummify(),k(n,function(e){e.points&&e.points.reverse()})}setMinDist(e,t,n){let r=e.layer,i=e.layerIndex;if(!Number.isInteger(r)||!Number.isInteger(i)||r<0||i<0)throw Error(`Invalid layer or index value.`);this.minDistances[r][i]=n}getMinDist(e,t){let n=0,r=e.layerIndex,i=t.layerIndex,a=e.layer,o=Math.min(r,i),s=Math.max(r,i);for(let e=o;e<s;++e)n+=this.minDistances[a][e];return n}placeLeftToRight(e){let t=new M,n,r;for(let i=0;i<this.layers.length;++i){let a=e[i];if(!a)continue;for(n=0;n<a.length;n++)r=a[n],t.containsKey(r)||this.placeLeft(r,t,i);let o=1/0;for(n=0;n<a.length;n++){r=a[n];let e=this.rightSibling(r);e&&this.nodeLeftClass.get(e)!==i&&(o=Math.min(o,t.get(e)-t.get(r)-this.getMinDist(r,e)))}if(o===1/0){let e=[];for(n=0;n<a.length;n++){r=a[n];let o=[];_t(o,this.upNodes.get(r)),_t(o,this.downNodes.get(r));for(let n=0;n<o.length;n++){let a=o[n];this.nodeLeftClass.get(a)<i&&e.push(t.get(a)-t.get(r))}}e.sort(),o=e.length===0?0:e.length%2==1?e[this.intDiv(e.length,2)]:(e[this.intDiv(e.length,2)-1]+e[this.intDiv(e.length,2)])/2}for(n=0;n<a.length;n++)r=a[n],t.set(r,t.get(r)+o)}return t}placeRightToLeft(e){let t=new M,n,r;for(let i=0;i<this.layers.length;++i){let a=e[i];if(!a)continue;for(n=0;n<a.length;n++)r=a[n],t.containsKey(r)||this.placeRight(r,t,i);let o=-1/0;for(n=0;n<a.length;n++){r=a[n];let e=this.leftSibling(r);e&&this.nodeRightClass.get(e)!==i&&(o=Math.max(o,t.get(e)-t.get(r)+this.getMinDist(e,r)))}if(o===-1/0){let e=[];for(n=0;n<a.length;n++){r=a[n];let o=[];_t(o,this.upNodes.get(r)),_t(o,this.downNodes.get(r));for(let n=0;n<o.length;n++){let a=o[n];this.nodeRightClass.get(a)<i&&e.push(t.get(r)-t.get(a))}}e.sort(),o=e.length===0?0:e.length%2==1?e[this.intDiv(e.length,2)]:(e[this.intDiv(e.length,2)-1]+e[this.intDiv(e.length,2)])/2}for(n=0;n<a.length;n++)r=a[n],t.set(r,t.get(r)+o)}return t}_getLeftWing(){let e={value:null},t=this.computeClasses(e,1);return this.nodeLeftClass=e.value,t}_getRightWing(){let e={value:null},t=this.computeClasses(e,-1);return this.nodeRightClass=e.value,t}computeClasses(e,t){let n=0,r=e.value=new M;for(let e=0;e<this.layers.length;++e){n=e;let i=this.layers[e];for(let e=t===1?0:i.length-1;e>=0&&e<i.length;e+=t){let t=i[e];if(r.containsKey(t))n=r.get(t);else if(r.set(t,n),t.isVirtual){let e=this._nodesInLink(t);for(let t=0;t<e.length;t++){let i=e[t];r.set(i,n)}}}}let i=[];for(let e=0;e<this.layers.length;e++)i.push(null);return r.forEach(function(e,t){i[t]===null&&(i[t]=[]),i[t].push(e)}),i}_isVerticalLayout(){return this.options.subtype.toLowerCase()===`up`||this.options.subtype.toLowerCase()===`down`||this.options.subtype.toLowerCase()===`vertical`}_isHorizontalLayout(){return this.options.subtype.toLowerCase()===`right`||this.options.subtype.toLowerCase()===`left`||this.options.subtype.toLowerCase()===`horizontal`}_isIncreasingLayout(){return this.options.subtype.toLowerCase()===`right`||this.options.subtype.toLowerCase()===`down`}_moveThingsAround(){let e,t,n,r,i,a;for(t=0;t<this.layers.length;++t)r=this.layers[t],r.sort(this._gridPositionComparer.bind(this));for(this.minDistances=[],t=0;t<this.layers.length;++t)for(r=this.layers[t],this.minDistances[t]=[],i=0;i<r.length;++i)n=r[i],n.layerIndex=i,this.minDistances[t][i]=this.options.nodeDistance,i<r.length-1&&(this._isVerticalLayout()?this.minDistances[t][i]+=(n.width+r[i+1].width)/2:this.minDistances[t][i]+=(n.height+r[i+1].height)/2);for(this.downNodes=new M,this.upNodes=new M,k(this.graph.nodes,function(e){this.downNodes.set(e,[]),this.upNodes.set(e,[])},this),k(this.graph.links,function(e){let t=e.source,n=e.target,r=null,i=null;t.layer>n.layer?(r=e.source,i=e.target):(i=e.source,r=e.target),this.downNodes.get(i).push(r),this.upNodes.get(r).push(i)},this),this.downNodes.forEachValue(function(e){e.sort(this._gridPositionComparer)},this),this.upNodes.forEachValue(function(e){e.sort(this._gridPositionComparer)},this),t=0;t<this.layers.length-1;++t)for(r=this.layers[t],a=0;a<r.length-1;a++){let e=r[a];if(!e.isVirtual)continue;let o=this.downNodes.get(e)[0];if(o.isVirtual)for(i=a+1;i<r.length;++i){if(n=r[i],!n.isVirtual)continue;let e=this.downNodes.get(n)[0];if(e.isVirtual&&o.gridPosition>e.gridPosition){let n=o.gridPosition;o.gridPosition=e.gridPosition,e.gridPosition=n;let r=o.layerIndex,i=e.layerIndex;this.layers[t+1][r]=e,this.layers[t+1][i]=o,o.layerIndex=i,e.layerIndex=r}}}let o=this._getLeftWing(),s=this._getRightWing(),c=this.placeLeftToRight(o),l=this.placeRightToLeft(s),u=new M;k(this.graph.nodes,function(e){u.set(e,(c.get(e)+l.get(e))/2)});let d=new M,f=new M;for(t=0;t<this.layers.length;++t){r=this.layers[t];let e=-1;for(i=0;i<r.length;++i)n=r[i],d.set(n,0),f.set(n,!1),n.isVirtual&&(e===-1||e===i-1?e=i:(d.set(r[e],0),u.get(n)-u.get(r[e])===this.getMinDist(r[e],n)?f.set(r[e],!0):f.set(r[e],!1),e=i))}k([1,-1],function(t){let n=t===1?0:this.layers.length-1;for(let r=n;r>=0&&r<this.layers.length;r+=t){let n=this.layers[r],i=this._firstVirtualNode(n),a=null,o=null;if(i!==-1)for(a=n[i],o=[],e=0;e<i;e++)o.push(n[e]);else a=null,o=n;if(o.length>0){for(this._sequencer(u,null,a,t,o),e=0;e<o.length-1;++e)this.setMinDist(o[e],o[e+1],u.get(o[e+1])-u.get(o[e]));a&&this.setMinDist(o[o.length-1],a,u.get(a)-u.get(o[o.length-1]))}for(;a;){let r=this.nextVirtualNode(n,a);if(!r){for(i=a.layerIndex,o=[],e=i+1;e<n.length;e++)o.push(n[e]);if(o.length>0){for(this._sequencer(u,a,null,t,o),e=0;e<o.length-1;++e)this.setMinDist(o[e],o[e+1],u.get(o[e+1])-u.get(o[e]));this.setMinDist(a,o[0],u.get(o[0])-u.get(a))}}else if(d.get(a)===t){i=a.layerIndex;let s=r.layerIndex;for(o=[],e=i+1;e<s;e++)o.push(n[e]);o.length>0&&this._sequencer(u,a,r,t,o),f.set(a,!0)}a=r}this.adjustDirections(r,t,d,f)}},this);let p=this._isIncreasingLayout()?0:this.layers.length-1,m=function(e,t){return t._isIncreasingLayout()?e<t.layers.length:e>=0},h=this._isIncreasingLayout()?1:-1,g=0;function _(e,t){let n=Number.MIN_VALUE;for(let r=0;r<e.length;++r){let i=e[r];n=t._isVerticalLayout()?Math.max(n,i.height):Math.max(n,i.width)}return n}for(e=p;m(e,this);e+=h){r=this.layers[e];let t=_(r,this);for(i=0;i<r.length;++i)n=r[i],this._isVerticalLayout()?(n.x=u.get(n),n.y=g+t/2):(n.x=g+t/2,n.y=u.get(n));g+=this.options.layerSeparation+t}}adjustDirections(e,t,n,r){if(e+t<0||e+t>=this.layers.length)return;let i=null,a=null,o=this.layers[e+t];for(let s=0;s<o.length;++s){let c=o[s];if(c.isVirtual){let s=this.getNeighborOnLayer(c,e);if(s.isVirtual){if(i){let l=r.get(a),u=this.layers[e],d=a.layerIndex,f=s.layerIndex;for(let e=d+1;e<f;++e)u[e].isVirtual&&(l&&=r.get(u[e]));if(l){n.set(i,t);let e=i.layerIndex,r=c.layerIndex;for(let i=e+1;i<r;++i)o[i].isVirtual&&n.set(o[i],t)}}i=c,a=s}}}}getNeighborOnLayer(e,t){let n=this.upNodes.get(e)[0];return n.layer===t||(n=this.downNodes.get(e)[0],n.layer===t)?n:null}_sequencer(e,t,n,r,i){if(i.length===1&&this._sequenceSingle(e,t,n,r,i[0]),i.length>1){let a=i.length,o=this.intDiv(a,2);this._sequencer(e,t,n,r,i.slice(0,o)),this._sequencer(e,t,n,r,i.slice(o)),this.combineSequences(e,t,n,r,i)}}_sequenceSingle(e,t,n,r,i){let a=r===-1?this.downNodes.get(i):this.upNodes.get(i),o=a.length;o!==0&&(o%2==1?e.set(i,e.get(a[this.intDiv(o,2)])):e.set(i,(e.get(a[this.intDiv(o,2)-1])+e.get(a[this.intDiv(o,2)]))/2),t&&e.set(i,Math.max(e.get(i),e.get(t)+this.getMinDist(t,i))),n&&e.set(i,Math.min(e.get(i),e.get(n)-this.getMinDist(i,n))))}combineSequences(e,t,n,r,i){let a=i.length,o=this.intDiv(a,2),s=[],c,l,u,d,f,p;for(c=0;c<o;++c){for(l=0,d=r===-1?this.downNodes.get(i[c]):this.upNodes.get(i[c]),u=0;u<d.length;++u)f=d[u],e.get(f)>=e.get(i[c])?l++:(l--,s.push({k:e.get(f)+this.getMinDist(i[c],i[o-1]),v:2}));s.push({k:e.get(i[c])+this.getMinDist(i[c],i[o-1]),v:l})}t&&s.push({k:e.get(t)+this.getMinDist(t,i[o-1]),v:Number.MAX_VALUE}),s.sort(this._positionDescendingComparer.bind(this));let m=[];for(c=o;c<a;++c){for(l=0,d=r===-1?this.downNodes.get(i[c]):this.upNodes.get(i[c]),u=0;u<d.length;++u)f=d[u],e.get(f)<=e.get(i[c])?l++:(l--,m.push({k:e.get(f)-this.getMinDist(i[c],i[o]),v:2}));m.push({k:e.get(i[c])-this.getMinDist(i[c],i[o]),v:l})}n&&m.push({k:e.get(n)-this.getMinDist(n,i[o]),v:Number.MAX_VALUE}),m.sort(this._positionAscendingComparer.bind(this));let h=0,g=0,_=this.getMinDist(i[o-1],i[o]);for(;e.get(i[o])-e.get(i[o-1])<_;)if(h<g)if(s.length===0){e.set(i[o-1],e.get(i[o])-_);break}else p=s.shift(),h+=p.v,e.set(i[o-1],p.k),e.set(i[o-1],Math.max(e.get(i[o-1]),e.get(i[o])-_));else if(m.length===0){e.set(i[o],e.get(i[o-1])+_);break}else p=m.shift(),g+=p.v,e.set(i[o],p.k),e.set(i[o],Math.min(e.get(i[o]),e.get(i[o-1])+_));for(c=o-2;c>=0;c--)e.set(i[c],Math.min(e.get(i[c]),e.get(i[o-1])-this.getMinDist(i[c],i[o-1])));for(c=o+1;c<a;c++)e.set(i[c],Math.max(e.get(i[c]),e.get(i[o])+this.getMinDist(i[c],i[o])))}placeLeft(e,t,n){let r=-1/0;k(this._getComposite(e),function(e){let i=this.leftSibling(e);i&&this.nodeLeftClass.get(i)===this.nodeLeftClass.get(e)&&(t.containsKey(i)||this.placeLeft(i,t,n),r=Math.max(r,t.get(i)+this.getMinDist(i,e)))},this),r===-1/0&&(r=0),k(this._getComposite(e),function(e){t.set(e,r)})}placeRight(e,t,n){let r=1/0;k(this._getComposite(e),function(e){let i=this.rightSibling(e);i&&this.nodeRightClass.get(i)===this.nodeRightClass.get(e)&&(t.containsKey(i)||this.placeRight(i,t,n),r=Math.min(r,t.get(i)-this.getMinDist(e,i)))},this),r===1/0&&(r=0),k(this._getComposite(e),function(e){t.set(e,r)})}leftSibling(e){let t=this.layers[e.layer],n=e.layerIndex;return n===0?null:t[n-1]}rightSibling(e){let t=this.layers[e.layer],n=e.layerIndex;return n===t.length-1?null:t[n+1]}_getComposite(e){return e.isVirtual?this._nodesInLink(e):[e]}arrangeNodes(){let e,t,n,r,i;for(t=0;t<this.layers.length;t++)for(r=this.layers[t],n=0;n<r.length;n++)i=r[n],i.upstreamPriority=i.upstreamLinkCount,i.downstreamPriority=i.downstreamLinkCount;for(let t=0;t<2;t++){for(e=this.layers.length-1;e>=1;e--)this.layoutLayer(!1,e);for(e=0;e<this.layers.length-1;e++)this.layoutLayer(!0,e)}let a=Number.MAX_VALUE;for(t=0;t<this.layers.length;t++)for(r=this.layers[t],n=0;n<r.length;n++)i=r[n],a=Math.min(a,i.gridPosition);if(a<0)for(t=0;t<this.layers.length;t++)for(r=this.layers[t],n=0;n<r.length;n++)i=r[n],i.gridPosition-=a}layoutLayer(e,t){let n,r;r=e?this.layers[n=t+1]:this.layers[n=t-1];let i=[];for(let e=0;e<r.length;e++)i.push(r[e]);i.sort(function(e,t){let n=(e.upstreamPriority+e.downstreamPriority)/2,r=(t.upstreamPriority+t.downstreamPriority)/2;return Math.abs(n-r)<1e-4?0:n<r?1:-1}),k(i,function(e){let t=e.gridPosition,n=this.calcBaryCenter(e),i=(e.upstreamPriority+e.downstreamPriority)/2;if(!(Math.abs(t-n)<1e-4)&&!(Math.abs(t-n)<.2501))if(t<n)for(;t<n&&this.moveRight(e,r,i);)t=e.gridPosition;else for(;t>n&&this.moveLeft(e,r,i);)t=e.gridPosition},this),n>0&&this.calcDownData(n-1),n<this.layers.length-1&&this.calcUpData(n+1)}moveRight(e,t,n){let r=st(t,e);if(r===t.length-1)return e.gridPosition+=.5,!0;let i=t[r+1],a=(i.upstreamPriority+i.downstreamPriority)/2;return i.gridPosition>e.gridPosition+1?(e.gridPosition+=.5,!0):a>n||Math.abs(a-n)<1e-4?!1:this.moveRight(i,t,n)?(e.gridPosition+=.5,!0):!1}moveLeft(e,t,n){let r=st(t,e);if(r===0)return e.gridPosition-=.5,!0;let i=t[r-1],a=(i.upstreamPriority+i.downstreamPriority)/2;return i.gridPosition<e.gridPosition-1?(e.gridPosition-=.5,!0):a>n||Math.abs(a-n)<1e-4?!1:this.moveLeft(i,t,n)?(e.gridPosition-=.5,!0):!1}mapVirtualNode(e,t){this.nodeToLinkMap.set(e,t),this.linkToNodeMap.containsKey(t)||this.linkToNodeMap.set(t,[]),this.linkToNodeMap.get(t).push(e)}_nodesInLink(e){return this.linkToNodeMap.get(this.nodeToLinkMap.get(e))}_dummify(){this.linkToNodeMap=new M,this.nodeToLinkMap=new M;let e=this.graph.links.slice(0),t=this.layers,n,r,i,a,o,s,c,l,u=function(e,n,r){t[e].linksTo[n]=t[e].linksTo[n]||[],t[e].linksTo[n].push(r)};for(l=0;l<e.length;l++){let d=e[l],f=d.source,p=d.target,m=f.layer,h=p.layer,g=f.gridPosition,_=p.gridPosition,v=(_-g)/Math.abs(h-m),y=f;if(m-h>1){for(c=m-1;c>h;c--){for(i=new df,i.x=f.x,i.y=f.y,i.width=f.width/100,i.height=f.height/100,n=t[c],r=(c-h)*v+g,r>n.length&&(r=n.length),g>=t[m].length-1&&_>=t[h].length-1?r=n.length:g===0&&_===0&&(r=0),i.layer=c,i.uBaryCenter=0,i.dBaryCenter=0,i.upstreamLinkCount=0,i.downstreamLinkCount=0,i.gridPosition=r,i.isVirtual=!0,pt(n,i,r),o=r+1;o<n.length;o++)a=n[o],a.gridPosition+=1;s=new ff(y,i),s.depthOfDumminess=0,u(c-1,c,s),y=i,this.graph._addNode(i),this.graph.addLink(s),i.index=this.graph.nodes.length-1,this.mapVirtualNode(i,d)}u(h-1,h,s),d.changeSource(y),d.depthOfDumminess=m-h-1}else if(m-h<-1){for(c=m+1;c<h;c++){for(i=new df,i.x=f.x,i.y=f.y,i.width=f.width/100,i.height=f.height/100,n=t[c],r=(c-m)*v+g,r>n.length&&(r=n.length),g>=t[m].length-1&&_>=t[h].length-1?r=n.length:g===0&&_===0&&(r=0),i.layer=c,i.uBaryCenter=0,i.dBaryCenter=0,i.upstreamLinkCount=0,i.downstreamLinkCount=0,i.gridPosition=r,i.isVirtual=!0,r=Math.floor(r),pt(n,i,r),o=r+1;o<n.length;o++)a=n[o],a.gridPosition+=1;s=new ff(y,i),s.depthOfDumminess=0,u(c-1,c,s),y=i,this.graph._addNode(i),this.graph.addLink(s),i.index=this.graph.nodes.length-1,this.mapVirtualNode(i,d)}u(h-1,h,d),d.changeSource(y),d.depthOfDumminess=h-m-1}else u(m,h,d)}}_dedummify(){let e=!0;for(;e;){e=!1;for(let t=0;t<this.graph.links.length;t++){let n=this.graph.links[t];if(!n.depthOfDumminess)continue;let r=[];r.unshift({x:n.target.x,y:n.target.y}),r.unshift({x:n.source.x,y:n.source.y});let i=n,a=n.depthOfDumminess;for(let e=0;e<a;e++){let e=i.source.incoming[0];r.unshift({x:e.source.x,y:e.source.y}),i=e}n.changeSource(i.source),n.depthOfDumminess=0,r.length>2?(r.splice(0,1),r.splice(r.length-1),n.points=r):n.points=[],e=!0;break}}}_optimizeCrossings(){let e=-1,t,n=0;for(;e!==0&&!(n++>3);){for(e=0,t=this.layers.length-1;t>=1;t--)e+=this.optimizeLayerCrossings(!1,t);for(t=0;t<this.layers.length-1;t++)e+=this.optimizeLayerCrossings(!0,t)}}calcUpData(e){if(e===0)return;let t=this.layers[e],n,r,i,a=new Sf,o=this.layers[e-1];for(n=0;n<o.length;n++)a.add(o[n]);for(n=0;n<t.length;n++){let e=t[n],o=0,s=0;for(r=0;r<e.incoming.length;r++)i=e.incoming[r],a.contains(i.source)&&(s++,o+=i.source.gridPosition);for(r=0;r<e.outgoing.length;r++)i=e.outgoing[r],a.contains(i.target)&&(s++,o+=i.target.gridPosition);s>0?(e.uBaryCenter=o/s,e.upstreamLinkCount=s):(e.uBaryCenter=n,e.upstreamLinkCount=0)}}calcDownData(e){if(e===this.layers.length-1)return;let t=this.layers[e],n,r,i,a=new Sf,o=this.layers[e+1];for(n=0;n<o.length;n++)a.add(o[n]);for(n=0;n<t.length;n++){let e=t[n],o=0,s=0;for(r=0;r<e.incoming.length;r++)i=e.incoming[r],a.contains(i.source)&&(s++,o+=i.source.gridPosition);for(r=0;r<e.outgoing.length;r++)i=e.outgoing[r],a.contains(i.target)&&(s++,o+=i.target.gridPosition);s>0?(e.dBaryCenter=o/s,e.downstreamLinkCount=s):(e.dBaryCenter=n,e.downstreamLinkCount=0)}}optimizeLayerCrossings(e,t){let n,r;r=e?this.layers[n=t+1]:this.layers[n=t-1];let i=r.slice(0);e?this.calcUpData(n):this.calcDownData(n),r.sort((e,t)=>{let n=this.calcBaryCenter(e),r=this.calcBaryCenter(t);if(Math.abs(n-r)<1e-4)return e.degree()===t.degree()?this.compareByIndex(e,t):e.degree()<t.degree()?1:-1;let i=(r-n)*1e3;return i>0?-1:i<0?1:this.compareByIndex(e,t)});let a,o=0;for(a=0;a<r.length;a++)r[a]!==i[a]&&o++;if(o>0){let e=0;for(a=0;a<r.length;a++){let t=r[a];t.gridPosition=e++}}return o}_swapPairs(){let e=this.options.layeredIterations,t=0;for(;!(t++>e);){let e=t%4<=1,n=t%4==1;for(let t=e?0:this.layers.length-1;e?t<=this.layers.length-1:t>=0;t+=e?1:-1){let r=this.layers[t],i=!1,a=!0,o=0;for(let s=0;s<r.length-1;s++){let c=0,l=0,u=0;if(a?(t!==0&&(c=this.countLinksCrossingBetweenTwoLayers(t-1,t)),t!==this.layers.length-1&&(l=this.countLinksCrossingBetweenTwoLayers(t,t+1)),e?c*=2:l*=2,u=c+l):u=o,u===0)continue;let d=r[s],f=r[s+1],p=d.gridPosition,m=f.gridPosition;r[s]=f,r[s+1]=d,d.gridPosition=m,f.gridPosition=p,c=0,t!==0&&(c=this.countLinksCrossingBetweenTwoLayers(t-1,t)),l=0,t!==this.layers.length-1&&(l=this.countLinksCrossingBetweenTwoLayers(t,t+1)),e?c*=2:l*=2;let h=c+l,g=!1;g=n?h>=u:h>u,g?(d=r[s],f=r[s+1],p=d.gridPosition,m=f.gridPosition,r[s]=f,r[s+1]=d,d.gridPosition=m,f.gridPosition=p,o=u,a=!1):(i=!0,a=!0)}i&&(t!==this.layers.length-1&&this.calcUpData(t+1),t!==0&&this.calcDownData(t-1))}}}countLinksCrossingBetweenTwoLayers(e,t){let n=this.layers[e].linksTo[t],r,i,a,o,s,c,l,u,d=0,f=n.length;for(l=0;l<f;l++)for(r=n[l],u=l+1;u<f;u++){i=n[u],r.target.layer===t?(a=r.source,o=r.target):(a=r.target,o=r.source),i.target.layer===t?(s=i.source,c=i.target):(s=i.target,c=i.source);let e=a.gridPosition,l=o.gridPosition,f=s.gridPosition,p=c.gridPosition;(e-f)*(l-p)<0&&d++}return d}calcBaryCenter(e){let t=e.upstreamLinkCount,n=e.downstreamLinkCount,r=e.uBaryCenter,i=e.dBaryCenter;return t>0&&n>0?(r+i)/2:t>0?r:n>0?i:0}_gridPositionComparer(e,t){return e.gridPosition<t.gridPosition?-1:+(e.gridPosition>t.gridPosition)}_positionAscendingComparer(e,t){return e.k<t.k?-1:+(e.k>t.k)}_positionDescendingComparer(e,t){return e.k<t.k?1:e.k>t.k?-1:0}_firstVirtualNode(e){for(let t=0;t<e.length;t++)if(e[t].isVirtual)return t;return-1}compareByIndex(e,t){let n=e.index,r=t.index;return n<r?1:n>r?-1:0}intDiv(e,t){return(e-e%t)/t}nextVirtualNode(e,t){let n=t.layerIndex;for(let t=n+1;t<e.length;++t)if(e[t].isVirtual)return e[t];return null}},xm=class{constructor(e){this.center=null,this.options=e}layout(e,t){if(this.graph=e,!(!this.graph.nodes||this.graph.nodes.length===0)){if(!j(this.graph.nodes,t))throw Error(`The given root is not in the graph.`);this.center=t,this.graph.cacheRelationships(),this.layoutSwitch()}}layoutLeft(e){this.setChildrenDirection(this.center,`Left`,!1),this.setChildrenLayout(this.center,`Default`,!1);let t=0,n=0,r,i,a;for(i=0;i<e.length;i++){a=e[i],a.TreeDirection=`Left`;let r=this.measure(a,Cf.Empty.bind(this));n=Math.max(n,r.width),t+=r.height+this.options.verticalSeparation}t-=this.options.verticalSeparation;let o=this.center.x-this.options.horizontalSeparation;for(r=this.center.y+(this.center.height-t)/2,i=0;i<e.length;i++){a=e[i];let t=new G(o-a.Size.width,r);this.arrange(a,t),r+=a.Size.height+this.options.verticalSeparation}}layoutRight(e){this.setChildrenDirection(this.center,`Right`,!1),this.setChildrenLayout(this.center,`Default`,!1);let t=0,n=0,r,i,a;for(i=0;i<e.length;i++){a=e[i],a.TreeDirection=`Right`;let r=this.measure(a,Cf.Empty.bind(this));n=Math.max(n,r.width),t+=r.height+this.options.verticalSeparation}t-=this.options.verticalSeparation;let o=this.center.x+this.options.horizontalSeparation+this.center.width;for(r=this.center.y+(this.center.height-t)/2,i=0;i<e.length;i++){a=e[i];let t=new G(o,r);this.arrange(a,t),r+=a.Size.height+this.options.verticalSeparation}}layoutUp(e){this.setChildrenDirection(this.center,`Up`,!1),this.setChildrenLayout(this.center,`Default`,!1);let t=0,n,r,i;for(i=0;i<e.length;i++){r=e[i],r.TreeDirection=`Up`;let n=this.measure(r,Cf.Empty.bind(this));t+=n.width+this.options.horizontalSeparation}t-=this.options.horizontalSeparation;let a=this.center.x+this.center.width/2-t/2;for(i=0;i<e.length;i++){r=e[i],n=this.center.y-this.options.verticalSeparation-r.Size.height;let t=new G(a,n);this.arrange(r,t),a+=r.Size.width+this.options.horizontalSeparation}}layoutDown(e){let t,n;this.setChildrenDirection(this.center,`Down`,!1),this.setChildrenLayout(this.center,`Default`,!1);let r=0;for(n=0;n<e.length;n++){t=e[n],t.treeDirection=`Down`;let i=this.measure(t,Cf.Empty.bind(this));r+=i.width+this.options.horizontalSeparation}r-=this.options.horizontalSeparation;let i=this.center.x+this.center.width/2-r/2,a=this.center.y+this.options.verticalSeparation+this.center.height;for(n=0;n<e.length;n++){t=e[n];let r=new G(i,a);this.arrange(t,r),i+=t.Size.width+this.options.horizontalSeparation}}layoutRadialTree(){this.setChildrenDirection(this.center,`Radial`,!1),this.setChildrenLayout(this.center,`Default`,!1),this.previousRoot=null;let e=this.options.startRadialAngle*ee,t=this.options.endRadialAngle*ee;if(t<=e)throw Error(`Final angle should not be less than the start angle.`);this.maxDepth=0,this.origin=new G(this.center.x,this.center.y),this.calculateAngularWidth(this.center,0),this.maxDepth>0&&this.radialLayout(this.center,this.options.radialFirstLevelSeparation,e,t),this.center.Angle=t-e}tipOverTree(e,t){D(t)&&(t=0),this.setChildrenDirection(this.center,`Down`,!1),this.setChildrenLayout(this.center,`Default`,!1),this.setChildrenLayout(this.center,`Underneath`,!1,t);let n=0,r,i;for(i=0;i<e.length;i++){r=e[i],r.TreeDirection=`Down`;let t=this.measure(r,Cf.Empty.bind(this));n+=t.width+this.options.horizontalSeparation}n-=this.options.horizontalSeparation,n-=e[e.length-1].width,n+=e[e.length-1].associatedShape.bounds().width;let a=this.center.x+this.center.width/2-n/2,o=this.center.y+this.options.verticalSeparation+this.center.height;for(i=0;i<e.length;i++){r=e[i];let t=new G(a,o);this.arrange(r,t),a+=r.Size.width+this.options.horizontalSeparation}}calculateAngularWidth(e,t){t>this.maxDepth&&(this.maxDepth=t);let n=t===0?0:Math.sqrt(2e6)/t,r=0;if(e.children.length>0){for(let n=0,i=e.children.length;n<i;n++){let i=e.children[n];r+=this.calculateAngularWidth(i,t+1)}r=Math.max(n,r)}else r=n;return e.sectorAngle=r,r}sortChildren(e){let t=0,n;if(e.parents.length>1)throw Error(`Node is not part of a tree.`);let r=e.parents[0];if(r){let n=new G(r.x,r.y),i=new G(e.x,e.y);t=this.normalizeAngle(Math.atan2(n.y-i.y,n.x-i.x))}let i=e.children.length;if(i===0)return null;let a=[],o=[];for(n=0;n<i;++n){let r=e.children[n],i=new G(r.x,r.y);o[n]=n,a[n]=this.normalizeAngle(-t+Math.atan2(i.y-i.y,i.x-i.x))}gt(a,o);let s=[],c=e.children;for(n=0;n<i;++n)s.push(c[o[n]]);return s}normalizeAngle(e){for(;e>Math.PI*2;)e-=2*Math.PI;for(;e<0;)e+=Math.PI*2;return e}radialLayout(e,t,n,r){let i=r-n,a=i/2,o=e.sectorAngle,s=0,c=this.sortChildren(e);for(let e=0,r=c.length;e<r;e++){let r=c[e],l=r,u=l.sectorAngle/o;r.children.length>0&&this.radialLayout(r,t+this.options.radialSeparation,n+s*i,n+(s+u)*i),this.setPolarLocation(r,t,n+s*i+u*a),l.angle=u*i,s+=u}}setPolarLocation(e,t,n){e.x=this.origin.x+t*Math.cos(n),e.y=this.origin.y+t*Math.sin(n),e.BoundingRectangle=new K(e.x,e.y,e.width,e.height)}setChildrenDirection(e,t,n){let r=e.treeDirection;this.graph.depthFirstTraversal(e,e=>{e.treeDirection=t}),n||(e.treeDirection=r)}setChildrenLayout(e,t,n,r){D(r)&&(r=0);let i=e.childrenLayout;r>0?(this.graph.assignLevels(e),this.graph.depthFirstTraversal(e,e=>{e.level>=r+1&&(e.childrenLayout=t)})):(this.graph.depthFirstTraversal(e,e=>{e.childrenLayout=t}),n||(e.childrenLayout=i))}measure(e,t){let n=0,r=0,i,a=new Cf(0,0);if(!e)throw Error(`Node is not defined.`);let o=e.associatedShape.bounds(),s=o.width,c=o.height;if(e.parents.length!==1)throw Error(`Node not in a spanning tree.`);let l=e.parents[0];if(e.treeDirection===`Undefined`&&(e.treeDirection=l.treeDirection),Je(e.children))a=new Cf(Math.abs(s)<1e-6?50:s,Math.abs(c)<1e-6?25:c);else if(e.children.length===1){switch(e.treeDirection){case`Radial`:i=this.measure(e.children[0],t),n=s+this.options.radialSeparation*Math.cos(e.AngleToParent)+i.width,r=c+Math.abs(this.options.radialSeparation*Math.sin(e.AngleToParent))+i.height;break;case`Left`:case`Right`:switch(e.childrenLayout){case`TopAlignedWithParent`:break;case`BottomAlignedWithParent`:break;case`Underneath`:i=this.measure(e.children[0],t),n=s+i.width+this.options.underneathHorizontalOffset,r=c+this.options.underneathVerticalTopOffset+i.height;break;case`Default`:i=this.measure(e.children[0],t),n=s+this.options.horizontalSeparation+i.width,r=Math.max(c,i.height);break;default:throw Error(`Unhandled TreeDirection in the Radial layout measuring.`)}break;case`Up`:case`Down`:switch(e.childrenLayout){case`TopAlignedWithParent`:case`BottomAlignedWithParent`:break;case`Underneath`:i=this.measure(e.children[0],t),n=Math.max(s,i.width+this.options.underneathHorizontalOffset),r=c+this.options.underneathVerticalTopOffset+i.height;break;case`Default`:i=this.measure(e.children[0],t),r=c+this.options.verticalSeparation+i.height,n=Math.max(s,i.width);break;default:throw Error(`Unhandled TreeDirection in the Down layout measuring.`)}break;default:throw Error(`Unhandled TreeDirection in the layout measuring.`)}a=new Cf(n,r)}else{let o,l;switch(e.treeDirection){case`Left`:case`Right`:switch(e.childrenLayout){case`TopAlignedWithParent`:case`BottomAlignedWithParent`:break;case`Underneath`:for(n=s,r=c+this.options.underneathVerticalTopOffset,o=0;o<e.children.length;o++)l=e.children[o],i=this.measure(l,t),n=Math.max(n,i.width+this.options.underneathHorizontalOffset),r+=i.height+this.options.underneathVerticalSeparation;r-=this.options.underneathVerticalSeparation;break;case`Default`:for(n=s,r=0,o=0;o<e.children.length;o++)l=e.children[o],i=this.measure(l,t),n=Math.max(n,s+this.options.horizontalSeparation+i.width),r+=i.height+this.options.verticalSeparation;r-=this.options.verticalSeparation;break;default:throw Error(`Unhandled TreeDirection in the Right layout measuring.`)}break;case`Up`:case`Down`:switch(e.childrenLayout){case`TopAlignedWithParent`:case`BottomAlignedWithParent`:break;case`Underneath`:for(n=s,r=c+this.options.underneathVerticalTopOffset,o=0;o<e.children.length;o++)l=e.children[o],i=this.measure(l,t),n=Math.max(n,i.width+this.options.underneathHorizontalOffset),r+=i.height+this.options.underneathVerticalSeparation;r-=this.options.underneathVerticalSeparation;break;case`Default`:for(n=0,r=0,o=0;o<e.children.length;o++)l=e.children[o],i=this.measure(l,t),n+=i.width+this.options.horizontalSeparation,r=Math.max(r,i.height+this.options.verticalSeparation+c);n-=this.options.horizontalSeparation;break;default:throw Error(`Unhandled TreeDirection in the Down layout measuring.`)}break;default:throw Error(`Unhandled TreeDirection in the layout measuring.`)}a=new Cf(n,r)}return e.SectorAngle=Math.sqrt(n*n/4+r*r/4),e.Size=a,a}arrange(e,t){let n=e.associatedShape.bounds(),r,i,a,o,s,c=n.width,l=n.height;if(Je(e.children))e.x=t.x,e.y=t.y,e.BoundingRectangle=new K(t.x,t.y,c,l);else{let n,u,d;switch(e.treeDirection){case`Left`:switch(e.childrenLayout){case`TopAlignedWithParent`:case`BottomAlignedWithParent`:break;case`Underneath`:for(d=t,e.x=d.x,e.y=d.y,e.BoundingRectangle=new K(e.x,e.y,e.width,e.height),u=t.y+l+this.options.underneathVerticalTopOffset,r=0;r<o.children.length;r++)o=o.children[r],n=d.x-o.associatedShape.width-this.options.underneathHorizontalOffset,i=new G(n,u),this.arrange(o,i),u+=o.Size.height+this.options.underneathVerticalSeparation;break;case`Default`:for(d=new G(t.x+e.Size.width-c,t.y+(e.Size.height-l)/2),e.x=d.x,e.y=d.y,e.BoundingRectangle=new K(e.x,e.y,e.width,e.height),n=d.x-this.options.horizontalSeparation,u=t.y,r=0;r<e.children.length;r++)o=e.children[r],i=new G(n-o.Size.width,u),this.arrange(o,i),u+=o.Size.height+this.options.verticalSeparation;break;default:throw Error(`Unsupported TreeDirection`)}break;case`Right`:switch(e.childrenLayout){case`TopAlignedWithParent`:case`BottomAlignedWithParent`:break;case`Underneath`:for(d=t,e.x=d.x,e.y=d.y,e.BoundingRectangle=new K(e.x,e.y,e.width,e.height),n=t.x+c+this.options.underneathHorizontalOffset,u=t.y+l+this.options.underneathVerticalTopOffset,r=0;r<e.children.length;r++)o=e.children[r],i=new G(n,u),this.arrange(o,i),u+=o.Size.height+this.options.underneathVerticalSeparation;break;case`Default`:for(d=new G(t.x,t.y+(e.Size.height-l)/2),e.x=d.x,e.y=d.y,e.BoundingRectangle=new K(e.x,e.y,e.width,e.height),n=t.x+c+this.options.horizontalSeparation,u=t.y,r=0;r<e.children.length;r++)o=e.children[r],i=new G(n,u),this.arrange(o,i),u+=o.Size.height+this.options.verticalSeparation;break;default:throw Error(`Unsupported TreeDirection`)}break;case`Up`:if(d=new G(t.x+(e.Size.width-c)/2,t.y+e.Size.height-l),e.x=d.x,e.y=d.y,e.BoundingRectangle=new K(e.x,e.y,e.width,e.height),Math.abs(d.x-t.x)<1e-6){for(s=0,r=0;r<e.children.length;r++)a=e.children[r],s+=a.Size.width+this.options.horizontalSeparation;s-=this.options.horizontalSeparation,n=t.x+(c-s)/2}else n=t.x;for(r=0;r<e.children.length;r++)o=e.children[r],u=d.y-this.options.verticalSeparation-o.Size.height,i=new G(n,u),this.arrange(o,i),n+=o.Size.width+this.options.horizontalSeparation;break;case`Down`:switch(e.childrenLayout){case`TopAlignedWithParent`:case`BottomAlignedWithParent`:break;case`Underneath`:for(d=t,e.x=d.x,e.y=d.y,e.BoundingRectangle=new K(e.x,e.y,e.width,e.height),n=t.x+this.options.underneathHorizontalOffset,u=t.y+l+this.options.underneathVerticalTopOffset,r=0;r<e.children.length;r++)o=e.children[r],i=new G(n,u),this.arrange(o,i),u+=o.Size.height+this.options.underneathVerticalSeparation;break;case`Default`:if(d=new G(t.x+(e.Size.width-c)/2,t.y),e.x=d.x,e.y=d.y,e.BoundingRectangle=new K(e.x,e.y,e.width,e.height),Math.abs(d.x-t.x)<1e-6){for(s=0,r=0;r<e.children.length;r++)a=e.children[r],s+=a.Size.width+this.options.horizontalSeparation;s-=this.options.horizontalSeparation,n=t.x+(c-s)/2}else n=t.x;for(r=0;r<e.children.length;r++)o=e.children[r],u=d.y+this.options.verticalSeparation+l,i=new G(n,u),this.arrange(o,i),n+=o.Size.width+this.options.horizontalSeparation;break;default:throw Error(`Unsupported TreeDirection`)}break;case`None`:break;default:throw Error(`Unsupported TreeDirection`)}}}layoutSwitch(){if(!this.center||Je(this.center.children))return;let e=this.options.subtype;D(e)&&(e=`Down`);let t,n,r,i,a=this.center.children;switch(e.toLowerCase()){case`radial`:case`radialtree`:this.layoutRadialTree();break;case`mindmaphorizontal`:case`mindmap`:t=this.center.children,this.center.children.length===1?this.layoutRight(t):(i=a.length/2,n=lt(this.center.children,function(e){return st(a,e)<i}),r=lt(this.center.children,function(e){return st(a,e)>=i}),this.layoutLeft(n),this.layoutRight(r));break;case`mindmapvertical`:t=this.center.children,this.center.children.length===1?this.layoutDown(t):(i=a.length/2,n=lt(this.center.children,function(e){return st(a,e)<i}),r=lt(this.center.children,function(e){return st(a,e)>=i}),this.layoutUp(n),this.layoutDown(r));break;case`right`:this.layoutRight(this.center.children);break;case`left`:this.layoutLeft(this.center.children);break;case`up`:case`bottom`:this.layoutUp(this.center.children);break;case`down`:case`top`:this.layoutDown(this.center.children);break;case`tipover`:case`tipovertree`:if(this.options.tipOverTreeStartLevel<0)throw Error(`The tip-over level should be a positive integer.`);this.tipOverTree(this.center.children,this.options.tipOverTreeStartLevel);break;case`undefined`:case`none`:break;default:break}}},Sm=class extends lf{constructor(e){if(super(),D(e))throw Error(`No diagram specified.`);this.diagram=e}layout(e){this.transferOptions(e);let t=new mf(this.diagram);this.graph=t.convert();let n=this.layoutComponents();return new uf(this.diagram,n)}layoutComponents(){if(this.graph.isEmpty())return;let e=this.graph.getConnectedComponents();if(Je(e))return;let t=new xm(this.options),n=[];for(let r=0;r<e.length;r++){let i=e[r],a=this.getTree(i);if(!a)throw Error(`Failed to find a spanning tree for the component.`);let o=a.root,s=a.tree;t.layout(s,o),n.push(s)}return this.gridLayoutComponents(n)}getTree(e){let t=null;if(this.options.roots&&this.options.roots.length>0)for(let n=0,r=e.nodes.length;n<r;n++){let r=e.nodes[n];for(let e=0;e<this.options.roots.length;e++)if(this.options.roots[e]===r.associatedShape){t=r;break}}if(!t&&(t=e.root(),!t))throw Error(`Unable to find a root for the tree.`);return this.getTreeForRoot(e,t)}getTreeForRoot(e,t){let n=e.getSpanningTree(t);return D(n)||n.isEmpty()?null:{tree:n,root:n.root()}}},Cm=class{constructor(e,t){this.diagram=e,this.options=q({},this.options,t),this.visual=new wp,this.diagram._adorners.push(this)}refresh(){}},wm=class{constructor(e,t,n){this.item=e,this._undoSource=t,this._undoTarget=n,this._redoSource=e.source(),this._redoTarget=e.target(),this.title=be}undo(){this.item._updateConnector(this._undoSource,_e),this.item._updateConnector(this._undoTarget,ve),this.item.updateModel()}redo(){this.item._updateConnector(this._redoSource,_e),this.item._updateConnector(this._redoTarget,ve),this.item.updateModel()}};let Tm={Left:{x:-1,y:0},Right:{x:1,y:0},Top:{x:0,y:-1},Bottom:{x:0,y:1}};function Em(e){return e===`Left`||e===`Right`?`H`:`V`}function Dm(e,t,n){return new G(e.x+t.x*n,e.y+t.y*n)}function Om(e,t){return e.x===t.x&&e.y===t.y}function km(e,t){return e.y===t.y?`H`:`V`}function Am(e,t){return t.axis===`x`?new G(t.value,e.y):new G(e.x,t.value)}function jm(e,t,n,r,i,a,o){if(!n||!r)return[];let s=t.x-e.x,c=t.y-e.y,l=n===`Top`||n===`Bottom`,u=r===`Top`||r===`Bottom`,d=i??30;if(l){if(u){if(n===r){let r=a?a.y:e.y,i=o?o.y:t.y,s=n===`Top`?Math.min(r,i)-d:Math.max(r,i)+d;return[new G(e.x,s),new G(t.x,s)]}let i=e.y+c/2;return[new G(e.x,i),new G(t.x,i)]}return[new G(e.x,t.y)]}if(!u){if(n===r){let r=a?a.x:e.x,i=o?o.x:t.x,s=n===`Left`?Math.min(r,i)-d:Math.max(r,i)+d;return[new G(s,e.y),new G(s,t.y)]}let i=e.x+s/2;return[new G(i,e.y),new G(i,t.y)]}return[new G(t.x,e.y)]}function Mm(e,t,n,r){let i=[{mid:new G(t.x,e.y),first:`H`,last:`V`},{mid:new G(e.x,t.y),first:`V`,last:`H`}];if(n){let e=i.filter(e=>e.first===n);e.length&&(i=e)}if(r&&i.length>1){let e=i.filter(e=>e.last===r);e.length&&(i=e)}return i[0].mid}function Nm(e,t,n,r){let i=[e[0].p],a=[],o=e=>e.kind===`connectionStart`?Em(n):e.kind===`lock`&&e.createdByLockIndex!=null?t[e.createdByLockIndex].axis===`y`?`H`:`V`:null,s=e=>e.kind===`connectionEnd`?Em(r):null;for(let n=0;n<e.length-1;n++){let r=e[n],c=e[n+1],l=r.p,u=c.p,d=r.createdByLockIndex,f=d==null?null:t[d],p=c.createdByLockIndex==null?t.length:c.createdByLockIndex,m=(e,t,n)=>{if(Om(e,t))return;let r=km(e,t),i=null;n&&d!=null&&f&&(f.axis===`y`&&r===`H`||f.axis===`x`&&r===`V`)&&(i=d),a.push({a:e,b:t,orientation:r,ownerLockIndex:i,insertIndex:p})},h=i[i.length-1],g=Om(h,l)?l:h;if(g.x===u.x||g.y===u.y)m(g,u,!0),i.push(u);else{let e=Mm(g,u,o(r),s(c));m(g,e,!0),i.push(e),m(e,u,!1),i.push(u)}}let c=[];for(let e of i)(c.length===0||!Om(c[c.length-1],e))&&c.push(e);return{points:c.slice(1,-1),segmentsMeta:a}}function Pm(e){let{source:t,target:n,sourceSide:r,targetSide:i,anchorOffset:a=10,sameSideDistance:o}=e,s=r?Dm(t,Tm[r],a):t,c=i?Dm(n,Tm[i],a):n,l=jm(s,c,r,i,o,t,n),u=[{p:t,kind:`source`,createdByLockIndex:null}];for(let e of l)u.push({p:e,kind:`lock`,createdByLockIndex:null});Om(u[u.length-1].p,n)||u.push({p:n,kind:`target`,createdByLockIndex:null});let{points:d,segmentsMeta:f}=Nm(u,[],r,i);return{points:d,segmentsMeta:f,connectionStart:s,connectionEnd:c}}function Fm(e){let{source:t,target:n,sourceSide:r,targetSide:i,locks:a,anchorOffset:o=10,sameSideDistance:s}=e,c=r?Dm(t,Tm[r],o):t,l=i?Dm(n,Tm[i],o):n,u=[{p:t,kind:`source`,createdByLockIndex:null},{p:c,kind:`connectionStart`,createdByLockIndex:null}];if(a.length===0){let e=zm(c,l,r,i,s,t,n);for(let t of e)u.push({p:t,kind:`lock`,createdByLockIndex:null})}else for(let e=0;e<a.length;e++){let t=u[u.length-1].p,n=Am(t,a[e]);u.push({p:n,kind:`lock`,createdByLockIndex:e})}Om(u[u.length-1].p,l)||u.push({p:l,kind:`connectionEnd`,createdByLockIndex:null}),Om(u[u.length-1].p,n)||u.push({p:n,kind:`target`,createdByLockIndex:null});let{points:d,segmentsMeta:f}=Nm(u,a,r,i);return{points:d,segmentsMeta:f,connectionStart:c,connectionEnd:l}}function Im(e,t=!0){if(!t){let{locks:t,...n}=e;return Pm(n)}return Fm(e)}function Lm(e){return e===0?0:e>0?1:-1}function Rm(e){if(!e||e.length<=2)return e?e.slice():[];let t=[];for(let n of e){let e=t[t.length-1];(!e||e.x!==n.x||e.y!==n.y)&&t.push(new G(n.x,n.y))}if(t.length<=2)return t;let n=[];n.push(t[0]);for(let e=1;e<t.length-1;e++){let r=n[n.length-1],i=t[e],a=t[e+1];r.x===i.x&&i.x===a.x||r.y===i.y&&i.y===a.y||n.push(i)}if(n.push(t[t.length-1]),n.length<=2)return n;let r=[n[0]];for(let e=1;e<n.length;e++)for(r.push(n[e]);r.length>=3;){let e=r[r.length-3],t=r[r.length-2],n=r[r.length-1];if(e.y===t.y&&t.y===n.y){let i=Lm(t.x-e.x),a=Lm(n.x-t.x);if(i!==0&&a!==0&&i!==a){r.splice(r.length-2,1);continue}}if(e.x===t.x&&t.x===n.x){let i=Lm(t.y-e.y),a=Lm(n.y-t.y);if(i!==0&&a!==0&&i!==a){r.splice(r.length-2,1);continue}}break}let i=[];for(let e of r){let t=i[i.length-1];(!t||!Om(t,e))&&i.push(e)}return i.length>=2?i:[n[0],n[n.length-1]]}function zm(e,t,n,r,i=30,a,o){if(!n||!r)return[];let s=Em(n);if(s===Em(r)){if(n===r){let r=a||e,c=o||t;if(s===`H`){let a=n===`Left`?Math.min(r.x,c.x)-i:Math.max(r.x,c.x)+i;return[new G(a,e.y),new G(a,t.y)]}else{let a=n===`Top`?Math.min(r.y,c.y)-i:Math.max(r.y,c.y)+i;return[new G(e.x,a),new G(t.x,a)]}}if(s===`H`){let n=(e.x+t.x)/2;return[new G(n,e.y),new G(n,t.y)]}else{let n=(e.y+t.y)/2;return[new G(e.x,n),new G(t.x,n)]}}return e.x===t.x||e.y===t.y?[]:s===`H`?[new G(t.x,e.y)]:[new G(e.x,t.y)]}function Bm(e,t,n,r={}){let i=r.hysteresis??8,a=t.x-e.x,o=t.y-e.y,s=Math.abs(a),c=Math.abs(o),l=(n.lastSide==null?s>=c?`H`:`V`:n.lastSide===`Left`||n.lastSide===`Right`?c>s+i?`V`:`H`:s>c+i?`H`:`V`)==`H`?a>=0?`Left`:`Right`:o>=0?`Top`:`Bottom`;return n.lastSide=l,l}var Vm=class{constructor(e){this._undoSourceSide=null,this._undoTargetSide=null,this._redoSourceSide=null,this._redoTargetSide=null,this.item=e.item,this._undoLocks=e.undoLocks?e.undoLocks.map(e=>({...e})):[],this._redoLocks=e.redoLocks?e.redoLocks.map(e=>({...e})):[],this._undoPoints=e.undoPoints?e.undoPoints.map(e=>e.clone()):[],this._redoPoints=e.redoPoints?e.redoPoints.map(e=>e.clone()):[],this._undoRoutingMode=e.routingMode,this._undoSourceSide=e.sourceSide,this._undoTargetSide=e.targetSide,this._redoRoutingMode=this.item.routingMode,this._redoSourceSide=this.item.buildOptions?.sourceSide||null,this._redoTargetSide=this.item.buildOptions?.targetSide||null,this.title=`Connection Dragging`}undo(){this.item.locks=this._undoLocks.map(e=>({...e})),this.item.points(this._undoPoints.map(e=>e.clone())),this.item.updateModel(),this.item.type().toLowerCase()===`cascading`?(this.item.routingMode=this._undoRoutingMode,this._applyConnectionLocks({sourceSide:this._undoSourceSide,targetSide:this._undoTargetSide})):this._updateConnection(this._undoPoints)}redo(){this.item.locks=this._redoLocks.map(e=>({...e})),this.item.points(this._redoPoints.map(e=>e.clone())),this.item.updateModel(),this.item.type().toLowerCase()===`cascading`?(this.item.routingMode=this._redoRoutingMode,this._applyConnectionLocks({sourceSide:this._redoSourceSide,targetSide:this._redoTargetSide})):this._updateConnection(this._redoPoints)}_applyConnectionLocks(e={}){this.item._resolveConnectors(),this.item.buildOptions={...this.item.buildOptions,...e,source:this.item.sourcePoint(),target:this.item.targetPoint()};let t=Im({...this.item.buildOptions,locks:this.item.locks});this.item.route=t;let n=Rm([this.item.sourcePoint(),...t.points,this.item.targetPoint()]);this._updateConnection(n.slice(1,-1))}_updateConnection(e){this.item.points(e),this.item.refresh(),this.item.resizeAdorner&&this.item.resizeAdorner.refresh()}};function Hm(e){let t=0;return e.wheelDelta?(t=-e.wheelDelta/40,t=t>0?Math.ceil(t):Math.floor(t)):e.detail&&(t=e.detail),t}function Um(e){return e.options.name.toLowerCase()===`auto`}function Wm(e,t){let n=Se,r,i;for(let a=0;a<t.length;a++)if(i=t[a],!Um(i)){let t=e.distanceTo(i.position());t<n&&(n=t,r=i)}return r}function Gm(e,t){let n=[],r,i,a=e.drawingContainer().children,o=a.length;for(r=0;r<t.length;r++){i=t[r];for(let e=0;e<o;e++)if(a[e]===i.drawingContainer()){n.push(e);break}}return n}function Km(e){let t=e.drawingContainer().clippedBBox(null);(t.origin.x!==0||t.origin.y!==0)&&e.position(-t.origin.x,-t.origin.y)}function qm(e){let t={};return e||={},E(e.text)&&e.text!==null&&(t.text=e.text),E(e.x)&&e.x!==null&&(t.x=e.x),E(e.y)&&e.y!==null&&(t.y=e.y),E(e.width)&&e.width!==null&&(t.width=e.width),E(e.height)&&e.height!==null&&(t.height=e.height),E(e.type)&&e.type!==null&&(t.type=e.type),t}function Jm(e){let t={};return e||={},E(e.text)&&e.text!==null&&(t.content=e.text),E(e.type)&&e.type!==null&&(t.type=e.type),E(e.from)&&e.from!==null&&(t.from=e.from),E(e.fromConnector)&&e.fromConnector!==null&&(t.fromConnector=e.fromConnector),E(e.fromX)&&e.fromX!==null&&(t.fromX=e.fromX),E(e.fromY)&&e.fromY!==null&&(t.fromY=e.fromY),E(e.to)&&e.to!==null&&(t.to=e.to),E(e.toConnector)&&e.toConnector!==null&&(t.toConnector=e.toConnector),E(e.toX)&&e.toX!==null&&(t.toX=e.toX),E(e.toY)&&e.toY!==null&&(t.toY=e.toY),t}var Ym;(function(e){e.Terminator=`Terminator`,e.Process=`Process`,e.Decision=`Decision`,e.PredefinedProcess=`PredefinedProcess`,e.Document=`Document`,e.MultipleDocuments=`MultipleDocuments`,e.ManualInputOutput=`ManualInputOutput`,e.Preparation=`Preparation`,e.ManualOperation=`ManualOperation`,e.InternalStorage=`InternalStorage`,e.Display=`Display`,e.DirectAccessStorage=`DirectAccessStorage`,e.Database=`Database`,e.OnPageConnector=`OnPageConnector`,e.OffPageConnector=`OffPageConnector`,e.DataInputOutput=`DataInputOutput`,e.SummingJunction=`SummingJunction`,e.LogicalOr=`LogicalOr`,e.Merge=`Merge`,e.Extract=`Extract`,e.DataStorage=`DataStorage`,e.Delay=`Delay`,e.Sort=`Sort`,e.Collate=`Collate`})(Ym||={});let Xm=[{name:`top`},{name:`bottom`,position:function(e){let t=e.bounds().height,n=t*e.shapeVisual.options.waveRatio,r=e.getPosition(`top`);return r.y+=t-n*.4,r}},{name:`left`},{name:`right`},{name:`auto`}],Zm=[{name:`top`},{name:`bottom`},{name:`left`,position:function(e){let t=e.getPosition(`left`),n=e.bounds();return t.x+=n.width/4-e.shapeVisual.options.cornerRadius*.6*(n.width/n.height),t}},{name:`right`,position:function(e){let t=e.getPosition(`right`),n=e.bounds();return t.x-=n.width/4-e.shapeVisual.options.cornerRadius*.6*(n.width/n.height),t}},{name:`auto`}],Qm={[Ym.Extract]:Zm,[Ym.Merge]:Zm,[Ym.Document]:Xm,[Ym.MultipleDocuments]:Xm,[Ym.DataInputOutput]:[{name:`top`},{name:`bottom`},{name:`left`,position:function(e){let t=e.getPosition(`left`);return t.x+=e.bounds().width*e.shapeVisual.options.slantRatio/2-e.shapeVisual.options.cornerRadius/5,t}},{name:`right`,position:function(e){let t=e.getPosition(`right`);return t.x-=e.bounds().width*e.shapeVisual.options.slantRatio/2-e.shapeVisual.options.cornerRadius/5,t}},{name:`auto`}],[Ym.ManualOperation]:[{name:`top`},{name:`bottom`},{name:`left`,position:function(e){let t=e.getPosition(`left`);return t.x+=e.bounds().width*e.shapeVisual.options.baseShrinkRatio/(4+e.shapeVisual.options.cornerRadius/10),t}},{name:`right`,position:function(e){let t=e.getPosition(`right`);return t.x-=e.bounds().width*e.shapeVisual.options.baseShrinkRatio/(4+e.shapeVisual.options.cornerRadius/10),t}},{name:`auto`}],[Ym.ManualInputOutput]:[{name:`top`,position:function(e){let t=e.getPosition(`top`);return t.y+=e.bounds().height*e.shapeVisual.options.topSlantRatio/2,t}},{name:`bottom`},{name:`left`},{name:`right`},{name:`auto`}],[Ym.DataStorage]:[{name:`top`},{name:`bottom`},{name:`left`},{name:`right`,position:function(e){let t=e.bounds().width,n=e.getPosition(`right`);return n.x-=t*e.shapeVisual.options.ellipseRadiusXRatio,n}},{name:`auto`}]};var $m=class{constructor(e,t,n){this.shapes=t,this.undoRotates=n,this.title=`Rotation`,this.redoRotates=[],this.redoAngle=e._angle,this.adorner=e,this.center=e._innerBounds.center();for(let e=0;e<this.shapes.length;e++)this.redoRotates.push(this.redoAngle)}undo(){let e,t;for(e=0;e<this.shapes.length;e++)t=this.shapes[e],t.rotate(this.undoRotates[e],this.center,!1),`layout`in t&&t.layout(t),t.updateModel();this.adorner&&(this.adorner._initialize(),this.adorner.refresh())}redo(){let e,t;for(e=0;e<this.shapes.length;e++)t=this.shapes[e],t.rotate(this.redoRotates[e],this.center,!1),`layout`in t&&t.layout(t),t.updateModel();this.adorner&&(this.adorner._initialize(),this.adorner.refresh())}};let eh={width:10,height:10,fill:{color:`Yellow`},hover:{stroke:{width:1}},offset:10};var th=class{constructor(e,t){this.options=q({},eh,t),this.connections=[],this.shape=e}position(){let e;if(e=this.options.position?this.options.position(this.shape):this.shape.getPosition(this.options.name),this.options.offset){let t=this._calculateOffset();e=e.plus(t)}return e}positionWithoutOffset(){return this.options.position?this.options.position(this.shape):this.shape.getPosition(this.options.name)}_calculateOffset(){var e;let t=this.options.offset||0,n=(this.options.name||``).toLowerCase(),r;switch(n){case`top`:r=new G(0,-t);break;case`bottom`:r=new G(0,t);break;case`left`:r=new G(-t,0);break;case`right`:r=new G(t,0);break;default:r=new G(0,0);break}let i=((e=this.shape)?.rotate)?.call(e).angle;return i&&r.rotate(i,new G(0,0)),r}toJSON(){return{shapeId:this.shape.toString(),connector:this.options.name}}static parse(e,t){let n=t.split(`:`),r=n[0],i=n[1]||`Auto`;for(let t=0;t<e.shapes.length;t++){let n=e.shapes[t];if(n.options.id===r)return n.getConnector(i.trim())}}};let nh=[{name:`Top`},{name:ie},{name:re},{name:ne},{name:w,position:function(e){return e.getPosition(`center`)}}],rh=function(e){let t={type:`rectangle`,path:``,autoSize:!0,visual:null,x:0,y:0,minWidth:20,minHeight:20,width:100,height:100,resize:`auto`,cornerRadius:0,tooltip:{visible:!0},hover:{},accessibility:{role:`graphics-symbol`,ariaRoleDescription:Re},editable:{connect:!0,tools:[]},connectors:nh,rotation:{angle:0}};return Ye(t,e),t},ih={compile:function(e,t){return e}};var ah=class{static register(e){ih=e}static compile(e,t={}){return ih.compile(e,t)}};function oh(e={}){let t;return e.visual?e.visual=t=ah.compile(e.visual,e):e.template?e.template=t=ah.compile(e.template,e):He(e.content)&&(t=e.content),t}function sh(){let e=ch(navigator.userAgent),t={};return t.mobileOS=e,t}function ch(e){let t=!1,n={wp:/(Windows Phone(?: OS)?)\s(\d+)\.(\d+(\.\d+)?)/,fire:/(Silk)\/(\d+)\.(\d+(\.\d+)?)/,android:/(Android|Android.*(?:Opera|Firefox).*?\/)\s*(\d+)\.?(\d+(\.\d+)?)?/,iphone:/(iPhone|iPod).*OS\s+(\d+)[._]([\d._]+)/,ipad:/(iPad).*OS\s+(\d+)[._]([\d_]+)/,playbook:/(PlayBook).*?Tablet\s*OS\s*(\d+)\.(\d+(\.\d+)?)/,windows:/(MSIE)\s+(\d+)\.(\d+(\.\d+)?)/,tizen:/(tizen).*?Version\/(\d+)\.(\d+(\.\d+)?)/i,sailfish:/(sailfish).*rv:(\d+)\.(\d+(\.\d+)?).*firefox/i},r={ios:/^i(phone|pad|pod)$/i,android:/^android|fire$/i,windows:/windows/,wp:/wp/,flat:/sailfish|ffos|tizen/i};for(let i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&e.match(n[i])){if(i===`windows`&&`plugins`in navigator)return!1;t={},t.device=i,t.name=lh(i,r),t[t.name]=!0;break}return t}function lh(e,t,n){for(let n in t)if(t[n].test(e))return n;return n===void 0?e:n}let uh=Object.assign,dh=()=>new Date().getTime(),fh=(e,t)=>{e.classList.add(t)},ph=e=>{let t=document.createElement(`div`);return t.innerHTML=e,t.firstChild},mh=(e,t)=>{t.insertBefore(e,t.firstChild)},hh=(e,t)=>{for(e.appendChild(t);e.firstChild!==t;)t.appendChild(e.firstChild)},gh=()=>{let{mobileOS:e}=sh();return e.ios||e.android},_h=e=>{let t=e.wheelDeltaY,n;return e.wheelDelta?(t===void 0||t)&&(n=e.wheelDelta):e.detail&&e.axis===e.VERTICAL_AXIS&&(n=-e.detail*10),n},vh=e=>{if(e.blocks)return cm;let t=e.textWrap;return t===void 0&&(e.text.includes(`
`)||!yh(e,_m(e).size.width))&&(t=y),(e.border||e.position===`inline`)&&(t=y),t===`wrap`?ym:em},yh=(e,t)=>{let n=e.text||``,r=vm(e);return!n.split(`
`).find(e=>mr(e,r).width>t)},bh={hover:{},cursor:C.grip,content:{align:`center middle`},selectable:!0,serializable:!0,enable:!0};var xh=class extends Ct{constructor(e){super(),this.dataItem=(e||{}).dataItem,this.options=q({id:Ot()},bh,e),this.isSelected=!1,this.visual=new wp({id:this.options.id,autoSize:this.options.autoSize,compensateOriginOnScale:!0}),this.id=this.options.id,this._template()}_getCursor(e){return this.adorner?this.adorner._getCursor(e):this.options.cursor}visible(e){if(D(e))return this.visual.visible();this.visual.visible(e)}bounds(e){return null}refresh(){this.visual.redraw()}position(e){this.options.x=e.x,this.options.y=e.y,this.visual.position(e)}toString(){return this.options.id}serialize(){let e=q({},{options:this.options});return this.dataItem&&(e.dataItem=this.dataItem.toString()),e}_content(e){if(e!==void 0){let t=this.options;if(O(e))t.content.text=e;else if(e.blocks){t.content.blocks=e.blocks;let{blocks:n,...r}=e;q(t.content,r)}else q(t.content,e);let n=t.content,r=this._contentVisual;if(r&&vh(n).name!==r.name){let e=r.drawingContainer();e.parent.remove(e),this._contentVisual=r=null}r?this._updateContentVisual(n):this._createContentVisual(n)}return this.options.content.blocks||this.options.content.text}_createContentVisual(e){if(e.text||e.blocks){e.shapeSize=this.bounds();let t=vh(e);this._contentVisual=new t(e),this._contentVisual._includeInBBox=!1,this.visual.append(this._contentVisual),this.shapeVisual?._renderContent===!1&&this._contentVisual.visible(!1)}}_updateContentVisual(e){this._contentVisual.redraw(e)}_hitTest(e){let t=this.bounds();return this.visible()&&t.contains(e)&&this.options.enable}_template(){if(this.options.content.template){let e=this.dataItem||{},t=oh(uh({},this.options.content,{dataItem:this.dataItem||this.options.dataItem}));He(t)?this.options.content.text=t(e):O(t)&&(this.options.content.text=t)}}_canSelect(){return this.options.selectable!==!1}toJSON(){return{id:this.options.id}}};let Sh={Terminator:Sp,Process:Jp,Decision:up,PredefinedProcess:Gp,Document:bp,MultipleDocuments:xp,ManualInputOutput:jp,Preparation:qp,ManualOperation:Np,InternalStorage:Dp,Display:gp,DirectAccessStorage:mp,Database:sp,OnPageConnector:rp,OffPageConnector:Lp,DataInputOutput:ap,SummingJunction:pm,LogicalOr:Fp,Merge:Pp,Extract:Cp,DataStorage:lp,Delay:fp,Sort:fm,Collate:np};function Ch(e){return e===void 0?`auto`:e}function wh(e){return e===`auto`||e===void 0?{preserveAspectRatio:!1,scaleContent:!1}:{preserveAspectRatio:!1,scaleContent:!1,...e}}function Th(e,t,n){let r=e.options.align;e.options.align!==n&&(e.options.align=n,typeof e._initText==`function`&&e._initText());let i=t.topLeft();e.position(i);let a=e.drawingElement.bbox(null);if(!a)return e.options.align=r,null;e.options.align=n;let o=typeof e.padding==`function`?e.padding():{left:0,top:0,right:0,bottom:0},s=a.width()>t.width-(o.left+o.right),c=a.height()>t.height-(o.top+o.bottom);if(s||c){let r=Eh(n,s,c);e.options.align!==r&&(e.options.align=r,typeof e._initText==`function`&&e._initText(),e.position(i),a=e.drawingElement.bbox(null)||a,s=a.width()>t.width-(o.left+o.right),c=a.height()>t.height-(o.top+o.bottom));let l=0,u=0;s&&(l=t.x-a.origin.x+o.left),c&&(u=t.y-a.origin.y+o.top),(l!==0||u!==0)&&(e.position(i.x+l,i.y+u),a=e.drawingElement.bbox(null)||a)}return e.options.align=r,a}function Eh(e,t,n){let r=(e||`center middle`).toLowerCase().split(/\s+/),i=`center`,a=`middle`;return r.forEach(e=>{(e===`left`||e===`center`||e===`right`)&&(i=e),(e===`top`||e===`middle`||e===`bottom`)&&(a=e)}),t&&(i=`left`),n&&(a=`top`),`${a} ${i}`}function Dh(e,t){if(e&&typeof e.clip==`function`){e.clip(t);return}e&&e.options&&typeof e.options.set==`function`&&e.options.set(`clip`,t)}function Oh(e,t,n){let r=t.x+n.left,i=t.y+n.top,a=e.position();return r-=a.x,i-=a.y,new F([r,i],[Math.max(0,t.width-n.left-n.right),Math.max(0,t.height-n.top-n.bottom)])}var $=class e extends xh{constructor(e,t){super(e),this.name=Re,this._originalWidth=e?.width,this._originalHeight=e?.height,this.options=q({},this.options,rh({connectors:void 0}),e),this._normalizeResizeOptions(),this.type=this.options.type,this._syncResizeOptions(),this.diagram=t,this.updateOptionsFromModel(),this.connectors=[],this.createShapeVisual(),this.updateBounds(),this.content(this.content()),this._createConnectors()}_setOptionsFromModel(e){let t=qm(e||this.dataItem);this.options=q({},this.options,t),this._normalizeResizeOptions(),this.redrawVisual()}updateOptionsFromModel(e,t){if(this.diagram&&this.diagram._isEditable){let n=qm(e||this.dataItem);if(e&&t)if(!j([`x`,`y`,`width`,`height`],t))this.options.visual?this._redrawVisual():n.type&&(this.options=q({},this.options,n),this._normalizeResizeOptions(),this._redrawVisual()),this.options.content&&(this._template(),this.content(this.options.content));else{let n=this.bounds();n[t]=e[t],this.bounds(n)}else this.options=q({},this.options,n),this._normalizeResizeOptions()}}_redrawVisual(){this.visual.clear(),this._contentVisual=null,this.options.dataItem=this.dataItem,this._normalizeResizeOptions(),this.type=this.options.type,this._syncResizeOptions(),this.createShapeVisual(),this.updateBounds()}redrawVisual(){this._redrawVisual(),this.options.content&&(this._template(),this.content(this.options.content))}updateModel(e){let t=this.diagram;t&&t._isEditable&&t.updateShapeModel(this,e)}updateBounds(){let e=this.visual._measure(!0),t=this.options;this.bounds(new K(t.x,t.y,e.width,e.height)),this._rotate(),this._alignContent()}content(e){let t=this._content(e);return this._alignContent(),t}_alignContent(){let e=this.options.content||{},t=this._contentVisual;if(!t){Dh(this.visual.drawingContainer(),null);return}Dh(this.visual.drawingContainer(),null);let n=this.visual._measure(),r=this.options.stroke?.width||0,i=r>0?r:0,a=new K(n.x+i,n.y+i,Math.max(0,n.width-i*2),Math.max(0,n.height-i*2)),o=new K(0,0,a.width,a.height),s=t.options.shapeSize,c=!s||s.width!==o.width||s.height!==o.height;e.shapeSize=o,t.options.shapeSize=o,c&&t.alignable===!1&&typeof t._initText==`function`&&t._initText();let l=t.position(),u=typeof t.padding==`function`?t.padding():{left:0,top:0,right:0,bottom:0};if(t.alignable===!1){if(!Th(t,a,e.align||`center middle`)){Dh(t.drawingContainer(),I.fromRect(Oh(t,a,u)));return}Dh(t.drawingContainer(),I.fromRect(Oh(t,a,u)));return}if(e.align&&t.alignable!==!1){let n=a;typeof t.padding==`function`&&(n=new K(a.x+u.left,a.y+u.top,Math.max(0,a.width-u.left-u.right),Math.max(0,a.height-u.top-u.bottom)));let r=n.topLeft(),i=new rf(new K(0,0,n.width,n.height)),o=t.drawingElement.bbox(null);if(!o){Dh(t.drawingContainer(),I.fromRect(Oh(t,a,u)));return}let s=new K(0,0,o.width(),o.height());l=i.align(s,e.align).topLeft().plus(r),t.position(l)}let d=t.drawingElement.bbox(null);if(!d){Dh(t.drawingContainer(),I.fromRect(Oh(t,a,u)));return}let f=0,p=0;d.width()>a.width-(u.left+u.right)&&(f=a.x-d.origin.x+u.left),d.height()>a.height-(u.top+u.bottom)&&(p=a.y-d.origin.y+u.top),(f!==0||p!==0)&&t.position(l.x+f,l.y+p),Dh(t.drawingContainer(),I.fromRect(Oh(t,a,u)))}_createConnectors(){let e=this.options,t=e.connectors||Qm[e.type]||nh,n=t.length,r=e.connectorDefaults,i,a;for(a=0;a<n;a++)i=new th(this,q({},r,t[a])),this.connectors.push(i)}bounds(e){let t;if(e)if(O(e))switch(e){case De:t=this._transformedBounds();break;case`absolute`:{t=this._transformedBounds();let e=this.diagram._pan;t.x+=e.x,t.y+=e.y;break}case ge:t=this._rotatedBounds();break;default:t=this._bounds;break}else this._setBounds(e),this._triggerBoundsChange(),this.diagram&&this.diagram._layouting||this.refreshConnections();else t=this._bounds;return t}_setBounds(e){let t=this.options,n=e.topLeft(),r=t.x=n.x,i=t.y=n.y,a=t.width=Math.max(e.width,t.minWidth),o=t.height=Math.max(e.height,t.minHeight);if(this._bounds=new K(r,i,a,o),this._syncResizeOptions(),this._scaleOnResize()){this.visual.redraw({x:r,y:i,width:a,height:o});return}this.shapeVisual&&typeof this.shapeVisual.redraw==`function`&&this.shapeVisual.redraw({...this._visualOptions(t),width:a,height:o}),this.visual.redraw({x:r,y:i}),this.visual._measure(!0),this._alignContent()}position(e){if(e)this.bounds(new K(e.x,e.y,this._bounds.width,this._bounds.height));else return this._bounds.topLeft()}clone(){let t=this.serialize();return t.options.id=Ot(),this.diagram&&this.diagram._isEditable&&E(this.dataItem)&&(t.options.dataItem=this.diagram.options.cloneDataItem(this.dataItem)),new e(t.options,void 0)}select(e){let t=this.diagram,n,r;if(D(e)&&(e=!0),this._canSelect()&&this.isSelected!==e)return n=[],r=[],this.isSelected=e,this.isSelected?(t._selectedItems.push(this),n.push(this)):(A(t._selectedItems,this),r.push(this)),t._internalSelection||t._selectionChanged(n,r),!0}rotate(e,t,n){let r=this.visual.rotate();if(e!==void 0){n!==!1&&this.diagram&&this.diagram.undoRedoService&&e!==r.angle&&this.diagram.undoRedoService.add(new $m(this.diagram._resizingAdorner,[this],[r.angle]),!1);let i=this.bounds(),a=new G(i.width/2,i.height/2),o,s;t&&(o=e-r.angle,s=i.center().rotate(o,t).minus(a),this._rotationOffset=this._rotationOffset.plus(s.minus(i.topLeft())),this.position(s)),this.visual.rotate(e,a),this.options.rotation.angle=e,this.diagram&&this.diagram._connectorsAdorner&&this.diagram._connectorsAdorner.refresh(),this.refreshConnections(),this.diagram&&this.diagram.trigger(ce,{item:this})}return r}connections(e){let t=[],n,r,i,a,o;for(n=0;n<this.connectors.length;n++)for(o=this.connectors[n],a=o.connections,r=0;r<a.length;r++)if(i=a[r],e===`out`){let e=i.source();e.shape&&e.shape===this&&t.push(i)}else if(e===`in`){let e=i.target();e.shape&&e.shape===this&&t.push(i)}else t.push(i);return t}refreshConnections(){this.connections().forEach(function(e){e.refresh()})}getConnector(e){let t,n;if(O(e)){for(e=e.toLocaleLowerCase(),t=0;t<this.connectors.length;t++)if(n=this.connectors[t],n.options.name.toLocaleLowerCase()===e)return n}else if(e instanceof G)return Wm(e,this.connectors);else return this.connectors.length?this.connectors[0]:null}getPosition(e){let t=this.bounds(),n=e.charAt(0).toLowerCase()+e.slice(1);return He(t[n])?this._transformPoint(t[n]()):t.center()}redraw(e){if(e){let t=this.options,n;(Object.prototype.hasOwnProperty.call(e,`resize`)||Object.prototype.hasOwnProperty.call(e,`type`))&&(t.resize=Object.prototype.hasOwnProperty.call(e,`resize`)?Ch(e.resize):t.resize,this._syncResizeOptions()),this.shapeVisual.redraw(this._visualOptions(e)),this._diffNumericOptions(e,[`width`,`height`,`x`,`y`])&&(this.bounds(new K(t.x,t.y,t.width,t.height)),n=!0),e.connectors&&(t.connectors=e.connectors,this._updateConnectors()),t=q(t,e),this._normalizeResizeOptions(),this.type=this.options.type,(e.rotation||n)&&this._rotate(),t.content&&this.content(t.content)}}_updateConnectors(){let e=this.connections();this.connectors=[],this._createConnectors();let t,n,r;for(let i=0;i<e.length;i++)t=e[i],n=t.source(),r=t.target(),n.shape&&n.shape===this?t.source(this.getConnector(n.options.name)||null):r.shape&&r.shape===this&&t.target(this.getConnector(r.options.name)||null),t.updateModel()}_diffNumericOptions(e,t){return Of.call(this,e,t)}_visualOptions(e){return{accessibility:e.accessibility,cornerRadius:e.cornerRadius,data:e.path,source:e.source,hover:e.hover,fill:e.fill,stroke:e.stroke,resize:e.resize,dataItem:this.dataItem||e?.dataItem,autoSize:e.autoSize,id:e.id}}_scaleOnResize(){return wh(this.options.resize).scaleContent===!0}_fixedAspectRatioOnResize(){return wh(this.options.resize).preserveAspectRatio===!0}_normalizeResizeOptions(){this.options.resize=Ch(this.options.resize)}_syncResizeOptions(){this.visual&&(this.visual.options.autoSize=this._scaleOnResize(),this._scaleOnResize()||(this.visual._transform.scale=void 0))}_resizeHandleAllowed(e){return!0}_resizeHandleVisible(e){return e&&e.x!==0&&e.y!==0}_resizeHandleVisualBounds(e,t,n){return t}_usesDynamicResizeBounds(){return!1}_triggerBoundsChange(){this.diagram&&this.diagram.trigger(le,{item:this,bounds:this._bounds.clone()})}_transformPoint(e){let t=this.rotate(),n=this.bounds().topLeft();return t.angle&&e.rotate(t.angle,t.center().plus(n)),e}_transformedBounds(){let e=this.bounds(),t=e.topLeft(),n=e.bottomRight();return K.fromPoints(this.diagram.modelToView(t),this.diagram.modelToView(n))}_rotatedBounds(){let e=this.bounds().rotatedBounds(this.rotate().angle),t=e.topLeft(),n=e.bottomRight();return K.fromPoints(t,n)}_rotate(){let e=this.options.rotation;e&&e.angle&&this.rotate(e.angle),this._rotationOffset=new G}_hover(e){let t=this.options,n=t.hover,r=t.stroke,i=t.fill;e&&T(n.stroke)&&(r=q({},r,n.stroke)),e&&T(n.fill)&&(i=n.fill),this.shapeVisual.redraw({stroke:r,fill:i}),t.editable&&t.editable.connect&&this.diagram._showConnectors(this,e)}_getMaxConnectorOffset(){let e=0;for(let t=0;t<this.connectors.length;t++){let n=this.connectors[t],r=n.options.offset||0,i=Math.max(n.options.width||0,n.options.height||0),a=n.options.stroke?.width||0,o=n.options.hover?.stroke?.width||a,s=r+i/2+Math.max(a,o);s>e&&(e=s)}return e}_hitTest(e){if(this.visible()){let t=this.bounds(),n=this.rotate().angle,r=this._getMaxConnectorOffset(),i;if(r>0&&(t=t.clone(),t.inflate(r,r)),e.isEmpty&&!e.isEmpty())return gf.rects(e,t,n||0);if(i=e.clone().rotate(n,t.center()),t.contains(i))return this}}toJSON(){return{shapeId:this.options.id}}createShapeVisual(){let e=this.options,t=this._visualOptions(e),n=e.visual?ah.compile(e.visual,e):e.visual,r=(e.type+``).toLocaleLowerCase(),i;t.width=e.width,t.height=e.height,He(n)?i=n.call(this,e):t.data?(i=new Rp(t),Km(i)):i=r===`rectangle`?new X(t):r===`circle`?new Zf(t):r===`image`?new Tp(t):Sh[e.type]?new Sh[e.type](t):new Rp(t),this.shapeVisual=i,this.visual.append(this.shapeVisual)}focus(){this.shapeVisual.drawingElement.options.set(Be,Oe)}blur(){this.shapeVisual.drawingElement.options.set(Be,``)}},kh=class extends Cm{constructor(e,t){t=q({handles:{}},t),super(e.diagram,t),this.connection=e;let n=this.connection.diagram;this._ts=n.toolService;let r=this.connection.sourcePoint(),i=this.connection.targetPoint();this.spVisual=new Zf(q({},this.options.handles,{center:r,autoSize:!1})),this.epVisual=new Zf(q({},this.options.handles,{center:i,autoSize:!1})),this.visual.append(this.spVisual),this.visual.append(this.epVisual)}_getCursor(){return C.move}start(e){switch(this.handle=this._hitTest(e),this.startPoint=e,this._initialSource=this.connection.source(),this._initialTarget=this.connection.target(),this._initialLocks=(this.connection.locks||[]).map(e=>({...e})),this._initialPoints=(this.connection.points()||[]).map(e=>e.clone()),this.handle){case-1:this.connection.targetConnector&&this._ts._connectionManipulation(this.connection,this.connection.targetConnector.shape);break;case 1:this.connection.sourceConnector&&this._ts._connectionManipulation(this.connection,this.connection.sourceConnector.shape);break;default:break}}move(e,t){let n=this.diagram.toolService,r=t,i=n._hoveredConnector;if(i){let t=e===-1,n=e===1;(t&&i._c!==this.connection.targetConnector||n&&i._c!==this.connection.sourceConnector)&&(r=i._c.position())}switch(e){case-1:this.connection.source(r);break;case 1:this.connection.target(r);break;default:{let e=t.minus(this.startPoint);this.startPoint=t;let n=this.connection.type();if(n&&n.toLowerCase()===`cascading`&&this.connection.locks&&this.connection.locks.length>0&&this.connection.locks.forEach(t=>{t.axis===`x`?t.value+=e.x:t.value+=e.y}),this.connection.points().length>0){let t=this.connection.points().map(t=>t.plus(e));this.connection.points(t)}this.connection.sourceConnector||this.connection.source(this.connection.sourcePoint().plus(e)),this.connection.targetConnector||this.connection.target(this.connection.targetPoint().plus(e));break}}return this.connection.refresh(),this.refresh(),!0}stop(e){let t=this.diagram.toolService,n=t.hoveredItem,r;r=t._hoveredConnector?t._hoveredConnector._c:n&&n instanceof $?n.getConnector(`Auto`)||n.getConnector(e):e,this.handle===-1?this.connection.source(r):this.handle===1&&this.connection.target(r);let i=this.handle;return this.handle=void 0,this._ts._connectionManipulation(),i===-1||i===1?new wm(this.connection,this._initialSource,this._initialTarget):new Vm({item:this.connection,undoLocks:this._initialLocks,redoLocks:this.connection.locks||[],undoPoints:this._initialPoints,redoPoints:(this.connection.points()||[]).map(e=>e.clone()),routingMode:this.connection.routingMode,sourceSide:this.connection.buildOptions?.sourceSide||null,targetSide:this.connection.buildOptions?.targetSide||null})}_hitTest(e){let t=this.connection.sourcePoint(),n=this.connection.targetPoint(),r=this.options.handles.width/2+10,i=this.options.handles.height/2+10,a=t.distanceTo(e),o=n.distanceTo(e),s=new K(t.x,t.y).inflate(r,i).contains(e),c=new K(n.x,n.y).inflate(r,i).contains(e),l=0;return s&&(!c||a<o)?l=-1:c&&(!s||o<a)&&(l=1),l}refresh(){this.spVisual.redraw({center:this.diagram.modelToLayer(this.connection.sourcePoint())}),this.epVisual.redraw({center:this.diagram.modelToLayer(this.connection.targetPoint())})}};function Ah(e,t){if(!e.length)return[];let n=e.some(e=>e.axis===`x`),r=e.some(e=>e.axis===`y`),i=[],a=new G(t.x,t.y);for(let t=0;t<e.length;t++){let n=e[t],r=n.axis===`x`?new G(n.value,a.y):new G(a.x,n.value);if(r.x!==a.x||r.y!==a.y){i.push(n),a=r;continue}let o=e.slice(t+1).some(e=>e.axis===n.axis);!i.some(e=>e.axis===n.axis)&&!o&&i.push(n)}if(n&&!i.some(e=>e.axis===`x`)){let t=e.find(e=>e.axis===`x`);t&&i.push(t)}if(r&&!i.some(e=>e.axis===`y`)){let t=e.find(e=>e.axis===`y`);t&&i.unshift(t)}return i}function jh(e,t,n={}){let r=n.tolerance??6,i=r*r,a=-1,o=1/0;for(let n=0;n<t.length;n++){let r=t[n],i=Nh(e,r.a,r.b);i<o&&(o=i,a=n)}if(a===-1||o>i)return-1;let s=[];for(let n=0;n<t.length;n++){let r=Nh(e,t[n].a,t[n].b);Math.abs(r-o)<1e-9&&s.push(n)}if(s.length>1){let e=s[0],n=Mh(t[e].a,t[e].b);for(let r=1;r<s.length;r++){let i=s[r],a=Mh(t[i].a,t[i].b);a>n&&(n=a,e=i)}return e}return a}function Mh(e,t){let n=t.x-e.x,r=t.y-e.y;return n*n+r*r}function Nh(e,t,n){if(t.y===n.y){let r=t.y,i=Math.min(t.x,n.x),a=Math.max(t.x,n.x);if(e.x>=i&&e.x<=a){let t=e.y-r;return t*t}let o=e.x<i?i:a,s=e.x-o,c=e.y-r;return s*s+c*c}let r=t.x,i=Math.min(t.y,n.y),a=Math.max(t.y,n.y);if(e.y>=i&&e.y<=a){let t=e.x-r;return t*t}let o=e.y<i?i:a,s=e.x-r,c=e.y-o;return s*s+c*c}function Ph(e,t){let n=e=>Math.round(e/t)*t;return e.map(e=>`${n(e.x)},${n(e.y)}`).join(`;`)}function Fh(e,t){let n=Im({...e,locks:t});return Rm([e.source,...n.points,e.target])}function Ih(e,t,n={}){let r=n.tolerance??.5;if(!e.length)return e;let i=Ph(Fh(t,e),r),a=e.slice(),o=!0;for(;o&&a.length;){o=!1;for(let e=0;e<a.length;e++){let n=a.slice(0,e).concat(a.slice(e+1));if(Ph(Fh(t,n),r)===i){a=n,o=!0;break}}}return a}function Lh(e){return e.orientation===`H`?`y`:`x`}function Rh(e,t,n,r){if(t.y===n.y){let i=Math.min(t.x,n.x),a=Math.max(t.x,n.x);return Math.abs(e.y-t.y)<=r&&e.x>=i-r&&e.x<=a+r}let i=Math.min(t.y,n.y),a=Math.max(t.y,n.y);return Math.abs(e.x-t.x)<=r&&e.y>=i-r&&e.y<=a+r}var zh=class extends Cm{constructor(e,t){super(e.diagram,q({},t)),this._sourceSide=null,this._targetSide=null,this.connection=e,this.handles=[],this.activeHandle=null,this._firstMove=!1,t&&this._createHandles(),this.diagram.bind(`dblclick`,this.onDblClick.bind(this))}onDblClick(e){let t=e.item&&e.item.name===`Connection`&&this._hitTest(e.point);if(!t||!t.vertex)return;let n=this.connection.route.segmentsMeta,r=n[jh(t.point,n,{tolerance:8})];if(r&&r.ownerLockIndex!=null){this.connection.locks.splice(r.ownerLockIndex,1),this.connection.routingMode=this.connection.locks.length?`manual`:`auto`;let e=Im({...this.connection.buildOptions,locks:this.connection.locks}),t=this.connection.sourcePoint(),n=this.connection.targetPoint(),i=Rm([t,...e.points,n]);this.connection.points(i.slice(1,-1)),this.connection.route=e,this.connection.refresh(),this.refresh()}}createMiddlePoints(){let e=this.connection.route,t=[];if(!e)return t;let n=e.points,r=this.connection.allPoints(),i=r[0],a=r[r.length-1],o=r.length>2?r[1]:null,s=r.length>2?r[r.length-2]:null,c=e.connectionStart.x!==i.x||e.connectionStart.y!==i.y,l=e.connectionEnd.x!==a.x||e.connectionEnd.y!==a.y,u=this._axisAligned(n)&&n.length>=2?[n[0],n[n.length-1]]:n,d=[...c?[]:[i],...u,...l?[]:[a]];if(d.length<2)return t;let f=this.connection.options.anchorOffset??0,p=.5;for(let e=0;e<d.length-1;){let n=e+1;for(;n<d.length-1&&this._axisAligned(d.slice(e,n+2));)n++;let r=d[e],c=d[n];if(r.x===c.x&&r.y===c.y){e=n;continue}let l=new G((r.x+c.x)/2,(r.y+c.y)/2),u=e===0,m=n===d.length-1,h=u&&o&&this._axisAligned([i,l,o]),g=m&&s&&this._axisAligned([a,l,s]),_=h&&o&&i.distanceTo(o)<=f+p,v=g&&s&&a.distanceTo(s)<=f+p;if(_||v){e=n;continue}u&&h&&!_&&o?l=new G((i.x+o.x)/2,(i.y+o.y)/2):m&&g&&!v&&s&&(l=new G((a.x+s.x)/2,(a.y+s.y)/2)),t.push(l),e=n}return t}_createHandles(){if(this.handles.forEach(e=>this.visual.remove(e.visual)),this.handles=[],(this.connection.options.type||``).toLowerCase()!==`cascading`||this.connection.pointsEditable()===!1)return;let e=this.createMiddlePoints(),t=this.options,n=this.connection.route.segmentsMeta.filter(e=>e.ownerLockIndex!==null);e.forEach(e=>{let r=n.some(t=>Rh(e,t.a,t.b,.5)),i=new Zf({center:this.diagram.modelToLayer(e),radius:r?t.vertex.radius:t.midpoint.radius,fill:r?t.vertex.fill:t.midpoint.fill,stroke:r?t.vertex.stroke:t.midpoint.stroke});this.visual.append(i),this.handles.push({visual:i,point:e,vertex:r})})}_axisAligned(e){if(e.length<=1)return!0;let{x:t,y:n}=e[0];return e.every(e=>e.x===t)||e.every(e=>e.y===n)}_getCursor(e){if(this._activeDrag)return this._activeDrag.cursor;let t=e&&this._hitTest(e);if(t){let e=this.connection.route.segmentsMeta,n=e[jh(t.point,e,{tolerance:8})];return!n||n.orientation===`H`?C.rowresize:C.colresize}}_hitTest(e){let t=this.options;if(!t.midpoint||!t.vertex)return null;let n=(t.vertex.radius+(t.vertex.stroke?.width||1))/this.diagram.zoom();return this.handles.find(t=>t.point.distanceTo(e)<=n)||null}start(e){if(this.activeHandle=this._hitTest(e),this.activeHandle){this._initialLocks=this.connection.locks.map(e=>({...e})),this._routingMode=this.connection.routingMode,this._sourceSide=this.connection.buildOptions.sourceSide,this._targetSide=this.connection.buildOptions.targetSide;let t=this.connection.route.segmentsMeta,n=jh(e,t,{tolerance:8}),r=t[n];r?this._activeDrag={axis:Lh(r),lockIndex:r.ownerLockIndex,insertIndex:r.insertIndex,inserted:!1,cursor:!r||r.orientation===`H`?C.rowresize:C.colresize,segmentIndex:n}:this._activeDrag={axis:`y`,lockIndex:null,insertIndex:this.connection.locks.length,inserted:!1,cursor:C.arrow,segmentIndex:n},this._firstMove=!0}}move(e,t){if(!this.activeHandle)return!1;let n=new G(Math.round(t.x),Math.round(t.y)),r=this.connection,i=this._activeDrag,a=i.axis===`x`?n.x:n.y,o=this._findSnapValue(i.axis,a);o!==null&&(a=o),i.lockIndex==null&&!i.inserted&&(r.locks.splice(i.insertIndex,0,{axis:i.axis,value:a}),i.lockIndex=i.insertIndex,i.inserted=!0),i.lockIndex!=null&&(r.locks[i.lockIndex].value=a);let s=Im({...this.connection.buildOptions,locks:r.locks});return this.updateConnection(s),!0}updateConnection(e){this.connection.routingMode=`manual`;let t=this.connection.sourcePoint(),n=this.connection.targetPoint(),r=Rm([t,...e.points,n]);this.connection.points(r.slice(1,-1)),this.connection.route=e,this.connection.refresh(),this._firstMove&&this.handles&&this.handles.forEach(e=>{e.visual&&e.visual.visible(!1)}),this._firstMove=!1}_findSnapValue(e,t){let n=this.connection.route?.segmentsMeta;if(!n||!this._activeDrag)return null;let r=this._activeDrag.lockIndex,i=null,a=this.options.snap===void 0?6:this.options.snap;for(let o of n){if(r!==null&&o.ownerLockIndex===r||!(e===`y`&&o.orientation===`H`||e===`x`&&o.orientation===`V`))continue;let n=o.orientation===`H`?(o.a.y+o.b.y)/2:(o.a.x+o.b.x)/2,s=Math.abs(n-t);s<a&&(a=s,i=n)}return i}stop(e){if(!this.activeHandle)return;let t=this.connection.locks.map(e=>({...e}));this.connection.locks=Ah(this.connection.locks,this.connection.route.connectionStart);let n=this.connection.sourcePoint(),r=this.connection.targetPoint();this.connection.locks=Ih(this.connection.locks,this.connection.buildOptions,{tolerance:.5});let i={...this.connection.buildOptions},a={};this.connection._resolveConnectors(a),(!a._resolvedTargetConnector?.positionWithoutOffset().equals(r)||!a._resolvedSourceConnector?.positionWithoutOffset().equals(n))&&(this.connection.locks=t,this.connection.buildOptions=i);let o=Im({...this.connection.buildOptions,locks:this.connection.locks});this.updateConnection(o);let s=new Vm({item:this.connection,undoLocks:this._initialLocks||[],redoLocks:this.connection.locks,undoPoints:[],redoPoints:[],routingMode:this._routingMode,sourceSide:this._sourceSide,targetSide:this._targetSide});return this._resetFlags(),this.refresh(),s}refresh(){this._createHandles()}cancel(){this.activeHandle&&this._initialLocks&&(this._initialLocks&&(this.connection.locks=this._initialLocks.map(e=>({...e})),this.updateConnection(Im({...this.connection.buildOptions,locks:this.connection.locks}))),this.refresh(),this._resetFlags())}_resetFlags(){this.activeHandle=null,this._activeDrag=null,this._firstMove=!1,this._initialLocks&&=void 0}},Bh=class extends Cm{constructor(e,t){super(e.diagram,q({},t)),this._handlePoints=[],this.connection=e,this.handles=[],this.activeHandle=null,this._firstMove=!1,t&&this._createHandles(),this.diagram.bind(`dblclick`,this.onDblClick.bind(this))}onDblClick(e){let t=e.item&&e.item.name===`Connection`&&this._hitTest(e.point),n=t&&this._handlePoints.find(e=>e.point.equals(t.point));if(n&&n.vertex){let e=this.connection.allPoints().slice(1,-1),t=e.findIndex(e=>e.equals(n.point));if(t<0)return;e.splice(t,1),this.connection.points(e.map(e=>e.clone())),this.connection.refresh(),this.refresh()}}createHandlePoints(){let e=this.connection.allPoints(),t=[],n=e[0],r=e[e.length-1],i=e.slice(1,-1),a=i.length?[n,...i,r]:[n,r];for(let e=0;e<a.length-1;){let n=e+1,r=a[e],i=a[n];(r.x!==i.x||r.y!==i.y)&&(t.push({vertex:!0,point:r}),t.push({vertex:!1,point:new G((r.x+i.x)/2,(r.y+i.y)/2)}),t.push({vertex:!0,point:i})),e=n}return t.slice(1,-1)}_createHandles(){if(this.handles.forEach(e=>this.visual.remove(e.visual)),this.handles=[],(this.connection.options.type||``).toLowerCase()!==`polyline`||this.connection.pointsEditable()===!1)return;this._handlePoints=this.createHandlePoints();let e=this.options;this._handlePoints.forEach(({point:t,vertex:n})=>{let r=new Zf({center:this.diagram.modelToLayer(t),radius:n?e.vertex.radius:e.midpoint.radius,fill:n?e.vertex.fill:e.midpoint.fill,stroke:n?e.vertex.stroke:e.midpoint.stroke});this.visual.append(r),this.handles.push({visual:r,point:t})})}_getCursor(e){if(e&&this._hitTest(e))return C.arrow}_hitTest(e){let t=this.options;if(!t.midpoint||!t.vertex)return null;let n=(t.midpoint.radius+(t.midpoint.stroke?.width||1))/this.diagram.zoom();return this.handles.find(t=>t.point.distanceTo(e)<=n)||null}start(e){this.activeHandle=this._hitTest(e),this.activeHandle&&(this._initialPoints=this.connection.points().map(e=>e.clone()),this._firstMove=!0)}move(e,t){if(!this.activeHandle)return!1;let n=this.connection.allPoints().slice(1,-1),r=this.activeHandle.point,i=this._handlePoints.findIndex(e=>e.point.equals(r)),a=this._handlePoints[i];if(!a)return;let o=this._applySnap(t,i);if(a.vertex){let e=n.find(e=>e.equals(a.point));e&&(e.x=o.x,e.y=o.y,this.connection.points(n.map(e=>e.clone())),this.updateConnection(),this.activeHandle.point=e.clone(),a.point=e.clone())}else{let e=this._handlePoints[i-1],t=this._handlePoints[i+1];if(e){let t=n.findIndex(t=>t.equals(e.point));t>=0&&n.splice(t+1,0,o.clone())}else if(t){let e=n.findIndex(e=>e.equals(t.point));e>=0&&n.splice(e,0,o.clone())}else n.length===0&&n.push(o.clone());this.connection.points(n.map(e=>e.clone())),this.updateConnection(),this._handlePoints=this.createHandlePoints();let r=this._handlePoints.findIndex(e=>e.vertex&&e.point.equals(o));r>=0&&(this.activeHandle.point=this._handlePoints[r].point)}return this.connection.refresh(),!0}updateConnection(){let e=this.connection.sourcePoint(),t=this.connection.targetPoint(),n=this.connection.points();this.connection.path.redraw({points:[e,...n,t]}),this.connection._alignContent(),this._firstMove&&this.handles&&this.handles.forEach(e=>{e.visual&&e.visual.visible(!1)}),this._firstMove=!1}_applySnap(e,t){let n=this._handlePoints[t];if(!n)return e;let r=this.options.snap===void 0?6:this.options.snap,i=this.connection.allPoints(),a=null,o=null;if(n.vertex){let e=i.findIndex(e=>e.distanceTo(n.point)<.1);e>=0&&(a=e>0?i[e-1]:null,o=e<i.length-1?i[e+1]:null)}else{let e=this._handlePoints[t-1],n=this._handlePoints[t+1];a=e?.point||null,o=n?.point||null}let s=null,c=null;return a&&Math.abs(e.y-a.y)<r&&(c=a.y),o&&c===null&&Math.abs(e.y-o.y)<r&&(c=o.y),a&&Math.abs(e.x-a.x)<r&&(s=a.x),o&&s===null&&Math.abs(e.x-o.x)<r&&(s=o.x),new G(s===null?e.x:s,c===null?e.y:c)}stop(e){if(!this.activeHandle)return;let t=new Vm({item:this.connection,undoLocks:[],redoLocks:[],undoPoints:this._initialPoints,redoPoints:this.connection.points(),routingMode:`manual`,sourceSide:null,targetSide:null});return this._resetFlags(),this.refresh(),t}refresh(){let e=this.activeHandle?.point.clone();this._createHandles(),e&&(this.activeHandle=this.handles.find(t=>t.point.equals(e))||null)}cancel(){this.activeHandle&&this._initialPoints&&(this._initialPoints&&(this.connection.points(this._initialPoints),this.connection.refresh()),this.refresh(),this._resetFlags())}_resetFlags(){this.activeHandle=null,this._firstMove=!1,this._initialPoints&&=void 0}},Vh=class{constructor(e){this.options=q({},e.options),this._c=e,this.visual=new Zf({...this.options,autoSize:!1}),this.refresh()}_hover(e){let t=this.options,n=t.hover,r=t.stroke,i=t.fill;e&&T(n.stroke)&&(r=q({},r,n.stroke)),e&&T(n.fill)&&(i=n.fill),this.visual.redraw({stroke:r,fill:i})}refresh(){let e=this._c.shape.diagram.modelToView(this._c.position()),t=e.minus(this._c.shape.bounds(`transformed`).topLeft()),n=new K(e.x,e.y,0,0),r=(this.options.stroke?.width||0)/2,i=Math.max(this.options.width,this.options.height);n.inflate(this.options.width/2+r+i,this.options.height/2+r+i),this._visualBounds=n,this.visual.redraw({center:new G(t.x,t.y)})}_hitTest(e){let t=this._c.shape.diagram.modelToView(e);return this._visualBounds.contains(t)}},Hh=class extends Cm{constructor(e,t){super(e,t),this._refreshHandler=e=>{e.item===this.shape&&this.refresh()}}show(e){if(this._paused)return;this._visible=!0,this.shape=e,this.diagram.bind(le,this._refreshHandler),this.connectors=[],this._clearVisual();let t=e.connectors.length;for(let n=0;n<t;n++){let t=new Vh(e.connectors[n]);this.connectors.push(t),this.visual.append(t.visual)}this.visual.visible(!0),this.refresh()}pause(){this._paused=!0,this.visual.visible(!1)}resume(){this._paused=!1}_clearVisual(){this.diagram._cachedTouchTarget?this._keepCachedTouchTarget():this.visual.clear()}_keepCachedTouchTarget(){let e=this.visual.children,t=e.length,n=ct(this.diagram._cachedTouchTarget,e);for(let r=t-1;r>=0;r--)r!==n&&this.visual.remove(e[r])}destroy(){this.diagram.unbind(le,this._refreshHandler),this.shape=void 0,this._visible=void 0,this.visual.visible(!1)}_hitTest(e){let t,n;for(n=0;n<this.connectors.length;n++)if(t=this.connectors[n],t._hitTest(e)){t._hover(!0),this.diagram.toolService._hoveredConnector=t;break}}refresh(){if(this.shape){let e=this.shape.bounds();e=this.diagram.modelToLayer(e),this.visual.position(e.topLeft()),this.connectors.forEach(function(e){e.refresh()})}}};function Uh(e){let t=e.options.editable;return t&&t.drag!==!1}var Wh=class{constructor(e,t,n){this.shapes=e,this.undoStates=t,this.title=`Transformation`,this.redoStates=[],this.adorner=n;for(let e=0;e<this.shapes.length;e++){let t=this.shapes[e];this.redoStates.push(t.bounds())}}undo(){for(let e=0;e<this.shapes.length;e++){let t=this.shapes[e];t.bounds(this.undoStates[e]),`layout`in t&&t.layout(t,this.redoStates[e],this.undoStates[e]),t.updateModel()}this.adorner&&(this.adorner.refreshBounds(),this.adorner.refresh())}redo(){for(let e=0;e<this.shapes.length;e++){let t=this.shapes[e];t.bounds(this.redoStates[e]),`layout`in t&&t.layout(t,this.undoStates[e],this.redoStates[e]),t.updateModel()}this.adorner&&(this.adorner.refreshBounds(),this.adorner.refresh())}};function Gh(e,t){let n;return e.x===-1&&e.y===-1?n=t.bottomRight():e.x===1&&e.y===1?n=t.topLeft():e.x===-1&&e.y===1?n=t.topRight():e.x===1&&e.y===-1?n=t.bottomLeft():e.x===0&&e.y===-1?n=t.bottom():e.x===0&&e.y===1?n=t.top():e.x===1&&e.y===0?n=t.left():e.x===-1&&e.y===0&&(n=t.right()),n}let Kh={handles:{fill:{color:`#fff`},stroke:{color:`#282828`},height:7,width:7,hover:{fill:{color:`#282828`},stroke:{color:`#282828`}}},selectable:{stroke:{color:`#778899`,width:1,dashType:`solid`},fill:{color:g},offset:3},offset:1};var qh=class extends Cm{constructor(e,t){t=q({},Kh,t);let n=e.options.editable;n&&typeof n!=`boolean`&&n.resize&&typeof n.resize!=`boolean`&&n.resize.offset!==void 0&&(t.offset=n.resize.offset);let r=e.options.selectable;r&&typeof r!=`boolean`&&r.offset!==void 0?t.selectionRectOffset=r.offset:t.selectionRectOffset=Kh.selectable.offset,super(e,t),this._manipulating=!1,this.map=[],this.shapes=[],this.shapeStates=[],this._initSelection(),this._createHandles(),this.redraw(),this.diagram.bind(`select`,()=>{this._initialize()}),this._refreshHandler=()=>{this._internalChange||(this.refreshBounds(),this.refresh())},this._rotatedHandler=()=>{this.shapes.length===1&&(this._angle=this.shapes[0].rotate().angle),this._refreshHandler()},this.diagram.bind(le,this._refreshHandler).bind(ce,this._rotatedHandler),this.refreshBounds(),this.refresh()}_initSelection(){let e=this.diagram,t=e.options.editable,n=e.options.selectable;t&&typeof t!=`boolean`&&t.resize&&typeof t.resize!=`boolean`&&t.resize.selectable&&(n=t.resize.selectable);let r=q({},this.options.selectable,n);this.rect=new X(r),this.visual.append(this.rect)}_resizable(){return this.options.editable&&this.options.editable.resize!==!1}_isResizeHandleAllowed(e){return!e||this.isDragHandle(e)||this.shapes.length===0?!0:this.shapes.every(t=>typeof t._resizeHandleAllowed!=`function`||t._resizeHandleAllowed(e))}_isResizeHandleVisible(e){if(!this._isResizeHandleAllowed(e))return!1;if(this.shapes.length!==1)return e&&e.x!==0&&e.y!==0;let t=this.shapes[0];return typeof t._resizeHandleVisible!=`function`||t._resizeHandleVisible(e)}_getResizeHandleVisualBounds(e,t){if(this.shapes.length!==1)return t;let n=this.shapes[0];return typeof n._resizeHandleVisualBounds==`function`&&n._resizeHandleVisualBounds(e,t,{zoom:this.diagram.zoom(),handles:this._handleOptions(),handleOffset:(this.options.selectionRectOffset-this.options.offset)*this.diagram.zoom()})||t}_handleOptions(){let e=(this.options.editable.resize||{}).handles;return e?q({},this.options.handles,e):this.options.handles}_createHandles(){let e,t,n,r;if(this._resizable())for(e=this._handleOptions(),r=-1;r<=1;r++)for(n=-1;n<=1;n++)(r!==0||n!==0)&&(t=new X(e),t.drawingElement._hover=this._hover.bind(this,new G(r,n)),this.map.push({x:r,y:n,visual:t}),this.visual.append(t))}bounds(e){if(e)this._innerBounds=e.clone(),this._bounds=this.diagram.modelToLayer(e).inflate(this.options.offset,this.options.offset);else return this._bounds}_hitTest(e){let t=this.map.length,n=this.diagram.modelToLayer(e),r,i,a,o;if(this._angle&&(n=n.clone().rotate(-this._angle,this._bounds.center())),this._resizable()){let e=this.diagram.modelToLayer(this._innerBounds),s=this.diagram.zoom(),c=this.options.selectionRectOffset*s,l=e.x-c,u=e.y-c;for(r=0;r<t;r++)if(o=this.map[r],o.x!==0&&o.y!==0){if(i=new G(o.x,o.y),!this._isResizeHandleAllowed(i))continue;if(a=this._getHandleBounds(i),a.offset(l,u),a.contains(n))return i}for(r=0;r<t;r++)if(o=this.map[r],o.x===0||o.y===0){if(i=new G(o.x,o.y),!this._isResizeHandleAllowed(i))continue;if(a=this._getHandleBounds(i),a.offset(l,u),a.contains(n))return i}}if(this._bounds.contains(n))return new G(0,0)}_getHandleBounds(e){if(this._resizable()){let t=this._handleOptions(),n=t.width,r=t.height,i=this.diagram.modelToLayer(this._innerBounds),a=this.diagram.zoom(),o=this.options.offset*a,s=this.options.selectionRectOffset*a-o,c=i.width-a,l=i.height-a,u=n*a,d=r*a,f;return e.x!==0&&e.y!==0?(f=new K(0,0,n,r),e.x<0?f.x=s-n/2:e.x>0&&(f.x=c+2*o+s-n/2),e.y<0?f.y=s-r/2:e.y>0&&(f.y=l+2*o+s-r/2)):e.x===0&&e.y!==0?f=new K(s,e.y<0?s-d/2:l+2*o+s-d/2,c+2*o,d):e.y===0&&e.x!==0&&(f=new K(e.x<0?s-u/2:c+2*o+s-u/2,s,u,l+2*o)),f}}_getCursor(e){let t=this._hitTest(e);if(t&&t.x>=-1&&t.x<=1&&t.y>=-1&&t.y<=1&&this._resizable()){let e=this._angle;if(e&&(t.rotate(e,new G(0,0)),t=new G(Math.round(t.x),Math.round(t.y))),t.x===-1&&t.y===-1)return`nw-resize`;if(t.x===1&&t.y===1)return`se-resize`;if(t.x===-1&&t.y===1)return`sw-resize`;if(t.x===1&&t.y===-1)return`ne-resize`;if(t.x===0&&t.y===-1)return`n-resize`;if(t.x===0&&t.y===1)return`s-resize`;if(t.x===1&&t.y===0)return`e-resize`;if(t.x===-1&&t.y===0)return`w-resize`}return this._manipulating?C.move:C.select}_initialize(){let e,t,n=this.diagram.select();for(this.shapes=[],e=0;e<n.length;e++)t=n[e],t instanceof $&&(this.shapes.push(t),t._rotationOffset=new G);this._angle=this.shapes.length===1?this.shapes[0].rotate().angle:0,this._startAngle=this._angle,this._rotates(),this._positions(),this.refreshBounds(),this.refresh(),this.redraw()}_rotates(){let e,t;for(this.initialRotates=[],e=0;e<this.shapes.length;e++)t=this.shapes[e],this.initialRotates.push(t.rotate().angle)}_positions(){let e,t;for(this.initialStates=[],e=0;e<this.shapes.length;e++)t=this.shapes[e],this.initialStates.push(t.bounds())}_hover(e,t,n){if(this._resizable()){if(!this._isResizeHandleVisible(e)){n.fill(`transparent`,0),n.stroke(`transparent`,0,0);return}let r=this._handleOptions(),i=r.hover,a=q({width:1},r.stroke),o=q({opacity:1},r.fill);a=q({opacity:1},a),t&&T(i.stroke)&&(a=q({},a,i.stroke)),t&&T(i.fill)&&(o=q({},o,i.fill)),n.stroke(a.color,a.width,a.opacity),n.fill(o.color,o.opacity)}}start(e,t){this._sp=e,this._cp=e,this._lp=e,this._interactionMeta=t||{},this._manipulating=!0,this._internalChange=!0,this.shapeStates=[];for(let e=0;e<this.shapes.length;e++){let t=this.shapes[e];this.shapeStates.push(t.bounds())}}redraw(){let e,t,n=this._resizable();for(e=0;e<this.map.length;e++)t=this.map[e],t.visual.visible(n&&this._isResizeHandleVisible(new G(t.x,t.y)))}angle(e){return E(e)&&(this._angle=e),this._angle}rotate(){let e=this._innerBounds.center(),t=this.angle();this._internalChange=!0;for(let n=0;n<this.shapes.length;n++){let r=this.shapes[n];t=(t+this.initialRotates[n]-this._startAngle)%360,r.rotate(t,e)}this.refresh()}move(e,t,n){let r,i,a=new G,o=new G,s,c,l,u,d,f,p=0,m,h,g;if(!(!this.isDragHandle(e)&&!this._isResizeHandleAllowed(e))){if(this._interactionMeta=n||this._interactionMeta||{},e.y===-2&&e.x===-1){for(c=this._innerBounds.center(),this._angle=this._truncateAngle(at(c,t)),u=0;u<this.shapes.length;u++)l=this.shapes[u],d=(this._angle+this.initialRotates[u]-this._startAngle)%360,l.rotate(d,c),Object.prototype.hasOwnProperty.call(l,`layout`)&&l.layout(l),this._rotating=!0;this.refresh()}else{if(this.shouldSnap()){let e=this._truncateDistance(t.minus(this._lp));if(e.x===0&&e.y===0){this._cp=t;return}r=e,this._lp=new G(this._lp.x+e.x,this._lp.y+e.y)}else r=t.minus(this._cp);for(this.isDragHandle(e)?(o=a=r,i=!0):(this._angle&&r.rotate(-this._angle,new G(0,0)),this._preserveAspectRatio(e,this._interactionMeta)&&(r=this._projectResizeDelta(e,r)),e.x===-1?a.x=r.x:e.x===1&&(o.x=r.x),e.y===-1?a.y=r.y:e.y===1&&(o.y=r.y)),i||(m=Gh(e,this._innerBounds),h=(this._innerBounds.width+r.x*e.x)/this._innerBounds.width,g=(this._innerBounds.height+r.y*e.y)/this._innerBounds.height),u=0;u<this.shapes.length;u++){if(l=this.shapes[u],s=l.bounds(),i){if(!Uh(l))continue;f=this._displaceBounds(s,a,o,i)}else f=this._scaleBounds(s,h,g,m,l.rotate().angle);if(f.width>=l.options.minWidth&&f.height>=l.options.minHeight){let e=s;l.bounds(f),Object.prototype.hasOwnProperty.call(l,`layout`)&&l.layout(l,e,f),(e.width!==f.width||e.height!==f.height)&&l.rotate(l.rotate().angle),p+=1}}if(p){let e=this.shapes.some(e=>typeof e._usesDynamicResizeBounds==`function`&&e._usesDynamicResizeBounds());p===u&&!e?(f=i?this._displaceBounds(this._innerBounds,a,o,i):this._scaleBounds(this._innerBounds,h,g,m,this._angle),this.bounds(f)):this.refreshBounds(),this.refresh()}this._positions()}this._cp=t}}isDragHandle(e){return e.x===0&&e.y===0}cancel(){let e=this.shapes,t=this.shapeStates;for(let n=0;n<e.length;n++)e[n].bounds(t[n]);this.refreshBounds(),this.refresh(),this._interactionMeta=void 0,this._manipulating=void 0,this._internalChange=void 0,this._rotating=void 0}_preserveAspectRatio(e,t){return e.x===0||e.y===0?!1:t?.shiftKey?!0:this.shapes.some(e=>e._fixedAspectRatioOnResize())}_projectResizeDelta(e,t){let n=new G(e.x*this._innerBounds.width,e.y*this._innerBounds.height),r=n.lengthSquared();if(!r)return t;let i=(t.x*n.x+t.y*n.y)/r;return n.times(i)}_scaleBounds(e,t,n,r,i){let a=e.clone();a.scale(t,n,r,this._innerBounds.center(),i);let o=a.center();return o.rotate(-this._angle,e.center()),new K(o.x-a.width/2,o.y-a.height/2,a.width,a.height)}_truncatePositionToGuides(e){return this.diagram.ruler?this.diagram.ruler.truncatePositionToGuides(e):e}_truncateSizeToGuides(e){return this.diagram.ruler?this.diagram.ruler.truncateSizeToGuides(e):e}_truncateAngle(e){let t=this.snapOptions(),n=Math.max(t.angle||10,5);return t?Math.floor(e%360/n)*n:e%360}_truncateDistance(e){if(e instanceof G)return new G(this._truncateDistance(e.x),this._truncateDistance(e.y));{let t=this.snapOptions()||{},n=Math.max(t.size||10,5);return t?Math.floor(e/n)*n:e}}snapOptions(){return((this.diagram.options.editable||{}).drag||{}).snap||{}}shouldSnap(){let e=this.diagram.options.editable,t=(e||{}).drag,n=(t||{}).snap;return e!==!1&&t!==!1&&n!==!1}_displaceBounds(e,t,n,r){let i=e.topLeft().plus(t),a=e.bottomRight().plus(n),o=K.fromPoints(i,a),s;return r||(s=o.center(),s.rotate(-this._angle,e.center()),o=new K(s.x-o.width/2,s.y-o.height/2,o.width,o.height)),o}stop(){let e,t,n,r;if(this._cp!==this._sp){if(this._rotating)e=new $m(this,this.shapes,this.initialRotates),this._rotating=!1;else if(this._diffStates()){if(this.diagram.ruler)for(t=0;t<this.shapes.length;t++)n=this.shapes[t],r=n.bounds(),r=this._truncateSizeToGuides(this._truncatePositionToGuides(r)),n.bounds(r),this.refreshBounds(),this.refresh();for(t=0;t<this.shapes.length;t++){n=this.shapes[t],r=n.bounds();let e=n.shapeVisual?.options.stroke?.width||0;n._originalWidth+e!==r.width&&(n._originalWidth=r.width-e),n._originalHeight+e!==r.height&&(n._originalHeight=r.height-e),n.updateModel()}e=new Wh(this.shapes,this.shapeStates,this),this.diagram._syncShapeChanges()}}return this._interactionMeta=void 0,this._manipulating=void 0,this._internalChange=void 0,this._rotating=void 0,e}_diffStates(){let e=this.shapes,t=this.shapeStates;for(let n=0;n<e.length;n++)if(!e[n].bounds().equals(t[n]))return!0;return!1}refreshBounds(){let e=this.shapes.length===1?this.shapes[0].bounds().clone():this.diagram.boundingBox(this.shapes,!0);this.bounds(e)}refresh(){let e,t;if(this.shapes.length>0){t=this.bounds(),this.visual.visible(!0);let n=this.diagram.modelToLayer(this._innerBounds),r=this.diagram.zoom(),i=this.options.selectionRectOffset*r;this.visual.position(new G(n.x-i,n.y-i));let a=this._handleOptions(),o=q({opacity:1},a.fill),s=q({width:1,opacity:1},a.stroke);this.map.forEach(t=>{let n=new G(t.x,t.y),r=this._isResizeHandleVisible(n);e=this._getHandleBounds(n);let i=this._getResizeHandleVisualBounds(n,e);t.visual.position(i.topLeft()),t.visual.redraw({width:i.width,height:i.height,fill:r?o:{color:`transparent`,opacity:0},stroke:r?s:{color:`transparent`,width:0,opacity:0}}),t.visual.visible(r)});let c=new G(n.width/2+i,n.height/2+i);if(this.visual.rotate(this._angle,c),this.rect.position(new G(0,0)),this.rect.redraw({width:n.width+2*i,height:n.height+2*i}),this.rotationThumb){let e=this.options.editable.rotate.thumb;this._rotationThumbBounds=new K(t.center().x,t.y+e.y,0,0).inflate(e.width),this.rotationThumb.redraw({x:t.width/2-e.width/2})}}else this.visual.visible(!1)}};let Jh={stroke:{color:`#778899`,width:1,dashType:`dash`},fill:{color:g}};var Yh=class{constructor(e){let t=e.options.selectable;this.options=q({},Jh,t),this.visual=new X(this.options),this.diagram=e}start(e){this._sp=this._ep=e,this.refresh(),this.diagram._adorn(this,!0)}end(){this._sp=this._ep=void 0,this.diagram._adorn(this,!1)}bounds(e){return e&&(this._bounds=e),this._bounds}move(e){this._ep=e,this.refresh()}refresh(){if(this._sp){let e=K.fromPoints(this.diagram.modelToLayer(this._sp),this.diagram.modelToLayer(this._ep));this.bounds(K.fromPoints(this._sp,this._ep)),this.visual.position(e.topLeft()),this.visual.redraw({height:e.height+1,width:e.width+1})}}},Xh=class{constructor(){}},Zh=class extends Xh{constructor(e){super(),this.connection=e}hitTest(e){return this.getBounds().inflate(10).contains(e)?At.distanceToPolyline(e,this.connection.allPoints())<10:!1}getBounds(){let e=this.connection.allPoints(),t=e[0],n=e[e.length-1],r=Math.max(t.x,n.x),i=Math.min(t.x,n.x),a=Math.min(t.y,n.y),o=Math.max(t.y,n.y);for(let t=1;t<e.length-1;++t)r=Math.max(r,e[t].x),i=Math.min(i,e[t].x),a=Math.min(a,e[t].y),o=Math.max(o,e[t].y);return new K(i,a,r-i,o-a)}};let Qh=`topLeft`,$h=`bottomRight`;var eg=class extends Zh{constructor(e){super(e),this.SAME_SIDE_DISTANCE_RATIO=5,this._connectorSides=[{name:`Top`,axis:`y`,boundsPoint:Qh,secondarySign:1},{name:re,axis:`x`,boundsPoint:Qh,secondarySign:1},{name:ie,axis:`y`,boundsPoint:$h,secondarySign:-1},{name:ne,axis:`x`,boundsPoint:$h,secondarySign:-1}],this.connection=e}routePoints(e,t,n,r){let i=n?this._connectorSide(n,t):null,a=r?this._connectorSide(r,e):null;return this._createRoute(e,t,i,a,n)}route(){let e=this.connection._resolvedSourceConnector,t=this.connection._resolvedTargetConnector,n=this.connection.sourcePoint(),r=this.connection.targetPoint(),i=Rm([n,...this.routePoints(n,r,e,t),r]);this.connection.points(i.slice(1,-1))}_createRoute(e,t,n,r,i){let a=i||this.connection._resolvedSourceConnector,o={source:e,target:t,sourceSide:n,targetSide:r||Bm(e,t,this.connection.previewState,{hysteresis:8}),locks:this.connection.locks,anchorOffset:this.connection.options.anchorOffset,sameSideDistance:a?this._sameSideDistance(a):void 0},s=Im(o,this.connection.pointsEditable());return this.connection.route=s,this.connection.buildOptions=o,s.points}_connectorSide(e,t){let n=e.positionWithoutOffset(),r=e.shape.bounds(ge),i={topLeft:r.topLeft(),bottomRight:r.bottomRight()},a=this._connectorSides,o=Number.MAX_VALUE,s,c,l,u;for(let e=0;e<a.length;e++)u=a[e],l=u.axis,s=Math.round(Math.abs(n[l]-i[u.boundsPoint][l])),s<o?(o=s,c=u):s===o&&(n[l]-t[l])*u.secondarySign>(n[c.axis]-t[c.axis])*c.secondarySign&&(c=u);return c.name}_sameSideDistance(e){let t=e.shape.bounds(ge);return Math.min(t.width,t.height)/this.SAME_SIDE_DISTANCE_RATIO}},tg=class extends Zh{constructor(e){super(e),this.connection=e}route(){}_connectorSide(e,t){return null}},ng=class{constructor(e){this.toolService=e,this.type=`ConnectionTool`}tryActivate(e,t){let n=this.toolService,r=n.diagram.options.selectable,i=n.hoveredItem,a=r!==!1&&i&&i.path&&!(i.isSelected&&t.ctrlKey);return a&&(this._c=i),a}start(e,t,n){let r=this.toolService,i=this._c;r.selectSingle(i,t);let a=i.adorner,o,s;a&&(o=a._hitTest(e),s=ye[o]),Uh(i)&&a&&!r.diagram.trigger(`dragStart`,{shapes:[],connections:[i],connectionHandle:s,point:e,meta:t,nativeEvent:n})?(this.handle=o,this.handleName=s,a.start(e)):(r.startPoint=e,r.end(e,t,n))}move(e,t,n){let r=this._c.adorner;if(Uh(this._c)&&r)return r.move(this.handle,e),this.toolService.diagram.trigger(oe,{shapes:[],connections:[this._c],connectionHandle:this.handleName,point:e,meta:t,nativeEvent:n}),!0}end(e,t,n){let r=this._c,i=r.adorner,a=this.toolService.diagram;if(i&&Uh(r)){let o=i.stop(e);a.trigger(`dragEnd`,{shapes:[],connections:[r],connectionHandle:this.handleName,point:e,meta:t,nativeEvent:n})?o.undo():(a.undoRedoService.add(o,!1),r.updateModel(),a._syncConnectionChanges())}}getCursor(){return C.move}},rg=class{constructor(e){this.toolService=e,this.type=`ConnectionTool`}tryActivate(){return this.toolService._hoveredConnector}start(e,t,n){let r=this.toolService,i=r.diagram,a=r._hoveredConnector,o=i._createConnection({},a._c,e);Uh(o)&&!i.trigger(`dragStart`,{shapes:[],connections:[o],connectionHandle:`target`,point:e,meta:t,nativeEvent:n})&&i._addConnection(o)?(r._connectionManipulation(o,a._c.shape,!0),r._removeHover(),r.selectSingle(r.activeConnection,t),t.type===`touchmove`&&(i._cachedTouchTarget=a.visual)):(o.source(null),r.end(e,t,n))}move(e,t,n){let r=this.toolService,i=r.activeConnection,a=e,o=r._hoveredConnector;return o&&o._c!==i.sourceConnector&&(a=o._c.positionWithoutOffset()),i.target(a),r.diagram.trigger(oe,{shapes:[],connections:[i],connectionHandle:ve,point:e,meta:t,nativeEvent:n}),!0}end(e,t,n){let r=this.toolService,i=r.diagram,a=r.activeConnection,o=r.hoveredItem,s=r._hoveredConnector,c=i._cachedTouchTarget,l;a&&(l=s&&s._c!==a.sourceConnector?s._c:o&&o instanceof $?o.getConnector(`Auto`)||o.getConnector(e):e,a.target(l),i.trigger(`dragEnd`,{shapes:[],connections:[a],connectionHandle:`target`,point:e,meta:t,nativeEvent:n})?(i.remove(a,!1),i.undoRedoService.pop()):(a.updateModel(),i._syncConnectionChanges()),r._connectionManipulation(),c&&(i._connectorsAdorner.visual.remove(c),i._cachedTouchTarget=null))}getCursor(){return C.arrow}},ig=class{constructor(e){this.toolService=e}start(){}move(){}end(){}tryActivate(){return!1}getCursor(){return C.arrow}};function ag(e){return e.ctrlKey===!1&&e.altKey===!1&&e.shiftKey===!1}var og=class{constructor(e){this.toolService=e}tryActivate(){return!0}start(e,t,n){let r=this.toolService,i=r.diagram,a=r.hoveredItem;a&&(r.selectSingle(a,t),a.adorner&&(this.adorner=a.adorner,this.handle=this.adorner._hitTest(e))),this.handle||(this.handle=i._resizingAdorner._hitTest(e),this.handle&&(this.adorner=i._resizingAdorner)),this.adorner&&(!this.adorner.isDragHandle(this.handle)||!i.trigger(`dragStart`,{shapes:this.adorner.shapes,connections:[],point:e,nativeEvent:n,meta:t})?this.adorner.start(e,t):(r.startPoint=e,r.end(e,t,n)))}move(e,t,n){this.adorner&&(this.adorner.move(this.handle,e,t),this.adorner.isDragHandle(this.handle)&&this.toolService.diagram.trigger(oe,{shapes:this.adorner.shapes,connections:[],point:e,meta:t,nativeEvent:n}))}end(e,t,n){let r=this.toolService.diagram,i=this.adorner,a;i&&(!i.isDragHandle(this.handle)||!r.trigger(`dragEnd`,{shapes:i.shapes,connections:[],point:e,meta:t,nativeEvent:n})?(a=i.stop(),a&&r.undoRedoService.add(a,!1)):i.cancel()),this.adorner=void 0,this.handle=void 0}getCursor(e){return this.toolService.hoveredItem?this.toolService.hoveredItem._getCursor(e):C.arrow}};let sg={down:`pointerdown`,move:`pointermove`,up:`pointerup`,cancel:`pointercancel pointerleave`};function cg(e){return sg[e]||e}let lg=e=>e.replace(/([^ ]+)/g,cg),ug=Jn,dg=function(e,t,n){return`translate3d(`+e+`px,`+t+`px,0) scale(`+n+`)`};var fg=class extends Ct{constructor(e,t){super();let n=e[0]||e;this.element=n,this.capture=!1,this._pressHandler=this._press.bind(this),this._releaseHandler=this._release.bind(this),sg.down.split(` `).forEach(e=>{n.addEventListener(e,this._pressHandler,!0)}),sg.up.split(` `).forEach(e=>{n.addEventListener(e,this._releaseHandler,!0)}),this.bind([`press`,`release`],t||{})}captureNext(){this.capture=!0}cancelCapture(){this.capture=!1}_press(e){this.trigger(`press`),this.capture&&e.preventDefault()}_release(e){this.trigger(`release`),this.capture&&(e.preventDefault(),this.cancelCapture())}destroy(){let e=this.element;sg.down.split(` `).forEach(t=>{e.removeEventListener(t,this._pressHandler,!0)}),sg.up.split(` `).forEach(t=>{e.removeEventListener(t,this._releaseHandler,!0)})}},pg=class extends Ct{constructor(e){super(),this.forcedEnabled=!1,uh(this,e),this.scale=1,this.horizontal?(this.measure=`offsetWidth`,this.scrollSize=`scrollWidth`,this.axis=`x`):(this.measure=`offsetHeight`,this.scrollSize=`scrollHeight`,this.axis=`y`)}makeVirtual(){uh(this,{virtual:!0,forcedEnabled:!0,_virtualMin:0,_virtualMax:0})}virtualSize(e,t){(this._virtualMin!==e||this._virtualMax!==t)&&(this._virtualMin=e,this._virtualMax=t,this.update())}outOfBounds(e){return e>this.max||e<this.min}forceEnabled(){this.forcedEnabled=!0}getSize(){return this.container[this.measure]}getTotal(){return this.element[this.scrollSize]}rescale(e){this.scale=e}update(e){let t=this.virtual?this._virtualMax:this.getTotal(),n=t*this.scale,r=this.getSize();t===0&&!this.forcedEnabled||(this.max=this.virtual?-this._virtualMin:0,this.size=r,this.total=n,this.min=Math.min(this.max,r-n),this.minScale=r/t,this.centerOffset=(n-r)/2,this.enabled=this.forcedEnabled||n>r,e||this.trigger(te,this))}},mg=class extends Ct{constructor(e){super(),this.x=new pg(uh({horizontal:!0},e)),this.y=new pg(uh({horizontal:!1},e)),this.container=e.container,this.forcedMinScale=e.minScale,this.maxScale=e.maxScale||100,this.bind(te,e)}rescale(e){this.x.rescale(e),this.y.rescale(e),this.refresh()}centerCoordinates(){return{x:Math.min(0,-this.x.centerOffset),y:Math.min(0,-this.y.centerOffset)}}refresh(){this.x.update(),this.y.update(),this.enabled=this.x.enabled||this.y.enabled,this.minScale=this.forcedMinScale||Math.min(this.x.minScale,this.y.minScale),this.fitScale=Math.max(this.x.minScale,this.y.minScale),this.trigger(te)}},hg=class extends Ct{constructor(e){super(),uh(this,e)}outOfBounds(){return this.dimension.outOfBounds(this.movable[this.axis])}dragMove(e){let t=this.dimension,n=this.axis,r=this.movable,i=r[n]+e;if(!t.enabled)return;let a=e;(i<t.min&&e<0||i>t.max&&e>0)&&(a*=this.resistance),r.translateAxis(n,a),this.trigger(te,this)}},gg=class{constructor(e){let t,n;uh(this,{elastic:!0},e);let r=this.elastic?.5:0,i=this.movable;this.x=t=new hg({axis:`x`,dimension:this.dimensions.x,resistance:r,movable:i}),this.y=n=new hg({axis:`y`,dimension:this.dimensions.y,resistance:r,movable:i}),this.userEvents.bind([`press`,`move`,`end`,`gesturestart`,`gesturechange`],{gesturestart(e){this.gesture=e,this.offset=ug(this.dimensions.container)},press(e){let t=e.event.target.closest(`a`);t&&t.matches(`[data-navigate-on-press=true]`)&&e.sender.cancel()},gesturechange(e){let r=this.gesture,a=r.center,o=e.center,s=this.dimensions.minScale,c=this.dimensions.maxScale,l=e.distance/r.distance;i.scale<=s&&l<1&&(l+=(1-l)*.8),i.scale*l>=c&&(l=c/i.scale);let u=i.x+this.offset.left,d=i.y+this.offset.top,f={x:(u-a.x)*l+o.x-u,y:(d-a.y)*l+o.y-d};i.scaleWith(l),t.dragMove(f.x),n.dragMove(f.y),this.dimensions.rescale(i.scale),this.gesture=e,e.preventDefault()},move(e){e.event.target.tagName.match(/textarea|input/i)||(t.dimension.enabled||n.dimension.enabled?(t.dragMove(e.x.delta),n.dragMove(e.y.delta),e.preventDefault()):e.touch.skip())},end(e){e.preventDefault()}})}},_g=class extends Ct{constructor(e){super(),this.element=e,this.element.style.transformOrigin=`left top`,this.x=0,this.y=0,this.scale=1;let t=dg(this.x,this.y,this.scale);this.element.style.transform=t,this._saveCoordinates(t)}translateAxis(e,t){this[e]+=t,this.refresh()}scaleTo(e){this.scale=e,this.refresh()}scaleWith(e){this.scale*=e,this.refresh()}translate(e){this.x+=e.x,this.y+=e.y,this.refresh()}moveAxis(e,t,n=!1){this[e]=t,this.refresh(n)}moveTo(e,t=!1){uh(this,e),this.refresh(t)}refresh(e=!1){let t=this.x,n=this.y;this.round&&(t=Math.round(t),n=Math.round(n));let r=dg(t,n,this.scale);r!==this.coordinates&&(this.element.style.transform=r,this._saveCoordinates(r),e||this.trigger(te))}_saveCoordinates(e){this.coordinates=e}};function vg(e){window.requestAnimationFrame(e)}var yg=class{constructor(){this._tickProxy=()=>this._tick(),this._started=!1}tick(){}done(){return!1}onEnd(){}onCancel(){}start(){this.enabled()&&(this.done()?this.onEnd():(this._started=!0,vg(this._tickProxy)))}enabled(){return!0}cancel(){this._started=!1,this.onCancel()}_tick(){this._started&&(this.tick(),this.done()?(this._started=!1,this.onEnd()):vg(this._tickProxy))}},bg=class extends yg{constructor(e){super(),uh(this,e)}done(){return this.timePassed()>=this.duration}timePassed(){return Math.min(this.duration,dh()-this.startDate)}moveTo(e){let t=this.movable;this.initial=t[this.axis],this.delta=e.location-this.initial,this.duration=typeof e.duration==`number`?e.duration:300,this.tick=this._easeProxy(e.ease),this.startDate=dh(),this.start()}_easeProxy(e){return function(){this.movable.moveAxis(this.axis,e(this.timePassed(),this.initial,this.delta,this.duration))}}static easeOutExpo(e,t,n,r){return e===r?t+n:n*(-(2**(-10*e/r))+1)+t}};function xg(){let e=``,t,n;for(t=0;t<32;t++)n=Math.floor(Math.random()*16),(t===8||t===12||t===16||t===20)&&(e+=`-`),e+=(t===12?4:t===16?n%4+8:n).toString(16);return e}let Sg=new WeakMap,Cg=Symbol(`id`);function wg(e,t,n,r,i){Dg(e,t,n,r,i)}function Tg(e,t,n,r){kg(e,t,n,r)}function Eg(e){return typeof e==`string`}function Dg(e,t,n,r,i){(Array.isArray(t)?t:(t||``).split(` `)).forEach(function(t){Og(e,t,n,r,i)})}function Og(e,t,n,r,i){let a=r,o;n&&He(n)&&!r?a=n:n&&Eg(n)&&He(a)&&(o=n);let s=function(t){let n=t.target?t.target.closest(o):null;if(!o||o&&t.target&&n){let r=o?n:t.currentTarget;Object.defineProperty(t,"currentTarget",{value:r}),Object.defineProperty(t,"delegateTarget",{value:e}),a(t)}};a[Cg]||(a[Cg]=xg());let c=Sg.get(e);c||(c=new Map,Sg.set(e,c)),c.set(t+a[Cg],s),e.addEventListener(t,s,!!i)}function kg(e,t,n,r){(Array.isArray(t)?t:(t||``).split(` `)).forEach(function(t){Ag(e,t,n,r)})}function Ag(e,t,n,r){let i=Sg.get(e);if(i&&n&&n[Cg]){let a=t+n[Cg],o=i.get(a);i.delete(a),o&&e.removeEventListener(t,o,!!r)}}function jg(e,t){let n=e.length,r=[];for(let i=0;i<n;i++)t(e[i])&&r.push(e[i]);return r}let Mg=e=>{e.preventDefault()},Ng=()=>{},Pg=`press`,Fg=`hold`,Ig=`select`,Lg=`start`,Rg=`move`,zg=`cancel`,Bg=`doubleTap`,Vg=`release`,Hg=`gesturechange`,Ug=`gestureend`,Wg=`gesturetap`,Gg={api:0,touch:0,mouse:3,pointer:3},Kg=800,qg=0;function Jg(e,t){let n=e.x.location,r=e.y.location,i=t.x.location,a=t.y.location,o=n-i,s=r-a;return{center:{x:(n+i)/2,y:(r+a)/2},distance:Math.sqrt(o*o+s*s)}}function Yg(e){let t=[],n=e.originalEvent||e,r=e.currentTarget;return e.api?t.push({id:2,event:e,target:e.target,currentTarget:e.target,location:e,type:`api`}):t.push({location:n,event:e,target:e.target,currentTarget:r,id:n.pointerId,type:`pointer`}),t}var Xg=class{constructor(e,t){this.support=sh(),this.invalidZeroEvents=this.support.mobileOS&&this.support.mobileOS.android,this.axis=e,this._updateLocationData(t),this.startLocation=this.location,this.velocity=this.delta=0,this.timeStamp=dh()}move(e){let t=e[`page`+this.axis],n=dh(),r=n-this.timeStamp||1;!t&&this.invalidZeroEvents||(this.delta=t-this.location,this._updateLocationData(e),this.initialDelta=t-this.startLocation,this.velocity=this.delta/r,this.timeStamp=n)}_updateLocationData(e){let t=this.axis;this.location=e[`page`+t],this.client=e[`client`+t],this.screen=e[`screen`+t]}},Zg=class{constructor(e,t,n){uh(this,{x:new Xg(`X`,n.location),y:new Xg(`Y`,n.location),type:n.type,threshold:e.threshold||Gg[n.type],userEvents:e,target:t,currentTarget:n.currentTarget,initialTouch:n.target,id:n.id,pressEvent:n,_clicks:e._clicks,supportDoubleTap:e.supportDoubleTap,_moved:!1,_finished:!1})}press(){this._holdTimeout=setTimeout(()=>this._hold(),this.userEvents.minHold),this._trigger(Pg,this.pressEvent)}_tap(e){this.userEvents._clicks++,this.userEvents._clicks===1&&(this._clickTimeout=setTimeout(()=>{this.userEvents._clicks===1?this._trigger(`tap`,e):this._trigger(Bg,e),this.userEvents._clicks=0},300))}_hold(){this._trigger(Fg,this.pressEvent)}move(e){let t=e.type!==`api`&&this.userEvents._shouldNotMove;if(!(this._finished||t)){if(this.x.move(e.location),this.y.move(e.location),!this._moved){if(this._withinIgnoreThreshold())return;if(!$g.current||$g.current===this.userEvents)this._start(e);else return this.dispose()}this._finished||this._trigger(Rg,e)}}end(e){this.endTime=dh(),!this._finished&&(this._finished=!0,this._trigger(Vg,e),this._moved?this._trigger(`end`,e):this.supportDoubleTap?this._tap(e):this._trigger(`tap`,e),clearTimeout(this._holdTimeout),this.dispose())}dispose(){let e=this.userEvents.touches||[];this._finished=!0,this.pressEvent=null,clearTimeout(this._holdTimeout);let t=e.indexOf(this);e.splice(t,1)}skip(){this.dispose()}cancel(){this.dispose()}isMoved(){return this._moved}_start(e){clearTimeout(this._holdTimeout),this.startTime=dh(),this._moved=!0,this._trigger(Lg,e)}_trigger(e,t){let n=t.event,r={touch:this,x:this.x,y:this.y,target:this.target,event:n};this.userEvents.notify(e,r)&&n.preventDefault()}_withinIgnoreThreshold(){let e=this.x.initialDelta,t=this.y.initialDelta;return Math.sqrt(e*e+t*t)<=this.threshold}};function Qg(e){let t=sg.up.split(` `),n=t.length;for(let r=0;r<n;r++)e(t[r])}var $g=class e extends Ct{constructor(e,t){super();let n=sh();this.support=n,t||={},this.options=t;let r=this.filter=t.filter;if(this.threshold=t.threshold||qg,this.minHold=t.minHold||Kg,this.touches=[],this._maxTouches=t.multiTouch?2:1,this.allowSelection=t.allowSelection,this.captureUpIfMoved=t.captureUpIfMoved,this._clicks=0,this.supportDoubleTap=t.supportDoubleTap,uh(this,{element:e,surface:t.surface||e,stopPropagation:t.stopPropagation,pressed:!1}),this._surfaceMoveHandler=this._move.bind(this),wg(this.surface,lg(`move`),this._surfaceMoveHandler),this._surfaceEndHandler=this._end.bind(this),wg(this.surface,lg(`up cancel`),this._surfaceEndHandler),this._elementStartHandler=this._start.bind(this),wg(e,lg(`down`),r,this._elementStartHandler),e.style[`touch-action`]=t.touchAction||`none`,t.preventDragEvent&&(this._elementDragStartHandler=Mg,wg(e,lg(`dragstart`),this._elementDragStartHandler)),this._elementSelectHandler=this._select.bind(this),wg(e,lg(`mousedown`),r,this._elementSelectHandler),this.captureUpIfMoved){let e=this.surface;this.preventIfMovingProxy=this.preventIfMoving.bind(this),Qg(t=>{e.addEventListener(t,this.preventIfMovingProxy,!0)})}this.bind([Pg,Fg,`tap`,Bg,Lg,Rg,`end`,Vg,zg,`gesturestart`,Hg,Ug,Wg,Ig],t)}preventIfMoving(e){this._isMoved()&&e.preventDefault()}destroy(){let e=this.options,t=this.element;if(!this._destroyed){if(this._destroyed=!0,this.captureUpIfMoved){let e=this.surface;Qg(t=>{e.removeEventListener(t,this.preventIfMovingProxy,!0)})}Tg(this.surface,lg(`move`),this._surfaceMoveHandler),Tg(this.surface,lg(`up cancel`),this._surfaceEndHandler),Tg(t,lg(`down`),this._elementStartHandler),e.preventDragEvent&&Tg(t,lg(`dragstart`),this._elementDragStartHandler),Tg(t,lg(`mousedown`),this._elementSelectHandler),this._disposeAll(),this.unbind(),delete this.surface,delete this.element,delete this.currentTarget}}capture(){e.current=this}cancel(){this._disposeAll(),this.trigger(zg)}notify(e,t){let n=this.touches,r=e;if(this._isMultiTouch()){switch(r){case Rg:r=Hg;break;case`end`:r=Ug;break;case`tap`:r=Wg;break;default:break}uh(t,{touches:n},Jg(n[0],n[1]))}return this.trigger(r,uh(t,{type:r}))}press(e,t,n){this._apiCall(`_start`,e,t,n)}move(e,t){this._apiCall(`_move`,e,t)}end(e,t){this._apiCall(`_end`,e,t)}_isMultiTouch(){return this.touches.length>1}_maxTouchesReached(){return this.touches.length>=this._maxTouches}_disposeAll(){let e=this.touches;for(;e.length>0;)e.pop().dispose()}_isMoved(){return jg(this.touches,function(e){return e.isMoved()}).length}_select(e){(!this.allowSelection||this.trigger(Ig,{event:e}))&&e.preventDefault()}_start(t){if(t.which&&t.which>1||this._maxTouchesReached())return;e.current=null,this.currentTarget=t.currentTarget,this.stopPropagation&&t.stopPropagation();let n,r=Yg(t);for(let e=0;e<r.length&&!this._maxTouchesReached();e++){let t=r[e];if(n=this.filter?t.currentTarget:this.element,n&&n.length===0)continue;let i=new Zg(this,n,t);this.touches.push(i),i.press(),this._isMultiTouch()&&this.notify(`gesturestart`,{})}}_move(e){this._eachTouch(`move`,e)}_end(e){this._eachTouch(`end`,e)}_eachTouch(e,t){let n={},r=Yg(t),i=this.touches,a,o,s,c;for(a=0;a<i.length;a++)o=i[a],n[o.id]=o;for(a=0;a<r.length;a++)s=r[a],c=n[s.id],c&&(e===`move`&&s.type===`pointer`&&!this.surface.hasPointerCapture(s.id)&&this.surface.setPointerCapture(s.id),c[e](s))}_apiCall(e,t,n,r){this[e]({api:!0,pageX:t,pageY:n,clientX:t,clientY:n,target:r||this.element,stopPropagation:Ng,preventDefault:Ng})}static defaultThreshold(e){qg=e}static minHold(e){Kg=e}};let e_=Object.assign,t_=Math.abs,n_=`change`,r_=`scroll`;var i_=class extends yg{constructor(e){super(),e_(this,e),this.userEvents.bind(`gestureend`,this.start.bind(this)),this.tapCapture.bind(`press`,this.cancel.bind(this))}enabled(){return this.movable.scale<this.dimensions.minScale}done(){return this.dimensions.minScale-this.movable.scale<.01}tick(){let e=this.movable;e.scaleWith(1.1),this.dimensions.rescale(e.scale)}onEnd(){let e=this.movable;e.scaleTo(this.dimensions.minScale),this.dimensions.rescale(e.scale)}},a_=class extends yg{constructor(e){super(),e_(this,e,{transition:new bg({axis:e.axis,movable:e.movable,onEnd:()=>{this._end()}})}),this.tapCapture.bind(`press`,()=>{this.cancel()}),this.userEvents.bind(`end`,()=>this.start()),this.userEvents.bind(`gestureend`,()=>this.start()),this.userEvents.bind(`tap`,()=>this.onEnd())}onCancel(){this.transition.cancel()}freeze(e){this.cancel(),this._moveTo(e)}onEnd(){this.paneAxis.outOfBounds()?this._snapBack():this._end()}done(){return t_(this.velocity)<1}start(e){let t;this.dimension.enabled&&(this.paneAxis.outOfBounds()?this.transition._started?(this.transition.cancel(),this.velocity=Math.min(e.touch[this.axis].velocity*this.velocityMultiplier,55),super.start()):this._snapBack():(t=e?e.touch.id===2?0:e.touch[this.axis].velocity:0,this.velocity=Math.max(Math.min(t*this.velocityMultiplier,55),-55),this.tapCapture.captureNext(),super.start()))}tick(){let e=this.dimension,t=this.paneAxis.outOfBounds()?.5:this.friction,n=this.velocity*=t,r=this.movable[this.axis]+n;!this.elastic&&e.outOfBounds(r)&&(r=Math.max(Math.min(r,e.max),e.min),this.velocity=0),this.movable.moveAxis(this.axis,r)}_end(){this.tapCapture.cancelCapture(),this.end()}end(){}_snapBack(){let e=this.dimension,t=this.movable[this.axis]>e.max?e.max:e.min;this._moveTo(t)}_moveTo(e){this.transition.moveTo({location:e,duration:500,ease:(...e)=>{bg.easeOutExpo.apply(null,e)}})}},o_=class extends yg{constructor(e){super(),e_(this,e,{origin:{},destination:{},offset:{}})}moveTo(e){}tick(){this._updateCoordinates(),this.moveTo(this.origin)}done(){return t_(this.offset.y)<5&&t_(this.offset.x)<5}onEnd(){this.moveTo(this.destination),this.callback&&this.callback.call()}setCoordinates(e,t){this.offset={},this.origin=e,this.destination=t}setCallback(e){e&&He(e)?this.callback=e:e=void 0}_updateCoordinates(){this.offset={x:(this.destination.x-this.origin.x)/4,y:(this.destination.y-this.origin.y)/4},this.origin={y:this.origin.y+this.offset.y,x:this.origin.x+this.offset.x}}};let s_=e=>{e.stopPropagation()};var c_=class{constructor(e){this.stopPropagationEvents=[`mousedown`,`touchstart`,`pointerdown`,`mousemove`,`touchmove`,`pointermove`,`mouseup`,`touchend`,`pointerup`,`click`],this.containerEnterEvents=[`mouseenter`,`mouseover`],this.containerLeaveEvents=[`mouseleave`,`mouseout`],this.options=e,this.axis=e.axis,this.dimension=e.dimension,this.container=e.container,this.scrollMovable=e.movable,this.autoHideScrollbars=e.autoHideScrollbars;let t=e.axis===`x`;this.size=t?`width`:`height`,this.scrollMovable.bind(n_,this.refresh.bind(this)),e.showScrollbars&&this._create()}_create(){let e=this.axis===`x`,t=ph(`<div class="km-touch-scrollbar km-`+(e?`horizontal`:`vertical`)+`-scrollbar" />`);t.style.position=`absolute`,t.style.zIndex=`100000`,t.style.backgroundColor=`rgba(0, 0, 0, 0.3)`,t.style.borderRadius=`4px`,e?(t.style.bottom=`1px`,t.style.left=`1px`,t.style.height=`7px`):(t.style.top=`1px`,t.style.right=`1px`,t.style.width=`7px`),this.element=t,this.elementSize=0,this.movable=new _g(t),this.container.appendChild(t),this.userEvents=new $g(t,{fastTap:!0,preventDragEvent:!0,captureUpIfMoved:!0,start:e=>{this.start=this.movable[this.axis],this.startContent=this.scrollMovable[this.axis],e.event.stopPropagation()},move:e=>{this.change(e),e.event.preventDefault()}}),this.stopPropagationEvents.forEach(e=>{t.addEventListener(e,s_)}),this.autoHideScrollbars?this._toggleHoverListeners(!0):this.show(),this.refresh()}setOptions(e){this.options=e_(this.options,e),this.autoHideScrollbars=this.options.autoHideScrollbars,this.options.showScrollbars?this.element?this.autoHideScrollbars?(this._toggleHoverListeners(!0),this.hide()):(this.show(),this._toggleHoverListeners(!1)):this._create():this.element&&=(this.destroy(),null)}_toggleHoverListeners(e){e?(this.showDelegate||(this.showDelegate=this.show.bind(this),this.containerEnterEvents.forEach(e=>{this.container.addEventListener(e,this.showDelegate)})),this.hideDelegate||(this.hideDelegate=this.hide.bind(this),this.containerLeaveEvents.forEach(e=>{this.container.addEventListener(e,this.hideDelegate)}))):(this.showDelegate&&=(this.containerEnterEvents.forEach(e=>{this.container.removeEventListener(e,this.showDelegate)}),null),this.hideDelegate&&=(this.containerLeaveEvents.forEach(e=>{this.container.removeEventListener(e,this.hideDelegate)}),null))}destroy(){this._toggleHoverListeners(!1),this.element&&(this.stopPropagationEvents.forEach(e=>{this.element.removeEventListener(e,s_)}),this.userEvents.destroy(),this.element.parentNode?.removeChild(this.element))}refresh(){if(!this.element)return;let e=this.axis,t=this.dimension,n=t.size,r=this.scrollMovable,i=n/t.total,a=t.max,o=a-t.min,s=Math.round(n*i),c=0;if(o>0){let t=a-r[e];c=Math.round(t/o*(n-s))}c=Math.max(0,Math.min(c,n-s)),i>=1&&!this.autoHideScrollbars?this.element.style.display=`none`:this.element.style.display=`block`,this.elementSize!==s&&(this.element.style[this.size]=s+`px`,this.elementSize=s),this.movable.moveAxis(e,c)}change(e){if(!this.element.checkVisibility({opacityProperty:!0,visibilityProperty:!0}))return;let t=this.axis,n=this.dimension,r=n.size,i=n.max,a=n.min,o=i-a,s=r/n.total,c=r-Math.round(r*s),l=e[t].initialDelta;if(o>0&&c>0){let e=-(o/c*l),n=Math.min(Math.max(this.startContent+e,a),i);this.scrollMovable.moveAxis(t,n)}}show(){this.element&&(this.element.style.opacity=.7,this.element.style.visibility=`visible`)}hide(){this.element&&this.autoHideScrollbars&&(this.element.style.opacity=0)}};let l_={name:`Scroller`,zoom:!1,pullOffset:140,showScrollbars:!0,autoHideScrollbars:!1,elastic:!0,useNative:!1,mousewheelScrolling:!0,avoidScrolling:()=>!1,pullToRefresh:!1,messages:{pullTemplate:`Pull to refresh`,releaseTemplate:`Release to refresh`,refreshTemplate:`Refreshing`}};var u_=class extends Ct{constructor(e,t){super(),this.element=e=e[0]||e,this._initOptions(t),this.events.push(`pull`,r_,`resize`);let n=gh();this._native=this.options.useNative&&n;let r=ph(`<div class="km-scroll-header"/>`);if(this._native){fh(e,`km-native-scroller`),mh(r,e),e_(this,{scrollElement:e,fixedContainer:e.children[0]});return}e.style.overflow=`hidden`,fh(e,`km-scroll-wrapper`);let i=ph(`<div class="km-scroll-container"/>`);hh(e,i),mh(r,e);let a=e.children[1],o=new fg(e),s=new _g(a),c=new mg({element:a,container:e,forcedEnabled:this.options.zoom}),l=this.options.avoidScrolling,u=new $g(e,{touchAction:`none`,allowSelection:!0,preventDragEvent:!0,captureUpIfMoved:!0,multiTouch:this.options.zoom,supportDoubleTap:this.options.supportDoubleTap,start:e=>{c.refresh();let t=t_(e.x.velocity),n=t_(e.y.velocity),r=t*2>=n,i=this.fixedContainer.contains(e.event.target),a=n*2>=t;!i&&!l(e)&&this.enabled&&(c.x.enabled&&r||c.y.enabled&&a)?u.capture():u.cancel()}}),d=new gg({movable:s,dimensions:c,userEvents:u,elastic:this.options.elastic}),f=new i_({movable:s,dimensions:c,userEvents:u,tapCapture:o}),p=new o_({moveTo:e=>{this.scrollTo(e.x,e.y)}});s.bind(n_,()=>{this.scrollTop=-s.y,this.scrollLeft=-s.x,!this._skipScrollEvent&&this.trigger(r_,{scrollTop:this.scrollTop,scrollLeft:this.scrollLeft})}),this.options.mousewheelScrolling&&(this._wheelScrollHandler=this._wheelScroll.bind(this),wg(e,`wheel`,this._wheelScrollHandler)),e_(this,{movable:s,dimensions:c,zoomSnapBack:f,animatedScroller:p,userEvents:u,pane:d,tapCapture:o,pulled:!1,enabled:!0,scrollElement:a,scrollTop:0,scrollLeft:0,fixedContainer:e.children[0]}),this._initAxis(`x`),this._initAxis(`y`),this._wheelEnd=()=>{this._wheel=!1,this.userEvents.end(0,this._wheelY)},c.refresh(),this.options.pullToRefresh&&this._initPullToRefresh(),this.bind(this.events,this.options)}_initOptions(e){this.options=q({},this.options,l_,e)}_wheelScroll(e){if(e.ctrlKey)return;this._wheel||(this._wheel=!0,this._wheelY=0,this.userEvents.press(0,this._wheelY)),clearTimeout(this._wheelTimeout),this._wheelTimeout=setTimeout(()=>this._wheelEnd(),50);let t=_h(e);t&&(this._wheelY+=t,this.userEvents.move(0,this._wheelY)),e.preventDefault()}makeVirtual(){this.dimensions.y.makeVirtual()}virtualSize(e,t){this.dimensions.y.virtualSize(e,t)}height(){return this.dimensions.y.size}scrollHeight(){return this.scrollElement.scrollHeight}scrollWidth(){return this.scrollElement.scrollWidth}_resize(){this._native||this.contentResized()}setOptions(e){this._initOptions(e),this.xScrollBar&&this.xScrollBar.setOptions(this.options),this.yScrollBar&&this.yScrollBar.setOptions(this.options),e.pullToRefresh&&this._initPullToRefresh()}reset(){this._native?this.scrollElement.scrollTop(0):(this.movable.moveTo({x:0,y:0}),this._scale(1))}contentResized(){this.dimensions.refresh(),this.pane.x.outOfBounds()&&this.movable.moveAxis(`x`,this.dimensions.x.min),this.pane.y.outOfBounds()&&this.movable.moveAxis(`y`,this.dimensions.y.min)}zoomOut(){let e=this.dimensions;e.refresh(),this._scale(e.fitScale),this.movable.moveTo(e.centerCoordinates())}enable(){this.enabled=!0}disable(){this.enabled=!1}scrollTo(e,t,n=!1){this._native?(this.scrollElement.scrollLeft(t_(e)),this.scrollElement.scrollTop(t_(t))):(this.dimensions.refresh(),n&&(this._skipScrollEvent=!0),this.movable.moveTo({x:e,y:t}),n&&(this._skipScrollEvent=!1))}animatedScrollTo(e,t,n){let r,i;this._native?this.scrollTo(e,t):(r={x:this.movable.x,y:this.movable.y},i={x:e,y:t},this.animatedScroller.setCoordinates(r,i),this.animatedScroller.setCallback(n),this.animatedScroller.start())}pullHandled(){}destroy(){let e=this.element;Tg(e,`wheel`,this._wheelScrollHandler),this.userEvents&&this.userEvents.destroy(),this.tapCapture&&this.tapCapture.destroy(),this.xScrollBar&&this.xScrollBar.destroy(),this.yScrollBar&&this.yScrollBar.destroy()}_scale(e){this.dimensions.rescale(e),this.movable.scaleTo(e)}_initPullToRefresh(){}_dragEnd(){}_paneChange(){}_initAxis(e){let t=this.movable,n=this.dimensions[e],r=this.tapCapture,i=this.pane[e],a=new c_({axis:e,movable:t,dimension:n,container:this.element,showScrollbars:this.options.showScrollbars,autoHideScrollbars:this.options.autoHideScrollbars});e===`x`?this.xScrollBar=a:this.yScrollBar=a,n.bind(n_,()=>{a.refresh()}),i.bind(n_,()=>{a.show()}),this[e+`inertia`]=new a_({axis:e,paneAxis:i,movable:t,tapCapture:r,userEvents:this.userEvents,dimension:n,elastic:this.options.elastic,friction:this.options.friction||.96,velocityMultiplier:this.options.velocityMultiplier||10,end:()=>{a.hide(),this.trigger(`scrollEnd`,{axis:e,scrollTop:this.scrollTop,scrollLeft:this.scrollLeft})}})}};function d_(){return/Macintosh|iPhone|iPad/i.test((window==null?void 0:window.navigator)?.userAgent||``)}let f_=new K(-500,-500,1e3,1e3);var p_=class extends ig{constructor(e){super(e),this.useMiddleButton=!0,this._init()}_init(){let e=this.toolService.diagram,t=e.canvas,n=e._mobileOS()?.93:.9,r=e.options.pannable,i=e.scroller=this.scroller=new u_(e.scrollable,{friction:n,velocityMultiplier:5,mousewheelScrolling:!1,zoom:!1,elastic:!1,scroll:this._move.bind(this),showScrollbars:r&&r.showScrollbars,autoHideScrollbars:r&&r.autoHideScrollbars});t.translate&&(this.movableCanvas=new _g(t.element)),this._updateVirtualSize(),e.bind(pe,t=>{i.dimensions.rescale(t.zoom),this._scheduleVirtualSizeUpdate();let n=e.pan().times(-1);i.scrollTo(n.x,n.y,!0)}),e.bind(te,()=>{this._scheduleVirtualSizeUpdate()}),e.bind(oe,()=>{this._scheduleVirtualSizeUpdate()}),e.bind(se,()=>{this._scheduleVirtualSizeUpdate()}),i.disable()}updateOptions(){let e=this.toolService.diagram.options.pannable;this.scroller&&e&&(this.scroller.setOptions({showScrollbars:e.showScrollbars,autoHideScrollbars:e.autoHideScrollbars}),this._updateVirtualSize())}_updateVirtualSize(){let e=this.toolService.diagram,t=this.scroller,n=e._zoom||1,r=this._getContentBounds(),i=e.viewport(),a=Math.max(i.width,i.height,1e3)/n,o=r.x-a,s=r.y-a,c=r.width+a*2,l=r.height+a*2,u=function(e,t,n){e.makeVirtual(),e.virtualSize(t,n)};u(t.dimensions.x,o,c),u(t.dimensions.y,s,l)}_getContentBounds(){let e=this.toolService.diagram;if(e.shapes.length===0&&e.connections.length===0)return f_;let t=e.boundingBox(e.shapes);for(let n=0;n<e.connections.length;n++){let r=e.connections[n].bounds();r&&(t=t.isEmpty()?r.clone():t.union(r))}return t.isEmpty()?f_:t}_scheduleVirtualSizeUpdate(){this._virtualSizeUpdateScheduled||(this._virtualSizeUpdateScheduled=!0,requestAnimationFrame(()=>{this._updateVirtualSize(),this._virtualSizeUpdateScheduled=!1}))}tryActivate(e,t){let n=this.toolService,r=n.diagram.options.pannable,i=t.metaKey&&d_(),a=t.ctrlKey||i;return t.middleButton?a=!0:E(r.key)&&(!r.key||r.key===`none`?a=ag(t)&&!E(n.hoveredItem):(a=t[r.key+`Key`],a||=r.key===`ctrl`&&i)),a||=n.diagram.panMode(),r!==!1&&a&&!E(n.hoveredAdorner)&&!E(n._hoveredConnector)}start(e,t){this._isMiddleButtonPan=!!(t&&t.middleButton),this._isMiddleButtonPan||this.scroller.enable()}move(e,t,n){if(this._isMiddleButtonPan&&n){let e=this.toolService.diagram,t=n.movementX||0,r=n.movementY||0;if(t!==0||r!==0){let n=e.pan();e.pan(new G(n.x-t,n.y-r))}}}_move(e){let t=this.toolService.diagram,n=t.canvas,r=new G(e.scrollLeft,e.scrollTop);n.translate?(t._storePan(r.times(-1)),this.movableCanvas.moveTo(r),n.translate(r.x,r.y)):r=r.plus(t._pan.times(-1)),t.trigger(`pan`,{pan:r})}end(){this._isMiddleButtonPan||this.scroller.disable(),this._isMiddleButtonPan=!1}getCursor(){return C.grabbing}},m_=class{constructor(e){this.toolService=e}tryActivate(e,t){let n=this.toolService,r=n.diagram.options.selectable,i=r&&r.multiple!==!1;return i&&=r.key&&r.key!==`none`?t[r.key+`Key`]:ag(t),i&&!E(n.hoveredItem)&&!E(n.hoveredAdorner)}start(e){let t=this.toolService.diagram;t.deselect(),t.selector.start(e)}move(e){this.toolService.diagram.selector.move(e)}end(e,t){let n=this.toolService.diagram,r=this.toolService.hoveredItem,i=n.selector.bounds();(!r||!r.isSelected)&&!t.ctrlKey&&n.deselect(),i.isEmpty()||n.selectArea(i),n.selector.end()}getCursor(){return C.arrow}};function h_(e,t){return t.charCodeAt(0)===e||t.toUpperCase().charCodeAt(0)===e}var g_=class{constructor(e){this.toolService=e,this.type=`ConnectionResizeTool`}tryActivate(e,t){let n=this.toolService.hoveredItem,r=(n&&n.pointsEditable&&n.pointsEditable())!==!1&&n&&n.path&&n.isSelected&&n.resizeAdorner&&n.resizeAdorner._hitTest(e)!==null&&!t.ctrlKey;return r&&(this._c=n,this.handle=n.resizeAdorner._hitTest(e)),!!r}start(e,t,n){let r=this._c,i=r.resizeAdorner,a=Uh(r),o=this.toolService.diagram.trigger(ae,{shapes:[],connections:[r],point:e,meta:t,nativeEvent:n});a&&i&&this.handle&&!o?i.start(e):(this.toolService.startPoint=e,this.toolService.end(e,t,n))}move(e,t,n){let r=this._c.resizeAdorner;if(Uh(this._c)&&r&&this.handle)return r.move(this.handle,e),this.toolService.diagram.trigger(oe,{shapes:[],connections:[this._c],point:e,meta:t,nativeEvent:n}),!0}end(e,t,n){let r=this._c,i=r.resizeAdorner,a=this.toolService.diagram;if(i&&Uh(r)){let o=i.stop(e);o&&!a.trigger(`dragEnd`,{shapes:[],connections:[r],point:e,meta:t,nativeEvent:n})?(a.undoRedoService.add(o,!1),r.updateModel(),a._syncConnectionChanges()):o?o.undo():i.cancel()}}getCursor(e){let t=this._c;return t&&t.resizeAdorner&&this.handle?t.resizeAdorner._getCursor(this.handle.point):C.move}},__=class{constructor(e,t,n){this.item=e,this._redoSource=t,this._redoTarget=n,E(t)&&(this._undoSource=e.source()),E(n)&&(this._undoTarget=e.target()),this.title=be}undo(){this._undoSource!==void 0&&this.item._updateConnector(this._undoSource,_e),this._undoTarget!==void 0&&this.item._updateConnector(this._undoTarget,ve),this.item.updateModel()}redo(){this._redoSource!==void 0&&this.item._updateConnector(this._redoSource,_e),this._redoTarget!==void 0&&this.item._updateConnector(this._redoTarget,ve),this.item.updateModel()}};let v_={hover:{stroke:{}},startCap:we,endCap:we,cornerRadius:0,anchorOffset:20,points:[],selectable:!0,fromConnector:w,toConnector:w},y_=e=>({...e,padding:void 0,margin:e.margin===void 0?0:e.margin,textPadding:e.padding,background:e.position===`inline`?e.background||e.bgColor:e.background,bgColor:void 0});var b_=class e extends xh{constructor(e,t,n={}){n=q({},v_,n),super(n),this.name=ze,this.previewState={lastSide:null},this.routingMode=`auto`,this.updateOptionsFromModel(),this._initRouter(),this.path=new zp(this.options),this.path.fill(g),this.visual.append(this.path),this._sourcePoint=this._targetPoint=new G,this._setSource(e),this._setTarget(t),this.content(this.options.content),this.definers=[],n.points&&this.points(n.points),n.locks?this.locks=n.locks.map(e=>({...e})):this.locks=[]}_getCursor(e){if(this.resizeAdorner){let t=this.resizeAdorner._getCursor(e);if(t!==C.select)return t}return this.adorner?this.adorner._getCursor(e):this.options.cursor||C.select}_setOptionsFromModel(e){this.updateOptionsFromModel(e||this.dataItem)}updateOptionsFromModel(e){if(this.diagram&&this.diagram._isEditable){let t=this.diagram._dataMap,n=Jm(e||this.dataItem);if(e){if(E(n.from)){let e=t[n.from];e&&E(n.fromConnector)&&(e=e.getConnector(n.fromConnector)),this.source(e)}else E(n.fromX)&&E(n.fromY)&&this.source(new G(n.fromX,n.fromY));if(E(n.to)){let e=t[n.to];e&&E(n.toConnector)&&(e=e.getConnector(n.toConnector)),this.target(e)}else E(n.toX)&&E(n.toY)&&this.target(new G(n.toX,n.toY));E(n.type)&&this.type()!==n.type&&(this.points([]),this.type(n.type)),this.dataItem=e,this._template(),this.redraw(this.options)}else this.options=q({},n,this.options)}}updateModel(e){this.diagram&&this.diagram._isEditable&&this.diagram.updateConnectionModel(this,e)}sourcePoint(){return this._resolvedSourceConnector?this._resolvedSourceConnector.positionWithoutOffset():this._sourcePoint}_setSource(e){let t=e instanceof $,n=this.options.fromConnector||`Auto`,r;t&&!e.getConnector(n)||(e!==void 0&&(this.from=e),this._removeFromSourceConnector(),e===null?this.sourceConnector&&(this._sourcePoint=(this._resolvedSourceConnector||this.sourceConnector).positionWithoutOffset(),this._clearSourceConnector(),this._setFromOptions(null,this._sourcePoint)):e instanceof th?(r=e.shape.dataItem,r&&this._setFromOptions(r.id),this.sourceConnector=e,this.sourceConnector.connections.push(this)):e instanceof G?(this._setFromOptions(null,e),this._sourcePoint=e,this.sourceConnector&&this._clearSourceConnector()):t&&(r=e.dataItem,r&&this._setFromOptions(r.id),this.sourceConnector=e.getConnector(n),this.sourceConnector.connections.push(this)))}source(e,t){return T(e)&&(t&&this.diagram&&this.diagram.undoRedoService.addCompositeItem(new __(this,e)),this._setSource(e),this.refresh()),this.sourceConnector?this.sourceConnector:this._sourcePoint}_setFromOptions(e,t){this.options.from=e,t?(this.options.fromX=t.x,this.options.fromY=t.y):(this.options.fromX=null,this.options.fromY=null)}sourceDefiner(e){if(e)if(e instanceof xf)e.left=null,this._sourceDefiner=e,this.source(e.point);else throw Error(`The sourceDefiner needs to be a PathDefiner.`);else return this._sourceDefiner||=new xf(this.sourcePoint(),null,null),this._sourceDefiner}targetPoint(){return this._resolvedTargetConnector?this._resolvedTargetConnector.positionWithoutOffset():this._targetPoint}_setTarget(e){let t=e instanceof $,n=this.options.toConnector||`Auto`,r;t&&!e.getConnector(n)||(e!==void 0&&(this.to=e),this._removeFromTargetConnector(),e===null?this.targetConnector&&(this._targetPoint=(this._resolvedTargetConnector||this.targetConnector).positionWithoutOffset(),this._clearTargetConnector(),this._setToOptions(null,this._targetPoint)):e instanceof th?(r=e.shape.dataItem,r&&this._setToOptions(r.id),this.targetConnector=e,this.targetConnector.connections.push(this)):e instanceof G?(this._setToOptions(null,e),this._targetPoint=e,this.targetConnector&&this._clearTargetConnector()):t&&(r=e.dataItem,r&&this._setToOptions(r.id),this.targetConnector=e.getConnector(n),this.targetConnector.connections.push(this)))}target(e,t){return T(e)&&(t&&this.diagram&&this.diagram.undoRedoService.addCompositeItem(new __(this,void 0,e)),this._setTarget(e),this.refresh()),this.targetConnector?this.targetConnector:this._targetPoint}_setToOptions(e,t){this.options.to=e,t?(this.options.toX=t.x,this.options.toY=t.y):(this.options.toX=null,this.options.toY=null)}targetDefiner(e){if(e)if(e instanceof xf)e.right=null,this._targetDefiner=e,this.target(e.point);else throw Error(`The sourceDefiner needs to be a PathDefiner.`);else return this._targetDefiner||=new xf(this.targetPoint(),null,null),this._targetDefiner}_updateConnectors(){this._updateConnector(this.source(),_e),this._updateConnector(this.target(),ve)}_updateConnector(e,t){let n=this.diagram;if(e instanceof th&&!n.getShapeById(e.shape.id)){let r=e.shape.dataItem,i=e.options.name,a=()=>{e=n._dataMap[r.id].getConnector(i),this[t](e,!1),this.updateModel()};if(n._dataMap[r.id])a();else{let e=n._inactiveShapeItems.getByUid(r.uid);e&&n._deferredConnectionUpdates.push(e.onActivate(a))}}else this[t](e,!1)}content(e){let t=this._content(e);return E(e)&&(this._contentVisual&&(this._contentVisual._measured=!1),this._alignContent()),t}_createContentVisual(e){let t,n=e.visual,r=e.template,i=uh({},e,{dataItem:this.dataItem||e.dataItem}),a=oh(i);if(n)t=He(a)?a.call(this,i):null;else if(r){let e=He(a)?a.call(this,i.dataItem||{}):null;if(He(e))t=e;else if(O(e)){let n={...i,text:e};t=new(vh(n))(y_(n))}}else(e.text||e.blocks)&&(t=new(vh(e))(y_(e)));return t&&(this._contentVisual=t,t._includeInBBox=!1,this.visual.append(t)),t}_updateContentVisual(e){He(e.visual)?(this.visual.remove(this._contentVisual),this._createContentVisual(e)):this._contentVisual.redraw(y_(e))}_alignContent(){if(this._contentVisual){let e=this.options.content||{},t=e.offset===void 0?5:e.offset,n=this.allPoints(),r=Math.floor(n.length/2),i=r-1;for(;i>0&&n[i].equals(n[r]);)i--,r++;let a=n[r],o=n[i],s=this._contentVisual._measure(),c=s.width,l=s.height,u=n.length%2==0,d=o.distanceTo(a),f=e.position||{},p=f.vertical||`top`,m=f.horizontal||`right`,h=f===`inline`,g=0,_=0;if(this._contentVisual._textOnlyRect){let t=this._contentVisual._textOnlyRect;c=t.size.width,l=t.size.height,(h||e.border)&&(g=t.origin.x,_=t.origin.y)}u&&n.length>2&&d>0&&(o.y===a.y&&d<c||o.x===a.x&&d<l)&&(u=!1);let v=`left`,y=`bottom`,b;if(u){let e=An(Math.atan2(a.y-o.y,a.x-o.x));b=new G((a.x-o.x)/2+o.x,(a.y-o.y)/2+o.y),h?(b.x-=c/2+g,b.y-=l/2+_):Math.abs(e)===90?(m===v?b.x-=c+t:b.x+=t,b.y-=l/2):e%180==0?(b.x-=c/2,p===y?b.y+=t:b.y-=l+t):e<-90||0<e&&e<90?b.y-=l:(e<0||e>90)&&(b.x-=c,b.y-=l)}else{let e=Math.floor(n.length/2);b=n[e].clone(),o=n[e-1],a=n[e+1];let r=o.x===b.x&&a.x===b.x,i=o.y===b.y&&a.y===b.y,u,d;h?(u=-(c/2+g),d=-(l/2+_)):r?(u=m===v?-s.width-t:t,d=-s.height/2):i?(u=-s.width/2,d=p===y?t:-s.height-t):(u=o.x<=b.x&&a.x<=b.x?t:-s.width-t,d=o.y<=b.y&&a.y<=b.y?t:-s.height-t),b.x+=u,b.y+=d}this._contentVisual.position(b)}}select(e){let t=this.diagram,n,r;if(this._canSelect()&&this.isSelected!==e){if(this.isSelected=e,n=[],r=[],this.isSelected){this.adorner=new kh(this,this.options.selection),t._adorn(this.adorner,!0);let e=(this.options.type||``).toLowerCase()===`cascading`?zh:Bh,r=this._resolveResizeOptions();this.resizeAdorner=new e(this,r),t._adorn(this.resizeAdorner,!0),t._selectedItems.push(this),n.push(this)}else this.adorner&&=(t._adorn(this.adorner,!1),void 0),this.resizeAdorner&&=(t._adorn(this.resizeAdorner,!1),void 0),A(t._selectedItems,this),r.push(this);return this.adorner&&this.adorner.refresh(),this.resizeAdorner&&this.resizeAdorner.refresh(),t._internalSelection||t._selectionChanged(n,r),!0}}bounds(e){if(e&&!O(e))this._bounds=e;else return this._bounds}type(e){let t=this.options;if(e)e!==t.type&&(t.type=e,this._initRouter(),this.refresh());else return t.type}_initRouter(){(this.options.type||``).toLowerCase()===`cascading`?this._router=new eg(this):this._router=new tg(this)}points(e){if(e){this.definers=[];for(let t=0;t<e.length;t++){let n=e[t];if(n instanceof G)this.definers.push(new xf(n));else if(Object.prototype.hasOwnProperty.call(n,`x`)&&Object.prototype.hasOwnProperty.call(n,`y`))this.definers.push(new xf(new G(n.x,n.y)));else throw Error(`A Connection point needs to be a Point or an object with x and y properties.`)}}else{let e=[];if(T(this.definers))for(let t=0;t<this.definers.length;t++)e.push(this.definers[t].point);return e}}allPoints(){let e=[this.sourcePoint()];if(this.definers)for(let t=0;t<this.definers.length;t++)e.push(this.definers[t].point);return e.push(this.targetPoint()),e}refresh(){this._resolveConnectors(),this._refreshPath(),this._alignContent(),this.adorner&&this.adorner.refresh(),this.resizeAdorner&&this.resizeAdorner.refresh()}_resolveConnectors(e){let t=e||this;t._resolvedSourceConnector=void 0,t._resolvedTargetConnector=void 0;let n=this.source(),r=this.target(),i=r instanceof G?r:null,a=n instanceof G?n:null;if(n instanceof th){let e=Um(n)?n.shape.connectors:[n];i&&Um(n)?t._resolvedSourceConnector=Wm(i,e):Um(n)||(t._resolvedSourceConnector=n)}if(r instanceof th){let e=Um(r)?r.shape.connectors:[r];a&&Um(r)?t._resolvedTargetConnector=Wm(a,e):Um(r)||(t._resolvedTargetConnector=r)}if(!i&&!a&&n instanceof th&&r instanceof th){let t=Um(n)?n.shape.connectors:[n],i=Um(r)?r.shape.connectors:[r];this._resolveAutoConnectors(t,i,e)}}_resolveAutoConnectors(e,t,n){let r=n||this;if(this.pointsEditable()&&(this.routingMode===`manual`||this._hasPolylineEditedPoints())){this._resolveAutoConnectorsWithLocks(e,t,n);return}let i=Se,a=Se,o,s,c,l,u,d,f,p,m,h,g;for(m=0;m<e.length;m++)if(f=e[m],!Um(f))for(c=f.positionWithoutOffset(),h=0;h<t.length;h++)p=t[h],Um(p)||(l=p.positionWithoutOffset(),g=Math.round(c.distanceTo(l)),g<i&&this.diagram&&this._testRoutePoints(c,l,f,p)&&(i=g,o=f,s=p),g<a&&(u=f,d=p,a=g));o&&(u=o,d=s),r._resolvedSourceConnector=u,r._resolvedTargetConnector=d}_hasPolylineEditedPoints(){return this._router instanceof tg&&this.definers&&this.definers.length>0}_resolveAutoConnectorsWithLocks(e,t,n){let r=n||this,i=Se,a=Se,o,s,c,l;for(let n=0;n<e.length;n++){let r=e[n];if(Um(r))continue;let u=r.positionWithoutOffset();for(let e=0;e<t.length;e++){let n=t[e];if(Um(n))continue;let d=n.positionWithoutOffset(),f=this._calculateRouteLength(u,d,r,n);this.diagram&&this._testRoutePoints(u,d,r,n)&&f<a&&(a=f,c=r,l=n),f<i&&(i=f,o=r,s=n)}}c?(r._resolvedSourceConnector=c,r._resolvedTargetConnector=l):(r._resolvedSourceConnector=o,r._resolvedTargetConnector=s)}_calculateRouteLength(e,t,n,r){let i=this._router;if(i instanceof eg){let a=[e,...i.routePoints(e,t,n,r),t],o=0;for(let e=1;e<a.length;e++)o+=a[e-1].distanceTo(a[e]);return Math.round(o)}else if(this._hasPolylineEditedPoints()){let n=[e,...this.definers.map(e=>e.point),t],r=0;for(let e=1;e<n.length;e++)r+=n[e-1].distanceTo(n[e]);return Math.round(r)}return Math.round(e.distanceTo(t))}_testRoutePoints(e,t,n,r){let i=this._router,a=!0;if(i instanceof eg){let o=i.routePoints(e,t,n,r),s=this._getRouteExclude(e,t,n.shape,r.shape),c,l,u;o.unshift(e),o.push(t);for(let e=1;e<o.length;e++)if(c=o[e-1],l=o[e],u=new K(Math.min(c.x,l.x),Math.min(c.y,l.y),Math.abs(c.x-l.x),Math.abs(c.y-l.y)),u.width>0&&(u.x++,u.width-=2),u.height>0&&(u.y++,u.height-=2),!u.isEmpty()&&this.diagram._shapesQuadTree.hitTestRect(u,s)){a=!1;break}}return a}_getRouteExclude(e,t,n,r){let i=[];return this._isPointInsideShape(e,n)&&i.push(n),this._isPointInsideShape(t,r)&&i.push(r),i}_isPointInsideShape(e,t){let n=t.bounds(),r=t.rotate().angle,i=n.x,a=n.y,o=e.clone().rotate(r,n.center()),s=o.x,c=o.y;return s>i&&s<i+n.width&&c>a&&c<a+n.height}redraw(e){if(e){this.options=q({},this.options,e);let t=this.options.points;E(t)&&t.length>0&&(this.points(t),this._refreshPath()),(e&&e.content||e.text)&&this.content(e.content),this.path.redraw({fill:e.fill,stroke:e.stroke,startCap:e.startCap,endCap:e.endCap})}}clone(){let t=this.serialize();return this.diagram&&this.diagram._isEditable&&E(this.dataItem)&&(t.options.dataItem=this.diagram.options.cloneDataItem(this.dataItem)),new e(this.from,this.to,t.options)}serialize(){let e=this.from.toJSON?this.from.toJSON:this.from.toString(),t=this.to.toJSON?this.to.toJSON:this.to.toString(),n=q({},{options:this.options,from:e,to:t});return E(this.dataItem)&&(n.dataItem=this.dataItem.toString()),n.options.points=this.points(),this.locks&&this.locks.length>0&&(n.options.locks=this.locks.map(e=>({...e}))),n}_hitTest(e){if(this.visible()){let t=new G(e.x,e.y),n=this.sourcePoint(),r=this.targetPoint();if(e.isEmpty&&!e.isEmpty()&&e.contains(n)&&e.contains(r)||this._router.hitTest(t))return this}}_hover(e){let t=(this.options.stroke||{}).color;e&&T(this.options.hover.stroke.color)&&(t=this.options.hover.stroke.color),this.path.redraw({stroke:{color:t}})}_refreshPath(){E(this.path)&&(this._drawPath(),this.bounds(this._router.getBounds()))}_drawPath(){this._router&&this._router.route();let e=this.sourcePoint(),t=this.targetPoint(),n=this.points();this.path.redraw({points:[e].concat(n,[t])})}_clearSourceConnector(){this.sourceConnector=void 0,this._resolvedSourceConnector=void 0}_clearTargetConnector(){this.targetConnector=void 0,this._resolvedTargetConnector=void 0}_removeFromSourceConnector(){this.sourceConnector&&A(this.sourceConnector.connections,this)}_removeFromTargetConnector(){this.targetConnector&&A(this.targetConnector.connections,this)}toJSON(){let e,t,n;return this.from&&this.from.toJSON?e=this.from.toJSON():(n=this._sourcePoint,e={x:n.x,y:n.y}),this.to&&this.to.toJSON?t=this.to.toJSON():(n=this._targetPoint,t={x:n.x,y:n.y}),{from:e,to:t}}focus(){this.path.drawingElement.options.set(Be,Oe)}blur(){this.path.drawingElement.options.set(Be,``)}pointsEditable(){let e=this.options.editable;return e&&typeof e!=`boolean`&&(e=e.points),e!==!1}_resolveResizeOptions(){let e=this.options.editable?.points,t=this.diagram?.options.connectionDefaults?.editable?.points;return e===!0&&!t?this.diagram._theme.connectionDefaults.editable.points:e}};let x_=N;function S_(e,t){let n,r,i;for(let a=0;a<e.connectors.length;a++)if(n=e.connectors[a],r=n.position(),i=new K(r.x,r.y),i.inflate(10,10),i.contains(t))return n}var C_=class{constructor(e){this.diagram=e,this.tools=[new p_(this),new g_(this),new ng(this),new rg(this),new m_(this),new og(this)],this.activeTool=void 0}start(e,t,n){return t=q({},t),this.activeTool&&this.activeTool.end(e,t),this._updateHoveredItem(e,t,n),this._activateTool(e,t),this.activeTool?(this.activeTool.start(e,t,n),this._updateCursor(e),this.diagram.focus(),this.diagram.canvas.surface.suspendTracking(),this.startPoint=e,!0):!1}move(e,t,n){t=q({},t);let r=!0;return this.activeTool&&(r=this.activeTool.move(e,t,n)),r&&this._updateHoveredItem(e,t,n),this._updateCursor(e),!0}end(e,t,n){return t=q({},t),this.activeTool&&this.activeTool.end(e,t,n),this.diagram.canvas.surface.resumeTracking(),this.activeTool=void 0,this._updateCursor(e),!0}keyDown(e,t){let n=this.diagram;if(t=q({ctrlKey:!1,metaKey:!1,altKey:!1},t),(t.ctrlKey||t.metaKey)&&!t.altKey){if(h_(e,`a`))return n.selectAll(),n._destroyToolBar(),!0;if(h_(e,`z`))return n.undo(),n._destroyToolBar(),!0;if(h_(e,`y`))return n.redo(),n._destroyToolBar(),!0;h_(e,`c`)?(n.copy(),n._destroyToolBar()):h_(e,`x`)?(n.cut(),n._destroyToolBar()):h_(e,`v`)?(n.paste(),n._destroyToolBar()):h_(e,`l`)?(n.layout(),n._destroyToolBar()):h_(e,`d`)&&(n._destroyToolBar(),n.copy(),n.paste())}else if(e===46||e===8){let e=this.diagram._triggerRemove(n.select());return e.length&&(this.diagram.remove(e,!0),this.diagram._syncChanges(),this.diagram._destroyToolBar()),!0}else if(e===27)return this._discardNewConnection(),n.deselect(),n._destroyToolBar(),!0}wheel(e,t,n){let r=this.diagram,i=r.zoom(),a=t.delta,o=r.options,s=o.zoomRate,c={point:e,meta:t,zoom:i,nativeEvent:n};if(!r.trigger(`zoomStart`,c))return a<0?i+=s:i-=s,i=x_(Math.max(o.zoomMin,Math.min(o.zoomMax,i)),2),c.zoom=i,r.zoom(i,c),r.trigger(pe,c),!0}setTool(e,t){e.toolService=this,this.tools[t]=e}selectSingle(e,t){let n=this.diagram,r=n.options.selectable;if(r&&!e.isSelected&&e.options.selectable!==!1){let i=t.ctrlKey&&r.multiple!==!1;n.select(e,{addToSelection:i})}}_discardNewConnection(){this.newConnection&&=(this.diagram.remove(this.newConnection),void 0)}_activateTool(e,t){for(let n=0;n<this.tools.length;n++){let r=this.tools[n];if(!(t.middleButton&&!r.useMiddleButton)&&r.tryActivate(e,t)){this.activeTool=r;break}}}_updateCursor(e){let t=this.diagram.element,n;this.activeTool?n=this.activeTool.getCursor(e):this.hoveredAdorner?(n=this.hoveredAdorner._getCursor(e),!n&&this.hoveredItem&&(n=this.hoveredItem._getCursor(e))):this.hoveredItem&&(n=this.hoveredItem._getCursor(e)),t.style.cursor=n||C.arrow}_connectionManipulation(e,t,n){this.activeConnection=e,this.disabledShape=t,n?this.newConnection=this.activeConnection:this.newConnection=void 0}_updateHoveredItem(e,t,n){let r=this._hitTest(e),i=this.diagram;r!==this.hoveredItem&&(!this.disabledShape||r!==this.disabledShape)&&(this.hoveredItem&&(i.trigger(de,{item:this.hoveredItem,nativeEvent:n,point:e,meta:t}),this.hoveredItem._hover(!1)),r&&r.options.enable?(i.trigger(ue,{item:r,nativeEvent:n,point:e,meta:t}),this.hoveredItem=r,this.hoveredItem._hover(!0)):this.hoveredItem=void 0)}_removeHover(){this.hoveredItem&&=(this.hoveredItem._hover(!1),void 0)}_hitTest(e){let t=this.diagram,n,r,i;if(this._hoveredConnector&&=(this._hoveredConnector._hover(!1),void 0),t._connectorsAdorner._visible&&(n=t._connectorsAdorner._hitTest(e),n))return n;if(n=this.diagram._resizingAdorner._hitTest(e),n){if(this.hoveredAdorner=t._resizingAdorner,n.x!==0||n.y!==0)return;n=void 0}else this.hoveredAdorner=void 0;if(!this.activeTool||this.activeTool.type!==`ConnectionTool`){let a=[];for(i=0;i<t._selectedItems.length;i++)r=t._selectedItems[i],r instanceof b_&&a.push(r);n=this._hitTestItems(a,e)}return n||this._hitTestElements(e)}_hitTestElements(e){let t=this.diagram,n=this._hitTestItems(t.shapes,e),r=this._hitTestItems(t.connections,e),i;if((!this.activeTool||this.activeTool.type!==`ConnectionTool`)&&n&&r&&!S_(n,e)){let e=t.mainLayer;i=ct(n.visual,e.children)>ct(r.visual,e.children)?n:r}return i||n||r}_hitTestItems(e,t){let n,r,i;for(n=e.length-1;n>=0;n--)if(r=e[n],i=r._hitTest(t),i)return i}},w_=class{constructor(e,t){this.connection=e,this.diagram=t,this.title=`New connection`}undo(){this.diagram.remove(this.connection,!1)}redo(){this.diagram._addConnection(this.connection,!1)}},T_=class{constructor(e,t){this.shape=e,this.diagram=t,this.title=`New shape`}undo(){this.diagram.deselect(),this.diagram.remove(this.shape,!1)}redo(){this.diagram._addShape(this.shape,!1)}},E_=class{constructor(e){this.units=[],this.title=`Composite unit`,e!==void 0&&this.units.push(e)}add(e){this.units.push(e)}undo(){for(let e=0;e<this.units.length;e++)this.units[e].undo()}redo(){for(let e=0;e<this.units.length;e++)this.units[e].redo()}},D_=class{constructor(e){this.connection=e,this.diagram=e.diagram,this.targetConnector=e.targetConnector,this.title=`Delete connection`}undo(){this.diagram._addConnection(this.connection,!1)}redo(){this.diagram.remove(this.connection,!1)}},O_=class{constructor(e){this.shape=e,this.diagram=e.diagram,this.title=`Deletion`}undo(){this.diagram._addShape(this.shape,!1),this.shape.select(!1)}redo(){this.shape.select(!1),this.diagram.remove(this.shape,!1)}},k_=class{constructor(e){this.layoutState=e,this.diagram=e.diagram}initState(){this.froms=[],this.tos=[],this.subjects=[],this.layoutState.nodeMap.forEach((e,t)=>{let n=this.diagram.getShapeById(e);n&&(this.subjects.push(n),this.froms.push(n.bounds().topLeft()),this.tos.push(t.topLeft()))},this)}update(e){if(!(this.subjects.length<=0))for(let t=0;t<this.subjects.length;t++)this.subjects[t].position(new G(this.froms[t].x+(this.tos[t].x-this.froms[t].x)*e,this.froms[t].y+(this.tos[t].y-this.froms[t].y)*e))}},A_=class{constructor(e,t,n){D(n)?this.animate=!1:this.animate=!!n,this._initialState=e,this._finalState=t,this.title=`Diagram layout`}undo(){this.setState(this._initialState)}redo(){this.setState(this._finalState)}setState(e){let t=e.diagram;if(this.animate){e.linkMap.forEach(function(e,n){let r=t.getShapeById(e);r.visible(!1),r&&r.points(n)});let n=new Dt;n.addAdapter(new k_(e)),n.onComplete(function(){e.linkMap.forEach(function(e){t.getShapeById(e).visible(!0)})}),n.play()}else e.nodeMap.forEach(function(e,n){let r=t.getShapeById(e);r&&r.position(n.topLeft())}),e.linkMap.forEach(function(e,n){let r=t.getShapeById(e);r&&r.points(n)})}},j_=class{constructor(e,t,n){this.initial=e,this.finalPos=t,this.diagram=n,this.title=`Pan Unit`}undo(){this.diagram.pan(this.initial)}redo(){this.diagram.pan(this.finalPos)}},M_=class{constructor(e,t,n){this.diagram=e,this.indices=n,this.items=t,this.title=`Rotate Unit`}undo(){this.diagram._toIndex(this.items,this.indices)}redo(){this.diagram.toBack(this.items,!1)}},N_=class{constructor(e,t,n){this.diagram=e,this.indices=n,this.items=t,this.title=`Rotate Unit`}undo(){this.diagram._toIndex(this.items,this.indices)}redo(){this.diagram.toFront(this.items,!1)}},P_=class extends Ct{constructor(e={}){super(),this.events=[`undone`,`redone`],this.bind(this.events,e),this.stack=[],this.index=0,this.capacity=1e4}begin(){this.composite=new E_}cancel(){this.composite=void 0}commit(e){this.composite.units.length>0&&this._restart(this.composite,e),this.composite=void 0}addCompositeItem(e){this.composite?this.composite.add(e):this.add(e)}add(e,t){this._restart(e,t)}pop(){this.index>0&&(this.stack.pop(),this.index--)}count(){return this.stack.length}undo(){this.index>0&&!this.trigger(`undo`,{unit:this.stack[this.index-1]})&&(this.index--,this.stack[this.index].undo(),this.trigger(`undone`))}redo(){this.stack.length>0&&this.index<this.stack.length&&!this.trigger(`redo`,{unit:this.stack[this.index]})&&(this.stack[this.index].redo(),this.index++,this.trigger(`redone`))}_restart(e,t){this.stack.splice(this.index,this.stack.length-this.index),this.stack.push(e),t===!1?this.index++:this.redo(),this.stack.length>this.capacity&&(this.stack.splice(0,this.stack.length-this.capacity),this.index=this.capacity)}clear(){this.stack=[],this.index=0}},F_=class extends ${content(e){if(e===void 0)return this.options.content;let t=this._content(this._normalizeAutoHeightContent(e));return this._syncAutoHeightBounds(),t}_createContentVisual(e){e.blocks&&(e.shapeSize=this.bounds(),this._contentVisual=new um(e),this._contentVisual._includeInBBox=!1,this.visual.append(this._contentVisual))}_normalizeAutoHeightContent(e){return e}_measureHeightForWidth(e){return Math.max(this.options.minHeight,um.measureHeightForWidth(this.options.content,e))}_syncAutoHeightBounds(){let e=this._bounds||new K(this.options.x,this.options.y,this.options.width,this.options.height),t=this._measureHeightForWidth(e.width);!this._bounds||this._bounds.height!==t||this.options.height!==t?(super._setBounds(new K(e.x,e.y,e.width,t)),this._triggerBoundsChange(),this.diagram&&this.diagram._layouting||this.refreshConnections()):this._alignContent()}_setBounds(e){let t=this._measureHeightForWidth(e.width);super._setBounds(new K(e.x,e.y,e.width,t))}_usesDynamicResizeBounds(){return!0}};let I_=(e,t)=>{let n={...e||{}};return n.blocks||(n.blocks=[{children:[{text:n.text||``}]}],delete n.text),n.padding===void 0&&(n.padding=0),n.margin===void 0&&(n.margin=0),n.color===void 0&&(n.color=t?._theme?.textDefaults?.color),n},L_=(e,t)=>{let n=I_(e?.content,t);return{...e,type:b,content:n,fill:{color:`transparent`,...e?.fill},stroke:{color:`transparent`,width:0,...e?.stroke},resize:{...e?.resize,preserveAspectRatio:!1,scaleContent:!1},height:um.measureHeightForWidth(n,e?.width)}};var R_=class e extends F_{constructor(e,t){super(L_(e,t),t)}createShapeVisual(){let e=this.options,t=this._visualOptions(e);t.width=e.width,t.height=e.height,this.shapeVisual=new gm(t),this.visual.append(this.shapeVisual)}_normalizeAutoHeightContent(e){return I_(e,this.diagram)}_resizeHandleAllowed(e){return e&&e.y===0&&e.x!==0}_resizeHandleVisible(e){return this._resizeHandleAllowed(e)}_resizeHandleVisualBounds(e,t,n){if(!this._resizeHandleAllowed(e))return t;let r=n?.handles||{width:7,height:7},i=n?.handleOffset||0,a=r.width/2,o=r.height*2,s=t.center();return new K(s.x+e.x*i-a/2,s.y-o/2,a,o)}clone(){let t=this.serialize();return t.options.id=Ot(),this.diagram&&this.diagram._isEditable&&E(this.dataItem)&&(t.options.dataItem=this.diagram.options.cloneDataItem(this.dataItem)),new e(t.options,void 0)}};let z_=e=>(e||``).toLowerCase()===b,B_=(e,t)=>{let n=t.options.shapeDefaults,r=z_(e?.type),i=q({},r?{...n,content:null,fill:null,stroke:null}:n,e);return new(r?R_:$)(i,t)};var V_=class{constructor(e){this.dataItem=e,this.callbacks=[]}onActivate(e){return new Promise(t=>{this.callbacks.push({callback:e,resolve:t})})}activate(){let e=this.callbacks,t;for(let n=0;n<e.length;n++)t=this.callbacks[n],t.callback(this.dataItem),t.resolve();this.callbacks=[]}},H_=class{constructor(){this.items={}}add(e){for(let t=0;t<e.length;t++)this.items[e[t].uid]=new V_(e[t])}forEach(e){for(let t in this.items)Object.prototype.hasOwnProperty.call(this.items,t)&&e(this.items[t])}getByUid(e){return this.items[e]}remove(e){delete this.items[e.uid]}destroy(){this.items={}}},U_=class{constructor(){this.shapes=[]}_add(e,t){this.shapes.push({bounds:t,shape:e}),e._quadNode=this}insert(e,t){this._add(e,t)}remove(e){let t=this.shapes,n=t.length;for(let r=0;r<n;r++)if(t[r].shape===e){t.splice(r,1);break}}hitTestRect(e,t){let n=this.shapes,r=n.length;for(let i=0;i<r;i++)if(this._testRect(n[i].shape,e)&&!j(t,n[i].shape))return!0}_testRect(e,t){let n=e.rotate().angle,r=e.bounds(),i;return i=n?gf.rects(t,r,-n):r.overlaps(t),i}},W_=class e extends U_{constructor(e){super(),this.children=[],this.rect=e}inBounds(e){let t=this.rect,n=t.bottomRight(),r=e.bottomRight();return t.x<=e.x&&t.y<=e.y&&r.x<=n.x&&r.y<=n.y}overlapsBounds(e){return this.rect.overlaps(e)}insert(e,t){let n=!1,r=this.children,i=r.length;if(this.inBounds(t)){if(!i&&this.shapes.length<4)this._add(e,t);else{i||this._initChildren();for(let i=0;i<r.length;i++)if(r[i].insert(e,t)){n=!0;break}n||this._add(e,t)}n=!0}return n}_initChildren(){let t=this.rect,n=this.children,r=this.shapes,i=t.center(),a=t.width/2,o=t.height/2,s,c;for(n.push(new e(new K(t.x,t.y,a,o)),new e(new K(i.x,t.y,a,o)),new e(new K(t.x,i.y,a,o)),new e(new K(i.x,i.y,a,o))),c=r.length-1;c>=0;c--)for(s=0;s<n.length;s++)if(n[s].insert(r[c].shape,r[c].bounds)){r.splice(c,1);break}}hitTestRect(e,t){let n,r=this.children,i=r.length,a=!1;if(this.overlapsBounds(e)){if(super.hitTestRect(e,t))a=!0;else for(n=0;n<i;n++)if(r[n].hitTestRect(e,t)){a=!0;break}}return a}},G_=class{constructor(e){this.ROOT_SIZE=1e3;let t=this._boundsChange.bind(this);e.bind(le,t),e.bind(ce,t),this.initRoots()}initRoots(){this.rootMap={},this.root=new U_}clear(){this.initRoots()}_boundsChange(e){e.item._quadNode&&e.item._quadNode.remove(e.item),this.insert(e.item)}insert(e){let t=e.bounds(ge),n=this.ROOT_SIZE,r=this.getSectors(t),i=r[0][0],a=r[1][0];this.inRoot(r)?this.root.insert(e,t):(this.rootMap[i]||(this.rootMap[i]={}),this.rootMap[i][a]||(this.rootMap[i][a]=new W_(new K(i*n,a*n,n,n))),this.rootMap[i][a].insert(e,t))}remove(e){e._quadNode&&e._quadNode.remove(e)}inRoot(e){return e[0].length>1||e[1].length>1}getSectors(e){let t=this.ROOT_SIZE,n=e.bottomRight(),r=Math.floor(n.x/t),i=Math.floor(n.y/t),a=[[],[]];for(let n=Math.floor(e.x/t);n<=r;n++)a[0].push(n);for(let n=Math.floor(e.y/t);n<=i;n++)a[1].push(n);return a}hitTestRect(e,t){let n=this.getSectors(e),r,i,a,o,s;if(this.root.hitTestRect(e,t))return!0;for(r=0;r<n[0].length;r++)for(a=n[0][r],i=0;i<n[1].length;i++)if(o=n[1][i],s=(this.rootMap[a]||{})[o],s&&s.hitTestRect(e,t))return!0;return!1}};function K_(e,t,n){let r;for(let i=0;i<n.length;i++)r=n[i],t&&!E(t[r])&&(t[r]=e[r])}let q_={name:`Diagram`,theme:`sass`,layout:``,zoomRate:.1,zoom:1,zoomMin:.1,zoomMax:2,dataSource:{},draggable:!0,template:``,autoBind:!0,editable:{rotate:{},resize:{},text:!0,tools:[],drag:{snap:{size:10,angle:10}},remove:!0},pannable:{showScrollbars:!0,autoHideScrollbars:!0},selectable:{key:`none`},tooltip:{delay:200,enabled:!0,format:`{0}`},copy:{enabled:!0,offsetX:20,offsetY:20},tabIndex:0,navigation:{disabled:!1,smallStep:1,largeStep:5},accessibility:{role:`graphics-document`,ariaRoleDescription:`Diagram`},shapeDefaults:rh({undoable:!0,connectors:void 0}),connectionDefaults:{accessibility:{role:`graphics-symbol`,ariaRoleDescription:ze},editable:{tools:[],points:{snap:6}},tooltip:{visible:!0},type:`cascading`},shapes:[],connections:[]},J_=[`contextmenu`,`dblclick`,`pointerdown`,`pointermove`,`pointerup`,`pointercancel`,`pointerleave`,`touchstart`,`touchmove`,`touchend`,`touchcancel`],Y_=[pe,fe,`pan`,Ce,ce,le,te,`click`,ue,de,me,he,`toolBarClick`,`save`,`cancel`,`edit`,`remove`,`undo`,`redo`,`add`,`dataBound`,...J_,ae,oe,se];function X_(e){let t=[],n=[],r,i;for(i=0;i<e.length;i++)r=e[i],r instanceof $?n.push(r):t.push(r);return{shapes:n,connections:t}}function Z_(e){let t=e.getBoundingClientRect(),n=e.ownerDocument,r=n.defaultView.scrollX||n.documentElement.scrollLeft||0,i=n.defaultView.scrollY||n.documentElement.scrollTop||0;return{top:t.top+i,left:t.left+r}}function Q_(e,t=!1){let n=e.offsetHeight;if(t){let t=getComputedStyle(e),r=parseFloat(t.marginTop),i=parseFloat(t.marginBottom);n+=r+i}return n}function $_(e){let t=getComputedStyle(e),n=e.clientWidth,r=parseFloat(t.paddingLeft),i=parseFloat(t.paddingRight);return n-r-i}function ev(e){let t=getComputedStyle(e),n=e.clientHeight,r=parseFloat(t.paddingTop),i=parseFloat(t.paddingBottom);return n-r-i}function tv(e,t){let n=[],r=new Set,i=[...e].sort((e,t)=>{let n=e.bounds(),r=t.bounds();return n.y===r.y?n.x-r.x:n.y-r.y}),a=new Map;i.forEach((e,t)=>{a.set(e,t)});for(let e of i){n.push(e);let i=t.filter(t=>t.from===e&&!r.has(t)).sort((e,t)=>(e.to?a.get(e.to)??1/0:1/0)-(t.to?a.get(t.to)??1/0:1/0));for(let e of i)n.push(e),r.add(e)}for(let e of t)r.has(e)||n.push(e);return n}var nv=class{constructor(e){this.elements=[],this._skipAutoFocus=!1,this._selectHandler=e=>{if(!this.isDisabled())if(e.selected&&e.selected.length>0){this.elements=tv(e.sender.shapes,e.sender.connections);let t=this.elements.indexOf(e.selected[0]);t!==-1&&(this.currentIndex=t,e.selected.length===1&&this.focusSelectedElement())}else this.diagram.element.removeAttribute(ke),this.blurAll()},this._keydownHandler=e=>{if(this.isDisabled()||!this._hasFocus())return;let t=this.diagram._meta(e),n=t.metaKey&&d_();if(t.ctrlKey||n){let t=this.elements[this.currentIndex];if(!t)return;let n=this.diagram.options.navigation?.smallStep;if(e.shiftKey&&(n=this.diagram.options.navigation?.largeStep),t.name!==`Shape`||!qe(n))return;let r=t,i=r.bounds(),a=r.position().clone();switch(e.key){case Ie:a.x+=n,e.preventDefault();break;case Le:a.x-=n,e.preventDefault();break;case`ArrowUp`:a.y-=n,e.preventDefault();break;case`ArrowDown`:a.y+=n,e.preventDefault();break;default:break}if(!a.equals(r.position())){r.position(a);let e=new Wh([r],[i]);this.diagram.undoRedoService.add(e,!1)}}else switch(e.key){case Ie:this.focusNext(),e.preventDefault();break;case Le:this.focusPrevious(),e.preventDefault();break;case`Home`:this.focusFirst(),e.preventDefault();break;case`End`:this.focusLast(),e.preventDefault();break;default:break}},this._downHandler=()=>{this.isDisabled()||this._hasFocus()||(this._skipAutoFocus=!0)},this._focusHandler=()=>{if(!this.isDisabled()){if(this._skipAutoFocus){this._skipAutoFocus=!1,this.elements.length>0&&this.currentIndex>=0&&this.currentIndex<this.elements.length&&this.focusSelectedElement();return}this.elements=tv(this.diagram.shapes,this.diagram.connections),this.updateFocus()}},this._blurHandler=()=>{this.isDisabled()||this.blurAll()},this.currentIndex=0,this.diagram=e,this.attachEvents(),this.setTabIndex()}setTabIndex(){let{options:e,element:t}=this.diagram;!t.hasAttribute(`tabindex`)&&!D(e.tabIndex)&&t.setAttribute(`tabindex`,String(e.tabIndex))}attachEvents(){this.diagram.element.addEventListener(Ae,this._keydownHandler),this.diagram.element.addEventListener(je,this._downHandler),this.diagram.element.addEventListener(Me,this._downHandler),this.diagram.element.addEventListener(Ne,this._downHandler),this.diagram.element.addEventListener(Pe,this._focusHandler),this.diagram.element.addEventListener(Fe,this._blurHandler),this.diagram.bind(Ce,this._selectHandler)}isDisabled(){return this.diagram?.options.navigation?.disabled}detachEvents(){this.diagram.element.removeEventListener(Ae,this._keydownHandler),this.diagram.element.removeEventListener(je,this._downHandler),this.diagram.element.removeEventListener(Me,this._downHandler),this.diagram.element.removeEventListener(Ne,this._downHandler),this.diagram.element.removeEventListener(Pe,this._focusHandler),this.diagram.element.removeEventListener(Fe,this._blurHandler),this.diagram.unbind(Ce,this._selectHandler)}_hasFocus(){return this.diagram?.element.ownerDocument.activeElement===this.diagram.element}destroy(){this.diagram&&this.detachEvents(),this.elements=[],this.currentIndex=-1,this.diagram=null}focusNext(){this.elements.length!==0&&(this.currentIndex=(this.currentIndex+1)%this.elements.length,this.updateFocus())}focusPrevious(){this.elements.length!==0&&(this.currentIndex=(this.currentIndex-1+this.elements.length)%this.elements.length,this.updateFocus())}focusFirst(){this.elements.length!==0&&(this.currentIndex=0,this.updateFocus())}focusLast(){this.elements.length!==0&&(this.currentIndex=this.elements.length-1,this.updateFocus())}selectCurrent(){this.elements[this.currentIndex].select(!0),this.focusSelectedElement()}deselectAll(){this.elements.forEach(e=>{e.select(!1),e.blur()}),this.diagram.element.removeAttribute(ke)}focusSelectedElement(){let e=this.elements[this.currentIndex];this.diagram.element.setAttribute(ke,e.options.id),this.blurAll(),e.focus()}blurAll(){this.elements.forEach(e=>e.blur())}updateFocus(){this.elements.length===0||this.currentIndex<0||this.currentIndex>=this.elements.length||(this.deselectAll(),this.selectCurrent())}},rv=class extends Ct{constructor(e,t,n){super(),this._clipboard=[],this._connectionsDataMap={},this._dataMap={},this._inactiveShapeItems=new H_,this._selectedItems=[],this.shapes=[],this.connections=[],this._deferredConnectionUpdates=[],this._panMode=!1,this._domEvent=e=>{let t=this._meta(e),n=this._eventPositions(e),r=this.toolService._hitTest(n);this.trigger(e.type,{nativeEvent:e,item:r,point:n,meta:t})},this.element=e,this.options=q({createToolBar:vt,destroyToolBar:vt},q_,t),this.events=Y_,this._initTheme(n),this._initElements(),this._extendLayoutOptions(this.options),this._initDefaults(t),this._interactionDefaults(),this._initCanvas(),this.mainLayer=new wp({id:`main-layer`}),this.canvas.append(this.mainLayer),this._shapesQuadTree=new G_(this),this._pan=new G,this._adorners=[],this.adornerLayer=new wp({id:`adorner-layer`}),this.canvas.append(this.adornerLayer),this._createHandlers(),this._initialize(),this._resizingAdorner=new qh(this,{editable:this.options.editable}),this._connectorsAdorner=new Hh(this),this._adorn(this._resizingAdorner,!0),this._adorn(this._connectorsAdorner,!0),this.selector=new Yh(this),this._clipboard.length=0,this.pauseMouseHandlers=!1,this._navigation=new nv(this)}_createShape(e,t){return t||={},t.dataItem=e,B_(t,this)}_createConnection(e,t,n){let r=q({},this.options.connectionDefaults);return r.dataItem=e,new b_(t||new G,n||new G,r)}_initElements(){this.element.innerHTML=``,this.element.style.position=`relative`,this.element.classList.add(`k-diagram`),this.scrollable=document.createElement(`div`),this.scrollable.style.height=`100%`,this.scrollable.style.width=`100%`,this.scrollable.style.position=`relative`,this.element.appendChild(this.scrollable);let e=this.options.accessibility||{};this._setAttributes(`role`,e.role),this._setAttributes(`aria-label`,e.ariaLabel),this._setAttributes(`aria-roledescription`,e.ariaRoleDescription),this.wrapper=this.element}_setAttributes(e,t){E(t)&&this.element.setAttribute(e,String(t))}_initDefaults(e){let t=this.options,n=t.editable,r=t.shapeDefaults,i=t.connectionDefaults,a=(e||{}).shapeDefaults;n===!1?(r.editable=!1,i.editable=!1):(K_(n,r.editable,[`drag`,`remove`,`connect`]),K_(n,i.editable,[`drag`,`remove`])),a&&a.connectors&&(t.shapeDefaults.connectors=a.connectors)}_interactionDefaults(){let e=this.options,t=e.selectable,n=e.pannable,r=this._mobileOS();t&&!E(t.multiple)&&(e.selectable=q({multiple:!r},e.selectable)),n===!0&&(e.pannable={...q_.pannable}),n&&!E(n.key)&&(e.pannable=q({key:r?`none`:`ctrl`},e.pannable))}_initCanvas(){let e=document.createElement(`div`);e.classList.add(`k-layer`),this.scrollable.appendChild(e);let t=this.viewport();this.canvas=new(this.options.Canvas||Yf)(e,{width:t.width||600,height:t.height||600})}_createHandlers(){let e=this.element;this._wheelHandler=this._wheelHandler||this._wheel.bind(this),this._keydownHandler=this._keydownHandler||this._keydown.bind(this),this._mobileOS()&&this._mobileOS().browser.mobilesafari?e.addEventListener(`mousewheel`,this._wheelHandler):e.addEventListener(`wheel`,this._wheelHandler),e.addEventListener(`keydown`,this._keydownHandler),this._userEvents=new $g(this.scrollable,{multiTouch:!0,fastTap:!0,tap:this._tap.bind(this),start:this._dragStart.bind(this),move:this._drag.bind(this),end:this._dragEnd.bind(this),gesturestart:this._gestureStart.bind(this),gesturechange:this._gestureChange.bind(this),gestureend:this._gestureEnd.bind(this),doubleTap:this._doubleTap.bind(this),supportDoubleTap:!0}),this.toolService=new C_(this),this._mouseoverHandler=this._mouseoverHandler||this._mouseover.bind(this),this._mouseoutHandler=this._mouseoutHandler||this._mouseout.bind(this),this._mouseMoveHandler=this._mouseMoveHandler||this._mouseMove.bind(this),this._mouseDownHandler=this._mouseDownHandler||this._mouseDown.bind(this),this._mouseUpHandler=this._mouseUpHandler||this._mouseUp.bind(this),this.scrollable.addEventListener(`mouseover`,this._mouseoverHandler),this.scrollable.addEventListener(`mouseout`,this._mouseoutHandler),this.scrollable.addEventListener(`mousemove`,this._mouseMoveHandler),this.scrollable.addEventListener(`mousedown`,this._mouseDownHandler),this.scrollable.addEventListener(`mouseup`,this._mouseUpHandler),J_.forEach(e=>{this.scrollable.addEventListener(e,this._domEvent)}),this._initResizeObserver(),this.bind(fe,this._destroyToolBar.bind(this)),this.bind(`pan`,this._destroyToolBar.bind(this)),this.bind(ue,this._onMouseEnter.bind(this)),this.bind(de,this._onMouseLeave.bind(this))}_onMouseEnter(e){let{delay:t}=this.options.tooltip;this._tooltipTimeOut=setTimeout(()=>{this.trigger(me,e),this._tooltipTimeOut=null},t)}_onMouseLeave(e){clearTimeout(this._tooltipTimeOut),this.trigger(he,e)}_initResizeObserver(){let e=new ResizeObserver(e=>{e.forEach(e=>{let{width:t,height:n}=e.contentRect;e.target!==this.element||this.size&&this.size.width===t&&this.size.height===n||(this.size={width:t,height:n},this._resize(),this.trigger(`resize`,this.size))})});this._resizeObserver=e,e.observe(this.element)}_destroyResizeObserver(){this._resizeObserver&&=(this._resizeObserver.disconnect(),null)}_dragStart(e){this._pauseMouseHandlers=!0;let t=this._eventPositions(e,!0);this.toolService.start(t,this._meta(e),e.event)&&(this._destroyToolBar(),e.preventDefault())}_drag(e){let t=this._eventPositions(e);this.toolService.move(t,this._meta(e),e.event)&&e.preventDefault()}_dragEnd(e){this._pauseMouseHandlers=!1;let t=this._eventPositions(e);this.toolService.end(t,this._meta(e),e.event)&&(this.options.createToolBar(),e.preventDefault())}_mouseMove(e){if(!this._pauseMouseHandlers){let t=this._eventPositions(e);this.toolService._updateHoveredItem(t,this._meta(e),e),this.toolService._updateCursor(t)}}_mouseDown(e){if(this._pauseMouseHandlers=!0,e.button===1&&this.options.pannable!==!1&&!this.toolService.hoveredItem){e.preventDefault();let t=this._eventPositions(e),n=q(this._meta(e),{middleButton:!0});this.toolService.start(t,n,e)&&(this._middleButtonMoveHandler=this._middleButtonMove.bind(this),this._middleButtonUpHandler=this._middleButtonUp.bind(this),this.element.ownerDocument.addEventListener(`mousemove`,this._middleButtonMoveHandler),this.element.ownerDocument.addEventListener(`mouseup`,this._middleButtonUpHandler))}}_middleButtonMove(e){e.preventDefault();let t=this._eventPositions(e),n=q(this._meta(e),{middleButton:!0});this.toolService.move(t,n,e)}_middleButtonUp(e){if(e.button===1){this._pauseMouseHandlers=!1;let t=this._eventPositions(e),n=q(this._meta(e),{middleButton:!0});this.toolService.end(t,n,e),this.element.ownerDocument.removeEventListener(`mousemove`,this._middleButtonMoveHandler),this.element.ownerDocument.removeEventListener(`mouseup`,this._middleButtonUpHandler),this._middleButtonMoveHandler=null,this._middleButtonUpHandler=null}}_mouseUp(){this._pauseMouseHandlers=!1}_tap(e){let t=this.toolService,n=this.options.selectable,r=this._eventPositions(e),i=this.focus(),a=this._meta(e);if(t._updateHoveredItem(r,a,e.event),t.hoveredItem){let o=t.hoveredItem;if(this.trigger(`click`,{nativeEvent:e.event,item:o,point:r,meta:a}),n&&o.options.selectable!==!1){let e=n.multiple!==!1,t=Tr||a.ctrlKey||a.metaKey&&d_();o.isSelected?t?(this._destroyToolBar(),o.select(!1)):this.options.createToolBar(i):(this._destroyToolBar(),this.select(o,{addToSelection:e&&t}),this.options.createToolBar(i))}}else n&&(this._destroyToolBar(),this.deselect())}_keydown(e){this.toolService.keyDown(e.keyCode,this._meta(e))&&e.preventDefault()}_wheel(e){let t=Hm(e),n=this._eventPositions(e),r=q(this._meta(e),{delta:t});this.toolService.wheel(n,r,e)&&e.preventDefault()}_meta(e){return e=e.event||e,{ctrlKey:e.ctrlKey,metaKey:e.metaKey,altKey:e.altKey,shiftKey:e.shiftKey,type:e.type}}_eventPositions(e,t){let n;if(e.touch){let r=t?`startLocation`:`location`;n=new G(e.x[r],e.y[r])}else n=new G(e.pageX,e.pageY);return this.documentToModel(n)}_gestureStart(e){this._destroyToolBar(),this.scroller.disable();let t=this.documentToModel(new G(e.center.x,e.center.y)),n={point:t,zoom:this.zoom()};this.trigger(`zoomStart`,n)||(this._gesture=e,this._initialCenter=t)}_gestureChange(e){let t=this._gesture,n=this._initialCenter,r=this.documentToView(new G(e.center.x,e.center.y)),i=e.distance/t.distance,a=this._zoom,o=!1;Math.abs(i-1)>=.05&&(this._zoom=a=this._getValidZoom(a*i),this.options.zoom=a,this._gesture=e,o=!0);let s=n.times(a),c=r.minus(s);(o||this._pan.distanceTo(c)>=5)&&(this._panTransform(c),this._updateAdorners()),e.preventDefault()}_doubleTap(e){if(!this._mobileOS())return;let t=this._eventPositions(e),n=this.options,r=n.zoomRate,i=this.zoom()+r,a={point:t,meta:this._meta(e),zoom:i};this.trigger(`zoomStart`,a)||(i=N(Math.max(n.zoomMin,Math.min(n.zoomMax,i)),2),a.zoom=i,this.zoom(i,a),this.trigger(pe,a))}_gestureEnd(){this.options.pannable!==!1&&this.scroller.enable(),this.trigger(pe,{point:this._initialCenter,zoom:this.zoom()})}_resize(){let e=this.viewport();this.canvas&&this.canvas.size(e),this.scrollable&&this.toolBar&&(this.scrollable.style.height=e.height+`px`)}_mouseover(e){let t=e.target._kendoNode;t&&t.srcElement._hover&&t.srcElement._hover(!0,t.srcElement)}_mouseout(e){let t=e.target._kendoNode;t&&t.srcElement._hover&&t.srcElement._hover(!1,t.srcElement)}_initTheme(e){this._theme=e,this.options=q({},e,this.options),this.options.editable===!0?this.options.editable=(e||{}).editable:this.options.editable&&this.options.editable.resize===!0&&(this.options.editable.resize=(e.editable||{}).resize),this.options.connectionDefaults?.editable===!0?this.options.connectionDefaults.editable=e.connectionDefaults.editable:this.options.connectionDefaults?.editable?.points===!0&&(this.options.connectionDefaults.editable.points=e.connectionDefaults.editable.points)}_createOptionElements(){let e=this.options,t=e.shapes.length;t&&this._createShapes(),e.connections.length&&this._createConnections(),t&&e.layout&&this.layout(e.layout),this.undoRedoService.clear()}_createShapes(){let e=this.options.shapes,t,n;for(n=0;n<e.length;n++)t=e[n],this.addShape(t)}_createConnections(){let e=this.options,t=e.connectionDefaults,n=e.connections,r,i,a,o;for(o=0;o<n.length;o++)r=n[o],i=this._findConnectionTarget(r.from),a=this._findConnectionTarget(r.to),this.options.connect?this.options.connect(i,a,q({},t,r)):this.connect(i,a,q({},t,r))}_findConnectionTarget(e){e||={};let t=O(e)?e:e.shapeId||e.id,n;return t?(n=this.getShapeById(t),e.connector&&(n=n.getConnector(e.connector))):n=new G(e.x||0,e.y||0),n}destroy(){super.destroy(),this._destroyResizeObserver(),this._navigation?.destroy(),this._navigation=null,this._userEvents&&this._userEvents.destroy(),this.clear(),this.element.removeEventListener(`mousewheel`,this._wheelHandler),this.element.removeEventListener(`wheel`,this._wheelHandler),this.element.removeEventListener(`keydown`,this._keydownHandler),this.scrollable.removeEventListener(`mouseover`,this._mouseoverHandler),this.scrollable.removeEventListener(`mouseout`,this._mouseoutHandler),this.scrollable.removeEventListener(`mousemove`,this._mouseMoveHandler),this.scrollable.removeEventListener(`mousedown`,this._mouseDownHandler),this.scrollable.removeEventListener(`mouseup`,this._mouseUpHandler),this._middleButtonMoveHandler&&this.element.ownerDocument.removeEventListener(`mousemove`,this._middleButtonMoveHandler),this._middleButtonUpHandler&&this.element.ownerDocument.removeEventListener(`mouseup`,this._middleButtonUpHandler),J_.forEach(e=>{this.scrollable.removeEventListener(e,this._domEvent)}),this.canvas.destroy(!0),this.canvas=void 0,this.destroyScroller(),this._destroyGlobalToolBar(),this._destroyToolBar(),this._inactiveShapeItems.destroy()}destroyScroller(){let e=this.scroller;e&&(e.destroy(),e.element.remove(),this.scroller=null)}save(){let e={shapes:[],connections:[]},t,n,r;for(t=0;t<this.shapes.length;t++)if(r=this.shapes[t],r.options.serializable){let t=q({},r.options);r._originalWidth!==void 0&&(t.width=r._originalWidth),r._originalHeight!==void 0&&(t.height=r._originalHeight),e.shapes.push(t)}for(t=0;t<this.connections.length;t++)n=this.connections[t],e.connections.push(q({},n.options,n.toJSON()));return e}focus(){if(this.element!==this.element.ownerDocument.activeElement){let e=this.element,t=[],n=[],r=e.ownerDocument.documentElement,i=e,a;do i=i.parentNode,i.scrollHeight>i.clientHeight&&(t.push(i),n.push(i.scrollTop));while(i!==r);for(e.focus({preventScroll:!0}),a=0;a<t.length;a++)t[a].scrollTop=n[a];return!0}}load(e){this.clear(),this.setOptions(e),this._createShapes(),this._createConnections(),this.undoRedoService.clear()}setOptions(e){if(q(this.options,e),e.pannable){let e=this.toolService.tools.find(e=>e.scroller);e&&e.updateOptions()}}enterEdit(e){e?.name===`Shape`&&this._connectorsAdorner&&this._connectorsAdorner.pause(),this.disablePan()}exitEdit(e){e?.name===`Shape`&&this._connectorsAdorner&&this._connectorsAdorner.resume(),this.restorePan()}disablePan(){let e=this.options.pannable;this._currentPannable=typeof e==`object`?{...e}:e,this.setOptions({pannable:{showScrollbars:!1,key:`none`}})}restorePan(){this.setOptions({pannable:this._currentPannable}),this._currentPannable=void 0}panMode(e){if(e===void 0)return this._panMode;this._panMode=e}clear(){this.select(!1),this.mainLayer.clear(),this._shapesQuadTree.clear(),this._initialize()}connected(e,t){for(let n=0;n<this.connections.length;n++){let r=this.connections[n];if(r.from===e&&r.to===t)return!0}return!1}addConnection(e,t){return t!==!1&&this.undoRedoService.add(new w_(e,this),!1),e.diagram=this,e._setOptionsFromModel(),e.refresh(),this.mainLayer.append(e.visual),this.connections.push(e),this.trigger(te,{added:[e],removed:[]}),e}addShape(e,t){let n;if(e instanceof $)n=e,this._parseBounds(n.bounds());else if(!e.prototype)n=B_(e||{},this),this._parseBounds(n.bounds());else return;return t!==!1&&this.undoRedoService.add(new T_(n,this),!1),this.shapes.push(n),n.diagram!==this&&(this._shapesQuadTree.insert(n),n.diagram=this),this.mainLayer.append(n.visual),this.trigger(te,{added:[n],removed:[]}),n}remove(e,t){e=Array.isArray(e)?e.slice(0):[e];let n=X_(e),r=n.shapes,i=n.connections,a;for(E(t)||(t=!0),t&&this.undoRedoService.begin(),this._suspendModelRefresh(),a=r.length-1;a>=0;a--)this._removeItem(r[a],t,i);for(a=i.length-1;a>=0;a--)this._removeItem(i[a],t);this._resumeModelRefresh(),t&&this.undoRedoService.commit(!1),this.trigger(te,{added:[],removed:e})}_addConnection(e,t){if(this.options._addConnection)return this.options._addConnection(e,t);if(!this.trigger(`add`,{connection:e}))return this.addConnection(e,t),e._updateConnectors(),e}_addShape(e,t){if(this.options._addShape)return this.options._addShape(e,t);if(!this.trigger(`add`,{shape:e}))return this.addShape(e,t)}_parseBounds(e){e.x=typeof e.x==`string`?parseFloat(e.x):e.x,e.y=typeof e.y==`string`?parseFloat(e.y):e.y}_shouldRefresh(){return!this._suspended}_suspendModelRefresh(){this._suspended=(this._suspended||0)+1}_resumeModelRefresh(){this._suspended=Math.max((this._suspended||0)-1,0)}_triggerRemove(e){let t=[],n,r,i;for(let a=0;a<e.length;a++)n=e[a],i=n.options.editable,r=n instanceof $?{shape:n}:{connection:n},i&&i.remove!==!1&&!this.trigger(`remove`,r)&&t.push(n);return t}_addConnections(e,t){let n=e.length;for(let r=0;r<n;r++){let n=e[r];this._addConnectionDataItem(n,t)}}_addConnectionDataItem(e,t){if(!this._connectionsDataMap[e.uid]){let n=this._validateConnector(e.from);(!E(n)||n===null)&&(n=new G(e.fromX,e.fromY));let r=this._validateConnector(e.to);if((!E(r)||r===null)&&(r=new G(e.toX,e.toY)),E(n)&&E(r)){let i=q({},this.options.connectionDefaults);i.dataItem=e;let a=new b_(n,r,i);this._connectionsDataMap[e.uid]=a,this.addConnection(a,t)}}}_validateConnector(e){let t;return E(e)&&e!==null&&(t=this._dataMap[e]),t}_addDataItems(e,t){let n,r,i,a;for(r=0;r<e.length;r++)n=e[r],i=this._addDataItemByUid(n),a=this._addDataItemByUid(t),a&&!this.connected(a,i)&&this.connect(a,i)}connect(e,t,n){let r=new b_(e,t,q({},this.options.connectionDefaults,n));return this.addConnection(r)}undo(){this.undoRedoService.undo()}redo(){this.undoRedoService.redo()}select(e,t){if(T(e)){t=q({addToSelection:!1},t);let n=t.addToSelection,r=[],i=[],a,o;for(n||this.deselect(),this._internalSelection=!0,e instanceof Array?i=e:e instanceof xh&&(i=[e]),a=0;a<i.length;a++)o=i[a],o.select(!0)&&r.push(o);this._selectionChanged(r,[]),this._internalSelection=!1}else return this._selectedItems}selectAll(){this.select(this.shapes.concat(this.connections))}selectArea(e){let t,n,r;this._internalSelection=!0;let i=[];if(e instanceof K)for(n=this.shapes.concat(this.connections),t=0;t<n.length;t++)r=n[t],(!e||r._hitTest(e))&&r.options.enable&&r.select(!0)&&i.push(r);this._selectionChanged(i,[]),this._internalSelection=!1}deselect(e){this._internalSelection=!0;let t=[],n=[],r,i;for(e instanceof Array?n=e:e instanceof xh?n.push(e):T(e)||(n=this._selectedItems.slice(0)),i=0;i<n.length;i++)r=n[i],r.select(!1)&&t.push(r);this._selectionChanged([],t),this._internalSelection=!1}toFront(e,t){e||=this._selectedItems.slice();let n=this._getDiagramItems(e),r;if(!E(t)||t){r=Gm(this.mainLayer,n.visuals);let t=new N_(this,e,r);this.undoRedoService.add(t)}else this.mainLayer.toFront(n.visuals),this._fixOrdering(n,!0)}toBack(e,t){e||=this._selectedItems.slice();let n=this._getDiagramItems(e),r;if(!E(t)||t){r=Gm(this.mainLayer,n.visuals);let t=new M_(this,e,r);this.undoRedoService.add(t)}else this.mainLayer.toBack(n.visuals),this._fixOrdering(n,!1)}bringIntoView(e,t){let n=this.viewport(),r=new rf(n),i;if(n.width===0||n.height===0)return;t=q({animate:!1,align:`center middle`},t),t.align===`none`&&(t.align=`center middle`),e instanceof xh?i=e.bounds(De):Array.isArray(e)?i=this.boundingBox(e):e instanceof K&&(i=e.clone());let a=i.clone();i.zoom(this._zoom),(i.width>n.width||i.height>n.height)&&(this._zoom=this._getValidZoom(Math.min(n.width/a.width,n.height/a.height)),i=a.clone().zoom(this._zoom)),this._zoomMainLayer();let o=i.clone();r.align(i,t.align);let s=i.topLeft().minus(o.topLeft());this.pan(s.times(-1),t.animate)}alignShapes(e){D(e)&&(e=`Left`);let t,n,r,i=this.select();if(i.length===0)return;switch(e.toLowerCase()){case`left`:case`top`:t=Te;break;case`right`:case`bottom`:t=Ee;break;default:break}for(r=0;r<i.length;r++)if(n=i[r],n instanceof $)switch(e.toLowerCase()){case`left`:t=Math.min(t,n.options.x);break;case`top`:t=Math.min(t,n.options.y);break;case`right`:t=Math.max(t,n.options.x);break;case`bottom`:t=Math.max(t,n.options.y);break;default:break}let a=[],o=[];for(r=0;r<i.length;r++)if(n=i[r],n instanceof $)switch(o.push(n),a.push(n.bounds()),e.toLowerCase()){case`left`:case`right`:n.position(new G(t,n.options.y));break;case`top`:case`bottom`:n.position(new G(n.options.x,t));break;default:break}let s=new Wh(o,a);this.undoRedoService.add(s,!1)}zoom(e,t){if(e){let n=t?t.point:new G(0,0);if(e=this._zoom=this._getValidZoom(e),!D(n)){n=new G(Math.round(n.x),Math.round(n.y));let t=n.times(e),r=this.modelToView(n).minus(t);this._storePan(new G(Math.round(r.x),Math.round(r.y)))}t&&(t.zoom=e),this._panTransform(),this.canvas.surface.hideTooltip&&this.canvas.surface.hideTooltip(),this._updateAdorners()}return this._zoom}_getPan(e){return this.canvas.translate||(e=e.plus(this._pan)),e}pan(e,t){if(e instanceof G){let n=this.scroller;e=this._getPan(e),e=e.times(-1),t?n.animatedScrollTo(e.x,e.y,()=>{this._updateAdorners()}):(n.scrollTo(e.x,e.y),this._updateAdorners())}else return this._pan.times(-1)}viewport(){let e=this.element,t=$_(e),n=ev(e);return this.toolBar&&(n-=Q_(this.toolBar.element)),new K(0,0,t,n)}copy(){if(this.options.copy.enabled){this._clipboard.length=0,this._copyOffset=1;for(let e=0;e<this._selectedItems.length;e++){let t=this._selectedItems[e];this._clipboard.push(t)}}}cut(){if(this.options.copy.enabled){this._clipboard.length=0,this._copyOffset=0;for(let e=0;e<this._selectedItems.length;e++){let t=this._selectedItems[e];this._clipboard.push(t)}this.remove(this._clipboard,!0)}}paste(){if(this._clipboard.length>0){let e,t,n,r={},i=X_(this._clipboard),a=i.connections,o=i.shapes,s={x:this._copyOffset*this.options.copy.offsetX,y:this._copyOffset*this.options.copy.offsetY};for(this.deselect(),n=0;n<o.length;n++)e=o[n],t=e.clone(),r[e.id]=t,t.position(new G(e.options.x+s.x,e.options.y+s.y)),t.diagram=this,t=this._addShape(t),t&&t.select();for(n=0;n<a.length;n++)e=a[n],t=this._addConnection(e.clone()),t&&(this._updateCopiedConnection(t,e,`source`,r,s),this._updateCopiedConnection(t,e,`target`,r,s),t.select(!0),t.updateModel());this._syncChanges(),this._copyOffset+=1}}_syncChanges(){this.options._syncChanges&&this.options._syncChanges()}_syncConnectionChanges(){this.options._syncConnectionChanges&&this.options._syncConnectionChanges()}_syncShapeChanges(){this.options._syncShapeChanges&&this.options._syncShapeChanges()}_updateCopiedConnection(e,t,n,r,i){let a,o,s,c=t[n]();c instanceof th&&r[c.shape.id]?(s=r[c.shape.id],this.getShapeById(s.id)?e[n](s.getConnector(c.options.name)):(o=this._inactiveShapeItems.getByUid(s.dataItem.uid),o&&(a=t=>{s=this._dataMap[t.id],e[n](s.getConnector(c.options.name)),e.updateModel()},this._deferredConnectionUpdates.push(o.onActivate(a))))):e[n](new G(t[n+`Point`]().x+i.x,t[n+`Point`]().y+i.y))}boundingBox(e,t){let n=K.empty(),r,i=T(e)?this._getDiagramItems(e):{shapes:this.shapes};if(i.shapes.length>0){let e=i.shapes[0];n=e.bounds(ge);for(let a=1;a<i.shapes.length;a++)e=i.shapes[a],r=e.bounds(ge),t===!0&&(r.x-=e._rotationOffset.x,r.y-=e._rotationOffset.y),n=n.union(r)}return n}_containerOffset(){let e=this.canvas?.translate?this.canvas.element:this.element,t=Z_(e);return e===this.element&&this.toolBar&&(t.top+=Q_(this.toolBar.element)),t}documentToView(e){let t=this._containerOffset();return new G(e.x-t.left,e.y-t.top)}viewToDocument(e){let t=this._containerOffset();return new G(e.x+t.left,e.y+t.top)}viewToModel(e){return this._transformWithMatrix(e,this._matrixInvert)}modelToView(e){return this._transformWithMatrix(e,this._matrix)}modelToLayer(e){return this._transformWithMatrix(e,this._layerMatrix)}layerToModel(e){return this._transformWithMatrix(e,this._layerMatrixInvert)}documentToModel(e){let t=this.documentToView(e);return this.canvas.translate||(t.x+=this.scroller.scrollLeft,t.y+=this.scroller.scrollTop),this.viewToModel(t)}modelToDocument(e){return this.viewToDocument(this.modelToView(e))}_transformWithMatrix(e,t){let n=e;if(e instanceof G)t&&(n=t.apply(e));else{let r=this._transformWithMatrix(e.topLeft(),t),i=this._transformWithMatrix(e.bottomRight(),t);n=K.fromPoints(r,i)}return n}layout(e){this._layouting=!0;let t;D(e)&&(e=this.options.layout),t=D(e)||D(e.type)?`Tree`:e.type;let n;switch(t.toLowerCase()){case`tree`:n=new Sm(this);break;case`layered`:n=new bm(this);break;case`forcedirected`:case`force`:case`spring`:case`springembedder`:n=new pf(this);break;default:throw Error(`Layout algorithm '`+t+`' is not supported.`)}let r=new uf(this),i=n.layout(e);if(i){let t=new A_(r,i,e?e.animate:null);this.undoRedoService.add(t)}this._layouting=!1,this._redrawConnections()}getShapeById(e){let t;return t=ft(this.shapes,function(t){return t.visual.id===e}),t||(t=ft(this.connections,function(t){return t.visual.id===e}),t)}getShapeByModelId(e){let t;return t=this._isEditable?this._dataMap[e]:ft(this.shapes,function(t){return(t.dataItem||{}).id===e}),t}getShapeByModelUid(e){let t;return t=this._isEditable?ft(this.shapes,function(t){return(t.dataItem||{}).uid===e}):this._dataMap[e],t}_extendLayoutOptions(e){e.layout&&=q({},cf,e.layout)}_selectionChanged(e,t){(e.length||t.length)&&this.trigger(Ce,{selected:e,deselected:t})}_getValidZoom(e){return Math.min(Math.max(e,this.options.zoomMin),this.options.zoomMax)}_panTransform(e){let t=e||this._pan;this.canvas.translate?(this.scroller.scrollTo(t.x,t.y),this._zoomMainLayer()):(this._storePan(t),this._transformMainLayer())}_finishPan(){this.trigger(`pan`,{total:this._pan,delta:NaN})}_storePan(e){this._pan=e,this._storeViewMatrix()}_zoomMainLayer(){let e=this._zoom,t=new Df(0,0,e,e);t.render(this.mainLayer),this._storeLayerMatrix(t),this._storeViewMatrix()}_transformMainLayer(){let e=this._pan,t=this._zoom,n=new Df(e.x,e.y,t,t);n.render(this.mainLayer),this._storeLayerMatrix(n),this._storeViewMatrix()}_storeLayerMatrix(e){this._layerMatrix=e.toMatrix(),this._layerMatrixInvert=e.invert().toMatrix()}_storeViewMatrix(){let e=this._pan,t=this._zoom,n=new Df(e.x,e.y,t,t);this._matrix=n.toMatrix(),this._matrixInvert=n.invert().toMatrix()}_toIndex(e,t){let n=this._getDiagramItems(e);this.mainLayer.toIndex(n.visuals,t),this._fixOrdering(n,!1)}_fixOrdering(e,t){let n=t?this.shapes.length-1:0,r=t?this.connections.length-1:0,i,a;for(i=0;i<e.shapes.length;i++)a=e.shapes[i],A(this.shapes,a),pt(this.shapes,a,n);for(i=0;i<e.cons.length;i++)a=e.cons[i],A(this.connections,a),pt(this.connections,a,r)}_getDiagramItems(e){let t,n=e,r={};for(r.visuals=[],r.shapes=[],r.cons=[],e?Array.isArray(e)||(n=[e]):n=this._selectedItems.slice(),t=0;t<n.length;t++){let e=n[t];e instanceof $?(r.shapes.push(e),r.visuals.push(e.visual)):e instanceof b_&&(r.cons.push(e),r.visuals.push(e.visual))}return r}_addDataItemByUid(e){if(!E(e))return;let t=this._dataMap[e.uid];if(t)return t;let n={};return n.dataItem=e,t=B_(n,this),this.addShape(t),this._dataMap[e.uid]=t,t}_addItem(e){e instanceof $?this.addShape(e):e instanceof b_&&this.addConnection(e)}_toolBarClick(e){this.trigger(`toolBarClick`,e),this._destroyToolBar()}_normalizePointZoom(e){return e.times(1/this.zoom())}_initialize(){this.shapes.length=0,this.connections.length=0,this._selectedItems.length=0,Object.keys(this._dataMap).forEach(e=>{delete this._dataMap[e]}),Object.keys(this._connectionsDataMap).forEach(e=>{delete this._connectionsDataMap[e]}),this._deferredConnectionUpdates.length=0,this.undoRedoService=new P_({undone:this._syncChanges.bind(this),redone:this._syncChanges.bind(this)}),this.undoRedoService.bind(`undo`,e=>{this.trigger(`undo`,e)}),this.undoRedoService.bind(`redo`,e=>{this.trigger(`redo`,e)}),this.id=Ot()}_redrawConnections(){let e=this.connections;for(let t=0;t<e.length;t++)e[t].refresh()}_adorn(e,t){t!==void 0&&e&&(t?(this._adorners.push(e),this.adornerLayer.append(e.visual)):(A(this._adorners,e),this.adornerLayer.remove(e.visual)))}_showConnectors(e,t){t?this._connectorsAdorner.show(e):this._connectorsAdorner.destroy()}_updateAdorners(){let e=this._adorners;for(let t=0;t<e.length;t++){let n=e[t];n.refreshBounds&&n.refreshBounds(),n.refresh()}}_refresh(){for(let e=0;e<this.connections.length;e++)this.connections[e].refresh()}_removeItem(e,t,n){e.select(!1),e instanceof $?(this._removeShapeDataItem(e),this._removeShape(e,t,n)):e instanceof b_&&(this._removeConnectionDataItem(e),this._removeConnection(e,t)),this.mainLayer.remove(e.visual)}_removeConnectionDataItem(e){this._isEditable&&(this.options._removeConnectionDataItem(e.dataItem),delete this._connectionsDataMap[e.dataItem.uid])}_removeShapeDataItem(e){this._isEditable&&(this.options._removeShapeDataItem(e.dataItem),delete this._dataMap[e.dataItem.id])}_removeShape(e,t,n){let r,i,a,o=[],s=[];for(this.toolService._removeHover(),t&&this.undoRedoService.addCompositeItem(new O_(e)),A(this.shapes,e),this._shapesQuadTree.remove(e),r=0;r<e.connectors.length;r++){a=e.connectors[r];for(let e=0;e<a.connections.length;e++)i=a.connections[e],(!n||!j(n,i))&&(i.sourceConnector===a?o.push(i):i.targetConnector===a&&s.push(i))}for(r=0;r<o.length;r++)o[r].source(null,t),o[r].updateModel();for(r=0;r<s.length;r++)s[r].target(null,t),s[r].updateModel()}_removeConnection(e,t){e.sourceConnector&&A(e.sourceConnector.connections,e),e.targetConnector&&A(e.targetConnector.connections,e),t&&this.undoRedoService.addCompositeItem(new D_(e)),A(this.connections,e)}_removeShapeConnections(e){let t=e.connections(),n;if(t)for(n=0;n<t.length;n++)this._removeItem(t[n],!1)}_destroyToolBar(){this.options.destroyToolBar()}_destroyGlobalToolBar(){this.toolBar&&=null}_mobileOS(){return Tr}exportDOMVisual(){let e=this.canvas._viewBox,t=Ur().translate(-e.x,-e.y),n=new F([0,0],[e.width,e.height]),r=I.fromRect(n),i=new L({transform:t}),a=new L({clip:r}),o=this.canvas.drawingElement.children[0];return a.append(i),i.children.push(o),a}exportVisual(){let e=1/this._zoom,t=new L({transform:Ur().scale(e,e)}),n=this.mainLayer.drawingElement;return t.children.push(n),t}updateConnectionModel(e,t){if(this.options.updateConnectionModel)return this.options.updateConnectionModel(e,t)}updateShapeModel(e,t){if(this.options.updateShapeModel)return this.options.updateShapeModel(e,t)}};let iv=e=>e.ownerDocument.defaultView.getComputedStyle(e),av=(e,t)=>iv(e).getPropertyValue(t),ov,sv=(e,t)=>{let n=av(e,t);if(!n)return;ov||=new Map;let r;return ov.has(n)?r=ov.get(n):(r=pn(e,t),ov.set(n,r)),r},cv=e=>{let t=sv(e,`--kendo-chart-primary-bg`),n=sv(e,`--kendo-chart-primary-contrast`),r=sv(e,`--kendo-chart-text`),i=sv(e,`--kendo-color-surface`),a=`#0B99FF`;return{shapeDefaults:{fill:{color:t},content:{color:n},connectorDefaults:{fill:{color:a},stroke:{color:n},hover:{fill:{color:a},stroke:{color:a}}}},editable:{resize:{handles:{width:10,height:10,stroke:{color:a},fill:{color:i},hover:{stroke:{color:a},fill:{color:a}}}}},selectable:{stroke:{color:a}},connectionDefaults:{stroke:{color:r},content:{color:r,bgColor:n},selection:{handles:{fill:{color:n},stroke:{color:r},width:8,height:8},stroke:{color:r}},editable:{points:{midpoint:{fill:{color:a},stroke:{color:n,width:1},radius:4},vertex:{fill:{color:n},stroke:{color:a,width:2},radius:3}}}},textDefaults:{color:r}}};function lv(e,t,n,r){return{x:t.left+e.x*n-r.x,y:t.top+e.y*n-r.y}}function uv(e,t,n,r){let i=lv({x:e.x,y:e.y},t,n,r);return new K(i.x,i.y,e.width*n,e.height*n)}function dv(e,t){let n={point:e[0],segIdx:0,t:0,dist2:1/0};for(let r=0;r<e.length-1;r++){let i=e[r],a=e[r+1],o={x:a.x-i.x,y:a.y-i.y},s={x:t.x-i.x,y:t.y-i.y},c=o.x*o.x+o.y*o.y||1e-9,l=Math.max(0,Math.min(1,(s.x*o.x+s.y*o.y)/c)),u={x:i.x+o.x*l,y:i.y+o.y*l},d=t.x-u.x,f=t.y-u.y,p=d*d+f*f;p<n.dist2&&(n={point:u,segIdx:r,t:l,dist2:p})}return n}function fv(e,t,n,r){switch(e){case`right`:return new K(t.x+10,t.y-r/2,n,r);case`left`:return new K(t.x-10-n,t.y-r/2,n,r);case`bottom`:return new K(t.x-n/2,t.y+10,n,r);case`top`:return new K(t.x-n/2,t.y-10-r,n,r)}}function pv(e,t){let n=Math.max(0,t.left-e.x+8),r=Math.max(0,t.top-e.y+8),i=Math.max(0,e.x+e.width-(t.right-8)),a=Math.max(0,e.y+e.height-(t.bottom-8));return n+r+i+a}function mv(e,t,n){let r=Math.min(e.x,t.x),i=Math.max(e.x,t.x),a=Math.min(e.y,t.y),o=Math.max(e.y,t.y);return new K(r-n/2,a-n/2,i-r+n,o-a+n)}let hv=[`right`,`left`,`bottom`,`top`];function gv(e){let{hovered:t,shapes:n,connections:r,diagramRect:i,zoom:a,pan:o,tooltipSize:s,viewportBounds:c,mouse:l}=e,u=c,d,f;if(t.name===`Shape`){let e=uv(t.bounds(),i,a,o);f={right:{x:e.x+e.width,y:e.y+e.height/2},left:{x:e.x,y:e.y+e.height/2},bottom:{x:e.x+e.width/2,y:e.y+e.height},top:{x:e.x+e.width/2,y:e.y}}}else d=lv(dv(t.allPoints(),l).point,i,a,o);let p=n.map(e=>uv(e,i,a,o)),m=[];for(let e of r)for(let t=0;t<e.length-1;t++){let n=lv(e[t],i,a,o),r=lv(e[t+1],i,a,o);m.push(mv(n,r,10))}let h=[];for(let e of hv){let n=fv(e,t.name===`Shape`?f[e]:d,s.width,s.height),r=pv(n,u),i=0;for(let e of p)if(n.overlaps(e)){i++;break}for(let e of m)if(n.overlaps(e)){i++;break}h.push({pos:e,rect:n,ov:r,hits:i})}h.sort((e,t)=>e.ov-t.ov||e.hits-t.hits||hv.indexOf(e.pos)-hv.indexOf(t.pos));let g=h[0],_=g.ov===0?g.rect:_v(g.rect,u);return{left:_.x,top:_.y,position:g.pos}}function _v(e,t){let n=e.x,r=e.y;return n<t.left+8&&(n=t.left+8),r<t.top+8&&(r=t.top+8),n+e.width>t.right-8&&(n=t.right-8-e.width),r+e.height>t.bottom-8&&(r=t.bottom-8-e.height),new K(n,r,e.width,e.height)}(function(){var e=window.kendo,t=e.dataviz.diagram={};e.deepExtend(t,{init:function(n){e.init(n,t.ui)},Utils:wt,Range:Tt,Ticker:Dt})})(),(function(){var e=window.kendo,t=e.dataviz.diagram;e.deepExtend(t,{init:function(n){e.init(n,t.ui)},Point:G,Intersect:gf,Geometry:At,Rect:K,Size:Cf,RectAlign:rf,Matrix:yf,MatrixVector:vf,normalVariable:bf,randomId:Ot,Dictionary:M,HashTable:kt,Queue:af,Set:Sf,Node:df,Link:ff,Graph:J,PathDefiner:xf})})();let{isFunction:vv}=wt;(function(){var e=window.kendo,t=e.drawing,n=e.dataviz.diagram;class r extends Yf{constructor(e,n){n||={},super(e,n),this.surface=t.Surface.create(e,n),this.translate=vv(this.surface.translate)?this._translate:void 0,this._viewBox=new K(0,0,n.width,n.height),this.size(this._viewBox)}}e.deepExtend(n,{init:function(t){e.init(t,n.ui)},diffNumericOptions:Of,Markers:x,Element:kf,Scale:Tf,Translation:Ef,Rotation:wf,Circle:Zf,Group:wp,Rectangle:X,Canvas:r,Path:Rp,Layout:Op,Line:kp,MarkerBase:Kf,ArrowMarker:Jf,CircleMarker:$f,Polyline:zp,CompositeTransform:Df,TextBlock:em,Terminator:Sp,Process:Jp,Decision:up,PredefinedProcess:Gp,Document:bp,ManualInputOutput:jp,Preparation:qp,ManualOperation:Np,InternalStorage:Dp,Display:gp,DirectAccessStorage:mp,Database:sp,OnPageConnector:rp,OffPageConnector:Lp,DataInputOutput:ap,SummingJunction:pm,LogicalOr:Fp,Merge:Pp,Extract:Cp,DataStorage:lp,Delay:fp,Sort:fm,Collate:np,MultipleDocuments:xp,Image:Tp,VisualBase:Wf})})(),(function(){var e=window.kendo,t=e.dataviz.diagram;t.Cursors=C,e.deepExtend(t,{CompositeUnit:E_,TransformUnit:Wh,PanUndoUnit:j_,AddShapeUnit:T_,AddConnectionUnit:w_,DeleteShapeUnit:O_,DeleteConnectionUnit:D_,ConnectionEditAdorner:kh,ConnectionTool:rg,ConnectorVisual:Vh,UndoRedoService:P_,ResizingAdorner:qh,Selector:Yh,ToolService:C_,ConnectorsAdorner:Hh,LayoutUndoUnit:A_,ConnectionEditUnit:__,ToFrontUnit:N_,ToBackUnit:M_,ConnectionRouterBase:Xh,PolylineRouter:tg,CascadingRouter:eg,SelectionTool:m_,ScrollerTool:p_,PointerTool:og,ConnectionEditTool:ng,RotateUnit:$m})})(),(function(){var e=window.kendo,t=e.dataviz.diagram;e.deepExtend(t,{init:function(n){e.init(n,t.ui)},SpringLayout:pf,TreeLayout:Sm,GraphAdapter:mf,LayeredLayout:bm,LayoutBase:lf,LayoutState:uf})})(),(function(){let e=window.kendo.dataviz;e.diagramTheme=cv})(),(function(e,t){var n=kendo.dataviz,r=n.diagram,i=kendo.ui.Widget,a=kendo.deepExtend,o=kendo._outerWidth,s=kendo._outerHeight,c=e.extend,l=kendo.data.HierarchicalDataSource,u=r.Canvas;r.Rect;var d=r.Point,f=kendo.drawing.util.defined,p=e.isPlainObject,m=kendo.data.DataSource;ah.register({compile:function(e){return kendo.template(e,{paramName:`dataItem`})}});var h=`.kendoDiagram`,g=`click`,_=`rotated`,v=`change`,y=`error`,b=({className:e,icon:t,themeColor:n,text:r})=>kendo.html.renderButton(`<button class="${e}" href="#">${r}</button>`,{icon:t,themeColor:n});function x(e){e.preventDefault()}function S(e,t){f(t[e])&&t.set(e,null)}let ee=e=>`<div class="k-popup">${e}</div>`,te=e=>Math.round(e)+`px`;r.DefaultConnectors=nh;var C={cancel:{text:`Cancel`,icon:`cancel`,className:`k-diagram-cancel`},update:{text:`Save`,imageClass:`save`,className:`k-diagram-update`,icon:`save`,themeColor:`primary`}};r.shapeDefaults=rh;var w=i.extend({init:function(n,r={}){var a=this;kendo.destroy(n),i.fn.init.call(a,n,r);let o=a._initTheme(),s=f(r.connectionsDataSource);this._isEditable=s;let c=new rv(n,{...a.options,_syncChanges:a._syncChanges.bind(a),_syncShapeChanges:a._syncShapeChanges.bind(a),_syncConnectionChanges:a._syncConnectionChanges.bind(a),_removeConnectionDataItem:a._removeConnectionDataItem.bind(a),_removeShapeDataItem:a._removeShapeDataItem.bind(a),_addConnection:a._addConnection.bind(a),_addShape:a._addShape.bind(a),updateConnectionModel:a.updateConnectionModel.bind(a),updateShapeModel:a.updateShapeModel.bind(a),cloneDataItem:oe,connect:s?a.connect.bind(a):t,createToolBar:a._createToolBar.bind(a),destroyToolBar:a._destroyToolBar.bind(a),Canvas:u,shapeDefaults:{...r.shapeDefaults},navigation:{...r.navigatable},connectionDefaults:{...r.connectionDefaults}},o);a.events.forEach(function(e){c.bind(e,function(t){if(e===`tooltipShow`){a._clearTooltips();let e=a.options.tooltip||{};t.item.name===`Shape`&&e.shapeTemplate?a._createTooltip(t.item,t.point,e.shapeTemplate,!0):t.item.name===`Connection`&&e.connectionTemplate&&a._createTooltip(t.item,t.point,e.connectionTemplate,!1)}e===`tooltipHide`&&a._clearTooltips(),t.sender=a,a.trigger(e,t)})}),a.widget=c,a.wrapper=e(c.wrapper),a.scrollable=e(c.scrollable),a.shapes=c.shapes,a.connections=c.connections,a._connectionsDataMap=c._connectionsDataMap,a._dataMap=c._dataMap,a._inactiveShapeItems=c._inactiveShapeItems,a._copyOffset=0,a._selectedItems=c._selectedItems,a.options=c.options,a._clipboard=c._clipboard,a.id=c.id,a.undoRedoService=c.undoRedoService,a.toolService=c.toolService,a._resizingAdorner=c._resizingAdorner,a._connectorsAdorner=c._connectorsAdorner,a.selector=c.selector,a.mainLayer=c.mainLayer,a._fetchFreshData(),a._createGlobalToolBar(),a.widget._createOptionElements(),a.widget.zoom(a.options.zoom),a.widget.canvas.draw()},options:a({},q_),events:[...Y_],shapes:[],connections:[],dataSource:null,connectionsDataSource:null,connect:function(e,t,n){let r;if(this.connectionsDataSource&&this._isEditable){let i=this.connectionsDataSource.add({});r=this.widget._connectionsDataMap[i.uid],r.source(e),r.target(t),r.redraw(n),r.updateModel()}else r=this.widget.connect(e,t,n);return r},connected:function(e,t){return this.widget.connected(e,t)},addConnection:function(e,t){return this.widget.addConnection(e,t)},addShape:function(e,t){return this.widget.addShape(e,t)},remove:function(e,t){return this.widget.remove(e,t)},undo:function(){return this.widget.undo()},redo:function(){return this.widget.redo()},select:function(e,t){return this.widget.select(e,t)},deselect:function(e){this.widget.deselect(e)},toFront:function(e,t){return this.widget.toFront(e,t)},toBack:function(e,t){return this.widget.toBack(e,t)},bringIntoView:function(e,t){return this.widget.bringIntoView(e,t)},boundingBox:function(e,t){return this.widget.boundingBox(e,t)},layout:function(e){return this.widget.layout(e)},getShapeById:function(e){return this.widget.getShapeById(e)},getConnectionByModelId(e){let t;return this.connectionsDataSource&&(t=ft(this.connections,function(t){return(t.dataItem||{}).id===e})),t},getConnectionByModelUid(e){let t;return this.connectionsDataSource&&(t=this.widget._connectionsDataMap[e]),t},copy:function(){this.widget.copy()},cut:function(){this.widget.cut()},alignShapes:function(e){return this.widget.alignShapes(e)},createShape:function(){if(this.editor&&this.editor.end()||!this.editor){var e=this.dataSource,t=(e.view()||[]).length,n=se(e,{}),r=this.widget._createShape(n,{});if(!this.trigger(`add`,{shape:r})){e.insert(t,n);var i=this.widget._inactiveShapeItems.getByUid(n.uid);i.element=r,this.edit(r)}}},createConnection:function(){if(this.editor&&this.editor.end()||!this.editor){var e=this.connectionsDataSource,t=(e.view()||[]).length,n=se(e,{}),r=this.widget._createConnection(n);this.trigger(`add`,{connection:r})||(this.widget._connectionsDataMap[n.uid]=r,e.insert(t,n),this.addConnection(r,!1),this.edit(r))}},exportVisual:function(){return this.widget.exportVisual()},exportDOMVisual:function(){return this.widget.exportDOMVisual()},_syncChanges(){this._syncShapeChanges(),this._syncConnectionChanges()},_syncShapeChanges(){this.dataSource&&this._isEditable&&this.dataSource.sync()},_syncConnectionChanges(){this.connectionsDataSource&&this._isEditable&&Promise.all(this.widget._deferredConnectionUpdates).then(()=>{this.connectionsDataSource.sync(),this.widget._deferredConnectionUpdates.length=0})},editModel:function(e,t){this.cancelEdit();var n,r,i=this.widget.options.editable;if(t==`shape`)n=i.shapeEditors,r=i.shapeTemplate;else if(t==`connection`){var o=ae.bind(this);n=a({},{from:o,to:o},i.connectionEditors),r=i.connectionTemplate}else return;this.editor=new ie(this.element,{update:this._update.bind(this),cancel:this._cancel.bind(this),model:e,type:t,target:this,editors:n,template:r}),this.trigger(`edit`,this._editArgs())},edit:function(e){if(e.dataItem){var t=e instanceof $?`shape`:`connection`;this.editModel(e.dataItem,t)}},cancelEdit:function(){if(this.editor){let e=this._getEditDataSource(),t=this.editor.model&&this.editor.model.uid,n=t?e.getByUid(t):null;n&&e.cancelChanges(n),this._destroyEditor()}},clear(){this.widget.clear()},saveEdit:function(){this.editor&&this.editor.end()&&!this.trigger(`save`,this._editArgs())&&this._getEditDataSource().sync()},updateConnectionModel:function(e,t){if(this.connectionsDataSource){let n=this.connectionsDataSource.getByUid(e.dataItem.uid);n&&(this._suspendModelRefresh(),f(e.options.fromX)&&e.options.fromX!==null?(S(`from`,n),S(`fromConnector`,n),n.set(`fromX`,e.options.fromX),n.set(`fromY`,e.options.fromY)):(n.set(`from`,e.options.from),f(n.fromConnector)&&n.set(`fromConnector`,e.sourceConnector?e.sourceConnector.options.name:null),S(`fromX`,n),S(`fromY`,n)),f(e.options.toX)&&e.options.toX!==null?(S(`to`,n),S(`toConnector`,n),n.set(`toX`,e.options.toX),n.set(`toY`,e.options.toY)):(n.set(`to`,e.options.to),f(n.toConnector)&&n.set(`toConnector`,e.targetConnector?e.targetConnector.options.name:null),S(`toX`,n),S(`toY`,n)),f(e.options.type)&&f(n.type)&&n.set(`type`,e.options.type),e.dataItem=n,this._resumeModelRefresh(),t&&this._syncConnectionChanges())}},updateShapeModel:function(e,t){let n=e._bounds,r=e.dataItem;r&&(this._suspendModelRefresh(),f(r.x)&&n.x!==r.x&&r.set(`x`,n.x),f(r.y)&&n.y!==r.y&&r.set(`y`,n.y),f(r.width)&&n.width!==r.width&&r.set(`width`,n.width),f(r.height)&&n.height!==r.height&&r.set(`height`,n.height),e.dataItem=r,this._resumeModelRefresh(),t&&this._syncShapeChanges())},destroy:function(){this.diagram=null,this.element=null,this.options=null,this._toolBar&&this._toolBar.destroy(),this._popup&&this._popup.destroy(),this._destroyGlobalToolBar(),this._destroyToolBar(),this.widget&&=(this.widget.destroy(),null)},documentToModel:function(e){return this.widget.documentToModel(e)},documentToView:function(e){return this.widget.documentToView(e)},focus:function(){return this.widget.focus()},getShapeByModelId:function(e){return this.widget.getShapeByModelId(e)},getShapeByModelUid:function(e){return this.widget.getShapeByModelUid(e)},layerToModel:function(e){return this.widget.layerToModel(e)},load:function(e){this.widget.load(e)},modelToDocument:function(e){return this.widget.modelToDocument(e)},modelToLayer:function(e){return this.widget.modelToLayer(e)},modelToView:function(e){return this.widget.modelToView(e)},pan:function(e,t){return this.widget.pan(e,t)},paste:function(){this.widget.paste()},save:function(){return this.widget.save()},selectAll:function(){this.widget.selectAll()},selectArea:function(e){this.widget.selectArea(e)},setDataSource(e){this.options.dataSource=e,this._dataSource(),this.options.autoBind!==!1&&this.dataSource.fetch()},setConnectionsDataSource(e){this.options.connectionsDataSource=e,this._connectionDataSource(),this.options.autoBind!==!1&&this.connectionsDataSource.fetch()},viewToDocument:function(e){return this.widget.viewToDocument(e)},viewToModel:function(e){return this.widget.viewToModel(e)},viewport:function(){return this.widget.viewport()},zoom:function(e,t){return this.widget.zoom(e,t)},_initTheme:function(){var e=this,t=((e.options||{}).theme||``).toLowerCase(),r=n.ui.themes||{},i;return n.SASS_THEMES.indexOf(t)==-1?i=(r[t]||{}).diagram:(e.element.addClass(`k-diagram`),i=n.diagramTheme(e.element[0]),e.element.removeClass(`k-diagram`)),i},items:function(){return e()},_createGlobalToolBar:function(){this.widget;var e=this.widget.options.editable;if(e){var t=e.tools;this._isEditable&&t!==!1&&(!t||t.length===0)&&(t=[`createShape`,`undo`,`redo`,`rotateClockwise`,`rotateAnticlockwise`]),t&&t.length&&(this.toolBar=new ne(this,{tools:t,click:this._toolBarClick.bind(this),modal:!1}),this.widget.toolBar={element:this.toolBar.element[0]},this.toolBar.element.css({textAlign:`left`}),this.element.prepend(this.toolBar.element),this.widget._resize())}},_toolBarClick:function(e){this.trigger(`toolBarClick`,e),this._destroyToolBar()},_createToolBar:function(e){let t=this,n=this.widget;if(!this.singleToolBar&&t.select().length===1){var r=t.select()[0];if(r&&r.options.editable!==!1){var i=r.options.editable||{},a=i.tools;if(this._isEditable&&a&&a.length===0&&(r instanceof $?a=[`edit`,`rotateClockwise`,`rotateAnticlockwise`]:r instanceof b_&&(a=[`edit`]),i&&i.remove!==!1&&a.push(`delete`)),a&&a.length){var c=20,l;this.singleToolBar=new ne(this,{tools:a,click:this._toolBarClick.bind(this),modal:!0,popupZIndex:parseInt(t.element.closest(`.k-window`).css(`zIndex`),10)+10});var u=o(this.singleToolBar._popup.element),f=s(this.singleToolBar._popup.element);if(r instanceof $){var p=n.modelToView(r.bounds(_));l=new d(p.x,p.y).minus(new d((u-p.width)/2,f+c))}else if(r instanceof b_){var m=n.modelToView(r.bounds());l=new d(m.x,m.y).minus(new d((u-m.width-20)/2,f+c))}l?(n.canvas.translate||(l=l.minus(new d(n.scroller.scrollLeft,n.scroller.scrollTop))),l=this.viewToDocument(l),l=new d(Math.max(l.x,0),Math.max(l.y,0)),this.singleToolBar.showAt(l),e&&this.singleToolBar._popup.one(`close`,x)):this._destroyToolBar()}}}},_destroyToolBar:function(){this.singleToolBar&&=(this.singleToolBar.hide(),this.singleToolBar.destroy(),null)},_destroyGlobalToolBar:function(){this.toolBar&&=(this.toolBar.hide(),this.toolBar.destroy(),null)},_update:function(){this.editor&&this.editor.end()&&!this.trigger(`save`,this._editArgs())&&(this._getEditDataSource().sync(),this._destroyEditor())},_cancel:function(){if(this.editor&&!this.trigger(`cancel`,this._editArgs())){var e=this.editor.model;this._getEditDataSource().cancelChanges(e);var t=this.widget._connectionsDataMap[e.uid]||this.widget._dataMap[e.id];t&&t._setOptionsFromModel(e),this._destroyEditor()}},_getEditDataSource:function(){return this.editor.options.type===`shape`?this.dataSource:this.connectionsDataSource},_editArgs:function(){var e={container:this.editor.wrapper};return e[this.editor.options.type]=this.editor.model,e},_fetchFreshData(){this._dataSource(),this._isEditable&&this._connectionDataSource(),this.options.autoBind!==!1&&(this._isEditable?(this._loadingShapes=!0,this._loadingConnections=!0,this.dataSource.fetch(),this.connectionsDataSource.fetch()):this.dataSource.fetch())},_dataSource(){if(f(this.options.connectionsDataSource)){this.widget._isEditable=!0;let e=this.options.dataSource||{},t=Array.isArray(e)?{data:e}:e;this.dataSource&&this._shapesRefreshHandler?this.dataSource.unbind(`change`,this._shapesRefreshHandler).unbind(`requestStart`,this._shapesRequestStartHandler).unbind(`error`,this._shapesErrorHandler):(this._shapesRefreshHandler=this._refreshShapes.bind(this),this._shapesRequestStartHandler=this._shapesRequestStart.bind(this),this._shapesErrorHandler=this._error.bind(this)),this.dataSource=m.create(t).bind(`change`,this._shapesRefreshHandler).bind(`requestStart`,this._shapesRequestStartHandler).bind(`error`,this._shapesErrorHandler)}else this._treeDataSource(),this.widget._isEditable=!1},_connectionDataSource(){let e=this.options.connectionsDataSource;if(e){let t=Array.isArray(e)?{data:e}:e;this.connectionsDataSource&&this._connectionsRefreshHandler?this.connectionsDataSource.unbind(`change`,this._connectionsRefreshHandler).unbind(`requestStart`,this._connectionsRequestStartHandler).unbind(`error`,this._connectionsErrorHandler):(this._connectionsRefreshHandler=this._refreshConnections.bind(this),this._connectionsRequestStartHandler=this._connectionsRequestStart.bind(this),this._connectionsErrorHandler=this._connectionsError.bind(this)),this.connectionsDataSource=m.create(t).bind(`change`,this._connectionsRefreshHandler).bind(`requestStart`,this._connectionsRequestStartHandler).bind(`error`,this._connectionsErrorHandler)}},_shapesRequestStart(e){e.type===`read`&&(this._loadingShapes=!0)},_connectionsRequestStart(e){e.type===`read`&&(this._loadingConnections=!0)},_error(){this._loadingShapes=!1},_connectionsError(){this._loadingConnections=!1},_refreshShapes(e){e.action===`remove`?this._shouldRefresh()&&this._removeShapes(e.items):e.action===`itemchange`?this._shouldRefresh()&&this._updateShapes(e.items,e.field):e.action===`add`?this._inactiveShapeItems.add(e.items):e.action===`sync`?this._syncShapes():this.refresh()},_shouldRefresh(){return this.widget._shouldRefresh()},_suspendModelRefresh(){this.widget._suspendModelRefresh()},_resumeModelRefresh(){this.widget._resumeModelRefresh()},refresh(){this._loadingShapes=!1,this._loadingConnections||this._rebindShapesAndConnections()},_rebindShapesAndConnections(){this.clear(),this._addShapes(this.dataSource.view()),this.connectionsDataSource&&this._addConnections(this.connectionsDataSource.view(),!1),this.options.layout?this.layout(this.options.layout):this._redrawConnections(),this.trigger(`dataBound`)},refreshConnections(){this._loadingConnections=!1,this._loadingShapes||this._rebindShapesAndConnections()},_redrawConnections(){this.widget._redrawConnections()},_removeShapes(e){let t=this.widget._dataMap,n,r;for(r=0;r<e.length;r++)n=e[r],t[n.id]&&(this.remove(t[n.id],!1),t[n.id]=null)},_syncShapes(){let e=this._inactiveShapeItems;e.forEach(t=>{let n=t.dataItem,r=t.element;n.isNew()||(r?(r._setOptionsFromModel(),this.addShape(r,t.undoable),this.widget._dataMap[n.id]=r):this._addDataItem(n),t.activate(),e.remove(n))})},_updateShapes(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=this.widget._dataMap[r.id];i&&i.updateOptionsFromModel(r,t)}},_addShapes(e){for(let t=0;t<e.length;t++)this._addDataItem(e[t],!1)},_addDataItem(e,t){if(!E(e))return;let n=this.widget._dataMap[e.id];if(n)return n;let r=a({},this.widget.options.shapeDefaults);return r.dataItem=e,n=new $(r,this.widget),this.addShape(n,t!==!1),this.widget._dataMap[e.id]=n,n},_refreshConnections(e){e.action===`remove`?this._shouldRefresh()&&this._removeConnections(e.items):e.action===`add`?this._addConnections(e.items):e.action===`sync`||(e.action===`itemchange`?this._shouldRefresh()&&this._updateConnections(e.items):this.refreshConnections())},_removeConnections(e){for(let t=0;t<e.length;t++)this.remove(this.widget._connectionsDataMap[e[t].uid],!1),this.widget._connectionsDataMap[e[t].uid]=null},_updateConnections(e){for(let t=0;t<e.length;t++){let n=e[t];this.widget._connectionsDataMap[n.uid].updateOptionsFromModel(n)}},_addConnections(e,t){this.widget._addConnections(e,t)},_addShape(e,t){let n=this.dataSource,r;if(n&&this._isEditable){if(r=se(n,oe(e.dataItem)),e.dataItem=r,e.updateModel(),!this.trigger(`add`,{shape:e})){this.dataSource.add(r);let n=this.widget._inactiveShapeItems.getByUid(r.uid);return n.element=e,n.undoable=t,e}}else if(!this.trigger(`add`,{shape:e}))return this.addShape(e,t)},_addConnection(e,t){let n=this.connectionsDataSource,r;if(n&&this._isEditable){if(r=se(n,oe(e.dataItem)),e.dataItem=r,e.updateModel(),!this.trigger(`add`,{connection:e}))return this.widget._connectionsDataMap[r.uid]=e,n.add(r),this.addConnection(e,t),e._updateConnectors(),e}else if(!this.trigger(`add`,{connection:e}))return this.addConnection(e,t),e._updateConnectors(),e},_treeDataSource(){let e=this.widget.options.dataSource;if(e=Array.isArray(e)?{data:e}:e,e instanceof m&&!(e instanceof l))throw Error(`Incorrect DataSource type. If a single dataSource instance is set to the diagram then it should be a HierarchicalDataSource. You should set only the options instead of an instance or a HierarchicalDataSource instance or supply connectionsDataSource as well.`);e.fields||=[{field:`text`},{field:`url`},{field:`spriteCssClass`},{field:`imageUrl`}],this.dataSource&&this._refreshHandler&&this._unbindDataSource(),this._refreshHandler=this._refreshSource.bind(this),this._errorHandler=this._error.bind(this),this.dataSource=l.create(e).bind(v,this._refreshHandler).bind(y,this._errorHandler)},_unbindDataSource(){this.dataSource.unbind(v,this._refreshHandler).unbind(y,this._errorHandler)},_refreshSource(e){let t=e.node,n=e.action,r=e.items,i=this.options,a,o;if(e.field){for(a=0;a<r.length;a++)this.widget._dataMap[r[a].uid]&&this.widget._dataMap[r[a].uid].redrawVisual();return}if(n===`remove`)this._removeDataItems(e.items,!0);else for((!n||n===`itemloaded`)&&!this._bindingRoots&&(this._bindingRoots=!0,o=!0),!n&&!t&&this.clear(),this.widget._addDataItems(r,t),a=0;a<r.length;a++)r[a].load();i.layout&&(o||n===`remove`||n===`add`)&&this.layout(i.layout),o&&(this.trigger(`dataBound`),this._bindingRoots=!1)},_removeDataItems(e,t){let n,r,i,a;for(e=Array.isArray(e)?e:[e];e.length;)if(n=e.shift(),i=this.widget._dataMap[n.uid],i&&(this.widget._removeShapeConnections(i),this.widget._removeItem(i,!1),delete this.widget._dataMap[n.uid],t&&n.hasChildren&&n.loaded()))for(r=n.children.data(),a=0;a<r.length;a++)e.push(r[a])},_removeConnectionDataItem(e){this.connectionsDataSource.remove(e)},_removeShapeDataItem(e){this.dataSource.remove(e)},_clearTooltips:function(){this._shapeTooltip&&=(this._shapeTooltip.remove(),null),this._connectionTooltip&&=(this._connectionTooltip.remove(),null)},_positionTooltip:function(e,t,n){let r=this.widget,i=r.zoom(),a=r.pan(),o=e[0],s=o.getBoundingClientRect(),c=r.element.getBoundingClientRect(),l=r.element.ownerDocument.defaultView,u=r.connections.map(e=>e.allPoints()),d=gv({hovered:t,mouse:n,shapes:r.shapes.map(e=>e.bounds()),connections:u,diagramRect:c,zoom:i,pan:a,tooltipSize:{width:s.width,height:s.height},viewportBounds:new DOMRect(0,0,l.innerWidth,l.innerHeight)});o.style.left=te(d.left+l.scrollX),o.style.top=te(d.top+l.scrollY)},_createTooltip:function(t,n,r,i){let a=this,o=i?`_shapeTooltip`:`_connectionTooltip`;a[o]=e(ee(kendo.template(r)(t))).css(`position`,`absolute`),a._positionTooltip(a[o],t,n),a[o].appendTo(`body`)},_destroyEditor:function(){this.editor&&=(this.editor.close(),null)}});n.ExportMixin.extend(w.fn,!0),kendo.PDFMixin&&kendo.PDFMixin.extend(w.fn);var ne=kendo.Observable.extend({init:function(e,t){kendo.Observable.fn.init.call(this),this.diagram=e,this.options=a({},this.options,t),this._tools=[],this.createToolBar(),this.createTools(),this.appendTools(),this.options.modal&&this.createPopup(),this.bind(this.events,t)},events:[`click`],createPopup:function(){this.container=e(`<div/>`).append(this.element),this._popup=this.container.kendoPopup({}).getKendoPopup()},appendTools:function(){for(var e=0;e<this._tools.length;e++){var t=this._tools[e];(t.buttons&&t.buttons.length||!f(t.buttons))&&this._toolBar.add(t)}},createToolBar:function(){this.element=e(`<div/>`),this._toolBar=this.element.kendoToolBar({click:this.click.bind(this),resizable:!1}).getKendoToolBar(),this.element.css(`border`,`none`)},createTools:function(){for(var e=0;e<this.options.tools.length;e++)this.createTool(this.options.tools[e])},createTool:function(e){p(e)||(e={name:e});var t=e.name+`Tool`;this[t]?this[t](e):this._tools.push(a({},e,{attributes:this._setAttributes({action:e.name})}))},showAt:function(e){var t=parseInt(this.options.popupZIndex,10);this._popup&&(this._popup.open(e.x,e.y),t&&this._popup.wrapper.css(`zIndex`,t))},hide:function(){this._popup&&this._popup.close()},newGroup:function(){return{type:`buttonGroup`,buttons:[]}},editTool:function(){this._tools.push({icon:`pencil`,showText:`overflow`,type:`button`,text:`Edit`,attributes:this._setAttributes({action:`edit`})})},deleteTool:function(){this._tools.push({icon:`x`,showText:`overflow`,type:`button`,text:`Delete`,attributes:this._setAttributes({action:`delete`})})},rotateAnticlockwiseTool:function(e){this._appendGroup(`rotate`),this._rotateGroup.buttons.push({icon:`rotate-left`,showText:`overflow`,text:`RotateAnticlockwise`,group:`rotate`,attributes:this._setAttributes({action:`rotateAnticlockwise`,step:e.step})})},rotateClockwiseTool:function(e){this._appendGroup(`rotate`),this._rotateGroup.buttons.push({icon:`rotate-right`,attributes:this._setAttributes({action:`rotateClockwise`,step:e.step}),showText:`overflow`,text:`RotateClockwise`,group:`rotate`})},createShapeTool:function(){this._appendGroup(`create`),this._createGroup.buttons.push({icon:`shapes`,showText:`overflow`,text:`CreateShape`,group:`create`,attributes:this._setAttributes({action:`createShape`})})},createConnectionTool:function(){this._appendGroup(`create`),this._createGroup.buttons.push({icon:`connector`,showText:`overflow`,text:`CreateConnection`,group:`create`,attributes:this._setAttributes({action:`createConnection`})})},undoTool:function(){this._appendGroup(`history`),this._historyGroup.buttons.push({icon:`undo`,showText:`overflow`,text:`Undo`,group:`history`,attributes:this._setAttributes({action:`undo`})})},redoTool:function(){this._appendGroup(`history`),this._historyGroup.buttons.push({icon:`redo`,showText:`overflow`,text:`Redo`,group:`history`,attributes:this._setAttributes({action:`redo`})})},_appendGroup:function(e){var t=`_`+e+`Group`;this[t]||(this[t]=this.newGroup(),this._tools.push(this[t]))},_setAttributes:function(e){var t={};return e.action&&(t[kendo.attr(`action`)]=e.action),e.step&&(t[kendo.attr(`step`)]=e.step),t},_getAttributes:function(e){var t={},n=e.attr(kendo.attr(`action`));n&&(t.action=n);var r=e.attr(kendo.attr(`step`));return r&&(t.step=r),t},click:function(t){var n=this._getAttributes(e(t.target)),r=n.action;r&&this[r]&&this[r](n),this.trigger(`click`,this.eventData(r,t.target))},eventData:function(e,t){for(var n=this.selectedElements(),r=n.length,i=[],a=[],o,s=0;s<r;s++)o=n[s],o instanceof $?i.push(o):a.push(o);return{shapes:i,connections:a,action:e,target:t}},delete:function(){var e=this.diagram.widget._triggerRemove(this.selectedElements());e.length&&(this.diagram.remove(e,!0),this.diagram._syncChanges())},edit:function(){var e=this.selectedElements();e.length===1&&this.diagram.edit(e[0])},rotateClockwise:function(e){var t=parseFloat(e.step||90);this._rotate(t)},rotateAnticlockwise:function(e){var t=parseFloat(e.step||90);this._rotate(-t)},_rotate:function(e){var t=this.diagram.widget._resizingAdorner;t.angle(t.angle()+e),t.rotate()},selectedElements:function(){return this.diagram.select()},createShape:function(){this.diagram.createShape()},createConnection:function(){this.diagram.createConnection()},undo:function(){this.diagram.undo()},redo:function(){this.diagram.redo()},destroy:function(){this.diagram=null,this.element=null,this.options=null,this._toolBar&&this._toolBar.destroy(),this._popup&&this._popup.destroy()}}),re=kendo.Observable.extend({init:function(e,t){kendo.Observable.fn.init.call(this),this.options=c(!0,{},this.options,t),this.element=e,this.model=this.options.model,this.fields=this._getFields(),this._initContainer(),this.createEditable()},options:{editors:{}},_initContainer:function(){this.wrapper=this.element},createEditable:function(){var e=this.options;this.editable=new kendo.ui.Editable(this.wrapper,{fields:this.fields,target:e.target,clearContainer:!1,model:this.model})},_isEditable:function(e){return this.model.editable&&this.model.editable(e)},_getFields:function(){var e=[];for(var t in this.model.fields){var n={};if(this._isEditable(t)){var r=this.options.editors[t];r&&(n.editor=r),n.field=t,e.push(n)}}return e},end:function(){return this.editable.end()},destroy:function(){this.editable.destroy(),this.editable.element.find(`[`+kendo.attr(`container-for`)+`]`).empty(),this.model=this.wrapper=this.element=this.columns=this.editable=null}}),ie=re.extend({init:function(e,t){re.fn.init.call(this,e,t),this.bind(this.events,this.options),this.open(),i.fn.endInit.call(this)},events:[`update`,`cancel`],options:{window:{modal:!0,resizable:!1,draggable:!0,title:`Edit`,visible:!1}},_initContainer:function(){var t=this;this.wrapper=e(`<div class="k-popup-edit-form"/>`).attr(kendo.attr(`uid`),this.model.uid);var n=``;this.options.template?(n+=this._renderTemplate(),this.fields=[]):n+=this._renderFields(),n+=this._renderButtons(),this.wrapper.append(e(`<div class="k-edit-form-container"/>`).append(n)),this.window=new kendo.ui.Window(this.wrapper.appendTo(this.element),this.options.window),this.window.bind(`close`,function(e){e.userTriggered&&(e.sender.element.trigger(`focus`),t._cancelClick(e))}),this._attachButtonEvents()},_renderTemplate:function(){var e=this.options.template;return typeof e==`string`&&(e=kendo.unescape(e)),e=kendo.template(e)(this.model),e},_renderFields:function(){for(var e=``,t=0;t<this.fields.length;t++){var n=this.fields[t];e+=`<div class="k-edit-label"><label for="`+n.field+`">`+(n.field||``)+`</label></div>`,this._isEditable(n.field)&&(e+=`<div `+kendo.attr(`container-for`)+`="`+n.field+`" class="k-edit-field"></div>`)}return e},_renderButtons:function(){var e=`<div class="k-edit-buttons">`;return e+=this._createButton(`update`),e+=this._createButton(`cancel`),e+=`</div>`,e},_createButton:function(e){return kendo.template(b)(C[e])},_attachButtonEvents:function(){this._cancelClickHandler=this._cancelClick.bind(this),this.window.element.on(g+h,`button.k-diagram-cancel`,this._cancelClickHandler),this._updateClickHandler=this._updateClick.bind(this),this.window.element.on(g+h,`button.k-diagram-update`,this._updateClickHandler)},_updateClick:function(e){e.preventDefault(),this.trigger(`update`)},_cancelClick:function(e){e.preventDefault(),this.trigger(`cancel`)},open:function(){this.window.center().open()},close:function(){this.window.bind(`deactivate`,this.destroy.bind(this)).close()},destroy:function(){this.window.close().destroy(),this.window.element.off(g+h,`a.k-diagram-cancel`,this._cancelClickHandler),this.window.element.off(g+h,`a.k-diagram-update`,this._updateClickHandler),this._cancelClickHandler=null,this._editUpdateClickHandler=null,this.window=null,re.fn.destroy.call(this)}});function ae(t,n){var r=this.dataSource.reader.model;if(r){var i=r.fn.fields.text?`text`:r.idField;e(`<input name='`+n.field+`' />`).appendTo(t).kendoDropDownList({dataValueField:r.idField,dataTextField:i,dataSource:this.dataSource.data().toJSON(),optionLabel:` `,valuePrimitive:!0})}}function oe(e){var t=e;return e instanceof kendo.data.Model&&(t=e.toJSON(),t[e.idField]=e._defaultId),t}function se(e,t){return e.reader.model?new e.reader.model(t):new kendo.data.ObservableObject(t)}n.ui.plugin(w),a(r,{Shape:$,Connection:b_,Connector:th,DiagramToolBar:ne,QuadNode:W_,QuadRoot:U_,ShapesQuadTree:G_,PopupEditor:ie})})(window.kendo.jQuery);let yv={id:`dataviz.diagram`,name:`Diagram`,category:`dataviz`,description:`The Kendo DataViz Diagram `,depends:[`data`,`userevents`,`mobile.scroller`,`draganddrop`,`drawing`,`dataviz.core`,`dataviz.themes`,`toolbar`],features:[{id:`dataviz.diagram-pdf-export`,name:`PDF export`,description:`Export Diagram as PDF`,depends:[`pdf`]},{id:`dataviz.diagram-editing`,name:`Editing`,description:`Support for model editing`,depends:[`editable`,`window`,`dropdownlist`]}]};var bv=kendo;e.__meta__=yv,e.default=bv});
//# sourceMappingURL=kendo.dataviz.diagram.min.js.map