UNPKG

@joint/core

Version:

JavaScript diagramming library

8 lines (6 loc) 440 kB
/*! JointJS v4.1.3 (2025-02-04) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ var g,V,Vectorizer;((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).joint={})})(this,function(t){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function _(t,e){return t(e={exports:{}},e.exports),e.exports}function N(t){return t&&t.Math==Math&&t}function O(t){try{return!!t()}catch(t){return!0}}function F(t){return St(kt(t))}function I(e,n){try{jt(yt,e,n)}catch(t){yt[e]=n}return n}function D(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++qt+$t).toString(36)}function z(t){return Wt[t]||(Wt[t]=D(t))}function j(t){return"function"==typeof t?t:void 0}function G(t,e){return arguments.length<2?j(Jt[t])||j(yt[t]):Jt[t]&&Jt[t][e]||yt[t]&&yt[t][e]}function U(t){return 0<t?ee(te(t),9007199254740991):0}function H(a){return function(t,e,n){var i,r=F(t),o=U(r.length),s=((t,e)=>(t=te(t))<0?ne(t+e,0):ie(t,e))(n,o);if(a&&e!=e){for(;s<o;)if((i=r[s++])!=i)return!0}else for(;s<o;s++)if((a||s in r)&&r[s]===e)return a||s||0;return!a&&-1}}function q(t,e){var n,i=F(t),r=0,o=[];for(n in i)!_t(Yt,n)&&_t(i,n)&&o.push(n);for(;e.length>r;)!_t(i,n=e[r++])||~re(o,n)||o.push(n);return o}function $(t,e){return(t=de[ce(t)])==pe||t!=fe&&("function"==typeof e?O(e):!!e)}function W(t,e){var n,i,r,o=t.target,s=t.global,a=t.stat,l=s?yt:a?yt[o]||I(o,{}):(yt[o]||{}).prototype;if(l)for(n in e){if(i=e[n],r=t.noTargetGet?(r=me(l,n))&&r.value:l[n],!ge(s?n:o+(a?".":"#")+n,t.forced)&&void 0!==r){if(typeof i==typeof r)continue;g=p=f=d=c=u=h=void 0;for(var h=i,u=r,c=he(u),d=zt.f,f=Vt.f,p=0;p<c.length;p++){var g=c[p];_t(h,g)||d(h,g,f(u,g))}}(t.sham||r&&r.sham)&&jt(i,"sham",!0),Zt(l,n,i,t)}}function Y(t){return _t(ye,t)||(ve&&_t(be,t)?ye[t]=be[t]:ye[t]=xe("Symbol."+t)),ye[t]}function X(){}function Z(t){Ne[_e][t]=!0}function J(t){throw t}function K(t,e){var n,i,r,o;return _t(Re,t)?Re[t]:(n=[][t],i=!!_t(e=e||{},"ACCESSORS")&&e.ACCESSORS,r=_t(e,0)?e[0]:J,o=_t(e,1)?e[1]:void 0,Re[t]=!!n&&!O(function(){if(i&&!bt)return 1;var t={length:-1};i?Oe(t,1,{enumerable:!0,get:J}):t[1]=1,n.call(t,r,o)}))}function Q(i,r,t){if(Ie(i),void 0===r)return i;switch(t){case 0:return function(){return i.call(r)};case 1:return function(t){return i.call(r,t)};case 2:return function(t,e){return i.call(r,t,e)};case 3:return function(t,e,n){return i.call(r,t,e,n)}}return function(){return i.apply(r,arguments)}}function nt(t,e,n){return Q(Ve,yt[t].prototype[e],n)}function it(t){return Object(kt(t))}function rt(t,e){var n;return new(void 0===(n=Be(t)&&("function"==typeof(n=t.constructor)&&(n===Array||Be(n.prototype))||Lt(n)&&null===(n=n[De]))?void 0:n)?Array:n)(0===e?0:e)}function ot(d){var f=1==d,p=2==d,g=3==d,m=4==d,v=6==d,y=7==d,b=5==d||v;return function(t,e,n,i){for(var r,o,s=it(t),a=St(s),l=Q(e,n,3),h=U(a.length),u=0,e=i||rt,c=f?e(t,h):p||y?e(t,0):void 0;u<h;u++)if((b||u in a)&&(o=l(r=a[u],u,s),d))if(f)c[u]=o;else if(o)switch(d){case 3:return!0;case 5:return r;case 6:return u;case 2:ze.call(c,r)}else switch(d){case 4:return!1;case 7:ze.call(c,r)}return v?-1:g||m?m:c}}function st(r){return function(t,e){var n,t=String(kt(t)),e=te(e),i=t.length;return e<0||i<=e?r?"":void 0:(n=t.charCodeAt(e))<55296||56319<n||e+1===i||(i=t.charCodeAt(e+1))<56320||57343<i?r?t.charAt(e):n:r?t.slice(e,e+2):i-56320+(n-55296<<10)+65536}}function at(){return this}var lt,ht,ut,ct,dt,ft,pt,gt,mt,vt,yt=N("object"==typeof globalThis&&globalThis)||N("object"==typeof window&&window)||N("object"==typeof self&&self)||N("object"==typeof e&&e)||function(){return this}()||Function("return this")(),bt=!O(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),e={}.propertyIsEnumerable,xt=Object.getOwnPropertyDescriptor,wt={f:xt&&!e.call({1:2},1)?function(t){t=xt(this,t);return!!t&&t.enumerable}:e},At=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Pt={}.toString,Et=function(t){return Pt.call(t).slice(8,-1)},Tt="".split,St=O(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==Et(t)?Tt.call(t,""):Object(t)}:Object,kt=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},Lt=function(t){return"object"==typeof t?null!==t:"function"==typeof t},Ct=function(t,e){if(!Lt(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!Lt(i=n.call(t))||"function"==typeof(n=t.valueOf)&&!Lt(i=n.call(t))||!e&&"function"==typeof(n=t.toString)&&!Lt(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")},Mt={}.hasOwnProperty,_t=function(t,e){return Mt.call(t,e)},Nt=yt.document,Ot=Lt(Nt)&&Lt(Nt.createElement),Rt=function(t){return Ot?Nt.createElement(t):{}},Ft=!bt&&!O(function(){return 7!=Object.defineProperty(Rt("div"),"a",{get:function(){return 7}}).a}),It=Object.getOwnPropertyDescriptor,Vt={f:bt?It:function(t,e){if(t=F(t),e=Ct(e,!0),Ft)try{return It(t,e)}catch(t){}if(_t(t,e))return At(!wt.f.call(t,e),t[e])}},Bt=function(t){if(Lt(t))return t;throw TypeError(String(t)+" is not an object")},Dt=Object.defineProperty,zt={f:bt?Dt:function(t,e,n){if(Bt(t),e=Ct(e,!0),Bt(n),Ft)try{return Dt(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},jt=bt?function(t,e,n){return zt.f(t,e,At(1,n))}:function(t,e,n){return t[e]=n,t},e="__core-js_shared__",Gt=yt[e]||I(e,{}),Ut=Function.toString,Ht=("function"!=typeof Gt.inspectSource&&(Gt.inspectSource=function(t){return Ut.call(t)}),Gt.inspectSource),e=yt.WeakMap,e="function"==typeof e&&/native code/.test(Ht(e)),n=_(function(t){(t.exports=function(t,e){return Gt[t]||(Gt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.8.3",mode:"global",copyright:"\xa9 2021 Denis Pushkarev (zloirock.ru)"})}),qt=0,$t=Math.random(),Wt=n("keys"),Yt={},i=yt.WeakMap,Xt=(pt=e?(lt=Gt.state||(Gt.state=new i),ht=lt.get,ut=lt.has,ct=lt.set,dt=function(t,e){return e.facade=t,ct.call(lt,t,e),e},ft=function(t){return ht.call(lt,t)||{}},function(t){return ut.call(lt,t)}):(gt=z("state"),Yt[gt]=!0,dt=function(t,e){return e.facade=t,jt(t,gt,e),e},ft=function(t){return _t(t,gt)?t[gt]:{}},function(t){return _t(t,gt)}),{set:dt,get:ft,has:pt,enforce:function(t){return pt(t)?ft(t):dt(t,{})},getterFor:function(e){return function(t){if(Lt(t)&&(t=ft(t)).type===e)return t;throw TypeError("Incompatible receiver, "+e+" required")}}}),Zt=_(function(t){var e=Xt.get,a=Xt.enforce,l=String(String).split("String");(t.exports=function(t,e,n,i){var r,o=!!i&&!!i.unsafe,s=!!i&&!!i.enumerable,i=!!i&&!!i.noTargetGet;"function"==typeof n&&("string"!=typeof e||_t(n,"name")||jt(n,"name",e),(r=a(n)).source||(r.source=l.join("string"==typeof e?e:""))),t===yt?s?t[e]=n:I(e,n):(o?!i&&t[e]&&(s=!0):delete t[e],s?t[e]=n:jt(t,e,n))})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||Ht(this)})}),Jt=yt,Kt=Math.ceil,Qt=Math.floor,te=function(t){return isNaN(t=+t)?0:(0<t?Qt:Kt)(t)},ee=Math.min,ne=Math.max,ie=Math.min,e={includes:H(!0),indexOf:H(!1)},re=e.indexOf,oe=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],se=oe.concat("length","prototype"),ae={f:Object.getOwnPropertyNames||function(t){return q(t,se)}},le={f:Object.getOwnPropertySymbols},he=G("Reflect","ownKeys")||function(t){var e=ae.f(Bt(t)),n=le.f;return n?e.concat(n(t)):e},ue=/#|\.prototype\./,ce=$.normalize=function(t){return String(t).replace(ue,".").toLowerCase()},de=$.data={},fe=$.NATIVE="N",pe=$.POLYFILL="P",ge=$,me=Vt.f,ve=!!Object.getOwnPropertySymbols&&!O(function(){return!String(Symbol())}),i=ve&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ye=n("wks"),be=yt.Symbol,xe=i?be:be&&be.withoutSetter||D,we=Object.keys||function(t){return q(t,oe)},Ae=bt?Object.defineProperties:function(t,e){Bt(t);for(var n,i=we(e),r=i.length,o=0;o<r;)zt.f(t,n=i[o++],e[n]);return t},Pe=G("document","documentElement"),Ee=">",Te="<",Se="prototype",ke="script",Le=z("IE_PROTO"),Ce=function(t){return Te+ke+Ee+t+Te+"/"+ke+Ee},Me=function(){try{mt=document.domain&&new ActiveXObject("htmlfile")}catch(t){}Me=mt?((t=mt).write(Ce("")),t.close(),e=t.parentWindow.Object,t=null,e):(t=Rt("iframe"),e="java"+ke+":",t.style.display="none",Pe.appendChild(t),t.src=String(e),(e=t.contentWindow.document).open(),e.write(Ce("document.F=Object")),e.close(),e.F);for(var t,e,n=oe.length;n--;)delete Me[Se][oe[n]];return Me()},n=(Yt[Le]=!0,Object.create||function(t,e){var n;return null!==t?(X[Se]=Bt(t),n=new X,X[Se]=null,n[Le]=t):n=Me(),void 0===e?n:Ae(n,e)}),_e=Y("unscopables"),Ne=Array.prototype,Oe=(null==Ne[_e]&&zt.f(Ne,_e,{configurable:!0,value:n(null)}),Object.defineProperty),Re={},Fe=e.includes,i=K("indexOf",{ACCESSORS:!0,1:0}),Ie=(W({target:"Array",proto:!0,forced:!i},{includes:function(t){return Fe(this,t,1<arguments.length?arguments[1]:void 0)}}),Z("includes"),function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}),Ve=Function.call,Be=(nt("Array","includes"),Array.isArray||function(t){return"Array"==Et(t)}),De=Y("species"),ze=[].push,e={forEach:ot(0),map:ot(1),filter:ot(2),some:ot(3),every:ot(4),find:ot(5),findIndex:ot(6),filterOut:ot(7)},je=e.find,i="find",Ge=!0,r=K(i),r=(i in[]&&Array(1)[i](function(){Ge=!1}),W({target:"Array",proto:!0,forced:Ge||!r},{find:function(t){return je(this,t,1<arguments.length?arguments[1]:void 0)}}),Z(i),nt("Array","find"),{codeAt:st(!1),charAt:st(!0)}),i=!O(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),Ue=z("IE_PROTO"),He=Object.prototype,i=i?Object.getPrototypeOf:function(t){return t=it(t),_t(t,Ue)?t[Ue]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?He:null},qe=Y("iterator"),$e=!1,We=([].keys&&("next"in(We=[].keys())?(We=i(i(We)))!==Object.prototype&&(vt=We):$e=!0),null==vt||O(function(){var t={};return vt[qe].call(t)!==t})),We=(_t(vt=We?{}:vt,qe)||jt(vt,qe,function(){return this}),{IteratorPrototype:vt,BUGGY_SAFARI_ITERATORS:$e}),Ye=zt.f,Xe=Y("toStringTag"),$e=function(t,e,n){t&&!_t(t=n?t:t.prototype,Xe)&&Ye(t,Xe,{configurable:!0,value:e})},Ze={},o=We.IteratorPrototype,Je=function(){return this},s=Object.setPrototypeOf||("__proto__"in{}?(()=>{var n,i=!1,t={};try{(n=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(t,[]),i=t instanceof Array}catch(t){}return function(t,e){return Bt(t),(t=>{if(Lt(t)||null===t)return;throw TypeError("Can't set "+String(t)+" as a prototype")})(e),i?n.call(t,e):t.__proto__=e,t}})():void 0),a=We.IteratorPrototype,Ke=We.BUGGY_SAFARI_ITERATORS,We=Y("iterator"),Qe="values",tn="entries",en=r.charAt,nn="String Iterator",rn=Xt.set,on=Xt.getterFor(nn),r=String,sn="String",an=function(t){rn(this,{type:nn,string:String(t),index:0})},l=function(){var t=on(this),e=t.string,n=t.index;return n>=e.length?{value:void 0,done:!0}:(e=en(e,n),t.index+=e.length,{value:e,done:!1})},ln=void 0,h=void 0,hn=void 0;function un(t){if(t===ln&&mn)return mn;if(!Ke&&t in pn)return pn[t];switch(t){case"keys":case Qe:case tn:return function(){return new an(this,t)}}return function(){return new an(this)}}c=sn,c+=" Iterator",(u=an).prototype=n(o,{next:At(1,l)}),$e(u,c,!1,!0),Ze[c]=Je;var cn,dn,l=sn+" Iterator",fn=!1,pn=r.prototype,gn=pn[We]||pn["@@iterator"]||ln&&pn[ln],mn=!Ke&&gn||un(ln),u="Array"==sn&&pn.entries||gn;if(u&&(c=i(u.call(new r)),a!==Object.prototype)&&c.next&&(i(c)!==a&&(s?s(c,a):"function"!=typeof c[We]&&jt(c,We,at)),$e(c,l,!0,!0)),ln==Qe&&gn&&gn.name!==Qe&&(fn=!0,mn=function(){return gn.call(this)}),pn[We]!==mn&&jt(pn,We,mn),Ze[sn]=mn,ln)if(cn={values:un(Qe),keys:h?mn:un("keys"),entries:un(tn)},hn)for(dn in cn)!Ke&&!fn&&dn in pn||Zt(pn,dn,cn[dn]);else W({target:sn,proto:!0,forced:Ke||fn},cn);function vn(t,e,n){(e=Ct(e))in t?zt.f(t,e,At(0,n)):t[e]=n}var yn=function(t){var e=t.return;if(void 0!==e)return Bt(e.call(t)).value},bn=Y("iterator"),xn=Array.prototype,n={},o=(n[Y("toStringTag")]="z","[object z]"===String(n)),wn=Y("toStringTag"),An="Arguments"==Et(function(){return arguments}()),Pn=o?Et:function(t){var e;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=((t,e)=>{try{return t[e]}catch(t){}})(t=Object(t),wn))?e:An?Et(t):"Object"==(e=Et(t))&&"function"==typeof t.callee?"Arguments":e},En=Y("iterator"),Tn=Y("iterator"),Sn=!1;try{var kn=0,Ln={next:function(){return{done:!!kn++}},return:function(){Sn=!0}};Ln[Tn]=function(){return this},Array.from(Ln,function(){throw 2})}catch(t){}function Cn(t){if(Lt(e=t)&&(void 0!==(n=e[Rn])?!!n:"RegExp"==Et(e)))throw TypeError("The method doesn't accept regular expressions");var e,n;return t}function Mn(e){var n=/./;try{"/./"[e](n)}catch(t){try{return n[Fn]=!1,"/./"[e](n)}catch(t){}}return!1}var Je=!((t,e)=>{if(!e&&!Sn)return!1;var n=!1;try{var i={};i[Tn]=function(){return{next:function(){return{done:n=!0}}}},t(i)}catch(t){}return n})(function(t){Array.from(t)}),_n=(W({target:"Array",stat:!0,forced:Je},{from:function(t){var e,n,i,r,o,s,a=it(t),t="function"==typeof this?this:Array,l=arguments.length,h=1<l?arguments[1]:void 0,u=void 0!==h,c=(t=>{if(null!=t)return t[En]||t["@@iterator"]||Ze[Pn(t)]})(a),d=0;if(u&&(h=Q(h,2<l?arguments[2]:void 0,2)),null!=c&&(t!=Array||void 0===(l=c)||Ze.Array!==l&&xn[bn]!==l))for(o=(r=c.call(a)).next,n=new t;!(i=o.call(r)).done;d++)s=u?((e,t,n,i)=>{try{return i?t(Bt(n)[0],n[1]):t(n)}catch(t){throw yn(e),t}})(r,h,[i.value,d],!0):i.value,vn(n,d,s);else for(n=new t(e=U(a.length));d<e;d++)s=u?h(a[d],d):a[d],vn(n,d,s);return n.length=d,n}}),Jt.Array.from,e.findIndex),u="findIndex",Nn=!0,r=K(u),On=(u in[]&&Array(1)[u](function(){Nn=!1}),W({target:"Array",proto:!0,forced:Nn||!r},{findIndex:function(t){return _n(this,t,1<arguments.length?arguments[1]:void 0)}}),Z(u),nt("Array","findIndex"),_(function(t,e){function a(t){this.message=t}var l;e=e,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",(a.prototype=new Error).name="InvalidCharacterError",e.btoa||(e.btoa=function(t){for(var e,n,i=String(t),r=0,o=l,s="";i.charAt(0|r)||(o="=",r%1);s+=o.charAt(63&e>>8-r%1*8)){if(255<(n=i.charCodeAt(r+=.75)))throw new a("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");e=e<<8|n}return s}),e.atob||(e.atob=function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new a("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,r=0,o=0,s="";i=e.charAt(o++);~i&&(n=r%4?64*n+i:i,r++%4)&&(s+=String.fromCharCode(255&n>>(-2*r&6))))i=l.indexOf(i);return s})}),W({target:"Number",stat:!0},{isNaN:function(t){return t!=t}}),Jt.Number.isNaN,yt.isFinite),i=Number.isFinite||function(t){return"number"==typeof t&&On(t)},Rn=(W({target:"Number",stat:!0},{isFinite:i}),Jt.Number.isFinite,Y("match")),Fn=Y("match"),s=(W({target:"String",proto:!0,forced:!Mn("includes")},{includes:function(t){return!!~String(kt(this)).indexOf(Cn(t),1<arguments.length?arguments[1]:void 0)}}),nt("String","includes"),Vt.f),In="".startsWith,Vn=Math.min,a=Mn("startsWith"),c=!(a||!($e=s(String.prototype,"startsWith"))||$e.writable);W({target:"String",proto:!0,forced:!c&&!a},{startsWith:function(t){var e=String(kt(this)),n=(Cn(t),U(Vn(1<arguments.length?arguments[1]:void 0,e.length))),t=String(t);return In?In.call(e,t,n):e.slice(n,n+t.length)===t}}),nt("String","startsWith");function Bn(t,e){return this.slice(t,e)}function Dn(t,e){arguments.length<2&&(e=0);for(var n=0,i=t.length;n<i;++n,++e)this[e]=255&t[n]}function zn(t){if("number"==typeof t)for(var e=new Array(t),n=0;n<t;++n)e[n]=0;else e=t.slice(0);return e.subarray=Bn,(e.buffer=e).byteLength=e.length,e.set=Dn,"object"==typeof t&&t.buffer&&(e.buffer=t.buffer),e}"undefined"==typeof Uint8Array&&"undefined"!=typeof window&&(window.Int32Array=window.Uint32Array=window.Uint8Array=zn);let{round:jn,floor:Gn,PI:Un}=Math;function Hn(t){return 180*t/Un%360}function qn(t,e){var n;return void 0===e?(e=void 0===t?1:t,t=0):e<t&&(n=t,t=e,e=n),Gn(Math.random()*(e-t+1)+t)}function $n(t,e){var n=Jn(t.y),i=Jn(e.y),t=t.x,e=e.x,e=Jn(e-t),t=Qn(e)*Kn(i),n=Kn(n)*Qn(i)-Qn(n)*Kn(i)*Kn(e);return(i=Hn(ti(t,n))-22.5)<0&&(i+=360),["NE","E","SE","S","SW","W","NW","N"][i=parseInt(i/45)]}function Wn(t,e){var n=t.x,t=t.y;return(n-=e.x)*n+(t-=e.y)*t}function Yn(t,e){return Math.sqrt(Wn(t,e))}let Xn=function(t){return t%360+(t<0?360:0)},Zn=function(t,e){return e*jn(t/e)},Jn=function(t,e){return(t=(e=e||!1)?t:t%360)*Un/180},{cos:Kn,sin:Qn,atan2:ti}=Math,d={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},{abs:ei,cos:ni,sin:ii,sqrt:ri,min:oi,max:si,atan2:ai,round:li,pow:hi,PI:ui}=Math,A=function(t,e){if(!(this instanceof A))return new A(t,e);var n;"string"==typeof t?(n=t.split(-1===t.indexOf("@")?" ":"@"),t=parseFloat(n[0]),e=parseFloat(n[1])):Object(t)===t&&(e=t.y,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e},ci=(A.fromPolar=function(t,e,n){n=new A(n);var i=ei(t*ni(e)),t=ei(t*ii(e)),e=Xn(Hn(e));return e<90?t=-t:e<180?(i=-i,t=-t):e<270&&(i=-i),new A(n.x+i,n.y+t)},A.random=function(t,e,n,i){return new A(qn(t,e),qn(n,i))},A.prototype={type:d.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new A(t[0]);for(var n=null,i=1/0,r=0;r<e;r++){var o=new A(t[r]),s=this.squaredDistance(o);s<i&&(n=o,i=s)}return n},adhereToRect:function(t){return t.containsPoint(this)||(this.x=oi(si(this.x,t.x),t.x+t.width),this.y=oi(si(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){e=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return e<0&&(e+=360),e},bearing:function(t){return $n(this,t)},changeInAngle:function(t,e,n){return this.clone().offset(-t,-e).theta(n)-this.theta(n)},clone:function(){return new A(this)},cross:function(t,e){return t&&e?(e.x-this.x)*(t.y-this.y)-(e.y-this.y)*(t.x-this.x):NaN},difference:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),new A(this.x-(t||0),this.y-(e||0))},distance:function(t){return Yn(this,t)},dot:function(t){return t?this.x*t.x+this.y*t.y:NaN},equals:function(t){return!!t&&this.x===t.x&&this.y===t.y},lerp:function(t,e){var n=this.x,i=this.y;return new A((1-e)*n+e*t.x,(1-e)*i+e*t.y)},magnitude:function(){return ri(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return ei(t.x-this.x)+ei(t.y-this.y)},move:function(t,e){t=Jn(new A(t).theta(this));return this.offset(ni(t)*e,-ii(t)*e)},normalize:function(t){t=(t||1)/this.magnitude();return this.scale(t,t)},offset:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x+=t||0,this.y+=e||0,this},reflection:function(t){return new A(t).move(this,this.distance(t))},rotate:function(t,e){var n,i;return 0!==e&&(t=t||new A(0,0),e=Jn(Xn(-e)),n=ni(e),e=ii(e),i=n*(this.x-t.x)-e*(this.y-t.y)+t.x,e=e*(this.x-t.x)+n*(this.y-t.y)+t.y,this.x=i,this.y=e),this},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=hi(10,t)}return this.x=li(this.x*e)/e,this.y=li(this.y*e)/e,this},scale:function(t,e,n){return n=n&&new A(n)||new A(0,0),this.x=n.x+t*(this.x-n.x),this.y=n.y+e*(this.y-n.y),this},snapToGrid:function(t,e){return this.x=Zn(this.x,t),this.y=Zn(this.y,e||t),this},squaredDistance:function(t){return Wn(this,t)},theta:function(t){var e=-((t=new A(t)).y-this.y),t=t.x-this.x,e=ai(e,t);return 180*(e=e<0?2*ui+e:e)/ui},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new A(t)||new A(0,0);var e=this.x,n=this.y;return this.x=ri((e-t.x)*(e-t.x)+(n-t.y)*(n-t.y)),this.y=Jn(t.theta(new A(e,n))),this},toString:function(){return this.x+"@"+this.y},serialize:function(){return this.x+","+this.y},update:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x=t||0,this.y=e||0,this},vectorAngle:function(t){return new A(0,0).angleBetween(this,t)}},A.prototype.translate=A.prototype.offset,A),{max:di,min:fi}=Math,P=function(t,e){return this instanceof P?t instanceof P?new P(t.start,t.end):(this.start=new A(t),void(this.end=new A(e))):new P(t,e)},pi=(P.prototype={type:d.Line,angle:function(){var t=new A(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=fi(this.start.x,this.end.x),e=fi(this.start.y,this.end.y),n=di(this.start.x,this.end.x),i=di(this.start.y,this.end.y);return new tt(t,e,n-t,i-e)},bearing:function(){return $n(this.start,this.end)},clone:function(){return new P(this.start,this.end)},closestPoint:function(t){return this.pointAt(this.closestPointNormalizedLength(t))},closestPointLength:function(t){return this.closestPointNormalizedLength(t)*this.length()},closestPointNormalizedLength:function(t){t=this.vector().dot(new P(this.start,t).vector()),t=fi(1,di(0,t/this.squaredLength()));return t!=t?0:t},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e,n=this.start,i=this.end;return 0===n.cross(t,i)&&(e=this.length(),!(new P(n,t).length()>e||new P(t,i).length()>e))},divideAt:function(t){t=this.pointAt(t);return[new P(this.start,t),new P(t,this.end)]},divideAtLength:function(t){t=this.pointAtLength(t);return[new P(this.start,t),new P(t,this.end)]},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.end.x===t.end.x&&this.end.y===t.end.y},intersect:function(t,e){return t&&t.intersectionWithLine?(e=t.intersectionWithLine(this,e))&&t instanceof P?e[0]:e:null},intersectionWithLine:function(t){var e=new A(this.end.x-this.start.x,this.end.y-this.start.y),n=new A(t.end.x-t.start.x,t.end.y-t.start.y),i=e.x*n.y-e.y*n.x,t=new A(t.start.x-this.start.x,t.start.y-this.start.y),n=t.x*n.y-t.y*n.x,t=t.x*e.y-t.y*e.x;if(0==i||n*i<0||t*i<0)return null;if(0<i){if(i<n||i<t)return null}else if(n<i||t<i)return null;return[new A(this.start.x+n*e.x/i,this.start.y+n*e.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return Yn(this.start,this.end)},midpoint:function(){return new A((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){var e,n,i,r,o=this.clone();return this.isDifferentiable()&&({start:e,end:n}=o,i=e.clone().rotate(n,270),r=n.clone().rotate(e,90),e.move(r,t),n.move(i,t)),o},pointAt:function(t){var e=this.start,n=this.end;return t<=0?e.clone():1<=t?n.clone():e.lerp(n,t)},pointAtLength:function(t){var e=this.start,n=this.end,i=!0,r=(t<0&&(i=!1,t=-t),this.length());return r<=t?(i?n:e).clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new A(t);var e=this.start,n=this.end;return((n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x))/this.length()},rotate:function(t,e){return this.start.rotate(t,e),this.end.rotate(t,e),this},round:function(t){return this.start.round(t),this.end.round(t),this},scale:function(t,e,n){return this.start.scale(t,e,n),this.end.scale(t,e,n),this},setLength:function(t){var e=this.length();return e?this.scale(t=t/e,t,this.start):this},squaredLength:function(){return Wn(this.start,this.end)},tangentAt:function(t){var e,n;return this.isDifferentiable()?(e=this.start,n=this.end,t=this.pointAt(t),(n=new P(e,n)).translate(t.x-e.x,t.y-e.y),n):null},tangentAtLength:function(t){var e,n;return this.isDifferentiable()?(e=this.start,n=this.end,t=this.pointAtLength(t),(n=new P(e,n)).translate(t.x-e.x,t.y-e.y),n):null},toString:function(){return this.start.toString()+" "+this.end.toString()},serialize:function(){return this.start.serialize()+" "+this.end.serialize()},translate:function(t,e){return this.start.translate(t,e),this.end.translate(t,e),this},vector:function(){return new A(this.end.x-this.start.x,this.end.y-this.start.y)}},P.prototype.intersection=P.prototype.intersect,P),{sqrt:gi,round:mi,pow:vi}=Math,yi=function(t,e,n){return this instanceof yi?t instanceof yi?new yi(new A(t.x,t.y),t.a,t.b):(t=new A(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=n)):new yi(t,e,n)};yi.fromRect=function(t){return t=new tt(t),new yi(t.center(),t.width/2,t.height/2)},yi.prototype={type:d.Ellipse,bbox:function(){return new tt(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new A(this.x,this.y)},clone:function(){return new yi(this)},containsPoint:function(t){return this.normalizedDistance(t)<=1},equals:function(t){return!!t&&t.x===this.x&&t.y===this.y&&t.a===this.a&&t.b===this.b},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.a+=2*t,this.b+=2*e,this},intersectionWithLine:function(t){var e=[],n=t.start,i=t.end,r=this.a,o=this.b,t=t.vector(),s=n.difference(new A(this)),a=new A(t.x/(r*r),t.y/(o*o)),r=new A(s.x/(r*r),s.y/(o*o)),o=t.dot(a),a=t.dot(r),t=a*a-o*(s.dot(r)-1);if(t<0)return null;if(0<t){s=gi(t),r=(-a-s)/o,t=(-a+s)/o;if((r<0||1<r)&&(t<0||1<t))return null;0<=r&&r<=1&&e.push(n.lerp(i,r)),0<=t&&t<=1&&e.push(n.lerp(i,t))}else{s=-a/o;if(!(0<=s&&s<=1))return null;e.push(n.lerp(i,s))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new A(t),e&&t.rotate(new A(this.x,this.y),e);var n,i,r,o=t.x-this.x,s=t.y-this.y;return r=0==o?this.bbox().pointNearestToPoint(t):(s=(t=s/o)*t,i=this.a*this.a,n=this.b*this.b,i=gi(1/(1/i+s/n)),s=t*(i=o<0?-i:i),new A(this.x+i,this.y+s)),e?r.rotate(new A(this.x,this.y),-e):r},normalizedDistance:function(t){var e=t.x,t=t.y,n=this.a,i=this.b,r=this.x,o=this.y;return(e-r)*(e-r)/(n*n)+(t-o)*(t-o)/(i*i)},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=vi(10,t)}return this.x=mi(this.x*e)/e,this.y=mi(this.y*e)/e,this.a=mi(this.a*e)/e,this.b=mi(this.b*e)/e,this},tangentTheta:function(t){var e,n,i=t.x,r=t.y,o=this.a,s=this.b,a=this.bbox().center(),l=a.x,h=a.y;return a.x+o/2<i||i<a.x-o/2?n=o*o/(i-l)-o*o*(r-h)*((e=i>a.x?r-30:r+30)-h)/(s*s*(i-l))+l:e=s*s/(r-h)-s*s*(i-l)*((n=r>a.y?i+30:i-30)-l)/(o*o*(r-h))+h,new A(n,e).theta(t)},toString:function(){return new A(this.x,this.y).toString()+" "+this.a+" "+this.b}};l=yi;let{abs:bi,cos:xi,sin:wi,min:Ai,max:Pi,round:Ei,pow:Ti}=Math,tt=function(t,e,n,i){if(!(this instanceof tt))return new tt(t,e,n,i);Object(t)===t&&(e=t.y,n=t.width,i=t.height,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e,this.width=void 0===n?0:n,this.height=void 0===i?0:i};tt.fromEllipse=function(t){return t=new yi(t),new tt(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},tt.fromPointUnion=function(){if(0===arguments.length)return null;var e=new A;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let t=0;t<arguments.length;t++){e.update(t<0||arguments.length<=t?void 0:arguments[t]);var s=e.x,a=e.y;s<n&&(n=s),s>r&&(r=s),a<i&&(i=a),a>o&&(o=a)}return new tt(n,i,r-n,o-i)},tt.fromRectUnion=function(){if(0===arguments.length)return null;var e=new tt;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let t=0;t<arguments.length;t++){e.update(t<0||arguments.length<=t?void 0:arguments[t]);var s=e.x,a=e.y,l=s+e.width,h=a+e.height;s<n&&(n=s),l>r&&(r=l),a<i&&(i=a),h>o&&(o=h)}return new tt(n,i,r-n,o-i)},tt.prototype={type:d.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){var e,n,i,r;return t&&({width:i,height:e}=this,t=Jn(t),r=i*(n=bi(wi(t)))+e*(t=bi(xi(t))),this.x+=(i-(i=i*t+e*n))/2,this.y+=(e-r)/2,this.width=i,this.height=r),this},bottomLeft:function(){return new A(this.x,this.y+this.height)},bottomLine:function(){return new P(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new A(this.x+this.width/2,this.y+this.height)},center:function(){return new A(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new tt(this)},containsPoint:function(t,e){let n,i;return t&&"string"!=typeof t?{x:n=0,y:i=0}=t:{x:n,y:i}=new A(t),e&&e.strict?n>this.x&&n<this.x+this.width&&i>this.y&&i<this.y+this.height:n>=this.x&&n<=this.x+this.width&&i>=this.y&&i<=this.y+this.height},containsRect:function(t){var e,n,i=new tt(this).normalize(),t=new tt(t).normalize(),r=i.width,o=i.height,s=t.width,a=t.height;return!!(r&&o&&s&&a)&&(e=i.x,i=i.y,s+=n=t.x,r+=e,a+=t=t.y,o+=i,e<=n)&&s<=r&&i<=t&&a<=o},corner:function(){return new A(this.x+this.width,this.y+this.height)},equals:function(t){var e=new tt(this).normalize(),t=new tt(t).normalize();return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this},intersect:function(t){var e,n=this.origin(),i=this.corner(),r=t.origin(),t=t.corner();return t.x<=n.x||t.y<=n.y||r.x>=i.x||r.y>=i.y?null:(e=Pi(n.x,r.x),n=Pi(n.y,r.y),new tt(e,n,Ai(i.x,t.x)-e,Ai(i.y,t.y)-n))},intersectionWithLine:function(t){for(var e,n=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],i=[],r=[],o=n.length,s=0;s<o;s++)null!==(e=t.intersect(n[s]))&&r.indexOf(e.toString())<0&&(i.push(e),r.push(e.toString()));return 0<i.length?i:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new A(t);for(var n,i=new A(this.x+this.width/2,this.y+this.height/2),r=(e&&t.rotate(i,e),[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()]),o=new P(i,t),s=r.length-1;0<=s;--s){var a=r[s].intersection(o);if(null!==a){n=a;break}}return n&&e&&n.rotate(i,-e),n},leftLine:function(){return new P(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new A(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){t=new tt(t);var n,i,r,o,s,a,l,h=(e=e||t.center()).x,e=e.y,u=n=i=r=o=s=a=l=1/0,c=t.topLeft(),c=(c.x<h&&(u=(this.x-h)/(c.x-h)),c.y<e&&(o=(this.y-e)/(c.y-e)),t.bottomRight()),c=(c.x>h&&(n=(this.x+this.width-h)/(c.x-h)),e<c.y&&(s=(this.y+this.height-e)/(c.y-e)),t.topRight()),c=(c.x>h&&(i=(this.x+this.width-h)/(c.x-h)),c.y<e&&(a=(this.y-e)/(c.y-e)),t.bottomLeft());return c.x<h&&(r=(this.x-h)/(c.x-h)),e<c.y&&(l=(this.y+this.height-e)/(c.y-e)),{sx:Ai(u,n,i,r),sy:Ai(o,s,a,l)}},maxRectUniformScaleToFit:function(t,e){t=this.maxRectScaleToFit(t,e);return Ai(t.sx,t.sy)},moveAndExpand:function(t){return this.x+=t.x||0,this.y+=t.y||0,this.width+=t.width||0,this.height+=t.height||0,this},normalize:function(){var t=this.x,e=this.y,n=this.width,i=this.height;return this.width<0&&(t=this.x+this.width,n=-this.width),this.height<0&&(e=this.y+this.height,i=-this.height),this.x=t,this.y=e,this.width=n,this.height=i,this},offset:function(t,e){return A.prototype.offset.call(this,t,e)},origin:function(){return new A(this.x,this.y)},pointNearestToPoint:function(t){if(t=new A(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new A(this.x+this.width,t.y);case"left":return new A(this.x,t.y);case"bottom":return new A(t.x,this.y+this.height);case"top":return new A(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new P(this.topRight(),this.bottomRight())},rightMiddle:function(){return new A(this.x+this.width,this.y+this.height/2)},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=Ti(10,t)}return this.x=Ei(this.x*e)/e,this.y=Ei(this.y*e)/e,this.width=Ei(this.width*e)/e,this.height=Ei(this.height*e)/e,this},scale:function(t,e,n){return n=this.origin().scale(t,e,n),this.x=n.x,this.y=n.y,this.width*=t,this.height*=e,this},sideNearestToPoint:function(t){var e=(t=new A(t)).x-this.x,n=this.x+this.width-t.x,i=t.y-this.y,r="left";return n<e&&(e=n,r="right"),i<e&&(e=i,r="top"),r=this.y+this.height-t.y<e?"bottom":r},snapToGrid:function(t,e){var n=this.origin().snapToGrid(t,e),t=this.corner().snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=t.x-n.x,this.height=t.y-n.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new P(this.topLeft(),this.topRight())},topMiddle:function(){return new A(this.x+this.width/2,this.y)},topRight:function(){return new A(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return tt.fromRectUnion(this,t)},update:function(t,e,n,i){return Object(t)===t&&(e=t.y,n=t.width,i=t.height,t=t.x),this.x=t||0,this.y=e||0,this.width=n||0,this.height=i||0,this}},tt.prototype.bottomRight=tt.prototype.corner,tt.prototype.topLeft=tt.prototype.origin,tt.prototype.translate=tt.prototype.offset;h=tt;function Si(t){t=t.trim();if(""===t)return[];var e=[],n=t.split(/\b\s*,\s*|,\s*|\s+/),i=n.length;for(let t=0;t<i;t+=2)e.push({x:+n[t],y:+n[t+1]});return e}function ki(e){var n=e.length;if(0===n)return[];var i=[];for(let t=0;t<n;t++){var r=e[t].clone();i.push(r)}return i}function Li(t){var e,n=Math.abs,i=t.length;if(0===i)return[];for(o=0;o<i;o++)(void 0===e||t[o].y<e.y||t[o].y===e.y&&t[o].x>e.x)&&(e=t[o]);for(var r=[],o=0;o<i;o++){var s=e.theta(t[o]),s=(0===s&&(s=360),[t[o],o,s]);r.push(s)}r.sort(function(t,e){var n=t[2]-e[2];return n=0===n?e[1]-t[1]:n}),2<r.length&&r.unshift(r[r.length-1]);for(var a,l,h,u={},c=[];0!==r.length;)if(l=(a=r.pop())[0],!u.hasOwnProperty(a[0]+"@@"+a[1]))for(var d,f,p,g,m,v=!1;!v;)c.length<2?(c.push(a),v=!0):(f=(d=c.pop())[0],(m=(g=(p=c.pop())[0]).cross(f,l))<0?(c.push(p),c.push(d),c.push(a),v=!0):0!==m||n((m=f.angleBetween(g,l))-180)<1e-10||f.equals(l)||g.equals(f)?(u[d[0]+"@@"+d[1]]=f,c.push(p)):n((m+1)%360-1)<1e-10&&(c.push(p),r.push(d)));2<c.length&&c.pop();var y=-1,b=c.length;for(o=0;o<b;o++){var x=c[o][1];(void 0===h||x<h)&&(h=x,y=o)}var w,A,P=[],E=[];for(b=(P=0<y?(w=c.slice(y),A=c.slice(0,y),w.concat(A)):c).length,o=0;o<b;o++)E.push(P[o][0]);return E}let x=function(t){return this instanceof x?"string"==typeof t?new x.parse(t):void(this.points=Array.isArray(t)?t.map(A):[]):new x(t)},{abs:Ci,sqrt:Mi,min:_i,max:Ni,pow:Oi}=(x.parse=function(t){return new x(Si(t))},x.fromRect=function(t){return new x([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},x.prototype={type:d.Polyline,bbox:function(){var t=1/0,e=-1/0,n=1/0,i=-1/0,r=this.points,o=r.length;if(0===o)return null;for(var s=0;s<o;s++){var a=r[s],l=a.x,a=a.y;l<t&&(t=l),e<l&&(e=l),a<n&&(n=a),i<a&&(i=a)}return new tt(t,n,e-t,i-n)},clone:function(){return new x(ki(this.points))},closestPoint:function(t){t=this.closestPointLength(t);return this.pointAtLength(t)},closestPointLength:function(t){var e,n=this.lengthPoints(),i=n.length;if(0===i)return 0;if(1===i)return 0;for(var r=1/0,o=0,s=i-1,a=0;a<s;a++){var l=new P(n[a],n[a+1]),h=l.length(),u=l.closestPointNormalizedLength(t),l=l.pointAt(u).squaredDistance(t);l<r&&(r=l,e=o+u*h),o+=h}return e},closestPointNormalizedLength:function(t){var e,t=this.closestPointLength(t);return 0===t||0===(e=this.length())?0:t/e},closestPointTangent:function(t){t=this.closestPointLength(t);return this.tangentAtLength(t)},containsPoint:function(t){var e=this.points,n=e.length;if(0===n)return!1;for(var i=t.x,r=t.y,o=n-1,s=0,a=0,l=new P,h=new P,u=new A;s<n;s++){var c=e[o],d=e[s];if(t.equals(c))return!0;if(l.start=c,l.end=d,l.containsPoint(t))return!0;(r<=c.y&&r>d.y||r>c.y&&r<=d.y)&&0<=(c=c.x-i>d.x-i?c.x-i:d.x-i)&&(u.x=i+c,u.y=r,h.start=t,h.end=u,l.intersect(h))&&a++,o=s}return a%2==1},close:function(){var{start:t,end:e,points:n}=this;return t&&e&&!t.equals(e)&&n.push(t.clone()),this},lengthPoints:function(){return this.points},convexHull:function(){return new x(Li(this.points))},equals:function(t){if(!t)return!1;var e=this.points,n=t.points,i=e.length;if(n.length!==i)return!1;for(var r=0;r<i;r++){var o=e[r],s=t.points[r];if(!o.equals(s))return!1}return!0},intersectionWithLine:function(t){for(var e=new P(t),n=[],i=this.lengthPoints(),r=new P,o=0,s=i.length-1;o<s;o++){r.start=i[o],r.end=i[o+1];var a=e.intersectionWithLine(r);a&&n.push(a[0])}return 0<n.length?n:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0!==e)for(var n=new P,i=e-1,r=0;r<i;r++)if(n.start=t[r],n.end=t[r+1],n.isDifferentiable())return!0;return!1},length:function(){var t=this.lengthPoints(),e=t.length;if(0===e)return 0;for(var n=0,i=e-1,r=0;r<i;r++)n+=t[r].distance(t[r+1]);return n},pointAt:function(t){var e=this.lengthPoints(),n=e.length;return 0===n?null:1===n||t<=0?e[0].clone():1<=t?e[n-1].clone():(e=this.length(),this.pointAtLength(e*t))},pointAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();for(var i=!0,r=(t<0&&(i=!1,t=-t),0),o=n-1,s=0;s<o;s++){var a=i?s:o-1-s,l=e[a],a=e[a+1],h=new P(l,a),l=l.distance(a);if(t<=r+l)return h.pointAtLength((i?1:-1)*(t-r));r+=l}return(i?e[n-1]:e[0]).clone()},round:function(t){for(var e=this.points,n=e.length,i=0;i<n;i++)e[i].round(t);return this},scale:function(t,e,n){for(var i=this.points,r=i.length,o=0;o<r;o++)i[o].scale(t,e,n);return this},simplify:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=this.points;if(!(n.length<3)){var i=e.threshold||1e-10;let t=0;for(;n[t+2];){var r=t,o=t+1,s=t+2,r=n[r],a=n[o],s=n[s];new P(r,s).closestPoint(a).distance(a)<=i?n.splice(o,1):t+=1}}return this},tangentAt:function(t){var e=this.lengthPoints().length;if(0===e)return null;if(1===e)return null;1<(t=t<0?0:t)&&(t=1);e=this.length();return this.tangentAtLength(e*t)},tangentAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return null;for(var i,r=!0,o=(t<0&&(r=!1,t=-t),0),s=n-1,a=0;a<s;a++){var l=r?a:s-1-a,h=e[l],l=e[l+1],u=new P(h,l),h=h.distance(l);if(u.isDifferentiable()){if(t<=o+h)return u.tangentAtLength((r?1:-1)*(t-o));i=u}o+=h}return i?i.tangentAt(r?1:0):null},toString:function(){return this.points+""},translate:function(t,e){for(var n=this.points,i=n.length,r=0;r<i;r++)n[r].translate(t,e);return this},serialize:function(){var t=this.points,e=t.length;if(0===e)return"";for(var n="",i=0;i<e;i++){var r=t[i];n+=r.x+","+r.y+" "}return n.trim()}},Object.defineProperty(x.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(x.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}}),Math),v=function(t,e,n,i){return this instanceof v?t instanceof v?new v(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new A(t),this.controlPoint1=new A(e),this.controlPoint2=new A(n),void(this.end=new A(i))):new v(t,e,n,i)};function Ri(t){var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,n[o]=(t[o]-n[o-1])/(r=(o<e-1?4:3.5)-i[o]);for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n}function Fi(t){for(var e=[],n=arguments.length,i=1;i<n;i++)e.push(arguments[i]);if(!t)throw new Error("Missing a parent object.");var r=Object.create(t);for(n=e.length,i=0;i<n;i++){var o,s,a=e[i];for(s in a)a.hasOwnProperty(s)&&(delete r[s],o=Object.getOwnPropertyDescriptor(a,s),Object.defineProperty(r,s,o))}return r}v.throughPoints=function(t){if(!t||Array.isArray(t)&&t.length<2)throw new Error("At least 2 points are required");for(var e=(t=>{var e=[],n=[],i=t.length-1;if(1==i)e[0]=new A((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),n[0]=new A(2*e[0].x-t[0].x,2*e[0].y-t[0].y);else{for(var r=[],o=1;o<i-1;o++)r[o]=4*t[o].x+2*t[o+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var s=Ri(r);for(o=1;o<i-1;++o)r[o]=4*t[o].y+2*t[o+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var a=Ri(r);for(o=0;o<i;o++)e.push(new A(s[o],a[o])),n.push(o<i-1?new A(2*t[o+1].x-s[o+1],2*t[o+1].y-a[o+1]):new A((t[i].x+s[i-1])/2,(t[i].y+a[i-1])/2))}return[e,n]})(t),n=[],i=e[0].length,r=0;r<i;r++){var o=new A(e[0][r].x,e[0][r].y),s=new A(e[1][r].x,e[1][r].y);n.push(new v(t[r],o,s,t[r+1]))}return n},v.prototype={type:d.Curve,bbox:function(){for(var t,e,n,i,r,o=this.start,s=this.controlPoint1,a=this.controlPoint2,l=this.end,h=o.x,u=o.y,c=s.x,d=s.y,f=a.x,p=a.y,g=l.x,m=l.y,v=new Array,y=new Array,b=[new Array,new Array],x=0;x<2;++x)i=0===x?(e=6*h-12*c+6*f,t=-3*h+9*c-9*f+3*g,3*c-3*h):(e=6*u-12*d+6*p,t=-3*u+9*d-9*p+3*m,3*d-3*u),Ci(t)<1e-12?Ci(e)<1e-12||0<(n=-i/e)&&n<1&&y.push(n):(i=e*e-4*i*t,r=Mi(i),i<0||(0<(i=(-e+r)/(2*t))&&i<1&&y.push(i),0<(i=(-e-r)/(2*t))&&i<1&&y.push(i)));for(var w,A,P=y.length,o=P;P--;)n=y[P],b[0][P]=w=(A=1-n)*A*A*h+3*A*A*n*c+3*A*n*n*f+n*n*n*g,b[1][P]=A=A*A*A*u+3*A*A*n*d+3*A*n*n*p+n*n*n*m,v[P]={X:w,Y:A};y[o]=0,y[o+1]=1,v[o]={X:h,Y:u},v[o+1]={X:g,Y:m},b[0][o]=h,b[1][o]=u,b[0][o+1]=g,b[1][o+1]=m,y.length=o+2,b[0].length=o+2,b[1].length=o+2,v.length=o+2;s=_i.apply(null,b[0]),a=_i.apply(null,b[1]),l=Ni.apply(null,b[0]),o=Ni.apply(null,b[1]);return new tt(s,a,l-s,o-a)},clone:function(){return new v(this.start,this.controlPoint1,this.controlPoint2,this.end)},closestPoint:function(t,e){return this.pointAtT(this.closestPointT(t,e))},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,n),n)},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},e=this.closestPointLength(t,n);return!e||0===(t=this.length(n))?0:e/t},closestPointT:function(t,e){for(var n,i,r,o,s,a,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,h=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,u=h.length,c=u?1/u:0,d=0;d<u;d++){var f=h[d],p=f.start.distance(t),g=f.end.distance(t),m=p+g;(!a||m<a)&&(i=d*c,r=(d+1)*c,o=p,E=g,s=(n=f).start.distance(f.end),a=m)}for(var v=Oi(10,-l);;){var y=o?Ci(o-E)/o:0,b=E?Ci(o-E)/E:0;if(y<v||b<v||(!o||o<s*v||(!E||E<s*v)))return o<=E?i:r;var y=n.divide(.5),b=(c/=2,y[0].start.distance(t)),x=y[0].end.distance(t),w=b+x,A=y[1].start.distance(t),P=y[1].end.distance(t),E=w<=A+P?(n=y[0],r-=c,o=b,x):(n=y[1],i+=c,o=A,P)}},closestPointTangent:function(t,e){return this.tangentAtT(this.closestPointT(t,e))},containsPoint:function(t,e){return this.toPolyline(e).containsPoint(t)},divideAt:function(t,e){return t<=0?this.divideAtT(0):1<=t?this.divideAtT(1):(t=this.tAt(t,e),this.divideAtT(t))},divideAtLength:function(t,e){t=this.tAtLength(t,e);return this.divideAtT(t)},divideAtT:function(t){var e,n,i=this.start,r=this.controlPoint1,o=this.controlPoint2,s=this.end;return t<=0?[new v(i,i,i,i),new v(i,r,o,s)]:1<=t?[new v(i,r,o,s),new v(s,s,s,s)]:(o=(r=this.getSkeletonPoints(t)).startControlPoint1,t=r.startControlPoint2,e=r.divider,n=r.dividerControlPoint1,r=r.dividerControlPoint2,[new v(i,o,t,e),new v(e,n,r,s)])},endpointDistance:function(){return this.start.distance(this.end)},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.controlPoint1.x===t.controlPoint1.x&&this.controlPoint1.y===t.controlPoint1.y&&this.controlPoint2.x===t.controlPoint2.x&&this.controlPoint2.y===t.controlPoint2.y&&this.end.x===t.end.x&&this.end.y===t.end.y},getSkeletonPoints:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;return t<=0?{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:i.clone()}:1<=t?{startControlPoint1:n.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()}:(e=new P(e,n).pointAt(t),n=new P(n,i).pointAt(t),i=new P(i,r).pointAt(t),r=new P(e,n).pointAt(t),n=new P(n,i).pointAt(t),{startControlPoint1:e,startControlPoint2:r,divider:new P(r,n).pointAt(t),dividerControlPoint1:n,dividerControlPoint2:i})},getSubdivisions:function(t){var t=void 0===(t=t||{}).precision?this.PRECISION:t.precision,e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end,o=[new v(e,n,i,r)];if(0===t)return o;if(!this.isDifferentiable())return o;for(var s=this.endpointDistance(),a=Oi(10,-t),l=2,h=(0===n.cross(e,r)&&0===i.cross(e,r)&&(l=2*t),0);;){h+=1;for(var u=[],c=o.length,d=0;d<c;d++){var f=o[d].divide(.5);u.push(f[0],f[1])}for(var p=0,g=u.length,m=0;m<g;m++)p+=u[m].endpointDistance();if(l<=h)if((0!==p?(p-s)/p:0)<a)return u;o=u,s=p}},isDifferentiable:function(){var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},length:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=0,r=n.length,o=0;o<r;o++)i+=n[o].endpointDistance();return i},lengthAtT:function(t,e){return t<=0?0:(e=void 0===(e=e||{}).precision?this.PRECISION:e.precision,this.divide(t)[0].length({precision:e}))},pointAt:function(t,e){return t<=0?this.start.clone():1<=t?this.end.clone():(t=this.tAt(t,e),this.pointAtT(t))},pointAtLength:function(t,e){t=this.tAtLength(t,e);return this.pointAtT(t)},pointAtT:function(t){return t<=0?this.start.clone():1<=t?this.end.clone():this.getSkeletonPoints(t).divider},PRECISION:3,round:function(t){return this.start.round(t),this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,n){return this.start.scale(t,e,n),this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this},tangentAt:function(t,e){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);t=this.tAt(t,e);return this.tangentAtT(t)},tangentAtLength:function(t,e){return this.isDifferentiable()?(t=this.tAtLength(t,e),this.tangentAtT(t)):null},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);var t=this.getSkeletonPoints(t),e=t.startControlPoint2,n=t.dividerControlPoint1,t=t.divider,n=new P(e,n);return n.translate(t.x-e.x,t.y-e.y),n},tAt:function(t,e){var n;return t<=0?0:1<=t?1:(n={precision:n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},e=this.length(n),this.tAtLength(e*t,n))},tAtLength:function(t,e){for(var n,i,r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.subdivisions?this.getSubdivisions({precision:s}):e.subdivisions,e={precision:s,subdivisions:a},l=0,h=a.length,u=1/h,c=0;c<h;c++){var d=o?c:h-1-c,f=a[c],p=f.endpointDistance();if(t<=l+p){n=f,i=d*u,r=(d+1)*u,w=o?t-l:p+l-t,A=o?p+l-t:t-l;break}l+=p}if(!n)return o?1:0;for(var g=this.length(e),m=Oi(10,-s);;){var v,y=0!==g?w/g:0;if(y<m)return i;if((0!==g?A/g:0)<m)return r;var y=n.divide(.5),b=(u/=2,y[0].endpointDistance()),x=y[1].endpointDistance(),y=w<=b?(n=y[0],r-=u,b-(v=w)):(n=y[1],i+=u,x-(v=w-b)),w=v,A=y}},toPoints:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=[n[0].start.clone()],r=n.length,o=0;o<r;o++){var s=n[o];i.push(s.end.clone())}return i},toPolyline:function(t){return new x(this.toPoints(t))},toString:function(){return this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.start.translate(t,e),this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}},v.prototype.divide=v.prototype.divideAtT;let V=function(t){if(!(this instanceof V))return new V(t);if("string"==typeof t)return new V.parse(t);var e;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(e=(t=t.reduce(function(t,e){return t.concat(e)},[])).length,t[0].isSegment)for(r=0;r<e;r++){var n=t[r];this.appendSegment(n)}else for(var i=null,r=0;r<e;r++){var o=t[r];if(!(o instanceof P||o instanceof v))throw new Error("Cannot construct a path segment from the provided object.");0===r&&this.appendSegment(V.createSegment("M",o.start)),i&&!i.end.equals(o.start)&&this.appendSegment(V.createSegment("M",o.start)),o instanceof P?this.appendSegment(V.createSegment("L",o.end)):o instanceof v&&this.appendSegment(V.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),i=o}else if(t.isSegment)this.appendSegment(t);else if(t instanceof P)this.appendSegment(V.createSegment("M",t.start)),this.appendSegment(V.createSegment("L",t.end));else if(t instanceof v)this.appendSegment(V.createSegment("M",t.start)),this.appendSegment(V.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof x))throw new Error("Cannot construct a path from the provided object.");if(t.points&&0!==t.points.length)for(e=t.points.length,r=0;r<e;r++){var s=t.points[r];0===r?this.appendSegment(V.createSegment("M",s)):this.appendSegment(V.createSegment("L",s))}}};function Ii(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}V.parse=function(t){if(!t)return new V;for(var e=new V,n=t.match(/(?:[a-zA-Z] *)(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)? *,? *)|(?:-?\.\d+ *,? *))+|(?:[a-zA-Z] *)(?! |\d|-|\.)/g),i=n.length,r=0;r<i;r++){var o=n[r].match(/(?:[a-zA-Z])|(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)?))|(?:(?:-?\.\d+))/g),o=V.createSegment.apply(this,o);e.appendSegment(o)}return e},V.createSegment=function(t){if(!t)throw new Error("Type must be provided.");var e=V.segmentTypes[t];if(!e)throw new Error(t+" is not a recognized path segment type.");for(var n=[],i=arguments.length,r=1;r<i;r++)n.push(arguments[r]);return Ii(e,n)},V.prototype={type:d.Path,appendSegment:function(t){var e=this.segments,n=e.length,i=0!==n?e[n-1]:null;if(Array.isArray(t)){if(!(t=t.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");for(var r=t.length,o=0;o<r;o++){var s=t[o],a=this.prepareSegment(s,i,null);e.push(a),i=a}}else{if(!t||!t.isSegment)throw new Error("Segment required.");a=this.prepareSegment(t,i,null),e.push(a)}},bbox:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n,i=0;i<e;i++){var r,o=t[i];o.isVisible&&(o=o.bbox(),r=r?r.union(o):o)}return r||(n=t[e-1],new tt(n.end.x,n.end.y,0,0))},clone:function(){for(var t=this.segments,e=t.length,n=new V,i=0;i<e;i++){var r=t[i].clone();n.appendSegment(r)}return n},closestPoint:function(t,e){t=this.closestPointT(t,e);return t?this.pointAtT(t):null},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.closestPointT(t,n);return e?this.lengthAtT(e,n):0},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).pr