plotboilerplate
Version:
A simple javascript plotting boilerplate for 2d stuff.
1 lines • 163 kB
JavaScript
(()=>{"use strict";var t={30: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.Vector=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="Vector",r}return r(e,t),e.prototype.perp=function(){var t=this.clone();return t.sub(this.a),(t=new e(new o.Vertex,new o.Vertex(-t.b.y,t.b.x))).a.add(this.a),t.b.add(this.a),t},e.prototype.inverse=function(){var t=this.a;return this.a=this.b,this.b=t,this},e.prototype.inv=function(){return this.b.x=this.a.x-(this.b.x-this.a.x),this.b.y=this.a.y-(this.b.y-this.a.y),this},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;return i=r/e,s=n/e,new o.Vertex(this.a.x+i*(this.b.x-this.a.x),this.a.y+i*(this.b.y-this.a.y))},e.prototype.getOrthogonal=function(){var t=this.a.clone(),i=this.b.clone().sub(this.a),s=i.x;return i.x=-i.y,i.y=s,new e(t,i.add(this.a))},e.prototype.rotate=function(t){return this.b.rotate(t,this.a),this},e.utils={buildArrowHead:function(t,e,i,s,r){var n=Math.atan2((e.y-t.y)*r,(e.x-t.x)*s),a=[];return a.push(new o.Vertex(e.x*s-i*Math.cos(n),e.y*r-i*Math.sin(n))),a.push(new o.Vertex(e.x*s-1.35*i*Math.cos(n-Math.PI/8),e.y*r-1.35*i*Math.sin(n-Math.PI/8))),a.push(new o.Vertex(e.x*s,e.y*r)),a.push(new o.Vertex(e.x*s-1.35*i*Math.cos(n+Math.PI/8),e.y*r-1.35*i*Math.sin(n+Math.PI/8))),a}},e}(n.VertTuple);e.Vector=a},39:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.drawutils=void 0;var s=i(973),r=i(787),n=i(378),o=i(30),a=function(){function t(t,e){this.ctx=t,this.offset=new r.Vertex(0,0),this.scale=new r.Vertex(1,1),this.fillShapes=e}return t.prototype.applyStrokeOpts=function(t){var e,i,s,r,n=this;this.ctx.setLineDash((null!==(e=null==t?void 0:t.dashArray)&&void 0!==e?e:[]).map(function(t){return t*n.scale.x})),this.ctx.lineDashOffset=(null!==(i=null==t?void 0:t.dashOffset)&&void 0!==i?i:0)*this.scale.x,this.ctx.lineJoin=null!==(s=null==t?void 0:t.lineJoin)&&void 0!==s?s:null,this.ctx.lineCap=null!==(r=null==t?void 0:t.lineCap)&&void 0!==r?r:null},t.prototype._fillOrDraw=function(t){this.fillShapes?(this.ctx.fillStyle=t,this.ctx.fill()):(this.ctx.strokeStyle=t,this.ctx.stroke())},t.prototype.beginDrawCycle=function(t){},t.prototype.endDrawCycle=function(t){},t.prototype.setConfiguration=function(t){this.ctx.globalCompositeOperation=t.blendMode||"source-over"},t.prototype.setCurrentId=function(t){},t.prototype.setCurrentClassName=function(t){},t.prototype.line=function(t,e,i,s,r){this.ctx.save(),this.ctx.beginPath(),this.applyStrokeOpts(r),this.ctx.moveTo(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y),this.ctx.lineTo(this.offset.x+e.x*this.scale.x,this.offset.y+e.y*this.scale.y),this.ctx.strokeStyle=i,this.ctx.lineWidth=s||1,this.ctx.stroke(),this.ctx.restore()},t.prototype.arrow=function(t,e,i,s,n,o){void 0===n&&(n=8);var a=new r.Vertex(0,0);this.arrowHead(t,e,i,s,n,void 0,a),this.line(t,a,i,s,o)},t.prototype.cubicBezierArrow=function(t,e,i,s,n,o,a,h){var c=new r.Vertex(0,0);this.arrowHead(s,e,n,o,a,void 0,c);var l=c.difference(e);this.cubicBezier(t,{x:e.x-l.x,y:e.y-l.y},i,{x:s.x-l.x,y:s.y-l.y},n,o,h)},t.prototype.arrowHead=function(t,e,i,s,r,n,a){void 0===r&&(r=8),this.ctx.save(),this.ctx.beginPath(),this.applyStrokeOpts(n);var h=o.Vector.utils.buildArrowHead(t,e,r,this.scale.x,this.scale.y);a&&(a.x=h[0].x/this.scale.x,a.y=h[0].y/this.scale.y),this.ctx.moveTo(this.offset.x+h[0].x,this.offset.y+h[0].y);for(var c=0;c<h.length;c++)this.ctx.lineTo(this.offset.x+h[c].x,this.offset.y+h[c].y);this.ctx.lineTo(this.offset.x+h[0].x,this.offset.y+h[0].y),this.ctx.lineWidth=s||1,this._fillOrDraw(i),this.ctx.restore()},t.prototype.image=function(t,e,i,s){void 0===s&&(s=1),t.complete&&t.naturalWidth&&(this.ctx.save(),this.ctx.globalAlpha=s,this.ctx.drawImage(t,0,0,t.naturalWidth-1,t.naturalHeight-1,this.offset.x+e.x*this.scale.x,this.offset.y+e.y*this.scale.y,i.x*this.scale.x,i.y*this.scale.y),this.ctx.restore())},t.prototype.texturedPoly=function(e,i,s,n,o){var a=s.getBounds(),h=(new r.Vertex(n.x,n.y).difference(a.getCenter()),new r.Vertex(i.width,i.height)),c=new r.Vertex(i.min.x,i.min.y).sub(n);this.ctx.save(),this.ctx.translate(this.offset.x+n.x*this.scale.x,this.offset.y+n.y*this.scale.y),t.helpers.clipPoly(this.ctx,{x:-n.x*this.scale.x,y:-n.y*this.scale.y},this.scale,s.vertices),this.ctx.scale(this.scale.x,this.scale.y),this.ctx.rotate(o),this.ctx.drawImage(e,0,0,e.naturalWidth-1,e.naturalHeight-1,c.x,c.y,h.x,h.y),this.ctx.restore()},t.prototype.rect=function(t,e,i,s,r,n){this.ctx.save(),this.ctx.beginPath(),this.applyStrokeOpts(n),this.ctx.moveTo(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y),this.ctx.lineTo(this.offset.x+(t.x+e)*this.scale.x,this.offset.y+t.y*this.scale.y),this.ctx.lineTo(this.offset.x+(t.x+e)*this.scale.x,this.offset.y+(t.y+i)*this.scale.y),this.ctx.lineTo(this.offset.x+t.x*this.scale.x,this.offset.y+(t.y+i)*this.scale.y),this.ctx.closePath(),this.ctx.lineWidth=r||1,this._fillOrDraw(s),this.ctx.restore()},t.prototype.bounds=function(t,e,i,s){this.rect(t.min,t.max.x-t.min.x,t.max.y-t.min.y,e,i,s)},t.prototype.cubicBezier=function(t,e,i,r,n,o,a){t instanceof s.CubicBezierCurve?this.cubicBezier(t.startPoint,t.endPoint,t.startControlPoint,t.endControlPoint,n,o):(this.ctx.save(),this.ctx.beginPath(),this.applyStrokeOpts(a),this.ctx.moveTo(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y),this.ctx.bezierCurveTo(this.offset.x+i.x*this.scale.x,this.offset.y+i.y*this.scale.y,this.offset.x+r.x*this.scale.x,this.offset.y+r.y*this.scale.y,this.offset.x+e.x*this.scale.x,this.offset.y+e.y*this.scale.y),this.ctx.lineWidth=o||2,this._fillOrDraw(n),this.ctx.restore())},t.prototype.quadraticBezier=function(t,e,i,s,r,n){this.ctx.save(),this.ctx.beginPath(),this.applyStrokeOpts(n),this.ctx.moveTo(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y),this.ctx.quadraticCurveTo(this.offset.x+e.x*this.scale.x,this.offset.y+e.y*this.scale.y,this.offset.x+i.x*this.scale.x,this.offset.y+i.y*this.scale.y),this.ctx.lineWidth=r||2,this._fillOrDraw(s),this.ctx.restore()},t.prototype.cubicBezierPath=function(t,e,i,s,r){if(t&&0!=t.length){var n,o,a;this.ctx.save(),this.ctx.beginPath(),this.applyStrokeOpts(s),this.ctx.moveTo(this.offset.x+t[0].x*this.scale.x,this.offset.y+t[0].y*this.scale.y);for(var h=1;h<t.length;h+=3)o=t[h],a=t[h+1],n=t[h+2],this.ctx.bezierCurveTo(this.offset.x+o.x*this.scale.x,this.offset.y+o.y*this.scale.y,this.offset.x+a.x*this.scale.x,this.offset.y+a.y*this.scale.y,this.offset.x+n.x*this.scale.x,this.offset.y+n.y*this.scale.y);r||this.ctx.closePath(),this.ctx.lineWidth=i||1,this._fillOrDraw(e),this.ctx.restore()}},t.prototype.handle=function(t,e){this.point(t,"rgb(0,32,192)"),this.square(e,5,"rgba(0,128,192,0.5)")},t.prototype.handleLine=function(t,e){this.line(t,e,"rgba(128,128,128, 0.5)",void 0)},t.prototype.dot=function(t,e){this.ctx.save(),this.ctx.beginPath(),this.ctx.setLineDash([]),this.ctx.moveTo(Math.round(this.offset.x+this.scale.x*t.x),Math.round(this.offset.y+this.scale.y*t.y)),this.ctx.lineTo(Math.round(this.offset.x+this.scale.x*t.x+1),Math.round(this.offset.y+this.scale.y*t.y+1)),this.ctx.closePath(),this.ctx.lineWidth=1,this._fillOrDraw(e),this.ctx.restore()},t.prototype.point=function(t,e){this.ctx.setLineDash([]),this.ctx.beginPath(),this.ctx.arc(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y,3,0,2*Math.PI,!1),this.ctx.closePath(),this.ctx.lineWidth=1,this._fillOrDraw(e)},t.prototype.circle=function(t,e,i,s,r){this.applyStrokeOpts(r),this.ctx.beginPath(),this.ctx.ellipse(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y,e*this.scale.x,e*this.scale.y,0,0,2*Math.PI),this.ctx.closePath(),this.ctx.lineWidth=s||1,this._fillOrDraw(i)},t.prototype.circleArc=function(t,e,i,s,r,n,o){o&&o.asSegment||this.ctx.beginPath(),this.applyStrokeOpts(o),this.ctx.ellipse(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y,e*this.scale.x,e*this.scale.y,0,i,s,!1),o&&o.asSegment||(this.ctx.lineWidth=n||1,this._fillOrDraw(r||"#000000"))},t.prototype.ellipse=function(t,e,i,s,r,n,o){void 0===n&&(n=0),this.applyStrokeOpts(o),this.ctx.beginPath(),this.ctx.ellipse(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y,e*this.scale.x,i*this.scale.y,n,0,2*Math.PI),this.ctx.closePath(),this.ctx.lineWidth=r||1,this._fillOrDraw(s)},t.prototype.square=function(t,e,i,s,r){this.applyStrokeOpts(r),this.ctx.beginPath(),this.ctx.rect(this.offset.x+(t.x-e/2)*this.scale.x,this.offset.y+(t.y-e/2)*this.scale.y,e*this.scale.x,e*this.scale.y),this.ctx.closePath(),this.ctx.lineWidth=s||1,this._fillOrDraw(i)},t.prototype.grid=function(t,e,i,s,r,n){this.ctx.setLineDash([]),this.ctx.beginPath();for(var o=-Math.ceil(.5*i/r)*r,a=i/2,h=-Math.ceil(.5*e/s)*s;h<e/2;h+=s)this.ctx.moveTo(this.offset.x+(t.x+h)*this.scale.x,this.offset.y+(t.y+o)*this.scale.y),this.ctx.lineTo(this.offset.x+(t.x+h)*this.scale.x,this.offset.y+(t.y+a)*this.scale.y);for(var c=-Math.ceil(.5*e/s)*s,l=e/2,u=-Math.ceil(.5*i/r)*r;u<i/2;u+=r)this.ctx.moveTo(this.offset.x+(t.x+c)*this.scale.x-4,this.offset.y+(t.y+u)*this.scale.y),this.ctx.lineTo(this.offset.x+(t.x+l)*this.scale.x+4,this.offset.y+(t.y+u)*this.scale.y);this.ctx.strokeStyle=n,this.ctx.lineWidth=1,this.ctx.stroke(),this.ctx.closePath()},t.prototype.raster=function(t,e,i,s,r,n){this.ctx.save(),this.ctx.setLineDash([]),this.ctx.beginPath();for(var o=-Math.ceil(.5*e/s)*s;o<e/2;o+=s)for(var a=-Math.ceil(.5*i/r)*r;a<i/2;a+=r)this.ctx.moveTo(this.offset.x+(t.x+o)*this.scale.x-4,this.offset.y+(t.y+a)*this.scale.y),this.ctx.lineTo(this.offset.x+(t.x+o)*this.scale.x+4,this.offset.y+(t.y+a)*this.scale.y),this.ctx.moveTo(this.offset.x+(t.x+o)*this.scale.x,this.offset.y+(t.y+a)*this.scale.y-4),this.ctx.lineTo(this.offset.x+(t.x+o)*this.scale.x,this.offset.y+(t.y+a)*this.scale.y+4);this.ctx.strokeStyle=n,this.ctx.lineWidth=1,this.ctx.stroke(),this.ctx.closePath(),this.ctx.restore()},t.prototype.diamondHandle=function(t,e,i){this.ctx.setLineDash([]),this.ctx.beginPath(),this.ctx.moveTo(this.offset.x+t.x*this.scale.x-e/2,this.offset.y+t.y*this.scale.y),this.ctx.lineTo(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y-e/2),this.ctx.lineTo(this.offset.x+t.x*this.scale.x+e/2,this.offset.y+t.y*this.scale.y),this.ctx.lineTo(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y+e/2),this.ctx.closePath(),this.ctx.lineWidth=1,this._fillOrDraw(i)},t.prototype.squareHandle=function(t,e,i){this.ctx.setLineDash([]),this.ctx.beginPath(),this.ctx.rect(this.offset.x+t.x*this.scale.x-e/2,this.offset.y+t.y*this.scale.y-e/2,e,e),this.ctx.closePath(),this.ctx.lineWidth=1,this._fillOrDraw(i)},t.prototype.circleHandle=function(t,e,i){e=e||3,this.ctx.setLineDash([]),this.ctx.beginPath(),this.ctx.arc(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y,e,0,2*Math.PI,!1),this.ctx.closePath(),this.ctx.lineWidth=1,this._fillOrDraw(i)},t.prototype.crosshair=function(t,e,i,s){this.ctx.save(),this.ctx.setLineDash([]),this.ctx.beginPath(),this.ctx.moveTo(this.offset.x+t.x*this.scale.x-e,this.offset.y+t.y*this.scale.y),this.ctx.lineTo(this.offset.x+t.x*this.scale.x+e,this.offset.y+t.y*this.scale.y),this.ctx.moveTo(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y-e),this.ctx.lineTo(this.offset.x+t.x*this.scale.x,this.offset.y+t.y*this.scale.y+e),this.ctx.strokeStyle=i,this.ctx.lineWidth=s||.5,this.ctx.stroke(),this.ctx.closePath(),this.ctx.restore()},t.prototype.cross=function(t,e,i,s){this.ctx.save(),this.ctx.setLineDash([]),this.ctx.beginPath(),this.ctx.moveTo(this.offset.x+t.x*this.scale.x-e,this.offset.y+t.y*this.scale.y-e),this.ctx.lineTo(this.offset.x+t.x*this.scale.x+e,this.offset.y+t.y*this.scale.y+e),this.ctx.moveTo(this.offset.x+t.x*this.scale.x-e,this.offset.y+t.y*this.scale.y+e),this.ctx.lineTo(this.offset.x+t.x*this.scale.x+e,this.offset.y+t.y*this.scale.y-e),this.ctx.strokeStyle=i,this.ctx.lineWidth=s||1,this.ctx.stroke(),this.ctx.closePath(),this.ctx.restore()},t.prototype.polygon=function(t,e,i,s){this.polyline(t.vertices,t.isOpen,e,i,s)},t.prototype.polyline=function(t,e,i,s,r){if(!(t.length<=1)){this.ctx.save(),this.applyStrokeOpts(r),this.ctx.beginPath(),this.ctx.lineWidth=s||1,this.ctx.moveTo(this.offset.x+t[0].x*this.scale.x,this.offset.y+t[0].y*this.scale.y);for(var n=0;n<t.length;n++)this.ctx.lineTo(this.offset.x+t[n].x*this.scale.x,this.offset.y+t[n].y*this.scale.y);e||this.ctx.closePath(),this._fillOrDraw(i),this.ctx.closePath(),this.ctx.setLineDash([]),this.ctx.restore()}},t.prototype.text=function(t,e,i,s){var r,n,o;s=s||{},this.ctx.save();var a=this.offset.x+e*this.scale.x,h=this.offset.y+i*this.scale.y,c=s.color||"black";(s.fontSize||s.fontFamily)&&(this.ctx.font=(s.fontWeight?s.fontWeight+" ":"")+(s.fontStyle?s.fontStyle+" ":"")+(s.fontSize?s.fontSize*this.scale.x+"px ":" ")+(s.fontFamily?-1===s.fontFamily.indexOf(" ")?s.fontFamily:'"'.concat(s.fontFamily,'"'):"Arial")),s.textAlign&&(this.ctx.textAlign=s.textAlign);var l=null!==(r=s.rotation)&&void 0!==r?r:0,u=(null!==(o=null!==(n=s.lineHeight)&&void 0!==n?n:s.fontSize)&&void 0!==o?o:0)*this.scale.x;this.ctx.translate(a,h),this.ctx.rotate(l),this.fillShapes?(this.ctx.fillStyle=c,this.ctx.fillText(t,0,u/2)):(this.ctx.strokeStyle=c,this.ctx.strokeText(t,0,u/2)),this.ctx.restore()},t.prototype.label=function(t,e,i,s,r){this.ctx.save(),this.ctx.font="lighter 9pt Arial",this.ctx.translate(e,i),void 0!==s&&this.ctx.rotate(s),this.ctx.fillStyle=r||"black",this.fillShapes?this.ctx.fillText(t,0,0):this.ctx.strokeText(t,0,0),this.ctx.restore()},t.prototype.path=function(t,e,i,s){var r=s&&s.inplace?t:n.drawutilssvg.copyPathData(t);n.drawutilssvg.transformPathData(r,this.offset,this.scale),e&&(this.ctx.strokeStyle=e),this.ctx.lineWidth=i||1,this.applyStrokeOpts(s),this.fillShapes?(e&&(this.ctx.fillStyle=e),this.ctx.fill(new Path2D(r.join(" ")))):(e&&(this.ctx.strokeStyle=e),this.ctx.stroke(new Path2D(r.join(" "))))},t.prototype.clear=function(t){this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.fillStyle=t,this.ctx.fillRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)},t.helpers={clipPoly:function(t,e,i,s){t.beginPath(),t.moveTo(e.x+s[0].x*i.x,e.y+s[0].y*i.y);for(var r=1;r<s.length;r++){var n=s[r];t.lineTo(e.x+n.x*i.x,e.y+n.y*i.y)}t.closePath(),t.clip()}},t}();e.drawutils=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.containsVert=function(t){return this.min.x<=t.x&&t.x<this.max.x&&this.min.y<=t.y&&t.y<this.max.y},t.prototype.getWidth=function(){return this.max.x-this.min.x},t.prototype.getHeight=function(){return this.max.y-this.min.y},t.prototype.getScaled=function(e){var i=this.getCenter();return new t(new r.Vertex(this.min).scale(e,i),new r.Vertex(this.max).scale(e,i))},t.prototype.getMoved=function(e){return new t(new r.Vertex(this.min).move(e),new r.Vertex(this.max).move(e))},t.prototype.getNorthPoint=function(){return new r.Vertex(this.min.x+this.width/2,this.min.y)},t.prototype.getSouthPoint=function(){return new r.Vertex(this.min.x+this.width/2,this.max.y)},t.prototype.getWestPoint=function(){return new r.Vertex(this.min.x,this.min.y+this.height/2)},t.prototype.getEastPoint=function(){return new r.Vertex(this.max.x,this.min.y+this.height/2)},t.prototype.getNorthWestPoint=function(){return new r.Vertex(this.min.x,this.min.y)},t.prototype.getNorthEastPoint=function(){return new r.Vertex(this.max.x,this.min.y)},t.prototype.getSouthEastPoint=function(){return new r.Vertex(this.max.x,this.max.y)},t.prototype.getSouthWestPoint=function(){return new r.Vertex(this.min.x,this.max.y)},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.getMinDimension=function(){return Math.min(this.width,this.height)},t.prototype.getMaxDimension=function(){return Math.max(this.width,this.height)},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.computeFromBoundsSet=function(e){if(0==e.length)return new t(new r.Vertex(0,0),new r.Vertex(0,0));var i,s=e[0].min.x,n=e[0].max.x,o=e[0].min.y,a=e[0].min.y;for(var h in e)i=e[h],s=Math.min(s,i.min.x),n=Math.max(n,i.max.x),o=Math.min(o,i.min.y),a=Math.max(a,i.min.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(76),r=i(939),n=i(938),o=i(30),a=i(787),h=function(){function t(t,e){this.className="Circle",this.uid=n.UIDGenerator.next(),this.center=t,this.radius=e}return t.prototype.move=function(t){return this.center.add(t),this},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 o.Vector(i,new a.Vertex(0,0)).add(this.center).perp()},t.prototype.getBounds=function(){return new s.Bounds(this.center.clone().subXY(Math.abs(this.radius),Math.abs(this.radius)),this.center.clone().addXY(Math.abs(this.radius),Math.abs(this.radius)))},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,s=e.distance(i),n=(this.radius*this.radius-t.radius*t.radius+s*s)/(2*s),o=Math.sqrt(this.radius*this.radius-n*n),h=i.clone().scale(n/s,e),c=h.x+o*(i.y-e.y)/s,l=h.y-o*(i.x-e.x)/s,u=h.x-o*(i.y-e.y)/s,d=h.y+o*(i.x-e.x)/s;return new r.Line(new a.Vertex(c,l),new a.Vertex(u,d))},t.prototype.lineIntersection=function(t,e){var i=new a.Vertex,s=new a.Vertex,n=new a.Vertex(t).sub(this.center),o=new a.Vertex(e).sub(this.center),h=n.difference(o);0===Math.abs(h.y)&&(h.y=1e-6);var c=n.distance(o),l=n.x*o.y-n.y*o.x,u=c*c;if(this.radius*this.radius*u-l*l<0)return null;var d=this.radius*this.radius*c*c-l*l,p=Math.sqrt(d);return i.x=(l*h.y+Math.sign(h.y)*h.x*p)/u,s.x=(l*h.y-Math.sign(h.y)*h.x*p)/u,i.y=(-l*h.x+Math.abs(h.y)*p)/u,s.y=(-l*h.x-Math.abs(h.y)*p)/u,new r.Line(i.add(this.center),s.add(this.center))},t.prototype.lineIntersections=function(t,e){void 0===e&&(e=!1);var i=this.lineIntersection(t.a,t.b);return i?e?[i.a,i.b].filter(function(e){return t.hasPoint(e,!0)}):[i.a,i.b]:[]},t.prototype.lineIntersectionTangents=function(t,e){var i=this;return void 0===e&&(e=!1),this.lineIntersections(t,e).map(function(t){var e=new r.Line(i.center,t).angle();return i.tangentAt(e)})},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 a.Vertex},t.prototype.destroy=function(){this.center.destroy(),this.isDestroyed=!0},t.circleUtils={vertAt:function(t,e){return new a.Vertex(Math.cos(t)*e,Math.sin(t)*e)}},t}();e.Circle=h},135:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CircleSector=void 0;var s=i(76),r=i(118),n=i(939),o=i(938),a=i(787),h=i(328),c=function(){function t(t,e,i){this.className="CircleSector",this.uid=o.UIDGenerator.next(),this.circle=t,this.startAngle=e,this.endAngle=i}return t.prototype.getBounds=function(){var t=this,e=this.circle.getBounds(),i=[e.getNorthPoint(),e.getSouthPoint(),e.getWestPoint(),e.getEastPoint()].filter(function(e){var i=new n.Line(t.circle.center,e).angle();return t.containsAngle(i)});return s.Bounds.computeFromVertices(i.concat([this.getStartPoint(),this.getEndPoint()]))},t.prototype.move=function(t){return this.circle.move(t),this},t.prototype.containsAngle=function(t){var e=h.geomutils.mapAngleTo2PI(t),i=h.geomutils.mapAngleTo2PI(this.startAngle),s=h.geomutils.mapAngleTo2PI(this.endAngle);return i<=s?e>=i&&e<s:e>=i||e<s},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 s=this.circle.center.angle(i.a),n=this.circle.center.angle(i.b);if(!this.containsAngle(s)||!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),c=new t(new r.Circle(this.circle.center.clone(),this.circle.radius),s,n);return c.containsAngle(h)&&(c.startAngle=n,c.endAngle=s),c},t.prototype.lineIntersections=function(t,e){var i=this;void 0===e&&(e=!1);var s=this.circle.lineIntersections(t,e),r=new n.Line(this.circle.center,new a.Vertex);return s.filter(function(t){r.b.set(t);var e=r.angle();return i.containsAngle(h.geomutils.wrapMinMax(e,0,2*Math.PI))})},t.prototype.lineIntersectionTangents=function(t,e){var i=this;return void 0===e&&(e=!1),this.lineIntersections(t,e).map(function(t){var e=new n.Line(i.circle.center,t).angle();return i.circle.tangentAt(e)})},t.prototype.describeSVGPath=function(e){return t.circleSectorUtils.describeSVGArc(this.circle.center.x,this.circle.center.y,this.circle.radius,this.startAngle,this.endAngle,e)},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 c=t.circleSectorUtils.describeSVGArc(e,i,s,r,r+(n-r)/2,o),l=t.circleSectorUtils.describeSVGArc(e,i,s,r+(n-r)/2,n,o);return c.concat(l)}var u,d,p=n-r;p<0?(u=Math.abs(p)<Math.PI?1:0,d=1):(u=Math.abs(p)>Math.PI?1:0,d=1);var f=[];return o.moveToStart&&f.push("M",h.x,h.y),f.push("A",s,s,0,u,d,a.x,a.y),f}},t}();e.CircleSector=c},264:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.drawutilsgl=void 0;var s=i(787),r=function(){function t(e,i){this.gl=e,this.offset=new s.Vertex(0,0),this.scale=new s.Vertex(1,1),this.fillShapes=i,this._zindex=0,null!=e&&void 0!==e&&(this.glutils=new n(e),this._vertShader=this.glutils.compileShader(t.vertCode,this.gl.VERTEX_SHADER),this._fragShader=this.glutils.compileShader(t.fragCode,this.gl.FRAGMENT_SHADER),this._program=this.glutils.makeProgram(this._vertShader,this._fragShader),this.vertex_buffer=this.gl.createBuffer(),console.log("gl initialized"))}return t.prototype._x2rel=function(t){return(this.scale.x*t+this.offset.x)/this.gl.canvas.width*2-1},t.prototype._y2rel=function(t){return(this.offset.y-this.scale.y*t)/this.gl.canvas.height*2-1},t.prototype.copyInstance=function(e){var i=new t(null,e);return i.gl=this.gl,i.glutils=this.glutils,i._vertShader=this._vertShader,i._fragShader=this._fragShader,i._program=this._program,i},t.prototype.beginDrawCycle=function(t){this._zindex=0,this.renderTime=t},t.prototype.endDrawCycle=function(t){},t.prototype.setConfiguration=function(t){},t.prototype.setCurrentId=function(t){this.curId=t},t.prototype.setCurrentClassName=function(t){},t.prototype.line=function(t,e,i){var s=new Float32Array(6);s[0]=this._x2rel(t.x),s[1]=this._y2rel(t.y),s[2]=this._zindex,s[3]=this._x2rel(e.x),s[4]=this._y2rel(e.y),s[5]=this._zindex,this._zindex+=.001,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertex_buffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,s,this.gl.STATIC_DRAW);var r=this.gl.getAttribLocation(this._program,"position");this.gl.vertexAttribPointer(r,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(r),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height);var n=this.gl.getUniformLocation(this._program,"uRotationVector");this.gl.uniform2fv(n,[0,1]),this.gl.lineWidth(5),this.gl.drawArrays(this.gl.LINES,0,s.length/3)},t.prototype.arrow=function(t,e,i){},t.prototype.cubicBezierArrow=function(t,e,i,s,r,n,o){},t.prototype.arrowHead=function(t,e,i,s,r){},t.prototype.image=function(t,e,i,s){void 0===s&&(s=0)},t.prototype.texturedPoly=function(t,e,i,s,r){},t.prototype._fillOrDraw=function(t){},t.prototype.cubicBezier=function(t,e,i,s,r,n){},t.prototype.cubicBezierPath=function(t,e,i,s,r){},t.prototype.handle=function(t,e){},t.prototype.handleLine=function(t,e){},t.prototype.dot=function(t,e){},t.prototype.point=function(t,e){},t.prototype.circle=function(t,e,i,s){},t.prototype.circleArc=function(t,e,i,s,r,n){},t.prototype.ellipse=function(t,e,i,s,r,n){},t.prototype.square=function(t,e,i,s){},t.prototype.rect=function(t,e,i,s,r,n){},t.prototype.bounds=function(t,e,i,s){this.rect(t.min,t.max.x-t.min.x,t.max.y-t.min.y,e,i,s)},t.prototype.grid=function(t,e,i,s,r,n){},t.prototype.raster=function(t,e,i,s,r,n){},t.prototype.diamondHandle=function(t,e,i){},t.prototype.squareHandle=function(t,e,i){},t.prototype.circleHandle=function(t,e,i){},t.prototype.crosshair=function(t,e,i,s){},t.prototype.cross=function(t,e,i,s){},t.prototype.polygon=function(t,e,i){for(var s=new Float32Array(3*t.vertices.length),r=0;r<t.vertices.length;r++)s[3*r+0]=this._x2rel(t.vertices[r].x),s[3*r+1]=this._y2rel(t.vertices[r].y),s[3*r+2]=this._zindex;this._zindex+=.001,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertex_buffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,s,this.gl.STATIC_DRAW);var n=this.gl.getAttribLocation(this._program,"position");this.gl.vertexAttribPointer(n,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(n),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height);var o=this.gl.getUniformLocation(this._program,"uRotationVector");this.gl.uniform2fv(o,[0,1]),this.gl.drawArrays(this.gl.TRIANGLE_FAN,0,s.length/3)},t.prototype.polyline=function(t,e,i,s){},t.prototype.text=function(t,e,i,s){},t.prototype.label=function(t,e,i,s,r){},t.prototype.path=function(t,e,i,s){},t.prototype.clear=function(t){this.gl.clearColor(1,1,1,1),this.gl.enable(this.gl.DEPTH_TEST),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT)},t.vertCode="\n precision mediump float;\n\n attribute vec3 position;\n\n uniform vec2 uRotationVector;\n\n void main(void) {\n\tvec2 rotatedPosition = vec2(\n\t position.x * uRotationVector.y +\n\t\tposition.y * uRotationVector.x,\n\t position.y * uRotationVector.y -\n\t\tposition.x * uRotationVector.x\n\t);\n\n\tgl_Position = vec4(rotatedPosition, position.z, 1.0);\n }",t.fragCode="\n precision highp float;\n\n void main(void) {\n\tgl_FragColor = vec4(0.0,0.75,1.0,1.0);\n }",t}();e.drawutilsgl=r;var n=function(){function t(t){this.gl=t}return t.prototype.bufferData=function(t){var e=this.gl.createBuffer();return this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e),this.gl.bufferData(this.gl.ARRAY_BUFFER,t,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),e},t.prototype.compileShader=function(t,e){var i=this.gl.createShader(e);return this.gl.shaderSource(i,t),this.gl.compileShader(i),this.gl.getShaderParameter(i,this.gl.COMPILE_STATUS)?i:(console.warn("Error in shader:"+this.gl.getShaderInfoLog(i)),this.gl.deleteShader(i),null)},t.prototype.makeProgram=function(t,e){var i=this.gl.createProgram();return this.gl.attachShader(i,t),this.gl.attachShader(i,e),this.gl.linkProgram(i),this.gl.useProgram(i),this.gl.detachShader(i,t),this.gl.detachShader(i,e),this.gl.deleteShader(t),this.gl.deleteShader(e),i},t}()},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},328:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.geomutils=void 0;var s=i(939),r=i(737);e.geomutils={mapAngleTo2PI:function(t){var e=Math.asin(Math.sin(t));return Math.cos(t)<0?Math.PI-e:e<0?e+2*Math.PI:e},dist4:function(t,e,i,s){return Math.sqrt(Math.pow(i-t,2)+Math.pow(e-s,2))},dotProduct:function(t,e){return t.x*e.x+t.y*e.y},nsectAngle:function(t,e,i,n){var o=new r.Triangle(t,e,i),a=new s.Line(t,e),h=new s.Line(t,i),c=a.angle(h),l=o.determinant()>0;c<0&&(c=2*Math.PI+c),l||(c=-1*(2*Math.PI-c));for(var u=Math.max(a.length(),h.length())/a.length(),d=[],p=1;p<n;p++)d.push(new s.Line(t,e.clone().rotate(c/n*-p,t)).scale(u));return d},wrapMax:function(t,e){return(e+t%e)%e},wrapMinMax:function(t,i,s){return i+e.geomutils.wrapMax(t-i,s-i)}}},378:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.drawutilssvg=void 0;var s=i(135),r=i(973),n=i(787),o=i(938),a=i(30),h=180/Math.PI,c=function(){function t(t,e,i,s,r,o,a,h,c,l,u,d){if(this.svgNode=t,this.offset=new n.Vertex(0,0).set(e),this.scale=new n.Vertex(1,1).set(i),this.fillShapes=r,this.isSecondary=Boolean(a),this.drawConfig=o,this.drawlibConfiguration={},this.cache=new Map,this.setSize(s),a){if(!(h&&c&&l&&u))throw"Cannot create secondary svg draw lib with undefinde gNode|bufferGNode|nodeDefs|bufferNodeDefs.";this.gNode=h,this.bufferGNode=c,this.nodeDefs=l,this.bufferedNodeDefs=u,d&&(this.nodeStyle=d)}else this.addStyleDefs(o),this.addDefsNode(),this.gNode=this.createSVGNode("g"),this.bufferGNode=this.createSVGNode("g"),this.svgNode.appendChild(this.gNode)}return t.prototype.addStyleDefs=function(t){this.nodeStyle=this.createSVGNode("style"),this.svgNode.appendChild(this.nodeStyle),this.rebuildStyleDefs(t)},t.prototype.rebuildStyleDefs=function(t){var e={bezier:"CubicBezierCurve",polygon:"Polygon",triangle:"Triangle",ellipse:"Ellipse",ellipseSector:"EllipseSector",circle:"Circle",circleSector:"CircleSector",vertex:"Vertex",line:"Line",vector:"Vector",image:"Image",text:"Text"},i=[];for(var s in e){var r=e[s],n=t[s];n?i.push(".".concat(r," { fill : none; stroke: ").concat(n.color,"; stroke-width: ").concat(n.lineWidth,"px }")):console.warn("Warning: your draw config is missing the key '".concat(s,"' which is required."))}this.customStyleDefs&&(i.push("\n/* Custom styles */\n"),this.customStyleDefs.forEach(function(t,e){i.push(e+" { "+t+" }")})),this.nodeStyle.innerHTML=i.join("\n")},t.prototype.addDefsNode=function(){this.nodeDefs=this.createSVGNode("defs"),this.bufferedNodeDefs=this.createSVGNode("defs"),this.svgNode.appendChild(this.nodeDefs)},t.prototype.addCustomStyleDefs=function(t){this.customStyleDefs=t},t.prototype.findElement=function(t,e){if(!t)return null;var i=this.cache.get(t);return i&&i.nodeName.toUpperCase()===e.toUpperCase()?(this.cache.delete(t),i):null},t.prototype.createSVGNode=function(t){return document.createElementNS("http://www.w3.org/2000/svg",t)},t.prototype.makeNode=function(t){var e=this.findElement(this.curId,t);if(e||(e=this.createSVGNode(t)),this.drawlibConfiguration.blendMode){var i=e.style["mix-blend-mode"];"function"==typeof i?i(this.drawlibConfiguration.blendMode):e.style["mix-blend-mode"]=this.drawlibConfiguration.blendMode}return e},t.prototype._bindFillDraw=function(t,e,i,s,r){return this._configureNode(t,e,this.fillShapes,i,s,r),this._bindNode(t,void 0)},t.prototype._bindNode=function(t,e){return t.parentNode||(null!=e?e:this.bufferGNode).appendChild(t),t},t.prototype._addCSSClasses=function(t,e){this.curClassName?t.setAttribute("class","".concat(e," ").concat(this.curClassName)):t.setAttribute("class",e)},t.prototype._configureNode=function(t,e,i,s,r,n){return this._addCSSClasses(t,e),t.setAttribute("fill",i&&s?s:"none"),t.setAttribute("stroke",i?"none":s||"none"),t.setAttribute("stroke-width","".concat(r||1)),this.curId&&t.setAttribute("id","".concat(this.curId)),this.applyStrokeOpts(t,n),t},t.prototype.setSize=function(t){this.canvasSize=t,this.svgNode.setAttribute("viewBox","0 0 ".concat(this.canvasSize.width," ").concat(this.canvasSize.height)),this.svgNode.setAttribute("width","".concat(this.canvasSize.width)),this.svgNode.setAttribute("height","".concat(this.canvasSize.height))},t.prototype.copyInstance=function(e){return new t(this.svgNode,this.offset,this.scale,this.canvasSize,e,this.drawConfig,!0,this.gNode,this.bufferGNode,this.nodeDefs,this.bufferedNodeDefs,this.nodeStyle)},t.prototype.setConfiguration=function(t){this.drawlibConfiguration=t},t.prototype.setCurrentId=function(t){this.curId=t},t.prototype.setCurrentClassName=function(t){this.curClassName=t},t.prototype.beginDrawCycle=function(t){this.cache.clear();for(var e=0;e<this.bufferGNode.childNodes.length;e++){var i=this.bufferGNode.childNodes[e];this.cache.set(i.getAttribute("id"),i)}this.removeAllChildNodes()},t.prototype.endDrawCycle=function(t){this.rebuildStyleDefs(this.drawConfig),this.isSecondary||(this.svgNode.replaceChild(this.bufferedNodeDefs,this.nodeDefs),this.svgNode.replaceChild(this.bufferGNode,this.gNode));var e=this.gNode;this.gNode=this.bufferGNode,this.bufferGNode=e;var i=this.nodeDefs;this.nodeDefs=this.bufferedNodeDefs,this.bufferedNodeDefs=i},t.prototype.applyStrokeOpts=function(e,i){var s=this;i&&i.dashArray&&i.dashArray.length>0&&t.nodeSupportsLineDash(e.tagName)&&(e.setAttribute("stroke-dasharray",i.dashArray.map(function(t){return t*s.scale.x}).join(" ")),i.dashOffset&&e.setAttribute("stroke-dashoffset","".concat(i.dashOffset*this.scale.x))),i&&i.lineJoin&&t.nodeSupportsLineJoin(e.tagName)&&e.setAttribute("stroke-linejoin",i.lineJoin),i&&i.lineCap&&t.nodeSupportsLineCap(e.tagName)&&e.setAttribute("stroke-linecap",i.lineCap)},t.prototype._x=function(t){return this.offset.x+this.scale.x*t},t.prototype._y=function(t){return this.offset.y+this.scale.y*t},t.prototype.line=function(t,e,i,s,r){var n=this.makeLineNode(t,e,i,s,r);return this._bindFillDraw(n,"line",i,s||1,r)},t.prototype.arrow=function(t,e,i,s,r,n){void 0===r&&(r=8);var o=this.makeNode("g"),a={x:0,y:0},h=this.makeArrowHeadNode(t,e,i,s,r,void 0,a),c=this.makeLineNode(t,a,i,s,n);return o.appendChild(c),o.appendChild(h),this._addCSSClasses(o,"linear-arrow"),this._bindNode(o,void 0),o},t.prototype.cubicBezierArrow=function(t,e,i,s,r,o,a,h){void 0===a&&(a=8);var c=this.makeNode("g"),l=new n.Vertex(0,0),u=this.makeArrowHeadNode(s,e,r,o,a,void 0,l),d=l.difference(e),p=this.makeCubicBezierNode(t,{x:e.x-d.x,y:e.y-d.y},i,{x:s.x-d.x,y:s.y-d.y},r,o,h);return c.appendChild(p),c.appendChild(u),this._addCSSClasses(c,"cubicbezier-arrow"),this._bindNode(c,void 0),c},t.prototype.arrowHead=function(t,e,i,s,r,n){void 0===r&&(r=8);var o=this.makeArrowHeadNode(t,e,i,s,r,n);return this._bindFillDraw(o,"arrowhead",i,s||1,n)},t.prototype.image=function(t,e,i,s){var r=this;void 0===s&&(s=1);var n=this.makeNode("image"),o=function(t){if(t.naturalWidth){var o=i.x/t.naturalWidth,a=i.y/t.naturalHeight;n.setAttribute("width","".concat(t.naturalWidth*r.scale.x)),n.setAttribute("height","".concat(t.naturalHeight*r.scale.y)),n.setAttribute("display",null),n.setAttribute("opacity","".concat(s)),n.setAttribute("transform","translate(".concat(r._x(e.x)," ").concat(r._y(e.y),") scale(").concat(o," ").concat(a,")"))}};return t.addEventListener("load",function(e){o(t)}),n.setAttribute("x","".concat(0)),n.setAttribute("y","".concat(0)),n.setAttribute("display","none"),o(t),n.setAttribute("href",t.src),this._bindFillDraw(n,"image",null,null)},t.prototype.texturedPoly=function(t,e,i,s,r){var a=new n.Vertex(e.min).clone().rotate(r,s),c=this.makeNode("clipPath"),l="clippath_".concat(o.UIDGenerator.next());c.setAttribute("id",l);var u=this.makeNode("g"),d=this.makeNode("image");d.setAttribute("x","".concat(this._x(a.x))),d.setAttribute("y","".concat(this._y(a.y))),d.setAttribute("width","".concat(e.width)),d.setAttribute("height","".concat(e.height)),d.setAttribute("href",t.src),d.setAttribute("transform","rotate(".concat(r*h,", ").concat(this._x(a.x),", ").concat(this._y(a.y),")"));var p=this.makeNode("path"),f=[];if(i.vertices.length>0){f.push("M","".concat(this._x(i.vertices[0].x)),"".concat(this._y(i.vertices[0].y)));for(var y=1;y<i.vertices.length;y++)f.push("L","".concat(this._x(i.vertices[y].x)),"".concat(this._y(i.vertices[y].y)))}p.setAttribute("d",f.join(" ")),c.appendChild(p),this.bufferedNodeDefs.appendChild(c),u.appendChild(d),u.setAttribute("transform-origin","".concat(this._x(a.x)," ").concat(this._y(a.y))),u.setAttribute("transform","scale(".concat(this.scale.x,", ").concat(this.scale.y,")"));var v=this.makeNode("g");return v.appendChild(u),v.setAttribute("clip-path","url(#".concat(l,")")),this._bindFillDraw(v,"image",null,null),v},t.prototype.cubicBezier=function(t,e,i,s,r,n,o){var a=this.makeCubicBezierNode(t,e,i,s,r,n,o);return this._bindNode(a,void 0)},t.prototype.cubicBezierPath=function(t,e,i,s,r){var n=this.makeNode("path");if(this.applyStrokeOpts(n,s),!t||0==t.length)return n;for(var o,a,h,c=["M",this._x(t[0].x),this._y(t[0].y)],l=1;l<t.length;l+=3)a=t[l],h=t[l+1],o=t[l+2],c.push("C",this._x(a.x),this._y(a.y),this._x(h.x),this._y(h.y),this._x(o.x),this._y(o.y));return r||c.push("Z"),n.setAttribute("d",c.join(" ")),this._bindFillDraw(n,"cubicBezierPath",e,i||1)},t.prototype.handle=function(t,e){this.point(t,"rgb(0,32,192)"),this.square(e,5,"rgba(0,128,192,0.5)")},t.prototype.handleLine=function(t,e){this.line(t,e,"rgb(128,128,128,0.5)")},t.prototype.dot=function(t,e){var i=this.makeNode("line");return i.setAttribute("x1","".concat(this._x(t.x))),i.setAttribute("y1","".concat(this._y(t.y))),i.setAttribute("x2","".concat(this._x(t.x))),i.setAttribute("y2","".concat(this._y(t.y))),this._bindFillDraw(i,"dot",e,1)},t.prototype.point=function(t,e){var i=this.makeNode("circle");return i.setAttribute("cx","".concat(this._x(t.x))),i.setAttribute("cy","".concat(this._y(t.y))),i.setAttribute("r","".concat(3)),this._bindFillDraw(i,"point",e,1)},t.prototype.circle=function(t,e,i,s,r){var n=this.makeNode("circle");return this.applyStrokeOpts(n,r),n.setAttribute("cx","".concat(this._x(t.x))),n.setAttribute("cy","".concat(this._y(t.y))),n.setAttribute("r","".concat(e*this.scale.x)),this._bindFillDraw(n,"circle",i,s||1)},t.prototype.circleArc=function(t,e,i,r,n,o,a){var h=this.makeNode("path");this.applyStrokeOpts(h,a);var c=s.CircleSector.circleSectorUtils.describeSVGArc(this._x(t.x),this._y(t.y),e*this.scale.x,i,r);return h.setAttribute("d",c.join(" ")),this._bindFillDraw(h,"circleArc",n,o||1)},t.prototype.ellipse=function(t,e,i,s,r,n,o){void 0===n&&(n=0);var a=this.makeNode("ellipse");return this.applyStrokeOpts(a,o),a.setAttribute("cx","".concat(this._x(t.x))),a.setAttribute("cy","".concat(this._y(t.y))),a.setAttribute("rx","".concat(e*this.scale.x)),a.setAttribute("ry","".concat(i*this.scale.y)),a.setAttribute("transform","rotate(".concat(180*n/Math.PI," ").concat(this._x(t.x)," ").concat(this._y(t.y),")")),this._bindFillDraw(a,"ellipse",s,r||1)},t.prototype.square=function(t,e,i,s,r){var n=this.makeNode("rectangle");return this.applyStrokeOpts(n,r),n.setAttribute("x","".concat(this._x(t.x-e/2))),n.setAttribute("y","".concat(this._y(t.y-e/2))),n.setAttribute("width","".concat(e*this.scale.x)),n.setAttribute("height","".concat(e*this.scale.y)),this._bindFillDraw(n,"square",i,s||1)},t.prototype.rect=function(t,e,i,s,r,n){var o=this.makeNode("rect");return this.applyStrokeOpts(o,n),o.setAttribute("x","".concat(this._x(t.x))),o.setAttribute("y","".concat(this._y(t.y))),o.setAttribute("width","".concat(e*this.scale.x)),o.setAttribute("height","".concat(i*this.scale.y)),this._bindFillDraw(o,"rect",s,r||1)},t.prototype.bounds=function(t,e,i,s){this.rect(t.min,t.max.x-t.min.x,t.max.y-t.min.y,e,i,s)},t.prototype.grid=function(t,e,i,s,r,n){for(var o=this.makeNode("path"),a=[],h=-Math.ceil(.5*i/r)*r,c=i/2,l=-Math.ceil(.5*e/s)*s;l<e/2;l+=s)a.push("M",this._x(t.x+l),this._y(t.y+h)),a.push("L",this._x(t.x+l),this._y(t.y+c));for(var u=-Math.ceil(.5*e/s)*s,d=e/2,p=-Math.ceil(.5*i/r)*r;p<i/2;p+=r)a.push("M",this._x(t.x+u),this._y(t.y+p)),a.push("L",this._x(t.x+d),this._y(t.y+p));return o.setAttribute("d",a.join(" ")),this._bindFillDraw(o,"grid",n,1)},t.prototype.raster=function(t,e,i,s,r,n){for(var o=this.makeNode("path"),a=[],h=-Math.ceil(.5*e/s)*s;h<e/2;h+=s)for(var c=-Math.ceil(.5*i/r)*r;c<i/2;c+=r)a.push("M",this._x(t.x+h)-4,this._y(t.y+c)),a.push("L",this._x(t.x+h)+4,this._y(t.y+c)),a.push("M",this._x(t.x+h),this._y(t.y+c)-4),a.push("L",this._x(t.x+h),this._y(t.y+c)+4);return o.setAttribute("d",a.join(" ")),this._bindFillDraw(o,"raster",n,1)},t.prototype.diamondHandle=function(t,e,i){var s=this.makeNode("path"),r=["M",this._x(t.x)-e/2,this._y(t.y),"L",this._x(t.x),this._y(t.y)-e/2,"L",this._x(t.x)+e/2,this._y(t.y),"L",this._x(t.x),this._y(t.y)+e/2,"Z"];return s.setAttribute("d",r.join(" ")),this._bindFillDraw(s,"diamondHandle",i,1)},t.prototype.squareHandle=function(t,e,i){var s=this.makeNode("rect");return s.setAttribute("x","".concat(this._x(t.x)-e/2)),s.setAttribute("y","".concat(this._y(t.y)-e/2)),s.setAttribute("width","".concat(e)),s.setAttribute("height","".concat(e)),this._bindFillDraw(s,"squareHandle",i,1)},t.prototype.circleHandle=function(t,e,i){e=e||3;var s=this.makeNode("circle");return s.setAttribute("cx","".concat(this._x(t.x))),s.setAttribute("cy","".concat(this._y(t.y))),s.setAttribute("r","".concat(e)),this._bindFillDraw(s,"circleHandle",i,1)},t.prototype.crosshair=function(t,e,i,s){var r=this.makeNode("path"),n=["M",this._x(t.x)-e,this._y(t.y),"L",this._x(t.x)+e,this._y(t.y),"M",this._x(t.x),this._y(t.y)-e,"L",this._x(t.x),this._y(t.y)+e];return r.setAttribute("d",n.join(" ")),this._bindFillDraw(r,"crosshair",i,s||.5)},t.prototype.cross=function(t,e,i,s){var r=this.makeNode("path"),n=["M",this._x(t.x)-e,this._y(t.y)-e,"L",this._x(t.x)+e,this._y(t.y)+e,"M",this._x(t.x)-e,this._y(t.y)+e,"L",this._x(t.x)+e,this._y(t.y)-e];return r.setAttribute("d",n.join(" ")),this._bindFillDraw(r,"cross",i,s||1)},t.prototype.polygon=function(t,e,i,s){return this.polyline(t.vertices,t.isOpen,e,i,s)},t.prototype.polyline=function(t,e,i,s,r){var n=this.makeNode("path");if(this.applyStrokeOpts(n,r),0==t.length)return n;for(var o=["M",this._x(t[0].x),this._y(t[0].y)],a=t.length,h=1;h<a;h++)o.push("L",this._x(t[h].x),this._y(t[h].y));return e||o.push("Z"),n.setAttribute("d",o.join(" ")),this._bindFillDraw(n,"polygon",i,s||1)},t.prototype.text=function(t,e,i,s){var r,n,o,a=(s=s||{}).color||"black",c=(null!==(n=null!==(r=s.lineHeight)&&void 0!==r?r:s.fontSize)&&void 0!==n?n:0)*this.scale.x,l="left"===s.textAlign||"start"===s.textAlign?"start":"center"===s.textAlign?"middle":"right"===s.textAlign||"end"===s.textAlign?"end":"start",u="".concat(this._x(e),"px ").concat(this._y(i),"px"),d="translate(".concat(this._x(e)," ").concat(this._y(i)+c/2,")"),p=s.rotation?"rotate(".concat(s.rotation*h," 0 0)"):"",f=this.makeNode("g"),y=this.curId;this.curId=y+"_text";var v=this.makeNode("text");return f.appendChild(v),v.setAttribute("font-family",null!==(o=s.fontFamily)&&void 0!==o?o:""),v.setAttribute("font-size",s.fontSize?"".concat(s.fontSize*this.scale.x):""),v.setAttribute("font-style",s.fontStyle?"".concat(s.fontStyle):""),v.setAttribute("font-weight",s.fontWeight?"".concat(s.fontWeight):""),v.setAttribute("text-anchor",l),v.setAttribute("transform-origin","0 0"),v.setAttribute("transform",p),f.setAttribute("transform-origin",u),f.setAttribute("transform",d),v.innerHTML=t,this.curId=y,this._bindFillDraw(f,"text",a,1)},t.prototype.label=function(t,e,i,s,r){var n=this.makeNode("text");return n.setAttribute("transform","translate(".concat(e,",").concat(i,"), rotate(").concat((s||0)/Math.PI*180,")")),n.setAttribute("font-family","Arial"),n.setAttribute("font-size","9pt"),n.setAttribute("font-style","normal"),n.setAttribute("font-weight","lighter"),n.innerHTML=t,this._bindFillDraw(n,"label",r||"black",null)},t.prototype.path=function(e,i,s,r){var n=this.makeNode("path");this.applyStrokeOpts(n,r);var o=r&&r.inplace?e:t.copyPathData(e);return t.transformPathData(o,this.offset,this.scale),n.setAttribute("d",o.join(" ")),this._bindFillDraw(n,"path",i,s)},t.prototype.clear=function(t){if(!this.isSecondary){this.curId="background",this.curClassName=null;var e=this.makeNode("rect");e.setAttribute("x","0"),e.setAttribute("y","0"),e.setAttribute("width","".concat(this.canvasSize.width)),e.setAttribute("height","".concat(this.canvasSize.height)),this._bindFillDraw(e,this.curId,null,null),e.setAttribute("fill",void 0===t?"none":t),this.curId=null}},t.prototype.removeAllChildNodes=function(){for(;this.bufferGNode.lastChild;)this.bufferGNode.removeChild(this.bufferGNode.lastChild);for(;this.bufferedNodeDefs.lastChild;)this.bufferedNodeDefs.removeChild(this.bufferedNodeDefs.lastChild)},t.createSvg=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg")},t.copyPathData=function(t){return t.slice()},t.transformPathData=function(t,e,i){for(var s=function(s){t[s]=e.x+i.x*Number(t[s])},r=function(s){t[s]=e.y+i.y*Number(t[s])},n=function(e){t[e]=i.x*Number(t[e])},o=function(e){t[e]=i.y*Number(t[e])},a=0,h={x:NaN,y:NaN},c=function(e){h.x=Number(t[e]),h.y=Number(t[e+1])};a<t.length;)switch(t[a]){case"M":case"L":case"T":s(a+1),r(a+2),c(a+1),a+=3;break;case"m":case"l":case"t":n(a+1),o(a+2),c(a+1),a+=3;break;case"H":s(a+1),h.x=Number(t[a+1]),a+=2;break;case"h":n(a+1),h.x=Number(t[a+1]),a+=2;break;case"V":r(a+1),h.y=Number(t[a+1]),a+=2;break;case"v":o(a+1),h.y=Number(t[a+1]),a+=2;break;case"C":s(a+1),r(a+2),s(a+3),r(a+4),s(a+5),r(a+6),c(a+5),a+=7;break;case"c":n(a+1),o(a+2),n(a+3),o(a+4),n(a+5),o(a+6),c(a+5),a+=7;break;case"S":case"Q":s(a+1),r(a+2),s(a+3),r(a+4),c(a+3),a+=5;break;case"s":case"q":n(a+1),o(a+2),n(a+3),o(a+4),c(a+3),a+=5;break;case"A":n(a+1),o(a+2),s(a+6),r(a+7),c(a+6),(i.x<0&&i.y>=0||i.x>=0&&i.y<0)&&(t[a+5]=t[a+5]?0:1),a+=8;break;case"a":n(a+1),o(a+2),n(a+6),o(a+7),c(a+6),a+=8;break;default:a++}},t.nodeSupportsLineDash=function(t){return["line","path","circle","ellipse","rectangle","rect"].includes(t)},t.nodeSupportsLineJoin=function(t){return["line","path","circle","ellipse","rectangle","rect"].includes(t)},t.nodeSupportsLineCap=function(t){return["line","path","circle","ellipse","rectangle","rect"].includes(t)},t.prototype.makeLineNode=function(t,e,i,s,r,n){var o=this.makeNode("line");return o.setAttribute("x1","".concat(this._x(t.x))),o.setAttribute("y1","".concat(this._y(t.y))),o.setAttribute("x2","".concat(this._x(e.x))),o.setAttribute("y2","".concat(this._y(e.y))),this._configureNode(o,null!=n?n:"line",this.fillShapes,i,s||1,r),o},t.prototype.makePathNode=function(t,e,i,s,r){var n=this.makeNode("path");return n.setAttribute("d",t),this._configureNode(n,null!=r?r:"path",this.fillShapes,e,i||1,s),n},t.prototype.makeArrowHeadNode=function(t,e,i,s,r,n,o){void 0===r&&(r=8);var h=a.Vector.utils.buildArrowHead(t,e,r,this.scale.x,this.scale.y),c=["M",this.offset.x+h[0].x,this.offset.y+h[0].y];o&&(o.x=h[0].x/this.scale.x,o.y=h[0].y/this.scale.y);for(var l=1;l<=h.length;l++)c.push("L"),c.push(this.offset.x+h[l%h.length].x),c.push(this.offset.y+h[l%h.length].y);return this.makePathNode(c.join(" "),i,s,n,"arrowhead")},t.prototype.makeCubicBezierNode=function(t,e,i,s,n,o,a){if(t instanceof r.CubicBezierCurve)return this.cubicBezier(t.startPoint,t.endPoint,t.startControlPoint,t.endControlPoint,n,o);var h=["M",this._x(t.x),this._y(t.y),"C",this._x(i.x),this._y(i.y),this._x(s.x),this._y(s.y),this._x(e.x),this._y(e.y)];return this.makePathNode(h.join(" "),n,o,a,"cubicBezier")},t.HEAD_XML=['<?xml version="1.0" encoding="UTF-8" standalone="no"?>','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" ',' "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',""].join("\n"),t}();e.drawutilssvg=c},476:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VertexAttr=void 0;var i=function(){function t(){for(var e in this.draggable=!0,this.selectable=!0,this.isSelected=!1,this.visible=!0,t.model)this[e]=t.model[e]}return t.model={draggable:!0,selectable:!0,isSelected:!1,visible:!0},t}();e.VertexAttr=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.ele