UNPKG

plotboilerplate

Version:

A simple javascript plotting boilerplate for 2d stuff.

1 lines 148 kB
(()=>{"use strict";var t={597:(t,e,i)=>{i.r(e),i.d(e,{AlloyFinger:()=>o,default:()=>a});const s=t=>Math.sqrt(t.x*t.x+t.y*t.y);class r{constructor(t){this.handlers=[],this.el=t}add(t){this.handlers.push(t)}del(t){t||(this.handlers=[]);for(var e=this.handlers.length;e>=0;e--)this.handlers[e]===t&&this.handlers.splice(e,1)}dispatch(...t){for(var e=0,i=this.handlers.length;e<i;e++){const t=this.handlers[e];"function"==typeof t&&t.apply(this.el,arguments)}}}const n=(t,e)=>{const i=new r(t);return i.add(e),i};class o{constructor(t,e){this.element="string"==typeof t?document.querySelector(t):t,this.start=this.start.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.cancel=this.cancel.bind(this),this.element.addEventListener("touchstart",this.start,!1),this.element.addEventListener("touchmove",this.move,!1),this.element.addEventListener("touchend",this.end,!1),this.element.addEventListener("touchcancel",this.cancel,!1),this.preV={x:null,y:null},this.pinchStartLen=null,this.zoom=1,this.isDoubleTap=!1;const i=()=>{};this.rotate=n(this.element,e.rotate||i),this.touchStart=n(this.element,e.touchStart||i),this.multipointStart=n(this.element,e.multipointStart||i),this.multipointEnd=n(this.element,e.multipointEnd||i),this.pinch=n(this.element,e.pinch||i),this.swipe=n(this.element,e.swipe||i),this.tap=n(this.element,e.tap||i),this.doubleTap=n(this.element,e.doubleTap||i),this.longTap=n(this.element,e.longTap||i),this.singleTap=n(this.element,e.singleTap||i),this.pressMove=n(this.element,e.pressMove||i),this.twoFingerPressMove=n(this.element,e.twoFingerPressMove||i),this.touchMove=n(this.element,e.touchMove||i),this.touchEnd=n(this.element,e.touchEnd||i),this.touchCancel=n(this.element,e.touchCancel||i),this._cancelAllHandler=this.cancelAll.bind(this),globalThis&&"function"==typeof globalThis.addEventListener&&globalThis.addEventListener("scroll",this._cancelAllHandler),this.delta=null,this.last=null,this.now=null,this.tapTimeout=null,this.singleTapTimeout=null,this.longTapTimeout=null,this.swipeTimeout=null,this.x1=this.x2=this.y1=this.y2=null,this.preTapPosition={x:null,y:null}}start(t){if(!t.touches)return;const e=this;this.now=Date.now(),this.x1=t.touches[0].pageX,this.y1=t.touches[0].pageY,this.delta=this.now-(this.last||this.now),this.touchStart.dispatch(t,this.element),null!==this.preTapPosition.x&&(this.isDoubleTap=this.delta>0&&this.delta<=250&&Math.abs(this.preTapPosition.x-this.x1)<30&&Math.abs(this.preTapPosition.y-this.y1)<30,this.isDoubleTap&&clearTimeout(this.singleTapTimeout)),this.preTapPosition.x=this.x1,this.preTapPosition.y=this.y1,this.last=this.now;const i=this.preV;if(t.touches.length>1){this._cancelLongTap(),this._cancelSingleTap();const e={x:t.touches[1].pageX-this.x1,y:t.touches[1].pageY-this.y1};i.x=e.x,i.y=e.y,this.pinchStartLen=s(i),this.multipointStart.dispatch(t,this.element)}this._preventTap=!1,this.longTapTimeout=setTimeout((()=>{e.longTap.dispatch(t,e.element),e._preventTap=!0}).bind(e),750)}move(t){if(!t.touches)return;const e=t,i=this.preV,r=t.touches.length,n=t.touches[0].pageX,o=t.touches[0].pageY;if(this.isDoubleTap=!1,r>1){const t=e.touches[1].pageX,r=e.touches[1].pageY,c={x:e.touches[1].pageX-n,y:e.touches[1].pageY-o};null!==i.x&&(this.pinchStartLen>0&&(e.zoom=s(c)/this.pinchStartLen,this.pinch.dispatch(e,this.element)),e.angle=(l=((t,e)=>{const i=s(t)*s(e);if(0===i)return 0;var r=((t,e)=>t.x*e.x+t.y*e.y)(t,e)/i;return r>1&&(r=1),Math.acos(r)})(a=c,h=i),((t,e)=>t.x*e.y-e.x*t.y)(a,h)>0&&(l*=-1),180*l/Math.PI),this.rotate.dispatch(e,this.element)),i.x=c.x,i.y=c.y,null!==this.x2&&null!==this.sx2?(e.deltaX=(n-this.x2+t-this.sx2)/2,e.deltaY=(o-this.y2+r-this.sy2)/2):(e.deltaX=0,e.deltaY=0),this.twoFingerPressMove.dispatch(e,this.element),this.sx2=t,this.sy2=r}else{if(null!==this.x2){e.deltaX=n-this.x2,e.deltaY=o-this.y2;const t=Math.abs(this.x1-this.x2),i=Math.abs(this.y1-this.y2);(t>10||i>10)&&(this._preventTap=!0)}else e.deltaX=0,e.deltaY=0;this.pressMove.dispatch(e,this.element)}var a,h,l;this.touchMove.dispatch(e,this.element),this._cancelLongTap(),this.x2=n,this.y2=o,r>1&&t.preventDefault()}end(t){if(!t.changedTouches)return;const e=t;this._cancelLongTap();const i=this;e.touches.length<2&&(this.multipointEnd.dispatch(e,this.element),this.sx2=this.sy2=null),this.x2&&Math.abs(this.x1-this.x2)>30||this.y2&&Math.abs(this.y1-this.y2)>30?(e.direction=this._swipeDirection(this.x1,this.x2,this.y1,this.y2),this.swipeTimeout=setTimeout((function(){i.swipe.dispatch(e,i.element)}),0)):(this.tapTimeout=setTimeout((function(){i._preventTap||i.tap.dispatch(e,i.element),i.isDoubleTap&&(i.doubleTap.dispatch(e,i.element),i.isDoubleTap=!1)}),0),i.isDoubleTap||(i.singleTapTimeout=setTimeout((function(){i.singleTap.dispatch(e,i.element)}),250))),this.touchEnd.dispatch(e,this.element),this.preV.x=0,this.preV.y=0,this.zoom=1,this.pinchStartLen=null,this.x1=this.x2=this.y1=this.y2=null}cancelAll(){this._preventTap=!0,clearTimeout(this.singleTapTimeout),clearTimeout(this.tapTimeout),clearTimeout(this.longTapTimeout),clearTimeout(this.swipeTimeout)}cancel(t){this.cancelAll(),this.touchCancel.dispatch(t,this.element)}_cancelLongTap(){clearTimeout(this.longTapTimeout)}_cancelSingleTap(){clearTimeout(this.singleTapTimeout)}_swipeDirection(t,e,i,s){return Math.abs(t-e)>=Math.abs(i-s)?t-e>0?"Left":"Right":i-s>0?"Up":"Down"}on(t,e){this[t]&&this[t].add(e)}off(t,e){this[t]&&this[t].del(e)}destroy(){this.singleTapTimeout&&clearTimeout(this.singleTapTimeout),this.tapTimeout&&clearTimeout(this.tapTimeout),this.longTapTimeout&&clearTimeout(this.longTapTimeout),this.swipeTimeout&&clearTimeout(this.swipeTimeout),this.element.removeEventListener("touchstart",this.start),this.element.removeEventListener("touchmove",this.move),this.element.removeEventListener("touchend",this.end),this.element.removeEventListener("touchcancel",this.cancel),this.rotate.del(),this.touchStart.del(),this.multipointStart.del(),this.multipointEnd.del(),this.pinch.del(),this.swipe.del(),this.tap.del(),this.doubleTap.del(),this.longTap.del(),this.singleTap.del(),this.pressMove.del(),this.twoFingerPressMove.del(),this.touchMove.del(),this.touchEnd.del(),this.touchCancel.del(),this.preV=this.pinchStartLen=this.zoom=this.isDoubleTap=this.delta=this.last=this.now=this.tapTimeout=this.singleTapTimeout=this.longTapTimeout=this.swipeTimeout=this.x1=this.x2=this.y1=this.y2=this.preTapPosition=this.rotate=this.touchStart=this.multipointStart=this.multipointEnd=this.pinch=this.swipe=this.tap=this.doubleTap=this.longTap=this.singleTap=this.pressMove=this.touchMove=this.touchEnd=this.touchCancel=this.twoFingerPressMove=null,globalThis&&"function"==typeof globalThis.removeEventListener&&globalThis.removeEventListener("scroll",this._cancelAllHandler)}}const a=o},733:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BezierPath=void 0;var s=i(76),r=i(973),n=i(938),o=i(787),a=function(){function t(){this.className="BezierPath",this.START_POINT=0,this.START_CONTROL_POINT=1,this.END_CONTROL_POINT=2,this.END_POINT=3,this.uid=n.UIDGenerator.next(),this.totalArcLength=0,this.adjustCircular=!1,this.bezierCurves=[]}return t.prototype.addCurve=function(t){if(null==t||void 0===t)throw"Cannot add null curve to bézier path.";this.bezierCurves.push(t),this.bezierCurves.length>1?(t.startPoint=this.bezierCurves[this.bezierCurves.length-2].endPoint,this.adjustSuccessorControlPoint(this.bezierCurves.length-2,!0,!0)):this.totalArcLength+=t.getLength()},t.prototype.locateCurveByStartPoint=function(t){for(var e=0;e<this.bezierCurves.length;e++)if(this.bezierCurves[e].startPoint.equals(t))return e;return-1},t.prototype.locateCurveByEndPoint=function(t){for(var e=0;e<this.bezierCurves.length;e++)if(this.bezierCurves[e].endPoint.equals(t))return e;return-1},t.prototype.locateCurveByStartControlPoint=function(t){for(var e=0;e<this.bezierCurves.length;e++)if(this.bezierCurves[e].startControlPoint.equals(t))return e;return-1},t.prototype.locateCurveByEndControlPoint=function(t){for(var e=0;e<this.bezierCurves.length;e++)if(this.bezierCurves[e].endControlPoint.equals(t))return e;return-1},t.prototype.getLength=function(){return this.totalArcLength},t.prototype.updateArcLengths=function(){this.totalArcLength=0;for(var t=0;t<this.bezierCurves.length;t++)this.bezierCurves[t].updateArcLengths(),this.totalArcLength+=this.bezierCurves[t].getLength()},t.prototype.getCurveCount=function(){return this.bezierCurves.length},t.prototype.getCurveAt=function(t){return this.bezierCurves[t]},t.prototype.translate=function(t){for(var e=0;e<this.bezierCurves.length;e++)(i=this.bezierCurves[e]).getStartPoint().add(t),i.getStartControlPoint().add(t),i.getEndControlPoint().add(t);var i;return(i=this.bezierCurves[this.bezierCurves.length-1]).getEndPoint().add(t),this.updateArcLengths(),this},t.prototype.scale=function(t,e){return this.scaleXY({x:e,y:e},t)},t.prototype.scaleXY=function(t,e){for(var i=0;i<this.bezierCurves.length;i++){var s=this.bezierCurves[i];s.getStartPoint().scaleXY(t,e),s.getStartControlPoint().scaleXY(t,e),s.getEndControlPoint().scaleXY(t,e)}return this.bezierCurves.length>0&&!this.adjustCircular&&this.bezierCurves[this.bezierCurves.length-1].getEndPoint().scaleXY(t,e),this.updateArcLengths(),this},t.prototype.rotate=function(t,e){for(var i=0;i<this.bezierCurves.length;i++){var s=this.bezierCurves[i];s.getStartPoint().rotate(t,e),s.getStartControlPoint().rotate(t,e),s.getEndControlPoint().rotate(t,e)}this.bezierCurves.length>0&&!this.adjustCircular&&this.bezierCurves[this.bezierCurves.length-1].getEndPoint().rotate(t,e)},t.prototype.getClosestT=function(t){for(var e=-1,i=0,s=0,r=0,n=0,o=0,a=0;a<this.bezierCurves.length;a++)r=this.bezierCurves[a].getClosestT(t),s=this.bezierCurves[a].getPointAt(r).distance(t),(-1==e||s<i)&&(e=a,i=s,n=o+r*this.bezierCurves[a].getLength()),o+=this.bezierCurves[a].getLength();return Math.max(0,Math.min(1,n/this.totalArcLength))},t.prototype.getPoint=function(t){(t<0||t>this.totalArcLength)&&(console.warn("[BezierPath.getPoint(u)] u is out of bounds: "+t+"."),t=Math.min(this.totalArcLength,Math.max(t,0)));for(var e=0,i=0;e<this.bezierCurves.length&&i+this.bezierCurves[e].getLength()<t;)i+=this.bezierCurves[e].getLength(),e++;if(e>=this.bezierCurves.length)return this.bezierCurves[this.bezierCurves.length-1].getEndPoint().clone();var s=t-i;return this.bezierCurves[e].getPoint(s)},t.prototype.getPointAt=function(t){return this.getPoint(t*this.totalArcLength)},t.prototype.getTangentAt=function(t){return this.getTangent(t*this.totalArcLength)},t.prototype.getTangent=function(t){(t<0||t>this.totalArcLength)&&(console.warn("[BezierPath.getTangent(u)] u is out of bounds: "+t+"."),t=Math.min(this.totalArcLength,Math.max(0,t)));for(var e=0,i=0;e<this.bezierCurves.length&&i+this.bezierCurves[e].getLength()<t;)i+=this.bezierCurves[e].getLength(),e++;var s=t-i;return this.bezierCurves[e].getTangent(s)},t.prototype.getPerpendicularAt=function(t){return this.getPerpendicular(t*this.totalArcLength)},t.prototype.getPerpendicular=function(e){(e<0||e>this.totalArcLength)&&(console.log("[BezierPath.getPerpendicular(u)] u is out of bounds: "+e+"."),e=Math.min(this.totalArcLength,Math.max(0,e)));var i=t._locateUIndex(this,e),s=this.bezierCurves[i.i],r=e-i.uPart;return s.getPerpendicular(r)},t._locateUIndex=function(t,e){for(var i=0,s=0,r=0;i<t.bezierCurves.length&&s+t.bezierCurves[i].getLength()<e;)s+=t.bezierCurves[i].getLength(),i+1<t.bezierCurves.length&&(r+=t.bezierCurves[i].getLength()),i++;return{i,uPart:s,uBefore:r}},t.prototype.getSubPathAt=function(e,i){e=Math.max(0,e),i=Math.min(1,i);var s=e*this.totalArcLength,r=i*this.totalArcLength,n=t._locateUIndex(this,s),o=t._locateUIndex(this,r),a=(s-n.uBefore)/this.bezierCurves[n.i].getLength();if(n.i==o.i){var h=(r-o.uBefore)/this.bezierCurves[o.i].getLength(),l=this.bezierCurves[n.i].getSubCurveAt(a,h);return t.fromArray([l])}var c=[];if(n.i>o.i){l=this.bezierCurves[n.i].getSubCurveAt(a,0),c.push(l);for(var u=n.i-1;u>o.i;u--)c.push(this.bezierCurves[u].clone().reverse());h=(r-o.uBefore)/this.bezierCurves[o.i].getLength(),c.push(this.bezierCurves[o.i].getSubCurveAt(1,h))}else{for(l=this.bezierCurves[n.i].getSubCurveAt(a,1),c.push(l),u=n.i+1;u<o.i&&u<this.bezierCurves.length;u++)c.push(this.bezierCurves[u].clone());h=(r-o.uBefore)/this.bezierCurves[o.i].getLength(),c.push(this.bezierCurves[o.i].getSubCurveAt(0,h))}return t.fromArray(c)},t.prototype.moveCurvePoint=function(t,e,i){this.getCurveAt(t).moveCurvePoint(e,i,!0,!0),e==this.START_POINT&&(t>0||this.adjustCircular)?this.getCurveAt(t-1<0?this.bezierCurves.length+(t-1):t-1).moveCurvePoint(this.END_CONTROL_POINT,i,!0,!1):e==this.END_POINT&&(t+1<this.bezierCurves.length||this.adjustCircular)?this.getCurveAt((t+1)%this.bezierCurves.length).moveCurvePoint(this.START_CONTROL_POINT,i,!0,!1):e==this.START_CONTROL_POINT&&t>0?this.adjustPredecessorControlPoint(t,!0,!1):e==this.END_CONTROL_POINT&&t+1<this.getCurveCount()&&this.adjustSuccessorControlPoint(t,!0,!1),this.updateArcLengths()},t.prototype.adjustPredecessorControlPoint=function(e,i,s){if(this.adjustCircular||!(e<=0)){var r=this.getCurveAt(e),n=this.getCurveAt(e-1<0?this.getCurveCount()+(e-1):e-1);t.adjustNeighbourControlPoint(r,n,r.getStartPoint(),r.getStartControlPoint(),n.getEndPoint(),n.getEndControlPoint(),i,s)}},t.prototype.adjustSuccessorControlPoint=function(e,i,s){if(this.adjustCircular||!(e+1>this.getCurveCount())){var r=this.getCurveAt(e),n=this.getCurveAt((e+1)%this.getCurveCount());t.adjustNeighbourControlPoint(r,n,r.getEndPoint(),r.getEndControlPoint(),n.getStartPoint(),n.getStartControlPoint(),i,s)}},t.adjustNeighbourControlPoint=function(t,e,i,s,r,n,a,h){var l=new o.Vertex(s.x-i.x,s.y-i.y),c=new o.Vertex(n.x-r.x,n.y-r.y),u=Math.sqrt(Math.pow(l.x,2)+Math.pow(l.y,2)),d=Math.sqrt(Math.pow(c.x,2)+Math.pow(c.y,2));u<=.1||(a?n.set(r.x-l.x*(d/u),r.y-l.y*(d/u)):n.set(r.x-l.x,r.y-l.y),e.updateArcLengths())},t.prototype.getBounds=function(){for(var t,e=new o.Vertex(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),i=new o.Vertex(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),r=0;r<this.bezierCurves.length;r++)t=this.bezierCurves[r].getBounds(),e.x=Math.min(e.x,t.min.x),e.y=Math.min(e.y,t.min.y),i.x=Math.max(i.x,t.max.x),i.y=Math.max(i.y,t.max.y);return new s.Bounds(e,i)},t.prototype.getEvenDistributionVertices=function(t){if(t<2)throw new Error("pointCount must be larger than one; is "+t+".");var e=[];if(0===this.bezierCurves.length)return e;var i=new o.Vertex(this.bezierCurves[0].startPoint);e.push(i);for(var s=this.totalArcLength/(t-1),r=this.bezierCurves.length,n=0,a=this.bezierCurves[0].arcLength,h=s,l=1;l<t&&n<r;)if(h<a){var c=this.bezierCurves[n].getPoint(h);e.push(c),h+=s,l++}else h-=a,a=++n<r?this.bezierCurves[n].arcLength:0;return e.push(new o.Vertex(this.bezierCurves[r-1].endPoint)),e},t.prototype.clone=function(){for(var e=new t,i=0;i<this.bezierCurves.length;i++)e.bezierCurves.push(this.bezierCurves[i].clone()),i>0&&(e.bezierCurves[i-1].endPoint=e.bezierCurves[i].startPoint);return e.updateArcLengths(),e.adjustCircular=this.adjustCircular,e},t.prototype.equals=function(t){if(!t)return!1;if(!t.bezierCurves)return!1;if(void 0===t.bezierCurves.length)return!1;if(t.bezierCurves.length!=this.bezierCurves.length)return!1;for(var e=0;e<this.bezierCurves.length;e++)if(!this.bezierCurves[e].equals(t.bezierCurves[e]))return!1;return!0},t.prototype.destroy=function(){for(var t=0;t<this.bezierCurves.length;t++)this.bezierCurves[t].destroy();this.isDestroyed=!0},t.prototype.toPathPoints=function(){if(0===this.bezierCurves.length)return[];if(1===this.bezierCurves.length)return[this.bezierCurves[0].startPoint,this.bezierCurves[0].startControlPoint,this.bezierCurves[0].endControlPoint,this.bezierCurves[0].endPoint];var t=[];t.push(this.bezierCurves[0].startPoint),t.push(this.bezierCurves[0].startControlPoint);for(var e=1;e<this.bezierCurves.length;e++)t.push(this.bezierCurves[e-1].endControlPoint),t.push(this.bezierCurves[e-1].endPoint),t.push(this.bezierCurves[e].startPoint),t.push(this.bezierCurves[e].startControlPoint);return t.push(this.bezierCurves[0].endControlPoint),t.push(this.bezierCurves[0].endPoint),t},t.prototype.toJSON=function(t){var e=[];e.push("[");for(var i=0;i<this.bezierCurves.length;i++)i>0&&e.push(","),t?e.push("\n\t"):e.push(" "),e.push(this.bezierCurves[i].toJSON(t));return 0!=this.bezierCurves.length&&e.push(" "),e.push("]"),e.join("")},t.fromJSON=function(e){var i=JSON.parse(e);return t.fromArray(i)},t.fromCurve=function(e){var i=new t;return i.addCurve(e),i},t.fromArray=function(e){if(!Array.isArray(e))throw"[BezierPath.fromArray] Passed object must be an array.";var i=e;if(i.length<1)throw"[BezierPath.fromArray] Passed array must contain at least one bezier curve (has "+i.length+").";for(var s=new t,n=null,o=0;o<i.length;o++){var a;if(r.CubicBezierCurve.isInstance(i[o]))a=i[o].clone();else if(0 in i[o]&&1 in i[o]&&2 in i[o]&&3 in i[o]){if(!(i[o][0]&&i[o][1]&&i[o][2]&&i[o][3]))throw"Cannot convert path data to BezierPath instance. At least one element is undefined (index="+o+"): "+i[o];a=r.CubicBezierCurve.fromArray(i[o])}else a=r.CubicBezierCurve.fromObject(i[o]);n&&(a.startPoint=n.endPoint),s.bezierCurves.push(a),n=a}return s.updateArcLengths(),s},t.prototype.toReducedListRepresentation=function(t){void 0===t&&(t=1);var e=[];e.push("[");for(var i=0;i<this.bezierCurves.length;i++){var s=this.bezierCurves[i];e.push(s.getStartPoint().x.toFixed(t)),e.push(","),e.push(s.getStartPoint().y.toFixed(t)),e.push(","),e.push(s.getStartControlPoint().x.toFixed(t)),e.push(","),e.push(s.getStartControlPoint().y.toFixed(t)),e.push(","),e.push(s.getEndControlPoint().x.toFixed(t)),e.push(","),e.push(s.getEndControlPoint().y.toFixed(t)),e.push(",")}return 0!=this.bezierCurves.length&&(s=this.bezierCurves[this.bezierCurves.length-1],e.push(s.getEndPoint().x.toFixed(t)),e.push(","),e.push(s.getEndPoint().y.toFixed(t))),e.push("]"),e.join("")},t.fromReducedListRepresentation=function(e,i){var s=JSON.parse(e);if(!s.length)throw console.log("Cannot parse bezier path from non-array object nor from empty point list."),"Cannot parse bezier path from non-array object nor from empty point list.";if(s.length<8)throw console.log("Cannot build bezier path. The passed array must contain at least 8 elements (numbers)."),"Cannot build bezier path. The passed array must contain at least 8 elements (numbers).";return t.fromReducedList(s,i)},t.fromReducedList=function(e,i){var s,n,a,h=new t,l=new o.Vertex,c=0;do{0==c&&(l=new o.Vertex(e[c],e[c+1])),s=new o.Vertex(e[c+2],e[c+3]),n=new o.Vertex(e[c+4],e[c+5]),a=new o.Vertex(e[c+6],e[c+7]);var u=new r.CubicBezierCurve(l,a,s,n);h.bezierCurves.push(u),l=a,c+=6}while(c+2<e.length);return h.adjustCircular=null!=i&&i,i&&(h.bezierCurves[h.bezierCurves.length-1].endPoint=h.bezierCurves[0].startPoint),h.updateArcLengths(),h},t.START_POINT=0,t.START_CONTROL_POINT=1,t.END_CONTROL_POINT=2,t.END_POINT=3,t}();e.BezierPath=a},76:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Bounds=void 0;var s=i(687),r=i(787),n=function(){function t(t,e){this.min=t,this.max=e,this.width=e.x-t.x,this.height=e.y-t.y}return t.prototype.toPolygon=function(){return new s.Polygon([new r.Vertex(this.min),new r.Vertex(this.max.x,this.min.y),new r.Vertex(this.max),new r.Vertex(this.min.x,this.max.y)],!1)},t.prototype.getCenter=function(){return new r.Vertex(this.min.x+(this.max.x-this.min.x)/2,this.min.y+(this.max.y-this.min.y)/2)},t.prototype.randomPoint=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0);var i=t>0&&t<1?this.width*t:t,s=e>0&&e<1?this.height*e:e;return new r.Vertex(this.min.x+i+Math.random()*(this.width-2*i),this.min.y+s+Math.random()*(this.height-2*s))},t.prototype.toString=function(){return"{ min: ".concat(this.min.toString(),", max : ").concat(this.max.toString(),", width: ").concat(this.width,", height : ").concat(this.height," }")},t.prototype.clone=function(){return new t({x:this.min.x,y:this.min.y},{x:this.max.x,y:this.max.y})},t.computeFromVertices=function(e){if(0==e.length)return new t(new r.Vertex(0,0),new r.Vertex(0,0));var i,s=e[0].x,n=e[0].x,o=e[0].y,a=e[0].y;for(var h in e)i=e[h],s=Math.min(s,i.x),n=Math.max(n,i.x),o=Math.min(o,i.y),a=Math.max(a,i.y);return new t(new r.Vertex(s,o),new r.Vertex(n,a))},t.fromDimension=function(e,i,s){return new t(null!=s?s:{x:0,y:0},{x:(s?s.x:0)+e,y:(s?s.y:0)+i})},t}();e.Bounds=n},118:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Circle=void 0;var s=i(939),r=i(938),n=i(30),o=i(787),a=function(){function t(t,e){this.className="Circle",this.uid=r.UIDGenerator.next(),this.center=t,this.radius=e}return t.prototype.containsPoint=function(t){return this.center.distance(t)<this.radius},t.prototype.containsCircle=function(t){return this.center.distance(t.center)+t.radius<this.radius},t.prototype.lineDistance=function(t){return t.getClosestPoint(this.center).distance(this.center)-this.radius},t.prototype.vertAt=function(e){return t.circleUtils.vertAt(e,this.radius).add(this.center)},t.prototype.tangentAt=function(e){var i=t.circleUtils.vertAt(e,this.radius);return new n.Vector(i,new o.Vertex(0,0)).add(this.center).perp()},t.prototype.circleIntersection=function(t){if(this.center.distance(t.center)>this.radius+t.radius)return null;if(this.center.distance(t.center)<Math.abs(this.radius-t.radius))return null;var e=this.center,i=t.center,r=e.distance(i),n=(this.radius*this.radius-t.radius*t.radius+r*r)/(2*r),a=Math.sqrt(this.radius*this.radius-n*n),h=i.clone().scale(n/r,e),l=h.x+a*(i.y-e.y)/r,c=h.y-a*(i.x-e.x)/r,u=h.x-a*(i.y-e.y)/r,d=h.y+a*(i.x-e.x)/r;return new s.Line(new o.Vertex(l,c),new o.Vertex(u,d))},t.prototype.lineIntersection=function(t,e){var i=new o.Vertex,r=new o.Vertex,n=new o.Vertex(t).sub(this.center),a=new o.Vertex(e).sub(this.center),h=n.difference(a);0===Math.abs(h.y)&&(h.y=1e-6);var l=n.distance(a),c=n.x*a.y-n.y*a.x,u=l*l;if(this.radius*this.radius*u-c*c<0)return null;var d=this.radius*this.radius*l*l-c*c,f=Math.sqrt(d);return i.x=(c*h.y+Math.sign(h.y)*h.x*f)/u,r.x=(c*h.y-Math.sign(h.y)*h.x*f)/u,i.y=(-c*h.x+Math.abs(h.y)*f)/u,r.y=(-c*h.x-Math.abs(h.y)*f)/u,new s.Line(i.add(this.center),r.add(this.center))},t.prototype.closestPoint=function(t){var e=this.lineIntersection(this.center,t);return e?e.a.distance(t)<e.b.distance(t)?e.a:e.b:new o.Vertex},t.prototype.destroy=function(){this.center.destroy(),this.isDestroyed=!0},t.circleUtils={vertAt:function(t,e){return new o.Vertex(Math.cos(t)*e,Math.sin(t)*e)}},t}();e.Circle=a},135:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CircleSector=void 0;var s=i(118),r=i(938),n=function(){function t(t,e,i){this.className="CircleSector",this.uid=r.UIDGenerator.next(),this.circle=t,this.startAngle=e,this.endAngle=i}return t.prototype.containsAngle=function(t){return this.startAngle<=this.endAngle?t>=this.startAngle&&t<this.endAngle:t>=this.startAngle||t<this.endAngle},t.prototype.angleAt=function(t){return this.startAngle<=this.endAngle?(this.startAngle+(this.endAngle-this.startAngle)*t)%(2*Math.PI):(this.startAngle+(2*Math.PI-this.startAngle+this.endAngle)*t)%(2*Math.PI)},t.prototype.getStartPoint=function(){return this.circle.vertAt(this.startAngle)},t.prototype.getEndPoint=function(){return this.circle.vertAt(this.endAngle)},t.prototype.circleSectorIntersection=function(e){var i=this.circle.circleIntersection(e.circle);if(!i)return null;var r=this.circle.center.angle(i.a),n=this.circle.center.angle(i.b);if(!this.containsAngle(r)||!this.containsAngle(n))return null;var o=e.circle.center.angle(i.a),a=e.circle.center.angle(i.b);if(!e.containsAngle(o)||!e.containsAngle(a))return null;var h=new t(this.circle,this.endAngle,this.startAngle).angleAt(.5),l=new t(new s.Circle(this.circle.center.clone(),this.circle.radius),r,n);return l.containsAngle(h)&&(l.startAngle=n,l.endAngle=r),l},t.prototype.destroy=function(){this.circle.destroy(),this.isDestroyed=!0},t.circleSectorUtils={polarToCartesian:function(t,e,i,s){return{x:t+i*Math.cos(s),y:e+i*Math.sin(s)}},describeSVGArc:function(e,i,s,r,n,o){void 0===o&&(o={moveToStart:!0});var a=t.circleSectorUtils.polarToCartesian(e,i,s,n),h=t.circleSectorUtils.polarToCartesian(e,i,s,r);if(2*Math.PI-Math.abs(r-n)<.001){var l=t.circleSectorUtils.describeSVGArc(e,i,s,r,r+(n-r)/2,o),c=t.circleSectorUtils.describeSVGArc(e,i,s,r+(n-r)/2,n,o);return l.concat(c)}var u,d,f=n-r;f<0?(u=Math.abs(f)<Math.PI?1:0,d=1):(u=Math.abs(f)>Math.PI?1:0,d=1);var p=[];return o.moveToStart&&p.push("M",h.x,h.y),p.push("A",s,s,0,u,d,a.x,a.y),p}},t}();e.CircleSector=n},973:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CubicBezierCurve=void 0;var s=i(76),r=i(938),n=i(787),o=i(30),a=function(){function t(e,i,s,n){this.START_POINT=t.START_POINT,this.START_CONTROL_POINT=t.START_CONTROL_POINT,this.END_CONTROL_POINT=t.END_CONTROL_POINT,this.END_POINT=t.END_POINT,this.uid=r.UIDGenerator.next(),this.startPoint=e,this.startControlPoint=s,this.endPoint=i,this.endControlPoint=n,this.curveIntervals=30,this.segmentCache=[],this.segmentLengths=[],this.updateArcLengths()}return t.prototype.moveCurvePoint=function(t,e,i,s){t==this.START_POINT?(this.getStartPoint().add(e),i&&this.getStartControlPoint().add(e)):t==this.START_CONTROL_POINT?this.getStartControlPoint().add(e):t==this.END_CONTROL_POINT?this.getEndControlPoint().add(e):t==this.END_POINT?(this.getEndPoint().add(e),i&&this.getEndControlPoint().add(e)):console.log("[CubicBezierCurve.moveCurvePoint] pointID '".concat(t,"' invalid.")),s&&this.updateArcLengths()},t.prototype.translate=function(t){return this.startPoint.add(t),this.startControlPoint.add(t),this.endControlPoint.add(t),this.endPoint.add(t),this},t.prototype.reverse=function(){var t=this.startPoint;return this.startPoint=this.endPoint,this.endPoint=t,t=this.startControlPoint,this.startControlPoint=this.endControlPoint,this.endControlPoint=t,this},t.prototype.getLength=function(){return this.arcLength},t.prototype.updateArcLengths=function(){var t=this.startPoint.clone(),e=new n.Vertex(0,0),i=1/this.curveIntervals;this.segmentCache=[],this.segmentCache.push(this.startPoint),this.segmentLengths=[];for(var s,r=0,o=0;o<=1;)e=this.getPointAt(o),this.segmentCache.push(e),s=t.distance(e),this.segmentLengths.push(s),r+=s,t=e,o+=i;this.arcLength=r},t.prototype.getClosestT=function(t){var e={t:0,tPrev:0,tNext:1},i=0;do{e=this.locateIntervalByDistance(t,e.tPrev,e.tNext,this.curveIntervals),i++}while(i<4&&this.getPointAt(e.tPrev).distance(this.getPointAt(e.tNext))>1);return e.t},t.prototype.locateIntervalByDistance=function(t,e,i,s){for(var r=-1,n=0,o=0,a=i-e,h=0;h<=s;h++){o=e+a*(h/s);var l=this.getPointAt(o).distance(t);(-1==r||l<n)&&(r=h,n=l)}return{t:e+a*(r/s),tPrev:e+a*(Math.max(0,r-1)/s),tNext:e+a*(Math.min(s,r+1)/s)}},t.prototype.getBounds=function(){for(var t,e=new n.Vertex(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),i=new n.Vertex(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),r=0;r<this.segmentCache.length;r++)t=this.segmentCache[r],e.x=Math.min(e.x,t.x),e.y=Math.min(e.y,t.y),i.x=Math.max(i.x,t.x),i.y=Math.max(i.y,t.y);return new s.Bounds(e,i)},t.prototype.getStartPoint=function(){return this.startPoint},t.prototype.getEndPoint=function(){return this.endPoint},t.prototype.getStartControlPoint=function(){return this.startControlPoint},t.prototype.getEndControlPoint=function(){return this.endControlPoint},t.prototype.getPointByID=function(t){if(t==this.START_POINT)return this.startPoint;if(t==this.END_POINT)return this.endPoint;if(t==this.START_CONTROL_POINT)return this.startControlPoint;if(t==this.END_CONTROL_POINT)return this.endControlPoint;throw new Error("Invalid point ID '".concat(t,"'."))},t.prototype.getPointAt=function(t){var e=this.startPoint.x*Math.pow(1-t,3)+3*this.startControlPoint.x*t*Math.pow(1-t,2)+3*this.endControlPoint.x*Math.pow(t,2)*(1-t)+this.endPoint.x*Math.pow(t,3),i=this.startPoint.y*Math.pow(1-t,3)+3*this.startControlPoint.y*t*Math.pow(1-t,2)+3*this.endControlPoint.y*Math.pow(t,2)*(1-t)+this.endPoint.y*Math.pow(t,3);return new n.Vertex(e,i)},t.prototype.getPoint=function(t){return this.getPointAt(t/this.arcLength)},t.prototype.getTangentAt=function(t){var e=this.getStartPoint(),i=this.getStartControlPoint(),s=this.getEndControlPoint(),r=this.getEndPoint(),o=t*t,a=1-2*t+o,h=-3*e.x*a+i.x*(3*a-6*(t-o))+s.x*(6*(t-o)-3*o)+3*r.x*o,l=-3*e.y*a+i.y*(3*a-6*(t-o))+s.y*(6*(t-o)-3*o)+3*r.y*o;return new n.Vertex(h,l)},t.prototype.trimStart=function(t){return this.trimStartAt(this.convertU2T(t))},t.prototype.trimStartAt=function(e){var i=t.utils.getSubCurvePointsAt(this,e,1);return this.startPoint.set(i[0]),this.startControlPoint.set(i[2]),this.endPoint.set(i[1]),this.endControlPoint.set(i[3]),this.updateArcLengths(),this},t.prototype.trimEnd=function(t){return this.trimEndAt(this.convertU2T(t))},t.prototype.trimEndAt=function(e){var i=t.utils.getSubCurvePointsAt(this,0,e);return this.startPoint.set(i[0]),this.startControlPoint.set(i[2]),this.endPoint.set(i[1]),this.endControlPoint.set(i[3]),this.updateArcLengths(),this},t.prototype.getSubCurve=function(t,e){return this.getSubCurveAt(this.convertU2T(t),this.convertU2T(e))},t.prototype.getSubCurveAt=function(e,i){var s=t.utils.getSubCurvePointsAt(this,e,i);return new t(s[0],s[1],s[2],s[3])},t.prototype.convertU2T=function(t){return Math.max(0,Math.min(1,t/this.arcLength))},t.prototype.getTangent=function(t){return this.getTangentAt(this.convertU2T(t))},t.prototype.getPerpendicular=function(t){return this.getPerpendicularAt(this.convertU2T(t))},t.prototype.getPerpendicularAt=function(t){var e=this.getTangentAt(t);return new n.Vertex(e.y,-e.x)},t.prototype.clone=function(){return new t(this.getStartPoint().clone(),this.getEndPoint().clone(),this.getStartControlPoint().clone(),this.getEndControlPoint().clone())},t.prototype.getStartTangent=function(){return this.startControlPoint},t.prototype.getEndTangent=function(){return this.endControlPoint},t.prototype.equals=function(t){return!!t&&!!(t.startPoint&&t.endPoint&&t.startControlPoint&&t.endControlPoint)&&this.startPoint.equals(t.startPoint)&&this.endPoint.equals(t.endPoint)&&this.startControlPoint.equals(t.startControlPoint)&&this.endControlPoint.equals(t.endControlPoint)},t.prototype.destroy=function(){this.startPoint.destroy(),this.endPoint.destroy(),this.startControlPoint.destroy(),this.endControlPoint.destroy(),this.isDestroyed=!0},t.isInstance=function(e){return e instanceof t},t.prototype.toJSON=function(t){return"{ "+(t?"\n\t":"")+'"startPoint" : ['+this.getStartPoint().x+","+this.getStartPoint().y+"], "+(t?"\n\t":"")+'"endPoint" : ['+this.getEndPoint().x+","+this.getEndPoint().y+"], "+(t?"\n\t":"")+'"startControlPoint": ['+this.getStartControlPoint().x+","+this.getStartControlPoint().y+"], "+(t?"\n\t":"")+'"endControlPoint" : ['+this.getEndControlPoint().x+","+this.getEndControlPoint().y+"]"+(t?"\n\t":"")+" }"},t.fromJSON=function(e){var i=JSON.parse(e);return t.fromObject(i)},t.fromObject=function(e){if("object"!=typeof e)throw"Can only build from object.";if(!e.startPoint)throw'Object member "startPoint" missing.';if(!e.endPoint)throw'Object member "endPoint" missing.';if(!e.startControlPoint)throw'Object member "startControlPoint" missing.';if(!e.endControlPoint)throw'Object member "endControlPoint" missing.';return new t(new n.Vertex(e.startPoint[0],e.startPoint[1]),new n.Vertex(e.endPoint[0],e.endPoint[1]),new n.Vertex(e.startControlPoint[0],e.startControlPoint[1]),new n.Vertex(e.endControlPoint[0],e.endControlPoint[1]))},t.fromArray=function(e){if(!Array.isArray(e))throw"Can only build from object.";if(4!=e.length)throw"Can only build from array with four elements.";return new t(e[0],e[1],e[2],e[3])},t.START_POINT=0,t.START_CONTROL_POINT=1,t.END_CONTROL_POINT=2,t.END_POINT=3,t.utils={getSubCurvePointsAt:function(t,e,i){var s=new o.Vector(t.getPointAt(e),t.getTangentAt(e)),r=new o.Vector(t.getPointAt(i),t.getTangentAt(i).inv());return s.b.add(s.a),r.b.add(r.a),s.scale(.33333333*(i-e)),r.scale(.33333333*(i-e)),[s.a,r.a,s.b,r.b]}},t}();e.CubicBezierCurve=a},289:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Grid=void 0;var i=function(){function t(t,e){this.center=t,this.size=e}return t.utils={baseLog:function(t,e){return Math.log(t)/Math.log(e)},mapRasterScale:function(e,i){var s=1;return i>=1?(s=Math.abs(Math.floor(1/t.utils.baseLog(e,i))),s=1/Math.pow(e,s)):s=Math.abs(Math.floor(t.utils.baseLog(1/e,1/(i+1)))),s}},t}();e.Grid=i},531:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyHandler=void 0;var i=function(){function t(t){this.downListeners=[],this.pressListeners=[],this.upListeners=[],this.keyStates={},t=t||{},this.element=t.element?t.element:globalThis,this.downListeners=[],this.pressListeners=[],this.upListeners=[],this.keyStates=[],this.trackAllKeys=t.trackAll||!1,this.installListeners()}return t.prototype.fireEvent=function(t,e){var i=!1;for(var s in e){var r=e[s];r.keyCode==t.keyCode&&(r.listener(t),i=!0)}return i},t.prototype.fireDownEvent=function(t,e){(e.fireEvent(t,e.downListeners)||e.trackAllKeys)&&(e.keyStates[t.keyCode]="down")},t.prototype.firePressEvent=function(t,e){e.fireEvent(t,e.pressListeners)},t.prototype.fireUpEvent=function(t,e){(e.fireEvent(t,e.upListeners)||e.trackAllKeys)&&delete e.keyStates[t.keyCode]},t.key2code=function(e){if("number"==typeof e)return e;if("string"!=typeof e)throw"Unknown key name or key type (should be a string or integer): "+e;if(t.KEY_CODES[e])return t.KEY_CODES[e];throw"Unknown key (cannot resolve key code): "+e},t.prototype.installListeners=function(){var t=this;this.element.addEventListener("keydown",this._keyDownListener=function(e){t.fireDownEvent(e,t)}),this.element.addEventListener("keypress",this._keyPressListener=function(e){t.firePressEvent(e,t)}),this.element.addEventListener("keyup",this._keyUpListener=function(e){t.fireUpEvent(e,t)})},t.prototype.releaseListeners=function(){this.element.removeEventListener("keydown",this._keyDownListener),this.element.removeEventListener("keypress",this._keyPressListener),this.element.removeEventListener("keyup",this._keyUpListener)},t.prototype.down=function(e,i){return this.downListeners.push({key:e,keyCode:t.key2code(e),listener:i}),this},t.prototype.press=function(e,i){return this.pressListeners.push({key:e,keyCode:t.key2code(e),listener:i}),this},t.prototype.up=function(e,i){return this.upListeners.push({key:e,keyCode:t.key2code(e),listener:i}),this},t.prototype.isDown=function(e){return"number"==typeof e?!!this.keyStates[e]:!!this.keyStates[t.key2code(e)]},t.prototype.destroy=function(){this.releaseListeners()},t.KEY_CODES={break:3,backspace:8,tab:9,clear:12,enter:13,shift:16,ctrl:17,alt:18,pause:19,capslock:20,hangul:21,hanja:25,escape:27,conversion:28,"non-conversion":29,spacebar:32,pageup:33,pagedown:34,end:35,home:36,leftarrow:37,uparrow:38,rightarrow:39,downarrow:40,select:41,print:42,execute:43,printscreen:44,insert:45,delete:46,help:47,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,":":58,"semicolon (firefox)":59,equals:59,"<":60,"equals (firefox)":61,ß:63,"@ (firefox)":64,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,windows:91,leftcommand:91,chromebooksearch:91,rightwindowkey:92,windowsmenu:93,rightcommant:93,sleep:95,numpad0:96,numpad1:97,numpad2:98,numpad3:99,numpad4:100,numpad5:101,numpad6:102,numpad7:103,numpad8:104,numpad9:105,multiply:106,add:107,numpadperiod:108,subtract:109,decimalpoint:110,divide:111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,f13:124,f14:125,f15:126,f16:127,f17:128,f18:129,f19:130,f20:131,f21:132,f22:133,f23:134,f24:135,numlock:144,scrolllock:145,"^":160,"!":161,"#":163,$:164,ù:165,pagebackward:166,pageforward:167,refresh:168,closingparen:169,"*":170,"~+*":171,minus:173,decreasevolumelevel:174,increasevolumelevel:175,next:176,previous:177,stop:178,"play/pause":179,email:180,mute:181,unmute:181,semicolon:186,ñ:186,equal:187,comma:188,dash:189,period:190,forwardslash:191,ç:191,"grave accent":192,æ:192,ö:192,"?":193,"/":193,"°":193,openbracket:219,backslash:220,closebracket:221,å:221,singlequote:222,ø:222,ä:222,"`":223,altgr:225,"GNOME Compose Key":230,XF86Forward:233,XF86Back:234,alphanumeric:240,hiragana:242,katakana:242,"half-width":243,"full-width":243,kanji:244,unlocktrackpad:251,toggletouchpad:255},t}();e.KeyHandler=i},939:function(t,e,i){var s,r=this&&this.__extends||(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0}),e.Line=void 0;var n=i(590),o=i(787),a=function(t){function e(i,s){var r=t.call(this,i,s,(function(t,i){return new e(t,i)}))||this;return r.className="Line",r}return r(e,t),e.prototype.intersection=function(t){var e=this.denominator(t);if(0==e)return null;var i=this.a.y-t.a.y,s=this.a.x-t.a.x,r=(t.b.x-t.a.x)*i-(t.b.y-t.a.y)*s,n=(this.b.x-this.a.x)*i-(this.b.y-this.a.y)*s;i=r/e,s=n/e;var a=this.a.x+i*(this.b.x-this.a.x),h=this.a.y+i*(this.b.y-this.a.y);return isNaN(i)||isNaN(a)||isNaN(h)?null:new o.Vertex(a,h)},e.prototype.getStartPoint=function(){return this.a},e.prototype.getEndPoint=function(){return this.b},e.prototype.getStartTangent=function(){return this.b},e.prototype.getEndTangent=function(){return this.a},e.prototype.reverse=function(){var t=this.a;return this.a=this.b,this.b=t,this},e}(n.VertTuple);e.Line=a},912:function(t,e){var i,s=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function s(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)});Object.defineProperty(e,"__esModule",{value:!0}),e.MouseHandler=e.XWheelEvent=e.XMouseEvent=void 0;var r=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e}(MouseEvent);e.XMouseEvent=r;var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e}(WheelEvent);e.XWheelEvent=n;var o=function(){function t(t,e){this.mouseDownPos=void 0,this.mouseDragPos=void 0,this.mouseButton=-1,this.listeners={},this.installed={},this.handlers={},this.name=e,this.element=t,this.mouseDownPos=void 0,this.mouseDragPos=void 0,this.mouseButton=-1,this.listeners={},this.installed={},this.handlers={};var i=this;this.handlers.mousemove=function(t){i.listeners.mousemove&&i.listeners.mousemove(i.mkParams(t,"mousemove")),i.mouseDragPos&&i.listeners.drag&&i.listeners.drag(i.mkParams(t,"drag")),i.mouseDownPos&&(i.mouseDragPos=i.relPos(t))},this.handlers.mouseup=function(t){i.listeners.mouseup&&i.listeners.mouseup(i.mkParams(t,"mouseup")),i.mouseDragPos=void 0,i.mouseDownPos=void 0,i.mouseButton=-1},this.handlers.mousedown=function(t){i.mouseDragPos=i.relPos(t),i.mouseDownPos=i.relPos(t),i.mouseButton=t.button,i.listeners.mousedown&&i.listeners.mousedown(i.mkParams(t,"mousedown"))},this.handlers.click=function(t){i.listeners.click&&i.listeners.click(i.mkParams(t,"click"))},this.handlers.wheel=function(t){i.listeners.wheel&&i.listeners.wheel(i.mkParams(t,"wheel"))},this.element.addEventListener("mousemove",this.handlers.mousemove),this.element.addEventListener("mouseup",this.handlers.mouseup),this.element.addEventListener("mousedown",this.handlers.mousedown),this.element.addEventListener("click",this.handlers.click),this.element.addEventListener("wheel",this.handlers.wheel)}return t.prototype.relPos=function(t){return{x:t.offsetX,y:t.offsetY}},t.prototype.mkParams=function(t,e){var i,s,r=this.relPos(t),n=t;return n.params={element:this.element,name:e,isTouchEvent:!1,pos:r,button:t.button,leftButton:0===t.button,middleButton:1===t.button,rightButton:2===t.button,mouseDownPos:null!==(i=this.mouseDownPos)&&void 0!==i?i:{x:NaN,y:NaN},draggedFrom:null!==(s=this.mouseDragPos)&&void 0!==s?s:{x:NaN,y:NaN},wasDragged:null!=this.mouseDownPos&&(this.mouseDownPos.x!=r.x||this.mouseDownPos.y!=r.y),dragAmount:null!=this.mouseDragPos?{x:r.x-this.mouseDragPos.x,y:r.y-this.mouseDragPos.y}:{x:0,y:0}},n},t.prototype.listenFor=function(t){this.installed[t]||(this.installed[t]=!0)},t.prototype.unlistenFor=function(t){this.installed[t]&&delete this.installed[t]},t.prototype.drag=function(t){return this.listeners.drag&&this.throwAlreadyInstalled("drag"),this.listeners.drag=t,this.listenFor("mousedown"),this.listenFor("mousemove"),this.listenFor("mouseup"),this},t.prototype.move=function(t){return this.listeners.mousemove&&this.throwAlreadyInstalled("mousemove"),this.listenFor("mousemove"),this.listeners.mousemove=t,this},t.prototype.up=function(t){return this.listeners.mouseup&&this.throwAlreadyInstalled("mouseup"),this.listenFor("mouseup"),this.listeners.mouseup=t,this},t.prototype.down=function(t){return this.listeners.mousedown&&this.throwAlreadyInstalled("mousedown"),this.listenFor("mousedown"),this.listeners.mousedown=t,this},t.prototype.click=function(t){return this.listeners.click&&this.throwAlreadyInstalled("click"),this.listenFor("click"),this.listeners.click=t,this},t.prototype.wheel=function(t){return this.listeners.wheel&&this.throwAlreadyInstalled("wheel"),this.listenFor("wheel"),this.listeners.wheel=t,this},t.prototype.throwAlreadyInstalled=function(t){throw"This MouseHandler already has a '".concat(t,"' callback. To keep the code simple there is only room for one.")},t.prototype.destroy=function(){this.unlistenFor("mousedown"),this.unlistenFor("mousemove"),this.unlistenFor("moseup"),this.unlistenFor("click"),this.unlistenFor("wheel"),this.element.removeEventListener("mousemove",this.handlers.mousemove),this.element.removeEventListener("mouseup",this.handlers.mousedown),this.element.removeEventListener("mousedown",this.handlers.mousedown),this.element.removeEventListener("click",this.handlers.click),this.element.removeEventListener("wheel",this.handlers.wheel)},t}();e.MouseHandler=o},862:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PBImage=void 0;var s=i(938),r=function(){function t(t,e,i){this.className="PBImage",this.uid=s.UIDGenerator.next(),this.image=t,this.upperLeft=e,this.lowerRight=i}return t.prototype.destroy=function(){this.upperLeft.destroy(),this.lowerRight.destroy(),this.isDestroyed=!0},t}();e.PBImage=r},628:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PBText=void 0;var s=i(938),r=i(787),n=function(){function t(t,e,i){this.className="PBText",this.uid=s.UIDGenerator.next(),this.text=t,this.anchor=null!=e?e:new r.Vertex,this.color=null==i?void 0:i.color,this.fontFamily=null==i?void 0:i.fontFamily,this.fontSize=null==i?void 0:i.fontSize,this.fontStyle=null==i?void 0:i.fontStyle,this.fontWeight=null==i?void 0:i.fontWeight,this.lineHeight=null==i?void 0:i.lineHeight,this.textAlign=null==i?void 0:i.textAlign,this.rotation=null==i?void 0:i.rotation}return t.prototype.destroy=function(){this.anchor.destroy(),this.isDestroyed=!0},t}();e.PBText=n},559:function(t,e,i){var s=this&&this.__setFunctionName||function(t,e,i){return"symbol"==typeof e&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:i?"".concat(i," ",e):e})};Object.defineProperty(e,"__esModule",{value:!0}),e.PlotBoilerplate=void 0;var r=i(597),n=i(39),o=i(264),a=i(378),h=i(733),l=i(76),c=i(118),u=i(135),d=i(289),f=i(531),p=i(939),y=i(912),v=i(862),g=i(687),x=i(737),b=i(881),m=i(719),w=i(30),C=i(787),P=i(476),A=i(628),T=function(){function t(e,i){var s,r;if(this.renderTime=0,this._gui=null,P.VertexAttr.model={bezierAutoAdjust:!1,renderTime:0,selectable:!0,isSelected:!1,draggable:!0,visible:!0},void 0===e.canvas)throw"No canvas specified.";var h=t.utils.fetch;this.config={canvas:e.canvas,fullSize:h.val(e,"fullSize",!0),fitToParent:h.bool(e,"fitToParent",!0),scaleX:h.num(e,"scaleX",1),scaleY:h.num(e,"scaleY",1),offsetX:h.num(e,"offsetX",0),offsetY:h.num(e,"offsetY",0),rasterGrid:h.bool(e,"rasterGrid",!0),drawRaster:h.bool(e,"drawRaster",!0),rasterScaleX:h.num(e,"rasterScaleX",1),rasterScaleY:h.num(e,"rasterScaleY",1),rasterAdjustFactor:h.num(e,"rasterAdjustdFactror",2),drawOrigin:h.bool(e,"drawOrigin",!1),autoAdjustOffset:h.val(e,"autoAdjustOffset",!0),offsetAdjustXPercent:h.num(e,"offsetAdjustXPercent",50),offsetAdjustYPercent:h.num(e,"offsetAdjustYPercent",50),backgroundColor:e.backgroundColor||"#ffffff",redrawOnResize:h.bool(e,"redrawOnResize",!0),defaultCanvasWidth:h.num(e,"defaultCanvasWidth",t.DEFAULT_CANVAS_WIDTH),defaultCanvasHeight:h.num(e,"defaultCanvasHeight",t.DEFAULT_CANVAS_HEIGHT),canvasWidthFactor:h.num(e,"canvasWidthFactor",1),canvasHeightFactor:h.num(e,"canvasHeightFactor",1),cssScaleX:h.num(e,"cssScaleX",1),cssScaleY:h.num(e,"cssScaleY",1),cssUniformScale:h.bool(e,"cssUniformScale",!0),saveFile:function(){u.hooks.saveFile(u)},setToRetina:function(){u._setToRetina()},autoDetectRetina:h.bool(e,"autoDetectRetina",!0),enableSVGExport:h.bool(e,"enableSVGExport",!0),preClear:h.func(e,"preClear",null),preDraw:h.func(e,"preDraw",null),postDraw:h.func(e,"postDraw",null),enableMouse:h.bool(e,"enableMouse",!0),enableTouch:h.bool(e,"enableTouch",!0),enableKeys:h.bool(e,"enableKeys",!0),enableMouseWheel:h.bool(e,"enableMouseWheel",!0),enableZoom:h.bool(e,"enableZoom",!0),enablePan:h.bool(e,"enablePan",!0),enableGL:h.bool(e,"enableGL",!1),isBackdropFiltersEnabled:h.bool(e,"isBackdropFiltersEnabled",!0)},this.drawConfig={drawVertices:!0,drawBezierHandleLines:h.bool(e,"drawBezierHandleLines",!0),drawBezierHandlePoints:h.bool(e,"drawBezierHandlePoints",!0),drawHandleLines:h.bool(e,"drawHandleLines",!0),drawHandlePoints:h.bool(e,"drawHandlePoints",!0),drawGrid:h.bool(e,"drawGrid",!0),drawRaster:h.bool(e,"drawRaster",!0),bezier:{color:"#00a822",lineWidth:2,handleLine:{color:"rgba(180,180,180,0.5)",lineWidth:1},pathVertex:{color:"#B400FF",lineWidth:1,fill:!0},controlVertex:{color:"#B8D438",lineWidth:1,fill:!0}},polygon:{color:"#0022a8",lineWidth:1},triangle:{color:"#6600ff",lineWidth:1},ellipse:{color:"#2222a8",lineWidth:1},ellipseSector:{color:"#a822a8",lineWidth:2},circle:{color:"#22a8a8",lineWidth:2},circleSector:{color:"#2280a8",lineWidth:1},vertex:{color:"#a8a8a8",lineWidth:1},selectedVertex:{color:"#c08000",lineWidth:2},line:{color:"#a844a8",lineWidth:1},vector:{color:"#ff44a8",lineWidth:1},image:{color:"#a8a8a8",lineWidth:1},text:{color:"rgba(192,0,128,0.5)",lineWidth:1,fill:!0,anchor:!0},origin:{color:"#000000"}},this.grid=new d.Grid(new C.Vertex(0,0),new C.Vertex(50,50)),this.canvasSize={width:t.DEFAULT_CANVAS_WIDTH,height:t.DEFAULT_CANVAS_HEIGHT};var l="string"==typeof e.canvas?document.querySelector(e.canvas):e.canvas;if(void 0===l)throw'Cannot initialize PlotBoilerplate with a null canvas (element "'.concat(e.canvas," not found).");if("canvas"===l.tagName.toLowerCase())if(this.canvas=l,this.eventCatcher=this.canvas,this.config.enableGL&&void 0===o.drawutilsgl&&(console.warn("Cannot use webgl. Package was compiled without experimental gl support. Please use plotboilerplate-glsupport.min.js instead."),console.warn("Disabling GL and falling back to Canvas2D."),this.config.enableGL=!1),this.config.enableGL){var c=this.canvas.getContext("webgl");this.draw=new o.drawutilsgl(c,!1),this.fill=this.draw.copyInstance(!0),console.warn("Initialized with experimental mode enableGL=true. Note that this is not yet fully implemented.")}else c=this.canvas.getContext("2d"),this.draw=new n.drawutils(c,!1),this.fill=new n.drawutils(c,!0);else{if("svg"!==l.tagName.toLowerCase())throw"Element is neither a canvas nor an svg element.";if(void 0===a.drawutilssvg)throw"The svg draw library is not yet integrated part of PlotBoilerplate. Please include ./src/js/utils/helpers/drawutils.svg into your document.";this.canvas=l,this.draw=new a.drawutilssvg(this.canvas,new C.Vertex,new C.Vertex,this.canvasSize,!1,this.drawConfig,!1),this.fill=this.draw.copyInstance(!0),this.canvas.parentElement?(this.eventCatcher=document.createElement("div"),this.eventCatcher.style.position="absolute",this.eventCatcher.style.left="0",this.eventCatcher.style.top="0",this.eventCatcher.style.cursor="pointer",this.canvas.parentElement.style.position="relative",this.canvas.parentElement.appendChild(this.eventCatcher)):this.eventCatcher=document.body}e.title&&this.eventCatcher.setAttribute("title",e.title),this.draw.scale.set(null!==(s=this.config.scaleX)&&void 0!==s?s:1,this.config.scaleY),this.fill.scale.set(null!==(r=this.config.scaleX)&&void 0!==r?r:1,this.config.scaleY),this.vertices=[],this.selectPolygon=null,this.draggedElements=[],this.drawables=[],this.console=console,this.hooks={saveFile:t._saveFile};var u=this;globalThis.addEventListener("resize",(function(){return u.resizeCanvas()})),this.resizeCanvas(),e.autoDetectRetina&&this._setToRetina(),this.installInputListeners(),this.updateCSSscale(),this.redraw(),this.canvas.focus()}var e;return t._saveFile=function(t){var e=document.createElementNS("http://www.w3.org/2000/svg","svg"),i=new a.drawutilssvg(e,t.draw.offset,t.draw.scale,t.canvasSize,!1,t.drawConfig),s=i.copyInstance(!0);i.beginDrawCycle(0),s.beginDrawCycle(0),t.config.preClear&&t.config.preClear(),i.clear(t.config.backgroundColor||"white"),t.config.preDraw&&t.config.preDraw(i,s),t.drawAll(0,i,s),t.drawVertices(0,i),t.config.postDraw&&t.config.postDraw(i,s),i.endDrawCycle(0),s.endDrawCycle(0);var r=(new XMLSerializer).serializeToString(e),n=new Blob(['<?xml version="1.0" encoding="utf-8"?>\n'+r],{type:"image/svg;charset=utf-8"});if("function"!=typeof globalThis.saveAs)throw"Cannot save file; did you load the ./utils/savefile helper fun