import{T as Hn,s as Bn,b as mn,e as Ct,h as gn,c as Ot,d as It,g as W,u as wt,U as St,j as ut,k as Et,n as ke,m as Ne,o as Un,t as yt,f as xt,V as Ve,w as Pe}from"./scheduler.Cj2_EUWt.js";import{S as Gn,i as qn}from"./index.fHxmWqpJ.js";import{az as $n,aA as pe,ak as Re,al as Wn,aB as re,aC as jn,aD as Xn,aE as Ie,aF as Yn,a as Qn}from"./state.64yjoE4Y.js";let zt=!0,vn,qt,$t;const Kn=1e3,Jn=150,bn=$n(()=>{zt=!0,vn()},Kn),tr=(t,e)=>{$t==null||$t();const{autoSync:n}=Hn(pe);if(!n)return;vn=e;const r=t>Jn;zt||bn(),zt=!r},er=()=>(qt||(qt=new Promise(t=>{$t=()=>{qt=void 0,t()}})),zt||bn(),zt),zs=()=>qt??Promise.resolve();var nr=function(){var t="",e,n,r,s=[],i={passive:!0};window.addEventListener?(e="addEventListener",n="removeEventListener"):(e="attachEvent",n="detachEvent",t="on"),r="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";function a(f,d){var m=function(g){!g&&(g=window.event);var v={originalEvent:g,target:g.target||g.srcElement,type:"wheel",deltaMode:g.type=="MozMousePixelScroll"?0:1,deltaX:0,delatZ:0,preventDefault:function(){g.preventDefault?g.preventDefault():g.returnValue=!1}};return r=="mousewheel"?(v.deltaY=-.025*g.wheelDelta,g.wheelDeltaX&&(v.deltaX=-.025*g.wheelDeltaX)):v.deltaY=g.detail,d(v)};return s.push({element:f,fn:m}),m}function o(f){for(var d=0;de?(clearTimeout(o),o=null,u=h,a=t.apply(s,i),o||(s=i=null)):!o&&n.trailing!==!1&&(o=setTimeout(l,c)),a}},createRequestAnimationFrame:function(t){var e=null;return t!=="auto"&&t<60&&t>1&&(e=Math.floor(1e3/t)),e===null?window.requestAnimationFrame||ze(33):ze(e)}};function ze(t){return function(e){window.setTimeout(e,t)}}var se=Se,yn="unknown";document.documentMode&&(yn="ie");var Ae={svgNS:"http://www.w3.org/2000/svg",xmlNS:"http://www.w3.org/XML/1998/namespace",xmlnsNS:"http://www.w3.org/2000/xmlns/",xlinkNS:"http://www.w3.org/1999/xlink",evNS:"http://www.w3.org/2001/xml-events",getBoundingClientRectNormalized:function(t){if(t.clientWidth&&t.clientHeight)return{width:t.clientWidth,height:t.clientHeight};if(t.getBoundingClientRect())return t.getBoundingClientRect();throw new Error("Cannot get BoundingClientRect for SVG.")},getOrCreateViewport:function(t,e){var n=null;if(se.isElement(e)?n=e:n=t.querySelector(e),!n){var r=Array.prototype.slice.call(t.childNodes||t.children).filter(function(u){return u.nodeName!=="defs"&&u.nodeName!=="#text"});r.length===1&&r[0].nodeName==="g"&&r[0].getAttribute("transform")===null&&(n=r[0])}if(!n){var s="viewport-"+new Date().toISOString().replace(/\D/g,"");n=document.createElementNS(this.svgNS,"g"),n.setAttribute("id",s);var i=t.childNodes||t.children;if(i&&i.length>0)for(var a=i.length;a>0;a--)i[i.length-a].nodeName!=="defs"&&n.appendChild(i[i.length-a]);t.appendChild(n)}var o=[];return n.getAttribute("class")&&(o=n.getAttribute("class").split(" ")),~o.indexOf("svg-pan-zoom_viewport")||(o.push("svg-pan-zoom_viewport"),n.setAttribute("class",o.join(" "))),n},setupSvgAttributes:function(t){if(t.setAttribute("xmlns",this.svgNS),t.setAttributeNS(this.xmlnsNS,"xmlns:xlink",this.xlinkNS),t.setAttributeNS(this.xmlnsNS,"xmlns:ev",this.evNS),t.parentNode!==null){var e=t.getAttribute("style")||"";e.toLowerCase().indexOf("overflow")===-1&&t.setAttribute("style","overflow: hidden; "+e)}},internetExplorerRedisplayInterval:300,refreshDefsGlobal:se.throttle(function(){for(var t=document.querySelectorAll("defs"),e=t.length,n=0;n=0;r--)this.eventListeners.hasOwnProperty(n[r])&&delete this.eventListeners[n[r]]}for(var s in this.eventListeners)(this.options.eventsListenerElement||this.svg).addEventListener(s,this.eventListeners[s],this.options.preventMouseEventsDefault?!1:wn);this.options.mouseWheelZoomEnabled&&(this.options.mouseWheelZoomEnabled=!1,this.enableMouseWheelZoom())};P.prototype.enableMouseWheelZoom=function(){if(!this.options.mouseWheelZoomEnabled){var t=this;this.wheelListener=function(n){return t.handleMouseWheel(n)};var e=!this.options.preventMouseEventsDefault;xn.on(this.options.eventsListenerElement||this.svg,this.wheelListener,e),this.options.mouseWheelZoomEnabled=!0}};P.prototype.disableMouseWheelZoom=function(){if(this.options.mouseWheelZoomEnabled){var t=!this.options.preventMouseEventsDefault;xn.off(this.options.eventsListenerElement||this.svg,this.wheelListener,t),this.options.mouseWheelZoomEnabled=!1}};P.prototype.handleMouseWheel=function(t){if(!(!this.options.zoomEnabled||this.state!=="none")){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1);var e=t.deltaY||1,n=Date.now()-this.lastMouseWheelEventTime,r=3+Math.max(0,30-n);this.lastMouseWheelEventTime=Date.now(),"deltaMode"in t&&t.deltaMode===0&&t.wheelDelta&&(e=t.deltaY===0?0:Math.abs(t.wheelDelta)/t.deltaY),e=-.30?1:-1)*Math.log(Math.abs(e)+10)/r;var s=this.svg.getScreenCTM().inverse(),i=ot.getEventPoint(t,this.svg).matrixTransform(s),a=Math.pow(1+this.options.zoomScaleSensitivity,-1*e);this.zoomAtPoint(a,i)}};P.prototype.zoomAtPoint=function(t,e,n){var r=this.viewport.getOriginalState();n?(t=Math.max(this.options.minZoom*r.zoom,Math.min(this.options.maxZoom*r.zoom,t)),t=t/this.getZoom()):this.getZoom()*tthis.options.maxZoom*r.zoom&&(t=this.options.maxZoom*r.zoom/this.getZoom());var s=this.viewport.getCTM(),i=e.matrixTransform(s.inverse()),a=this.svg.createSVGMatrix().translate(i.x,i.y).scale(t).translate(-i.x,-i.y),o=s.multiply(a);o.a!==s.a&&this.viewport.setCTM(o)};P.prototype.zoom=function(t,e){this.zoomAtPoint(t,ot.getSvgCenterPoint(this.svg,this.width,this.height),e)};P.prototype.publicZoom=function(t,e){e&&(t=this.computeFromRelativeZoom(t)),this.zoom(t,e)};P.prototype.publicZoomAtPoint=function(t,e,n){if(n&&(t=this.computeFromRelativeZoom(t)),nt.getType(e)!=="SVGPoint")if("x"in e&&"y"in e)e=ot.createSVGPoint(this.svg,e.x,e.y);else throw new Error("Given point is invalid");this.zoomAtPoint(t,e,n)};P.prototype.getZoom=function(){return this.viewport.getZoom()};P.prototype.getRelativeZoom=function(){return this.viewport.getRelativeZoom()};P.prototype.computeFromRelativeZoom=function(t){return t*this.viewport.getOriginalState().zoom};P.prototype.resetZoom=function(){var t=this.viewport.getOriginalState();this.zoom(t.zoom,!0)};P.prototype.resetPan=function(){this.pan(this.viewport.getOriginalState())};P.prototype.reset=function(){this.resetZoom(),this.resetPan()};P.prototype.handleDblClick=function(t){if(this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.options.controlIconsEnabled){var e=t.target.getAttribute("class")||"";if(e.indexOf("svg-pan-zoom-control")>-1)return!1}var n;t.shiftKey?n=1/((1+this.options.zoomScaleSensitivity)*2):n=(1+this.options.zoomScaleSensitivity)*2;var r=ot.getEventPoint(t,this.svg).matrixTransform(this.svg.getScreenCTM().inverse());this.zoomAtPoint(n,r)};P.prototype.handleMouseDown=function(t,e){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),nt.mouseAndTouchNormalize(t,this.svg),this.options.dblClickZoomEnabled&&nt.isDblClick(t,e)?this.handleDblClick(t):(this.state="pan",this.firstEventCTM=this.viewport.getCTM(),this.stateOrigin=ot.getEventPoint(t,this.svg).matrixTransform(this.firstEventCTM.inverse()))};P.prototype.handleMouseMove=function(t){if(this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.state==="pan"&&this.options.panEnabled){var e=ot.getEventPoint(t,this.svg).matrixTransform(this.firstEventCTM.inverse()),n=this.firstEventCTM.translate(e.x-this.stateOrigin.x,e.y-this.stateOrigin.y);this.viewport.setCTM(n)}};P.prototype.handleMouseUp=function(t){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.state==="pan"&&(this.state="none")};P.prototype.fit=function(){var t=this.viewport.getViewBox(),e=Math.min(this.width/t.width,this.height/t.height);this.zoom(e,!0)};P.prototype.contain=function(){var t=this.viewport.getViewBox(),e=Math.max(this.width/t.width,this.height/t.height);this.zoom(e,!0)};P.prototype.center=function(){var t=this.viewport.getViewBox(),e=(this.width-(t.width+t.x*2)*this.getZoom())*.5,n=(this.height-(t.height+t.y*2)*this.getZoom())*.5;this.getPublicInstance().pan({x:e,y:n})};P.prototype.updateBBox=function(){this.viewport.simpleViewBoxCache()};P.prototype.pan=function(t){var e=this.viewport.getCTM();e.e=t.x,e.f=t.y,this.viewport.setCTM(e)};P.prototype.panBy=function(t){var e=this.viewport.getCTM();e.e+=t.x,e.f+=t.y,this.viewport.setCTM(e)};P.prototype.getPan=function(){var t=this.viewport.getState();return{x:t.x,y:t.y}};P.prototype.resize=function(){var t=ot.getBoundingClientRectNormalized(this.svg);this.width=t.width,this.height=t.height;var e=this.viewport;e.options.width=this.width,e.options.height=this.height,e.processCTM(),this.options.controlIconsEnabled&&(this.getPublicInstance().disableControlIcons(),this.getPublicInstance().enableControlIcons())};P.prototype.destroy=function(){var t=this;this.beforeZoom=null,this.onZoom=null,this.beforePan=null,this.onPan=null,this.onUpdatedCTM=null,this.options.customEventsHandler!=null&&this.options.customEventsHandler.destroy({svgElement:this.svg,eventsListenerElement:this.options.eventsListenerElement,instance:this.getPublicInstance()});for(var e in this.eventListeners)(this.options.eventsListenerElement||this.svg).removeEventListener(e,this.eventListeners[e],this.options.preventMouseEventsDefault?!1:wn);this.disableMouseWheelZoom(),this.getPublicInstance().disableControlIcons(),this.reset(),ht=ht.filter(function(n){return n.svg!==t.svg}),delete this.options,delete this.viewport,delete this.publicInstance,delete this.pi,this.getPublicInstance=function(){return null}};P.prototype.getPublicInstance=function(){var t=this;return this.publicInstance||(this.publicInstance=this.pi={enablePan:function(){return t.options.panEnabled=!0,t.pi},disablePan:function(){return t.options.panEnabled=!1,t.pi},isPanEnabled:function(){return!!t.options.panEnabled},pan:function(e){return t.pan(e),t.pi},panBy:function(e){return t.panBy(e),t.pi},getPan:function(){return t.getPan()},setBeforePan:function(e){return t.options.beforePan=e===null?null:nt.proxy(e,t.publicInstance),t.pi},setOnPan:function(e){return t.options.onPan=e===null?null:nt.proxy(e,t.publicInstance),t.pi},enableZoom:function(){return t.options.zoomEnabled=!0,t.pi},disableZoom:function(){return t.options.zoomEnabled=!1,t.pi},isZoomEnabled:function(){return!!t.options.zoomEnabled},enableControlIcons:function(){return t.options.controlIconsEnabled||(t.options.controlIconsEnabled=!0,de.enable(t)),t.pi},disableControlIcons:function(){return t.options.controlIconsEnabled&&(t.options.controlIconsEnabled=!1,de.disable(t)),t.pi},isControlIconsEnabled:function(){return!!t.options.controlIconsEnabled},enableDblClickZoom:function(){return t.options.dblClickZoomEnabled=!0,t.pi},disableDblClickZoom:function(){return t.options.dblClickZoomEnabled=!1,t.pi},isDblClickZoomEnabled:function(){return!!t.options.dblClickZoomEnabled},enableMouseWheelZoom:function(){return t.enableMouseWheelZoom(),t.pi},disableMouseWheelZoom:function(){return t.disableMouseWheelZoom(),t.pi},isMouseWheelZoomEnabled:function(){return!!t.options.mouseWheelZoomEnabled},setZoomScaleSensitivity:function(e){return t.options.zoomScaleSensitivity=e,t.pi},setMinZoom:function(e){return t.options.minZoom=e,t.pi},setMaxZoom:function(e){return t.options.maxZoom=e,t.pi},setBeforeZoom:function(e){return t.options.beforeZoom=e===null?null:nt.proxy(e,t.publicInstance),t.pi},setOnZoom:function(e){return t.options.onZoom=e===null?null:nt.proxy(e,t.publicInstance),t.pi},zoom:function(e){return t.publicZoom(e,!0),t.pi},zoomBy:function(e){return t.publicZoom(e,!1),t.pi},zoomAtPoint:function(e,n){return t.publicZoomAtPoint(e,n,!0),t.pi},zoomAtPointBy:function(e,n){return t.publicZoomAtPoint(e,n,!1),t.pi},zoomIn:function(){return this.zoomBy(1+t.options.zoomScaleSensitivity),t.pi},zoomOut:function(){return this.zoomBy(1/(1+t.options.zoomScaleSensitivity)),t.pi},getZoom:function(){return t.getRelativeZoom()},setOnUpdatedCTM:function(e){return t.options.onUpdatedCTM=e===null?null:nt.proxy(e,t.publicInstance),t.pi},resetZoom:function(){return t.resetZoom(),t.pi},resetPan:function(){return t.resetPan(),t.pi},reset:function(){return t.reset(),t.pi},fit:function(){return t.fit(),t.pi},contain:function(){return t.contain(),t.pi},center:function(){return t.center(),t.pi},updateBBox:function(){return t.updateBBox(),t.pi},resize:function(){return t.resize(),t.pi},getSizes:function(){return{width:t.width,height:t.height,realZoom:t.getZoom(),viewBox:t.viewport.getViewBox()}},destroy:function(){return t.destroy(),t.pi}}),this.publicInstance};var ht=[],lr=function(t,e){var n=nt.getSvg(t);if(n===null)return null;for(var r=ht.length-1;r>=0;r--)if(ht[r].svg===n)return ht[r].instance.getPublicInstance();return ht.push({svg:n,instance:new P(n,e)}),ht[ht.length-1].instance.getPublicInstance()},ur=lr;const hr=Wn(ur);function me(t,e,n){if(t&&t.length){const[r,s]=e,i=Math.PI/180*n,a=Math.cos(i),o=Math.sin(i);for(const u of t){const[l,h]=u;u[0]=(l-r)*a-(h-s)*o+r,u[1]=(l-r)*o+(h-s)*a+s}}}function cr(t,e,n){const r=[];t.forEach(s=>r.push(...s)),me(r,e,n)}function fr(t,e){return t[0]===e[0]&&t[1]===e[1]}function pr(t,e,n,r=1){const s=n,i=Math.max(e,.1),a=t[0]&&t[0][0]&&typeof t[0][0]=="number"?[t]:t,o=[0,0];if(s)for(const l of a)me(l,o,s);const u=dr(a,i,r);if(s){for(const l of a)me(l,o,-s);cr(u,o,-s)}return u}function dr(t,e,n){const r=[];for(const l of t){const h=[...l];fr(h[0],h[h.length-1])||h.push([h[0][0],h[0][1]]),h.length>2&&r.push(h)}const s=[];e=Math.max(e,.1);const i=[];for(const l of r)for(let h=0;hl.yminh.ymin?1:l.xh.x?1:l.ymax===h.ymax?0:(l.ymax-h.ymax)/Math.abs(l.ymax-h.ymax)),!i.length)return s;let a=[],o=i[0].ymin,u=0;for(;a.length||i.length;){if(i.length){let l=-1;for(let c=0;co);c++)l=c;i.splice(0,l+1).forEach(c=>{a.push({s:o,edge:c})})}if(a=a.filter(l=>!(l.edge.ymax<=o)),a.sort((l,h)=>l.edge.x===h.edge.x?0:(l.edge.x-h.edge.x)/Math.abs(l.edge.x-h.edge.x)),(n!==1||u%e===0)&&a.length>1)for(let l=0;l=a.length)break;const c=a[l].edge,p=a[h].edge;s.push([[Math.round(c.x),o],[Math.round(p.x),o]])}o+=n,a.forEach(l=>{l.edge.x=l.edge.x+n*l.edge.islope}),u++}return s}function Zt(t,e){var n;const r=e.hachureAngle+90;let s=e.hachureGap;s<0&&(s=e.strokeWidth*4),s=Math.round(Math.max(s,.1));let i=1;return e.roughness>=1&&(((n=e.randomizer)===null||n===void 0?void 0:n.next())||Math.random())>.7&&(i=s),pr(t,s,r,i||1)}class Ee{constructor(e){this.helper=e}fillPolygons(e,n){return this._fillPolygons(e,n)}_fillPolygons(e,n){const r=Zt(e,n);return{type:"fillSketch",ops:this.renderLines(r,n)}}renderLines(e,n){const r=[];for(const s of e)r.push(...this.helper.doubleLineOps(s[0][0],s[0][1],s[1][0],s[1][1],n));return r}}function ee(t){const e=t[0],n=t[1];return Math.sqrt(Math.pow(e[0]-n[0],2)+Math.pow(e[1]-n[1],2))}class mr extends Ee{fillPolygons(e,n){let r=n.hachureGap;r<0&&(r=n.strokeWidth*4),r=Math.max(r,.1);const s=Object.assign({},n,{hachureGap:r}),i=Zt(e,s),a=Math.PI/180*n.hachureAngle,o=[],u=r*.5*Math.cos(a),l=r*.5*Math.sin(a);for(const[c,p]of i)ee([c,p])&&o.push([[c[0]-u,c[1]+l],[...p]],[[c[0]+u,c[1]-l],[...p]]);return{type:"fillSketch",ops:this.renderLines(o,n)}}}class gr extends Ee{fillPolygons(e,n){const r=this._fillPolygons(e,n),s=Object.assign({},n,{hachureAngle:n.hachureAngle+90}),i=this._fillPolygons(e,s);return r.ops=r.ops.concat(i.ops),r}}class vr{constructor(e){this.helper=e}fillPolygons(e,n){n=Object.assign({},n,{hachureAngle:0});const r=Zt(e,n);return this.dotsOnLines(r,n)}dotsOnLines(e,n){const r=[];let s=n.hachureGap;s<0&&(s=n.strokeWidth*4),s=Math.max(s,.1);let i=n.fillWeight;i<0&&(i=n.strokeWidth/2);const a=s/4;for(const o of e){const u=ee(o),l=u/s,h=Math.ceil(l)-1,c=u-h*s,p=(o[0][0]+o[1][0])/2-s/4,f=Math.min(o[0][1],o[1][1]);for(let d=0;d{const o=ee(a),u=Math.floor(o/(r+s)),l=(o+s-u*(r+s))/2;let h=a[0],c=a[1];h[0]>c[0]&&(h=a[1],c=a[0]);const p=Math.atan((c[1]-h[1])/(c[0]-h[0]));for(let f=0;f{const a=ee(i),o=Math.round(a/(2*n));let u=i[0],l=i[1];u[0]>l[0]&&(u=i[1],l=i[0]);const h=Math.atan((l[1]-u[1])/(l[0]-u[0]));for(let c=0;ch%2?l+n:l+e);i.push({key:"C",data:u}),e=u[4],n=u[5];break}case"Q":i.push({key:"Q",data:[...o]}),e=o[2],n=o[3];break;case"q":{const u=o.map((l,h)=>h%2?l+n:l+e);i.push({key:"Q",data:u}),e=u[2],n=u[3];break}case"A":i.push({key:"A",data:[...o]}),e=o[5],n=o[6];break;case"a":e+=o[5],n+=o[6],i.push({key:"A",data:[o[0],o[1],o[2],o[3],o[4],e,n]});break;case"H":i.push({key:"H",data:[...o]}),e=o[0];break;case"h":e+=o[0],i.push({key:"H",data:[e]});break;case"V":i.push({key:"V",data:[...o]}),n=o[0];break;case"v":n+=o[0],i.push({key:"V",data:[n]});break;case"S":i.push({key:"S",data:[...o]}),e=o[2],n=o[3];break;case"s":{const u=o.map((l,h)=>h%2?l+n:l+e);i.push({key:"S",data:u}),e=u[2],n=u[3];break}case"T":i.push({key:"T",data:[...o]}),e=o[0],n=o[1];break;case"t":e+=o[0],n+=o[1],i.push({key:"T",data:[e,n]});break;case"Z":case"z":i.push({key:"Z",data:[]}),e=r,n=s;break}return i}function En(t){const e=[];let n="",r=0,s=0,i=0,a=0,o=0,u=0;for(const{key:l,data:h}of t){switch(l){case"M":e.push({key:"M",data:[...h]}),[r,s]=h,[i,a]=h;break;case"C":e.push({key:"C",data:[...h]}),r=h[4],s=h[5],o=h[2],u=h[3];break;case"L":e.push({key:"L",data:[...h]}),[r,s]=h;break;case"H":r=h[0],e.push({key:"L",data:[r,s]});break;case"V":s=h[0],e.push({key:"L",data:[r,s]});break;case"S":{let c=0,p=0;n==="C"||n==="S"?(c=r+(r-o),p=s+(s-u)):(c=r,p=s),e.push({key:"C",data:[c,p,...h]}),o=h[0],u=h[1],r=h[2],s=h[3];break}case"T":{const[c,p]=h;let f=0,d=0;n==="Q"||n==="T"?(f=r+(r-o),d=s+(s-u)):(f=r,d=s);const m=r+2*(f-r)/3,g=s+2*(d-s)/3,v=c+2*(f-c)/3,y=p+2*(d-p)/3;e.push({key:"C",data:[m,g,v,y,c,p]}),o=f,u=d,r=c,s=p;break}case"Q":{const[c,p,f,d]=h,m=r+2*(c-r)/3,g=s+2*(p-s)/3,v=f+2*(c-f)/3,y=d+2*(p-d)/3;e.push({key:"C",data:[m,g,v,y,f,d]}),o=c,u=p,r=f,s=d;break}case"A":{const c=Math.abs(h[0]),p=Math.abs(h[1]),f=h[2],d=h[3],m=h[4],g=h[5],v=h[6];c===0||p===0?(e.push({key:"C",data:[r,s,g,v,g,v]}),r=g,s=v):(r!==g||s!==v)&&(_n(r,s,g,v,c,p,f,d,m).forEach(function(C){e.push({key:"C",data:C})}),r=g,s=v);break}case"Z":e.push({key:"Z",data:[]}),r=i,s=a;break}n=l}return e}function Ar(t){return Math.PI*t/180}function kt(t,e,n){const r=t*Math.cos(n)-e*Math.sin(n),s=t*Math.sin(n)+e*Math.cos(n);return[r,s]}function _n(t,e,n,r,s,i,a,o,u,l){const h=Ar(a);let c=[],p=0,f=0,d=0,m=0;if(l)[p,f,d,m]=l;else{[t,e]=kt(t,e,-h),[n,r]=kt(n,r,-h);const k=(t-n)/2,N=(e-r)/2;let R=k*k/(s*s)+N*N/(i*i);R>1&&(R=Math.sqrt(R),s=R*s,i=R*i);const B=o===u?-1:1,D=s*s,q=i*i,K=D*q-D*N*N-q*k*k,Z=D*N*N+q*k*k,L=B*Math.sqrt(Math.abs(K/Z));d=L*s*N/i+(t+n)/2,m=L*-i*k/s+(e+r)/2,p=Math.asin(parseFloat(((e-m)/i).toFixed(9))),f=Math.asin(parseFloat(((r-m)/i).toFixed(9))),tf&&(p=p-Math.PI*2),!u&&f>p&&(f=f-Math.PI*2)}let g=f-p;if(Math.abs(g)>Math.PI*120/180){const k=f,N=n,R=r;u&&f>p?f=p+Math.PI*120/180*1:f=p+Math.PI*120/180*-1,n=d+s*Math.cos(f),r=m+i*Math.sin(f),c=_n(n,r,N,R,s,i,a,0,u,[f,k,d,m])}g=f-p;const v=Math.cos(p),y=Math.sin(p),C=Math.cos(f),M=Math.sin(f),x=Math.tan(g/4),_=4/3*s*x,S=4/3*i*x,T=[t,e],V=[t+_*y,e-S*v],G=[n+_*M,r-S*C],H=[n,r];if(V[0]=2*T[0]-V[0],V[1]=2*T[1]-V[1],l)return[V,G,H].concat(c);{c=[V,G,H].concat(c);const k=[];for(let N=0;N2){const s=[];for(let i=0;iMath.PI*2&&(f=0,d=Math.PI*2);const m=Math.PI*2/u.curveStepCount,g=Math.min(m/2,(d-f)/2),v=Be(g,l,h,c,p,f,d,1,u);if(!u.disableMultiStroke){const y=Be(g,l,h,c,p,f,d,1.5,u);v.push(...y)}return a&&(o?v.push(...gt(l,h,l+c*Math.cos(f),h+p*Math.sin(f),u),...gt(l,h,l+c*Math.cos(d),h+p*Math.sin(d),u)):v.push({op:"lineTo",data:[l,h]},{op:"lineTo",data:[l+c*Math.cos(f),h+p*Math.sin(f)]})),{type:"path",ops:v}}function Ze(t,e){const n=En(An(_e(t))),r=[];let s=[0,0],i=[0,0];for(const{key:a,data:o}of n)switch(a){case"M":{i=[o[0],o[1]],s=[o[0],o[1]];break}case"L":r.push(...gt(i[0],i[1],o[0],o[1],e)),i=[o[0],o[1]];break;case"C":{const[u,l,h,c,p,f]=o;r.push(...Pr(u,l,h,c,p,f,i,e)),i=[p,f];break}case"Z":r.push(...gt(i[0],i[1],s[0],s[1],e)),i=[s[0],s[1]];break}return{type:"path",ops:r}}function oe(t,e){const n=[];for(const r of t)if(r.length){const s=e.maxRandomnessOffset||0,i=r.length;if(i>2){n.push({op:"move",data:[r[0][0]+A(s,e),r[0][1]+A(s,e)]});for(let a=1;aMath.PI*2&&(c=0,p=Math.PI*2);const f=(p-c)/a.curveStepCount,d=[];for(let m=c;m<=p;m=m+f)d.push([o+l*Math.cos(m),u+h*Math.sin(m)]);return d.push([o+l*Math.cos(p),u+h*Math.sin(p)]),d.push([o,u]),At([d],a)}function kr(t,e){return A(t,e)}function Nr(t,e,n){return Xt(t,e,n)}function Vr(t,e,n,r,s){return gt(t,e,n,r,s,!0)}function Fe(t){const e=Object.assign({},t);return e.randomizer=void 0,t.seed&&(e.seed=t.seed+1),e}function Tn(t){return t.randomizer||(t.randomizer=new Mn(t.seed||0)),t.randomizer.next()}function Xt(t,e,n,r=1){return n.roughness*r*(Tn(n)*(e-t)+t)}function A(t,e,n=1){return Xt(-t,t,e,n)}function gt(t,e,n,r,s,i=!1){const a=i?s.disableMultiStrokeFill:s.disableMultiStroke,o=be(t,e,n,r,s,!0,!1);if(a)return o;const u=be(t,e,n,r,s,!0,!0);return o.concat(u)}function be(t,e,n,r,s,i,a){const o=Math.pow(t-n,2)+Math.pow(e-r,2),u=Math.sqrt(o);let l=1;u<200?l=1:u>500?l=.4:l=-.0016668*u+1.233334;let h=s.maxRandomnessOffset||0;h*h*100>o&&(h=u/10);const c=h/2,p=.2+Tn(s)*.2;let f=s.bowing*s.maxRandomnessOffset*(r-e)/200,d=s.bowing*s.maxRandomnessOffset*(t-n)/200;f=A(f,s,l),d=A(d,s,l);const m=[],g=()=>A(c,s,l),v=()=>A(h,s,l),y=s.preserveVertices;return a?m.push({op:"move",data:[t+(y?0:g()),e+(y?0:g())]}):m.push({op:"move",data:[t+(y?0:A(h,s,l)),e+(y?0:A(h,s,l))]}),a?m.push({op:"bcurveTo",data:[f+t+(n-t)*p+g(),d+e+(r-e)*p+g(),f+t+2*(n-t)*p+g(),d+e+2*(r-e)*p+g(),n+(y?0:g()),r+(y?0:g())]}):m.push({op:"bcurveTo",data:[f+t+(n-t)*p+v(),d+e+(r-e)*p+v(),f+t+2*(n-t)*p+v(),d+e+2*(r-e)*p+v(),n+(y?0:v()),r+(y?0:v())]}),m}function Ht(t,e,n){if(!t.length)return[];const r=[];r.push([t[0][0]+A(e,n),t[0][1]+A(e,n)]),r.push([t[0][0]+A(e,n),t[0][1]+A(e,n)]);for(let s=1;s3){const i=[],a=1-n.curveTightness;s.push({op:"move",data:[t[1][0],t[1][1]]});for(let o=1;o+21&&s.push(i):s.push(i),s.push(t[e+3])}else{const a=t[e+0],o=t[e+1],u=t[e+2],l=t[e+3],h=vt(a,o,.5),c=vt(o,u,.5),p=vt(u,l,.5),f=vt(h,c,.5),d=vt(c,p,.5),m=vt(f,d,.5);ye([a,h,f,m],0,n,s),ye([m,d,p,l],0,n,s)}return s}function Lr(t,e){return Qt(t,0,t.length,e)}function Qt(t,e,n,r,s){const i=s||[],a=t[e],o=t[n-1];let u=0,l=1;for(let h=e+1;hu&&(u=c,l=h)}return Math.sqrt(u)>r?(Qt(t,e,l+1,r,i),Qt(t,l,n,r,i)):(i.length||i.push(a),i.push(o)),i}function xe(t,e=.15,n){const r=[],s=(t.length-1)/3;for(let i=0;i0?Qt(r,0,r.length,n):r}function Dr(t,e,n){const r=_e(t),s=En(An(r)),i=[];let a=[],o=[0,0],u=[];const l=()=>{u.length>=4&&a.push(...xe(u,e)),u=[]},h=()=>{l(),a.length&&(i.push(a),a=[])};for(const{key:p,data:f}of s)switch(p){case"M":h(),o=[f[0],f[1]],a.push(o);break;case"L":l(),a.push([f[0],f[1]]);break;case"C":if(!u.length){const d=a.length?a[a.length-1]:o;u.push([d[0],d[1]])}u.push([f[0],f[1]]),u.push([f[2],f[3]]),u.push([f[4],f[5]]);break;case"Z":l(),a.push([o[0],o[1]]);break}if(h(),!n)return i;const c=[];for(const p of i){const f=Lr(p,n);f.length&&c.push(f)}return c}const X="none";class Kt{constructor(e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=e||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return wr()}_o(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_d(e,n,r){return{shape:e,sets:n||[],options:r||this.defaultOptions}}line(e,n,r,s,i){const a=this._o(i);return this._d("line",[Cn(e,n,r,s,a)],a)}rectangle(e,n,r,s,i){const a=this._o(i),o=[],u=Cr(e,n,r,s,a);if(a.fill){const l=[[e,n],[e+r,n],[e+r,n+s],[e,n+s]];a.fillStyle==="solid"?o.push(oe([l],a)):o.push(At([l],a))}return a.stroke!==X&&o.push(u),this._d("rectangle",o,a)}ellipse(e,n,r,s,i){const a=this._o(i),o=[],u=On(r,s,a),l=ve(e,n,a,u);if(a.fill)if(a.fillStyle==="solid"){const h=ve(e,n,a,u).opset;h.type="fillPath",o.push(h)}else o.push(At([l.estimatedPoints],a));return a.stroke!==X&&o.push(l.opset),this._d("ellipse",o,a)}circle(e,n,r,s){const i=this.ellipse(e,n,r,r,s);return i.shape="circle",i}linearPath(e,n){const r=this._o(n);return this._d("linearPath",[Wt(e,!1,r)],r)}arc(e,n,r,s,i,a,o=!1,u){const l=this._o(u),h=[],c=De(e,n,r,s,i,a,o,!0,l);if(o&&l.fill)if(l.fillStyle==="solid"){const p=Object.assign({},l);p.disableMultiStroke=!0;const f=De(e,n,r,s,i,a,!0,!1,p);f.type="fillPath",h.push(f)}else h.push(Tr(e,n,r,s,i,a,l));return l.stroke!==X&&h.push(c),this._d("arc",h,l)}curve(e,n){const r=this._o(n),s=[],i=Le(e,r);if(r.fill&&r.fill!==X)if(r.fillStyle==="solid"){const a=Le(e,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));s.push({type:"fillPath",ops:this._mergedShape(a.ops)})}else{const a=[],o=e;if(o.length){const l=typeof o[0][0]=="number"?[o]:o;for(const h of l)h.length<3?a.push(...h):h.length===3?a.push(...xe(Ue([h[0],h[0],h[1],h[2]]),10,(1+r.roughness)/2)):a.push(...xe(Ue(h),10,(1+r.roughness)/2))}a.length&&s.push(At([a],r))}return r.stroke!==X&&s.push(i),this._d("curve",s,r)}polygon(e,n){const r=this._o(n),s=[],i=Wt(e,!0,r);return r.fill&&(r.fillStyle==="solid"?s.push(oe([e],r)):s.push(At([e],r))),r.stroke!==X&&s.push(i),this._d("polygon",s,r)}path(e,n){const r=this._o(n),s=[];if(!e)return this._d("path",s,r);e=(e||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");const i=r.fill&&r.fill!=="transparent"&&r.fill!==X,a=r.stroke!==X,o=!!(r.simplification&&r.simplification<1),u=o?4-4*(r.simplification||1):(1+r.roughness)/2,l=Dr(e,1,u),h=Ze(e,r);if(i)if(r.fillStyle==="solid")if(l.length===1){const c=Ze(e,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));s.push({type:"fillPath",ops:this._mergedShape(c.ops)})}else s.push(oe(l,r));else s.push(At(l,r));return a&&(o?l.forEach(c=>{s.push(Wt(c,!1,r))}):s.push(h)),this._d("path",s,r)}opsToPath(e,n){let r="";for(const s of e.ops){const i=typeof n=="number"&&n>=0?s.data.map(a=>+a.toFixed(n)):s.data;switch(s.op){case"move":r+=`M${i[0]} ${i[1]} `;break;case"bcurveTo":r+=`C${i[0]} ${i[1]}, ${i[2]} ${i[3]}, ${i[4]} ${i[5]} `;break;case"lineTo":r+=`L${i[0]} ${i[1]} `;break}}return r.trim()}toPaths(e){const n=e.sets||[],r=e.options||this.defaultOptions,s=[];for(const i of n){let a=null;switch(i.type){case"path":a={d:this.opsToPath(i),stroke:r.stroke,strokeWidth:r.strokeWidth,fill:X};break;case"fillPath":a={d:this.opsToPath(i),stroke:X,strokeWidth:0,fill:r.fill||X};break;case"fillSketch":a=this.fillSketch(i,r);break}a&&s.push(a)}return s}fillSketch(e,n){let r=n.fillWeight;return r<0&&(r=n.strokeWidth/2),{d:this.opsToPath(e),stroke:n.fill||X,strokeWidth:r,fill:X}}_mergedShape(e){return e.filter((n,r)=>r===0?!0:n.op!=="move")}}class Zr{constructor(e,n){this.canvas=e,this.ctx=this.canvas.getContext("2d"),this.gen=new Kt(n)}draw(e){const n=e.sets||[],r=e.options||this.getDefaultOptions(),s=this.ctx,i=e.options.fixedDecimalPlaceDigits;for(const a of n)switch(a.type){case"path":s.save(),s.strokeStyle=r.stroke==="none"?"transparent":r.stroke,s.lineWidth=r.strokeWidth,r.strokeLineDash&&s.setLineDash(r.strokeLineDash),r.strokeLineDashOffset&&(s.lineDashOffset=r.strokeLineDashOffset),this._drawToContext(s,a,i),s.restore();break;case"fillPath":{s.save(),s.fillStyle=r.fill||"";const o=e.shape==="curve"||e.shape==="polygon"||e.shape==="path"?"evenodd":"nonzero";this._drawToContext(s,a,i,o),s.restore();break}case"fillSketch":this.fillSketch(s,a,r);break}}fillSketch(e,n,r){let s=r.fillWeight;s<0&&(s=r.strokeWidth/2),e.save(),r.fillLineDash&&e.setLineDash(r.fillLineDash),r.fillLineDashOffset&&(e.lineDashOffset=r.fillLineDashOffset),e.strokeStyle=r.fill||"",e.lineWidth=s,this._drawToContext(e,n,r.fixedDecimalPlaceDigits),e.restore()}_drawToContext(e,n,r,s="nonzero"){e.beginPath();for(const i of n.ops){const a=typeof r=="number"&&r>=0?i.data.map(o=>+o.toFixed(r)):i.data;switch(i.op){case"move":e.moveTo(a[0],a[1]);break;case"bcurveTo":e.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case"lineTo":e.lineTo(a[0],a[1]);break}}n.type==="fillPath"?e.fill(s):e.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(e,n,r,s,i){const a=this.gen.line(e,n,r,s,i);return this.draw(a),a}rectangle(e,n,r,s,i){const a=this.gen.rectangle(e,n,r,s,i);return this.draw(a),a}ellipse(e,n,r,s,i){const a=this.gen.ellipse(e,n,r,s,i);return this.draw(a),a}circle(e,n,r,s){const i=this.gen.circle(e,n,r,s);return this.draw(i),i}linearPath(e,n){const r=this.gen.linearPath(e,n);return this.draw(r),r}polygon(e,n){const r=this.gen.polygon(e,n);return this.draw(r),r}arc(e,n,r,s,i,a,o=!1,u){const l=this.gen.arc(e,n,r,s,i,a,o,u);return this.draw(l),l}curve(e,n){const r=this.gen.curve(e,n);return this.draw(r),r}path(e,n){const r=this.gen.path(e,n);return this.draw(r),r}}const Bt="http://www.w3.org/2000/svg";class Fr{constructor(e,n){this.svg=e,this.gen=new Kt(n)}draw(e){const n=e.sets||[],r=e.options||this.getDefaultOptions(),s=this.svg.ownerDocument||window.document,i=s.createElementNS(Bt,"g"),a=e.options.fixedDecimalPlaceDigits;for(const o of n){let u=null;switch(o.type){case"path":{u=s.createElementNS(Bt,"path"),u.setAttribute("d",this.opsToPath(o,a)),u.setAttribute("stroke",r.stroke),u.setAttribute("stroke-width",r.strokeWidth+""),u.setAttribute("fill","none"),r.strokeLineDash&&u.setAttribute("stroke-dasharray",r.strokeLineDash.join(" ").trim()),r.strokeLineDashOffset&&u.setAttribute("stroke-dashoffset",`${r.strokeLineDashOffset}`);break}case"fillPath":{u=s.createElementNS(Bt,"path"),u.setAttribute("d",this.opsToPath(o,a)),u.setAttribute("stroke","none"),u.setAttribute("stroke-width","0"),u.setAttribute("fill",r.fill||""),(e.shape==="curve"||e.shape==="polygon")&&u.setAttribute("fill-rule","evenodd");break}case"fillSketch":{u=this.fillSketch(s,o,r);break}}u&&i.appendChild(u)}return i}fillSketch(e,n,r){let s=r.fillWeight;s<0&&(s=r.strokeWidth/2);const i=e.createElementNS(Bt,"path");return i.setAttribute("d",this.opsToPath(n,r.fixedDecimalPlaceDigits)),i.setAttribute("stroke",r.fill||""),i.setAttribute("stroke-width",s+""),i.setAttribute("fill","none"),r.fillLineDash&&i.setAttribute("stroke-dasharray",r.fillLineDash.join(" ").trim()),r.fillLineDashOffset&&i.setAttribute("stroke-dashoffset",`${r.fillLineDashOffset}`),i}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(e,n){return this.gen.opsToPath(e,n)}line(e,n,r,s,i){const a=this.gen.line(e,n,r,s,i);return this.draw(a)}rectangle(e,n,r,s,i){const a=this.gen.rectangle(e,n,r,s,i);return this.draw(a)}ellipse(e,n,r,s,i){const a=this.gen.ellipse(e,n,r,s,i);return this.draw(a)}circle(e,n,r,s){const i=this.gen.circle(e,n,r,s);return this.draw(i)}linearPath(e,n){const r=this.gen.linearPath(e,n);return this.draw(r)}polygon(e,n){const r=this.gen.polygon(e,n);return this.draw(r)}arc(e,n,r,s,i,a,o=!1,u){const l=this.gen.arc(e,n,r,s,i,a,o,u);return this.draw(l)}curve(e,n){const r=this.gen.curve(e,n);return this.draw(r)}path(e,n){const r=this.gen.path(e,n);return this.draw(r)}}const Hr={canvas(t,e){return new Zr(t,e)},svg(t,e){return new Fr(t,e)},generator(t){return new Kt(t)},newSeed(){return Kt.newSeed()}};function Jt(t){"@babel/helpers - typeof";return Jt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Jt(t)}var Br=/^\s+/,Ur=/\s+$/;function w(t,e){if(t=t||"",e=e||{},t instanceof w)return t;if(!(this instanceof w))return new w(t,e);var n=Gr(t);this._originalInput=t,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||n.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}w.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),n,r,s,i,a,o;return n=e.r/255,r=e.g/255,s=e.b/255,n<=.03928?i=n/12.92:i=Math.pow((n+.055)/1.055,2.4),r<=.03928?a=r/12.92:a=Math.pow((r+.055)/1.055,2.4),s<=.03928?o=s/12.92:o=Math.pow((s+.055)/1.055,2.4),.2126*i+.7152*a+.0722*o},setAlpha:function(e){return this._a=kn(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=qe(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=qe(this._r,this._g,this._b),n=Math.round(e.h*360),r=Math.round(e.s*100),s=Math.round(e.v*100);return this._a==1?"hsv("+n+", "+r+"%, "+s+"%)":"hsva("+n+", "+r+"%, "+s+"%, "+this._roundA+")"},toHsl:function(){var e=Ge(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=Ge(this._r,this._g,this._b),n=Math.round(e.h*360),r=Math.round(e.s*100),s=Math.round(e.l*100);return this._a==1?"hsl("+n+", "+r+"%, "+s+"%)":"hsla("+n+", "+r+"%, "+s+"%, "+this._roundA+")"},toHex:function(e){return $e(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return jr(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(I(this._r,255)*100)+"%",g:Math.round(I(this._g,255)*100)+"%",b:Math.round(I(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(I(this._r,255)*100)+"%, "+Math.round(I(this._g,255)*100)+"%, "+Math.round(I(this._b,255)*100)+"%)":"rgba("+Math.round(I(this._r,255)*100)+"%, "+Math.round(I(this._g,255)*100)+"%, "+Math.round(I(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:os[$e(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var n="#"+We(this._r,this._g,this._b,this._a),r=n,s=this._gradientType?"GradientType = 1, ":"";if(e){var i=w(e);r="#"+We(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+s+"startColorstr="+n+",endColorstr="+r+")"},toString:function(e){var n=!!e;e=e||this._format;var r=!1,s=this._a<1&&this._a>=0,i=!n&&s&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return i?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(r=this.toRgbString()),e==="prgb"&&(r=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(r=this.toHexString()),e==="hex3"&&(r=this.toHexString(!0)),e==="hex4"&&(r=this.toHex8String(!0)),e==="hex8"&&(r=this.toHex8String()),e==="name"&&(r=this.toName()),e==="hsl"&&(r=this.toHslString()),e==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return w(this.toString())},_applyModification:function(e,n){var r=e.apply(null,[this].concat([].slice.call(n)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(Kr,arguments)},brighten:function(){return this._applyModification(Jr,arguments)},darken:function(){return this._applyModification(ts,arguments)},desaturate:function(){return this._applyModification(Xr,arguments)},saturate:function(){return this._applyModification(Yr,arguments)},greyscale:function(){return this._applyModification(Qr,arguments)},spin:function(){return this._applyModification(es,arguments)},_applyCombination:function(e,n){return e.apply(null,[this].concat([].slice.call(n)))},analogous:function(){return this._applyCombination(ss,arguments)},complement:function(){return this._applyCombination(ns,arguments)},monochromatic:function(){return this._applyCombination(is,arguments)},splitcomplement:function(){return this._applyCombination(rs,arguments)},triad:function(){return this._applyCombination(je,[3])},tetrad:function(){return this._applyCombination(je,[4])}};w.fromRatio=function(t,e){if(Jt(t)=="object"){var n={};for(var r in t)t.hasOwnProperty(r)&&(r==="a"?n[r]=t[r]:n[r]=Vt(t[r]));t=n}return w(t,e)};function Gr(t){var e={r:0,g:0,b:0},n=1,r=null,s=null,i=null,a=!1,o=!1;return typeof t=="string"&&(t=hs(t)),Jt(t)=="object"&&(at(t.r)&&at(t.g)&&at(t.b)?(e=qr(t.r,t.g,t.b),a=!0,o=String(t.r).substr(-1)==="%"?"prgb":"rgb"):at(t.h)&&at(t.s)&&at(t.v)?(r=Vt(t.s),s=Vt(t.v),e=Wr(t.h,r,s),a=!0,o="hsv"):at(t.h)&&at(t.s)&&at(t.l)&&(r=Vt(t.s),i=Vt(t.l),e=$r(t.h,r,i),a=!0,o="hsl"),t.hasOwnProperty("a")&&(n=t.a)),n=kn(n),{ok:a,format:t.format||o,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:n}}function qr(t,e,n){return{r:I(t,255)*255,g:I(e,255)*255,b:I(n,255)*255}}function Ge(t,e,n){t=I(t,255),e=I(e,255),n=I(n,255);var r=Math.max(t,e,n),s=Math.min(t,e,n),i,a,o=(r+s)/2;if(r==s)i=a=0;else{var u=r-s;switch(a=o>.5?u/(2-r-s):u/(r+s),r){case t:i=(e-n)/u+(e1&&(c-=1),c<1/6?l+(h-l)*6*c:c<1/2?h:c<2/3?l+(h-l)*(2/3-c)*6:l}if(e===0)r=s=i=n;else{var o=n<.5?n*(1+e):n+e-n*e,u=2*n-o;r=a(u,o,t+1/3),s=a(u,o,t),i=a(u,o,t-1/3)}return{r:r*255,g:s*255,b:i*255}}function qe(t,e,n){t=I(t,255),e=I(e,255),n=I(n,255);var r=Math.max(t,e,n),s=Math.min(t,e,n),i,a,o=r,u=r-s;if(a=r===0?0:u/r,r==s)i=0;else{switch(r){case t:i=(e-n)/u+(e>1)+720)%360;--e;)r.h=(r.h+s)%360,i.push(w(r));return i}function is(t,e){e=e||6;for(var n=w(t).toHsv(),r=n.h,s=n.s,i=n.v,a=[],o=1/e;e--;)a.push(w({h:r,s,v:i})),i=(i+o)%1;return a}w.mix=function(t,e,n){n=n===0?0:n||50;var r=w(t).toRgb(),s=w(e).toRgb(),i=n/100,a={r:(s.r-r.r)*i+r.r,g:(s.g-r.g)*i+r.g,b:(s.b-r.b)*i+r.b,a:(s.a-r.a)*i+r.a};return w(a)};w.readability=function(t,e){var n=w(t),r=w(e);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)};w.isReadable=function(t,e,n){var r=w.readability(t,e),s,i;switch(i=!1,s=cs(n),s.level+s.size){case"AAsmall":case"AAAlarge":i=r>=4.5;break;case"AAlarge":i=r>=3;break;case"AAAsmall":i=r>=7;break}return i};w.mostReadable=function(t,e,n){var r=null,s=0,i,a,o,u;n=n||{},a=n.includeFallbackColors,o=n.level,u=n.size;for(var l=0;ls&&(s=i,r=w(e[l]));return w.isReadable(t,r,{level:o,size:u})||!a?r:(n.includeFallbackColors=!1,w.mostReadable(t,["#fff","#000"],n))};var we=w.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},os=w.hexNames=as(we);function as(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}function kn(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function I(t,e){ls(t)&&(t="100%");var n=us(t);return t=Math.min(e,Math.max(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),Math.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function ne(t){return Math.min(1,Math.max(0,t))}function Y(t){return parseInt(t,16)}function ls(t){return typeof t=="string"&&t.indexOf(".")!=-1&&parseFloat(t)===1}function us(t){return typeof t=="string"&&t.indexOf("%")!=-1}function rt(t){return t.length==1?"0"+t:""+t}function Vt(t){return t<=1&&(t=t*100+"%"),t}function Nn(t){return Math.round(parseFloat(t)*255).toString(16)}function Xe(t){return Y(t)/255}var tt=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",n="(?:"+e+")|(?:"+t+")",r="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?",s="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?";return{CSS_UNIT:new RegExp(n),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+s),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+s),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+s),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function at(t){return!!tt.CSS_UNIT.exec(t)}function hs(t){t=t.replace(Br,"").replace(Ur,"").toLowerCase();var e=!1;if(we[t])t=we[t],e=!0;else if(t=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=tt.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=tt.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=tt.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=tt.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=tt.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=tt.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=tt.hex8.exec(t))?{r:Y(n[1]),g:Y(n[2]),b:Y(n[3]),a:Xe(n[4]),format:e?"name":"hex8"}:(n=tt.hex6.exec(t))?{r:Y(n[1]),g:Y(n[2]),b:Y(n[3]),format:e?"name":"hex"}:(n=tt.hex4.exec(t))?{r:Y(n[1]+""+n[1]),g:Y(n[2]+""+n[2]),b:Y(n[3]+""+n[3]),a:Xe(n[4]+""+n[4]),format:e?"name":"hex8"}:(n=tt.hex3.exec(t))?{r:Y(n[1]+""+n[1]),g:Y(n[2]+""+n[2]),b:Y(n[3]+""+n[3]),format:e?"name":"hex"}:!1}function cs(t){var e,n;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),n!=="small"&&n!=="large"&&(n="small"),{level:e,size:n}}/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var Vn=function(t,e){return(Vn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])})(t,e)};function Pn(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}Vn(t,e),t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function Rn(t){var e="";Array.isArray(t)||(t=[t]);for(var n=0;nt.phi1&&(t.phi2-=2*ct),t.sweepFlag===1&&t.phi2r)return[];if(r===0)return[[t*n/(t*t+e*e),e*n/(t*t+e*e)]];var s=Math.sqrt(r);return[[(t*n+e*s)/(t*t+e*e),(e*n-t*s)/(t*t+e*e)],[(t*n-e*s)/(t*t+e*e),(e*n+t*s)/(t*t+e*e)]]}var z,lt=Math.PI/180;function Qe(t,e,n){return(1-n)*t+n*e}function Ke(t,e,n,r){return t+Math.cos(r/180*ct)*e+Math.sin(r/180*ct)*n}function Je(t,e,n,r){var s=1e-6,i=e-t,a=n-e,o=3*i+3*(r-n)-6*a,u=6*(a-i),l=3*i;return Math.abs(o)S&&(f.sweepFlag=+!f.sweepFlag),f})}function a(){return function(o){var u={};for(var l in o)u[l]=o[l];return u}}t.ROUND=function(o){function u(l){return Math.round(l*o)/o}return o===void 0&&(o=1e13),et(o),function(l){return l.x1!==void 0&&(l.x1=u(l.x1)),l.y1!==void 0&&(l.y1=u(l.y1)),l.x2!==void 0&&(l.x2=u(l.x2)),l.y2!==void 0&&(l.y2=u(l.y2)),l.x!==void 0&&(l.x=u(l.x)),l.y!==void 0&&(l.y=u(l.y)),l.rX!==void 0&&(l.rX=u(l.rX)),l.rY!==void 0&&(l.rY=u(l.rY)),l}},t.TO_ABS=e,t.TO_REL=function(){return s(function(o,u,l){return o.relative||(o.x1!==void 0&&(o.x1-=u),o.y1!==void 0&&(o.y1-=l),o.x2!==void 0&&(o.x2-=u),o.y2!==void 0&&(o.y2-=l),o.x!==void 0&&(o.x-=u),o.y!==void 0&&(o.y-=l),o.relative=!0),o})},t.NORMALIZE_HVZ=function(o,u,l){return o===void 0&&(o=!0),u===void 0&&(u=!0),l===void 0&&(l=!0),s(function(h,c,p,f,d){if(isNaN(f)&&!(h.type&b.MOVE_TO))throw new Error("path must start with moveto");return u&&h.type&b.HORIZ_LINE_TO&&(h.type=b.LINE_TO,h.y=h.relative?0:p),l&&h.type&b.VERT_LINE_TO&&(h.type=b.LINE_TO,h.x=h.relative?0:c),o&&h.type&b.CLOSE_PATH&&(h.type=b.LINE_TO,h.x=h.relative?f-c:f,h.y=h.relative?d-p:d),h.type&b.ARC&&(h.rX===0||h.rY===0)&&(h.type=b.LINE_TO,delete h.rX,delete h.rY,delete h.xRot,delete h.lArcFlag,delete h.sweepFlag),h})},t.NORMALIZE_ST=n,t.QT_TO_C=r,t.INFO=s,t.SANITIZE=function(o){o===void 0&&(o=0),et(o);var u=NaN,l=NaN,h=NaN,c=NaN;return s(function(p,f,d,m,g){var v=Math.abs,y=!1,C=0,M=0;if(p.type&b.SMOOTH_CURVE_TO&&(C=isNaN(u)?0:f-u,M=isNaN(l)?0:d-l),p.type&(b.CURVE_TO|b.SMOOTH_CURVE_TO)?(u=p.relative?f+p.x2:p.x2,l=p.relative?d+p.y2:p.y2):(u=NaN,l=NaN),p.type&b.SMOOTH_QUAD_TO?(h=isNaN(h)?f:2*f-h,c=isNaN(c)?d:2*d-c):p.type&b.QUAD_TO?(h=p.relative?f+p.x1:p.x1,c=p.relative?d+p.y1:p.y2):(h=NaN,c=NaN),p.type&b.LINE_COMMANDS||p.type&b.ARC&&(p.rX===0||p.rY===0||!p.lArcFlag)||p.type&b.CURVE_TO||p.type&b.SMOOTH_CURVE_TO||p.type&b.QUAD_TO||p.type&b.SMOOTH_QUAD_TO){var x=p.x===void 0?0:p.relative?p.x:p.x-f,_=p.y===void 0?0:p.relative?p.y:p.y-d;C=isNaN(h)?p.x1===void 0?C:p.relative?p.x:p.x1-f:h-f,M=isNaN(c)?p.y1===void 0?M:p.relative?p.y:p.y1-d:c-d;var S=p.x2===void 0?0:p.relative?p.x:p.x2-f,T=p.y2===void 0?0:p.relative?p.y:p.y2-d;v(x)<=o&&v(_)<=o&&v(C)<=o&&v(M)<=o&&v(S)<=o&&v(T)<=o&&(y=!0)}return p.type&b.CLOSE_PATH&&v(f-m)<=o&&v(d-g)<=o&&(y=!0),y?[]:p})},t.MATRIX=i,t.ROTATE=function(o,u,l){u===void 0&&(u=0),l===void 0&&(l=0),et(o,u,l);var h=Math.sin(o),c=Math.cos(o);return i(c,h,-h,c,u-u*c+l*h,l-u*h-l*c)},t.TRANSLATE=function(o,u){return u===void 0&&(u=0),et(o,u),i(1,0,0,1,o,u)},t.SCALE=function(o,u){return u===void 0&&(u=o),et(o,u),i(o,0,0,u,0,0)},t.SKEW_X=function(o){return et(o),i(1,0,Math.atan(o),1,0,0)},t.SKEW_Y=function(o){return et(o),i(1,Math.atan(o),0,1,0,0)},t.X_AXIS_SYMMETRY=function(o){return o===void 0&&(o=0),et(o),i(-1,0,0,1,o,0)},t.Y_AXIS_SYMMETRY=function(o){return o===void 0&&(o=0),et(o),i(1,0,0,-1,0,o)},t.A_TO_C=function(){return s(function(o,u,l){return b.ARC===o.type?function(h,c,p){var f,d,m,g;h.cX||ae(h,c,p);for(var v=Math.min(h.phi1,h.phi2),y=Math.max(h.phi1,h.phi2)-v,C=Math.ceil(y/90),M=new Array(C),x=c,_=p,S=0;Sc.maxX&&(c.maxX=L),Lc.maxY&&(c.maxY=L),LZ&&g(tn(f,m.x1,m.x2,m.x,Z));for(var M=0,x=Je(d,m.y1,m.y2,m.y);MZ&&v(tn(d,m.y1,m.y2,m.y,Z))}if(m.type&b.ARC){g(m.x),v(m.y),ae(m,f,d);for(var _=m.xRot/180*Math.PI,S=Math.cos(_)*m.rX,T=Math.sin(_)*m.rX,V=-Math.sin(_)*m.rY,G=Math.cos(_)*m.rY,H=m.phi1m.phi2?[m.phi2+360,m.phi1+360]:[m.phi2,m.phi1],k=H[0],N=H[1],R=function(L){var st=L[0],Mt=L[1],Tt=180*Math.atan2(Mt,st)/Math.PI;return Ttk&&Zk&&Zh)throw new SyntaxError('Expected positive number, got "'+h+'" at index "'+a+'"')}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+a+'"')}this.curArgs.push(h),this.curArgs.length===ds[this.curCommandType]&&(b.HORIZ_LINE_TO===this.curCommandType?i({type:b.HORIZ_LINE_TO,relative:this.curCommandRelative,x:h}):b.VERT_LINE_TO===this.curCommandType?i({type:b.VERT_LINE_TO,relative:this.curCommandRelative,y:h}):this.curCommandType===b.MOVE_TO||this.curCommandType===b.LINE_TO||this.curCommandType===b.SMOOTH_QUAD_TO?(i({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),b.MOVE_TO===this.curCommandType&&(this.curCommandType=b.LINE_TO)):this.curCommandType===b.CURVE_TO?i({type:b.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===b.SMOOTH_CURVE_TO?i({type:b.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===b.QUAD_TO?i({type:b.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===b.ARC&&i({type:b.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!fs(o))if(o===","&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if(o!=="+"&&o!=="-"&&o!==".")if(l)this.curNumber=o,this.curNumberHasDecimal=!1;else{if(this.curArgs.length!==0)throw new SyntaxError("Unterminated command at index "+a+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+o+'" at index '+a+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,o!=="z"&&o!=="Z")if(o==="h"||o==="H")this.curCommandType=b.HORIZ_LINE_TO,this.curCommandRelative=o==="h";else if(o==="v"||o==="V")this.curCommandType=b.VERT_LINE_TO,this.curCommandRelative=o==="v";else if(o==="m"||o==="M")this.curCommandType=b.MOVE_TO,this.curCommandRelative=o==="m";else if(o==="l"||o==="L")this.curCommandType=b.LINE_TO,this.curCommandRelative=o==="l";else if(o==="c"||o==="C")this.curCommandType=b.CURVE_TO,this.curCommandRelative=o==="c";else if(o==="s"||o==="S")this.curCommandType=b.SMOOTH_CURVE_TO,this.curCommandRelative=o==="s";else if(o==="q"||o==="Q")this.curCommandType=b.QUAD_TO,this.curCommandRelative=o==="q";else if(o==="t"||o==="T")this.curCommandType=b.SMOOTH_QUAD_TO,this.curCommandRelative=o==="t";else{if(o!=="a"&&o!=="A")throw new SyntaxError('Unexpected character "'+o+'" at index '+a+".");this.curCommandType=b.ARC,this.curCommandRelative=o==="a"}else r.push({type:b.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=o,this.curNumberHasDecimal=o==="."}else this.curNumber+=o,this.curNumberHasDecimal=!0;else this.curNumber+=o;else this.curNumber+=o,this.curNumberHasExp=!0;else this.curNumber+=o,this.curNumberHasExpDigits=this.curNumberHasExp}return r},e.prototype.transform=function(n){return Object.create(this,{parse:{value:function(r,s){s===void 0&&(s=[]);for(var i=0,a=Object.getPrototypeOf(this).parse.call(this,r);i1?e[1]:null}(function(t){t[t.SVG=0]="SVG",t[t.CANVAS=1]="CANVAS"})(ft||(ft={}));const Lt="data-sketchy-clip-path",ms=/[acsqt]/i;function Oe(t){if(t.svgSketchDefs)return t.svgSketchDefs;const e=t.svgSketch,n=document.createElementNS("http://www.w3.org/2000/svg","defs");return e.childElementCount>0?e.insertBefore(n,e.firstElementChild):e.appendChild(n),t.svgSketchDefs=n,n}function nn(t){const e=t.getAttribute("points");if(!e)return[];let n;n=e.indexOf(" ")>0?/\s+/g:/,/g;const r=e.split(n),s=[];for(let i=0;i0?t.transform.baseVal.consolidate():null}function Dt(t,e,n){if(!n)return on(e);const r=on(e);if(r){const s=r.matrix,i=n.matrix.multiply(s);return t.sourceSvg.createSVGTransformFromMatrix(i)}return n}function pt(t,e,n){if(e&&e.matrix&&!Rt(e)){const r=e.matrix;n.transform.baseVal.numberOfItems>0?n.transform.baseVal.getItem(0).setMatrix(r):n.transform.baseVal.appendItem(e)}}function an(t){var e;let n=t.getAttribute("stop-color");if(!n){const r=(e=t.getAttribute("style"))!==null&&e!==void 0?e:"",s=/stop-color:\s?(.*);?/.exec(r);s&&s.length>1&&(n=s[1])}return w(n||"white")}function ln(t){const e=t.length;let n=0,r=0,s=0,i=0;return t.forEach(a=>{const o=a.toRgb();n+=o.r*o.r,r+=o.g*o.g,s+=o.b*o.b,i+=o.a}),w({r:Math.sqrt(n/e),g:Math.sqrt(r/e),b:Math.sqrt(s/e),a:i/e})}function bs(t){const e=t.getAttribute("offset");return e?e.indexOf("%")?parseFloat(e.substring(0,e.length-1)):100*parseFloat(e):0}function ys(t,e){if(t.roughConfig.fillStyle==="solid")return{angle:0,gap:0,weight:0};const{width:n,height:r}=e.getBoundingClientRect(),s=n/r,i=Math.sqrt(n*r),{angle:a,gap:o,weight:u}=function(l){const h={angle:{normal:[-30,-50],horizontal:[-30,-50],vertical:[-30,-50]},weight:{normal:[.5,3],small:[.5,3]},gap:{normal:[3,5],small:[3,5]}},c={angle:{normal:[-30,-50],horizontal:[-50,-75],vertical:[-30,-15]},weight:{normal:[1,3],small:[.5,1.7]},gap:{normal:[2,5],small:[1,3]}};switch(l){default:return c;case"zigzag":case"zigzag-line":return Object.assign(Object.assign({},c),{weight:{normal:[.5,3],small:[.5,2]},gap:{normal:[2,6],small:[2,5]}});case"cross-hatch":return Object.assign(Object.assign({},c),{weight:{normal:[1,3],small:[.5,1.3]},gap:{normal:[4,8],small:[2,5]}});case"dots":return h}}(t.roughConfig.fillStyle);return{angle:xs(t,a,s),gap:ws(t,o,i),weight:Ms(t,u,i)}}function xs({rng:t},{normal:e,horizontal:n,vertical:r},s){if(isFinite(s)){if(s<.25)return t.next(n);if(s>6)return t.next(r)}return t.next(e)}function ws({rng:t},{normal:e,small:n},r){return r<45?t.next(n):t.next(e)}function Ms({rng:t},{normal:e,small:n},r){return r<45?t.next(n):t.next(e)}function it(t,e,n){var r;const s=(r=t.roughConfig.fixedDecimalPlaceDigits)!==null&&r!==void 0?r:15,i=Object.assign({},t.roughConfig);let a=1;if(!Rt(n)){const m=n.matrix,g=m.a*m.d-m.c*m.b;a=Math.sqrt(Math.abs(g))}const o=zn(t,e,1,t.useElementContext),u=U(t,e,"fill",t.useElementContext)||"black",l=o*un(e,"fill-opacity");if(u)if(u.indexOf("url")!==-1){const m=hn(t,u,l);m!=="none"?i.fill=m:delete i.fill}else if(u==="none")delete i.fill;else{const m=w(u);m.setAlpha(l),i.fill=m.toString()}const h=U(t,e,"stroke",t.useElementContext),c=o*un(e,"stroke-opacity");if(h)if(h.indexOf("url")!==-1)i.stroke=hn(t,h,c);else if(h==="none")i.stroke="none";else{const m=w(h);m.setAlpha(c),i.stroke=m.toString()}else i.stroke="none";const p=U(t,e,"stroke-width",t.useElementContext);if(p){const m=Pt(t,e,p,"stroke-width")*a;i.strokeWidth=parseFloat(m.toFixed(s))}else i.strokeWidth=1;const f=U(t,e,"stroke-dasharray",t.useElementContext);f&&f!=="none"&&(i.strokeLineDash=f.split(/[\s,]+/).filter(m=>m.length>0).map(m=>{const g=Pt(t,e,m,"stroke-dasharray")*a;return Math.max(.5,parseFloat(g.toFixed(s)))}));const d=U(t,e,"stroke-dashoffset",t.useElementContext);if(d){const m=Pt(t,e,d,"stroke-dashoffset")*a;i.strokeLineDashOffset=parseFloat(m.toFixed(s))}if(i.fill&&i.stroke==="none"&&(i.stroke=i.fill,i.strokeWidth=1),t.randomize){const{angle:m,gap:g,weight:v}=ys(t,e);i.hachureAngle=m,i.hachureGap=Math.round(g),i.fillWeight=parseFloat(v.toFixed(s)),i.disableMultiStroke===void 0&&(i.disableMultiStroke=t.rng.next()>.3)}return i}function un(t,e){const n=getComputedStyle(t)[e]||t.getAttribute(e);return n?n.indexOf("%")!==-1?Math.min(1,Math.max(0,parseFloat(n.substring(0,n.length-1))/100)):Math.min(1,Math.max(0,parseFloat(n))):1}function hn(t,e,n){const r=_t(e);if(!r)return"none";const s=t.idElements[r];if(!s)return"none";if(typeof s=="string")return s;if(s instanceof SVGLinearGradientElement||s instanceof SVGRadialGradientElement){const i=function(a,o){const u=Array.prototype.slice.apply(a.querySelectorAll("stop"));if(u.length===0)return"transparent";if(u.length===1){const l=an(u[0]);return l.setAlpha(o),l.toString()}{const h=[];let c=null;for(let f=0;f0;)h.push(g),v--;c=d}const p=ln(h);return p.setAlpha(o),p.toString()}}(s,n);return t.idElements[r]=i,i}return"none"}function O(t){return`${t.x},${t.y}`}function Gt(t,e,n,r){if(n.length===0)return;const s=n[0],i=n[n.length-1],a=_t(e.getAttribute("marker-start")),o=a?t.idElements[a]:null;if(o&&n.length>1){let p=o.orientAngle.baseVal.value;const f=n[1],d=o.getAttribute("orient");if(d==="auto"||d==="auto-start-reverse"){const y=d==="auto"?0:180,C=n[n.length-2];cn(n)?p=fe(C,i,f)-y:p=te({x:1,y:0},{x:f.x-s.x,y:f.y-s.y})-y}const m=t.sourceSvg.createSVGMatrix().translate(s.x,s.y).rotate(p).scale(ce(t,o,e)),g=r?r.matrix.multiply(m):m,v=t.sourceSvg.createSVGTransformFromMatrix(g);t.processElement(t,o,v)}const u=_t(e.getAttribute("marker-end")),l=u?t.idElements[u]:null;if(l){let p=l.orientAngle.baseVal.value;if(n.length>1){const g=l.getAttribute("orient");if(g==="auto"||g==="auto-start-reverse"){const v=n[n.length-2];cn(n)?p=fe(v,i,n[1]):p=te({x:1,y:0},{x:i.x-v.x,y:i.y-v.y})}}const f=t.sourceSvg.createSVGMatrix().translate(i.x,i.y).rotate(p).scale(ce(t,l,e)),d=r?r.matrix.multiply(f):f,m=t.sourceSvg.createSVGTransformFromMatrix(d);t.processElement(t,l,m)}const h=_t(e.getAttribute("marker-mid")),c=h?t.idElements[h]:null;if(c&&n.length>2)for(let p=0;p{const a=document.createElementNS("http://www.w3.org/2000/svg","rect");return a.x.baseVal.value=n,a.y.baseVal.value=r,a.width.baseVal.value=s,a.height.baseVal.value=i,a})}function Ss(t,e,n,r){const s=_t(n);if(!s)return;const i=t.idElements[s];if(!i)return;const a=Oe(t),o=`${s}_${a.childElementCount}`,u=document.createElementNS("http://www.w3.org/2000/svg","clipPath");u.id=o,function(c,p){if(c.tagName!=="g")return void c.setAttribute(Lt,p);const f=[],d=dt(c);for(let m=d.length-1;m>=0;m--)f.push(d[m]);for(;f.length>0;){const m=f.pop();m.setAttribute(Lt,p);const g=dt(m);for(let v=g.length-1;v>=0;v--)f.push(g[v])}}(e,o);const l=[],h=dt(i);for(let c=h.length-1;c>=0;c--){const p=h[c],f=Dt(t,p,r);l.push({element:p,transform:f})}for(;l.length>0;){const{element:c,transform:p}=l.pop();try{As(t,c,u,p)}catch(d){console.error(d)}if(c.tagName==="defs"||c.tagName==="svg"||c.tagName==="clipPath"||c.tagName==="text")continue;const f=dt(c);for(let d=f.length-1;d>=0;d--){const m=f[d],g=Dt(t,m,p);l.push({element:m,transform:g})}}u.childNodes.length>0&&a.appendChild(u)}function As(t,e,n,r){switch(e.tagName){case"rect":(function(s,i,a,o){const u=i.x.baseVal.value,l=i.y.baseVal.value,h=i.width.baseVal.value,c=i.height.baseVal.value;if(h===0||c===0)return;const p=i.hasAttribute("rx")?i.rx.baseVal.value:null,f=i.hasAttribute("ry")?i.ry.baseVal.value:null,d=document.createElementNS("http://www.w3.org/2000/svg","rect");d.x.baseVal.value=u,d.y.baseVal.value=l,d.width.baseVal.value=h,d.height.baseVal.value=c,p&&(d.rx.baseVal.value=p),f&&(d.ry.baseVal.value=f),pt(0,o,d),a.appendChild(d)})(0,e,n,r);break;case"circle":(function(s,i,a,o){const u=i.cx.baseVal.value,l=i.cy.baseVal.value,h=i.r.baseVal.value;if(h===0)return;const c=document.createElementNS("http://www.w3.org/2000/svg","circle");c.cx.baseVal.value=u,c.cy.baseVal.value=l,c.r.baseVal.value=h,pt(0,o,c),a.appendChild(c)})(0,e,n,r);break;case"ellipse":(function(s,i,a,o){const u=i.cx.baseVal.value,l=i.cy.baseVal.value,h=i.rx.baseVal.value,c=i.ry.baseVal.value;if(h===0||c===0)return;const p=document.createElementNS("http://www.w3.org/2000/svg","ellipse");p.cx.baseVal.value=u,p.cy.baseVal.value=l,p.rx.baseVal.value=h,p.ry.baseVal.value=c,pt(0,o,p),a.appendChild(p)})(0,e,n,r);break;case"polygon":(function(s,i,a,o){const u=document.createElementNS("http://www.w3.org/2000/svg","polygon");u.setAttribute("points",i.getAttribute("points")),pt(0,o,u),a.appendChild(u)})(0,e,n,r);break;case"path":(function(s,i,a,o){const u=document.createElementNS("http://www.w3.org/2000/svg","path");u.setAttribute("d",i.getAttribute("d")),pt(0,o,u),a.appendChild(u)})(0,e,n,r)}}function Es(t,e,n){const r=document.createElementNS("http://www.w3.org/2000/svg","g");r.setAttribute("class","text-container"),pt(0,n,r);const s=e.cloneNode(!0);s.transform.baseVal.numberOfItems>0&&s.transform.baseVal.clear(),s.removeAttribute("clip-path");const{cssFont:i,fontSize:a}=function(l,h,c=!1){const p={};let f="";const d=U(l,h,"font-style",l.useElementContext);d&&(f+=c?`font-style: ${d};`:d,p.fontStyle=d);const m=U(l,h,"font-weight",l.useElementContext);m&&(f+=c?`font-weight: ${m};`:` ${m}`,p.fontWeight=m);const g=U(l,h,"font-size",l.useElementContext);if(g&&(f+=c?`font-size: ${g};`:` ${g}`,p.fontSize=g),l.fontFamily)f+=c?`font-family: ${l.fontFamily};`:` ${l.fontFamily}`,p.fontFamiliy=l.fontFamily;else{const v=U(l,h,"font-family",l.useElementContext);v&&(f+=c?`font-family: ${v};`:` ${v}`,p.fontFamiliy=v)}return f=f.trim(),Object.assign(Object.assign({},p),{cssFont:f})}(t,e,!0);if(s.setAttribute("style",function(...l){let h="";l=l.filter(c=>c!==null);for(const c of l)h.length>0&&h[h.length-1]!==";"&&(h+=";"),h+=c;return h}(s.getAttribute("style"),i)),pn(t,e,s),s.childElementCount>0){const l=dt(s),h=dt(e);for(let c=0;c=0;d--){const m=f[d];if(m instanceof SVGSymbolElement||m instanceof SVGMarkerElement)continue;const g=Dt(t,m,n);o.push({element:m,transform:g,viewBox:u})}}else o.push({element:e,transform:n,viewBox:u});for(;o.length>0;){const{element:l,transform:h,viewBox:c}=o.pop();try{t.viewBox=c,_s(t,l,h)}catch(f){console.error(f)}if(l.tagName==="defs"||l.tagName==="symbol"||l.tagName==="marker"||l.tagName==="svg"||l.tagName==="clipPath")continue;const p=dt(l);for(let f=p.length-1;f>=0;f--){const d=p[f],m=Dt(t,d,h);o.push({element:d,transform:m,viewBox:c})}}}function _s(t,e,n){if(function(s){const i=s.style;return!!i&&(i.display==="none"||i.visibility==="hidden")}(e))return;const r=e.getAttribute("clip-path");switch(r&&Ss(t,e,r,n),e.tagName){case"svg":case"symbol":(function(s,i,a){let o=parseFloat(i.getAttribute("width")),u=parseFloat(i.getAttribute("height"));(isNaN(o)||isNaN(u))&&(o=u=void 0),Dn(s,i,a,o,u)})(t,e,n);break;case"rect":(function(s,i,a){const o=i.x.baseVal.value,u=i.y.baseVal.value,l=i.width.baseVal.value,h=i.height.baseVal.value;if(l===0||h===0)return;let c=i.hasAttribute("rx")?Math.min(Math.max(0,i.rx.baseVal.value),l/2):null,p=i.hasAttribute("ry")?Math.min(Math.max(0,i.ry.baseVal.value),h/2):null;c===null&&p===null||(c=c===null?p:c,p=p===null?c:p);const f=E({x:o,y:u},a),d=E({x:o+l,y:u+h},a),m=d.x-f.x,g=d.y-f.y,v={x:f.x,y:f.y,w:m,h:g};if(!Rt(a)&&!he(a)||c||p){let y="";if(c!==null&&p!==null){const M=1.3333333333333333*(Math.sqrt(2)-1),x=E({x:o+c,y:u},a);y+=`M ${O(x)}`,y+=`L ${O(E({x:o+l-c,y:u},a))}`;const _=E({x:o+l-c+M*c,y:u},a),S=E({x:o+l,y:u+M*p},a),T=E({x:o+l,y:u+p},a);y+=`C ${O(_)} ${O(S)} ${O(T)}`,y+=`L ${O(E({x:o+l,y:u+h-p},a))}`;const V=E({x:o+l,y:u+h-p+M*p},a),G=E({x:o+l-M*c,y:u+h},a),H=E({x:o+l-c,y:u+h},a);y+=`C ${O(V)} ${O(G)} ${O(H)}`,y+=`L ${O(E({x:o+c,y:u+h},a))}`;const k=E({x:o+c-M*c,y:u+h},a),N=E({x:o,y:u+h-M*p},a),R=E({x:o,y:u+h-p},a);y+=`C ${O(k)} ${O(N)} ${O(R)}`,y+=`L ${O(E({x:o,y:u+p},a))}`;const B=E({x:o,y:u+M*p},a),D=E({x:o+M*c,y:u},a);y+=`C ${O(B)} ${O(D)} ${O(x)}`,y+="z"}else{const M=E({x:o,y:u},a),x=E({x:o+l,y:u},a),_=E({x:o+l,y:u+h},a),S=E({x:o,y:u+h},a);y+=`M ${O(M)}`,y+=`L ${O(x)}`,y+=`L ${O(_)}`,y+=`L ${O(S)}`,y+="z"}const C=Ut(s,y,it(s,i,a));fn(s,i,v),Q(s,i,C)}else{const y=s.rc.rectangle(v.x,v.y,v.w,v.h,it(s,i,a));fn(s,i,v),Q(s,i,y)}})(t,e,n);break;case"path":(function(s,i,a){const o=i.getAttribute("d"),u=new b(o).toAbs().transform(z.NORMALIZE_HVZ()).transform(z.NORMALIZE_ST()),l=new b(u.commands.map(d=>Object.assign({},d)));a&&l.transform(z.MATRIX(a.matrix.a,a.matrix.b,a.matrix.c,a.matrix.d,a.matrix.e,a.matrix.f));const h=Rn(l.commands);if(h.indexOf("undefined")!==-1)return void console.error("broken path data");const c=Ut(s,h,it(s,i,a));bt(s,i,()=>{const d=document.createElementNS("http://www.w3.org/2000/svg","path");return d.setAttribute("d",h),d}),Q(s,i,c);const p=[];let f;u.commands.forEach(d=>{switch(d.type){case b.MOVE_TO:{const m={x:d.x,y:d.y};p.push(m),f=m;break}case b.LINE_TO:case b.QUAD_TO:case b.SMOOTH_QUAD_TO:case b.CURVE_TO:case b.SMOOTH_CURVE_TO:case b.ARC:p.push({x:d.x,y:d.y});break;case b.HORIZ_LINE_TO:p.push({x:d.x,y:0});break;case b.VERT_LINE_TO:p.push({x:0,y:d.y});break;case b.CLOSE_PATH:f&&p.push(f)}}),Gt(s,i,p,a)})(t,e,n);break;case"use":(function(s,i,a){let o=i.href.baseVal;o.startsWith("#")&&(o=o.substring(1));const u=s.idElements[o];if(u){let l,h;i.getAttribute("width")&&i.getAttribute("height")&&(l=i.width.baseVal.value,h=i.height.baseVal.value);const c=i.x.baseVal.value,p=i.y.baseVal.value;let f=s.sourceSvg.createSVGMatrix().translate(c,p);f=a?a.matrix.multiply(f):f;const d=s.sourceSvg.createSVGTransformFromMatrix(f);if(s.useElementContext){const m={root:i,referenced:u,parentContext:Object.assign({},s.useElementContext)};s.useElementContext=m}else s.useElementContext={root:i,referenced:u,parentContext:null};s.processElement(s,u,Dt(s,u,d),l,h),s.useElementContext.parentContext?s.useElementContext=s.useElementContext.parentContext:s.useElementContext=null}})(t,e,n);break;case"line":(function(s,i,a){const o={x:i.x1.baseVal.value,y:i.y1.baseVal.value},u={x:i.x2.baseVal.value,y:i.y2.baseVal.value},{x:l,y:h}=E(o,a),{x:c,y:p}=E(u,a);if(l===c&&h===p)return;const f=s.rc.line(l,h,c,p,it(s,i,a));bt(s,i,()=>{const d=document.createElementNS("http://www.w3.org/2000/svg","line");return d.x1.baseVal.value=l,d.y1.baseVal.value=h,d.x2.baseVal.value=c,d.y2.baseVal.value=p,d}),Q(s,i,f),Gt(s,i,[o,u],a)})(t,e,n);break;case"circle":(function(s,i,a){const o=i.cx.baseVal.value,u=i.cy.baseVal.value,l=i.r.baseVal.value;if(l===0)return;const h=E({x:o,y:u},a),c=E({x:o+l,y:u+l},a).x-h.x;let p;if(Rt(a)||he(a))p=s.rc.circle(h.x,h.y,2*c,Object.assign(Object.assign({},it(s,i,a)),{preserveVertices:!0}));else{const f=1.3333333333333333*(Math.sqrt(2)-1),d=E({x:o+l,y:u},a),m=E({x:o,y:u+l},a),g=E({x:o-l,y:u},a),v=E({x:o,y:u-l},a),y=E({x:o+l,y:u+f*l},a),C=E({x:o+f*l,y:u+l},a),M=E({x:o-l,y:u+f*l},a),x=E({x:o-f*l,y:u-l},a),_=E({x:o+l,y:u-f*l},a);p=Ut(s,`M ${O(d)} C ${O(y)} ${O(C)} ${O(m)} S ${O(M)} ${O(g)} S ${O(x)} ${O(v)} S ${O(_)} ${O(d)}z`,it(s,i,a))}bt(s,i,()=>{const f=document.createElementNS("http://www.w3.org/2000/svg","circle");return f.cx.baseVal.value=h.x,f.cy.baseVal.value=h.y,f.r.baseVal.value=c,f}),Q(s,i,p)})(t,e,n);break;case"ellipse":(function(s,i,a){const o=i.cx.baseVal.value,u=i.cy.baseVal.value,l=i.rx.baseVal.value,h=i.ry.baseVal.value;if(l===0||h===0)return;const c=E({x:o,y:u},a),p=E({x:o+l,y:u+h},a),f=p.x-c.x,d=p.y-c.y;let m;if(Rt(a)||he(a))m=s.rc.ellipse(c.x,c.y,2*f,2*d,Object.assign(Object.assign({},it(s,i,a)),{preserveVertices:!0}));else{const g=1.3333333333333333*(Math.sqrt(2)-1),v=E({x:o+l,y:u},a),y=E({x:o,y:u+h},a),C=E({x:o-l,y:u},a),M=E({x:o,y:u-h},a),x=E({x:o+l,y:u+g*h},a),_=E({x:o+g*l,y:u+h},a),S=E({x:o-l,y:u+g*h},a),T=E({x:o-g*l,y:u-h},a),V=E({x:o+l,y:u-g*h},a);m=Ut(s,`M ${O(v)} C ${O(x)} ${O(_)} ${O(y)} S ${O(S)} ${O(C)} S ${O(T)} ${O(M)} S ${O(V)} ${O(v)}z`,it(s,i,a))}bt(s,i,()=>{const g=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return g.cx.baseVal.value=c.x,g.cy.baseVal.value=c.y,g.rx.baseVal.value=f,g.ry.baseVal.value=d,g}),Q(s,i,m)})(t,e,n);break;case"polyline":(function(s,i,a){const o=nn(i),u=o.map(h=>{const c=E(h,a);return[c.x,c.y]}),l=it(s,i,a);if(bt(s,i,()=>{const h=document.createElementNS("http://www.w3.org/2000/svg","polyline");return h.setAttribute("points",u.join(" ")),h}),l.fill&&l.fill!=="none"){const h=Object.assign(Object.assign({},l),{stroke:"none"});Q(s,i,s.rc.polygon(u,h))}Q(s,i,s.rc.linearPath(u,l)),Gt(s,i,o,a)})(t,e,n);break;case"polygon":(function(s,i,a){const o=nn(i),u=o.map(h=>{const c=E(h,a);return[c.x,c.y]}),l=s.rc.polygon(u,it(s,i,a));bt(s,i,()=>{const h=document.createElementNS("http://www.w3.org/2000/svg","polygon");return h.setAttribute("points",u.join(" ")),h}),Q(s,i,l),o.length>0&&(o.push(o[0]),Gt(s,i,o,a))})(t,e,n);break;case"text":Es(t,e,n);break;case"image":(function(s,i,a){const o=i.href.baseVal,u=i.x.baseVal.value,l=i.y.baseVal.value;let h,c;if(i.getAttribute("width")&&i.getAttribute("height")&&(h=i.width.baseVal.value,c=i.height.baseVal.value),o.startsWith("data:")&&o.indexOf("image/svg+xml")!==-1){const p=/^data:([^,]*),(.*)/.exec(o);if(p&&p.length>2){const f=p[1];let d=p[2];const m=f.indexOf("base64")!==-1,g=f.indexOf("utf8")!==-1;m&&(d=atob(d)),g||(d=decodeURIComponent(d));const v=new DOMParser().parseFromString(d,"image/svg+xml").firstChild;let y=s.sourceSvg.createSVGMatrix().translate(u,l);y=a?a.matrix.multiply(y):y,s.processElement(s,v,s.sourceSvg.createSVGTransformFromMatrix(y),h,c)}}else{const p=i.cloneNode(),f=document.createElementNS("http://www.w3.org/2000/svg","g");pt(0,a,f),f.appendChild(p),Q(s,i,f)}})(t,e,n);break;case"foreignObject":(function(s,i,a){const o=i.cloneNode(!0),u=document.createElementNS("http://www.w3.org/2000/svg","g"),l=["color","font-family","font-size","font-style","font-variant","font-weight"],h=getComputedStyle(i);for(const c of l)u.style.setProperty(c,h.getPropertyValue(c));o.transform.baseVal.clear(),pt(0,a,u),u.appendChild(o),Q(s,o,u)})(t,e,n)}}class Cs{constructor(e){this.rng=e?new Mn(e):null}next(e){var n,r;const s=(r=(n=this.rng)===null||n===void 0?void 0:n.next())!==null&&r!==void 0?r:Math.random();if(e){const i=e[0];return s*(e[1]-i)+i}return s}}class Os{set svg(e){this.$svg!==e&&(this.$svg=e,this.sourceSvgChanged())}get svg(){return this.$svg}set outputType(e){if(this.$outputType!==e){if(e===ft.CANVAS&&this.outputElement instanceof SVGSVGElement||e===ft.SVG&&this.outputElement instanceof HTMLCanvasElement)throw new Error(`Output format ${e} incompatible with given output element ${this.outputElement.tagName}`);this.$outputType=e}}get outputType(){return this.$outputType}set roughConfig(e){e.fixedDecimalPlaceDigits===void 0&&(e.fixedDecimalPlaceDigits=3),this.$roughConfig=e}get roughConfig(){return this.$roughConfig}constructor(e,n=ft.SVG,r={}){if(this.backgroundColor=null,this.fontFamily="Comic Sans MS, cursive",this.randomize=!0,this.seed=null,this.sketchPatterns=!0,this.pencilFilter=!1,this.width=0,this.height=0,this.$roughConfig={},this.idElements={},this.lastResult=null,!e)throw new Error("No target provided");const s=typeof e=="string"?document.querySelector(e):e;if(!s)throw new Error("Could not find target in document");this.roughConfig=r,this.outputElement=s,s instanceof HTMLCanvasElement?this.$outputType=ft.CANVAS:s instanceof SVGSVGElement?this.$outputType=ft.SVG:this.$outputType=n}sketch(e=!1){var n,r;if(!this.svg)return Promise.resolve(null);e&&this.sourceSvgChanged();const s=this.prepareRenderContainer(),i=this.createRenderContext(s);if(this.pencilFilter&&Oe(i).appendChild(function(){const a=document.createElementNS("http://www.w3.org/2000/svg","filter");a.setAttribute("id","pencilTextureFilter"),a.setAttribute("x","0%"),a.setAttribute("y","0%"),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("filterUnits","objectBoundingBox");const o=document.createElementNS("http://www.w3.org/2000/svg","feTurbulence");o.setAttribute("type","fractalNoise"),o.setAttribute("baseFrequency","2"),o.setAttribute("numOctaves","5"),o.setAttribute("stitchTiles","stitch"),o.setAttribute("result","f1"),a.appendChild(o);const u=document.createElementNS("http://www.w3.org/2000/svg","feColorMatrix");u.setAttribute("type","matrix"),u.setAttribute("values","0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 -1.5 1.5"),u.setAttribute("result","f2"),a.appendChild(u);const l=document.createElementNS("http://www.w3.org/2000/svg","feComposite");return l.setAttribute("operator","in"),l.setAttribute("in","SourceGraphic"),l.setAttribute("in2","f2"),l.setAttribute("result","f3"),a.appendChild(l),a}()),i.processElement(i,this.svg,null,this.width,this.height),this.outputElement instanceof SVGSVGElement)return Promise.resolve(this.outputElement);if(this.outputElement instanceof HTMLCanvasElement)return this.drawToCanvas(i,this.outputElement);if((r=(n=this.lastResult)===null||n===void 0?void 0:n.parentNode)===null||r===void 0||r.removeChild(this.lastResult),this.outputType===ft.SVG){const a=i.svgSketch;return this.outputElement.appendChild(a),this.lastResult=a,Promise.resolve(a)}{const a=document.createElement("canvas");return this.outputElement.appendChild(a),this.lastResult=a,this.drawToCanvas(i,a)}}createRenderContext(e){if(!this.svg)throw new Error("No source SVG set yet.");let n=this.roughConfig;return this.seed!==null&&(n=Object.assign({seed:this.seed},n)),{rc:Hr.svg(e,{options:n}),roughConfig:this.roughConfig,fontFamily:this.fontFamily,pencilFilter:this.pencilFilter,randomize:this.randomize,rng:new Cs(this.seed),sketchPatterns:this.sketchPatterns,idElements:this.idElements,sourceSvg:this.svg,svgSketch:e,svgSketchIsInDOM:document.body.contains(e),styleSheets:Array.from(this.svg.querySelectorAll("style")).map(r=>r.sheet).filter(r=>r!==null),processElement:Dn}}drawToCanvas(e,n){n.width=this.width,n.height=this.height;const r=n.getContext("2d");return r.clearRect(0,0,this.width,this.height),new Promise(s=>{const i=new XMLSerializer().serializeToString(e.svgSketch),a=new Image;a.onload=function(){r.drawImage(this,0,0),s(n)},a.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(i)}`})}prepareRenderContainer(){let e,n;for(e=this.outputElement instanceof SVGSVGElement?this.outputElement:document.createElementNS("http://www.w3.org/2000/svg","svg"),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink");e.firstChild;)e.removeChild(e.firstChild);return e.setAttribute("width",this.width.toString()),e.setAttribute("height",this.height.toString()),this.backgroundColor&&(n=document.createElementNS("http://www.w3.org/2000/svg","rect"),n.width.baseVal.value=this.width,n.height.baseVal.value=this.height,n.setAttribute("fill",this.backgroundColor),e.appendChild(n)),e.setAttribute("stroke-linecap","round"),e}sourceSvgChanged(){const e=this.$svg;if(e){const n=this.roughConfig.fixedDecimalPlaceDigits;this.width=parseFloat(this.coerceSize(e,"width",300).toFixed(n)),this.height=parseFloat(this.coerceSize(e,"height",150).toFixed(n)),this.collectElementsWithID()}}collectElementsWithID(){this.idElements={};const e=Array.prototype.slice.apply(this.svg.querySelectorAll("*[id]"));for(const n of e){const r=n.getAttribute("id");r&&(this.idElements[r]=n)}}coerceSize(e,n,r){let s=r;const i=e.hasAttribute("viewBox");return e.hasAttribute(n)?s=e[n].baseVal.unitType===SVGLength.SVG_LENGTHTYPE_PERCENTAGE&&i?e.viewBox.baseVal[n]:e[n].baseVal.value:i&&(s=e.viewBox.baseVal[n]),s}}function dn(t){let e,n,r,s;function i(u,l){return u[5].autoSync?ks:Ts}let a=i(t),o=a(t);return{c(){e=Ct("div"),n=yt("Diagram out of sync. "),r=Ct("br"),s=mn(),o.c(),this.h()},l(u){e=Ot(u,"DIV",{class:!0,id:!0});var l=It(e);n=xt(l,"Diagram out of sync. "),r=Ot(l,"BR",{}),s=gn(l),o.l(l),l.forEach(W),this.h()},h(){wt(e,"class","font-monotext-yellow-600 absolute z-10 w-full bg-base-100 bg-opacity-80 p-2 text-left"),wt(e,"id","errorContainer")},m(u,l){ut(u,e,l),Et(e,n),Et(e,r),Et(e,s),o.m(e,null)},p(u,l){a!==(a=i(u))&&(o.d(1),o=a(u),o&&(o.c(),o.m(e,null)))},d(u){u&&W(e),o.d()}}}function Ts(t){let e,n,r,s,i,a,o;return{c(){e=yt("Press "),n=Ct("i"),r=yt(" (Sync button) or "),s=Ct("kbd"),i=yt(Ie),a=yt(" + Enter"),o=yt(" to sync."),this.h()},l(u){e=xt(u,"Press "),n=Ot(u,"I",{class:!0}),It(n).forEach(W),r=xt(u," (Sync button) or "),s=Ot(u,"KBD",{});var l=It(s);i=xt(l,Ie),a=xt(l," + Enter"),l.forEach(W),o=xt(u," to sync."),this.h()},h(){wt(n,"class","fas fa-sync")},m(u,l){ut(u,e,l),ut(u,n,l),ut(u,r,l),ut(u,s,l),Et(s,i),Et(s,a),ut(u,o,l)},d(u){u&&(W(e),W(n),W(r),W(s),W(o))}}}function ks(t){let e;return{c(){e=yt("It will be updated automatically.")},l(n){e=xt(n,"It will be updated automatically.")},m(n,r){ut(n,e,r)},d(n){n&&W(e)}}}function Ns(t){let e,n,r,s=t[3]&&dn(t);return{c(){s&&s.c(),e=mn(),n=Ct("div"),r=Ct("div"),this.h()},l(i){s&&s.l(i),e=gn(i),n=Ot(i,"DIV",{id:!0,class:!0});var a=It(n);r=Ot(a,"DIV",{id:!0,class:!0}),It(r).forEach(W),a.forEach(W),this.h()},h(){wt(r,"id","container"),wt(r,"class","h-full overflow-auto svelte-1ewr4tw"),St(r,"hide",t[4]),wt(n,"id","view"),wt(n,"class","h-full p-2 svelte-1ewr4tw"),St(n,"error",t[2]),St(n,"outOfSync",t[3])},m(i,a){s&&s.m(i,a),ut(i,e,a),ut(i,n,a),Et(n,r),t[6](r),t[7](n)},p(i,[a]){i[3]?s?s.p(i,a):(s=dn(i),s.c(),s.m(e.parentNode,e)):s&&(s.d(1),s=null),a&16&&St(r,"hide",i[4]),a&4&&St(n,"error",i[2]),a&8&&St(n,"outOfSync",i[3])},i:ke,o:ke,d(i){i&&(W(e),W(n)),s&&s.d(i),t[6](null),t[7](null)}}}function Vs(t,e,n){let r,s;Ne(t,pe,x=>n(5,r=x)),Ne(t,re,x=>n(14,s=x));let i="",a="",o,u,l,h=!1,c=!1,p=!1,f=!0,d=r.panZoom,m;const g=()=>{if(!m)return;const x=m.getPan(),_=m.getZoom();Yn({pan:x,zoom:_}),Qn("panZoom")},v=x=>{x.panZoom&&(n(4,p=!0),m==null||m.destroy(),m=void 0,Promise.resolve().then(()=>{const _=document.querySelector("#graph-div");if(!_)return;m=hr(_,{onPan:g,onZoom:g,controlIconsEnabled:!0,fit:!0,center:!0});const{pan:S,zoom:T}=x;S!==void 0&&T!==void 0&&Number.isFinite(T)&&(m.zoom(T),m.pan(S)),n(4,p=!1)}))},y=async x=>{var T;const _=Date.now();if(x.error!==void 0){n(2,h=!0);return}n(2,h=!1);try{if(o&&x&&(x.updateDiagram||x.autoSync)){if(x.autoSync||Ve(re,s.updateDiagram=!1,s),n(3,c=!1),f=!0,i===x.code&&a===x.mermaid&&d===x.panZoom&&u===x.rough)return;if(!er()){n(3,c=!0);return}i=x.code,a=x.mermaid,d=x.panZoom,u=x.rough;const V=(T=l.parentElement)==null?void 0:T.scrollTop;delete o.dataset.processed;const{svg:G,bindFunctions:H}=await jn(Object.assign({},JSON.parse(x.mermaid)),i,"graph-div");if(G.length>0){v(x),n(0,o.innerHTML=G,o);const k=document.querySelector("#graph-div");if(!k)throw new Error("graph-div not found");if(x.rough){const N=new Os("#container");N.svg=k,await N.sketch(),k.remove();const R=document.querySelector("#container > svg");if(!R)throw new Error("sketch not found");const B=R.getAttribute("height"),D=R.getAttribute("width");R.setAttribute("height","100%"),R.setAttribute("width","100%"),R.setAttribute("viewBox",`0 0 ${D} ${B}`),R.style.maxWidth="100%"}else k.setAttribute("height","100%"),k.style.maxWidth="100%",H&&H(k)}l.parentElement&&V&&n(1,l.parentElement.scrollTop=V,l),n(2,h=!1)}else f?f=!1:(i!==x.code||a!==x.mermaid)&&n(3,c=!0)}catch(V){console.error("view fail",V),n(2,h=!0)}const S=Date.now()-_;Xn({code:i,renderTime:S,isRough:x.rough}),tr(S,()=>{Ve(re,s.updateDiagram=!0,s)})};Un(()=>{pe.subscribe(x=>{y(x)}),window.addEventListener("resize",()=>{r.panZoom&&m&&m.resize()})});function C(x){Pe[x?"unshift":"push"](()=>{o=x,n(0,o)})}function M(x){Pe[x?"unshift":"push"](()=>{l=x,n(1,l)})}return[o,l,h,c,p,r,C,M]}class Ls extends Gn{constructor(e){super(),qn(this,e,Vs,Ns,Bn,{})}}export{Ls as V,zs as w};