@equinor/esv-intersection 4.1.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1082 -1162
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1 -14
- package/dist/index.umd.js.map +1 -1
- package/package.json +14 -14
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("pixi.js");function Ms(e){return e}var Ve=1,he=2,nn=3,ne=4,jn=1e-6;function As(e){return"translate("+e+",0)"}function Ps(e){return"translate(0,"+e+")"}function Cs(e){return t=>+e(t)}function Ls(e,t){return t=Math.max(0,e.bandwidth()-t*2)/2,e.round()&&(t=Math.round(t)),n=>+e(n)+t}function ks(){return!this.__axis}function Ui(e,t){var n=[],i=null,r=null,s=6,o=6,a=3,c=typeof window<"u"&&window.devicePixelRatio>1?0:.5,h=e===Ve||e===ne?-1:1,l=e===ne||e===he?"x":"y",u=e===Ve||e===nn?As:Ps;function f(d){var p=i??(t.ticks?t.ticks.apply(t,n):t.domain()),g=r??(t.tickFormat?t.tickFormat.apply(t,n):Ms),y=Math.max(s,0)+a,m=t.range(),_=+m[0]+c,v=+m[m.length-1]+c,M=(t.bandwidth?Ls:Cs)(t.copy(),c),b=d.selection?d.selection():d,T=b.selectAll(".domain").data([null]),S=b.selectAll(".tick").data(p,t).order(),C=S.exit(),k=S.enter().append("g").attr("class","tick"),I=S.select("line"),P=S.select("text");T=T.merge(T.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),S=S.merge(k),I=I.merge(k.append("line").attr("stroke","currentColor").attr(l+"2",h*s)),P=P.merge(k.append("text").attr("fill","currentColor").attr(l,h*y).attr("dy",e===Ve?"0em":e===nn?"0.71em":"0.32em")),d!==b&&(T=T.transition(d),S=S.transition(d),I=I.transition(d),P=P.transition(d),C=C.transition(d).attr("opacity",jn).attr("transform",function(O){return isFinite(O=M(O))?u(O+c):this.getAttribute("transform")}),k.attr("opacity",jn).attr("transform",function(O){var $=this.parentNode.__axis;return u(($&&isFinite($=$(O))?$:M(O))+c)})),C.remove(),T.attr("d",e===ne||e===he?o?"M"+h*o+","+_+"H"+c+"V"+v+"H"+h*o:"M"+c+","+_+"V"+v:o?"M"+_+","+h*o+"V"+c+"H"+v+"V"+h*o:"M"+_+","+c+"H"+v),S.attr("opacity",1).attr("transform",function(O){return u(M(O)+c)}),I.attr(l+"2",h*s),P.attr(l,h*y).text(g),b.filter(ks).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",e===he?"start":e===ne?"end":"middle"),b.each(function(){this.__axis=M})}return f.scale=function(d){return arguments.length?(t=d,f):t},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(d){return arguments.length?(n=d==null?[]:Array.from(d),f):n.slice()},f.tickValues=function(d){return arguments.length?(i=d==null?null:Array.from(d),f):i&&i.slice()},f.tickFormat=function(d){return arguments.length?(r=d,f):r},f.tickSize=function(d){return arguments.length?(s=o=+d,f):s},f.tickSizeInner=function(d){return arguments.length?(s=+d,f):s},f.tickSizeOuter=function(d){return arguments.length?(o=+d,f):o},f.tickPadding=function(d){return arguments.length?(a=+d,f):a},f.offset=function(d){return arguments.length?(c=+d,f):c},f}function Es(e){return Ui(he,e)}function Fs(e){return Ui(nn,e)}function le(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Rs(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Vi(e){let t,n,i;e.length!==2?(t=le,n=(a,c)=>le(e(a),c),i=(a,c)=>e(a)-c):(t=e===le||e===Rs?e:Is,n=e,i=e);function r(a,c,h=0,l=a.length){if(h<l){if(t(c,c)!==0)return l;do{const u=h+l>>>1;n(a[u],c)<0?h=u+1:l=u}while(h<l)}return h}function s(a,c,h=0,l=a.length){if(h<l){if(t(c,c)!==0)return l;do{const u=h+l>>>1;n(a[u],c)<=0?h=u+1:l=u}while(h<l)}return h}function o(a,c,h=0,l=a.length){const u=r(a,c,h,l-1);return u>h&&i(a[u-1],c)>-i(a[u],c)?u-1:u}return{left:r,center:o,right:s}}function Is(){return 0}function Os(e){return e===null?NaN:+e}const zs=Vi(le),Ds=zs.right;Vi(Os).center;class Zn extends Map{constructor(t,n=Bs){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[i,r]of t)this.set(i,r)}get(t){return super.get(Kn(this,t))}has(t){return super.has(Kn(this,t))}set(t,n){return super.set(Ns(this,t),n)}delete(t){return super.delete($s(this,t))}}function Kn({_intern:e,_key:t},n){const i=t(n);return e.has(i)?e.get(i):n}function Ns({_intern:e,_key:t},n){const i=t(n);return e.has(i)?e.get(i):(e.set(i,n),n)}function $s({_intern:e,_key:t},n){const i=t(n);return e.has(i)&&(n=e.get(n),e.delete(i)),n}function Bs(e){return e!==null&&typeof e=="object"?e.valueOf():e}const Hs=Math.sqrt(50),Xs=Math.sqrt(10),Us=Math.sqrt(2);function _e(e,t,n){const i=(t-e)/Math.max(0,n),r=Math.floor(Math.log10(i)),s=i/Math.pow(10,r),o=s>=Hs?10:s>=Xs?5:s>=Us?2:1;let a,c,h;return r<0?(h=Math.pow(10,-r)/o,a=Math.round(e*h),c=Math.round(t*h),a/h<e&&++a,c/h>t&&--c,h=-h):(h=Math.pow(10,r)*o,a=Math.round(e/h),c=Math.round(t/h),a*h<e&&++a,c*h>t&&--c),c<a&&.5<=n&&n<2?_e(e,t,n*2):[a,c,h]}function Vs(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];const i=t<e,[r,s,o]=i?_e(t,e,n):_e(e,t,n);if(!(s>=r))return[];const a=s-r+1,c=new Array(a);if(i)if(o<0)for(let h=0;h<a;++h)c[h]=(s-h)/-o;else for(let h=0;h<a;++h)c[h]=(s-h)*o;else if(o<0)for(let h=0;h<a;++h)c[h]=(r+h)/-o;else for(let h=0;h<a;++h)c[h]=(r+h)*o;return c}function rn(e,t,n){return t=+t,e=+e,n=+n,_e(e,t,n)[2]}function Ws(e,t,n){t=+t,e=+e,n=+n;const i=t<e,r=i?rn(t,e,n):rn(e,t,n);return(i?-1:1)*(r<0?1/-r:r)}function sn(e,t){let n;if(t===void 0)for(const i of e)i!=null&&(n<i||n===void 0&&i>=i)&&(n=i);else{let i=-1;for(let r of e)(r=t(r,++i,e))!=null&&(n<r||n===void 0&&r>=r)&&(n=r)}return n}function We(e,t){let n=0;if(t===void 0)for(let i of e)(i=+i)&&(n+=i);else{let i=-1;for(let r of e)(r=+t(r,++i,e))&&(n+=r)}return n}function Wi(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}const Qn=Symbol("implicit");function Yi(){var e=new Zn,t=[],n=[],i=Qn;function r(s){let o=e.get(s);if(o===void 0){if(i!==Qn)return i;e.set(s,o=t.push(s)-1)}return n[o%n.length]}return r.domain=function(s){if(!arguments.length)return t.slice();t=[],e=new Zn;for(const o of s)e.has(o)||e.set(o,t.push(o)-1);return r},r.range=function(s){return arguments.length?(n=Array.from(s),r):n.slice()},r.unknown=function(s){return arguments.length?(i=s,r):i},r.copy=function(){return Yi(t,n).unknown(i)},Wi.apply(r,arguments),r}function Cn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Gi(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function Qt(){}var qt=.7,xe=1/qt,Ot="\\s*([+-]?\\d+)\\s*",jt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ct="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ys=/^#([0-9a-f]{3,8})$/,Gs=new RegExp(`^rgb\\(${Ot},${Ot},${Ot}\\)$`),qs=new RegExp(`^rgb\\(${ct},${ct},${ct}\\)$`),js=new RegExp(`^rgba\\(${Ot},${Ot},${Ot},${jt}\\)$`),Zs=new RegExp(`^rgba\\(${ct},${ct},${ct},${jt}\\)$`),Ks=new RegExp(`^hsl\\(${jt},${ct},${ct}\\)$`),Qs=new RegExp(`^hsla\\(${jt},${ct},${ct},${jt}\\)$`),Jn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Cn(Qt,gt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ti,formatHex:ti,formatHex8:Js,formatHsl:to,formatRgb:ei,toString:ei});function ti(){return this.rgb().formatHex()}function Js(){return this.rgb().formatHex8()}function to(){return qi(this).formatHsl()}function ei(){return this.rgb().formatRgb()}function gt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ys.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ni(t):n===3?new q(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ie(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ie(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Gs.exec(e))?new q(t[1],t[2],t[3],1):(t=qs.exec(e))?new q(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=js.exec(e))?ie(t[1],t[2],t[3],t[4]):(t=Zs.exec(e))?ie(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Ks.exec(e))?si(t[1],t[2]/100,t[3]/100,1):(t=Qs.exec(e))?si(t[1],t[2]/100,t[3]/100,t[4]):Jn.hasOwnProperty(e)?ni(Jn[e]):e==="transparent"?new q(NaN,NaN,NaN,0):null}function ni(e){return new q(e>>16&255,e>>8&255,e&255,1)}function ie(e,t,n,i){return i<=0&&(e=t=n=NaN),new q(e,t,n,i)}function eo(e){return e instanceof Qt||(e=gt(e)),e?(e=e.rgb(),new q(e.r,e.g,e.b,e.opacity)):new q}function on(e,t,n,i){return arguments.length===1?eo(e):new q(e,t,n,i??1)}function q(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}Cn(q,on,Gi(Qt,{brighter(e){return e=e==null?xe:Math.pow(xe,e),new q(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?qt:Math.pow(qt,e),new q(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new q(Ct(this.r),Ct(this.g),Ct(this.b),ve(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ii,formatHex:ii,formatHex8:no,formatRgb:ri,toString:ri}));function ii(){return`#${Pt(this.r)}${Pt(this.g)}${Pt(this.b)}`}function no(){return`#${Pt(this.r)}${Pt(this.g)}${Pt(this.b)}${Pt((isNaN(this.opacity)?1:this.opacity)*255)}`}function ri(){const e=ve(this.opacity);return`${e===1?"rgb(":"rgba("}${Ct(this.r)}, ${Ct(this.g)}, ${Ct(this.b)}${e===1?")":`, ${e})`}`}function ve(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ct(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Pt(e){return e=Ct(e),(e<16?"0":"")+e.toString(16)}function si(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new rt(e,t,n,i)}function qi(e){if(e instanceof rt)return new rt(e.h,e.s,e.l,e.opacity);if(e instanceof Qt||(e=gt(e)),!e)return new rt;if(e instanceof rt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),s=Math.max(t,n,i),o=NaN,a=s-r,c=(s+r)/2;return a?(t===s?o=(n-i)/a+(n<i)*6:n===s?o=(i-t)/a+2:o=(t-n)/a+4,a/=c<.5?s+r:2-s-r,o*=60):a=c>0&&c<1?0:o,new rt(o,a,c,e.opacity)}function io(e,t,n,i){return arguments.length===1?qi(e):new rt(e,t,n,i??1)}function rt(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}Cn(rt,io,Gi(Qt,{brighter(e){return e=e==null?xe:Math.pow(xe,e),new rt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?qt:Math.pow(qt,e),new rt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new q(Ye(e>=240?e-240:e+120,r,i),Ye(e,r,i),Ye(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new rt(oi(this.h),re(this.s),re(this.l),ve(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=ve(this.opacity);return`${e===1?"hsl(":"hsla("}${oi(this.h)}, ${re(this.s)*100}%, ${re(this.l)*100}%${e===1?")":`, ${e})`}`}}));function oi(e){return e=(e||0)%360,e<0?e+360:e}function re(e){return Math.max(0,Math.min(1,e||0))}function Ye(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Ln=e=>()=>e;function ro(e,t){return function(n){return e+n*t}}function so(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function oo(e){return(e=+e)==1?ji:function(t,n){return n-t?so(t,n,e):Ln(isNaN(t)?n:t)}}function ji(e,t){var n=t-e;return n?ro(e,n):Ln(isNaN(e)?t:e)}const Zt=(function e(t){var n=oo(t);function i(r,s){var o=n((r=on(r)).r,(s=on(s)).r),a=n(r.g,s.g),c=n(r.b,s.b),h=ji(r.opacity,s.opacity);return function(l){return r.r=o(l),r.g=a(l),r.b=c(l),r.opacity=h(l),r+""}}return i.gamma=e,i})(1);function ao(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),r;return function(s){for(r=0;r<n;++r)i[r]=e[r]*(1-s)+t[r]*s;return i}}function co(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ho(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,r=new Array(i),s=new Array(n),o;for(o=0;o<i;++o)r[o]=kn(e[o],t[o]);for(;o<n;++o)s[o]=t[o];return function(a){for(o=0;o<i;++o)s[o]=r[o](a);return s}}function lo(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function it(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function uo(e,t){var n={},i={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=kn(e[r],t[r]):i[r]=t[r];return function(s){for(r in n)i[r]=n[r](s);return i}}var an=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ge=new RegExp(an.source,"g");function fo(e){return function(){return e}}function po(e){return function(t){return e(t)+""}}function Zi(e,t){var n=an.lastIndex=Ge.lastIndex=0,i,r,s,o=-1,a=[],c=[];for(e=e+"",t=t+"";(i=an.exec(e))&&(r=Ge.exec(t));)(s=r.index)>n&&(s=t.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(i=i[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,c.push({i:o,x:it(i,r)})),n=Ge.lastIndex;return n<t.length&&(s=t.slice(n),a[o]?a[o]+=s:a[++o]=s),a.length<2?c[0]?po(c[0].x):fo(t):(t=c.length,function(h){for(var l=0,u;l<t;++l)a[(u=c[l]).i]=u.x(h);return a.join("")})}function kn(e,t){var n=typeof t,i;return t==null||n==="boolean"?Ln(t):(n==="number"?it:n==="string"?(i=gt(t))?(t=i,Zt):Zi:t instanceof gt?Zt:t instanceof Date?lo:co(t)?ao:Array.isArray(t)?ho:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?uo:it)(e,t)}function go(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var ai=180/Math.PI,cn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ki(e,t,n,i,r,s){var o,a,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*i)&&(n-=e*c,i-=t*c),(a=Math.sqrt(n*n+i*i))&&(n/=a,i/=a,c/=a),e*i<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:r,translateY:s,rotate:Math.atan2(t,e)*ai,skewX:Math.atan(c)*ai,scaleX:o,scaleY:a}}var se;function mo(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?cn:Ki(t.a,t.b,t.c,t.d,t.e,t.f)}function yo(e){return e==null||(se||(se=document.createElementNS("http://www.w3.org/2000/svg","g")),se.setAttribute("transform",e),!(e=se.transform.baseVal.consolidate()))?cn:(e=e.matrix,Ki(e.a,e.b,e.c,e.d,e.e,e.f))}function Qi(e,t,n,i){function r(h){return h.length?h.pop()+" ":""}function s(h,l,u,f,d,p){if(h!==u||l!==f){var g=d.push("translate(",null,t,null,n);p.push({i:g-4,x:it(h,u)},{i:g-2,x:it(l,f)})}else(u||f)&&d.push("translate("+u+t+f+n)}function o(h,l,u,f){h!==l?(h-l>180?l+=360:l-h>180&&(h+=360),f.push({i:u.push(r(u)+"rotate(",null,i)-2,x:it(h,l)})):l&&u.push(r(u)+"rotate("+l+i)}function a(h,l,u,f){h!==l?f.push({i:u.push(r(u)+"skewX(",null,i)-2,x:it(h,l)}):l&&u.push(r(u)+"skewX("+l+i)}function c(h,l,u,f,d,p){if(h!==u||l!==f){var g=d.push(r(d)+"scale(",null,",",null,")");p.push({i:g-4,x:it(h,u)},{i:g-2,x:it(l,f)})}else(u!==1||f!==1)&&d.push(r(d)+"scale("+u+","+f+")")}return function(h,l){var u=[],f=[];return h=e(h),l=e(l),s(h.translateX,h.translateY,l.translateX,l.translateY,u,f),o(h.rotate,l.rotate,u,f),a(h.skewX,l.skewX,u,f),c(h.scaleX,h.scaleY,l.scaleX,l.scaleY,u,f),h=l=null,function(d){for(var p=-1,g=f.length,y;++p<g;)u[(y=f[p]).i]=y.x(d);return u.join("")}}}var _o=Qi(mo,"px, ","px)","deg)"),xo=Qi(yo,", ",")",")"),vo=1e-12;function ci(e){return((e=Math.exp(e))+1/e)/2}function wo(e){return((e=Math.exp(e))-1/e)/2}function bo(e){return((e=Math.exp(2*e))-1)/(e+1)}const So=(function e(t,n,i){function r(s,o){var a=s[0],c=s[1],h=s[2],l=o[0],u=o[1],f=o[2],d=l-a,p=u-c,g=d*d+p*p,y,m;if(g<vo)m=Math.log(f/h)/t,y=function(S){return[a+S*d,c+S*p,h*Math.exp(t*S*m)]};else{var _=Math.sqrt(g),v=(f*f-h*h+i*g)/(2*h*n*_),M=(f*f-h*h-i*g)/(2*f*n*_),b=Math.log(Math.sqrt(v*v+1)-v),T=Math.log(Math.sqrt(M*M+1)-M);m=(T-b)/t,y=function(S){var C=S*m,k=ci(b),I=h/(n*_)*(k*bo(t*C+b)-wo(b));return[a+I*d,c+I*p,h*k/ci(t*C+b)]}}return y.duration=m*1e3*t/Math.SQRT2,y}return r.rho=function(s){var o=Math.max(.001,+s),a=o*o,c=a*a;return e(o,a,c)},r})(Math.SQRT2,2,4);function To(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e(i/(t-1));return n}function Mo(e){return function(){return e}}function Ao(e){return+e}var hi=[0,1];function Ft(e){return e}function hn(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:Mo(isNaN(t)?NaN:.5)}function Po(e,t){var n;return e>t&&(n=e,e=t,t=n),function(i){return Math.max(e,Math.min(t,i))}}function Co(e,t,n){var i=e[0],r=e[1],s=t[0],o=t[1];return r<i?(i=hn(r,i),s=n(o,s)):(i=hn(i,r),s=n(s,o)),function(a){return s(i(a))}}function Lo(e,t,n){var i=Math.min(e.length,t.length)-1,r=new Array(i),s=new Array(i),o=-1;for(e[i]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<i;)r[o]=hn(e[o],e[o+1]),s[o]=n(t[o],t[o+1]);return function(a){var c=Ds(e,a,1,i)-1;return s[c](r[c](a))}}function ko(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function Eo(){var e=hi,t=hi,n=kn,i,r,s,o=Ft,a,c,h;function l(){var f=Math.min(e.length,t.length);return o!==Ft&&(o=Po(e[0],e[f-1])),a=f>2?Lo:Co,c=h=null,u}function u(f){return f==null||isNaN(f=+f)?s:(c||(c=a(e.map(i),t,n)))(i(o(f)))}return u.invert=function(f){return o(r((h||(h=a(t,e.map(i),it)))(f)))},u.domain=function(f){return arguments.length?(e=Array.from(f,Ao),l()):e.slice()},u.range=function(f){return arguments.length?(t=Array.from(f),l()):t.slice()},u.rangeRound=function(f){return t=Array.from(f),n=go,l()},u.clamp=function(f){return arguments.length?(o=f?!0:Ft,l()):o!==Ft},u.interpolate=function(f){return arguments.length?(n=f,l()):n},u.unknown=function(f){return arguments.length?(s=f,u):s},function(f,d){return i=f,r=d,l()}}function Fo(){return Eo()(Ft,Ft)}function Ro(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function we(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,i=e.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+e.slice(n+1)]}function zt(e){return e=we(Math.abs(e)),e?e[1]:NaN}function Io(e,t){return function(n,i){for(var r=n.length,s=[],o=0,a=e[0],c=0;r>0&&a>0&&(c+a+1>i&&(a=Math.max(1,i-c)),s.push(n.substring(r-=a,r+a)),!((c+=a+1)>i));)a=e[o=(o+1)%e.length];return s.reverse().join(t)}}function Oo(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var zo=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function be(e){if(!(t=zo.exec(e)))throw new Error("invalid format: "+e);var t;return new En({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}be.prototype=En.prototype;function En(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}En.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Do(e){t:for(var t=e.length,n=1,i=-1,r;n<t;++n)switch(e[n]){case".":i=r=n;break;case"0":i===0&&(i=n),r=n;break;default:if(!+e[n])break t;i>0&&(i=0);break}return i>0?e.slice(0,i)+e.slice(r+1):e}var Ji;function No(e,t){var n=we(e,t);if(!n)return e+"";var i=n[0],r=n[1],s=r-(Ji=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,o=i.length;return s===o?i:s>o?i+new Array(s-o+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+we(e,Math.max(0,t+s-1))[0]}function li(e,t){var n=we(e,t);if(!n)return e+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const ui={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Ro,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>li(e*100,t),r:li,s:No,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function fi(e){return e}var di=Array.prototype.map,pi=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function $o(e){var t=e.grouping===void 0||e.thousands===void 0?fi:Io(di.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",i=e.currency===void 0?"":e.currency[1]+"",r=e.decimal===void 0?".":e.decimal+"",s=e.numerals===void 0?fi:Oo(di.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",a=e.minus===void 0?"−":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function h(u){u=be(u);var f=u.fill,d=u.align,p=u.sign,g=u.symbol,y=u.zero,m=u.width,_=u.comma,v=u.precision,M=u.trim,b=u.type;b==="n"?(_=!0,b="g"):ui[b]||(v===void 0&&(v=12),M=!0,b="g"),(y||f==="0"&&d==="=")&&(y=!0,f="0",d="=");var T=g==="$"?n:g==="#"&&/[boxX]/.test(b)?"0"+b.toLowerCase():"",S=g==="$"?i:/[%p]/.test(b)?o:"",C=ui[b],k=/[defgprs%]/.test(b);v=v===void 0?6:/[gprs]/.test(b)?Math.max(1,Math.min(21,v)):Math.max(0,Math.min(20,v));function I(P){var O=T,$=S,x,A,w;if(b==="c")$=C(P)+$,P="";else{P=+P;var L=P<0||1/P<0;if(P=isNaN(P)?c:C(Math.abs(P),v),M&&(P=Do(P)),L&&+P==0&&p!=="+"&&(L=!1),O=(L?p==="("?p:a:p==="-"||p==="("?"":p)+O,$=(b==="s"?pi[8+Ji/3]:"")+$+(L&&p==="("?")":""),k){for(x=-1,A=P.length;++x<A;)if(w=P.charCodeAt(x),48>w||w>57){$=(w===46?r+P.slice(x+1):P.slice(x))+$,P=P.slice(0,x);break}}}_&&!y&&(P=t(P,1/0));var E=O.length+P.length+$.length,F=E<m?new Array(m-E+1).join(f):"";switch(_&&y&&(P=t(F+P,F.length?m-$.length:1/0),F=""),d){case"<":P=O+P+$+F;break;case"=":P=O+F+P+$;break;case"^":P=F.slice(0,E=F.length>>1)+O+P+$+F.slice(E);break;default:P=F+O+P+$;break}return s(P)}return I.toString=function(){return u+""},I}function l(u,f){var d=h((u=be(u),u.type="f",u)),p=Math.max(-8,Math.min(8,Math.floor(zt(f)/3)))*3,g=Math.pow(10,-p),y=pi[8+p/3];return function(m){return d(g*m)+y}}return{format:h,formatPrefix:l}}var oe,tr,er;Bo({thousands:",",grouping:[3],currency:["$",""]});function Bo(e){return oe=$o(e),tr=oe.format,er=oe.formatPrefix,oe}function Ho(e){return Math.max(0,-zt(Math.abs(e)))}function Xo(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(zt(t)/3)))*3-zt(Math.abs(e)))}function Uo(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,zt(t)-zt(e))+1}function Vo(e,t,n,i){var r=Ws(e,t,n),s;switch(i=be(i??",f"),i.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return i.precision==null&&!isNaN(s=Xo(r,o))&&(i.precision=s),er(i,o)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(s=Uo(r,Math.max(Math.abs(e),Math.abs(t))))&&(i.precision=s-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(s=Ho(r))&&(i.precision=s-(i.type==="%")*2);break}}return tr(i)}function Wo(e){var t=e.domain;return e.ticks=function(n){var i=t();return Vs(i[0],i[i.length-1],n??10)},e.tickFormat=function(n,i){var r=t();return Vo(r[0],r[r.length-1],n??10,i)},e.nice=function(n){n==null&&(n=10);var i=t(),r=0,s=i.length-1,o=i[r],a=i[s],c,h,l=10;for(a<o&&(h=o,o=a,a=h,h=r,r=s,s=h);l-- >0;){if(h=rn(o,a,n),h===c)return i[r]=o,i[s]=a,t(i);if(h>0)o=Math.floor(o/h)*h,a=Math.ceil(a/h)*h;else if(h<0)o=Math.ceil(o*h)/h,a=Math.floor(a*h)/h;else break;c=h}return e},e}function Lt(){var e=Fo();return e.copy=function(){return ko(e,Lt())},Wi.apply(e,arguments),Wo(e)}class nr{constructor(t,n=!0,i,r,s,o){this._showLabels=!0,this._offsetX=0,this._offsetY=0,this._flipX=!1,this._flipY=!1,this.visible=!0,this.createOrGet=a=>{const{mainGroup:c}=this;let h=c.select(`g.${a}`);return h.empty()&&(h=c.append("g").attr("class",a)),h},this.mainGroup=t,this._showLabels=n,this._labelXDesc=i,this._labelYDesc=r,this._unitOfMeasure=s,o&&o.offsetX&&(this._offsetX=o.offsetX),o&&o.offsetX&&(this._offsetY=o.offsetY),o&&o.visible&&(this.visible=o.visible),this.mainGroup.style("pointer-events","none"),this._scaleX=Lt().domain([0,1]).range([0,1]),this._scaleY=Lt().domain([0,1]).range([0,1])}renderLabelx(){const{_labelXDesc:t,_unitOfMeasure:n,_showLabels:i,_scaleX:r}=this,[,s]=r.range(),o=this.renderGx();let a=o.select("text.axis-labelx");return i?a.empty()&&(a=o.append("text").attr("class","axis-labelx").attr("fill","rgba(0,0,0,0.3)").style("text-anchor","middle").style("font-weight","800").style("font-size","10px").text(`${t} (${n})`)):a.remove(),a.attr("transform",`translate(${s/2},-4)`),a}renderLabely(){const{_labelYDesc:t,_unitOfMeasure:n,_showLabels:i,_scaleY:r}=this,[,s]=r.range(),o=this.renderGy();let a=o.select("text.axis-labely");return i?(a.empty()&&(a=o.append("text").attr("class","axis-labely").attr("fill","rgba(0,0,0,0.3)").style("text-anchor","middle").style("font-weight","800").style("font-size","10px").text(`${t} (${n})`)),a.attr("transform",`translate(-10,${s/2})rotate(90)`)):a.remove(),a}renderGy(){const{_scaleX:t,_scaleY:n}=this,i=Es(n),[,r]=t.range(),s=this.createOrGet("y-axis");return s.call(i),s.attr("transform",`translate(${r},0)`),s}renderGx(){const{_scaleX:t,_scaleY:n}=this,i=Fs(t),[,r]=n.range(),s=this.createOrGet("x-axis");return s.attr("transform",`translate(0 ${r})`),s.call(i),s}render(){this.renderLabelx(),this.renderLabely()}onResize(t){this.mainGroup.attr("height",`${t.height}px`).attr("width",`${t.width}px`)}onRescale(t){const{_scaleX:n,_scaleY:i,offsetX:r,offsetY:s}=this,{xScale:o,yScale:a}=t,c=o.domain(),h=a.domain(),l=o.range(),u=a.range();n.domain([c[0]-r,c[1]-r]).range(l),i.domain([h[0]-s,h[1]-s]).range(u),this.flipX(this._flipX),this.flipY(this._flipY),this.visible&&this.render()}show(){return this.visible=!0,this.mainGroup.attr("visibility","visible"),this.render(),this}hide(){return this.visible=!1,this.mainGroup.attr("visibility","hidden"),this}flipX(t){this._flipX=t;const n=this._scaleX.domain(),i=t?-1:1;return this._scaleX.domain([i*n[0],i*n[1]]),this}flipY(t){this._flipY=t;const n=this._scaleY.domain(),i=t?-1:1;return this._scaleY.domain([i*n[0],i*n[1]]),this}showLabels(){return this._showLabels=!0,this.render(),this}hideLabels(){return this._showLabels=!1,this.render(),this}setLabelX(t){return this._labelXDesc=t,this}setLabelY(t){return this._labelYDesc=t,this}setUnitOfMeasure(t){return this._unitOfMeasure=t,this}setLabels(t,n,i){return this._labelXDesc=t,this._labelYDesc=n,this._unitOfMeasure=i,this}get offsetX(){return this._offsetX}set offsetX(t){this._offsetX=t}get offsetY(){return this._offsetY}set offsetY(t){this._offsetY=t}get scaleX(){return this._scaleX.copy()}get scaleY(){return this._scaleY.copy()}}const Yo=Math.PI/180;function xt(e,t=0,n=1){return e<t?t:e>n?n:e}function Go(e){return e*Yo}function gi(e){const t=new Array(e),n=1/(e-1);t[0]=0;for(let i=1;i<e-1;i++)t[i]=i*n;return t[e-1]=1,t}function Bt(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=e[i]+t[i];return n}function Ht(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=e[i]-t[i];return n}function Tt(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=e[i]*t;return n}function qo(e){for(var t=0,n=0;n<e.length;n++)t+=Math.pow(e[n],2);return t}function Wt(e){var t=qo(e);return t===0?t:Math.sqrt(t)}function mi(e,t){t===void 0&&(t=e);var n=Wt(e);return n===0?jo(0,t):Tt(e,1/n,t)}function jo(e,t){for(var n=0;n<t.length;n++)t[n]=e;return t}function Zo(e,t){for(var n=0,i=0;i<e.length;i++)n+=Math.pow(t[i]-e[i],2);return n===0?n:Math.sqrt(n)}function Ko(e,t){for(var n=0,i=0;i<e.length;i++)n+=e[i]*t[i];return n}function Qo(e,t,n,i){i===void 0&&(i=e);for(var r=xt(n,0,1),s=1-r,o=0;o<e.length;o++)i[o]=e[o]*s+t[o]*r;return i}function Jo(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=t(e[i],i);return n}function yi(e,t){t===void 0&&(t=0),t===void 0&&(t=0);for(var n=0;n<e.length;n++)if(Math.abs(e[n])>t)return!1;return!0}var qe=180/Math.PI,ta=Math.PI/180;function je(e,t,n){var i=Math.cos(t),r=Math.sin(t),s=e[0];return n[0]=i*s-r*e[1],n[1]=r*s+i*e[1],n}function _i(e){return Math.atan2(e[1],e[0])}function Xt(e,t){var n=Math.atan2(t[1],t[0])-Math.atan2(e[1],e[0]);return n>Math.PI?n-=2*Math.PI:n<=-Math.PI&&(n+=2*Math.PI),n}var D=(function(){function e(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.isMutating=!1,this.length=2,typeof t=="number"?typeof n[0]=="number"?(this[0]=t,this[1]=n[0]):(this[0]=t,this[1]=t):"x"in t&&"y"in t?(this[0]=t.x,this[1]=t.y):(this[0]=t[0],this[1]=t[1])}return Object.defineProperty(e.prototype,"x",{get:function(){return this[0]},set:function(t){this[0]=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this[1]},set:function(t){this[1]=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"magnitude",{get:function(){return Wt(this)},set:function(t){var n=Wt(this);Tt(this,t/n,this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mutable",{get:function(){return this.isMutating=!0,this},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"immutable",{get:function(){return this.isMutating=!1,this},enumerable:!1,configurable:!0}),e.prototype.set=function(t,n){return typeof t=="number"?typeof n=="number"?(this[0]=t,this[1]=n):(this[0]=t,this[1]=t):(this[0]=t[0],this[1]=t[1]),this},e.prototype.add=function(t,n){return n===void 0&&(n=0),typeof t=="number"?this.isMutating?Bt(this,[t,n]):Bt(this.clone(),[t,n]):this.isMutating?Bt(this,t):Bt(this.clone(),t)},e.add=function(t,n){var i=new e(t);return Bt(i,n)},e.prototype.sub=function(t,n){return n===void 0&&(n=0),typeof t=="number"?this.isMutating?Ht(this,[t,n]):Ht(this.clone(),[t,n]):this.isMutating?Ht(this,t):Ht(this.clone(),t)},e.sub=function(t,n){var i=new e(t);return Ht(i,n)},e.prototype.subFrom=function(t,n){return n===void 0&&(n=0),typeof t=="number"?this.isMutating?(this[0]=t-this[0],this[1]=n-this[1],this):new e(t-this[0],n-this[1]):this.isMutating?(this[0]=t[0]-this[0],this[1]=t[1]-this[1],this):new e(t[0]-this[0],t[1]-this[1])},e.divide=function(t,n){var i=new e(t);return Tt(i,1/n)},e.multiply=function(t,n){var i=new e(t);return Tt(i,n)},e.prototype.scale=function(t){return Tt(this,t,this.isMutating?this:e.zero)},e.prototype.rescale=function(t){var n=Wt(this);return n<=0?this.isMutating?this:e.zero:Tt(this,t/n,this.isMutating?this:e.zero)},e.prototype.clampMagnitude=function(t){var n=Wt(this);return n>t?Tt(this,t/n,this.isMutating?this:e.zero):this.isMutating?this:this.clone()},e.prototype.rotate=function(t){return je(this,t,this.isMutating?this:e.zero)},e.prototype.rotateDeg=function(t){return je(this,t*ta,this.isMutating?this:e.zero)},e.prototype.rotate90=function(){return t=this,n=this.isMutating?this:e.zero,i=t[0],n[0]=-t[1],n[1]=i,n;var t,n,i},e.prototype.rotate180=function(){return t=this,(n=this.isMutating?this:e.zero)[0]=-t[0],n[1]=-t[1],n;var t,n},e.prototype.rotate270=function(){return t=this,n=this.isMutating?this:e.zero,i=t[0],n[0]=t[1],n[1]=-i,n;var t,n,i},e.prototype.normalize=function(){return mi(this)},e.prototype.normalized=function(){return mi(this,e.zero)},e.distance=function(t,n){return Zo(t,n)},e.dot=function(t,n){return Ko(t,n)},e.cross=function(t,n){return(function(i,r){return i[0]*r[1]-i[1]*r[0]})(t,n)},e.angleRight=function(t){return _i(t)},e.angleRightDeg=function(t){return _i(t)*qe},e.angle=function(t,n){return Math.abs(Xt(t,n))},e.angleDeg=function(t,n){return Math.abs(Xt(t,n))*qe},e.signedAngle=function(t,n){return Xt(t,n)},e.signedAngleDeg=function(t,n){return Xt(t,n)*qe},e.lerp=function(t,n,i){var r=new e(t);return Qo(r,n,i)},e.lerpRot=function(t,n,i){return(function(r,s,o,a){return a===void 0&&(a=r),je(r,o*Xt(r,s),a)})(t,n,i,e.zero)},e.prototype.clone=function(){return new e(this[0],this[1])},e.equals=function(t,n,i){return i===void 0&&(i=0),!(Math.abs(t[0]-n[0])>i)&&!(Math.abs(t[1]-n[1])>i)},e.prototype.equals=function(t,n){return n===void 0&&(n=0),e.equals(this,t,n)},e.isZeroVector=function(t,n){return n===void 0&&(n=0),yi(t,n)},e.prototype.isZeroVector=function(t){return t===void 0&&(t=0),yi(this,t)},e.prototype.toArray=function(){return[this[0],this[1]]},e.prototype.modify=function(t){return Jo(this,t)},e.prototype[Symbol.iterator]=function(){var t=this,n=0;return{next:function(){switch(n++){case 0:return{value:t[0],done:!1};case 1:return{value:t[1],done:!1};default:return{value:-1,done:!0}}}}},Object.defineProperty(e,"zero",{get:function(){return new e(0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"positiveInfinity",{get:function(){return new e(1/0,1/0)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"negativeInfinity",{get:function(){return new e(-1/0,-1/0)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"up",{get:function(){return new e(0,1)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"right",{get:function(){return new e(1,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"down",{get:function(){return new e(0,-1)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"left",{get:function(){return new e(-1,0)},enumerable:!1,configurable:!0}),e})();/*! *****************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */var ln=function(e,t){return ln=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var r in i)i.hasOwnProperty(r)&&(n[r]=i[r])},ln(e,t)};function ir(e,t){function n(){this.constructor=e}ln(e,t),e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Se=function(){return Se=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Se.apply(this,arguments)};function xi(e,t){for(var n=new Array(e.length),i=0;i<e.length;i++)n[i]=2*e[i]-t[i];return n}function un(e,t,n){var i,r,s,o,a=t.length-1;if(n)i=t[e-1<0?a:e-1],r=t[e%t.length],s=t[(e+1)%t.length],o=t[(e+2)%t.length];else{if(e===a)throw Error("There is no spline segment at this index for a closed curve!");r=t[e],s=t[e+1],i=e>0?t[e-1]:xi(r,s),o=e<a-1?t[e+2]:xi(s,r)}return[i,r,s,o]}function ea(e,t,n){n===void 0&&(n=!1);var i=n?t.length:t.length-1;if(e===1)return{index:i-1,weight:1};var r=i*e,s=Math.floor(r);return{index:s,weight:r-s}}function na(e,t){for(var n=0;n<e.length;n++)e[n]=t;return e}function ia(e,t){for(var n=0;n<e.length;n++)e[n]=t(e[n],n);return e}function ra(e,t,n){n===void 0&&(n=0);for(var i=0;i<e.length;i++)n=t(n,e[i],i);return n}function ue(e,t){t=t||new Array(e.length);for(var n=0;n<e.length;n++)t[n]=e[n];return t}function G(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e<t?t:e>n?n:e}function fn(e,t){var n=t[0];if(e>=t[t.length-1])return t.length-1;if(e<=n)return 0;for(var i=0,r=t.length-1;i<=r;){var s=Math.floor((i+r)/2),o=t[s];if(o<e)i=s+1;else{if(!(o>e))return s;r=s-1}}return Math.max(0,r)}var tt=Math.pow(2,-42);function vi(e){var t=Math.pow(Math.abs(e),.3333333333333333);return e<0?-t:t}function rr(e,t,n){if(Math.abs(e)<tt)return Math.abs(t)<tt?[]:[-n/t];var i=t*t-4*e*n;return Math.abs(i)<tt?[-t/(2*e)]:i>0?[(-t+Math.sqrt(i))/(2*e),(-t-Math.sqrt(i))/(2*e)]:[]}function sa(e,t,n,i){if(Math.abs(e)<tt)return rr(t,n,i);var r,s=(3*e*n-t*t)/(3*e*e),o=(2*t*t*t-9*e*t*n+27*e*e*i)/(27*e*e*e);if(Math.abs(s)<tt)r=[vi(-o)];else if(Math.abs(o)<tt)r=[0].concat(s<0?[Math.sqrt(-s),-Math.sqrt(-s)]:[]);else{var a=o*o/4+s*s*s/27;if(Math.abs(a)<tt)r=[-1.5*o/s,3*o/s];else if(a>0)r=[(c=vi(-o/2-Math.sqrt(a)))-s/(3*c)];else{var c=2*Math.sqrt(-s/3),h=Math.acos(3*o/s/c)/3,l=2*Math.PI/3;r=[c*Math.cos(h),c*Math.cos(h-l),c*Math.cos(h-2*l)]}}for(var u=0;u<r.length;u++)r[u]-=t/(3*e);return r}function ae(e,t){if(e.length!==t.length)throw Error("Vectors must be of equal length!");for(var n=0,i=0;i<e.length;i++)n+=e[i]*t[i];return n}function et(e,t,n){if(!(e.length>3)){n=n||new Array(3);var i=e[0],r=e[1],s=e[2]||0,o=t[0],a=t[1],c=t[2]||0;return n[0]=r*c-s*a,n[1]=s*o-i*c,n[2]=i*a-r*o,n}}function sr(e,t){for(var n=0,i=0;i<e.length;i++)n+=(e[i]-t[i])*(e[i]-t[i]);return n}function At(e){for(var t=0,n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t)}function Te(e,t){var n=sr(e,t);return n===0?0:Math.sqrt(n)}function ft(e,t){var n=t?ue(e,t):e,i=ra(n,(function(s,o){return s+Math.pow(o,2)})),r=Math.sqrt(i);return r===0?na(n,0):ia(n,(function(s){return s/r}))}function wi(e,t,n,i){t===void 0&&(t=[0,1,0]),n===void 0&&(n=0);var r=Math.cos(n),s=Math.sin(n),o=1-r,a=e[0],c=e[1],h=e[2],l=t[0],u=t[1],f=t[2],d=o*l,p=o*u;return(i=i||e)[0]=(d*l+r)*a+(d*u-s*f)*c+(d*f+s*u)*h,i[1]=(d*u+s*f)*a+(p*u+r)*c+(p*f-s*l)*h,i[2]=(d*f-s*u)*a+(p*f+s*l)*c+(o*f*f+r)*h,i}function oa(e,t,n,i,r){if(r===void 0&&(r=0),r===0)return[0,1,2,3];var s=function(c,h){return Math.pow(sr(c,h),.5*r)},o=s(t,e),a=s(n,t)+o;return[0,o,a,s(i,n)+a]}function aa(e,t,n,i,r){for(var s=Number.isFinite(r.tension)?r.tension:.5,o=Number.isFinite(r.alpha)?r.alpha:null,a=o>0?oa(e,t,n,i,o):null,c=new Array(e.length),h=0;h<e.length;h++){var l=0,u=0,f=e[h],d=t[h],p=n[h],g=i[h];if(a){var y=a[0],m=a[1],_=a[2],v=a[3];m-_!=0&&(y-m!=0&&y-_!=0&&(l=(1-s)*(_-m)*((f-d)/(y-m)-(f-p)/(y-_)+(d-p)/(m-_))),m-v!=0&&_-v!=0&&(u=(1-s)*(_-m)*((d-p)/(m-_)-(d-g)/(m-v)+(p-g)/(_-v))))}else l=(1-s)*(p-f)*.5,u=(1-s)*(g-d)*.5;var M=2*d-2*p+l+u,b=-3*d+3*p-2*l-u,T=l,S=d;c[h]=[M,b,T,S]}return c}function Rt(e,t){var n=e*e,i=e*n;return t[0]*i+t[1]*n+t[2]*e+t[3]}function It(e,t){var n=e*e;return 3*t[0]*n+2*t[1]*e+t[2]}function Ze(e,t){return 6*t[0]*e+2*t[1]}function ca(e,t){var n=t[0],i=t[1],r=t[2],s=t[3]-e;return n===0&&i===0&&r===0&&s===0?[0]:sa(n,i,r,s).filter((function(o){return o>-tt&&o<=1+tt})).map((function(o){return G(o,0,1)}))}function dn(e,t,n,i){i===void 0&&(i=null),i=i||new Array(n.length);for(var r=0;r<n.length;r++)i[r]=e(t,n[r]);return i}var or=(function(){function e(t){t===void 0&&(t=null),this._alpha=0,this._tension=.5,this._closed=!1,this._onInvalidateCache=null,this._onInvalidateCache=t,this._cache={arcLengths:null,coefficients:null}}return e.prototype._invalidateCache=function(){this.points&&(this._cache={arcLengths:null,coefficients:null},this._onInvalidateCache&&this._onInvalidateCache())},Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(t){Number.isFinite(t)&&t!==this._alpha&&(this._invalidateCache(),this._alpha=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tension",{get:function(){return this._tension},set:function(t){Number.isFinite(t)&&t!==this._tension&&(this._invalidateCache(),this._tension=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"points",{get:function(){return this._points},set:function(t){if(!t||t.length<2)throw Error("At least 2 control points are required!");this._points=t,this._invalidateCache()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"closed",{get:function(){return this._closed},set:function(t){t=!!t,this._closed!==t&&(this._invalidateCache(),this._closed=t)},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this._invalidateCache()},e.prototype.evaluateForT=function(t,n,i){var r=ea(n,this.points,this.closed),s=r.index;return dn(t,r.weight,this.getCoefficients(s),i)},e.prototype.getCoefficients=function(t){if(this.points){if(this._cache.coefficients||(this._cache.coefficients=new Map),!this._cache.coefficients.has(t)){var n=un(t,this.points,this.closed),i=aa(n[0],n[1],n[2],n[3],{tension:this.tension,alpha:this.alpha});this._cache.coefficients.set(t,i)}return this._cache.coefficients.get(t)}},e})(),ha=(function(e){function t(n,i){n===void 0&&(n=300),i===void 0&&(i=null);var r=e.call(this,i)||this;return r._subDivisions=n,r}return ir(t,e),Object.defineProperty(t.prototype,"arcLengths",{get:function(){return this._cache.arcLengths||(this._cache.arcLengths=this.computeArcLengths()),this._cache.arcLengths},enumerable:!1,configurable:!0}),t.prototype._invalidateCache=function(){e.prototype._invalidateCache.call(this),this._cache.arcLengths=null},t.prototype.computeArcLengths=function(){var n,i=[],r=this.evaluateForT(Rt,0),s=0;i.push(0);for(var o=1;o<=this._subDivisions;o++)s+=Te(n=this.evaluateForT(Rt,o/this._subDivisions),r),i.push(s),r=n;return i},t.prototype.lengthAt=function(n){var i=this.arcLengths;return n*i[i.length-1]},t.prototype.getT=function(n){var i=this.arcLengths,r=i.length,s=n*i[r-1],o=fn(s,i);if(i[o]===s)return o/(r-1);var a=i[o];return(o+(s-a)/(i[o+1]-a))/(r-1)},t.prototype.getU=function(n){if(n===0)return 0;if(n===1)return 1;var i=this.arcLengths,r=i.length-1,s=i[r],o=n*r,a=Math.floor(o),c=i[a];if(o===a)return c/s;var h=a/r;return(c+Te(this.evaluateForT(Rt,h),this.evaluateForT(Rt,n)))/s},t})(or),ar=[[[-.906179845938664,.23692688505618908],[-.5384693101056831,.47862867049936647],[0,.5688888888888889],[.5384693101056831,.47862867049936647],[.906179845938664,.23692688505618908]],[[-.932469514203152,.17132449237917036],[-.6612093864662645,.3607615730481386],[-.2386191860831969,.46791393457269104],[.2386191860831969,.46791393457269104],[.6612093864662645,.3607615730481386],[.932469514203152,.17132449237917036]],[[-.9491079123427585,.1294849661688697],[-.7415311855993945,.27970539148927664],[-.4058451513773972,.3818300505051189],[0,.4179591836734694],[.4058451513773972,.3818300505051189],[.7415311855993945,.27970539148927664],[.9491079123427585,.1294849661688697]],[[-.9602898564975363,.10122853629037626],[-.7966664774136267,.22238103445337448],[-.525532409916329,.31370664587788727],[-.1834346424956498,.362683783378362],[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],[[-.9681602395076261,.08127438836157441],[-.8360311073266358,.1806481606948574],[-.6133714327005904,.26061069640293544],[-.3242534234038089,.31234707704000286],[0,.3302393550012598],[.3242534234038089,.31234707704000286],[.6133714327005904,.26061069640293544],[.8360311073266358,.1806481606948574],[.9681602395076261,.08127438836157441]],[[-.9739065285171717,.06667134430868814],[-.8650633666889845,.1494513491505806],[-.6794095682990244,.21908636251598204],[-.4333953941292472,.26926671930999635],[-.14887433898163122,.29552422471475287],[.14887433898163122,.29552422471475287],[.4333953941292472,.26926671930999635],[.6794095682990244,.21908636251598204],[.8650633666889845,.1494513491505806],[.9739065285171717,.06667134430868814]],[[-.978228658146056,.0556685671161736],[-.887062599768095,.125580369464904],[-.730152005574049,.186290210927734],[-.519096129206811,.23319376459199],[-.269543155952344,.262804544510246],[0,.2729250867779],[.269543155952344,.262804544510246],[.519096129206811,.23319376459199],[.730152005574049,.186290210927734],[.887062599768095,.125580369464904],[.978228658146056,.0556685671161736]],[[-.981560634246719,.0471753363865118],[-.904117256370474,.106939325995318],[-.769902674194304,.160078328543346],[-.587317954286617,.203167426723065],[-.36783149899818,.233492536538354],[-.125233408511468,.249147045813402],[.125233408511468,.249147045813402],[.36783149899818,.233492536538354],[.587317954286617,.203167426723065],[.769902674194304,.160078328543346],[.904117256370474,.106939325995318],[.981560634246719,.0471753363865118]],[[-.984183054718588,.0404840047653158],[-.917598399222977,.0921214998377284],[-.801578090733309,.138873510219787],[-.64234933944034,.178145980761945],[-.448492751036446,.207816047536888],[-.230458315955134,.226283180262897],[0,.232551553230873],[.230458315955134,.226283180262897],[.448492751036446,.207816047536888],[.64234933944034,.178145980761945],[.801578090733309,.138873510219787],[.917598399222977,.0921214998377284],[.984183054718588,.0404840047653158]],[[-.986283808696812,.0351194603317518],[-.928434883663573,.0801580871597602],[-.827201315069764,.121518570687903],[-.687292904811685,.157203167158193],[-.515248636358154,.185538397477937],[-.319112368927889,.205198463721295],[-.108054948707343,.215263853463157],[.108054948707343,.215263853463157],[.319112368927889,.205198463721295],[.515248636358154,.185538397477937],[.687292904811685,.157203167158193],[.827201315069764,.121518570687903],[.928434883663573,.0801580871597602],[.986283808696812,.0351194603317518]],[[-.987992518020485,.0307532419961172],[-.937273392400705,.0703660474881081],[-.848206583410427,.107159220467171],[-.72441773136017,.139570677926154],[-.570972172608538,.166269205816993],[-.394151347077563,.186161000015562],[-.201194093997434,.198431485327111],[0,.202578241925561],[.201194093997434,.198431485327111],[.394151347077563,.186161000015562],[.570972172608538,.166269205816993],[.72441773136017,.139570677926154],[.848206583410427,.107159220467171],[.937273392400705,.0703660474881081],[.987992518020485,.0307532419961172]],[[-.989400934991649,.027152459411754],[-.944575023073232,.0622535239386478],[-.865631202387831,.0951585116824927],[-.755404408355003,.124628971255533],[-.617876244402643,.149595988816576],[-.458016777657227,.169156519395002],[-.281603550779258,.182603415044923],[-.0950125098376374,.189450610455068],[.0950125098376374,.189450610455068],[.281603550779258,.182603415044923],[.458016777657227,.169156519395002],[.617876244402643,.149595988816576],[.755404408355003,.124628971255533],[.865631202387831,.0951585116824927],[.944575023073232,.0622535239386478],[.989400934991649,.027152459411754]],[[-.990575475314417,.0241483028685479],[-.950675521768767,.0554595293739872],[-.880239153726985,.0850361483171791],[-.781514003896801,.111883847193403],[-.65767115921669,.135136368468525],[-.512690537086476,.15404576107681],[-.351231763453876,.16800410215645],[-.178484181495847,.176562705366992],[0,.179446470356206],[.178484181495847,.176562705366992],[.351231763453876,.16800410215645],[.512690537086476,.15404576107681],[.65767115921669,.135136368468525],[.781514003896801,.111883847193403],[.880239153726985,.0850361483171791],[.950675521768767,.0554595293739872],[.990575475314417,.0241483028685479]],[[-.99156516842093,.0216160135264833],[-.955823949571397,.0497145488949698],[-.892602466497555,.076425730254889],[-.803704958972523,.100942044106287],[-.691687043060353,.122555206711478],[-.559770831073947,.14064291467065],[-.411751161462842,.154684675126265],[-.251886225691505,.164276483745832],[-.0847750130417353,.169142382963143],[.0847750130417353,.169142382963143],[.251886225691505,.164276483745832],[.411751161462842,.154684675126265],[.559770831073947,.14064291467065],[.691687043060353,.122555206711478],[.803704958972523,.100942044106287],[.892602466497555,.076425730254889],[.955823949571397,.0497145488949697],[.99156516842093,.0216160135264833]],[[-.992406843843584,.0194617882297264],[-.96020815213483,.0448142267656996],[-.903155903614817,.0690445427376412],[-.822714656537142,.0914900216224499],[-.720966177335229,.111566645547333],[-.600545304661681,.128753962539336],[-.46457074137596,.142606702173606],[-.316564099963629,.152766042065859],[-.160358645640225,.158968843393954],[0,.161054449848783],[.160358645640225,.158968843393954],[.316564099963629,.152766042065859],[.46457074137596,.142606702173606],[.600545304661681,.128753962539336],[.720966177335229,.111566645547333],[.822714656537142,.0914900216224499],[.903155903614817,.0690445427376412],[.96020815213483,.0448142267656996],[.992406843843584,.0194617882297264]],[[-.993128599185094,.0176140071391521],[-.963971927277913,.0406014298003869],[-.912234428251325,.062672048334109],[-.839116971822218,.0832767415767047],[-.74633190646015,.10193011981724],[-.636053680726515,.118194531961518],[-.510867001950827,.131688638449176],[-.373706088715419,.142096109318382],[-.227785851141645,.149172986472603],[-.0765265211334973,.152753387130725],[.0765265211334973,.152753387130725],[.227785851141645,.149172986472603],[.373706088715419,.142096109318382],[.510867001950827,.131688638449176],[.636053680726515,.118194531961518],[.74633190646015,.10193011981724],[.839116971822218,.0832767415767047],[.912234428251325,.062672048334109],[.963971927277913,.0406014298003869],[.993128599185094,.0176140071391521]],[[-.993752170620389,.0160172282577743],[-.967226838566306,.0369537897708524],[-.9200993341504,.0571344254268572],[-.853363364583317,.0761001136283793],[-.768439963475677,.0934444234560338],[-.667138804197412,.108797299167148],[-.551618835887219,.121831416053728],[-.424342120207438,.132268938633337],[-.288021316802401,.139887394791073],[-.145561854160895,.14452440398997],[0,.14608113364969],[.145561854160895,.14452440398997],[.288021316802401,.139887394791073],[.424342120207438,.132268938633337],[.551618835887219,.121831416053728],[.667138804197412,.108797299167148],[.768439963475677,.0934444234560338],[.853363364583317,.0761001136283793],[.9200993341504,.0571344254268572],[.967226838566306,.0369537897708524],[.993752170620389,.0160172282577743]],[[-.994294585482399,.0146279952982722],[-.970060497835428,.0337749015848141],[-.926956772187174,.0522933351526832],[-.8658125777203,.0697964684245204],[-.787816805979208,.0859416062170677],[-.694487263186682,.10041414444288],[-.587640403506911,.112932296080539],[-.469355837986757,.123252376810512],[-.341935820892084,.131173504787062],[-.207860426688221,.136541498346015],[-.0697392733197222,.139251872855631],[.0697392733197222,.139251872855631],[.207860426688221,.136541498346015],[.341935820892084,.131173504787062],[.469355837986757,.123252376810512],[.587640403506911,.112932296080539],[.694487263186682,.10041414444288],[.787816805979208,.0859416062170677],[.8658125777203,.0697964684245204],[.926956772187174,.0522933351526832],[.970060497835428,.0337749015848141],[.994294585482399,.0146279952982722]],[[-.994769334997552,.0134118594871417],[-.972542471218115,.0309880058569794],[-.932971086826016,.0480376717310846],[-.876752358270441,.0642324214085258],[-.804888401618839,.0792814117767189],[-.71866136313195,.0929157660600351],[-.619609875763646,.104892091464541],[-.509501477846007,.114996640222411],[-.39030103803029,.123049084306729],[-.264135680970344,.128905722188082],[-.133256824298466,.132462039404696],[0,.133654572186106],[.133256824298466,.132462039404696],[.264135680970344,.128905722188082],[.39030103803029,.123049084306729],[.509501477846007,.114996640222411],[.619609875763646,.104892091464541],[.71866136313195,.0929157660600351],[.804888401618839,.0792814117767189],[.876752358270441,.0642324214085258],[.932971086826016,.0480376717310846],[.972542471218115,.0309880058569794],[.994769334997552,.0134118594871417]],[[-.995187219997021,.0123412297999872],[-.974728555971309,.0285313886289336],[-.938274552002732,.0442774388174198],[-.886415527004401,.0592985849154367],[-.820001985973902,.0733464814110803],[-.740124191578554,.0861901615319532],[-.648093651936975,.0976186521041138],[-.545421471388839,.107444270115965],[-.433793507626045,.115505668053725],[-.315042679696163,.121670472927803],[-.191118867473616,.125837456346828],[-.0640568928626056,.127938195346752],[.0640568928626056,.127938195346752],[.191118867473616,.125837456346828],[.315042679696163,.121670472927803],[.433793507626045,.115505668053725],[.545421471388839,.107444270115965],[.648093651936975,.0976186521041138],[.740124191578554,.0861901615319532],[.820001985973902,.0733464814110803],[.886415527004401,.0592985849154367],[.938274552002732,.0442774388174198],[.974728555971309,.0285313886289336],[.995187219997021,.0123412297999872]],[[-.995556969790498,.0113937985010262],[-.976663921459517,.0263549866150321],[-.942974571228974,.0409391567013063],[-.894991997878275,.0549046959758351],[-.833442628760834,.0680383338123569],[-.759259263037357,.080140700335001],[-.673566368473468,.0910282619829636],[-.577662930241222,.10053594906705],[-.473002731445714,.108519624474263],[-.361172305809387,.114858259145711],[-.243866883720988,.119455763535784],[-.12286469261071,.12224244299031],[0,.123176053726715],[.12286469261071,.12224244299031],[.243866883720988,.119455763535784],[.361172305809387,.114858259145711],[.473002731445714,.108519624474263],[.577662930241222,.10053594906705],[.673566368473468,.0910282619829636],[.759259263037357,.080140700335001],[.833442628760834,.0680383338123569],[.894991997878275,.0549046959758351],[.942974571228974,.0409391567013063],[.976663921459517,.0263549866150321],[.995556969790498,.0113937985010262]],[[-.995885701145616,.010551372617343],[-.97838544595647,.0244178510926319],[-.947159066661714,.0379623832943627],[-.902637861984307,.0509758252971478],[-.845445942788498,.0632740463295748],[-.776385948820678,.0746841497656597],[-.696427260419957,.0850458943134852],[-.606692293017618,.0942138003559141],[-.508440714824505,.102059161094425],[-.403051755123486,.108471840528576],[-.292004839485956,.113361816546319],[-.17685882035689,.116660443485296],[-.0592300934293132,.118321415279262],[.0592300934293132,.118321415279262],[.17685882035689,.116660443485296],[.292004839485956,.113361816546319],[.403051755123486,.108471840528576],[.508440714824505,.102059161094425],[.606692293017618,.0942138003559141],[.696427260419957,.0850458943134852],[.776385948820678,.0746841497656597],[.845445942788498,.0632740463295748],[.902637861984307,.0509758252971478],[.947159066661714,.0379623832943627],[.97838544595647,.0244178510926319],[.995885701145616,.010551372617343]],[[-.996179262888988,.00979899605129436],[-.979923475961501,.0226862315961806],[-.950900557814705,.0352970537574197],[-.909482320677491,.047449412520615],[-.856207908018294,.0589835368598335],[-.791771639070508,.0697488237662455],[-.717013473739423,.0796048677730577],[-.632907971946495,.0884231585437569],[-.540551564579456,.0960887273700285],[-.441148251750026,.102501637817745],[-.335993903638508,.107578285788533],[-.226459365439536,.111252488356845],[-.113972585609529,.113476346108965],[0,.114220867378956],[.113972585609529,.113476346108965],[.226459365439536,.111252488356845],[.335993903638508,.107578285788533],[.441148251750026,.102501637817745],[.540551564579456,.0960887273700285],[.632907971946495,.0884231585437569],[.717013473739423,.0796048677730577],[.791771639070508,.0697488237662455],[.856207908018294,.0589835368598336],[.909482320677491,.047449412520615],[.950900557814705,.0352970537574197],[.979923475961501,.0226862315961806],[.996179262888988,.00979899605129436]],[[-.996442497573954,.00912428259309452],[-.981303165370872,.0211321125927712],[-.954259280628938,.0329014277823043],[-.915633026392132,.0442729347590042],[-.865892522574395,.0551073456757167],[-.805641370917179,.0652729239669995],[-.735610878013631,.0746462142345687],[-.656651094038864,.0831134172289012],[-.569720471811401,.0905717443930328],[-.475874224955118,.0969306579979299],[-.376251516089078,.10211296757806],[-.272061627635178,.106055765922846],[-.16456928213338,.108711192258294],[-.0550792898840342,.110047013016475],[.0550792898840342,.110047013016475],[.16456928213338,.108711192258294],[.272061627635178,.106055765922846],[.376251516089078,.10211296757806],[.475874224955118,.0969306579979299],[.569720471811401,.0905717443930328],[.656651094038864,.0831134172289012],[.735610878013631,.0746462142345687],[.805641370917179,.0652729239669995],[.865892522574395,.0551073456757167],[.915633026392132,.0442729347590042],[.954259280628938,.0329014277823043],[.981303165370872,.0211321125927712],[.996442497573954,.00912428259309452]],[[-.996679442260596,.00851690387874641],[-.982545505261413,.0197320850561227],[-.957285595778087,.0307404922020936],[-.921180232953058,.0414020625186828],[-.874637804920102,.0515948269024979],[-.818185487615252,.0612030906570791],[-.752462851734477,.0701179332550512],[-.678214537602686,.0782383271357637],[-.596281797138227,.0854722573661725],[-.507592955124227,.0917377571392587],[-.413152888174008,.0969638340944086],[-.314031637867639,.101091273759914],[-.211352286166001,.104073310077729],[-.106278230132679,.10587615509732],[0,.106479381718314],[.106278230132679,.10587615509732],[.211352286166001,.104073310077729],[.314031637867639,.101091273759914],[.413152888174008,.0969638340944086],[.507592955124227,.0917377571392587],[.596281797138227,.0854722573661725],[.678214537602686,.0782383271357637],[.752462851734477,.0701179332550512],[.818185487615252,.0612030906570791],[.874637804920102,.0515948269024979],[.921180232953058,.0414020625186828],[.957285595778087,.0307404922020936],[.982545505261413,.0197320850561227],[.996679442260596,.00851690387874641]],[[-.996893484074649,.0079681924961666],[-.983668123279747,.0184664683110909],[-.960021864968307,.0287847078833233],[-.926200047429274,.038799192569627],[-.882560535792052,.048402672830594],[-.829565762382768,.057493156217619],[-.767777432104826,.0659742298821805],[-.697850494793315,.0737559747377052],[-.620526182989242,.0807558952294202],[-.536624148142019,.0868997872010829],[-.447033769538089,.0921225222377861],[-.352704725530878,.0963687371746442],[-.254636926167889,.0995934205867952],[-.153869913608583,.101762389748405],[-.0514718425553176,.102852652893558],[.0514718425553176,.102852652893558],[.153869913608583,.101762389748405],[.254636926167889,.0995934205867952],[.352704725530878,.0963687371746442],[.447033769538089,.0921225222377861],[.536624148142019,.0868997872010829],[.620526182989242,.0807558952294202],[.697850494793315,.0737559747377052],[.767777432104826,.0659742298821805],[.829565762382768,.057493156217619],[.882560535792052,.048402672830594],[.926200047429274,.038799192569627],[.960021864968307,.0287847078833233],[.983668123279747,.0184664683110909],[.996893484074649,.0079681924961666]]],bi=ar.length+5,la=(function(e){function t(n,i,r){n===void 0&&(n=24),i===void 0&&(i=21);var s=e.call(this,r)||this;return s._nSamples=21,s._gauss=(function(o){if(o<5||o>bi)throw Error("Order for Gaussian Quadrature must be in the range of ".concat(5," and ").concat(bi,"."));return ar[o-5]})(n),s._nSamples=i,s}return ir(t,e),t.prototype._invalidateCache=function(){e.prototype._invalidateCache.call(this),this._cache.arcLengths=null,this._cache.samples=null},Object.defineProperty(t.prototype,"arcLengths",{get:function(){return this._cache.arcLengths||(this._cache.arcLengths=this.computeArcLengths()),this._cache.arcLengths},enumerable:!1,configurable:!0}),t.prototype.getSamples=function(n){if(this.points){if(this._cache.samples||(this._cache.samples=new Map),!this._cache.samples.has(n)){for(var i=this._nSamples,r=[],s=[],o=this.getCoefficients(n),a=0;a<i;++a){var c=a/(i-1);r.push(this.computeArcLength(n,0,c));var h=At(dn(It,c,o)),l=h===0?0:1/h;this.tension>.95&&(l=G(l,-1,1)),s.push(l)}var u=i-1,f=[],d=[],p=r[0],g=s[0],y=1/u;for(a=0;a<u;++a){var m=p,_=(p=r[a+1])-m,v=g,M=s[a+1];g=M;var b=y/_,T=(v+M-2*b)/(_*_),S=(3*b-2*v-M)/_;f.push(T),d.push(S)}this._cache.samples.set(n,[r,s,d,f])}return this._cache.samples.get(n)}},t.prototype.computeArcLength=function(n,i,r){if(i===void 0&&(i=0),r===void 0&&(r=1),i===r)return 0;for(var s=this.getCoefficients(n),o=.5*(r-i),a=0,c=0;c<this._gauss.length;c++){var h=this._gauss[c],l=h[0];a+=h[1]*At(dn(It,o*l+o+i,s))}return o*a},t.prototype.computeArcLengths=function(){if(this.points){var n=[];n.push(0);for(var i=this.closed?this.points.length:this.points.length-1,r=0,s=0;s<i;s++)r+=this.computeArcLength(s),n.push(r);return n}},t.prototype.inverse=function(n,i){var r=1/(this._nSamples-1),s=this.getSamples(n),o=s[0],a=s[1],c=s[2],h=s[3];if(i>=o[o.length-1])return 1;if(i<=0)return 0;var l=Math.max(0,fn(i,o)),u=l*r;if(o[l]===i)return u;var f=a[l],d=h[l],p=c[l],g=i-o[l];return((d*g+p)*g+f)*g+u},t.prototype.lengthAt=function(n){return n*this.arcLengths[this.arcLengths.length-1]},t.prototype.getT=function(n){var i=this.arcLengths,r=i.length,s=n*i[r-1],o=fn(s,i),a=o/(r-1);if(i[o]===s)return a;var c=s-i[o];return(o+this.inverse(o,c))/(r-1)},t.prototype.getU=function(n){if(n===0)return 0;if(n===1)return 1;var i=this.arcLengths,r=i.length-1,s=i[r],o=n*r,a=Math.floor(o),c=i[a];if(o===a)return c/s;var h=o-a;return(c+this.computeArcLength(a,0,h))/s},t})(or),cr=(function(){function e(t,n){n===void 0&&(n={});var i=this;this._cache=new Map;var r=(n=Se({tension:.5,alpha:0,closed:!1},n)).arcDivisions?new ha(n.arcDivisions,(function(){return i._invalidateCache()})):new la(n.numericalApproximationOrder,n.numericalInverseSamples,(function(){return i._invalidateCache()}));r.alpha=n.alpha,r.tension=n.tension,r.closed=n.closed,r.points=t,this._lmargin=n.lmargin||1-r.tension,this._curveMapper=r}return e.prototype.getTimeFromPosition=function(t,n){return n===void 0&&(n=!1),this._curveMapper.getT(n?G(t,0,1):t)},e.prototype.getPositionFromTime=function(t,n){return n===void 0&&(n=!1),this._curveMapper.getU(n?G(t,0,1):t)},e.prototype.getPositionFromLength=function(t,n){n===void 0&&(n=!1);var i=n?G(t,0,this.length):t;return this._curveMapper.getU(i/this.length)},e.prototype.getLengthAt=function(t,n){return t===void 0&&(t=1),n===void 0&&(n=!1),this._curveMapper.lengthAt(n?G(t,0,1):t)},e.prototype.getTimeAtKnot=function(t){if(t<0||t>this.points.length-1)throw Error("Invalid index!");return t===0?0:this.closed||t!==this.points.length-1?t/(this.closed?this.points.length:this.points.length-1):1},e.prototype.getPositionAtKnot=function(t){return this.getPositionFromTime(this.getTimeAtKnot(t))},e.prototype.getPointAtTime=function(t,n){return(t=G(t,0,1))===0?ue(this.points[0],n):t===1?ue(this.closed?this.points[0]:this.points[this.points.length-1],n):this._curveMapper.evaluateForT(Rt,t,n)},e.prototype.getPointAt=function(t,n){return this.getPointAtTime(this.getTimeFromPosition(t),n)},e.prototype.getTangentAt=function(t,n){var i=G(this.getTimeFromPosition(t),0,1);return this.getTangentAtTime(i,n)},e.prototype.getTangentAtTime=function(t,n){return ft(this._curveMapper.evaluateForT(It,t,n))},e.prototype.getNormalAt=function(t,n){var i=G(this.getTimeFromPosition(t),0,1);return this.getNormalAtTime(i,n)},e.prototype.getNormalAtTime=function(t,n){var i=ft(this._curveMapper.evaluateForT(It,t));if(!(i.length<2||i.length>3)){var r=n||new Array(i.length);if(i.length===2)return r[0]=-i[1],r[1]=i[0],r;var s=ft(this._curveMapper.evaluateForT(Ze,t));return ft(et(et(i,s),i),r)}},e.prototype.getFrenetFrames=function(t,n,i){if(n===void 0&&(n=0),i===void 0&&(i=1),!(n<0||i>1||i<n)){for(var r=new Array(t+1),s=new Array(t+1),o=0;o<=t;o++){var a=n===0&&i===1?o/t:n+o/t*(i-n);r[o]=this.getTangentAt(a)}if(this.dim===2){for(o=0;o<r.length;o++)s[o]=[-r[o][1],r[o][0]];return{tangents:r,normals:s}}if(this.dim===3){var c=new Array(t+1),h=void 0,l=Number.MAX_VALUE,u=Math.abs(r[0][0]),f=Math.abs(r[0][1]);u<=l&&(l=u,h=[1,0,0]),f<=l&&(l=f,h=[0,1,0]),Math.abs(r[0][2])<=l&&(h=[0,0,1]);var d=ft(et(r[0],h));for(s[0]=et(r[0],d),c[0]=et(r[0],s[0]),o=1;o<=t;o++){if(d=et(r[o-1],r[o]),s[o]=ue(s[o-1]),At(d)>tt){ft(d);var p=Math.acos(G(ae(r[o-1],r[o]),-1,1));wi(s[o-1],d,p,s[o])}c[o]=et(r[o],s[o])}if(this.closed===!0)for(p=Math.acos(G(ae(s[0],s[t]),-1,1))/t,ae(r[0],et(s[0],s[t]))>0&&(p=-p),o=1;o<=t;o++)wi(s[o],r[o],p*o,s[o]),c[o]=et(r[o],s[o]);return{tangents:r,normals:s,binormals:c}}}},e.prototype.getCurvatureAt=function(t){var n=G(this.getTimeFromPosition(t),0,1);return this.getCurvatureAtTime(n)},e.prototype.getCurvatureAtTime=function(t){var n=this._curveMapper.evaluateForT(It,t),i=this._curveMapper.evaluateForT(Ze,t),r=ft(n,[]),s=0,o=void 0;if(n.length===2){if((u=Math.pow(n[0]*n[0]+n[1]*n[1],1.5))!==0){var a=(n[0]*i[1]-n[1]*i[0])/u;o=a<0?[r[1],-r[0]]:[-r[1],r[0]],s=Math.abs(a)}}else if(n.length===3){var c=At(n),h=et(n,i);o=ft(et(h,n)),c!==0&&(s=At(h)/Math.pow(c,3))}else{c=At(n);var l=At(i),u=Math.pow(c,3),f=ae(n,i);u!==0&&(s=Math.sqrt(Math.pow(c,2)*Math.pow(l,2)-Math.pow(f,2))/u)}return{curvature:s,radius:s!==0?1/s:0,tangent:r,direction:o}},e.prototype.getDerivativeAt=function(t,n){var i=G(this.getTimeFromPosition(t),0,1);return this._curveMapper.evaluateForT(It,i,n)},e.prototype.getSecondDerivativeAt=function(t,n){var i=G(this.getTimeFromPosition(t),0,1);return this._curveMapper.evaluateForT(Ze,i,n)},e.prototype.getBoundingBox=function(t,n){if(t===void 0&&(t=0),n===void 0&&(n=1),t===0&&n===1&&this._cache.has("bbox"))return this._cache.get("bbox");for(var i=[],r=[],s=this.getTimeFromPosition(t),o=this.getTimeFromPosition(n),a=this.getPointAtTime(s),c=this.getPointAtTime(o),h=this.closed?this.points.length:this.points.length-1,l=Math.floor(h*s),u=Math.ceil(h*o),f=0;f<a.length;f++)i[f]=Math.min(a[f],c[f]),r[f]=Math.max(a[f],c[f]);for(var d=function(m){var _=un(m-1,p.points,p.closed)[2];if(m<u)for(var v=0;v<_.length;v++)_[v]<i[v]&&(i[v]=_[v]),_[v]>r[v]&&(r[v]=_[v]);if(p.tension<1){var M=h*s-(m-1),b=h*o-(m-1),T=function(k){return k>-tt&&k<=1+tt&&(m-1!==l||k>M)&&(m!==u||k<b)},S=p._curveMapper.getCoefficients(m-1),C=function(k){var I=S[k];rr(3*I[0],2*I[1],I[2]).filter(T).forEach((function(P){var O=Rt(P,S[k]);O<i[k]&&(i[k]=O),O>r[k]&&(r[k]=O)}))};for(v=0;v<S.length;v++)C(v)}},p=this,g=l+1;g<=u;g++)d(g);var y={min:i,max:r};return t===0&&n===1&&this._cache.set("bbox",y),y},e.prototype.getPoints=function(t,n,i,r){if(t===void 0&&(t=100),i===void 0&&(i=0),r===void 0&&(r=1),!t||t<=0)throw Error("Invalid arguments passed to getPoints(). You must specify at least 1 sample/segment.");if(!(i<0||r>1||r<i)){for(var s=[],o=0;o<=t;o++){var a=i===0&&r===1?o/t:i+o/t*(r-i);s.push(this.getPointAt(a,n&&new n))}return s}},e.prototype.getNearestPosition=function(t,n,i){var r=this;if(n===void 0&&(n=1e-5),n<=0||!Number.isFinite(n))throw Error("Invalid threshold. Must be a number greater than zero!");i=i||10*this.points.length-1;var s=new Array(t.length),o=1/0,a=0,c=this.createLookupTable((function(f){return r.getPointAt(f)}),i,{cacheKey:"lut_nearest_".concat(i)});Array.from(c.keys()).forEach((function(f){var d=c.get(f),p=Te(t,d);if(p<o)return o=p,a=f,!0}));for(var h=this.getTimeFromPosition(a),l=function(f){if(f>=0&&f<=1){r.getPointAtTime(f,s);var d=Te(t,s);if(d<o)return o=d,h=f,!0}},u=.005;u>n;)l(h-u)||l(h+u)||(u/=2);return{u:a=this._curveMapper.getU(h),distance:o,point:s}},e.prototype.getIntersects=function(t,n,i,r){var s=this;n===void 0&&(n=0),i===void 0&&(i=0),r===void 0&&(r=this._lmargin);var o=this.getIntersectsAsTime(t,n,i,r).map((function(a){return s.getPointAtTime(a)}));return Math.abs(i)===1?o.length===1?o[0]:null:o},e.prototype.getIntersectsAsPositions=function(t,n,i,r){var s=this;return n===void 0&&(n=0),i===void 0&&(i=0),r===void 0&&(r=this._lmargin),this.getIntersectsAsTime(t,n,i,r).map((function(o){return s.getPositionFromTime(o)}))},e.prototype.getIntersectsAsTime=function(t,n,i,r){n===void 0&&(n=0),i===void 0&&(i=0),r===void 0&&(r=this._lmargin);for(var s=n,o=new Set,a=this.closed?this.points.length:this.points.length-1,c=0;c<a&&(i===0||o.size<Math.abs(i));c+=1){var h=i<0?a-(c+1):c,l=un(h,this.points,this.closed),u=l[1],f=l[2],d=this._curveMapper.getCoefficients(h),p=void 0,g=void 0;if(u[s]<f[s]?(p=u[s],g=f[s]):(p=f[s],g=u[s]),t-r<=g&&t+r>=p){var y=ca(t,d[s]);i<0?y.sort((function(v,M){return M-v})):i>=0&&y.sort((function(v,M){return v-M}));for(var m=0;m<y.length;m++){var _=(y[m]+h)/a;if(o.add(_),i!==0&&o.size===Math.abs(i))break}}}return Array.from(o)},e.prototype.createLookupTable=function(t,n,i){if(!n||n<=1)throw Error("Invalid arguments passed to createLookupTable(). You must specify at least 2 samples.");var r=Se({from:0,to:1,cacheForceUpdate:!1},i),s=r.from,o=r.to,a=r.cacheKey,c=r.cacheForceUpdate;if(!(s<0||o>1||o<s)){var h=null;if(a&&!c&&this._cache.has(a))a&&this._cache.has(a)&&(h=this._cache.get(a));else{h=new Map;for(var l=0;l<n;l++){var u=s===0&&o===1?l/(n-1):s+l/(n-1)*(o-s),f=t(u);h.set(u,f)}a&&this._cache.set(a,h)}return h}},e.prototype.forEach=function(t,n,i,r){var s=this;i===void 0&&(i=0),r===void 0&&(r=1);var o=[];if(Number.isFinite(n)){var a=n;if(a<=1)throw Error("Invalid arguments passed to forEach(). You must specify at least 2 samples.");for(var c=0;c<a;c++){var h=i===0&&r===1?c/(a-1):i+c/(a-1)*(r-i);o.push(h)}}else Array.isArray(n)&&(o=n);var l=null;o.forEach((function(u,f){if(!Number.isFinite(u)||u<0||u>1)throw Error("Invalid position (u) for sample in forEach!");var d=s.getTimeFromPosition(u),p=t({u,t:d,i:f,prev:l});l={u,t:d,i:f,value:p}}))},e.prototype.map=function(t,n,i,r){var s=this;i===void 0&&(i=0),r===void 0&&(r=1);var o=[];if(Number.isFinite(n)){var a=n;if(a<=1)throw Error("Invalid arguments passed to map(). You must specify at least 2 samples.");for(var c=0;c<a;c++){var h=i===0&&r===1?c/(a-1):i+c/(a-1)*(r-i);o.push(h)}}else Array.isArray(n)&&(o=n);var l=null;return o.map((function(u,f){if(!Number.isFinite(u)||u<0||u>1)throw Error("Invalid position (u) for sample in map()!");var d=s.getTimeFromPosition(u),p=t({u,t:d,i:f,prev:l});return l={u,t:d,i:f,value:p},p}))},e.prototype.reduce=function(t,n,i,r,s){var o=this;r===void 0&&(r=0),s===void 0&&(s=1);var a=[];if(Number.isFinite(i)){var c=i;if(c<=1)throw Error("Invalid arguments passed to map(). You must specify at least 2 samples.");for(var h=0;h<c;h++){var l=r===0&&s===1?h/(c-1):r+h/(c-1)*(s-r);a.push(l)}}else Array.isArray(i)&&(a=i);return a.reduce((function(u,f,d){if(!Number.isFinite(f)||f<0||f>1)throw Error("Invalid position (u) for sample in map()!");var p=o.getTimeFromPosition(f);return t({acc:u,u:f,t:p,i:d})}),n)},e.prototype._invalidateCache=function(){return this._cache=new Map,this},e.prototype.reset=function(){this._curveMapper.reset()},Object.defineProperty(e.prototype,"points",{get:function(){return this._curveMapper.points},set:function(t){this._curveMapper.points=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tension",{get:function(){return this._curveMapper.tension},set:function(t){this._curveMapper.tension=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this._curveMapper.alpha},set:function(t){this._curveMapper.alpha=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"closed",{get:function(){return this._curveMapper.closed},set:function(t){this._curveMapper.closed=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._curveMapper.lengthAt(1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minX",{get:function(){return this.getBoundingBox().min[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxX",{get:function(){return this.getBoundingBox().max[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minY",{get:function(){return this.getBoundingBox().min[1]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxY",{get:function(){return this.getBoundingBox().max[1]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minZ",{get:function(){return this.getBoundingBox().min[2]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxZ",{get:function(){return this.getBoundingBox().max[2]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dim",{get:function(){var t;return((t=this.points[0])===null||t===void 0?void 0:t.length)||void 0},enumerable:!1,configurable:!0}),e})();class Me{static newton(t,n=.01,i=1e3,r=.5,s=0,o=1){let c=r;for(let h=0;h<i;h++){const l=t(c);if(Math.abs(l)<n)return xt(c,s,o);const u=(t(c+1e-4)-l)/1e-4;c=c-l/u}}static bisect(t,n=.01,i=1e3,r=.5,s=0,o=1){let a=s,c=o,h=r,l,u;for(u=0;u<i;u++){if(l=t(h),Math.abs(l)<n)return h;l<0?c=h:a=h,h=(c+a)/2}return h}static findRoot(t,n=.01,i=1e3,r=.5,s=0,o=1){let a=Me.newton(t,n,i,r);return a==null&&(a=Me.bisect(t,n,i,r,s,o)),a}}class ua{static bisect(t,n=0,i=1,r=.005,s=4,o=10){const a=(f,d,p,g,y,m,_=0)=>{const v=(f+d)/2,M=t(v),b=D.distance(p,M),T=D.distance(M,g),S=b+T;if(_>=s&&Math.abs(S-y)<m||_>=o)return S;const C=m/2,k=_+1;return a(f,v,p,M,b,C,k)+a(v,d,M,g,T,C,k)},c=t(n),h=t(i),l=D.distance(c,h);return a(n,i,c,h,l,r)}static trapezoid(t,n=0,i=1,r=1e3){let s=0,o=t(n);const a=(i-n)/(r-1);for(let c=1;c<r;c++){const h=t(n+c*a),l=D.distance(o,h);s+=l,o=h}return s}}class fa{static search(t,n){let i=0,r=t.length-1,s=Math.floor(i+r/2);for(;s>i&&s<r;){const o=t[s],a=t[s+1];if(o!=null&&a!=null&&o<=n&&a>=n)return s;o!=null&&n<o?r=s:i=s,s=Math.floor(i+r/2)}return s}}class Ke extends cr{constructor(t,n){super(t,n),this.arcLengthLookup=[],this.findTForArcLength=this.findTForArcLength.bind(this),this.findTByRootForArcLength=this.findTByRootForArcLength.bind(this),this.findApproxTForArcLength=this.findApproxTForArcLength.bind(this),this.findTQuickForArcLength=this.findTQuickForArcLength.bind(this),this.generateArcLengthLookup=this.generateArcLengthLookup.bind(this),this.getArcLength=this.getArcLength.bind(this),this.getQuickArcLength=this.getQuickArcLength.bind(this),this.getPointAtArcLength=this.getPointAtArcLength.bind(this),this.getPointAt=this.getPointAt.bind(this)}findTForArcLength(t,n){let i;return n!=null&&n.approxT?i=this.findApproxTForArcLength(t,n==null?void 0:n.normalizedLength):n!=null&&n.quickT?i=this.findTQuickForArcLength(t):i=this.findTByRootForArcLength(t),i}findTByRootForArcLength(t,n=.01,i=100){return t<=0?0:t>=this.length?1:Me.findRoot(s=>t-this.getQuickArcLength(0,s),n,i,t/this.length)}findApproxTForArcLength(t,n){return t/(n||this.length)}findTQuickForArcLength(t){this.arcLengthLookup.length===0&&this.generateArcLengthLookup();const n=fa.search(this.arcLengthLookup,t),i=this.arcLengthLookup[n],r=this.arcLengthLookup[n+1];return(n+(t-i)/(r-i))/this.arcLengthLookup.length}generateArcLengthLookup(t=1e3){let n=this.getPointAt(0),i=0;for(let r=0;r<t;r++){const s=this.getPointAt(r/(t-1)),o=D.distance(n,s);i+=o,this.arcLengthLookup.push(i),n=s}}getArcLength(t=0,n=1){return t===0&&n===1?this.length:ua.bisect(r=>this.getPointAt(r),t,n,.002)}getQuickArcLength(t=0,n=1){let i=0,r=this.length;if(this.arcLengthLookup.length===0&&this.generateArcLengthLookup(),t!==0){const o=Math.floor(t*this.arcLengthLookup.length),a=this.arcLengthLookup[o],c=this.arcLengthLookup[o+1];i=a+t*this.arcLengthLookup.length%this.arcLengthLookup.length*(c-a)}if(n!==1){const o=Math.floor(n*this.arcLengthLookup.length),a=this.arcLengthLookup[o],c=this.arcLengthLookup[o+1];r=a+t*this.arcLengthLookup.length%this.arcLengthLookup.length*(c-a)}return r-i}getPointAtArcLength(t,n){const i=this.findTForArcLength(t,n);return this.getPointAt(i)}getPointAt(t){const n=xt(t,0,1);return super.getPointAt(n)}}const Si=.75,Ti=5e3,Mi=.001,da=1e3,pa=1e3,ga=5e-4,ma=.1,ya={approxT:!0};class Dt{constructor(t,n){if(this.path=[],this.projectedPath=[],this._offset=0,t.length<1)throw new Error("Missing coordinates");if(t[0]&&t[0].length!==3)throw new Error("Coordinates should be in 3d");this.setPath(t,n),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.getPosition=this.getPosition.bind(this),this.getProjectedLength=this.getProjectedLength.bind(this),this.getTrajectory=this.getTrajectory.bind(this)}setPath(t,n={}){this.options={...ya,...n};const{arcDivisions:i,tension:r,calculateDisplacementFromBottom:s}=this.options;this.path=t,this.projectedPath=Dt.toDisplacement(t);const[o]=this.projectedPath[this.projectedPath.length-1];this.displacement=o,this.interpolators={curve:n.curveInterpolator||new Ke(t),trajectory:n.trajectoryInterpolator||new Ke(t.map(h=>[h[0],h[1]]),{tension:r||Si,arcDivisions:i||Ti}),curtain:n.curtainInterpolator||new Ke(this.projectedPath,{tension:r||Si,arcDivisions:i||Ti})};const a=this.getTrajectoryVector(),c=a.map(h=>h*-1);s?(this.endVector=c,this.startVector=a):(this.endVector=a,this.startVector=c),this._curtainPathCache=void 0}project(t){const{curtain:n}=this.interpolators,{calculateDisplacementFromBottom:i}=this.options,r=xt(i?this.length-(t-this._offset):t-this._offset,0,this.length);return n.getPointAtArcLength(r,this.options)}curtainTangent(t){const{curtain:n}=this.interpolators,i=t-this._offset,r=n.findTForArcLength(i,this.options);return r&&n.getTangentAt(r)}getCurtainPath(t,n,i=!1){if(!this._curtainPathCache){const r=[];let s=Math.PI*2;for(let o=this._offset;o<=this.length+this._offset;o+=ma){const a=this.project(o),c=Math.atan2(a[1],a[0]);Math.abs(c-s)>ga&&(r.push({point:a,md:o}),s=c)}this._curtainPathCache=r}if(i){const r={point:this.project(t),md:t},s=this._curtainPathCache.filter(a=>a.md>t&&a.md<n),o={point:this.project(n),md:n};return[r,...s,o]}return this._curtainPathCache.filter(r=>r.md>=t&&r.md<=n)}unproject(t){const{normalizedLength:n,calculateDisplacementFromBottom:i}=this.options,r=i?this.displacement-t:t,s=n||this.length;if(r<0)return r;if(r>this.displacement)return s+(r-this.displacement);const o=this.interpolators.curtain.getIntersectsAsPositions(r,0,1);if(o&&o.length)return o[0]*s+this._offset}getProjectedLength(t){const{curtain:n}=this.interpolators,r=this.project(t)[0]/n.maxX;return Number.isFinite(r)?xt(r,0,1):0}getPosition(t){const{trajectory:n}=this.interpolators,i=this.getProjectedLength(t);return n.getPointAt(i)}getTrajectory(t,n=0,i=1){const r=n<0?-n:0,s=i>1?i-1:0,o=this.interpolators.trajectory.getPointAt(0),a=this.interpolators.trajectory.getPointAt(1);let c,h,l=0;const u=Math.max(0,n),f=Math.min(1,i),d=this.interpolators.trajectory.getPointAt(u),p=this.interpolators.trajectory.getPointAt(f);r?(c=[o[0]+this.startVector[0]*r*this.displacement,o[1]+this.startVector[1]*r*this.displacement],l=-D.distance(c,o)):n>0&&(l=D.distance(d,o)),s&&(h=[a[0]+this.endVector[0]*s*this.displacement,a[1]+this.endVector[1]*s*this.displacement]);const g=[],y=i-n,m=Math.floor(r/y*t),_=Math.ceil((f-u)/y*t),v=t-_-m;if(c){g.push(c);for(let b=1;b<m;b++){const T=b/m*r*this.displacement;g.push([c[0]-this.startVector[0]*T,c[1]-this.startVector[1]*T])}}const M=this.interpolators.trajectory.getPoints(_-1,null,u,f);if(g.push(...M),h){for(let b=1;b<v-1;b++){const T=b/v*s*this.displacement;g.push([p[0]+this.endVector[0]*T,p[1]+this.endVector[1]*T])}g.push(h)}return{points:g,offset:l}}getExtendedTrajectory(t,n=da,i=pa){if(!isFinite(n)||n<0)throw new Error("Invalid parameter, getExtendedTrajectory() must be called with a valid and positive startExtensionLength parameter");if(!isFinite(i)||i<0)throw new Error("Invalid parameter, getExtendedTrajectory() must be called with a valid and positive endExtensionLength parameter");const r=this.displacement+n+i,s=Math.floor(n/r*t),o=Math.max(Math.ceil(this.displacement/r*t),1),a=t-o-s,c=[],h=new D(this.interpolators.trajectory.getPointAt(0)),l=new D(this.startVector),u=n/s;for(let _=s;_>0;_--){const v=_*u,M=h.add(l.scale(v));c.push(M.toArray())}const f=this.interpolators.trajectory.getPoints(o,null,0,1);c.push(...f);const d=new D(this.interpolators.trajectory.getPointAt(1)),p=new D(this.endVector),g=i/(a-1);for(let _=1;_<a;_++){const v=_*g,M=d.add(p.scale(v));c.push(M.toArray())}const y=-n;return{points:c,offset:y}}getTrajectoryVector(){const{trajectoryAngle:t,calculateDisplacementFromBottom:n}=this.options;if(t!=null&&isFinite(t)){const r=Go(t);return new D(Math.cos(r),Math.sin(r)).toArray()}return Dt.getDirectionVector(this.interpolators.trajectory,n?Mi:1-Mi,n?0:1)}static toDisplacement(t,n=0){let i=t[0],r=0;return t.map(o=>{const a=o[0]-i[0],c=o[1]-i[1];return r+=Math.sqrt(a**2+c**2),i=o,[n>0?n-r:r,o[2]||0]})}static getDirectionVector(t,n,i){const r=t.getPointAt(i),s=t.getPointAt(n);return ft([r[0]-s[0],r[1]-s[1]])}get length(){var t;return((t=this.interpolators.curve)==null?void 0:t.length)??0}get offset(){return this._offset}set offset(t){this._curtainPathCache=void 0,this._offset=t}}var pn="http://www.w3.org/1999/xhtml";const Ai={svg:"http://www.w3.org/2000/svg",xhtml:pn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ie(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ai.hasOwnProperty(t)?{space:Ai[t],local:e}:e}function _a(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===pn&&t.documentElement.namespaceURI===pn?t.createElement(e):t.createElementNS(n,e)}}function xa(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function hr(e){var t=Ie(e);return(t.local?xa:_a)(t)}function va(){}function Fn(e){return e==null?va:function(){return this.querySelector(e)}}function wa(e){typeof e!="function"&&(e=Fn(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=new Array(o),c,h,l=0;l<o;++l)(c=s[l])&&(h=e.call(c,c.__data__,l,s))&&("__data__"in c&&(h.__data__=c.__data__),a[l]=h);return new Q(i,this._parents)}function ba(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Sa(){return[]}function lr(e){return e==null?Sa:function(){return this.querySelectorAll(e)}}function Ta(e){return function(){return ba(e.apply(this,arguments))}}function Ma(e){typeof e=="function"?e=Ta(e):e=lr(e);for(var t=this._groups,n=t.length,i=[],r=[],s=0;s<n;++s)for(var o=t[s],a=o.length,c,h=0;h<a;++h)(c=o[h])&&(i.push(e.call(c,c.__data__,h,o)),r.push(c));return new Q(i,r)}function ur(e){return function(){return this.matches(e)}}function fr(e){return function(t){return t.matches(e)}}var Aa=Array.prototype.find;function Pa(e){return function(){return Aa.call(this.children,e)}}function Ca(){return this.firstElementChild}function La(e){return this.select(e==null?Ca:Pa(typeof e=="function"?e:fr(e)))}var ka=Array.prototype.filter;function Ea(){return Array.from(this.children)}function Fa(e){return function(){return ka.call(this.children,e)}}function Ra(e){return this.selectAll(e==null?Ea:Fa(typeof e=="function"?e:fr(e)))}function Ia(e){typeof e!="function"&&(e=ur(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=[],c,h=0;h<o;++h)(c=s[h])&&e.call(c,c.__data__,h,s)&&a.push(c);return new Q(i,this._parents)}function dr(e){return new Array(e.length)}function Oa(){return new Q(this._enter||this._groups.map(dr),this._parents)}function Ae(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ae.prototype={constructor:Ae,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function za(e){return function(){return e}}function Da(e,t,n,i,r,s){for(var o=0,a,c=t.length,h=s.length;o<h;++o)(a=t[o])?(a.__data__=s[o],i[o]=a):n[o]=new Ae(e,s[o]);for(;o<c;++o)(a=t[o])&&(r[o]=a)}function Na(e,t,n,i,r,s,o){var a,c,h=new Map,l=t.length,u=s.length,f=new Array(l),d;for(a=0;a<l;++a)(c=t[a])&&(f[a]=d=o.call(c,c.__data__,a,t)+"",h.has(d)?r[a]=c:h.set(d,c));for(a=0;a<u;++a)d=o.call(e,s[a],a,s)+"",(c=h.get(d))?(i[a]=c,c.__data__=s[a],h.delete(d)):n[a]=new Ae(e,s[a]);for(a=0;a<l;++a)(c=t[a])&&h.get(f[a])===c&&(r[a]=c)}function $a(e){return e.__data__}function Ba(e,t){if(!arguments.length)return Array.from(this,$a);var n=t?Na:Da,i=this._parents,r=this._groups;typeof e!="function"&&(e=za(e));for(var s=r.length,o=new Array(s),a=new Array(s),c=new Array(s),h=0;h<s;++h){var l=i[h],u=r[h],f=u.length,d=Ha(e.call(l,l&&l.__data__,h,i)),p=d.length,g=a[h]=new Array(p),y=o[h]=new Array(p),m=c[h]=new Array(f);n(l,u,g,y,m,d,t);for(var _=0,v=0,M,b;_<p;++_)if(M=g[_]){for(_>=v&&(v=_+1);!(b=y[v])&&++v<p;);M._next=b||null}}return o=new Q(o,i),o._enter=a,o._exit=c,o}function Ha(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Xa(){return new Q(this._exit||this._groups.map(dr),this._parents)}function Ua(e,t,n){var i=this.enter(),r=this,s=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?s.remove():n(s),i&&r?i.merge(r).order():r}function Va(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,r=n.length,s=i.length,o=Math.min(r,s),a=new Array(r),c=0;c<o;++c)for(var h=n[c],l=i[c],u=h.length,f=a[c]=new Array(u),d,p=0;p<u;++p)(d=h[p]||l[p])&&(f[p]=d);for(;c<r;++c)a[c]=n[c];return new Q(a,this._parents)}function Wa(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],r=i.length-1,s=i[r],o;--r>=0;)(o=i[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function Ya(e){e||(e=Ga);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var n=this._groups,i=n.length,r=new Array(i),s=0;s<i;++s){for(var o=n[s],a=o.length,c=r[s]=new Array(a),h,l=0;l<a;++l)(h=o[l])&&(c[l]=h);c.sort(t)}return new Q(r,this._parents).order()}function Ga(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function qa(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ja(){return Array.from(this)}function Za(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length;r<s;++r){var o=i[r];if(o)return o}return null}function Ka(){let e=0;for(const t of this)++e;return e}function Qa(){return!this.node()}function Ja(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var r=t[n],s=0,o=r.length,a;s<o;++s)(a=r[s])&&e.call(a,a.__data__,s,r);return this}function tc(e){return function(){this.removeAttribute(e)}}function ec(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nc(e,t){return function(){this.setAttribute(e,t)}}function ic(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function rc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function sc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function oc(e,t){var n=Ie(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?ec:tc:typeof t=="function"?n.local?sc:rc:n.local?ic:nc)(n,t))}function pr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ac(e){return function(){this.style.removeProperty(e)}}function cc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function hc(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function lc(e,t,n){return arguments.length>1?this.each((t==null?ac:typeof t=="function"?hc:cc)(e,t,n??"")):Nt(this.node(),e)}function Nt(e,t){return e.style.getPropertyValue(t)||pr(e).getComputedStyle(e,null).getPropertyValue(t)}function uc(e){return function(){delete this[e]}}function fc(e,t){return function(){this[e]=t}}function dc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function pc(e,t){return arguments.length>1?this.each((t==null?uc:typeof t=="function"?dc:fc)(e,t)):this.node()[e]}function gr(e){return e.trim().split(/^|\s+/)}function Rn(e){return e.classList||new mr(e)}function mr(e){this._node=e,this._names=gr(e.getAttribute("class")||"")}mr.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function yr(e,t){for(var n=Rn(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function _r(e,t){for(var n=Rn(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function gc(e){return function(){yr(this,e)}}function mc(e){return function(){_r(this,e)}}function yc(e,t){return function(){(t.apply(this,arguments)?yr:_r)(this,e)}}function _c(e,t){var n=gr(e+"");if(arguments.length<2){for(var i=Rn(this.node()),r=-1,s=n.length;++r<s;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?yc:t?gc:mc)(n,t))}function xc(){this.textContent=""}function vc(e){return function(){this.textContent=e}}function wc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function bc(e){return arguments.length?this.each(e==null?xc:(typeof e=="function"?wc:vc)(e)):this.node().textContent}function Sc(){this.innerHTML=""}function Tc(e){return function(){this.innerHTML=e}}function Mc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Ac(e){return arguments.length?this.each(e==null?Sc:(typeof e=="function"?Mc:Tc)(e)):this.node().innerHTML}function Pc(){this.nextSibling&&this.parentNode.appendChild(this)}function Cc(){return this.each(Pc)}function Lc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function kc(){return this.each(Lc)}function Ec(e){var t=typeof e=="function"?e:hr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Fc(){return null}function Rc(e,t){var n=typeof e=="function"?e:hr(e),i=t==null?Fc:typeof t=="function"?t:Fn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function Ic(){var e=this.parentNode;e&&e.removeChild(this)}function Oc(){return this.each(Ic)}function zc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Dc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Nc(e){return this.select(e?Dc:zc)}function $c(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Bc(e){return function(t){e.call(this,t,this.__data__)}}function Hc(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function Xc(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,r=t.length,s;n<r;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++i]=s;++i?t.length=i:delete this.__on}}}function Uc(e,t,n){return function(){var i=this.__on,r,s=Bc(t);if(i){for(var o=0,a=i.length;o<a;++o)if((r=i[o]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=t;return}}this.addEventListener(e.type,s,n),r={type:e.type,name:e.name,value:t,listener:s,options:n},i?i.push(r):this.__on=[r]}}function Vc(e,t,n){var i=Hc(e+""),r,s=i.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,h=a.length,l;c<h;++c)for(r=0,l=a[c];r<s;++r)if((o=i[r]).type===l.type&&o.name===l.name)return l.value}return}for(a=t?Uc:Xc,r=0;r<s;++r)this.each(a(i[r],t,n));return this}function xr(e,t,n){var i=pr(e),r=i.CustomEvent;typeof r=="function"?r=new r(t,n):(r=i.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Wc(e,t){return function(){return xr(this,e,t)}}function Yc(e,t){return function(){return xr(this,e,t.apply(this,arguments))}}function Gc(e,t){return this.each((typeof t=="function"?Yc:Wc)(e,t))}function*qc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length,o;r<s;++r)(o=i[r])&&(yield o)}var vr=[null];function Q(e,t){this._groups=e,this._parents=t}function Jt(){return new Q([[document.documentElement]],vr)}function jc(){return this}Q.prototype=Jt.prototype={constructor:Q,select:wa,selectAll:Ma,selectChild:La,selectChildren:Ra,filter:Ia,data:Ba,enter:Oa,exit:Xa,join:Ua,merge:Va,selection:jc,order:Wa,sort:Ya,call:qa,nodes:ja,node:Za,size:Ka,empty:Qa,each:Ja,attr:oc,style:lc,property:pc,classed:_c,text:bc,html:Ac,raise:Cc,lower:kc,append:Ec,insert:Rc,remove:Oc,clone:Nc,datum:$c,on:Vc,dispatch:Gc,[Symbol.iterator]:qc};function K(e){return typeof e=="string"?new Q([[document.querySelector(e)]],[document.documentElement]):new Q([[e]],vr)}function Zc(e){let t;for(;t=e.sourceEvent;)e=t;return e}function yt(e,t){if(e=Zc(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}var Kc={value:()=>{}};function In(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new fe(n)}function fe(e){this._=e}function Qc(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}fe.prototype=In.prototype={constructor:fe,on:function(e,t){var n=this._,i=Qc(e+"",n),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(e=i[s]).type)&&(r=Jc(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<o;)if(r=(e=i[s]).type)n[r]=Pi(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Pi(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new fe(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,s;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],i=0,r=s.length;i<r;++i)s[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,s=i.length;r<s;++r)i[r].value.apply(t,n)}};function Jc(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function Pi(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=Kc,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}const gn={capture:!0,passive:!1};function mn(e){e.preventDefault(),e.stopImmediatePropagation()}function th(e){var t=e.document.documentElement,n=K(e).on("dragstart.drag",mn,gn);"onselectstart"in t?n.on("selectstart.drag",mn,gn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function eh(e,t){var n=e.document.documentElement,i=K(e).on("dragstart.drag",null);t&&(i.on("click.drag",mn,gn),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var $t=0,Yt=0,Ut=0,wr=1e3,Pe,Gt,Ce=0,kt=0,Oe=0,Kt=typeof performance=="object"&&performance.now?performance:Date,br=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function On(){return kt||(br(nh),kt=Kt.now()+Oe)}function nh(){kt=0}function Le(){this._call=this._time=this._next=null}Le.prototype=Sr.prototype={constructor:Le,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?On():+n)+(t==null?0:+t),!this._next&&Gt!==this&&(Gt?Gt._next=this:Pe=this,Gt=this),this._call=e,this._time=n,yn()},stop:function(){this._call&&(this._call=null,this._time=1/0,yn())}};function Sr(e,t,n){var i=new Le;return i.restart(e,t,n),i}function ih(){On(),++$t;for(var e=Pe,t;e;)(t=kt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--$t}function Ci(){kt=(Ce=Kt.now())+Oe,$t=Yt=0;try{ih()}finally{$t=0,sh(),kt=0}}function rh(){var e=Kt.now(),t=e-Ce;t>wr&&(Oe-=t,Ce=e)}function sh(){for(var e,t=Pe,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Pe=n);Gt=e,yn(i)}function yn(e){if(!$t){Yt&&(Yt=clearTimeout(Yt));var t=e-kt;t>24?(e<1/0&&(Yt=setTimeout(Ci,e-Kt.now()-Oe)),Ut&&(Ut=clearInterval(Ut))):(Ut||(Ce=Kt.now(),Ut=setInterval(rh,wr)),$t=1,br(Ci))}}function Li(e,t,n){var i=new Le;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var oh=In("start","end","cancel","interrupt"),ah=[],Tr=0,ki=1,_n=2,de=3,Ei=4,xn=5,pe=6;function ze(e,t,n,i,r,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;ch(e,n,{name:t,index:i,group:r,on:oh,tween:ah,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Tr})}function zn(e,t){var n=st(e,t);if(n.state>Tr)throw new Error("too late; already scheduled");return n}function lt(e,t){var n=st(e,t);if(n.state>de)throw new Error("too late; already running");return n}function st(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function ch(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=Sr(s,0,n.time);function s(h){n.state=ki,n.timer.restart(o,n.delay,n.time),n.delay<=h&&o(h-n.delay)}function o(h){var l,u,f,d;if(n.state!==ki)return c();for(l in i)if(d=i[l],d.name===n.name){if(d.state===de)return Li(o);d.state===Ei?(d.state=pe,d.timer.stop(),d.on.call("interrupt",e,e.__data__,d.index,d.group),delete i[l]):+l<t&&(d.state=pe,d.timer.stop(),d.on.call("cancel",e,e.__data__,d.index,d.group),delete i[l])}if(Li(function(){n.state===de&&(n.state=Ei,n.timer.restart(a,n.delay,n.time),a(h))}),n.state=_n,n.on.call("start",e,e.__data__,n.index,n.group),n.state===_n){for(n.state=de,r=new Array(f=n.tween.length),l=0,u=-1;l<f;++l)(d=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=d);r.length=u+1}}function a(h){for(var l=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(c),n.state=xn,1),u=-1,f=r.length;++u<f;)r[u].call(e,l);n.state===xn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=pe,n.timer.stop(),delete i[t];for(var h in i)return;delete e.__transition}}function ge(e,t){var n=e.__transition,i,r,s=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((i=n[o]).name!==t){s=!1;continue}r=i.state>_n&&i.state<xn,i.state=pe,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[o]}s&&delete e.__transition}}function hh(e){return this.each(function(){ge(this,e)})}function lh(e,t){var n,i;return function(){var r=lt(this,e),s=r.tween;if(s!==n){i=n=s;for(var o=0,a=i.length;o<a;++o)if(i[o].name===t){i=i.slice(),i.splice(o,1);break}}r.tween=i}}function uh(e,t,n){var i,r;if(typeof n!="function")throw new Error;return function(){var s=lt(this,e),o=s.tween;if(o!==i){r=(i=o).slice();for(var a={name:t,value:n},c=0,h=r.length;c<h;++c)if(r[c].name===t){r[c]=a;break}c===h&&r.push(a)}s.tween=r}}function fh(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=st(this.node(),n).tween,r=0,s=i.length,o;r<s;++r)if((o=i[r]).name===e)return o.value;return null}return this.each((t==null?lh:uh)(n,e,t))}function Dn(e,t,n){var i=e._id;return e.each(function(){var r=lt(this,i);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return st(r,i).value[t]}}function Mr(e,t){var n;return(typeof t=="number"?it:t instanceof gt?Zt:(n=gt(t))?(t=n,Zt):Zi)(e,t)}function dh(e){return function(){this.removeAttribute(e)}}function ph(e){return function(){this.removeAttributeNS(e.space,e.local)}}function gh(e,t,n){var i,r=n+"",s;return function(){var o=this.getAttribute(e);return o===r?null:o===i?s:s=t(i=o,n)}}function mh(e,t,n){var i,r=n+"",s;return function(){var o=this.getAttributeNS(e.space,e.local);return o===r?null:o===i?s:s=t(i=o,n)}}function yh(e,t,n){var i,r,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=a+"",o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a)))}}function _h(e,t,n){var i,r,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=a+"",o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a)))}}function xh(e,t){var n=Ie(e),i=n==="transform"?xo:Mr;return this.attrTween(e,typeof t=="function"?(n.local?_h:yh)(n,i,Dn(this,"attr."+e,t)):t==null?(n.local?ph:dh)(n):(n.local?mh:gh)(n,i,t))}function vh(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function wh(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function bh(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&wh(e,s)),n}return r._value=t,r}function Sh(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&vh(e,s)),n}return r._value=t,r}function Th(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=Ie(e);return this.tween(n,(i.local?bh:Sh)(i,t))}function Mh(e,t){return function(){zn(this,e).delay=+t.apply(this,arguments)}}function Ah(e,t){return t=+t,function(){zn(this,e).delay=t}}function Ph(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Mh:Ah)(t,e)):st(this.node(),t).delay}function Ch(e,t){return function(){lt(this,e).duration=+t.apply(this,arguments)}}function Lh(e,t){return t=+t,function(){lt(this,e).duration=t}}function kh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ch:Lh)(t,e)):st(this.node(),t).duration}function Eh(e,t){if(typeof t!="function")throw new Error;return function(){lt(this,e).ease=t}}function Fh(e){var t=this._id;return arguments.length?this.each(Eh(t,e)):st(this.node(),t).ease}function Rh(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;lt(this,e).ease=n}}function Ih(e){if(typeof e!="function")throw new Error;return this.each(Rh(this._id,e))}function Oh(e){typeof e!="function"&&(e=ur(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=[],c,h=0;h<o;++h)(c=s[h])&&e.call(c,c.__data__,h,s)&&a.push(c);return new mt(i,this._parents,this._name,this._id)}function zh(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,r=n.length,s=Math.min(i,r),o=new Array(i),a=0;a<s;++a)for(var c=t[a],h=n[a],l=c.length,u=o[a]=new Array(l),f,d=0;d<l;++d)(f=c[d]||h[d])&&(u[d]=f);for(;a<i;++a)o[a]=t[a];return new mt(o,this._parents,this._name,this._id)}function Dh(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Nh(e,t,n){var i,r,s=Dh(t)?zn:lt;return function(){var o=s(this,e),a=o.on;a!==i&&(r=(i=a).copy()).on(t,n),o.on=r}}function $h(e,t){var n=this._id;return arguments.length<2?st(this.node(),n).on.on(e):this.each(Nh(n,e,t))}function Bh(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Hh(){return this.on("end.remove",Bh(this._id))}function Xh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Fn(e));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o<r;++o)for(var a=i[o],c=a.length,h=s[o]=new Array(c),l,u,f=0;f<c;++f)(l=a[f])&&(u=e.call(l,l.__data__,f,a))&&("__data__"in l&&(u.__data__=l.__data__),h[f]=u,ze(h[f],t,n,f,h,st(l,n)));return new mt(s,this._parents,t,n)}function Uh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=lr(e));for(var i=this._groups,r=i.length,s=[],o=[],a=0;a<r;++a)for(var c=i[a],h=c.length,l,u=0;u<h;++u)if(l=c[u]){for(var f=e.call(l,l.__data__,u,c),d,p=st(l,n),g=0,y=f.length;g<y;++g)(d=f[g])&&ze(d,t,n,g,f,p);s.push(f),o.push(l)}return new mt(s,o,t,n)}var Vh=Jt.prototype.constructor;function Wh(){return new Vh(this._groups,this._parents)}function Yh(e,t){var n,i,r;return function(){var s=Nt(this,e),o=(this.style.removeProperty(e),Nt(this,e));return s===o?null:s===n&&o===i?r:r=t(n=s,i=o)}}function Ar(e){return function(){this.style.removeProperty(e)}}function Gh(e,t,n){var i,r=n+"",s;return function(){var o=Nt(this,e);return o===r?null:o===i?s:s=t(i=o,n)}}function qh(e,t,n){var i,r,s;return function(){var o=Nt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),Nt(this,e))),o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a))}}function jh(e,t){var n,i,r,s="style."+t,o="end."+s,a;return function(){var c=lt(this,e),h=c.on,l=c.value[s]==null?a||(a=Ar(t)):void 0;(h!==n||r!==l)&&(i=(n=h).copy()).on(o,r=l),c.on=i}}function Zh(e,t,n){var i=(e+="")=="transform"?_o:Mr;return t==null?this.styleTween(e,Yh(e,i)).on("end.style."+e,Ar(e)):typeof t=="function"?this.styleTween(e,qh(e,i,Dn(this,"style."+e,t))).each(jh(this._id,e)):this.styleTween(e,Gh(e,i,t),n).on("end.style."+e,null)}function Kh(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function Qh(e,t,n){var i,r;function s(){var o=t.apply(this,arguments);return o!==r&&(i=(r=o)&&Kh(e,o,n)),i}return s._value=t,s}function Jh(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,Qh(e,t,n??""))}function tl(e){return function(){this.textContent=e}}function el(e){return function(){var t=e(this);this.textContent=t??""}}function nl(e){return this.tween("text",typeof e=="function"?el(Dn(this,"text",e)):tl(e==null?"":e+""))}function il(e){return function(t){this.textContent=e.call(this,t)}}function rl(e){var t,n;function i(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&il(r)),t}return i._value=e,i}function sl(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,rl(e))}function ol(){for(var e=this._name,t=this._id,n=Pr(),i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,c,h=0;h<a;++h)if(c=o[h]){var l=st(c,t);ze(c,e,n,h,o,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new mt(i,this._parents,e,n)}function al(){var e,t,n=this,i=n._id,r=n.size();return new Promise(function(s,o){var a={value:o},c={value:function(){--r===0&&s()}};n.each(function(){var h=lt(this,i),l=h.on;l!==e&&(t=(e=l).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),h.on=t}),r===0&&s()})}var cl=0;function mt(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function Pr(){return++cl}var ut=Jt.prototype;mt.prototype={constructor:mt,select:Xh,selectAll:Uh,selectChild:ut.selectChild,selectChildren:ut.selectChildren,filter:Oh,merge:zh,selection:Wh,transition:ol,call:ut.call,nodes:ut.nodes,node:ut.node,size:ut.size,empty:ut.empty,each:ut.each,on:$h,attr:xh,attrTween:Th,style:Zh,styleTween:Jh,text:nl,textTween:sl,remove:Hh,tween:fh,delay:Ph,duration:kh,ease:Fh,easeVarying:Ih,end:al,[Symbol.iterator]:ut[Symbol.iterator]};function hl(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ll={time:null,delay:0,duration:250,ease:hl};function ul(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function fl(e){var t,n;e instanceof mt?(t=e._id,e=e._name):(t=Pr(),(n=ll).time=On(),e=e==null?null:e+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,c,h=0;h<a;++h)(c=o[h])&&ze(c,e,t,h,o,n||ul(c,t));return new mt(i,this._parents,e,t)}Jt.prototype.interrupt=hh;Jt.prototype.transition=fl;const ce=e=>()=>e;function dl(e,{sourceEvent:t,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function pt(e,t,n){this.k=e,this.x=t,this.y=n}pt.prototype={constructor:pt,scale:function(e){return e===1?this:new pt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new pt(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Nn=new pt(1,0,0);pt.prototype;function Qe(e){e.stopImmediatePropagation()}function Vt(e){e.preventDefault(),e.stopImmediatePropagation()}function pl(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function gl(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Fi(){return this.__zoom||Nn}function ml(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function yl(){return navigator.maxTouchPoints||"ontouchstart"in this}function _l(e,t,n){var i=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function xl(){var e=pl,t=gl,n=_l,i=ml,r=yl,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,c=So,h=In("start","zoom","end"),l,u,f,d=500,p=150,g=0,y=10;function m(x){x.property("__zoom",Fi).on("wheel.zoom",C,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",I).filter(r).on("touchstart.zoom",P).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",$).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(x,A,w,L){var E=x.selection?x.selection():x;E.property("__zoom",Fi),x!==E?b(x,A,w,L):E.interrupt().each(function(){T(this,arguments).event(L).start().zoom(null,typeof A=="function"?A.apply(this,arguments):A).end()})},m.scaleBy=function(x,A,w,L){m.scaleTo(x,function(){var E=this.__zoom.k,F=typeof A=="function"?A.apply(this,arguments):A;return E*F},w,L)},m.scaleTo=function(x,A,w,L){m.transform(x,function(){var E=t.apply(this,arguments),F=this.__zoom,z=w==null?M(E):typeof w=="function"?w.apply(this,arguments):w,N=F.invert(z),B=typeof A=="function"?A.apply(this,arguments):A;return n(v(_(F,B),z,N),E,o)},w,L)},m.translateBy=function(x,A,w,L){m.transform(x,function(){return n(this.__zoom.translate(typeof A=="function"?A.apply(this,arguments):A,typeof w=="function"?w.apply(this,arguments):w),t.apply(this,arguments),o)},null,L)},m.translateTo=function(x,A,w,L,E){m.transform(x,function(){var F=t.apply(this,arguments),z=this.__zoom,N=L==null?M(F):typeof L=="function"?L.apply(this,arguments):L;return n(Nn.translate(N[0],N[1]).scale(z.k).translate(typeof A=="function"?-A.apply(this,arguments):-A,typeof w=="function"?-w.apply(this,arguments):-w),F,o)},L,E)};function _(x,A){return A=Math.max(s[0],Math.min(s[1],A)),A===x.k?x:new pt(A,x.x,x.y)}function v(x,A,w){var L=A[0]-w[0]*x.k,E=A[1]-w[1]*x.k;return L===x.x&&E===x.y?x:new pt(x.k,L,E)}function M(x){return[(+x[0][0]+ +x[1][0])/2,(+x[0][1]+ +x[1][1])/2]}function b(x,A,w,L){x.on("start.zoom",function(){T(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(L).end()}).tween("zoom",function(){var E=this,F=arguments,z=T(E,F).event(L),N=t.apply(E,F),B=w==null?M(N):typeof w=="function"?w.apply(E,F):w,H=Math.max(N[1][0]-N[0][0],N[1][1]-N[0][1]),X=E.__zoom,W=typeof A=="function"?A.apply(E,F):A,j=c(X.invert(B).concat(H/X.k),W.invert(B).concat(H/W.k));return function(V){if(V===1)V=W;else{var Y=j(V),ot=H/Y[2];V=new pt(ot,B[0]-Y[0]*ot,B[1]-Y[1]*ot)}z.zoom(null,V)}})}function T(x,A,w){return!w&&x.__zooming||new S(x,A)}function S(x,A){this.that=x,this.args=A,this.active=0,this.sourceEvent=null,this.extent=t.apply(x,A),this.taps=0}S.prototype={event:function(x){return x&&(this.sourceEvent=x),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(x,A){return this.mouse&&x!=="mouse"&&(this.mouse[1]=A.invert(this.mouse[0])),this.touch0&&x!=="touch"&&(this.touch0[1]=A.invert(this.touch0[0])),this.touch1&&x!=="touch"&&(this.touch1[1]=A.invert(this.touch1[0])),this.that.__zoom=A,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(x){var A=K(this.that).datum();h.call(x,this.that,new dl(x,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:h}),A)}};function C(x,...A){if(!e.apply(this,arguments))return;var w=T(this,A).event(x),L=this.__zoom,E=Math.max(s[0],Math.min(s[1],L.k*Math.pow(2,i.apply(this,arguments)))),F=yt(x);if(w.wheel)(w.mouse[0][0]!==F[0]||w.mouse[0][1]!==F[1])&&(w.mouse[1]=L.invert(w.mouse[0]=F)),clearTimeout(w.wheel);else{if(L.k===E)return;w.mouse=[F,L.invert(F)],ge(this),w.start()}Vt(x),w.wheel=setTimeout(z,p),w.zoom("mouse",n(v(_(L,E),w.mouse[0],w.mouse[1]),w.extent,o));function z(){w.wheel=null,w.end()}}function k(x,...A){if(f||!e.apply(this,arguments))return;var w=x.currentTarget,L=T(this,A,!0).event(x),E=K(x.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",H,!0),F=yt(x,w),z=x.clientX,N=x.clientY;th(x.view),Qe(x),L.mouse=[F,this.__zoom.invert(F)],ge(this),L.start();function B(X){if(Vt(X),!L.moved){var W=X.clientX-z,j=X.clientY-N;L.moved=W*W+j*j>g}L.event(X).zoom("mouse",n(v(L.that.__zoom,L.mouse[0]=yt(X,w),L.mouse[1]),L.extent,o))}function H(X){E.on("mousemove.zoom mouseup.zoom",null),eh(X.view,L.moved),Vt(X),L.event(X).end()}}function I(x,...A){if(e.apply(this,arguments)){var w=this.__zoom,L=yt(x.changedTouches?x.changedTouches[0]:x,this),E=w.invert(L),F=w.k*(x.shiftKey?.5:2),z=n(v(_(w,F),L,E),t.apply(this,A),o);Vt(x),a>0?K(this).transition().duration(a).call(b,z,L,x):K(this).call(m.transform,z,L,x)}}function P(x,...A){if(e.apply(this,arguments)){var w=x.touches,L=w.length,E=T(this,A,x.changedTouches.length===L).event(x),F,z,N,B;for(Qe(x),z=0;z<L;++z)N=w[z],B=yt(N,this),B=[B,this.__zoom.invert(B),N.identifier],E.touch0?!E.touch1&&E.touch0[2]!==B[2]&&(E.touch1=B,E.taps=0):(E.touch0=B,F=!0,E.taps=1+!!l);l&&(l=clearTimeout(l)),F&&(E.taps<2&&(u=B[0],l=setTimeout(function(){l=null},d)),ge(this),E.start())}}function O(x,...A){if(this.__zooming){var w=T(this,A).event(x),L=x.changedTouches,E=L.length,F,z,N,B;for(Vt(x),F=0;F<E;++F)z=L[F],N=yt(z,this),w.touch0&&w.touch0[2]===z.identifier?w.touch0[0]=N:w.touch1&&w.touch1[2]===z.identifier&&(w.touch1[0]=N);if(z=w.that.__zoom,w.touch1){var H=w.touch0[0],X=w.touch0[1],W=w.touch1[0],j=w.touch1[1],V=(V=W[0]-H[0])*V+(V=W[1]-H[1])*V,Y=(Y=j[0]-X[0])*Y+(Y=j[1]-X[1])*Y;z=_(z,Math.sqrt(V/Y)),N=[(H[0]+W[0])/2,(H[1]+W[1])/2],B=[(X[0]+j[0])/2,(X[1]+j[1])/2]}else if(w.touch0)N=w.touch0[0],B=w.touch0[1];else return;w.zoom("touch",n(v(z,N,B),w.extent,o))}}function $(x,...A){if(this.__zooming){var w=T(this,A).event(x),L=x.changedTouches,E=L.length,F,z;for(Qe(x),f&&clearTimeout(f),f=setTimeout(function(){f=null},d),F=0;F<E;++F)z=L[F],w.touch0&&w.touch0[2]===z.identifier?delete w.touch0:w.touch1&&w.touch1[2]===z.identifier&&delete w.touch1;if(w.touch1&&!w.touch0&&(w.touch0=w.touch1,delete w.touch1),w.touch0)w.touch0[1]=this.__zoom.invert(w.touch0[0]);else if(w.end(),w.taps===2&&(z=yt(z,this),Math.hypot(u[0]-z[0],u[1]-z[1])<y)){var N=K(this).on("dblclick.zoom");N&&N.apply(this,arguments)}}}return m.wheelDelta=function(x){return arguments.length?(i=typeof x=="function"?x:ce(+x),m):i},m.filter=function(x){return arguments.length?(e=typeof x=="function"?x:ce(!!x),m):e},m.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:ce(!!x),m):r},m.extent=function(x){return arguments.length?(t=typeof x=="function"?x:ce([[+x[0][0],+x[0][1]],[+x[1][0],+x[1][1]]]),m):t},m.scaleExtent=function(x){return arguments.length?(s[0]=+x[0],s[1]=+x[1],m):[s[0],s[1]]},m.translateExtent=function(x){return arguments.length?(o[0][0]=+x[0][0],o[1][0]=+x[1][0],o[0][1]=+x[0][1],o[1][1]=+x[1][1],m):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},m.constrain=function(x){return arguments.length?(n=x,m):n},m.duration=function(x){return arguments.length?(a=+x,m):a},m.interpolate=function(x){return arguments.length?(c=x,m):c},m.on=function(){var x=h.on.apply(h,arguments);return x===h?m:x},m.clickDistance=function(x){return arguments.length?(g=(x=+x)*x,m):Math.sqrt(g)},m.tapDistance=function(x){return arguments.length?(y=+x,m):y},m}const vl=.1,wl=256;class Cr{constructor(t,n,i={maxZoomLevel:wl,minZoomLevel:vl}){this.xBounds=[0,1],this.yBounds=[0,1],this.translateBoundsX=[0,1],this.translateBoundsY=[0,1],this._zFactor=1,this._enableTranslateExtent=!1,this.container=K(t),this.options=i,this.onRescale=n,this.onZoom=this.onZoom.bind(this),this.calculateTransform=this.calculateTransform.bind(this),this.applyTransform=this.applyTransform.bind(this),this.recalculateZoomTransform=this.recalculateZoomTransform.bind(this),this.rescale=this.rescale.bind(this),this.adjustToSize=this.adjustToSize.bind(this),this.setViewport=this.setViewport.bind(this),this.currentStateAsEvent=this.currentStateAsEvent.bind(this),this.updateTranslateExtent=this.updateTranslateExtent.bind(this),this.scaleX=Lt().domain(this.xBounds).range([0,1]),this.scaleY=Lt().domain(this.yBounds).range([0,1]),this.init()}get width(){return this.scaleX.range()[1]??0}get height(){return this.scaleY.range()[1]??0}get xSpan(){const{xBounds:t}=this;return Math.abs(t[1]-t[0])}get ySpan(){const{yBounds:t}=this;return Math.abs(t[1]-t[0])}get viewportRatio(){return this.width/(this.height||1)}get xRatio(){const t=this.scaleX.domain();return Math.abs(this.width/(t[1]-t[0]))}get yRatio(){const t=this.scaleY.domain();return Math.abs(this.height/(t[1]-t[0]))}get zFactor(){return this._zFactor}set zFactor(t){this._zFactor=t,this.recalculateZoomTransform()}get isXInverted(){return this.xBounds[1]<this.xBounds[0]}get isYInverted(){return this.yBounds[1]<this.yBounds[0]}get enableTranslateExtent(){return this._enableTranslateExtent}set enableTranslateExtent(t){this._enableTranslateExtent=t,this.updateTranslateExtent()}updateTranslateExtent(){const{width:t,xSpan:n,zFactor:i,enableTranslateExtent:r,translateBoundsX:s,translateBoundsY:o}=this;let a=-1/0,c=-1/0,h=1/0,l=1/0;if(r){const u=t/n;a=s[0]*u,h=s[1]*u,c=o[0]*u*i,l=o[1]*u*i}this.zoom.translateExtent([[a,c],[h,l]])}currentStateAsEvent(){const{scaleX:t,scaleY:n,xBounds:i,yBounds:r,zFactor:s,viewportRatio:o,currentTransform:a,xRatio:c,yRatio:h,width:l,height:u}=this;return{xScale:t.copy(),yScale:n.copy(),xBounds:i,yBounds:r,zFactor:s,viewportRatio:o,xRatio:c,yRatio:h,width:l,height:u,transform:Object.assign({},a)}}rescale(){const{currentStateAsEvent:t}=this;this.onRescale(t())}init(){this.zoom=xl().scaleExtent([this.options.minZoomLevel,this.options.maxZoomLevel]).on("zoom",this.onZoom),this.container.call(this.zoom)}onZoom(t){const{transform:n}=t;n&&(this.applyTransform(n),this.rescale())}applyTransform(t){const{width:n,scaleX:i,scaleY:r,xSpan:s,xBounds:o,yBounds:a,zFactor:c}=this,{viewportRatio:h,isXInverted:l,isYInverted:u}=this,f=n*t.k,d=s/f,p=s/t.k,g=p/c/h,y=d*t.x,m=d/c*t.y,_=o[0]-(l?-y:y),v=a[0]-(u?-m:m);i.domain([_,_+(l?-p:p)]),r.domain([v,v+(u?-g:g)]),this.currentTransform=t}setViewport(t,n,i,r){const{zoom:s,container:o,calculateTransform:a,scaleX:c,scaleY:h,isXInverted:l}=this;if(t==null||i==null||isNaN(t)||isNaN(i)){const g=c.domain(),y=g[1]-g[0];(t==null||isNaN(t))&&(t=g[0]+y/2||0),(i==null||isNaN(i))&&(i=Math.abs(y)||1)}if(n==null||isNaN(n)){const g=h.domain();n=g[0]+(g[1]-g[0])/2||0}const u=l?-i:i,f=t-u/2,d=f+u,p=a(f,d,n);r!=null&&Number.isFinite(r)&&r>0?s.transform(o.transition().duration(r),p):s.transform(o,p)}setBounds(t,n){this.xBounds=t,this.yBounds=n,this.recalculateZoomTransform()}setTranslateBounds(t,n){this.translateBoundsX=t,this.translateBoundsY=n,this.updateTranslateExtent()}adjustToSize(t,n,i=!1){const{width:r,height:s,scaleX:o,scaleY:a,recalculateZoomTransform:c}=this;let h=0,l=0;if(typeof t=="number"&&typeof n=="number")l=n,h=t;else{const d=this.container.node();if(d){const{width:p,height:g}=d.getBoundingClientRect();h=p,l=g}}const u=Math.max(1,h),f=Math.max(1,l);!i&&r===u&&s===f||(o.range([0,u]),a.range([0,f]),c(),this.onRescale(this.currentStateAsEvent()))}calculateTransform(t,n,i){const{scaleX:r,xSpan:s,xBounds:o,yBounds:a,zFactor:c,viewportRatio:h,isXInverted:l,isYInverted:u}=this,[f,d]=r.range(),p=Math.abs(n-t),g=s/p,y=p/(d-f),m=i-(u?-p:p)/c/h/2,_=(o[0]-t)/(l?-y:y),v=(a[0]-m)/((u?-y:y)/c);return Nn.translate(_,v).scale(g)}recalculateZoomTransform(){const{scaleX:t,scaleY:n,container:i,calculateTransform:r,updateTranslateExtent:s}=this,[o,a]=t.domain(),[c,h]=n.domain(),l=c+(h-c)/2,u=r(o,a,l);s(),this.zoom.transform(i,u)}setZoomLevelBoundary(t){return this.zoom.scaleExtent(t),this}setMaxZoomLevel(t){const n=this.zoom.scaleExtent();return this.zoom.scaleExtent([n[0],t]),this}setMinZoomLevel(t){const n=this.zoom.scaleExtent();return this.zoom.scaleExtent([t,n[1]]),this}}const bl={order:1,layerOpacity:1,interactive:!1};class te{constructor(t,n){this._interactive=!1,this._id=t||`layer-${Math.floor(Math.random()*1e3)}`;const i=n||bl;this._order=i.order||1,this._options={...i},this.loading=!1,this._element=void 0,this._opacity=i.layerOpacity||1,this._visible=!0,this._interactive=i.interactive||!1,n&&n.data&&this.setData(n.data),this._referenceSystem=n==null?void 0:n.referenceSystem,this.onMount=this.onMount.bind(this),this.onUnmount=this.onUnmount.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onRescale=this.onRescale.bind(this),this.onResize=this.onResize.bind(this),this.onOrderChanged=this.onOrderChanged.bind(this),this.onOpacityChanged=this.onOpacityChanged.bind(this),this.setVisibility=this.setVisibility.bind(this)}get id(){return this._id}get element(){return this._element}get options(){return this._options}set options(t){this._options=t}set isLoading(t){this.loading=t}get isLoading(){return this.loading}set opacity(t){this._opacity=t,this.onOpacityChanged(t)}get opacity(){return this._opacity}set order(t){this._order=t,this.onOrderChanged(t)}get order(){return this._order}set interactive(t){this._interactive=t,this.onInteractivityChanged(t)}get interactive(){return this._interactive}get referenceSystem(){return this._referenceSystem}set referenceSystem(t){this._referenceSystem=t}get data(){return this.getData()}set data(t){this.setData(t)}get isVisible(){return this._visible}getData(){return this._data}setData(t){this._data=t,this.element&&t!=null&&this.onUpdate({data:t})}clearData(t=!0){this._data=void 0,t&&(this.referenceSystem=void 0),this.onUpdate({})}setVisibility(t,n){this._visible=t}onMount(t){this._element=t.elm,this._options.onMount&&this._options.onMount(t,this)}onUnmount(t){this._options.onUnmount&&t!=null&&this._options.onUnmount(t,this)}onResize(t){this._options.onResize&&this._options.onResize(t,this)}onUpdate(t){t.data&&(this._data=t.data),this._options.onUpdate&&this._options.onUpdate(t,this)}onRescale(t){this.optionsRescale(t)}optionsRescale(t){this._options.onRescale&&this._options.onRescale(t,this)}getInternalLayerIds(){return[]}}const De=200,Ne=300,Lr=40,kr=30,Sl=100,Tl=.6,Ml=.3,Al=8,Pl=16,vt=64,Er=1;class St extends te{onOpacityChanged(t){this.canvas&&this.updateStyle()}onOrderChanged(t){this.canvas&&this.updateStyle()}onInteractivityChanged(t){this.canvas&&this.updateStyle()}setVisibility(t){super.setVisibility(t),this.canvas&&this.updateStyle(t)}updateStyle(t){var s;const i=t||this.isVisible?"visible":"hidden",r=this.interactive?"auto":"none";(s=this.canvas)==null||s.setAttribute("style",`position:absolute;pointer-events:${r};z-index:${this.order};opacity:${this.opacity};visibility:${i}`)}onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt((n==null?void 0:n.getAttribute("width"))??"",10)||De,r=t.height||parseInt((n==null?void 0:n.getAttribute("height"))??"",10)||Ne;this.elm=n;let s;this.canvas||(s=document.createElement("canvas"),this.canvas=s,t.elm.appendChild(s)),this.canvas.setAttribute("id",`${this.id}`),this.canvas.setAttribute("width",`${i}px`),this.canvas.setAttribute("height",`${r}px`),this.canvas.setAttribute("class","canvas-layer"),this.updateStyle(),this.ctx=this.canvas.getContext("2d")??void 0}onUnmount(){var t;super.onUnmount(),(t=this.canvas)==null||t.remove(),this.canvas=void 0}onResize(t){const{ctx:n}=this,{width:i,height:r}=t;n==null||n.canvas.setAttribute("width",`${i}px`),n==null||n.canvas.setAttribute("height",`${r}px`)}onUpdate(t){super.onUpdate(t)}resetTransform(){var t;(t=this.ctx)==null||t.resetTransform()}setTransform(t){var r,s;this.resetTransform();const n=t.xBounds[0]>t.xBounds[1],i=t.yBounds[0]>t.yBounds[1];(r=this.ctx)==null||r.translate(t.xScale(0),t.yScale(0)),(s=this.ctx)==null||s.scale(t.xRatio*(n?-1:1),t.yRatio*(i?-1:1))}clearCanvas(){const{ctx:t,canvas:n}=this;t==null||t.save(),t==null||t.resetTransform(),t==null||t.clearRect(0,0,(n==null?void 0:n.width)??0,(n==null?void 0:n.height)??0),t==null||t.restore()}}class Cl extends te{onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt((n==null?void 0:n.getAttribute("width"))??"",10)||De,r=t.height||parseInt((n==null?void 0:n.getAttribute("height"))??"",10)||Ne;this.elm||(this.elm=K(n).append("div"),this.elm.attr("id",`${this.id}`),this.elm.attr("class","html-layer"));const s=this.interactive?"auto":"none";this.elm.style("position","absolute").style("height",`${r}px`).style("width",`${i}px`).style("opacity",this.opacity).style("overflow","hidden").style("pointer-events",s).style("z-index",this.order)}onUnmount(){var t;super.onUnmount(),(t=this.elm)==null||t.remove(),this.elm=void 0}onResize(t){this.elm&&(super.onResize(t),this.elm.style("height",`${t.height}px`).style("width",`${t.width}px`))}setVisibility(t){super.setVisibility(t),this.elm&&this.elm.attr("visibility",t?"visible":"hidden")}onOpacityChanged(t){this.elm&&this.elm.style("opacity",t)}onOrderChanged(t){this.elm&&this.elm.style("z-index",t)}onInteractivityChanged(t){if(this.elm){const n=t?"auto":"none";this.elm.style("pointer-events",n)}}}class Fr extends te{onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n.getAttribute("width")??"",10)||De,r=t.height||parseInt(n.getAttribute("height")??"",10)||Ne;this.elm||(this.elm=K(n).append("svg"),this.elm.attr("id",`${this.id}`),this.elm.attr("class","svg-layer")),this.elm.attr("height",r).attr("width",i);const s=this.interactive?"auto":"none";this.elm.style("position","absolute").style("pointer-events",s).style("opacity",this.opacity).style("z-index",this.order)}onUnmount(){var t;super.onUnmount(),(t=this.elm)==null||t.remove(),this.elm=void 0}onResize(t){this.elm&&(super.onResize(t),this.elm.attr("height",t.height).attr("width",t.width))}setVisibility(t){super.setVisibility(t),this.elm&&this.elm.attr("visibility",t?"visible":"hidden")}onOpacityChanged(t){this.elm&&this.elm.style("opacity",t)}onOrderChanged(t){this.elm&&this.elm.style("z-index",t)}onInteractivityChanged(t){if(this.elm){const n=t?"auto":"none";this.elm.style("pointer-events",n)}}}class Ll{async init(t){const n={width:De,height:Ne,antialias:!0,backgroundAlpha:0,clearBeforeRender:!0,preserveDrawingBuffer:!0,...t};this.renderer=await R.autoDetectRenderer(n),this.stage=new R.Container}get canvas(){var t;return(t=this.renderer)==null?void 0:t.canvas}render(){var t;this.stage!=null&&((t=this.renderer)==null||t.render(this.stage))}}class $n extends te{constructor(t,n,i){var r;super(n,i),this.ctx=t,this.container=new R.Container,(r=this.ctx.stage)==null||r.addChild(this.container)}render(){this.ctx.render()}addChild(t){this.container.addChild(t)}clearLayer(){this.container.removeChildren().forEach(n=>{n.destroy()})}onMount(t){var n,i;super.onMount(t),this.pixiViewContainer=((n=this.element)==null?void 0:n.querySelector("#webgl-layer"))??void 0,this.pixiViewContainer||(this.pixiViewContainer=document.createElement("div"),this.pixiViewContainer.setAttribute("id",`${this.id}`),this.pixiViewContainer.setAttribute("class","webgl-layer"),this.ctx.canvas!=null&&this.pixiViewContainer.appendChild(this.ctx.canvas),(i=this.element)==null||i.appendChild(this.pixiViewContainer),this.updateStyle())}onUnmount(t){var n,i;super.onUnmount(t),this.clearLayer(),(n=this.ctx.stage)==null||n.removeChild(this.container),this.container.destroy(),(i=this.pixiViewContainer)==null||i.remove(),this.pixiViewContainer=void 0}onResize(t){var n;super.onResize(t),(n=this.ctx.renderer)==null||n.resize(t.width,t.height)}onRescale(t){super.onRescale(t);const n=t.xBounds[0]>t.xBounds[1],i=t.yBounds[0]>t.yBounds[1];this.setContainerPosition(t.xScale(0),t.yScale(0)),this.setContainerScale(t.xRatio*(n?-1:1),t.yRatio*(i?-1:1))}setContainerPosition(t,n){this.container.position.set(t,n)}setContainerScale(t,n){this.container.scale.set(t,n)}updateStyle(t){var s;const n=t||this.isVisible,i=this.interactive?"auto":"none";this.container.visible=n;const r=[["position","absolute"],["pointer-events",`${i}`],["z-index",`${this.order}`],["opacity",`${this.opacity}`]].map(o=>o.join(":")).join(";");(s=this.pixiViewContainer)==null||s.setAttribute("style",r)}setVisibility(t,n){super.setVisibility(t,n),this.pixiViewContainer&&this.updateStyle(t)}onOpacityChanged(t){this.pixiViewContainer&&this.updateStyle()}onOrderChanged(t){this.pixiViewContainer&&this.updateStyle()}onInteractivityChanged(t){this.pixiViewContainer&&this.updateStyle()}renderType(){var t;return(t=this.ctx.renderer)==null?void 0:t.type}}function ee(e){throw new Error(`Unexpected object: ${JSON.stringify(e)}`)}const Rr=e=>e.kind==="pAndASymbol",Ir=e=>e.kind==="cementSqueeze",Or=e=>e.kind==="cementPlug",zr=(e,t,n)=>i=>{switch(i.kind){case"screen":return e(i);case"tubing":return t(i);case"completionSymbol":return n(i);default:return ee(i)}},J=(e,t)=>{switch(t){case"Perforation":return e.Perforation(t);case"Open hole gravel pack":return e.OpenHoleGravelPack(t);case"Open hole frac pack":return e.OpenHoleFracPack(t);case"Cased hole fracturation":return e.CasedHoleFracturation(t);case"Cased hole frac pack":return e.CasedHoleFracPack(t);case"Cased hole gravel pack":return e.CasedHoleGravelPack(t);default:return ee(t)}},kl=e=>J({Perforation:()=>!0,OpenHoleGravelPack:()=>!0,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind),El=e=>J({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!0,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!0},e.subKind),Dr=e=>J({Perforation:()=>!1,OpenHoleGravelPack:()=>!0,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!0},e.subKind);function Nr(e){return J({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!0,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!0},e.subKind)}function $r(e){return J({Perforation:()=>!0,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}function Br(e){return J({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!1},e.subKind)}function Fl(e){return J({Perforation:()=>!0,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}function Hr(e){return J({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!0},e.subKind)}function Rl(e){return J({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}const Xr=e=>e.subKind==="Cased hole fracturation",Ur=(e,t)=>e.start<t.end&&e.end>t.start,Vr=e=>({holeLayerId:`${e}-hole`,casingLayerId:`${e}-casing`,completionLayerId:`${e}-completion`,cementLayerId:`${e}-cement`,pAndALayerId:`${e}-pAndA`,perforationLayerId:`${e}-perforation`}),Wr={firstColor:"#8c541d",secondColor:"#eee3d8",lineColor:"#8b4513"},Yr={solidColor:"#dcdcdc",lineColor:"#575757",shoeSize:{width:Al,length:Pl},windowOptions:{dashColor:"#dc0000",dashLength:5,spaceLength:3}},Gr={stroke:"rgba(0, 0, 0, 0.25)",yellow:"#FFFC00",grey:"gray",red:"#FF5050",outline:"black",transparent:"rgba(255, 255, 255, 0)",spikeWidth:50,spikeLength:50,packingOpacity:.7,fracLineCurve:10,fracLineLength:25,scalingFactor:25},qr={firstColor:"#c7b9ab",secondColor:"#5b5b5b",scalingFactor:4},jr={firstColor:"#8b6713",secondColor:"#000000",scalingFactor:4},Zr={scalingFactor:4,lineColor:"#63666a"},Kr={scalingFactor:1,innerColor:"#eeeeff",outerColor:"#777788"},Qr={firstColor:"#c7b9ab",secondColor:"#000000",scalingFactor:4},Jr=4,ts=2;function es(e){const[t]=e.domain();return Math.abs(e(t+1))}function ke(e,t,n,i){return xt(es(i)*e,t,n)}function Il(e,t){const n=e.x+e.width,i=t.x+t.width;return!(t.x>n||i<e.x)}function ns(e,t,n=Jr,i=ts){const r=e.x+e.width+n,s=t.x+t.width+n,o=e.y+e.height+i,a=t.y+t.height+i;return!(t.x-n>r||t.y-i>o||s+n<e.x||a+i<e.y)}function Ol(e,t){const n=e.x+e.width,i=t.x+t.width,r=e.y+e.height,s=t.y+t.height;if(t.x>n||t.y>r||i<e.x||s<e.y)return;const o=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),a=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return{dx:o,dy:a}}function vn(e,t,n=Jr,i=ts){const r=e.x+e.width,s=t.x+t.width,o=e.y+e.height,a=t.y+t.height;if(t.x-n>r||t.y-i>o||s+n<e.x||a+i<e.y)return;const c=e.x+e.width-t.x+n,h=e.y+e.height-t.y+i;return{dx:c,dy:h}}const zl=7,Dl=11,Nl=7,$l=20,Bl=120,Hl=19,Xl="rgba(0, 0, 0, 0.5)",Ul=5,Vl=5;function Wl(e,t){return e??t}const nt={topleft:"topleft",topright:"topright",bottomleft:"bottomleft",bottomright:"bottomright"};class Yl extends St{constructor(t,n){super(t,n),this.callouts=[],this.groupFilter=[],this.renderAnnotation=(i,r,s,o,a,c)=>{this.renderText(i,s,o-a,a,c,"arial","bold"),this.renderText(r,s,o,a,c)},this.renderLine=(i,r,s,o,a,c,h=!0)=>{const{ctx:l}=this,u=h?i:i+s,f=h?i+s:i,d=r+2;l!=null&&(l.strokeStyle=c,l.lineWidth=1,l.beginPath(),l.moveTo(o,a),l.lineTo(u,d),l.lineTo(f,d),l.stroke())},this.minFontSize=(n==null?void 0:n.minFontSize)||zl,this.maxFontSize=(n==null?void 0:n.maxFontSize)||Dl,this.fontSizeFactor=(n==null?void 0:n.fontSizeFactor)||Nl,this.offsetMin=(n==null?void 0:n.offsetMin)||$l,this.offsetMax=(n==null?void 0:n.offsetMax)||Bl,this.offsetFactor=(n==null?void 0:n.offsetFactor)||Hl,this.fontColor=n==null?void 0:n.fontColor,n!=null&&n.backgroundColor?(this.backgroundActive=!0,this.backgroundColor=n.backgroundColor):(this.backgroundActive=!1,this.backgroundColor=Xl),this.backgroundPadding=(n==null?void 0:n.backgroundPadding)||Ul,this.backgroundBorderRadius=Wl(n==null?void 0:n.backgroundBorderRadius,Vl)}setGroupFilter(t){this.groupFilter=t,this.callouts=[],this.render()}onUpdate(t){super.onUpdate(t),this.callouts=[],this.render()}onRescale(t){super.onRescale(t);const n=this.rescaleEvent&&this.rescaleEvent.xRatio===t.xRatio;this.rescaleEvent=t,this.render(n)}render(t=!1){requestAnimationFrame(()=>{if(this.clearCanvas(),!this.data||!this.rescaleEvent||!this.referenceSystem)return;const{xScale:n,yScale:i,xBounds:r}=this.rescaleEvent,s=ke(this.fontSizeFactor,this.minFontSize,this.maxFontSize,n);if(!t||this.callouts.length<=0){const{data:o,ctx:a,groupFilter:c}=this,{calculateDisplacementFromBottom:h}=this.referenceSystem.options,l=h?r[0]<r[1]:r[0]>r[1],u=0;a!=null&&(a.font=`bold ${s}px arial`);const f=o.filter(p=>c.length<=0||c.includes(p.group)),d=ke(this.offsetFactor,this.offsetMin,this.offsetMax,n);this.callouts=this.positionCallouts(f,l,n,i,u,s,d)}this.callouts.forEach(o=>{const{pos:a,title:c,color:h}=o,l=n(a.x),u=i(a.y),f={x:l,y:u,width:o.boundingBox.width,height:s,offsetX:o.dx,offsetY:o.dy};this.renderCallout(c,o.label,f,h,o.alignment)})})}renderBackground(t,n,i,r,s){const{ctx:o}=this;if(o==null)return;const a=this.backgroundPadding,c=this.backgroundBorderRadius,h=this.measureTextWidth(t,s,"arial","bold"),l=this.measureTextWidth(n,s),u=Math.max(h,l)+a*2,f=(s+a)*2,d=i-a,p=r-2*s-a;if(o.fillStyle=this.backgroundColor,c>0){const g=d+u,y=p+f;o.beginPath(),o.moveTo(d+c,p),o.lineTo(g-c,p),o.quadraticCurveTo(g,p,g,p+c),o.lineTo(g,y-c),o.quadraticCurveTo(g,y,g-c,y),o.lineTo(d+c,y),o.quadraticCurveTo(d,y,d,y-c),o.lineTo(d,p+c),o.quadraticCurveTo(d,p,d+c,p),o.fill()}else o.fillRect(d,p,u,f)}renderText(t,n,i,r,s,o="arial",a="normal"){const{ctx:c}=this;c!=null&&(c.font=`${a} ${r}px ${o}`,c.fillStyle=this.fontColor||s,c.fillText(t,n,i))}measureTextWidth(t,n,i="arial",r="normal"){const{ctx:s}=this;return s==null?0:(s.font=`${r} ${n}px ${i}`,s.measureText(t).width)}renderPoint(t,n,i,r=3){const{ctx:s}=this;s!=null&&(s.fillStyle=i,s.beginPath(),s.moveTo(t,n),s.arc(t,n,r,0,Math.PI*2),s.fill())}renderCallout(t,n,i,r,s){const o=this.getPosition(i,s),{x:a,y:c}=o,{height:h,width:l,x:u,y:f}=i,d=s===nt.topright||s===nt.bottomright;this.backgroundActive&&this.renderBackground(t,n,a,c,h),this.renderAnnotation(t,n,a,c,h,r),this.renderPoint(u,f,r),this.renderLine(a,c,l,u,f,r,d)}getPosition(t,n){const{x:i,y:r,offsetX:s=0,offsetY:o=0,width:a}=t;switch(n){case nt.topleft:return{x:i-a-s,y:r-o};case nt.topright:return{x:i+s,y:r-o};case nt.bottomleft:return{x:i-a-s,y:r+o};case nt.bottomright:return{x:i+s,y:r+o};default:return{x:i,y:r}}}positionCallouts(t,n,i,r,s,o,a=20){if(t.length===0)return[];const c=n?nt.topleft:nt.topright,h=t.map(f=>{var p;const d=f.pos?f.pos:(p=this.referenceSystem)==null?void 0:p.project(f.md);return{title:f.title,label:f.label,color:f.color,pos:{x:d==null?void 0:d[0],y:d==null?void 0:d[1]},group:f.group,alignment:c,boundingBox:this.getAnnotationBoundingBox(f.title,f.label,d,i,r,o),dx:a,dy:a}}),l=[h[h.length-1]],u=[];return this.chooseTopOrBottomPosition(h,u,l),this.adjustTopPositions(l),this.adjustBottomPositions(u),h}getAnnotationBoundingBox(t,n,i,r,s,o){const{ctx:a}=this,c=r(i[0]),h=s(i[1]),l=(a==null?void 0:a.measureText(n).width)??0,u=(a==null?void 0:a.measureText(t).width)??0,f=Math.max(l,u);return{x:c,y:h,width:f,height:o*2+4}}chooseTopOrBottomPosition(t,n,i){for(let r=t.length-2;r>=0;--r){const s=t[r],o=i[0];ns(s.boundingBox,o.boundingBox)?(s.alignment=s.alignment===nt.topleft?nt.bottomright:nt.bottomleft,n.push(s),r>0&&i.unshift(t[--r])):i.unshift(s)}}adjustTopPositions(t){for(let n=t.length-2;n>=0;--n){const i=t[n];for(let r=t.length-1;r>n;--r){const s=t[r],o=vn(i.boundingBox,s.boundingBox);o&&(i.dy+=o.dy,i.boundingBox.y-=o.dy)}}}adjustBottomPositions(t){for(let n=t.length-2;n>=0;--n){const i=t[n];for(let r=t.length-1;r>n;--r){const s=t[r],o=vn(s.boundingBox,i.boundingBox);o&&(i.dy+=o.dy,i.boundingBox.y+=o.dy)}}}}const Gl=16,ql=6;function dt(e){const t=gt(e);if(t!=null){const n=t==null?void 0:t.formatHex();return parseInt(n.replace("#","0x"))}else throw Error(`Could not format string ${e} to hex code.`)}function jl(e){return typeof e=="string"?e:`#${e.toString(Gl).padStart(ql,"0")}`}const Zl=1e4;class Kl extends St{constructor(t,n){super(t,n),this.surfaceAreasPaths=[],this.surfaceLinesPaths=[],this.maxDepth=Zl,this.drawPolygonPath=(i,r)=>{const{ctx:s}=this;s!=null&&(s.fillStyle=i,s.fill(r))},this.drawLinePath=(i,r)=>{const{ctx:s}=this;s!=null&&(s.strokeStyle=i,s.stroke(r))},this.createPolygons=i=>{var o,a,c,h,l,u;const r=[];let s=[];for(let f=0;f<i.length;f++){const d=!!((o=i[f])!=null&&o[1]);d&&(s===null&&(s=[]),s.push((a=i[f])==null?void 0:a[0],(c=i[f])==null?void 0:c[1]));const p=f===i.length-1;if((!d||p)&&s.length>0){for(let g=d?f:f-1;g>=0&&((h=i[g])!=null&&h[1]);g--)s.push((l=i[g])==null?void 0:l[0],((u=i[g])==null?void 0:u[2])||this.maxDepth);r.push(s),s=[]}}return r},this.generatePolygonPath=i=>{const r=new Path2D;r.moveTo(i[0],i[1]);for(let s=2;s<i.length;s+=2)r.lineTo(i[s],i[s+1]);return r.closePath(),r},this.generateLinePaths=i=>{var c,h,l,u,f;const r=[],{data:s}=i;let o=!1,a;for(let d=0;d<s.length;d++)(c=s[d])!=null&&c[1]?o&&a?a.lineTo((h=s[d])==null?void 0:h[0],(l=s[d])==null?void 0:l[1]):(a=new Path2D,a.moveTo((u=s[d])==null?void 0:u[0],(f=s[d])==null?void 0:f[1]),o=!0):o&&a&&(r.push(a),o=!1);return o&&a&&r.push(a),r},this.render=this.render.bind(this),this.generateSurfaceAreasPaths=this.generateSurfaceAreasPaths.bind(this),this.generateSurfaceLinesPaths=this.generateSurfaceLinesPaths.bind(this),this.drawPolygonPath=this.drawPolygonPath.bind(this),this.drawLinePath=this.drawLinePath.bind(this),this.updatePaths=this.updatePaths.bind(this)}onUpdate(t){super.onUpdate(t),this.updatePaths(),this.render()}onRescale(t){this.rescaleEvent=t,this.setTransform(this.rescaleEvent),this.render()}updatePaths(){this.data?(this.generateSurfaceAreasPaths(),this.generateSurfaceLinesPaths()):(this.surfaceAreasPaths=[],this.surfaceLinesPaths=[])}render(){!this.ctx||!this.rescaleEvent||requestAnimationFrame(()=>{this.clearCanvas(),this.surfaceAreasPaths.forEach(t=>this.drawPolygonPath(t.color,t.path)),this.surfaceLinesPaths.forEach(t=>this.drawLinePath(t.color,t.path))})}colorToCSSColor(t){return jl(t)}generateSurfaceAreasPaths(){var t;this.surfaceAreasPaths=((t=this.data)==null?void 0:t.areas.reduce((n,i)=>{const s=this.createPolygons(i.data).map(o=>({color:this.colorToCSSColor(i.color),path:this.generatePolygonPath(o)}));return n.push(...s),n},[]))??[]}generateSurfaceLinesPaths(){var t;this.surfaceLinesPaths=((t=this.data)==null?void 0:t.lines.reduce((n,i)=>{const s=this.generateLinePaths(i).map(o=>({color:this.colorToCSSColor(i.color),path:o}));return n.push(...s),n},[]))??[]}}function Bn(e,t){var c,h,l,u,f,d,p,g,y;if(e.length<2)return-1;const n=20;let i=0,r=e.length-1,s=(c=e[i])==null?void 0:c[0],o=(h=e[r])==null?void 0:h[0];for(;r-i>n;){const m=Math.floor((r+i)/2),_=(l=e[m])==null?void 0:l[0];if(s==null||o==null||_==null)return-1;if(t>=s&&t<_)r=m,o=(u=e[r])==null?void 0:u[0];else if(t>=_&&t<=o)i=m,s=(f=e[i])==null?void 0:f[0];else if(t<=s&&t>_)r=m,o=(d=e[r])==null?void 0:d[0];else if(t<=_&&t>=o)i=m,s=(p=e[i])==null?void 0:p[0];else return-1}let a=-1;for(let m=i;m<r;m++){const _=(g=e[m])==null?void 0:g[0],v=(y=e[m+1])==null?void 0:y[0];if(_!=null&&v!=null&&Math.min(_,v)<=t&&t<=Math.max(_,v)){a=m;break}}return a}function _t(e,t,n=0,i=0){var o,a,c,h;let r=0;const s=Bn(e,t);if(s!==-1){const l=(o=e[s])==null?void 0:o[1],u=(a=e[s+1])==null?void 0:a[1];if(l&&u){const f=((c=e[s])==null?void 0:c[0])??0,p=(((h=e[s+1])==null?void 0:h[0])??0)-f,y=(t-f)/p;r=l*(1-y)+u*y,n&&n>r&&(r=n),i&&i<r&&(r=i)}}return r}const Hn=(e,t)=>({title:e.pickIdentifier||e.identifier,group:t,label:`${e.md} ${e.mdUnit} ${e.depthReferencePoint}`,color:t==="strat-picks"?"#227":"rgba(0,0,0,0.8)",md:e.md});function Ql(e){return e?e.map(t=>Hn(t,"ref-picks")):[]}function Jl(e){return e?e.filter(t=>t.entryPick.md===t.from).map(t=>Hn(t.entryPick,"strat-picks")):[]}function tu(e){return e?e.filter(t=>e.findIndex(n=>Math.abs(n.entryPick.md-t.exitPick.md)<.5)===-1).map(t=>Hn(t.exitPick,"strat-picks")).filter((t,n,i)=>n===i.findIndex(r=>r.title===t.title&&r.md===t.md)):[]}const eu=e=>[...Ql(e.nonUnitPicks),...Jl(e.unitPicks),...tu(e.unitPicks)].sort((t,n)=>t.md-n.md),nu=e=>({unitName:e.identifier,topSurface:e.top,baseSurface:e.base,ageBase:e.baseAge,ageTop:e.topAge,color:{r:e.colorR===null?255:e.colorR,g:e.colorG===null?255:e.colorG,b:e.colorB===null?255:e.colorB},level:e.stratUnitLevel,lithType:e.lithologyType,parent:e.stratUnitParent});function iu(e,t,n){if(n.length===0)return[[e,t]];const i=[];let r=e,s=0;for(;r<t&&s<n.length;){const o=n[s];o.from>r&&i.push([r,Math.min(o.from,t)]),r=Math.min(t,Math.max(e,o.to)),s+=1}return r<t&&i.push([r,t]),i}const ru=e=>e.map(nu);function su(e,t){const n=ru(t),i=[],r=[];return e.forEach(s=>{const o=n.filter(a=>{var c;return((c=s.pickIdentifier)==null?void 0:c.search(new RegExp(`(${a.topSurface}|${a.baseSurface})`,"i")))!==-1});o.length>0?o.forEach(a=>r.push({md:s.md,tvd:s.tvd,identifier:s.pickIdentifier,confidence:s.confidence,mdUnit:s.mdUnit,depthReferencePoint:s.depthReferencePoint,...a})):i.push({identifier:s.pickIdentifier,...s})}),{joined:r,nonUnitPicks:i}}function ou(e){const t=[];let n=null;const i=e.filter(r=>r.level).sort((r,s)=>r.unitName.localeCompare(s.unitName)||r.md-s.md||r.ageTop-s.ageTop);for(;i.length>0;){n=i.shift();const r=n.identifier;let s;const o=r===n.topSurface,a=r===n.baseSurface;if(o)s=n.baseSurface;else if(a)s=n.topSurface;else{console.warn(`Unable to match ${r} with top or base surface, ignored`);continue}let c,h;const l=i.find(u=>u.identifier===s);if(l)c=o?n:l,h=o?l:n,c.md>h.md&&([c,h]=[h,c]),i.splice(i.indexOf(l),1);else if(console.warn(`Unable to find ${s} pick for ${r}`),o)if(c=n,h=e.filter(u=>u.level).sort((u,f)=>u.md-f.md).find(u=>u.md>c.md),h)console.warn(`Using ${h.identifier} as base for ${r}`);else{console.warn(`Unable to find a base pick for ${r} pick at ${c.md}, ignored`);continue}else if(a)if(h=n,c=e.filter(u=>u.level).sort((u,f)=>f.md-u.md).find(u=>u.md<h.md),c)console.warn(`Using ${c.identifier} as top for ${r}`);else{console.warn(`Unable to find a top pick for ${r} pick at ${h.md}, ignored`);continue}else{console.warn(`${r} ignored`);continue}t.push({name:c.unitName,mdEntry:c.md,tvdEntry:c.tvd,color:c.color,level:c.level,entryPick:c,mdExit:h.md,tvdExit:h.tvd,exitPick:h,confidenceEntry:c.confidence,confidenceExit:h.confidence})}return t}function au(e,t){var a;const{joined:n,nonUnitPicks:i}=su(e,t),s=ou(n).filter(c=>c.mdEntry<c.mdExit).sort((c,h)=>c.mdEntry-h.mdEntry||c.level-h.level).reverse(),o=[];for(;s.length>0;){const c=s.pop(),h=[];for(;s.length>0&&((a=s[s.length-1])==null?void 0:a.level)>c.level;)h.push(s.pop());h.reverse(),h.push(c);const l=[];h.forEach(u=>{const f=iu(u.mdEntry,u.mdExit,l);l.push(...f.map(d=>({from:d[0],to:d[1],itm:u})))}),l.sort((u,f)=>u.from-f.from),o.push(...l.map(u=>({from:u.from,to:u.to,...u.itm})))}return{unitPicks:o,nonUnitPicks:i}}function cu(e,t){const n=e.map((s,o)=>o*t/e.length),i=Lt().domain(n).range(e);return Array.from(new Array(t).keys()).map(s=>{var a;const o=(a=gt(i(s)))==null?void 0:a.rgb();return o!=null?[o.r,o.g,o.b]:[0,0,0]})}const hu=e=>e?{x:e.minX,y:e.minTvdMsl,width:e.maxX-e.minX,height:e.maxTvdMsl-e.minTvdMsl}:{x:0,y:0,width:0,height:0};function lu(e,t){if(!(e&&e.datapoints))return null;const n=t.reduce((d,p)=>Math.min(d,p[0]),0),i=t.reduce((d,p)=>Math.max(d,p[0]),0),r=e.yAxisValues&&e.yAxisValues[0],s=e.yAxisValues&&e.yAxisValues[e.yAxisValues.length-1],o=e.datapoints||[],a=-o.reduce((d,p)=>Math.min(...p,d),0),c=o.reduce((d,p)=>Math.max(...p,d),0),h=Math.max(Math.abs(a),Math.abs(c)),l=-h,u=h;return{minX:n,maxX:i,minTvdMsl:r,maxTvdMsl:s,domain:{min:l,max:u,difference:u-l}}}async function uu(e,t,n,i={isLeftToRight:!0}){var x,A,w,L,E,F,z,N;if(!(e&&e.datapoints&&e.datapoints.length>0))return;const{datapoints:r}=e,s=(i==null?void 0:i.seismicMin)||(i==null?void 0:i.seismicRange)||r.reduce((B,H)=>Math.min(...H,B),0),o=(i==null?void 0:i.seismicMax)||(i==null?void 0:i.seismicRange)||r.reduce((B,H)=>Math.max(...H,B),0),a=Math.max(Math.abs(s),Math.abs(o)),c=-a,l={min:c,difference:a-c},u=((x=t[0])==null?void 0:x[0])-((A=t[t.length-1])==null?void 0:A[0]),f=Math.abs(Math.floor(u/5)),d=e.yAxisValues.length,p=1e3,g=cu(n,p),y=new Uint8ClampedArray(f*d*4);let m=0;const _=(p-1)/l.difference;let v=i!=null&&i.isLeftToRight?(w=t[0])==null?void 0:w[0]:(L=t[t.length-1])==null?void 0:L[0];const M=u/f*(i!=null&&i.isLeftToRight?-1:1);let b,T,S,C,k;const I=[0,0,0];let P;for(let B=0;B<f;B++){m=B*4;const H=Bn(t,v),X=(E=t[H])==null?void 0:E[0],j=((F=t[H+1])==null?void 0:F[0])-X,Y=(v-X)/j;for(let ot=0;ot<d;ot++)b=(z=r[ot])==null?void 0:z[H],T=(N=r[ot])==null?void 0:N[H+1],b==null||T==null?(k=I,P=0):(S=b*(1-Y)+T*Y,C=(S-l.min)*_,C=xt(~~C,0,p-1),k=g[C],P=255),y.set([k[0],k[1],k[2],P],m),m+=f*4;v+=M}const O=new ImageData(y,f,d);return await createImageBitmap(O,0,0,f,d)}const fu=2147483648,du=4294967295;function pu(e,t,n){const i=n.filter(d=>d.data.values),r=vu(i),s=new Map,o=_u(r,t,s);xu(o);const a=gu(r,e),c=Mu(e,o,t),h=yu(s,c),u=[...mu(h,e),...Object.values(c).flat().filter(d=>!d.exclude)];return{lines:a,areas:u}}function gu(e,t){return e.filter(i=>i.visualization==="line").map(i=>({id:i.name,label:i.name,width:2,color:dt(i.color||"black"),data:t.map((r,s)=>[r[0],i.values[s]])}))}function mu(e,t){return e.map((i,r)=>{const s=r+1<e.length?e[r+1]:null;return{id:i.id,color:dt(i.color),data:t.map((o,a)=>[o[0],i.top[a],...s?[s.top[a]]:[]])}})}function yu(e,t){return Array.from(e.values()).sort((i,r)=>i.age-r.age).filter(i=>{const r=t[i.name],s=r&&r.length>0;return s||console.warn(`Intersection surface group '${i.name}' has no valid entries and will be discarded.`),s}).map((i,r)=>{const o=t[i.name][0];return{id:i.name,label:i.name,color:bu(r),top:o.data.map(a=>a[1])}})}function _u(e,t,n){const i=t&&t.find(o=>o.stratUnitLevel===1),r=i?i.identifier:"SEABED";return e.filter(o=>o.visualization==="interval"||o.visualization==="none").map(o=>{const a=[],c=is(t,o.name,a);c||console.warn(`No match for ${o.name} in strat column`);const h=a[0]||c,l=h&&h.identifier||r;return h&&!n.has(l)&&n.set(l,{age:h.topAge,name:h.identifier}),{...o,unit:c,group:l}})}function xu(e){e.sort((t,n)=>{if(!t.unit&&!n.unit)return 0;if(!t.unit)return-1;if(!n.unit)return 1;const i=t.isBase?t.unit.baseAge:t.unit.topAge,r=n.isBase?n.unit.baseAge:n.unit.topAge;return i!==r?i-r:t.isBase&&!n.isBase?1:!t.isBase&&n.isBase?-1:t.unit.stratUnitLevel-n.unit.stratUnitLevel})}function is(e,t,n=[]){const i=e.find(r=>r.identifier.toLowerCase()===t.toLowerCase());if(i){let r=i;do n.unshift(r),r=e.find(s=>s.identifier===r.stratUnitParent);while(r);return i}return null}function vu(e){return e.map(t=>{const n=t.visualSettings.displayName,i=n.replace(/\s(Base|Top)/gi,""),r=n.toLowerCase().endsWith("base");return{name:i,isBase:r,values:t.data.values,color:t.visualSettings.colors.crossSection,visualization:t.visualSettings.crossSection.toLowerCase()}})}function wu(e){return e.colorR===null||e.colorG===null||e.colorB===null?fu:e.colorR<<16|e.colorG<<8|e.colorB}const bu=Yi().domain([0,100]).range(To(Zt("#e6f1cf","#85906d"),10));function Su(e,t,n,i){const r=t+1;if(!n||r>=n.length)return;const s=n.findIndex(o=>o.isBase&&o.name===e.name);if(s!==-1)return s;for(let o=r;o<n.length;o++){const a=n[o];if(!(a!=null&&a.isBase)||Tu(e,a,i))return o}}function Tu(e,t,n){const i=[];return is(n,e.name,i),i.some(r=>t.name===r.identifier)}function Mu(e,t,n){return t.reduce((r,s,o)=>{var a;if(!s.isBase){r[s.group]||(r[s.group]=[]);const c=Su(s,o,t,n);(a=r[s.group])==null||a.push({id:s.name,label:s.name,color:s.unit&&wu(s.unit)||du,exclude:s.visualization==="none"||!s.unit,data:e.map((h,l)=>{const u=s.values[l]!=null?Au(c,t,l):void 0;return[h[0],s.values[l],u]})})}return r},{})}function Au(e,t,n){var i,r;if(!(!t||!e||e>=t.length)){for(let s=e;s<t.length;s++)if(((i=t[s])==null?void 0:i.values[n])!=null)return(r=t[s])==null?void 0:r.values[n]}}const Ri=.1,Je=1e3,Pu=150,Cu=30,Lu=10;function ku(e){var r;if(!e||e.length===0)return[];const t=e?e.map(s=>[s.easting,s.northing,s.tvd,s.md]):[],n=rs(ss(t)),i=(r=n[n.length-1])==null?void 0:r[0];return i!=null&&n.forEach((s,o)=>{n[o][0]=i-s[0]}),n}function Eu(e,t){if(!e||e.length===0)return[];const n=e?e.map(_=>[_.easting,_.northing,_.tvd,_.md]):[],i=new cr(n,{tension:.75,arcDivisions:5e3}),r=i.length,s=Math.round(r*Lu);let o;s>0?o=rs(i.getPoints(s),5e-4,10):o=[[n[0][0],n[0][1]]];const a=o[0],c=o[o.length-1],h=D.distance(a,c);let l;if(h<Pu){const v=t/180*Math.PI;l=new D(Math.cos(v),Math.sin(v)).mutable}else l=Fu(o,Cu);const u=Math.max(0,Je-r),f=u+r,d=[];let p=[];const g=l.toArray();u>0&&(p=gi(Math.ceil(u*Ri)).map(_=>l.set(g).scale(u*(1-_)).subFrom(a).toArray()),p.pop(),d.push(...p)),d.push(...o);const y=gi(Math.ceil(Je*Ri)).map(_=>l.set(g).scale(Je*_).add(c).toArray()).splice(1);return d.push(...y),ss(d,void 0,f)}function Fu(e,t){const n=D.zero.mutable;let i=0;const r=D.zero.mutable;for(let s=0;s<e.length-1;s++){const o=e.length-1-s;if(r.set(e[o]).sub(e[o-1]),n.add(r),i=n.magnitude,i>t)break}return i===0?new D([0,0]):n.scale(1/i)}function rs(e,t=.001,n=10){if(e.length<=4)return e;const[i,r]=e[0],s=e.map(l=>[l[0]-i,l[1]-r]);let[o,a]=s[0];const c=[e[0]];for(let l=1;l+1<s.length;l++){const[u,f]=s[l]??[],[d,p]=s[l+1]??[];if(u!=null&&f!=null&&d!=null&&p!=null&&(d-u!==0||p-f!==0)){const g=Math.abs(o*p-a*d+d*f-p*u+a*u-o*f)/Math.sqrt((d-o)**2+(p-a)**2),y=[o-u,a-f],m=Math.sqrt(y[0]**2+y[1]**2);(g>t||m>=n)&&(c.push([u+i,f+r]),[o,a]=[u,f])}}const h=s[s.length-1];return c.push([h[0]+i,h[1]+r]),c}function ss(e,t,n=0){let i=e[0],r=0;return e.map(o=>{const a=o[0]-i[0],c=o[1]-i[1];return r+=Math.sqrt(a**2+c**2),i=o,[n>0?n-r:r,o[2]??0]})}const Ru=18,Iu=8,Ou=13,zu="black",Du="Arial",Nu=70;class $u extends St{constructor(t,n){super(t,n),this.defaultMargins=Ru,this.defaultMinFontSize=Iu,this.defaultMaxFontSize=Ou,this.defaultTextColor=zu,this.defaultFont=Du,this.isLabelsOnLeftSide=!0,this.maxFontSizeInWorldCoordinates=Nu,this.isXFlipped=!1,this.areasWithAvgTopDepth=[],this.drawAreaLabel=(i,r,s,o)=>{const{data:a}=i,{ctx:c,maxFontSizeInWorldCoordinates:h,isXFlipped:l}=this,{xScale:u,yScale:f,xRatio:d,yRatio:p,zFactor:g}=this.rescaleEvent;if(c==null)return;let y=this.checkDrawLabelsOnLeftSide();const _=(this.options.margins||this.defaultMargins)*(l?-1:1)/d,v=this.options.minFontSize||this.defaultMinFontSize;let b=(this.options.maxFontSize||this.defaultMaxFontSize)/p;b>h&&(b=h,b*p<v&&(b=v/p));const T=u.invert(u.range()[0])+_,S=u.invert(u.range()[1])-_,[C,k]=this.getSurfacesAreaEdges();c.save(),c.font=`${b*p}px ${this.options.font||this.defaultFont}`;let I=c.measureText(i.label??""),P=I.width/d;if(y){const U=T+(l?-P:P);(!l&&U>k||l&&U<k)&&(y=!1)}else{const U=S+(l?P:-P);(!l&&U<C||l&&U>C)&&(y=!0)}let O;const $=.07;y?O=l?Math.min(C,T):Math.max(C,T):O=l?Math.max(k,S):Math.min(k,S);const x=f.invert(f.range()[0]),A=f.invert(f.range()[1]),w=5,L=3,E=$*(P/L)*(y?1:-1)*(l?-1:1),F=P/w*(y?1:-1)*(l?-1:1),z=a.map(U=>[U[0],U[1]]),N=this.calcPos(z,O,L,E,x,A);if(!N)return;const B=a.map(U=>[U[0],U[2]]);let H=this.calcPos(B,O,L,E,x,A,(r==null?void 0:r.data.map(U=>[U[0],U[1]]))??[],s,o);H||(H=new D(N.x,A));const X=H.y-N.y;if(X<b){if(X*p<v)return;b=X,c.font=`${b*p}px ${this.options.font||this.defaultFont}`,I=c.measureText(i.label??""),P=I.width/d}const W=y!==l?D.right:D.left,j=this.calcAreaDir(z,B,O,w,F,W,x,A,0,Math.PI/4,4,(r==null?void 0:r.data.map(U=>[U[0],U[1]]))??[],s,o),V=Math.atan(Math.tan(j)*g),Y=O,ot=(N.y+H.y)/2,Ts=l?-V:V;c&&(c.textAlign=y?"left":"right",c.translate(u(Y),f(ot)),c.rotate(Ts),c.fillStyle=this.options.textColor||this.defaultTextColor,c.font=`${b*p}px ${this.options.font||this.defaultFont}`,c.textBaseline="middle",c.fillText(i.label??"",0,0),c.restore())},this.drawLineLabel=i=>{const{ctx:r,isXFlipped:s}=this,{xScale:o,yScale:a,xRatio:c,yRatio:h,zFactor:l}=this.rescaleEvent;if(r==null)return;const u=this.checkDrawLabelsOnLeftSide(),f=this.getMarginsInWorldCoordinates(),p=(this.options.maxFontSize||this.defaultMaxFontSize)/h;r.save(),r.font=`${p*h}px ${this.options.font||this.defaultFont}`;const y=r.measureText(i.label).width/c,m=o.invert(o.range()[0])+f,_=o.invert(o.range()[1])-f,[v,M]=this.getSurfacesAreaEdges();let b;const T=5;u?b=s?Math.max(M,_):Math.min(M,_):b=s?Math.min(v,m):Math.max(v,m);const S=y/T*(u?-1:1),{data:C}=i,k=this.calcPos(C,b,T,S),I=this.calcLineDir(C,b,T,S,l,u?D.left:D.right);if(!k||!I)return;const P=b,O=k.y-Er-p/2,$=D.angleRight(I)-(u?Math.PI:0);r&&(r.textAlign=u?"right":"left",r.translate(o(P),a(O)),r.rotate($),r.fillStyle=this.colorToCSSColor(i.color),r.textBaseline="middle",r.fillText(i.label,0,0),r.restore())},this.render=this.render.bind(this),this.getMarginsInWorldCoordinates=this.getMarginsInWorldCoordinates.bind(this),this.getSurfacesAreaEdges=this.getSurfacesAreaEdges.bind(this),this.updateXFlipped=this.updateXFlipped.bind(this),this.generateSurfacesWithAvgDepth=this.generateSurfacesWithAvgDepth.bind(this)}get options(){return this._options}setData(t){super.setData(t),this.areasWithAvgTopDepth=[]}generateSurfacesWithAvgDepth(){var n;const t=((n=this.data)==null?void 0:n.areas)??[];this.areasWithAvgTopDepth=t.reduce((i,r)=>{if(!r.label)return i;const s=r.data.reduce((a,c)=>(c[1]!=null&&(a.sum+=c[1],a.count++),a),{sum:0,count:0});if(s.count===0)return i;const o=s.sum/s.count;return i.push({...r,avgTopDepth:o}),i},[])}onMount(t){super.onMount(t)}onUpdate(t){super.onUpdate(t),this.render()}onRescale(t){this.rescaleEvent=t,this.updateXFlipped(),this.resetTransform(),this.render()}render(){this.rescaleEvent&&requestAnimationFrame(()=>{this.clearCanvas(),this.data&&(this.areasWithAvgTopDepth.length<=0&&this.generateSurfacesWithAvgDepth(),this.drawAreaLabels(),this.drawLineLabels())})}drawAreaLabels(){this.areasWithAvgTopDepth.forEach((t,n,i)=>{const r=i.reduce((s,o,a)=>(a>n&&(s==null||o.avgTopDepth<s.avgTopDepth)&&(s=o),s),null);this.drawAreaLabel(t,r,i,n)})}drawLineLabels(){var t;(t=this.data)==null||t.lines.filter(n=>n.label).forEach(n=>this.drawLineLabel(n))}colorToCSSColor(t){if(typeof t=="string")return t;let n=t.toString(16);return n="000000".substr(0,6-n.length)+n,`#${n}`}calcPos(t,n,i,r,s,o,a,c=null,h){const l=D.zero.mutable;let u=0;for(let f=0;f<i;f++){const d=n+f*r,p=_t(t,d,s,o);if(p){const g=this.getAlternativeYValueIfAvailable(d,s,o,a,c,h),y=g?Math.min(p,g):p;l.add(d,y),u++}}return u===0?null:D.divide(l,u)}getAlternativeYValueIfAvailable(t,n,i,r,s=null,o){if(!r)return null;let a=_t(r,t,n,i);if(a==null&&s&&o!=null){let c=o+1;for(;a==null&&c<s.length;){const h=s[c++];a=_t((h==null?void 0:h.data.map(l=>[l[0],l[1]]))??[],t,n,i)}}return a}calcLineDir(t,n,i,r,s,o=D.left,a,c){const h=o.mutable,l=_t(t,n,a,c);if(l===null)return h;const u=new D(n,l*s),f=D.zero.mutable;for(let d=1;d<=i;d++){const p=n+d*r,g=_t(t,n,a,c);g!==null&&(f.set(p,g*s),f.sub(u),h.add(f))}return h}calcAreaDir(t,n,i,r,s,o=D.left,a,c,h=0,l=Math.PI/4,u=4,f,d=null,p){const g=[],y=D.zero.mutable;let m;for(let S=0;S<=r;S++){const C=i+S*s,k=_t(t,C,a,c),I=_t(n,C,a,c)||c,P=this.getAlternativeYValueIfAvailable(C,a,c,f,d,p),O=P?Math.min(I,P):I;if(S===0){if(k===null)return D.angleRight(o);const $=(k+O)/2;m=new D(i,$)}else k!==null?(y.set(C,(k+O)/2),y.sub(m),g.push(D.angleRight(y))):g.push(D.angleRight(o))}const _=g[0],v=g.map(S=>S-_);let M=0;return v.reduce((S,C)=>{const k=(Math.abs(C)-h)/l,I=Math.pow(1-xt(k,0,1),u);return M+=I,S+C*I},0)/M+_}updateXFlipped(){const{xBounds:t}=this.rescaleEvent;this.isXFlipped=t[0]>t[1]}getMarginsInWorldCoordinates(){const{xRatio:t}=this.rescaleEvent;return(this.options.margins||this.defaultMargins)*(this.isXFlipped?-1:1)/t}getSurfacesAreaEdges(){var c,h;const t=((c=this.data)==null?void 0:c.areas.reduce((l,u)=>{var p,g;const{data:f}=u,d=f.find(y=>y[1]!=null);d&&l.push(d[0]);for(let y=f.length-1;y>=0;y--)if(((p=f[y])==null?void 0:p[1])!=null){l.push((g=f[y])==null?void 0:g[0]);break}return l},[]))??[];t.push(...((h=this.data)==null?void 0:h.lines.reduce((l,u)=>{var p,g;const{data:f}=u,d=f.find(y=>y[1]!=null);d&&l.push(d[0]);for(let y=f.length-1;y>=0;y--)if(((p=f[y])==null?void 0:p[1])!=null){l.push((g=f[y])==null?void 0:g[0]);break}return l},[]))??[]);const n=Math.min(...t),i=Math.max(...t),r=this.getMarginsInWorldCoordinates(),{isXFlipped:s}=this,o=s?i+r:n+r,a=s?n-r:i-r;return[o,a]}checkDrawLabelsOnLeftSide(){var O,$,x,A,w;const{referenceSystem:t,isXFlipped:n}=this;if(!t)return!0;const{xScale:i,yScale:r,xRatio:s}=this.rescaleEvent,o=200,[a,c]=i.domain(),[h,l]=r.domain();let u=t.interpolators.curtain.getIntersects(h,1,0);u.length===0&&(u=[t.interpolators.curtain.getPointAt(0)]);let f=t.interpolators.curtain.getIntersects(l,1,0);f.length===0&&(f=[t.interpolators.curtain.getPointAt(1)]);const d=Math.max((O=u[0])==null?void 0:O[0],($=f[0])==null?void 0:$[0]),p=Math.min((x=u[0])==null?void 0:x[0],(A=f[0])==null?void 0:A[0]),g={left:n?d:p,right:n?p:d},y=this.getMarginsInWorldCoordinates(),m=a+y,_=c-y,[v,M]=this.getSurfacesAreaEdges(),b=n?Math.min(m,v):Math.max(m,v),T=n?Math.max(_,M):Math.min(_,M),S=Math.max(n?b-g.left:g.left-b,0),C=Math.max(n?g.right-T:T-g.right,0),k=S*s,I=C*s;return S>C||k>o||k<o&&I<o&&n||((w=f[0])==null?void 0:w[1])<h}}const Bu=1e4;class Hu extends $n{constructor(){super(...arguments),this.isPreRendered=!1,this.createPolygons=t=>{var r,s,o,a,c,h;const n=[];let i;for(let l=0;l<t.length;l++){const u=!!((r=t[l])!=null&&r[1]);u&&(i==null&&(i=[]),i.push((s=t[l])==null?void 0:s[0],(o=t[l])==null?void 0:o[1]));const f=l===t.length-1;if((!u||f)&&i){for(let d=u?l:l-1;d>=0&&((a=t[d])!=null&&a[1]);d--)i.push((c=t[d])==null?void 0:c[0],((h=t[d])==null?void 0:h[2])||Bu);n.push(i),i=void 0}}return n},this.generateAreaPolygon=t=>{const n=new R.Graphics;this.createPolygons(t.data).forEach(r=>n.poly(r)),n.setStrokeStyle({width:1,color:t.color,alpha:1}),n.fill({color:t.color}),this.addChild(n)},this.generateSurfaceLine=t=>{const n=new R.Graphics,{data:i}=t;n.setStrokeStyle({width:Er,color:t.color,alpha:1,alignment:.5});let s=!1;for(let o=0;o<i.length;o++){const a=i[o];a&&a[1]&&a[0]?s?n.lineTo(a[0],a[1]):(n.moveTo(a[0],a[1]),s=!0):s=!1}this.addChild(n)}}onRescale(t){super.onRescale(t),this.isPreRendered||(this.clearLayer(),this.preRender()),this.render()}onUpdate(t){super.onUpdate(t),this.isPreRendered=!1,this.clearLayer(),this.preRender(),this.render()}preRender(){const{data:t}=this;t&&(t.areas.forEach(n=>this.generateAreaPolygon(n)),t.lines.forEach(n=>this.generateSurfaceLine(n)),this.isPreRendered=!0)}}const os="lightgray",as="gray",cs=.25,hs=.75,Xu={minorColor:os,majorColor:as,minorWidth:cs,majorWidth:hs};class me extends St{constructor(t,n){super(t,n),this._offsetX=0,this._offsetY=0,this.options={...this.options,...n||Xu},this.render=this.render.bind(this)}onUpdate(t){super.onUpdate(t),this.render(t)}onRescale(t){super.onRescale(t),this.render(t)}render(t){const{ctx:n}=this,{minorWidth:i,minorColor:r,majorWidth:s,majorColor:o}=this.options;if(!n||(this.clearCanvas(),!(t.xScale||t.yScale)))return;const a=t.xScale.copy(),c=t.yScale.copy(),h=a.domain(),l=c.domain(),u=this.offsetX,f=this.offsetY;a.domain([h[0]-u,h[1]-u]),c.domain([l[0]-f,l[1]-f]);const[d,p]=a.range(),[g,y]=c.range();n.lineWidth=i||cs,n.strokeStyle=r||os;const m=this.mapMinorTicks(a.ticks()),_=this.mapMinorTicks(c.ticks());this.renderTicksX(a,m,g,y),this.renderTicksY(c,_,d,p),n.lineWidth=s||hs,n.strokeStyle=o||as,this.renderTicksX(a,a.ticks(),g,y),this.renderTicksY(c,c.ticks(),d,p),n.restore()}renderTicksX(t,n,i,r){n.forEach(s=>{const o=t(s);this.ctx!=null&&(this.ctx.beginPath(),this.ctx.moveTo(o,i),this.ctx.lineTo(o,r),this.ctx.stroke())})}renderTicksY(t,n,i,r){n.forEach(s=>{const o=t(s);this.ctx!=null&&(this.ctx.beginPath(),this.ctx.moveTo(i,o),this.ctx.lineTo(r,o),this.ctx.stroke())})}mapMinorTicks(t){let n=[];return t.length>=2&&(n=t.map(i=>i+(t[1]-t[0])/2),n.pop()),n}get offsetX(){return this._offsetX}set offsetX(t){this._offsetX=t}get offsetY(){return this._offsetY}set offsetY(t){this._offsetY=t}}class Uu extends St{onMount(t){super.onMount(t);const n=document.createElement("img");this.img=n,this.isLoading=!0}onUpdate(t){super.onUpdate(t),this.img!=null&&(this.img.src=t.url),this.render(t)}onRescale(t){super.onRescale(t),this.setTransform(t),this.render(t)}render(t){var f,d,p;const n=parseInt(((f=this.elm)==null?void 0:f.getAttribute("width"))??"0",10),i=parseInt(((d=this.elm)==null?void 0:d.getAttribute("height"))??"0",10),{xScale:r,yScale:s,xRatio:o,yRatio:a,x:c,y:h}=t,l=n*(o||1),u=i*(a||1);this.clearCanvas(),this.img!=null&&(this.isLoading?this.img.onload=()=>{var g;this.isLoading=!1,this.img!=null&&((g=this.ctx)==null||g.drawImage(this.img,r(c||0),s(h||0),l,u))}:(p=this.ctx)==null||p.drawImage(this.img,r(c||0),s(h||0),l,u))}}const Vu={dash:[10,5],width:1,color:16777215,alpha:1,scale:1,useTexture:!1,alignment:.5},at=class at{constructor(t,n={}){this.cursor=new R.Point,this.scale=1,this.graphics=t,n={...Vu,...n},this.dash=n.dash,this.dashSize=this.dash.reduce((i,r)=>i+r),this.useTexture=n.useTexture,this.options=n,this.setLineStyle()}setLineStyle(){const t=this.options;if(this.useTexture){const n=at.getTexture(t,this.dashSize);this.graphics.lineTextureStyle({width:t.width*t.scale,color:t.color,alpha:t.alpha,texture:n,alignment:t.alignment})}else this.graphics.setStrokeStyle({width:t.width*t.scale,color:t.color,alpha:t.alpha,cap:t.cap,join:t.join,alignment:t.alignment});this.scale=t.scale}static distance(t,n,i,r){return Math.sqrt(Math.pow(i-t,2)+Math.pow(r-n,2))}moveTo(t,n){return this.lineLength=0,this.cursor.set(t,n),this.start=new R.Point(t,n),this.graphics.moveTo(this.cursor.x,this.cursor.y),this}lineTo(t,n,i){typeof this.lineLength===void 0&&this.moveTo(0,0);const s=at.distance(this.cursor.x,this.cursor.y,t,n),o=Math.atan2(n-this.cursor.y,t-this.cursor.x),a=i&&t===this.start.x&&n===this.start.y;if(this.useTexture)if(this.graphics.moveTo(this.cursor.x,this.cursor.y),this.adjustLineStyle(o),a&&this.dash.length%2===0){const c=Math.min(this.dash[this.dash.length-1],s);this.graphics.lineTo(t-Math.cos(o)*c,n-Math.sin(o)*c),this.graphics.closePath()}else this.graphics.lineTo(t,n);else{const c=Math.cos(o),h=Math.sin(o);let l=this.cursor.x,u=this.cursor.y;const f=this.lineLength%(this.dashSize*this.scale);let d=0,p=0,g=0;for(let m=0;m<this.dash.length;m++){const _=this.dash[m]*this.scale;if(f<g+_){d=m,p=f-g;break}else g+=_}let y=s;for(;y>0;){const m=this.dash[d]*this.scale-p,_=y>m?m:y;if(a&&at.distance(l+c*_,u+h*_,this.start.x,this.start.y)<=_){if(d%2===0){const M=at.distance(l,u,this.start.x,this.start.y)-this.dash[this.dash.length-1]*this.scale;l+=c*M,u+=h*M,this.graphics.lineTo(l,u)}break}l+=c*_,u+=h*_,d%2?this.graphics.moveTo(l,u):this.graphics.lineTo(l,u),y-=_,d++,d=d===this.dash.length?0:d,p=0}}return this.lineLength+=s,this.cursor.set(t,n),this}closePath(){this.lineTo(this.start.x,this.start.y,!0)}drawCircle(t,n,i,r=80,s){const o=Math.PI*2/r;let a=0,c;s?(c=new R.Point(t+Math.cos(a)*i,n+Math.sin(a)*i),s.apply(c,c),this.moveTo(c[0],c[1])):(c=new R.Point(t+Math.cos(a)*i,n+Math.sin(a)*i),this.moveTo(c.x,c.y)),a+=o;for(let h=1;h<r+1;h++){const l=h===r?c:[t+Math.cos(a)*i,n+Math.sin(a)*i];this.lineTo(l[0],l[1]),a+=o}return this}drawEllipse(t,n,i,r,s=80,o){const a=Math.PI*2/s;let c;const h=new R.Point;for(let l=0;l<Math.PI*2;l+=a){let u=t-i*Math.sin(l),f=n-r*Math.cos(l);o&&(h.set(u,f),o.apply(h,h),u=h.x,f=h.y),l===0?(this.moveTo(u,f),c={x:u,y:f}):this.lineTo(u,f)}return this.lineTo(c.x,c.y,!0),this}drawPolygon(t,n){const i=new R.Point;if(typeof t[0]=="number")if(n){i.set(t[0],t[1]),n.apply(i,i),this.moveTo(i.x,i.y);for(let r=2;r<t.length;r+=2)i.set(t[r],t[r+1]),n.apply(i,i),this.lineTo(i.x,i.y,r===t.length-2)}else{this.moveTo(t[0],t[1]);for(let r=2;r<t.length;r+=2)this.lineTo(t[r],t[r+1],r===t.length-2)}else if(n){const r=t[0];i.copyFrom(r),n.apply(i,i),this.moveTo(i.x,i.y);for(let s=1;s<t.length;s++){const o=t[s];i.copyFrom(o),n.apply(i,i),this.lineTo(i.x,i.y,s===t.length-1)}}else{const r=t[0];this.moveTo(r.x,r.y);for(let s=1;s<t.length;s++){const o=t[s];this.lineTo(o.x,o.y,s===t.length-1)}}return this}drawRect(t,n,i,r,s){if(s){const o=new R.Point;o.set(t,n),s.apply(o,o),this.moveTo(o.x,o.y),o.set(t+i,n),s.apply(o,o),this.lineTo(o.x,o.y),o.set(t+i,n+r),s.apply(o,o),this.lineTo(o.x,o.y),o.set(t,n+r),s.apply(o,o),this.lineTo(o.x,o.y),o.set(t,n),s.apply(o,o),this.lineTo(o.x,o.y,!0)}else this.moveTo(t,n).lineTo(t+i,n).lineTo(t+i,n+r).lineTo(t,n+r).lineTo(t,n,!0);return this}adjustLineStyle(t){const n=this.graphics.line;n.matrix=new R.Matrix,t&&n.matrix.rotate(t),this.scale!==1&&n.matrix.scale(this.scale,this.scale);const i=-this.lineLength;n.matrix.translate(this.cursor.x+i*Math.cos(t),this.cursor.y+i*Math.sin(t)),this.graphics.lineStyle(n)}static getTexture(t,n){const i=t.dash.toString();if(at.dashTextureCache[i])return at.dashTextureCache[i];const r=document.createElement("canvas");r.width=n,r.height=Math.ceil(t.width);const s=r.getContext("2d");if(!s){console.warn("Did not get context from canvas");return}s.globalAlpha=t.alpha,s.lineWidth=t.width;let o=0;const a=t.width/2;s.moveTo(o,a);for(let h=0;h<t.dash.length;h+=2)o+=t.dash[h],s.lineTo(o,a),t.dash.length!==h+1&&(o+=t.dash[h+1],s.moveTo(o,a));s.strokeStyle="white",s.stroke();const c=at.dashTextureCache[i]=R.Texture.from(r);return c.baseTexture.scaleMode=R.SCALE_MODES.NEAREST,c}};at.dashTextureCache={};let wn=at;const bn=e=>new D(e.x,e.y),Wu=e=>new R.Point(e[0],e[1]),ls=e=>{if(e.length<2)return[new D(0)];let t;return e.map((n,i,r)=>{const s=r[i],o=r[i+1];if(i<r.length-1&&s!=null&&o!=null){const a=bn(s);return t=bn(o).sub(a).rotate90().normalized(),t}return t})},us=(e,t,n)=>{const i=bn(e);return Wu(i.add(t.scale(n)))},Sn=(e,t,n)=>{if(e.length!==t.length)throw new Error("Number of vectors does not match number of points");return e.map((i,r)=>{const s=t[r];if(s!=null)return us(i,s,n);throw new Error(`Trying to read index ${r} of point ${i}, but no such vector was found!`)})},Ii=(e,t,n,i)=>e<=i&&n<=t,Yu=(e,t,n,i)=>e<i&&n<t,Gu=e=>Array.from(new Set(e)),$e=(e,t,n,i)=>{const r=i.filter(o=>Ii(e,t,o.start,o.end)),s=n.filter(o=>Ii(e,t,o.start,o.end));return{overlappingHoles:r,overlappingOuterStrings:s}},Be=([e,t],n)=>{const s=n.flatMap(a=>[a.start-1e-4,a.start,a.end,a.end+1e-4]).filter(a=>a>=e&&a<=t);return s.push(e),s.push(t),Gu(s).sort((a,c)=>a-c)},Z=e=>e.kind==="casing"?e.innerDiameter:e.diameter,fs=(e,t,n,i)=>{const s=e.find(h=>h.start<=i&&h.end>=i),o=s?s.diameter:0,a=t.filter(h=>Z(h)>o).sort((h,l)=>Z(h)-Z(l)).find(h=>h.start<=i&&h.end>=i),c=n.find(h=>h.start<=i&&h.end>=i&&h.diameter>o);return a?Z(a):c?c.diameter:100},qu=(e,t,n,i)=>{const s=e.sort((a,c)=>c.diameter-a.diameter).find(a=>a.start<=n&&a.end>=n),o=t.find(a=>a.start<=n&&a.end>=n);return s&&i!=="Open hole frac pack"&&i!=="Open hole gravel pack"?Z(s):o?o.diameter:100},ju=(e,t,n,i)=>{const s=e.sort((h,l)=>Z(h)-Z(l)).find(h=>h.start<=i&&h.end>=i);if(s)return Z(s);const o=e.length?Math.min(...e.map(h=>Z(h))):0,a=t.sort((h,l)=>Z(h)-Z(l)).find(h=>h.start<=i&&h.end>=i&&o<=Z(h));if(a)return Z(a);const c=n.find(h=>h.start<=i&&h.end>=i&&h.diameter);return c?c.diameter:100},Zu=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Xn(e.referenceIds,t,n);if(o.length===0)throw new Error(`Invalid cement data, can't find referenced casing/completion string for cement with id '${e.id}'`);o.sort((g,y)=>g.end-y.end);const c=o[o.length-1].end,{overlappingOuterStrings:h,overlappingHoles:l}=$e(e.toc,c,a,i),u=[...h,...l].map(g=>({start:g.start,end:g.end}));return Be([e.toc,c],u).flatMap((g,y,m)=>{if(y===m.length-1)return[];const _=m[y+1],v=fs(o,h,l,g);return[{top:g,bottom:_,diameter:v*r}]}).map(g=>({diameter:g.diameter,points:s(g.top,g.bottom)}))},Xn=(e,t,n)=>[...t,...n].reduce((i,r)=>e.includes(r.id)?{...i,attachedStrings:[...i.attachedStrings,r]}:{...i,nonAttachedStrings:[...i.nonAttachedStrings,r]},{attachedStrings:[],nonAttachedStrings:[]}),Ku=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Xn(e.referenceIds,t,n);if(o.length===0)throw new Error(`Invalid cement squeeze data, can't find referenced casing/completion for squeeze with id '${e.id}'`);const{overlappingOuterStrings:c,overlappingHoles:h}=$e(e.start,e.end,a,i),l=[...c,...h].map(p=>({start:p.start,end:p.end}));return Be([e.start,e.end],l).flatMap((p,g,y)=>{if(g===y.length-1)return[];const m=y[g+1],_=fs(o,c,h,p);return[{top:p,bottom:m,diameter:_*r}]}).map(p=>({diameter:p.diameter,points:s(p.top,p.bottom)}))},Qu=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Xn(e.referenceIds,t,n),{overlappingHoles:c,overlappingOuterStrings:h}=$e(e.start,e.end,a,i),l=[...o,...c,...h].map(p=>({start:p.start,end:p.end}));return Be([e.start,e.end],l).flatMap((p,g,y)=>{if(g===y.length-1)return[];const m=y[g+1],_=ju(o,h,c,p);return[{top:p,bottom:m,diameter:_*r}]}).map(p=>({diameter:p.diameter,points:s(p.top,p.bottom)}))},Ju=(e,t,n,i,r)=>{const o=t.createLinearGradient(0,0,0,e.height);return o.addColorStop(0,n),o.addColorStop(.5-r,i),o.addColorStop(.5+r,i),o.addColorStop(1,n),o},t0=({firstColor:e,secondColor:t},n,i)=>{const r=document.createElement("canvas");r.width=n,r.height=i;const s=r.getContext("2d");if(s==null)throw Error("Could not get canvas context!");return s.fillStyle=Ju(r,s,e,t,0),s.fillRect(0,0,r.width,r.height),R.Texture.from(r)},e0=({scalingFactor:e})=>{const t=document.createElement("canvas"),n=vt*e;t.width=n,t.height=n;const i=t.getContext("2d");if(i==null)throw Error("Could not get canvas context!");i.fillStyle="white",i.fillRect(0,0,t.width,t.height);const r=n/10;i.strokeStyle="#AAAAAA",i.lineWidth=r,i.beginPath();const s=n/3;for(let o=-t.width;o<t.width;o++)i.moveTo(-t.width+s*o,-t.height),i.lineTo(t.width+s*o,t.height*2);return i.stroke(),R.Texture.from(t)},n0=({innerColor:e,outerColor:t,scalingFactor:n})=>{const i=vt*n,r=document.createElement("canvas");r.width=i,r.height=i;const s=r.getContext("2d");if(s==null)throw Error("Could not get canvas context!");const o=s.createLinearGradient(0,0,0,i),a=.3,c=.7;return o.addColorStop(0,t),o.addColorStop(a,e),o.addColorStop(c,e),o.addColorStop(1,t),s.fillStyle=o,s.fillRect(0,0,r.width,r.height),R.Texture.from(r)},i0=({firstColor:e,secondColor:t,scalingFactor:n})=>{const i=document.createElement("canvas"),r=vt*n,s=n;i.width=r,i.height=r;const o=i.getContext("2d");if(o==null)throw Error("Could not get canvas context!");o.fillStyle=e,o.fillRect(0,0,i.width,i.height),o.lineWidth=s,o.fillStyle=t,o.beginPath();const a=r/12;for(let c=-i.width;c<i.width;c++)o.moveTo(-i.width+a*c,-i.height),o.lineTo(i.width+a*c,i.height);return o.stroke(),R.Texture.from(i)},r0=({firstColor:e,secondColor:t,scalingFactor:n})=>{const i=document.createElement("canvas"),r=vt*n;i.width=r,i.height=r;const s=i.getContext("2d");if(s==null)throw Error("Could not get canvas context!");s.fillStyle=e,s.fillRect(0,0,i.width,i.height),s.lineWidth=n,s.strokeStyle=t,s.beginPath(),s.setLineDash([20,10]);const o=r/12;for(let a=-i.width;a<i.width;a++)s.moveTo(-i.width+o*a,-i.height),s.lineTo(i.width+o*a,i.height*2);return s.stroke(),R.Texture.from(i)},s0=({firstColor:e,secondColor:t,scalingFactor:n})=>{const i=document.createElement("canvas"),r=vt*n,s=n;i.width=r,i.height=r;const o=i.getContext("2d");if(o==null)throw Error("Could not get canvas context!");o.lineWidth=s,o.fillStyle=e,o.strokeStyle=t,o.fillRect(0,0,i.width,i.height),o.beginPath(),o.setLineDash([20,10]);const a=r/12;for(let c=-i.width;c<i.width;c++)o.moveTo(-i.width+a*c,-i.height),o.lineTo(i.width+a*c,i.height*2);return o.stroke(),R.Texture.from(i)},ye=(e,t)=>{const n=ls(t),i=Sn(t,n,e);return{leftPath:Sn(t,n,-e),rightPath:i}},tn=(e,t)=>({kind:"casing",start:e,end:t}),o0=(e,t)=>({kind:"casing-window",start:e,end:t}),a0=e=>{const t=(e.windows||[]).filter(n=>Yu(e.start,e.end,n.start,n.end)).reduce(({intervals:n,lastBottom:i},r,s,o)=>{const a=i<r.start?tn(i,r.start):null,c=a?a.end:i,h=Math.max(c,r.start),l=Math.min(e.end,r.end),u=o0(h,l),f=l,p=s===o.length-1&&f<e.end?tn(f,e.end):null,g=[a,u,p].filter(y=>y!=null);return{intervals:[...n,...g],lastBottom:f}},{intervals:[],lastBottom:e.start});return t.intervals.length?t.intervals:[tn(e.start,e.end)]},c0=(e,t,n)=>{const i=t.diameter*e,r=i/2,o=t.innerDiameter*e/2,a=r-o,c=a0(t).map(h=>{const l=n(h.start,h.end),{leftPath:u,rightPath:f}=ye(r,l);return{kind:h.kind,leftPath:u,rightPath:f,pathPoints:l}});return{kind:"casing",id:t.id,referenceDiameter:i,referenceRadius:r,sections:c,casingWallWidth:a,hasShoe:t.hasShoe,bottom:t.end}},h0=(e,t,n,i,r)=>{const{overlappingOuterStrings:s,overlappingHoles:o}=$e(e.start,e.end,t,n),a=[...s,...o].map(u=>({start:u.start,end:u.end}));return Be([e.start,e.end],a).flatMap((u,f,d)=>{if(f===d.length-1)return[];const p=d[f+1],g=qu(s,o,u,e.subKind);return[{top:u,bottom:p,diameter:g*i}]}).map(u=>{const f=r(u.top,u.bottom);return{diameter:u.diameter,points:f}})},He=(e,t,n)=>{const{packingOpacity:i,yellow:r}=n;t.fillStyle=r,t.strokeStyle=r;const s=[0,0],o=[e.width,e.height];t.save(),t.globalAlpha=i,t.fillRect(...s,...o),t.restore()},Un=(e,t,n,i,r)=>{const{fracLineCurve:s}=i,o=10,a=e.width/o,c=n/3*i.scalingFactor,h=c/4,l=c/2,u=0,f=r==="diameter"?0:l;t.globalAlpha=i.packingOpacity;const d=()=>{for(let p=-1;p<o;p++){const g=[p*a+u+a/2,e.height/2-h-f-h];t.beginPath();const y=[...g],m=[g[0]-s*2,g[1]-h/4],_=[g[0],g[1]-h/2],v=[g[0]+s*2,g[1]-h/2-h/4],M=[g[0],g[1]-h];t.bezierCurveTo(...y,...m,..._),t.bezierCurveTo(..._,...v,...M),t.stroke()}for(let p=-1;p<o;p++){const g=[p*a+a+u+a/2,e.height/2+c/2+f];t.beginPath();const y=[...g],m=[g[0]-s*2,g[1]+h/4],_=[g[0],g[1]+h/2],v=[g[0]+s*2,g[1]+h/2+h/4],M=[g[0],g[1]+h];t.bezierCurveTo(...y,...m,..._),t.bezierCurveTo(..._,...v,...M),t.stroke()}};t.strokeStyle=i.yellow,t.lineWidth=6,t.save(),d(),t.restore(),t.lineWidth=1,t.strokeStyle=i.outline,d(),t.closePath()},l0=(e,t,n,i)=>{const s=e.width/4;t.strokeStyle=i.outline;const o=n/3*i.scalingFactor;t.lineWidth=1;const a=o/2;for(let c=0;c<=4;c++){const h=[c*s,e.height/2-o/2],l=[h[0]-s/2,h[1]-a],u=[h[0]-s,h[1]];t.beginPath(),t.moveTo(...h),t.lineTo(...l),t.lineTo(...u),t.fill(),t.lineWidth=1,t.stroke()}for(let c=0;c<=4;c++){const h=[c*s,e.height/2+o/2],l=[h[0]-s/2,h[1]+a],u=[h[0]-s,h[1]];t.beginPath(),t.moveTo(...h),t.lineTo(...l),t.lineTo(...u),t.fill(),t.lineWidth=1,t.stroke()}t.closePath()},ht=(e="Error!",t)=>{console.error(`${e}`);const n=document.createElement("canvas"),i=vt;n.width=i/2,n.height=i;const r=n.getContext("2d"),s=[0,0],o=[n.width,n.height];if(r==null)throw Error("Could not get canvas context!");return r.fillStyle="#ff00ff",r.fillRect(...s,...o),new R.Texture({source:new R.CanvasSource({resource:n,wrapMode:"clamp-to-edge"}),orig:new R.Rectangle(0,0,n.width,n.height),rotate:R.groupD8.MIRROR_HORIZONTAL})},wt=(e,t)=>{const n=document.createElement("canvas"),r=e.diameter*t.scalingFactor;n.width=r/2,n.height=r;const s=n.getContext("2d");if(s==null)throw Error("Could not get canvas context!");return{canvas:n,ctx:s}},bt=e=>new R.Texture({source:new R.CanvasSource({resource:e}),orig:new R.Rectangle(0,0,e.width,e.height),rotate:R.groupD8.MIRROR_HORIZONTAL}),u0=(e,t)=>n=>t.some(i=>n(i)&&Ur(e,i)),Vn={packing:()=>ht(),fracLines:()=>ht(),spikes:(e,t,n,i)=>{const{canvas:r,ctx:s}=wt(t,i),o=u0(e,n),a=o(Br),c=o(Xr),h=o(Hr),u=a||c||h?i.yellow:i.red;return s.globalAlpha=i.packingOpacity,e.isOpen?(s.fillStyle=u,s.strokeStyle=u):(s.fillStyle=i.grey,s.strokeStyle=i.grey),l0(r,s,t.diameter,i),h&&Un(r,s,t.diameter,i,"spike"),bt(r)}},ds={packing:()=>ht(),fracLines:(e,t)=>{const{canvas:n,ctx:i}=wt(e,t);return Un(n,i,e.diameter,t,"diameter"),bt(n)},spikes:()=>ht()},Ee={packing:(e,t)=>{const{canvas:n,ctx:i}=wt(e,t);return He(n,i,t),bt(n)},fracLines:(e,t)=>{const{canvas:n}=wt(e,t);return bt(n)},spikes:()=>ht()},Wn={packing:(e,t)=>{const{canvas:n,ctx:i}=wt(e,t);return He(n,i,t),bt(n)},fracLines:()=>ht(),spikes:()=>ht()},Yn={packing:(e,t)=>{const{canvas:n,ctx:i}=wt(e,t);return He(n,i,t),bt(n)},fracLines:()=>ht(),spikes:()=>ht()},Gn={packing:(e,t,n)=>{const{canvas:i,ctx:r}=wt(t,n);return He(i,r,n),bt(i)},fracLines:(e,t)=>{const{canvas:n,ctx:i}=wt(e,t);return Un(n,i,e.diameter,t,"diameter"),bt(n)},spikes:()=>ht()},f0=(e,t,n)=>J({Perforation:()=>Vn.packing(),CasedHoleFracturation:()=>Ee.packing(t,n),CasedHoleFracPack:()=>Ee.packing(t,n),OpenHoleGravelPack:()=>Yn.packing(t,n),OpenHoleFracPack:()=>Gn.packing(e,t,n),CasedHoleGravelPack:()=>Wn.packing(t,n)},e.subKind),d0=(e,t,n)=>J({Perforation:()=>Vn.fracLines(),OpenHoleGravelPack:()=>Yn.fracLines(),OpenHoleFracPack:()=>Gn.fracLines(t,n),CasedHoleFracturation:()=>ds.fracLines(t,n),CasedHoleGravelPack:()=>Wn.fracLines(),CasedHoleFracPack:()=>Ee.fracLines(t,n)},e.subKind),p0=(e,t,n,i)=>J({Perforation:()=>Vn.spikes(e,n,t,i),OpenHoleGravelPack:()=>Yn.spikes(),OpenHoleFracPack:()=>Gn.spikes(),CasedHoleFracturation:()=>ds.spikes(),CasedHoleGravelPack:()=>Wn.spikes(),CasedHoleFracPack:()=>Ee.spikes()},e.subKind);class g0 extends R.MeshGeometry{constructor(t){const n=We(t,i=>i.points.length);super({positions:new Float32Array(n*4),uvs:new Float32Array(n*4),indices:new Uint32Array((n-1)*6),shrinkBuffersToFit:!0}),this.segments=t,this.build()}get width(){return sn(this.segments,t=>t.diameter)}build(){var p,g,y,m,_,v,M,b;const t=this.segments;if(!t)return;const n=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),r=this.getIndex(),s=We(t,T=>T.points.length);if(s<1)return;n.data.length/4!==s&&(n.data=new Float32Array(s*4),i.data=new Float32Array(s*4),r.data=new Uint16Array((s-1)*6));const o=i.data,a=r.data;o[0]=0,o[1]=0,o[2]=0,o[3]=1;const c=t.length,h=sn(t,T=>T.diameter);let l=0,u=0,f=0,d=0;for(let T=0;T<c;T++){let S=(p=t[T])==null?void 0:p.points[0];const C=h,k=((g=t[T])==null?void 0:g.diameter)/h/2,I=(y=t[T])==null?void 0:y.points.length;for(let P=0;P<I;P++){const O=S.x-((_=(m=t[T])==null?void 0:m.points[P])==null?void 0:_.x),$=S.y-((M=(v=t[T])==null?void 0:v.points[P])==null?void 0:M.y),x=Math.sqrt(O*O+$*$);S=(b=t[T])==null?void 0:b.points[P],l+=x/C,o[u]=l,o[u+1]=.5-k,o[u+2]=l,o[u+3]=.5+k,u+=4}for(let P=0;P<I-1;P++)a[d++]=f,a[d++]=f+1,a[d++]=f+2,a[d++]=f+2,a[d++]=f+1,a[d++]=f+3,f+=2;f+=2}i.update(),r.update(),this.updateVertices()}updateVertices(){var s,o,a,c,h,l,u,f;const t=this.segments;if(We(t,d=>d.points.length)<1)return;const i=t.length;let r=0;for(let d=0;d<i;d++){let p=(s=t[d])==null?void 0:s.points[0],g,y=0,m=0;const _=(o=this.buffers[0])==null?void 0:o.data,v=(a=t[d])==null?void 0:a.points.length;let M=0;for(let b=0;b<v;b++){const T=(c=t[d])==null?void 0:c.points[b];M=r+b*4,b<((h=t[d])==null?void 0:h.points.length)-1?g=(l=t[d])==null?void 0:l.points[b+1]:g=T,m=-(g.x-p.x),y=g.y-p.y;const S=Math.sqrt(y*y+m*m),C=((u=t[d])==null?void 0:u.diameter)/2;y/=S,m/=S,y*=C,m*=C,_!=null&&(_[M]=T.x+y,_[M+1]=T.y+m,_[M+2]=T.x-y,_[M+3]=T.y-m),p=T}r=M+4}(f=this.buffers[0])==null||f.update()}update(){this.build()}}class m0 extends R.Mesh{constructor(t,n){const i=new g0(n);t.source.addressMode="repeat",super({geometry:i,texture:t}),this.autoUpdate=!0,this.onRender=()=>{const r=this.geometry;this.autoUpdate&&r.update()}}}class y0 extends R.MeshGeometry{constructor(t,n=200){super({positions:new Float32Array(t.length*4),uvs:new Float32Array(t.length*4),indices:new Uint32Array((t.length-1)*6)}),this.points=t,this._width=n,this.build()}get width(){return this._width}build(){var u,f;const t=this.points;if(!t)return;const n=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),r=this.getIndex();if(t.length<1)return;n.data.length/4!==t.length&&(n.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),r.data=new Uint16Array((t.length-1)*6));const s=i.data,o=r.data;s[0]=0,s[1]=0,s[2]=0,s[3]=1;let a=0,c=t[0];const h=t.length;for(let d=0;d<h;d++){const p=d*4,g=c.x-((u=t[d])==null?void 0:u.x),y=c.y-((f=t[d])==null?void 0:f.y),m=Math.sqrt(g*g+y*y);c=t[d],a+=m/this._width,s[p]=a,s[p+1]=0,s[p+2]=a,s[p+3]=1}let l=0;for(let d=0;d<h-1;d++){const p=d*2;o[l++]=p,o[l++]=p+1,o[l++]=p+2,o[l++]=p+2,o[l++]=p+1,o[l++]=p+3}i.update(),r.update(),this.updateVertices()}updateVertices(){var c,h;const t=this.points;if(t.length<1)return;let n=t[0],i,r=0,s=0;const o=(c=this.buffers[0])==null?void 0:c.data,a=t.length;for(let l=0;l<a;l++){const u=t[l],f=l*4;l<t.length-1?i=t[l+1]:i=u,s=-(i.x-n.x),r=i.y-n.y;const d=Math.sqrt(r*r+s*s),p=this._width/2;r/=d,s/=d,r*=p,s*=p,o[f]=u.x+r,o[f+1]=u.y+s,o[f+2]=u.x-r,o[f+3]=u.y-s,n=u}(h=this.buffers[0])==null||h.update()}update(){this.build()}}class _0 extends R.Mesh{constructor(t,n,i){const r=new y0(n,i);t.source.addressMode="repeat",super({geometry:r,texture:t}),this.autoUpdate=!0,this.onRender=()=>{const s=this.geometry;this.autoUpdate&&s.update()}}}class x0 extends R.MeshGeometry{constructor(t,n=200){super({positions:new Float32Array(t.length*4),uvs:new Float32Array(t.length*4),indices:new Uint32Array((t.length-1)*6)}),this.points=t,this._width=n,this.build()}build(){var d,p,g,y;const t=this.points;if(!t)return;const n=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),r=this.getIndex();if(t.length<1)return;n.data.length/4!==t.length&&(n.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),r.data=new Uint16Array((t.length-1)*6));const s=t.length;let o=0,a=t[0];for(let m=0;m<s;m++){const _=a.x-((d=t[m])==null?void 0:d.x),v=a.y-((p=t[m])==null?void 0:p.y),M=Math.sqrt(_*_+v*v);a=t[m],o+=M}const c=i.data,h=r.data;c[0]=0,c[1]=0,c[2]=0,c[3]=1;let l=0,u=t[0];for(let m=0;m<s;m++){const _=m*4,v=u.x-((g=t[m])==null?void 0:g.x),M=u.y-((y=t[m])==null?void 0:y.y),b=Math.sqrt(v*v+M*M);u=t[m],l+=b/o,c[_]=l,c[_+1]=0,c[_+2]=l,c[_+3]=1}let f=0;for(let m=0;m<s-1;m++){const _=m*2;h[f++]=_,h[f++]=_+1,h[f++]=_+2,h[f++]=_+2,h[f++]=_+1,h[f++]=_+3}i.update(),r.update(),this.updateVertices()}updateVertices(){var c,h;const t=this.points;if(t.length<1)return;let n=t[0],i,r=0,s=0;const o=(c=this.buffers[0])==null?void 0:c.data,a=t.length;for(let l=0;l<a;l++){const u=t[l],f=l*4;l<t.length-1?i=t[l+1]:i=u,s=-(i.x-n.x),r=i.y-n.y;const d=Math.sqrt(r*r+s*s),p=this._width/2;r/=d,s/=d,r*=p,s*=p,o[f]=u.x+r,o[f+1]=u.y+s,o[f+2]=u.x-r,o[f+3]=u.y-s,n=u}(h=this.buffers[0])==null||h.update()}update(){this.updateVertices()}}class v0 extends R.Mesh{constructor(t,n){const i=new x0(n,t.height);super({geometry:i,texture:t}),this.autoUpdate=!0,this.onRender=()=>{var s,o;const r=this.geometry;(this.autoUpdate||r._width!==((s=this.shader)==null?void 0:s.texture.height))&&(r._width=((o=this.shader)==null?void 0:o.texture.height)??0,r.update())}}}const w0=(e,t,n)=>i=>{switch(i.kind){case"casing":return e(i);case"cement":return t(i);case"cementSqueeze":return n(i);default:return ee(i)}},b0=e=>({exaggerationFactor:2,internalLayerOptions:Vr(e),holeOptions:Wr,casingOptions:Yr,cementOptions:qr,cementSqueezeOptions:jr,screenOptions:Zr,tubingOptions:Kr,cementPlugOptions:Qr,perforationOptions:Gr}),Re=class Re extends $n{constructor(t,n,i){super(t,n,i),this.internalLayerVisibility={holeLayerId:!0,casingLayerId:!0,completionLayerId:!0,cementLayerId:!0,pAndALayerId:!0,perforationLayerId:!0},this.cementTextureCache=null,this.cementSqueezeTextureCache=null,this.cementPlugTextureCache=null,this.holeTextureCache=null,this.screenTextureCache=null,this.tubingTextureCache=null,this.textureSymbolCacheArray=null,this.scalingFactors={height:600,zFactor:1,yScale:Lt()},this.getZFactorScaledPathForPoints=(r,s)=>{var c;const o=h=>h*this.scalingFactors.zFactor;return(((c=this.referenceSystem)==null?void 0:c.getCurtainPath(r,s,!0))??[]).map(h=>new R.Point(h.point[0],o(h.point[1])))},this.drawBigPolygon=(r,s=0)=>{const o=new R.Graphics;o.poly(r),o.fill(s),this.addChild(o)},this.perforationRopeAndTextureReferences=[],this.prepareSymbolRenderObject=r=>{const{exaggerationFactor:s=1}=this.options,o=r.diameter*s;return{pathPoints:this.getZFactorScaledPathForPoints(r.start,r.end),referenceDiameter:o,symbolKey:r.symbolKey}},this.drawSymbolComponent=({pathPoints:r,referenceDiameter:s,symbolKey:o})=>{const a=this.getSymbolTexture(o,s);this.drawSVGRope(r,a)},this.drawHoleSize=(r,s)=>{if(s==null)return;const o=this.getZFactorScaledPathForPoints(s.start,s.end);if(o.length===0)return;const{exaggerationFactor:a=1,holeOptions:c}=this.options,h=s.diameter*a,{rightPath:l,leftPath:u}=ye(h/2,o),f=this.getHoleTexture(c,h,r);this.drawHoleRope(o,f,r),this.drawOutline(u,l,dt(c.lineColor),Tl*a,"TopAndBottom",0)},this.drawCasing=r=>{const{casingOptions:s}=this.options,o=dt(s.solidColor),a=dt(s.lineColor);r.sections.forEach((c,h,l)=>{const u=Re.getOutlineClosureType(h,l.length-1),f=this.createCasingTexture(r.referenceDiameter);this.drawRope(c.pathPoints,f,o),c.kind==="casing-window"?this.drawCasingWindowOutline(c.leftPath,c.rightPath,s,r.casingWallWidth):this.drawOutline(c.leftPath,c.rightPath,a,r.casingWallWidth,u)})},this.generateShoe=(r,s,o,a)=>{const c=r-o,h=r,l=this.getZFactorScaledPathForPoints(c,h),u=ls(l),f=Sn(l,u,s*(a<0?-1:1)),d=l[l.length-1],p=u[u.length-1],g=us(d,p,a+s*(a<0?-1:1));return[...f,g]},this.createCementSqueezeShape=(r,s,o,a)=>{const{exaggerationFactor:c=1}=this.options;return Ku(r,s,o,a,c,this.getZFactorScaledPathForPoints)},this.createPerforationShape=(r,s,o)=>{const{exaggerationFactor:a=1}=this.options;return h0(r,s,o,a,this.getZFactorScaledPathForPoints)},this.options={...this.options,...b0(this.id),...i}}onUnmount(t){super.onUnmount(t),this.cementTextureCache=null,this.cementSqueezeTextureCache=null,this.holeTextureCache=null,this.screenTextureCache=null,this.tubingTextureCache=null,this.textureSymbolCacheArray=null}async onUpdate(t){super.onUpdate(t),this.clearLayer(),await this.preRender(),this.render()}async onRescale(t){const n=this.scalingFactors.zFactor!==t.zFactor;this.scalingFactors={height:t.height,zFactor:t.zFactor,yScale:t.yScale},super.optionsRescale(t);const i=this.yRatio(),r=t.xBounds[0]>t.xBounds[1],s=t.yBounds[0]>t.yBounds[1];this.setContainerPosition(t.xScale(0),t.yScale(0)),this.setContainerScale(t.xRatio*(r?-1:1),i*(s?-1:1)),n&&(this.clearLayer(),await this.preRender()),this.render()}async setVisibility(t,n){if(n===this.id){super.setVisibility(t,n);return}const{internalLayerOptions:i}=this.options,s=(i?Object.entries(i):[]).find(([a,c])=>c===n),o=s==null?void 0:s[0];o&&(this.internalLayerVisibility[o]=t,this.clearLayer(),await this.preRender(),this.render())}getInternalLayerIds(){const{internalLayerOptions:t}=this.options;return t?Object.values(t):[]}yRatio(){const t=this.scalingFactors.yScale.domain(),i=(t[1]-t[0])*this.scalingFactors.zFactor,r=[t[0],t[0]+i];return Math.abs(this.scalingFactors.height/(r[1]-r[0]))}drawRope(t,n,i){if(t.length===0)return;const r=new R.MeshRope({texture:n,points:t,textureScale:1});r.tint=i||r.tint,this.addChild(r)}drawOutline(t,n,i,r=1,s="None",o=1){const a=t.map(u=>u.clone()).reverse(),c=n[0],h=a[0],l=new R.Graphics;l.moveTo(c.x,c.y),n.forEach(u=>l.lineTo(u.x,u.y)),(s==="None"||s==="Top")&&l.moveTo(h.x,h.y),a.forEach(u=>l.lineTo(u.x,u.y)),(s==="TopAndBottom"||s==="Top")&&l.lineTo(c.x,c.y),l.stroke({width:r,color:i,alignment:o}),this.addChild(l)}drawCasingWindowOutline(t,n,{lineColor:i,windowOptions:r},s=1){var g,y;const o=!!((y=(g=this.referenceSystem)==null?void 0:g.options)!=null&&y.calculateDisplacementFromBottom),[a,c]=o?[t,n]:[n,t],[h,l]=o?[1,0]:[0,1],u=new R.Graphics,f=a[0];u.moveTo(f.x,f.y),a.forEach(m=>u.lineTo(m.x,m.y)),u.setStrokeStyle({width:s,color:dt(i),alignment:l});const d=new wn(u,{dash:[r.dashLength,r.spaceLength],color:dt(r.dashColor),width:s,alignment:h}),p=c[0];d.moveTo(p.x,p.y),c.forEach(m=>{d.lineTo(m.x,m.y)}),this.addChild(u)}async preRender(){if(!this.data||!this.referenceSystem)return;const{exaggerationFactor:t=1}=this.options,{holeSizes:n,casings:i,cements:r,completion:s,symbols:o,pAndA:a,perforations:c}=this.data;await this.updateSymbolCache(o),n.sort((g,y)=>y.diameter-g.diameter);const h=n.length>0?(sn(n,g=>g.diameter)??0)*t:Sl*t;this.internalLayerVisibility.holeLayerId&&n.forEach(g=>this.drawHoleSize(h,g)),i.sort((g,y)=>y.diameter-g.diameter);const l=i.map(g=>this.createCasingRenderObject(g)),u=r.map(g=>({kind:"cement",segments:Zu(g,i,s,n,t,this.getZFactorScaledPathForPoints),casingIds:(g.referenceIds||[]).filter(y=>y)})),[f,d]=a.reduce(([g,y],m)=>Ir(m)?[[m,...g],y]:[g,[m,...y]],[[],[]]),p=f.map(g=>({kind:"cementSqueeze",segments:this.createCementSqueezeShape(g,i,s,n),casingIds:g.referenceIds}));if(this.sortCementAndCasingRenderObjects(l,u,p).forEach(w0(g=>{this.internalLayerVisibility.casingLayerId&&(this.drawCasing(g),g.hasShoe&&this.drawShoe(g.bottom,g.referenceRadius))},g=>{if(this.internalLayerVisibility.cementLayerId){const y=this.getCementTexture();y&&this.drawComplexRope(g.segments,y)}},g=>{if(this.internalLayerVisibility.pAndALayerId){const y=this.getCementSqueezeTexture();y&&this.drawComplexRope(g.segments,y)}})),this.perforationRopeAndTextureReferences.forEach(({rope:g,texture:y})=>{g.destroyed||g.destroy({children:!0,texture:!0,textureSource:!0}),y&&y.destroy(!0)}),this.perforationRopeAndTextureReferences=[],this.internalLayerVisibility.perforationLayerId){const{perforationOptions:g}=this.options,y=c.filter(Dr),m=c.filter(Nr),_=c.filter($r);y.forEach(v=>{const b=this.createPerforationShape(v,i,n).reduce((T,S)=>(T[S.diameter]||(T[S.diameter]=[]),T[S.diameter]=[...T[S.diameter]??[],S],T),{});Object.values(b).forEach(T=>{const S=f0(v,T[0],g),C=this.drawComplexRope(T,S);C&&this.perforationRopeAndTextureReferences.push({rope:C,texture:S})})}),_.forEach(v=>{const T=this.createPerforationShape(v,i,n).map(S=>({...S,diameter:S.diameter*3})).reduce((S,C)=>(S[C.diameter]||(S[C.diameter]=[]),S[C.diameter]=[...S[C.diameter]??[],C],S),{});Object.values(T).forEach(S=>{S.forEach(C=>{const k=p0(v,c,C,g),I=this.drawComplexRope([C],k);I&&this.perforationRopeAndTextureReferences.push({rope:I,texture:k})})})}),m.forEach(v=>{const T=this.createPerforationShape(v,i,n).map(S=>({...S,diameter:S.diameter*3})).reduce((S,C)=>(S[C.diameter]||(S[C.diameter]=[]),S[C.diameter]=[...S[C.diameter]??[],C],S),{});Object.values(T).forEach(S=>{S.forEach(C=>{const k=d0(v,C,g),I=this.drawComplexRope([C],k);I&&this.perforationRopeAndTextureReferences.push({rope:I,texture:k})})})})}this.internalLayerVisibility.completionLayerId&&s.forEach(zr(g=>this.drawScreen(g),g=>this.drawTubing(g),g=>{const y=this.prepareSymbolRenderObject(g);this.drawSymbolComponent(y)})),this.internalLayerVisibility.pAndALayerId&&d.forEach(g=>{if(Rr(g)){const y=this.prepareSymbolRenderObject(g);this.drawSymbolComponent(y)}Or(g)&&this.drawCementPlug(g,i,s,n)})}async updateSymbolCache(t){if(this.textureSymbolCacheArray||(this.textureSymbolCacheArray={}),!t)return;const n=Object.keys(this.textureSymbolCacheArray),i=Object.entries(t).map(async([r,s])=>{!n.includes(r)&&this.textureSymbolCacheArray&&(this.textureSymbolCacheArray[r]=await R.Assets.load(s))});await Promise.all(i)}drawCementPlug(t,n,i,r){const{exaggerationFactor:s=1,cementPlugOptions:o}=this.options,a=Qu(t,n,i,r,s,this.getZFactorScaledPathForPoints);o&&this.drawComplexRope(a,this.getCementPlugTexture(o));const{rightPath:c,leftPath:h}=a.reduce((l,u)=>{const{leftPath:f,rightPath:d}=ye(u.diameter/2,u.points);return{rightPath:[...l.rightPath,...d],leftPath:[...l.leftPath,...f]}},{rightPath:[],leftPath:[]});this.drawOutline(h,c,dt("black"),.25,"TopAndBottom")}createCasingRenderObject(t){const{exaggerationFactor:n=1}=this.options;return c0(n,t,this.getZFactorScaledPathForPoints)}getCementPlugTexture(t){return this.cementPlugTextureCache||(this.cementPlugTextureCache=r0(t)),this.cementPlugTextureCache}drawSVGRope(t,n){if(t.length===0)return;const i=new v0(n,t);this.addChild(i)}getSymbolTexture(t,n){var r,s;const i=(s=(r=this.textureSymbolCacheArray)==null?void 0:r[t])==null?void 0:s.source;return i?new R.Texture({source:i,orig:new R.Rectangle(0,0,0,n),rotate:R.groupD8.MAIN_DIAGONAL}):void 0}drawHoleRope(t,n,i){if(t.length===0)return;const r=new R.MeshRope({texture:n,points:t,textureScale:i/vt});this.addChild(r)}getHoleTexture(t,n,i){const r=vt,s=r,o=r,a=n/i*r;this.holeTextureCache||(this.holeTextureCache=t0(t,o,s));const c=this.holeTextureCache.source,h=(s-a)/2,l=new R.Rectangle(0,h,o,a);return new R.Texture({source:c,frame:l})}sortCementAndCasingRenderObjects(t,n,i){let r=0;const{result:s}=t.reduce((o,a)=>{const c=o.remainingCement.find(l=>l.casingIds.includes(a.id)),h=o.remainingCementSqueezes.filter(l=>l.casingIds.includes(a.id));return c&&(c.zIndex=r++),h.forEach(l=>l.zIndex=r++),a.zIndex=r++,{result:[...o.result,c,a,...h],remainingCement:o.remainingCement.filter(l=>l!==c),remainingCementSqueezes:o.remainingCementSqueezes.filter(l=>!h.includes(l))}},{result:[],remainingCement:n,remainingCementSqueezes:i});return s.filter(o=>o!=null).sort((o,a)=>o.zIndex-a.zIndex)}drawComplexRope(t,n){if(t.length===0)return;const i=new m0(n,t);return this.addChild(i),i}createCasingTexture(t){return new R.Texture({source:R.Texture.WHITE.source,orig:new R.Rectangle(0,0,16,t)})}drawShoe(t,n){const{exaggerationFactor:i=1,casingOptions:r}=this.options,s=r.shoeSize.width*i,o=r.shoeSize.length*i,a=this.generateShoe(t,n,o,s),c=this.generateShoe(t,n,o,-s);this.drawBigPolygon(c),this.drawBigPolygon(a)}getCementTexture(){if(!this.cementTextureCache){const{cementOptions:t}=this.options;t&&(this.cementTextureCache=i0(t))}return this.cementTextureCache}getCementSqueezeTexture(){if(!this.cementSqueezeTextureCache){const{cementSqueezeOptions:t}=this.options;t&&(this.cementSqueezeTextureCache=s0(t))}return this.cementSqueezeTextureCache}drawScreen({start:t,end:n,diameter:i}){const{exaggerationFactor:r=1,screenOptions:s}=this.options,o=r*i,a=this.getZFactorScaledPathForPoints(t,n),{leftPath:c,rightPath:h}=ye(o/2,a),l=this.getScreenTexture();l&&(this.drawCompletionRope(a,l,o),this.drawOutline(c,h,dt(s.lineColor),Ml*r,"TopAndBottom"))}drawTubing({diameter:t,start:n,end:i}){const{exaggerationFactor:r=1,tubingOptions:s}=this.options,o=r*t,a=this.getZFactorScaledPathForPoints(n,i),c=this.getTubingTexture(s);this.drawCompletionRope(a,c,o)}getTubingTexture(t){return this.tubingTextureCache||(this.tubingTextureCache=n0(t)),this.tubingTextureCache}getScreenTexture(){if(!this.screenTextureCache){const{screenOptions:t}=this.options;t&&(this.screenTextureCache=e0(t))}return this.screenTextureCache}drawCompletionRope(t,n,i){if(t.length===0)return;const r=new _0(n,t,i);this.addChild(r)}};Re.getOutlineClosureType=(t,n)=>t===0?t===n?"TopAndBottom":"Top":t===n?"Bottom":"None";let Tn=Re;class S0 extends St{onMount(t){super.onMount(t)}onUpdate(t){super.onUpdate(t),this.clearCanvas(),this.render()}onRescale(t){super.onRescale(t),this.setTransform(t),this.render()}render(){if(!this.data||!this.ctx||!this.data.image)return;const{ctx:t}=this,{options:n,image:i}=this.data;this.clearCanvas(),t.drawImage(i,n.x,n.y,n.width,n.height)}}function Et(e){return function(){return e}}const Oi=1e-12,Mn=Math.PI,An=2*Mn,Mt=1e-6,T0=An-Mt;function ps(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function M0(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return ps;const n=10**t;return function(i){this._+=i[0];for(let r=1,s=i.length;r<s;++r)this._+=Math.round(arguments[r]*n)/n+i[r]}}class A0{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?ps:M0(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,i,r){this._append`Q${+t},${+n},${this._x1=+i},${this._y1=+r}`}bezierCurveTo(t,n,i,r,s,o){this._append`C${+t},${+n},${+i},${+r},${this._x1=+s},${this._y1=+o}`}arcTo(t,n,i,r,s){if(t=+t,n=+n,i=+i,r=+r,s=+s,s<0)throw new Error(`negative radius: ${s}`);let o=this._x1,a=this._y1,c=i-t,h=r-n,l=o-t,u=a-n,f=l*l+u*u;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(f>Mt)if(!(Math.abs(u*c-h*l)>Mt)||!s)this._append`L${this._x1=t},${this._y1=n}`;else{let d=i-o,p=r-a,g=c*c+h*h,y=d*d+p*p,m=Math.sqrt(g),_=Math.sqrt(f),v=s*Math.tan((Mn-Math.acos((g+f-y)/(2*m*_)))/2),M=v/_,b=v/m;Math.abs(M-1)>Mt&&this._append`L${t+M*l},${n+M*u}`,this._append`A${s},${s},0,0,${+(u*d>l*p)},${this._x1=t+b*c},${this._y1=n+b*h}`}}arc(t,n,i,r,s,o){if(t=+t,n=+n,i=+i,o=!!o,i<0)throw new Error(`negative radius: ${i}`);let a=i*Math.cos(r),c=i*Math.sin(r),h=t+a,l=n+c,u=1^o,f=o?r-s:s-r;this._x1===null?this._append`M${h},${l}`:(Math.abs(this._x1-h)>Mt||Math.abs(this._y1-l)>Mt)&&this._append`L${h},${l}`,i&&(f<0&&(f=f%An+An),f>T0?this._append`A${i},${i},0,1,${u},${t-a},${n-c}A${i},${i},0,1,${u},${this._x1=h},${this._y1=l}`:f>Mt&&this._append`A${i},${i},0,${+(f>=Mn)},${u},${this._x1=t+i*Math.cos(s)},${this._y1=n+i*Math.sin(s)}`)}rect(t,n,i,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${i=+i}v${+r}h${-i}Z`}toString(){return this._}}function P0(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const i=Math.floor(n);if(!(i>=0))throw new RangeError(`invalid digits: ${n}`);t=i}return e},()=>new A0(t)}function C0(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function gs(e){this._context=e}gs.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function ms(e){return new gs(e)}function L0(e){return e[0]}function k0(e){return e[1]}function E0(e,t){var n=Et(!0),i=null,r=ms,s=null,o=P0(a);e=typeof e=="function"?e:e===void 0?L0:Et(e),t=typeof t=="function"?t:t===void 0?k0:Et(t);function a(c){var h,l=(c=C0(c)).length,u,f=!1,d;for(i==null&&(s=r(d=o())),h=0;h<=l;++h)!(h<l&&n(u=c[h],h,c))===f&&((f=!f)?s.lineStart():s.lineEnd()),f&&s.point(+e(u,h,c),+t(u,h,c));if(d)return s=null,d+""||null}return a.x=function(c){return arguments.length?(e=typeof c=="function"?c:Et(+c),a):e},a.y=function(c){return arguments.length?(t=typeof c=="function"?c:Et(+c),a):t},a.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Et(!!c),a):n},a.curve=function(c){return arguments.length?(r=c,i!=null&&(s=r(i)),a):r},a.context=function(c){return arguments.length?(c==null?i=s=null:s=r(i=c),a):i},a}function zi(){}function Pn(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function Xe(e){this._context=e}Xe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Pn(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Pn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function F0(e){return new Xe(e)}function ys(e){this._context=e}ys.prototype={areaStart:zi,areaEnd:zi,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Pn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function R0(e){return new ys(e)}function _s(e,t){this._basis=new Xe(e),this._beta=t}_s.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var e=this._x,t=this._y,n=e.length-1;if(n>0)for(var i=e[0],r=t[0],s=e[n]-i,o=t[n]-r,a=-1,c;++a<=n;)c=a/n,this._basis.point(this._beta*e[a]+(1-this._beta)*(i+c*s),this._beta*t[a]+(1-this._beta)*(r+c*o));this._x=this._y=null,this._basis.lineEnd()},point:function(e,t){this._x.push(+e),this._y.push(+t)}};const I0=(function e(t){function n(i){return t===1?new Xe(i):new _s(i,t)}return n.beta=function(i){return e(+i)},n})(.85);function Di(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function qn(e,t){this._context=e,this._k=(1-t)/6}qn.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:Di(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:Di(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const O0=(function e(t){function n(i){return new qn(i,t)}return n.tension=function(i){return e(+i)},n})(0);function z0(e,t,n){var i=e._x1,r=e._y1,s=e._x2,o=e._y2;if(e._l01_a>Oi){var a=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,c=3*e._l01_a*(e._l01_a+e._l12_a);i=(i*a-e._x0*e._l12_2a+e._x2*e._l01_2a)/c,r=(r*a-e._y0*e._l12_2a+e._y2*e._l01_2a)/c}if(e._l23_a>Oi){var h=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,l=3*e._l23_a*(e._l23_a+e._l12_a);s=(s*h+e._x1*e._l23_2a-t*e._l12_2a)/l,o=(o*h+e._y1*e._l23_2a-n*e._l12_2a)/l}e._context.bezierCurveTo(i,r,s,o,e._x2,e._y2)}function xs(e,t){this._context=e,this._alpha=t}xs.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,i=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:z0(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const D0=(function e(t){function n(i){return t?new xs(i,t):new qn(i,0)}return n.alpha=function(i){return e(+i)},n})(.5);function Ni(e){return e<0?-1:1}function $i(e,t,n){var i=e._x1-e._x0,r=t-e._x1,s=(e._y1-e._y0)/(i||r<0&&-0),o=(n-e._y1)/(r||i<0&&-0),a=(s*r+o*i)/(i+r);return(Ni(s)+Ni(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(a))||0}function Bi(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function en(e,t,n){var i=e._x0,r=e._y0,s=e._x1,o=e._y1,a=(s-i)/3;e._context.bezierCurveTo(i+a,r+a*t,s-a,o-a*n,s,o)}function Fe(e){this._context=e}Fe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:en(this,this._t0,Bi(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,en(this,Bi(this,n=$i(this,e,t)),n);break;default:en(this,this._t0,n=$i(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function vs(e){this._context=new ws(e)}(vs.prototype=Object.create(Fe.prototype)).point=function(e,t){Fe.prototype.point.call(this,t,e)};function ws(e){this._context=e}ws.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,i,r,s){this._context.bezierCurveTo(t,e,i,n,s,r)}};function N0(e){return new Fe(e)}function $0(e){return new vs(e)}function bs(e){this._context=e}bs.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var i=Hi(e),r=Hi(t),s=0,o=1;o<n;++s,++o)this._context.bezierCurveTo(i[0][s],r[0][s],i[1][s],r[1][s],e[o],t[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function Hi(e){var t,n=e.length-1,i,r=new Array(n),s=new Array(n),o=new Array(n);for(r[0]=0,s[0]=2,o[0]=e[0]+2*e[1],t=1;t<n-1;++t)r[t]=1,s[t]=4,o[t]=4*e[t]+2*e[t+1];for(r[n-1]=2,s[n-1]=7,o[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)i=r[t]/s[t-1],s[t]-=i,o[t]-=i*o[t-1];for(r[n-1]=o[n-1]/s[n-1],t=n-2;t>=0;--t)r[t]=(o[t]-r[t+1])/s[t];for(s[n-1]=(e[n]+r[n-1])/2,t=0;t<n-1;++t)s[t]=2*e[t+1]-r[t+1];return[r,s]}function B0(e){return new bs(e)}function Ue(e,t){this._context=e,this._t=t}Ue.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function H0(e){return new Ue(e,.5)}function X0(e){return new Ue(e,0)}function U0(e){return new Ue(e,1)}const V0=.7,W0=.9,Y0=1;class G0 extends Fr{constructor(t,n){super(t,n),this.options={...this.options,...n},this.render=this.render.bind(this)}onUpdate(t){super.onUpdate(t),this.render()}onRescale(t){super.onRescale(t),this.elm&&(this.rescaleEvent=t,this.render())}render(){const{strokeWidth:t,stroke:n}=this.options;if(!this.elm)return;this.elm.select("g").remove();const i=this.data||this.referenceSystem&&this.referenceSystem.projectedPath;!i||!this.rescaleEvent||this.elm.append("g").attr("class","well-path").append("path").attr("d",this.renderWellborePath(i)).attr("stroke-width",t||"2px").attr("stroke",n||"red").attr("fill","none")}renderWellborePath(t){if(this.rescaleEvent!=null){const{xScale:n,yScale:i}=this.rescaleEvent,r=t.map(c=>[n(c[0]),i(c[1])]);let s;const{curveType:o,tension:a}=this.options;switch(o){default:case"curveCatmullRom":s=D0.alpha(a||V0);break;case"curveLinear":s=ms;break;case"curveBasis":s=F0;break;case"curveBasisClosed":s=R0;break;case"curveBundle":s=I0.beta(a||Y0);break;case"curveCardinal":s=O0.tension(a||W0);break;case"curveMonotoneX":s=N0;break;case"curveMonotoneY":s=$0;break;case"curveNatural":s=B0;break;case"curveStep":s=H0;break;case"curveStepAfter":s=U0;break;case"curveStepBefore":s=X0;break}return E0().curve(s)(r)??""}return""}}const Xi=(e,t)=>{switch(t.lineType){case"wavy":return e.wavy(t);case"dashed":return e.dashed(t);case"solid":return e.solid(t);default:return ee(t.lineType)}};class q0 extends St{constructor(){super(...arguments),this.yScale=null,this.xScale=null}onMount(t){super.onMount(t)}onUpdate(t){super.onUpdate(t),this.clearCanvas(),this.render()}onRescale(t){super.onRescale(t),this.yScale=t.yScale,this.xScale=t.xScale,this.resetTransform(),this.render()}drawDashed(t){var r;const{ctx:n}=this,{canvas:i}=this;if(n!=null&&i!=null){const s=(r=this.yScale)==null?void 0:r.call(this,t.depth);n.save(),n.strokeStyle=t.color,this.setCtxLineStyle(n,t),this.setCtxLineWidth(n,t),n.beginPath(),n.moveTo(0,s),n.lineTo(i.width,s),n.stroke(),n.restore(),t.text&&this.drawText(n,t,n.canvas.width,s)}}drawSolid(t){const{ctx:n}=this,{canvas:i}=this,r=this.yScale(t.depth);n!=null&&i!=null&&(n.save(),n.strokeStyle=t.color,this.setCtxLineStyle(n,t),this.setCtxLineWidth(n,t),n.beginPath(),n.moveTo(0,r),n.lineTo(i.width,r),n.stroke(),n.restore(),t.text&&this.drawText(n,t,n.canvas.width,r))}drawWavy(t){const{ctx:s,canvas:o}=this;if(this.xScale!=null&&this.yScale!=null&&o!=null&&s!=null){const a=ke(4,2.5,500,this.yScale),c=a*2,h=this.yScale(t.depth)-a,l=Math.ceil(o.width/c)+1,u=this.xScale(0)%c;s.save(),s.strokeStyle=t.color,this.setCtxLineStyle(s,t),this.setCtxLineWidth(s,t);for(let f=-1;f<l;f++)s.beginPath(),s.arc(f*c+u+a,h,a,0,Math.PI),s.stroke();s.restore(),t.text&&this.drawText(s,t,s.canvas.width,h)}}drawText(t,n,i,r){const s=n.textColor||"#000",o=n.fontSize||"10px sans-serif",a=10;t.save(),t.strokeStyle=s,t.font=o,t.textAlign="end",t.textBaseline="bottom",t.fillText(n.text??"",i-a,r),t.restore()}setCtxLineStyle(t,n){Xi({solid:()=>{t.setLineDash([])},dashed:()=>{t.setLineDash([8,10])},wavy:()=>{t.setLineDash([])}},n)}setCtxLineWidth(t,n){t.lineWidth=n.lineWidth||1}render(){!this.ctx||!this.yScale||!this.xScale||requestAnimationFrame(()=>{var t;this.clearCanvas(),(t=this.data)==null||t.forEach(n=>{Xi({solid:i=>this.drawSolid(i),dashed:i=>this.drawDashed(i),wavy:i=>this.drawWavy(i)},n)})})}}class Ss{constructor(t,n,i){if(this.layers=[],this.createAxis=r=>{const{container:s}=this;this._svgContainer=K(s).append("div").attr("class","axis").style("position","absolute").style("z-index","10").style("pointer-events","none");const o=this._svgContainer.append("svg").attr("height",`${s.offsetHeight}px`).attr("width",`${s.offsetWidth}px`),a=!0;return new nr(o,a,r.xLabel,r.yLabel,r.unitOfMeasure)},this.container=t,this.layerContainer=document.createElement("div"),this.layerContainer.className="layer-container",this.container.appendChild(this.layerContainer),this.adjustToSize(+(this.container.getAttribute("width")??0),+(this.container.getAttribute("height")??0)),this._zoomPanHandler=new Cr(t,r=>this.rescale(r)),n){const{xMin:r,xMax:s,yMin:o,yMax:a,xBounds:c,yBounds:h}=n;r!==void 0&&s!==void 0&&o!==void 0&&a!==void 0&&this._zoomPanHandler.setBounds([r,s],[o,a]),c&&h&&this._zoomPanHandler.setBounds(c,h)}else this._zoomPanHandler.setBounds([0,1],[0,1]);i&&(this._axis=this.createAxis(i)),this.rescale=this.rescale.bind(this)}addLayers(t){return t.forEach(n=>this.addLayer(n)),this}getLayers(){return this.layers}clearAllData(t=!0){return this.layers.forEach(n=>n.clearData(t)),this}addLayer(t,n){return this.layers.push(t),this.initLayer(t,n),this}removeLayer(t){const n=this.layers.find(i=>i.id===t);return n&&(n.onUnmount(),this.layers=this.layers.filter(i=>i.id!==t)),this}removeAllLayers(){const{layers:t}=this;return t.forEach(n=>{this.removeLayer(n.id)}),this}getLayer(t){return this.layers.find(n=>n.id===t||n.getInternalLayerIds().includes(t))}initLayer(t,n){const i={elm:this.layerContainer};t.onMount(i);const r=this.zoomPanHandler.currentStateAsEvent();if(t.onUpdate({...r,...n}),t.onRescale(r),this._svgContainer){const s=this.layers.length>0?this.layers.reduce((o,a)=>o.order>a.order?o:a).order:1;this._svgContainer.style("z-index",`${s+1}`)}return this}showLayer(t){const n=this.getLayer(t);return n?(n.setVisibility(!0,t),n.onRescale(this.zoomPanHandler.currentStateAsEvent()),this):this}hideLayer(t){const n=this.getLayer(t);return n?(n.setVisibility(!1,t),n.onRescale(this.zoomPanHandler.currentStateAsEvent()),this):this}adjustToSize(t,n){const i=Math.max(this._axis?t-Lr:t,0),r=Math.max(this._axis?n-kr:n,0);if(this._axis){const s={width:t,height:n};this._axis.onResize(s)}if(this.layers){const s={width:i,height:r};this.layers.forEach(o=>o.onResize(s))}this._zoomPanHandler&&this._zoomPanHandler.adjustToSize(i,r,!0)}setReferenceSystem(t){this.layers.forEach(n=>n.referenceSystem=t)}showAxis(){var t;return(t=this._axis)==null||t.show(),this}hideAxis(){var t;return(t=this._axis)==null||t.hide(),this}showAxisLabels(){var t;return(t=this._axis)==null||t.showLabels(),this}hideAxisLabels(){var t;return(t=this._axis)==null||t.hideLabels(),this}setAxisOffset(t,n){return this._axis&&(this._axis.offsetX=t,this._axis.offsetY=n,this.layers.filter(r=>r instanceof me).forEach(r=>{r.offsetX=t,r.offsetY=n})),this}setXAxisOffset(t){return this._axis&&(this._axis.offsetX=t,this.layers.filter(i=>i instanceof me).forEach(i=>{i.offsetX=t})),this}setYAxisOffset(t){return this._axis&&(this._axis.offsetY=t,this.layers.filter(i=>i instanceof me).forEach(i=>{i.offsetY=t})),this}setZoomLevelBoundary(t){return this._zoomPanHandler.setZoomLevelBoundary(t),this}setMaxZoomLevel(t){return this._zoomPanHandler.setMaxZoomLevel(t),this}setMinZoomLevel(t){return this._zoomPanHandler.setMinZoomLevel(t),this}destroy(){return this.removeAllLayers(),this.layerContainer.remove(),this._axis=void 0,this._svgContainer=void 0,this}get zoomPanHandler(){return this._zoomPanHandler}get axis(){return this._axis}rescale(t){this._axis&&this._axis.onRescale(t),this.layers&&this.layers.forEach(n=>n.isVisible===!0?n.onRescale(t):{})}}class j0{constructor(t,n){this.elements={},this.listeners={},this.enabled=!0;const i=K(n);this.elm=i.append("div").attr("id","overlay").style("z-index","11").style("position","absolute"),this.source=this.elm.node()??void 0;const{elm:r}=this;r.on("resize",s=>{const{width:o,height:a}=s.detail;r.style("width",`${o}px`).style("height",`${a}px`),this.enabled&&Object.keys(this.listeners).forEach(c=>{const h=this.elements[c]??void 0,l=this.listeners[c];l&&l.onResize&&requestAnimationFrame(()=>{var u;return(u=l.onResize)==null?void 0:u.call(l,{target:h,source:this.source,caller:t,width:o,height:a})})})}),r.on("mousemove",s=>{if(!this.enabled)return;const[o,a]=yt(s,this.elm.node());Object.keys(this.listeners).forEach(c=>{const h=this.elements[c]??void 0,l=this.listeners[c];l&&l.onMouseMove&&requestAnimationFrame(()=>{var u;return(u=l.onMouseMove)==null?void 0:u.call(l,{x:o,y:a,target:h,source:this.source,caller:t})})})}),r.on("mouseout",()=>{this.enabled&&Object.keys(this.listeners).forEach(s=>{const o=this.elements[s]||void 0,a=this.listeners[s];a&&a.onMouseExit&&requestAnimationFrame(()=>{var c;return(c=a.onMouseExit)==null?void 0:c.call(a,{target:o,source:this.source,caller:t})})})})}create(t,n){const i=this.elm.append("div").style("position","relative").style("pointer-events","none").node();if(i!=null)return this.elements[t]=i,n&&(this.listeners[t]=n),i}register(t,n){this.listeners[t]=n}remove(t){const n=this.elements[t];n&&(K(n).remove(),delete this.elements[t]),delete this.listeners[t]}setZIndex(t){this.elm.style("z-index",t)}destroy(){var t;(t=this.source)==null||t.remove()}}const Z0=(e,t)=>new j0(e,t);class K0{constructor(t){const{container:n,axisOptions:i,scaleOptions:r,referenceSystem:s,layers:o,path:a}=t;this._referenceSystem=s||a&&new Dt(a),this._overlay=Z0(this,n),this.layerManager=new Ss(this._overlay.elm.node(),r,i),o&&(this.layerManager.addLayers(o),this.setOverlayZIndex(o))}setReferenceSystem(t){return this._referenceSystem=t,this.layerManager.setReferenceSystem(t),this}updatePath(t,n){return this.setReferenceSystem(new Dt(t,n)),this}clearAllData(t=!0){return this.layerManager.clearAllData(t),this}addLayer(t,n){return this.layerManager.addLayer(t,n),this.setOverlayZIndex(this.layerManager.getLayers()),this}removeLayer(t){return this.layerManager.removeLayer(t),this}removeAllLayers(){return this.layerManager.removeAllLayers(),this}getLayer(t){return this.layerManager.getLayer(t)}showLayer(t){return this.layerManager.showLayer(t),this}hideLayer(t){return this.layerManager.hideLayer(t),this}adjustToSize(t,n){this.layerManager.adjustToSize(t,n);const i={width:Math.max(t-Lr,0),height:Math.max(n-kr,0)};return this.overlay.elm.dispatch("resize",{detail:i,bubbles:!0,cancelable:!0}),this}setViewport(t,n,i,r){return this.zoomPanHandler.setViewport(t,n,i,r),this}setBounds(t,n){return this.zoomPanHandler.setBounds(t,n),this}showAxis(){return this.layerManager.showAxis(),this}hideAxis(){return this.layerManager.hideAxis(),this}showAxisLabels(){return this.layerManager.showAxisLabels(),this}hideAxisLabels(){return this.layerManager.hideAxisLabels(),this}setAxisOffset(t,n){return this.layerManager.setAxisOffset(t,n),this}setXAxisOffset(t){return this.layerManager.setXAxisOffset(t),this}setYAxisOffset(t){return this.layerManager.setYAxisOffset(t),this}setZoomLevelBoundary(t){return this.zoomPanHandler.setZoomLevelBoundary(t),this}setMaxZoomLevel(t){return this.zoomPanHandler.setMaxZoomLevel(t),this}setMinZoomLevel(t){return this.zoomPanHandler.setMinZoomLevel(t),this}destroy(){return this.layerManager.destroy(),this._overlay.destroy(),this._referenceSystem=void 0,this}getHighestZIndex(t){return t.length>0?t.reduce((i,r)=>i.order>r.order?i:r).order:1}setOverlayZIndex(t){const n=this.getHighestZIndex(t);this.overlay.setZIndex(n+2)}get overlay(){return this._overlay}get referenceSystem(){return this._referenceSystem}get zoomPanHandler(){return this.layerManager.zoomPanHandler}get axis(){return this.layerManager.axis}get currentStateAsEvent(){return this.zoomPanHandler.currentStateAsEvent()}}exports.Axis=nr;exports.CalloutCanvasLayer=Yl;exports.CanvasLayer=St;exports.Controller=K0;exports.GeomodelCanvasLayer=Kl;exports.GeomodelLabelsLayer=$u;exports.GeomodelLayerV2=Hu;exports.GridLayer=me;exports.HTMLLayer=Cl;exports.ImageLayer=Uu;exports.IntersectionReferenceSystem=Dt;exports.Layer=te;exports.LayerManager=Ss;exports.PixiLayer=$n;exports.PixiRenderApplication=Ll;exports.ReferenceLineLayer=q0;exports.SVGLayer=Fr;exports.SchematicLayer=Tn;exports.SeismicCanvasLayer=S0;exports.WellborepathLayer=G0;exports.ZoomPanHandler=Cr;exports.assertNever=ee;exports.calcSize=ke;exports.defaultCasingOptions=Yr;exports.defaultCementOptions=qr;exports.defaultCementPlugOptions=Qr;exports.defaultCementSqueezeOptions=jr;exports.defaultHoleOptions=Wr;exports.defaultInternalLayerOptions=Vr;exports.defaultPerforationOptions=Gr;exports.defaultScreenOptions=Zr;exports.defaultTubingOptions=Kr;exports.findIndexOfSample=Bn;exports.findSampleAtPos=_t;exports.foldCompletion=zr;exports.foldPerforationSubKind=J;exports.generateProjectedTrajectory=Eu;exports.generateProjectedWellborePath=ku;exports.generateSeismicSliceImage=uu;exports.generateSurfaceData=pu;exports.getOverlap=Ol;exports.getOverlapOffset=vn;exports.getPicksData=eu;exports.getSeismicInfo=lu;exports.getSeismicOptions=hu;exports.hasFracLines=Nr;exports.hasPacking=Dr;exports.hasSpikes=$r;exports.intersect=Ur;exports.isCementPlug=Or;exports.isCementSqueeze=Ir;exports.isOpenHoleFracPack=Rl;exports.isOverlapping=ns;exports.isOverlappingHorizontally=Il;exports.isPAndASymbol=Rr;exports.isSubKindCasedHoleFracPack=Hr;exports.isSubKindCasedHoleFracturation=Xr;exports.isSubKindPerforation=Fl;exports.isSubkindCasedHoleGravelPack=Br;exports.pixelsPerUnit=es;exports.shouldPerforationStartAtCasingDiameter=El;exports.shouldPerforationStartAtHoleDiameter=kl;exports.transformFormationData=au;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("pixi.js");function As(e){return e}var Ve=1,he=2,nn=3,ne=4,jn=1e-6;function Ms(e){return"translate("+e+",0)"}function Ps(e){return"translate(0,"+e+")"}function Cs(e){return t=>+e(t)}function Ls(e,t){return t=Math.max(0,e.bandwidth()-t*2)/2,e.round()&&(t=Math.round(t)),n=>+e(n)+t}function ks(){return!this.__axis}function Ui(e,t){var n=[],i=null,r=null,s=6,o=6,a=3,c=typeof window<"u"&&window.devicePixelRatio>1?0:.5,h=e===Ve||e===ne?-1:1,l=e===ne||e===he?"x":"y",u=e===Ve||e===nn?Ms:Ps;function f(d){var p=i??(t.ticks?t.ticks.apply(t,n):t.domain()),g=r??(t.tickFormat?t.tickFormat.apply(t,n):As),m=Math.max(s,0)+a,_=t.range(),x=+_[0]+c,v=+_[_.length-1]+c,A=(t.bandwidth?Ls:Cs)(t.copy(),c),S=d.selection?d.selection():d,M=S.selectAll(".domain").data([null]),b=S.selectAll(".tick").data(p,t).order(),C=b.exit(),k=b.enter().append("g").attr("class","tick"),O=b.select("line"),L=b.select("text");M=M.merge(M.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),b=b.merge(k),O=O.merge(k.append("line").attr("stroke","currentColor").attr(l+"2",h*s)),L=L.merge(k.append("text").attr("fill","currentColor").attr(l,h*m).attr("dy",e===Ve?"0em":e===nn?"0.71em":"0.32em")),d!==S&&(M=M.transition(d),b=b.transition(d),O=O.transition(d),L=L.transition(d),C=C.transition(d).attr("opacity",jn).attr("transform",function(z){return isFinite(z=A(z))?u(z+c):this.getAttribute("transform")}),k.attr("opacity",jn).attr("transform",function(z){var $=this.parentNode.__axis;return u(($&&isFinite($=$(z))?$:A(z))+c)})),C.remove(),M.attr("d",e===ne||e===he?o?"M"+h*o+","+x+"H"+c+"V"+v+"H"+h*o:"M"+c+","+x+"V"+v:o?"M"+x+","+h*o+"V"+c+"H"+v+"V"+h*o:"M"+x+","+c+"H"+v),b.attr("opacity",1).attr("transform",function(z){return u(A(z)+c)}),O.attr(l+"2",h*s),L.attr(l,h*m).text(g),S.filter(ks).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",e===he?"start":e===ne?"end":"middle"),S.each(function(){this.__axis=A})}return f.scale=function(d){return arguments.length?(t=d,f):t},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(d){return arguments.length?(n=d==null?[]:Array.from(d),f):n.slice()},f.tickValues=function(d){return arguments.length?(i=d==null?null:Array.from(d),f):i&&i.slice()},f.tickFormat=function(d){return arguments.length?(r=d,f):r},f.tickSize=function(d){return arguments.length?(s=o=+d,f):s},f.tickSizeInner=function(d){return arguments.length?(s=+d,f):s},f.tickSizeOuter=function(d){return arguments.length?(o=+d,f):o},f.tickPadding=function(d){return arguments.length?(a=+d,f):a},f.offset=function(d){return arguments.length?(c=+d,f):c},f}function Es(e){return Ui(he,e)}function Fs(e){return Ui(nn,e)}function le(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Rs(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Vi(e){let t,n,i;e.length!==2?(t=le,n=(a,c)=>le(e(a),c),i=(a,c)=>e(a)-c):(t=e===le||e===Rs?e:Is,n=e,i=e);function r(a,c,h=0,l=a.length){if(h<l){if(t(c,c)!==0)return l;do{const u=h+l>>>1;n(a[u],c)<0?h=u+1:l=u}while(h<l)}return h}function s(a,c,h=0,l=a.length){if(h<l){if(t(c,c)!==0)return l;do{const u=h+l>>>1;n(a[u],c)<=0?h=u+1:l=u}while(h<l)}return h}function o(a,c,h=0,l=a.length){const u=r(a,c,h,l-1);return u>h&&i(a[u-1],c)>-i(a[u],c)?u-1:u}return{left:r,center:o,right:s}}function Is(){return 0}function Os(e){return e===null?NaN:+e}const zs=Vi(le),Ds=zs.right;Vi(Os).center;class Zn extends Map{constructor(t,n=Bs){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[i,r]of t)this.set(i,r)}get(t){return super.get(Kn(this,t))}has(t){return super.has(Kn(this,t))}set(t,n){return super.set(Ns(this,t),n)}delete(t){return super.delete($s(this,t))}}function Kn({_intern:e,_key:t},n){const i=t(n);return e.has(i)?e.get(i):n}function Ns({_intern:e,_key:t},n){const i=t(n);return e.has(i)?e.get(i):(e.set(i,n),n)}function $s({_intern:e,_key:t},n){const i=t(n);return e.has(i)&&(n=e.get(n),e.delete(i)),n}function Bs(e){return e!==null&&typeof e=="object"?e.valueOf():e}const Hs=Math.sqrt(50),Xs=Math.sqrt(10),Us=Math.sqrt(2);function _e(e,t,n){const i=(t-e)/Math.max(0,n),r=Math.floor(Math.log10(i)),s=i/Math.pow(10,r),o=s>=Hs?10:s>=Xs?5:s>=Us?2:1;let a,c,h;return r<0?(h=Math.pow(10,-r)/o,a=Math.round(e*h),c=Math.round(t*h),a/h<e&&++a,c/h>t&&--c,h=-h):(h=Math.pow(10,r)*o,a=Math.round(e/h),c=Math.round(t/h),a*h<e&&++a,c*h>t&&--c),c<a&&.5<=n&&n<2?_e(e,t,n*2):[a,c,h]}function Vs(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];const i=t<e,[r,s,o]=i?_e(t,e,n):_e(e,t,n);if(!(s>=r))return[];const a=s-r+1,c=new Array(a);if(i)if(o<0)for(let h=0;h<a;++h)c[h]=(s-h)/-o;else for(let h=0;h<a;++h)c[h]=(s-h)*o;else if(o<0)for(let h=0;h<a;++h)c[h]=(r+h)/-o;else for(let h=0;h<a;++h)c[h]=(r+h)*o;return c}function rn(e,t,n){return t=+t,e=+e,n=+n,_e(e,t,n)[2]}function Ws(e,t,n){t=+t,e=+e,n=+n;const i=t<e,r=i?rn(t,e,n):rn(e,t,n);return(i?-1:1)*(r<0?1/-r:r)}function sn(e,t){let n;if(t===void 0)for(const i of e)i!=null&&(n<i||n===void 0&&i>=i)&&(n=i);else{let i=-1;for(let r of e)(r=t(r,++i,e))!=null&&(n<r||n===void 0&&r>=r)&&(n=r)}return n}function We(e,t){let n=0;if(t===void 0)for(let i of e)(i=+i)&&(n+=i);else{let i=-1;for(let r of e)(r=+t(r,++i,e))&&(n+=r)}return n}function Wi(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}const Qn=Symbol("implicit");function Yi(){var e=new Zn,t=[],n=[],i=Qn;function r(s){let o=e.get(s);if(o===void 0){if(i!==Qn)return i;e.set(s,o=t.push(s)-1)}return n[o%n.length]}return r.domain=function(s){if(!arguments.length)return t.slice();t=[],e=new Zn;for(const o of s)e.has(o)||e.set(o,t.push(o)-1);return r},r.range=function(s){return arguments.length?(n=Array.from(s),r):n.slice()},r.unknown=function(s){return arguments.length?(i=s,r):i},r.copy=function(){return Yi(t,n).unknown(i)},Wi.apply(r,arguments),r}function Cn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Gi(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function Qt(){}var qt=.7,xe=1/qt,It="\\s*([+-]?\\d+)\\s*",jt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",at="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ys=/^#([0-9a-f]{3,8})$/,Gs=new RegExp(`^rgb\\(${It},${It},${It}\\)$`),qs=new RegExp(`^rgb\\(${at},${at},${at}\\)$`),js=new RegExp(`^rgba\\(${It},${It},${It},${jt}\\)$`),Zs=new RegExp(`^rgba\\(${at},${at},${at},${jt}\\)$`),Ks=new RegExp(`^hsl\\(${jt},${at},${at}\\)$`),Qs=new RegExp(`^hsla\\(${jt},${at},${at},${jt}\\)$`),Jn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Cn(Qt,pt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ti,formatHex:ti,formatHex8:Js,formatHsl:to,formatRgb:ei,toString:ei});function ti(){return this.rgb().formatHex()}function Js(){return this.rgb().formatHex8()}function to(){return qi(this).formatHsl()}function ei(){return this.rgb().formatRgb()}function pt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ys.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ni(t):n===3?new Y(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ie(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ie(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Gs.exec(e))?new Y(t[1],t[2],t[3],1):(t=qs.exec(e))?new Y(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=js.exec(e))?ie(t[1],t[2],t[3],t[4]):(t=Zs.exec(e))?ie(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Ks.exec(e))?si(t[1],t[2]/100,t[3]/100,1):(t=Qs.exec(e))?si(t[1],t[2]/100,t[3]/100,t[4]):Jn.hasOwnProperty(e)?ni(Jn[e]):e==="transparent"?new Y(NaN,NaN,NaN,0):null}function ni(e){return new Y(e>>16&255,e>>8&255,e&255,1)}function ie(e,t,n,i){return i<=0&&(e=t=n=NaN),new Y(e,t,n,i)}function eo(e){return e instanceof Qt||(e=pt(e)),e?(e=e.rgb(),new Y(e.r,e.g,e.b,e.opacity)):new Y}function on(e,t,n,i){return arguments.length===1?eo(e):new Y(e,t,n,i??1)}function Y(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}Cn(Y,on,Gi(Qt,{brighter(e){return e=e==null?xe:Math.pow(xe,e),new Y(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?qt:Math.pow(qt,e),new Y(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Y(Pt(this.r),Pt(this.g),Pt(this.b),ve(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ii,formatHex:ii,formatHex8:no,formatRgb:ri,toString:ri}));function ii(){return`#${Mt(this.r)}${Mt(this.g)}${Mt(this.b)}`}function no(){return`#${Mt(this.r)}${Mt(this.g)}${Mt(this.b)}${Mt((isNaN(this.opacity)?1:this.opacity)*255)}`}function ri(){const e=ve(this.opacity);return`${e===1?"rgb(":"rgba("}${Pt(this.r)}, ${Pt(this.g)}, ${Pt(this.b)}${e===1?")":`, ${e})`}`}function ve(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Pt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Mt(e){return e=Pt(e),(e<16?"0":"")+e.toString(16)}function si(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new rt(e,t,n,i)}function qi(e){if(e instanceof rt)return new rt(e.h,e.s,e.l,e.opacity);if(e instanceof Qt||(e=pt(e)),!e)return new rt;if(e instanceof rt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),s=Math.max(t,n,i),o=NaN,a=s-r,c=(s+r)/2;return a?(t===s?o=(n-i)/a+(n<i)*6:n===s?o=(i-t)/a+2:o=(t-n)/a+4,a/=c<.5?s+r:2-s-r,o*=60):a=c>0&&c<1?0:o,new rt(o,a,c,e.opacity)}function io(e,t,n,i){return arguments.length===1?qi(e):new rt(e,t,n,i??1)}function rt(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}Cn(rt,io,Gi(Qt,{brighter(e){return e=e==null?xe:Math.pow(xe,e),new rt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?qt:Math.pow(qt,e),new rt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new Y(Ye(e>=240?e-240:e+120,r,i),Ye(e,r,i),Ye(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new rt(oi(this.h),re(this.s),re(this.l),ve(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=ve(this.opacity);return`${e===1?"hsl(":"hsla("}${oi(this.h)}, ${re(this.s)*100}%, ${re(this.l)*100}%${e===1?")":`, ${e})`}`}}));function oi(e){return e=(e||0)%360,e<0?e+360:e}function re(e){return Math.max(0,Math.min(1,e||0))}function Ye(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Ln=e=>()=>e;function ro(e,t){return function(n){return e+n*t}}function so(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function oo(e){return(e=+e)==1?ji:function(t,n){return n-t?so(t,n,e):Ln(isNaN(t)?n:t)}}function ji(e,t){var n=t-e;return n?ro(e,n):Ln(isNaN(e)?t:e)}const Zt=(function e(t){var n=oo(t);function i(r,s){var o=n((r=on(r)).r,(s=on(s)).r),a=n(r.g,s.g),c=n(r.b,s.b),h=ji(r.opacity,s.opacity);return function(l){return r.r=o(l),r.g=a(l),r.b=c(l),r.opacity=h(l),r+""}}return i.gamma=e,i})(1);function ao(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),r;return function(s){for(r=0;r<n;++r)i[r]=e[r]*(1-s)+t[r]*s;return i}}function co(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ho(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,r=new Array(i),s=new Array(n),o;for(o=0;o<i;++o)r[o]=kn(e[o],t[o]);for(;o<n;++o)s[o]=t[o];return function(a){for(o=0;o<i;++o)s[o]=r[o](a);return s}}function lo(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function it(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function uo(e,t){var n={},i={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=kn(e[r],t[r]):i[r]=t[r];return function(s){for(r in n)i[r]=n[r](s);return i}}var an=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ge=new RegExp(an.source,"g");function fo(e){return function(){return e}}function po(e){return function(t){return e(t)+""}}function Zi(e,t){var n=an.lastIndex=Ge.lastIndex=0,i,r,s,o=-1,a=[],c=[];for(e=e+"",t=t+"";(i=an.exec(e))&&(r=Ge.exec(t));)(s=r.index)>n&&(s=t.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(i=i[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,c.push({i:o,x:it(i,r)})),n=Ge.lastIndex;return n<t.length&&(s=t.slice(n),a[o]?a[o]+=s:a[++o]=s),a.length<2?c[0]?po(c[0].x):fo(t):(t=c.length,function(h){for(var l=0,u;l<t;++l)a[(u=c[l]).i]=u.x(h);return a.join("")})}function kn(e,t){var n=typeof t,i;return t==null||n==="boolean"?Ln(t):(n==="number"?it:n==="string"?(i=pt(t))?(t=i,Zt):Zi:t instanceof pt?Zt:t instanceof Date?lo:co(t)?ao:Array.isArray(t)?ho:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?uo:it)(e,t)}function go(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var ai=180/Math.PI,cn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ki(e,t,n,i,r,s){var o,a,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*i)&&(n-=e*c,i-=t*c),(a=Math.sqrt(n*n+i*i))&&(n/=a,i/=a,c/=a),e*i<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:r,translateY:s,rotate:Math.atan2(t,e)*ai,skewX:Math.atan(c)*ai,scaleX:o,scaleY:a}}var se;function mo(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?cn:Ki(t.a,t.b,t.c,t.d,t.e,t.f)}function yo(e){return e==null||(se||(se=document.createElementNS("http://www.w3.org/2000/svg","g")),se.setAttribute("transform",e),!(e=se.transform.baseVal.consolidate()))?cn:(e=e.matrix,Ki(e.a,e.b,e.c,e.d,e.e,e.f))}function Qi(e,t,n,i){function r(h){return h.length?h.pop()+" ":""}function s(h,l,u,f,d,p){if(h!==u||l!==f){var g=d.push("translate(",null,t,null,n);p.push({i:g-4,x:it(h,u)},{i:g-2,x:it(l,f)})}else(u||f)&&d.push("translate("+u+t+f+n)}function o(h,l,u,f){h!==l?(h-l>180?l+=360:l-h>180&&(h+=360),f.push({i:u.push(r(u)+"rotate(",null,i)-2,x:it(h,l)})):l&&u.push(r(u)+"rotate("+l+i)}function a(h,l,u,f){h!==l?f.push({i:u.push(r(u)+"skewX(",null,i)-2,x:it(h,l)}):l&&u.push(r(u)+"skewX("+l+i)}function c(h,l,u,f,d,p){if(h!==u||l!==f){var g=d.push(r(d)+"scale(",null,",",null,")");p.push({i:g-4,x:it(h,u)},{i:g-2,x:it(l,f)})}else(u!==1||f!==1)&&d.push(r(d)+"scale("+u+","+f+")")}return function(h,l){var u=[],f=[];return h=e(h),l=e(l),s(h.translateX,h.translateY,l.translateX,l.translateY,u,f),o(h.rotate,l.rotate,u,f),a(h.skewX,l.skewX,u,f),c(h.scaleX,h.scaleY,l.scaleX,l.scaleY,u,f),h=l=null,function(d){for(var p=-1,g=f.length,m;++p<g;)u[(m=f[p]).i]=m.x(d);return u.join("")}}}var _o=Qi(mo,"px, ","px)","deg)"),xo=Qi(yo,", ",")",")"),vo=1e-12;function ci(e){return((e=Math.exp(e))+1/e)/2}function wo(e){return((e=Math.exp(e))-1/e)/2}function bo(e){return((e=Math.exp(2*e))-1)/(e+1)}const So=(function e(t,n,i){function r(s,o){var a=s[0],c=s[1],h=s[2],l=o[0],u=o[1],f=o[2],d=l-a,p=u-c,g=d*d+p*p,m,_;if(g<vo)_=Math.log(f/h)/t,m=function(b){return[a+b*d,c+b*p,h*Math.exp(t*b*_)]};else{var x=Math.sqrt(g),v=(f*f-h*h+i*g)/(2*h*n*x),A=(f*f-h*h-i*g)/(2*f*n*x),S=Math.log(Math.sqrt(v*v+1)-v),M=Math.log(Math.sqrt(A*A+1)-A);_=(M-S)/t,m=function(b){var C=b*_,k=ci(S),O=h/(n*x)*(k*bo(t*C+S)-wo(S));return[a+O*d,c+O*p,h*k/ci(t*C+S)]}}return m.duration=_*1e3*t/Math.SQRT2,m}return r.rho=function(s){var o=Math.max(.001,+s),a=o*o,c=a*a;return e(o,a,c)},r})(Math.SQRT2,2,4);function To(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e(i/(t-1));return n}function Ao(e){return function(){return e}}function Mo(e){return+e}var hi=[0,1];function Et(e){return e}function hn(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:Ao(isNaN(t)?NaN:.5)}function Po(e,t){var n;return e>t&&(n=e,e=t,t=n),function(i){return Math.max(e,Math.min(t,i))}}function Co(e,t,n){var i=e[0],r=e[1],s=t[0],o=t[1];return r<i?(i=hn(r,i),s=n(o,s)):(i=hn(i,r),s=n(s,o)),function(a){return s(i(a))}}function Lo(e,t,n){var i=Math.min(e.length,t.length)-1,r=new Array(i),s=new Array(i),o=-1;for(e[i]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<i;)r[o]=hn(e[o],e[o+1]),s[o]=n(t[o],t[o+1]);return function(a){var c=Ds(e,a,1,i)-1;return s[c](r[c](a))}}function ko(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function Eo(){var e=hi,t=hi,n=kn,i,r,s,o=Et,a,c,h;function l(){var f=Math.min(e.length,t.length);return o!==Et&&(o=Po(e[0],e[f-1])),a=f>2?Lo:Co,c=h=null,u}function u(f){return f==null||isNaN(f=+f)?s:(c||(c=a(e.map(i),t,n)))(i(o(f)))}return u.invert=function(f){return o(r((h||(h=a(t,e.map(i),it)))(f)))},u.domain=function(f){return arguments.length?(e=Array.from(f,Mo),l()):e.slice()},u.range=function(f){return arguments.length?(t=Array.from(f),l()):t.slice()},u.rangeRound=function(f){return t=Array.from(f),n=go,l()},u.clamp=function(f){return arguments.length?(o=f?!0:Et,l()):o!==Et},u.interpolate=function(f){return arguments.length?(n=f,l()):n},u.unknown=function(f){return arguments.length?(s=f,u):s},function(f,d){return i=f,r=d,l()}}function Fo(){return Eo()(Et,Et)}function Ro(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function we(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,i=e.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+e.slice(n+1)]}function Ot(e){return e=we(Math.abs(e)),e?e[1]:NaN}function Io(e,t){return function(n,i){for(var r=n.length,s=[],o=0,a=e[0],c=0;r>0&&a>0&&(c+a+1>i&&(a=Math.max(1,i-c)),s.push(n.substring(r-=a,r+a)),!((c+=a+1)>i));)a=e[o=(o+1)%e.length];return s.reverse().join(t)}}function Oo(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var zo=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function be(e){if(!(t=zo.exec(e)))throw new Error("invalid format: "+e);var t;return new En({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}be.prototype=En.prototype;function En(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}En.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Do(e){t:for(var t=e.length,n=1,i=-1,r;n<t;++n)switch(e[n]){case".":i=r=n;break;case"0":i===0&&(i=n),r=n;break;default:if(!+e[n])break t;i>0&&(i=0);break}return i>0?e.slice(0,i)+e.slice(r+1):e}var Ji;function No(e,t){var n=we(e,t);if(!n)return e+"";var i=n[0],r=n[1],s=r-(Ji=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,o=i.length;return s===o?i:s>o?i+new Array(s-o+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+we(e,Math.max(0,t+s-1))[0]}function li(e,t){var n=we(e,t);if(!n)return e+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const ui={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Ro,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>li(e*100,t),r:li,s:No,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function fi(e){return e}var di=Array.prototype.map,pi=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function $o(e){var t=e.grouping===void 0||e.thousands===void 0?fi:Io(di.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",i=e.currency===void 0?"":e.currency[1]+"",r=e.decimal===void 0?".":e.decimal+"",s=e.numerals===void 0?fi:Oo(di.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",a=e.minus===void 0?"−":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function h(u){u=be(u);var f=u.fill,d=u.align,p=u.sign,g=u.symbol,m=u.zero,_=u.width,x=u.comma,v=u.precision,A=u.trim,S=u.type;S==="n"?(x=!0,S="g"):ui[S]||(v===void 0&&(v=12),A=!0,S="g"),(m||f==="0"&&d==="=")&&(m=!0,f="0",d="=");var M=g==="$"?n:g==="#"&&/[boxX]/.test(S)?"0"+S.toLowerCase():"",b=g==="$"?i:/[%p]/.test(S)?o:"",C=ui[S],k=/[defgprs%]/.test(S);v=v===void 0?6:/[gprs]/.test(S)?Math.max(1,Math.min(21,v)):Math.max(0,Math.min(20,v));function O(L){var z=M,$=b,y,T,w;if(S==="c")$=C(L)+$,L="";else{L=+L;var P=L<0||1/L<0;if(L=isNaN(L)?c:C(Math.abs(L),v),A&&(L=Do(L)),P&&+L==0&&p!=="+"&&(P=!1),z=(P?p==="("?p:a:p==="-"||p==="("?"":p)+z,$=(S==="s"?pi[8+Ji/3]:"")+$+(P&&p==="("?")":""),k){for(y=-1,T=L.length;++y<T;)if(w=L.charCodeAt(y),48>w||w>57){$=(w===46?r+L.slice(y+1):L.slice(y))+$,L=L.slice(0,y);break}}}x&&!m&&(L=t(L,1/0));var F=z.length+L.length+$.length,R=F<_?new Array(_-F+1).join(f):"";switch(x&&m&&(L=t(R+L,R.length?_-$.length:1/0),R=""),d){case"<":L=z+L+$+R;break;case"=":L=z+R+L+$;break;case"^":L=R.slice(0,F=R.length>>1)+z+L+$+R.slice(F);break;default:L=R+z+L+$;break}return s(L)}return O.toString=function(){return u+""},O}function l(u,f){var d=h((u=be(u),u.type="f",u)),p=Math.max(-8,Math.min(8,Math.floor(Ot(f)/3)))*3,g=Math.pow(10,-p),m=pi[8+p/3];return function(_){return d(g*_)+m}}return{format:h,formatPrefix:l}}var oe,tr,er;Bo({thousands:",",grouping:[3],currency:["$",""]});function Bo(e){return oe=$o(e),tr=oe.format,er=oe.formatPrefix,oe}function Ho(e){return Math.max(0,-Ot(Math.abs(e)))}function Xo(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Ot(t)/3)))*3-Ot(Math.abs(e)))}function Uo(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Ot(t)-Ot(e))+1}function Vo(e,t,n,i){var r=Ws(e,t,n),s;switch(i=be(i??",f"),i.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return i.precision==null&&!isNaN(s=Xo(r,o))&&(i.precision=s),er(i,o)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(s=Uo(r,Math.max(Math.abs(e),Math.abs(t))))&&(i.precision=s-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(s=Ho(r))&&(i.precision=s-(i.type==="%")*2);break}}return tr(i)}function Wo(e){var t=e.domain;return e.ticks=function(n){var i=t();return Vs(i[0],i[i.length-1],n??10)},e.tickFormat=function(n,i){var r=t();return Vo(r[0],r[r.length-1],n??10,i)},e.nice=function(n){n==null&&(n=10);var i=t(),r=0,s=i.length-1,o=i[r],a=i[s],c,h,l=10;for(a<o&&(h=o,o=a,a=h,h=r,r=s,s=h);l-- >0;){if(h=rn(o,a,n),h===c)return i[r]=o,i[s]=a,t(i);if(h>0)o=Math.floor(o/h)*h,a=Math.ceil(a/h)*h;else if(h<0)o=Math.ceil(o*h)/h,a=Math.floor(a*h)/h;else break;c=h}return e},e}function Ct(){var e=Fo();return e.copy=function(){return ko(e,Ct())},Wi.apply(e,arguments),Wo(e)}class nr{constructor(t,n=!0,i,r,s,o){this._showLabels=!0,this._offsetX=0,this._offsetY=0,this._flipX=!1,this._flipY=!1,this.visible=!0,this.createOrGet=a=>{const{mainGroup:c}=this;let h=c.select(`g.${a}`);return h.empty()&&(h=c.append("g").attr("class",a)),h},this.mainGroup=t,this._showLabels=n,this._labelXDesc=i,this._labelYDesc=r,this._unitOfMeasure=s,o&&o.offsetX&&(this._offsetX=o.offsetX),o&&o.offsetX&&(this._offsetY=o.offsetY),o&&o.visible&&(this.visible=o.visible),this.mainGroup.style("pointer-events","none"),this._scaleX=Ct().domain([0,1]).range([0,1]),this._scaleY=Ct().domain([0,1]).range([0,1])}renderLabelx(){const{_labelXDesc:t,_unitOfMeasure:n,_showLabels:i,_scaleX:r}=this,[,s]=r.range(),o=this.renderGx();let a=o.select("text.axis-labelx");return i?a.empty()&&(a=o.append("text").attr("class","axis-labelx").attr("fill","rgba(0,0,0,0.3)").style("text-anchor","middle").style("font-weight","800").style("font-size","10px").text(`${t} (${n})`)):a.remove(),a.attr("transform",`translate(${s/2},-4)`),a}renderLabely(){const{_labelYDesc:t,_unitOfMeasure:n,_showLabels:i,_scaleY:r}=this,[,s]=r.range(),o=this.renderGy();let a=o.select("text.axis-labely");return i?(a.empty()&&(a=o.append("text").attr("class","axis-labely").attr("fill","rgba(0,0,0,0.3)").style("text-anchor","middle").style("font-weight","800").style("font-size","10px").text(`${t} (${n})`)),a.attr("transform",`translate(-10,${s/2})rotate(90)`)):a.remove(),a}renderGy(){const{_scaleX:t,_scaleY:n}=this,i=Es(n),[,r]=t.range(),s=this.createOrGet("y-axis");return s.call(i),s.attr("transform",`translate(${r},0)`),s}renderGx(){const{_scaleX:t,_scaleY:n}=this,i=Fs(t),[,r]=n.range(),s=this.createOrGet("x-axis");return s.attr("transform",`translate(0 ${r})`),s.call(i),s}render(){this.renderLabelx(),this.renderLabely()}onResize(t){this.mainGroup.attr("height",`${t.height}px`).attr("width",`${t.width}px`)}onRescale(t){const{_scaleX:n,_scaleY:i,offsetX:r,offsetY:s}=this,{xScale:o,yScale:a}=t,c=o.domain(),h=a.domain(),l=o.range(),u=a.range();n.domain([c[0]-r,c[1]-r]).range(l),i.domain([h[0]-s,h[1]-s]).range(u),this.flipX(this._flipX),this.flipY(this._flipY),this.visible&&this.render()}show(){return this.visible=!0,this.mainGroup.attr("visibility","visible"),this.render(),this}hide(){return this.visible=!1,this.mainGroup.attr("visibility","hidden"),this}flipX(t){this._flipX=t;const n=this._scaleX.domain(),i=t?-1:1;return this._scaleX.domain([i*n[0],i*n[1]]),this}flipY(t){this._flipY=t;const n=this._scaleY.domain(),i=t?-1:1;return this._scaleY.domain([i*n[0],i*n[1]]),this}showLabels(){return this._showLabels=!0,this.render(),this}hideLabels(){return this._showLabels=!1,this.render(),this}setLabelX(t){return this._labelXDesc=t,this}setLabelY(t){return this._labelYDesc=t,this}setUnitOfMeasure(t){return this._unitOfMeasure=t,this}setLabels(t,n,i){return this._labelXDesc=t,this._labelYDesc=n,this._unitOfMeasure=i,this}get offsetX(){return this._offsetX}set offsetX(t){this._offsetX=t}get offsetY(){return this._offsetY}set offsetY(t){this._offsetY=t}get scaleX(){return this._scaleX.copy()}get scaleY(){return this._scaleY.copy()}}const Yo=Math.PI/180;function _t(e,t=0,n=1){return e<t?t:e>n?n:e}function Go(e){return e*Yo}function gi(e){const t=new Array(e),n=1/(e-1);t[0]=0;for(let i=1;i<e-1;i++)t[i]=i*n;return t[e-1]=1,t}function Bt(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=e[i]+t[i];return n}function Ht(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=e[i]-t[i];return n}function St(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=e[i]*t;return n}function qo(e){for(var t=0,n=0;n<e.length;n++)t+=Math.pow(e[n],2);return t}function Wt(e){var t=qo(e);return t===0?t:Math.sqrt(t)}function mi(e,t){t===void 0&&(t=e);var n=Wt(e);return n===0?jo(0,t):St(e,1/n,t)}function jo(e,t){for(var n=0;n<t.length;n++)t[n]=e;return t}function Zo(e,t){for(var n=0,i=0;i<e.length;i++)n+=Math.pow(t[i]-e[i],2);return n===0?n:Math.sqrt(n)}function Ko(e,t){for(var n=0,i=0;i<e.length;i++)n+=e[i]*t[i];return n}function Qo(e,t,n,i){i===void 0&&(i=e);for(var r=_t(n,0,1),s=1-r,o=0;o<e.length;o++)i[o]=e[o]*s+t[o]*r;return i}function Jo(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=t(e[i],i);return n}function yi(e,t){t===void 0&&(t=0),t===void 0&&(t=0);for(var n=0;n<e.length;n++)if(Math.abs(e[n])>t)return!1;return!0}var qe=180/Math.PI,ta=Math.PI/180;function je(e,t,n){var i=Math.cos(t),r=Math.sin(t),s=e[0];return n[0]=i*s-r*e[1],n[1]=r*s+i*e[1],n}function _i(e){return Math.atan2(e[1],e[0])}function Xt(e,t){var n=Math.atan2(t[1],t[0])-Math.atan2(e[1],e[0]);return n>Math.PI?n-=2*Math.PI:n<=-Math.PI&&(n+=2*Math.PI),n}var N=(function(){function e(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.isMutating=!1,this.length=2,typeof t=="number"?typeof n[0]=="number"?(this[0]=t,this[1]=n[0]):(this[0]=t,this[1]=t):"x"in t&&"y"in t?(this[0]=t.x,this[1]=t.y):(this[0]=t[0],this[1]=t[1])}return Object.defineProperty(e.prototype,"x",{get:function(){return this[0]},set:function(t){this[0]=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this[1]},set:function(t){this[1]=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"magnitude",{get:function(){return Wt(this)},set:function(t){var n=Wt(this);St(this,t/n,this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mutable",{get:function(){return this.isMutating=!0,this},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"immutable",{get:function(){return this.isMutating=!1,this},enumerable:!1,configurable:!0}),e.prototype.set=function(t,n){return typeof t=="number"?typeof n=="number"?(this[0]=t,this[1]=n):(this[0]=t,this[1]=t):(this[0]=t[0],this[1]=t[1]),this},e.prototype.add=function(t,n){return n===void 0&&(n=0),typeof t=="number"?this.isMutating?Bt(this,[t,n]):Bt(this.clone(),[t,n]):this.isMutating?Bt(this,t):Bt(this.clone(),t)},e.add=function(t,n){var i=new e(t);return Bt(i,n)},e.prototype.sub=function(t,n){return n===void 0&&(n=0),typeof t=="number"?this.isMutating?Ht(this,[t,n]):Ht(this.clone(),[t,n]):this.isMutating?Ht(this,t):Ht(this.clone(),t)},e.sub=function(t,n){var i=new e(t);return Ht(i,n)},e.prototype.subFrom=function(t,n){return n===void 0&&(n=0),typeof t=="number"?this.isMutating?(this[0]=t-this[0],this[1]=n-this[1],this):new e(t-this[0],n-this[1]):this.isMutating?(this[0]=t[0]-this[0],this[1]=t[1]-this[1],this):new e(t[0]-this[0],t[1]-this[1])},e.divide=function(t,n){var i=new e(t);return St(i,1/n)},e.multiply=function(t,n){var i=new e(t);return St(i,n)},e.prototype.scale=function(t){return St(this,t,this.isMutating?this:e.zero)},e.prototype.rescale=function(t){var n=Wt(this);return n<=0?this.isMutating?this:e.zero:St(this,t/n,this.isMutating?this:e.zero)},e.prototype.clampMagnitude=function(t){var n=Wt(this);return n>t?St(this,t/n,this.isMutating?this:e.zero):this.isMutating?this:this.clone()},e.prototype.rotate=function(t){return je(this,t,this.isMutating?this:e.zero)},e.prototype.rotateDeg=function(t){return je(this,t*ta,this.isMutating?this:e.zero)},e.prototype.rotate90=function(){return t=this,n=this.isMutating?this:e.zero,i=t[0],n[0]=-t[1],n[1]=i,n;var t,n,i},e.prototype.rotate180=function(){return t=this,(n=this.isMutating?this:e.zero)[0]=-t[0],n[1]=-t[1],n;var t,n},e.prototype.rotate270=function(){return t=this,n=this.isMutating?this:e.zero,i=t[0],n[0]=t[1],n[1]=-i,n;var t,n,i},e.prototype.normalize=function(){return mi(this)},e.prototype.normalized=function(){return mi(this,e.zero)},e.distance=function(t,n){return Zo(t,n)},e.dot=function(t,n){return Ko(t,n)},e.cross=function(t,n){return(function(i,r){return i[0]*r[1]-i[1]*r[0]})(t,n)},e.angleRight=function(t){return _i(t)},e.angleRightDeg=function(t){return _i(t)*qe},e.angle=function(t,n){return Math.abs(Xt(t,n))},e.angleDeg=function(t,n){return Math.abs(Xt(t,n))*qe},e.signedAngle=function(t,n){return Xt(t,n)},e.signedAngleDeg=function(t,n){return Xt(t,n)*qe},e.lerp=function(t,n,i){var r=new e(t);return Qo(r,n,i)},e.lerpRot=function(t,n,i){return(function(r,s,o,a){return a===void 0&&(a=r),je(r,o*Xt(r,s),a)})(t,n,i,e.zero)},e.prototype.clone=function(){return new e(this[0],this[1])},e.equals=function(t,n,i){return i===void 0&&(i=0),!(Math.abs(t[0]-n[0])>i)&&!(Math.abs(t[1]-n[1])>i)},e.prototype.equals=function(t,n){return n===void 0&&(n=0),e.equals(this,t,n)},e.isZeroVector=function(t,n){return n===void 0&&(n=0),yi(t,n)},e.prototype.isZeroVector=function(t){return t===void 0&&(t=0),yi(this,t)},e.prototype.toArray=function(){return[this[0],this[1]]},e.prototype.modify=function(t){return Jo(this,t)},e.prototype[Symbol.iterator]=function(){var t=this,n=0;return{next:function(){switch(n++){case 0:return{value:t[0],done:!1};case 1:return{value:t[1],done:!1};default:return{value:-1,done:!0}}}}},Object.defineProperty(e,"zero",{get:function(){return new e(0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"positiveInfinity",{get:function(){return new e(1/0,1/0)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"negativeInfinity",{get:function(){return new e(-1/0,-1/0)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"up",{get:function(){return new e(0,1)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"right",{get:function(){return new e(1,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"down",{get:function(){return new e(0,-1)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"left",{get:function(){return new e(-1,0)},enumerable:!1,configurable:!0}),e})();var ln=function(e,t){return ln=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var r in i)i.hasOwnProperty(r)&&(n[r]=i[r])},ln(e,t)};function ir(e,t){function n(){this.constructor=e}ln(e,t),e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Se=function(){return Se=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Se.apply(this,arguments)};function xi(e,t){for(var n=new Array(e.length),i=0;i<e.length;i++)n[i]=2*e[i]-t[i];return n}function un(e,t,n){var i,r,s,o,a=t.length-1;if(n)i=t[e-1<0?a:e-1],r=t[e%t.length],s=t[(e+1)%t.length],o=t[(e+2)%t.length];else{if(e===a)throw Error("There is no spline segment at this index for a closed curve!");r=t[e],s=t[e+1],i=e>0?t[e-1]:xi(r,s),o=e<a-1?t[e+2]:xi(s,r)}return[i,r,s,o]}function ea(e,t,n){n===void 0&&(n=!1);var i=n?t.length:t.length-1;if(e===1)return{index:i-1,weight:1};var r=i*e,s=Math.floor(r);return{index:s,weight:r-s}}function na(e,t){for(var n=0;n<e.length;n++)e[n]=t;return e}function ia(e,t){for(var n=0;n<e.length;n++)e[n]=t(e[n],n);return e}function ra(e,t,n){n===void 0&&(n=0);for(var i=0;i<e.length;i++)n=t(n,e[i],i);return n}function ue(e,t){t=t||new Array(e.length);for(var n=0;n<e.length;n++)t[n]=e[n];return t}function W(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e<t?t:e>n?n:e}function fn(e,t){var n=t[0];if(e>=t[t.length-1])return t.length-1;if(e<=n)return 0;for(var i=0,r=t.length-1;i<=r;){var s=Math.floor((i+r)/2),o=t[s];if(o<e)i=s+1;else{if(!(o>e))return s;r=s-1}}return Math.max(0,r)}var Q=Math.pow(2,-42);function vi(e){var t=Math.pow(Math.abs(e),.3333333333333333);return e<0?-t:t}function rr(e,t,n){if(Math.abs(e)<Q)return Math.abs(t)<Q?[]:[-n/t];var i=t*t-4*e*n;return Math.abs(i)<Q?[-t/(2*e)]:i>0?[(-t+Math.sqrt(i))/(2*e),(-t-Math.sqrt(i))/(2*e)]:[]}function sa(e,t,n,i){if(Math.abs(e)<Q)return rr(t,n,i);var r,s=(3*e*n-t*t)/(3*e*e),o=(2*t*t*t-9*e*t*n+27*e*e*i)/(27*e*e*e);if(Math.abs(s)<Q)r=[vi(-o)];else if(Math.abs(o)<Q)r=[0].concat(s<0?[Math.sqrt(-s),-Math.sqrt(-s)]:[]);else{var a=o*o/4+s*s*s/27;if(Math.abs(a)<Q)r=[-1.5*o/s,3*o/s];else if(a>0)r=[(c=vi(-o/2-Math.sqrt(a)))-s/(3*c)];else{var c=2*Math.sqrt(-s/3),h=Math.acos(3*o/s/c)/3,l=2*Math.PI/3;r=[c*Math.cos(h),c*Math.cos(h-l),c*Math.cos(h-2*l)]}}for(var u=0;u<r.length;u++)r[u]-=t/(3*e);return r}function ae(e,t){if(e.length!==t.length)throw Error("Vectors must be of equal length!");for(var n=0,i=0;i<e.length;i++)n+=e[i]*t[i];return n}function et(e,t,n){if(!(e.length>3)){n=n||new Array(3);var i=e[0],r=e[1],s=e[2]||0,o=t[0],a=t[1],c=t[2]||0;return n[0]=r*c-s*a,n[1]=s*o-i*c,n[2]=i*a-r*o,n}}function sr(e,t){for(var n=0,i=0;i<e.length;i++)n+=(e[i]-t[i])*(e[i]-t[i]);return n}function At(e){for(var t=0,n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t)}function Te(e,t){var n=sr(e,t);return n===0?0:Math.sqrt(n)}function ut(e,t){var n=t?ue(e,t):e,i=ra(n,(function(s,o){return s+Math.pow(o,2)})),r=Math.sqrt(i);return r===0?na(n,0):ia(n,(function(s){return s/r}))}function wi(e,t,n,i){t===void 0&&(t=[0,1,0]),n===void 0&&(n=0);var r=Math.cos(n),s=Math.sin(n),o=1-r,a=e[0],c=e[1],h=e[2],l=t[0],u=t[1],f=t[2],d=o*l,p=o*u;return(i=i||e)[0]=(d*l+r)*a+(d*u-s*f)*c+(d*f+s*u)*h,i[1]=(d*u+s*f)*a+(p*u+r)*c+(p*f-s*l)*h,i[2]=(d*f-s*u)*a+(p*f+s*l)*c+(o*f*f+r)*h,i}function oa(e,t,n,i,r){if(r===void 0&&(r=0),r===0)return[0,1,2,3];var s=function(c,h){return Math.pow(sr(c,h),.5*r)},o=s(t,e),a=s(n,t)+o;return[0,o,a,s(i,n)+a]}function aa(e,t,n,i,r){for(var s=Number.isFinite(r.tension)?r.tension:.5,o=Number.isFinite(r.alpha)?r.alpha:null,a=o>0?oa(e,t,n,i,o):null,c=new Array(e.length),h=0;h<e.length;h++){var l=0,u=0,f=e[h],d=t[h],p=n[h],g=i[h];if(a){var m=a[0],_=a[1],x=a[2],v=a[3];_-x!=0&&(m-_!=0&&m-x!=0&&(l=(1-s)*(x-_)*((f-d)/(m-_)-(f-p)/(m-x)+(d-p)/(_-x))),_-v!=0&&x-v!=0&&(u=(1-s)*(x-_)*((d-p)/(_-x)-(d-g)/(_-v)+(p-g)/(x-v))))}else l=(1-s)*(p-f)*.5,u=(1-s)*(g-d)*.5;var A=2*d-2*p+l+u,S=-3*d+3*p-2*l-u,M=l,b=d;c[h]=[A,S,M,b]}return c}function Ft(e,t){var n=e*e,i=e*n;return t[0]*i+t[1]*n+t[2]*e+t[3]}function Rt(e,t){var n=e*e;return 3*t[0]*n+2*t[1]*e+t[2]}function Ze(e,t){return 6*t[0]*e+2*t[1]}function ca(e,t){var n=t[0],i=t[1],r=t[2],s=t[3]-e;return n===0&&i===0&&r===0&&s===0?[0]:sa(n,i,r,s).filter((function(o){return o>-Q&&o<=1+Q})).map((function(o){return W(o,0,1)}))}function dn(e,t,n,i){i===void 0&&(i=null),i=i||new Array(n.length);for(var r=0;r<n.length;r++)i[r]=e(t,n[r]);return i}var or=(function(){function e(t){t===void 0&&(t=null),this._alpha=0,this._tension=.5,this._closed=!1,this._onInvalidateCache=null,this._onInvalidateCache=t,this._cache={arcLengths:null,coefficients:null}}return e.prototype._invalidateCache=function(){this.points&&(this._cache={arcLengths:null,coefficients:null},this._onInvalidateCache&&this._onInvalidateCache())},Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(t){Number.isFinite(t)&&t!==this._alpha&&(this._invalidateCache(),this._alpha=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tension",{get:function(){return this._tension},set:function(t){Number.isFinite(t)&&t!==this._tension&&(this._invalidateCache(),this._tension=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"points",{get:function(){return this._points},set:function(t){if(!t||t.length<2)throw Error("At least 2 control points are required!");this._points=t,this._invalidateCache()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"closed",{get:function(){return this._closed},set:function(t){t=!!t,this._closed!==t&&(this._invalidateCache(),this._closed=t)},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this._invalidateCache()},e.prototype.evaluateForT=function(t,n,i){var r=ea(n,this.points,this.closed),s=r.index;return dn(t,r.weight,this.getCoefficients(s),i)},e.prototype.getCoefficients=function(t){if(this.points){if(this._cache.coefficients||(this._cache.coefficients=new Map),!this._cache.coefficients.has(t)){var n=un(t,this.points,this.closed),i=aa(n[0],n[1],n[2],n[3],{tension:this.tension,alpha:this.alpha});this._cache.coefficients.set(t,i)}return this._cache.coefficients.get(t)}},e})(),ha=(function(e){function t(n,i){n===void 0&&(n=300),i===void 0&&(i=null);var r=e.call(this,i)||this;return r._subDivisions=n,r}return ir(t,e),Object.defineProperty(t.prototype,"arcLengths",{get:function(){return this._cache.arcLengths||(this._cache.arcLengths=this.computeArcLengths()),this._cache.arcLengths},enumerable:!1,configurable:!0}),t.prototype._invalidateCache=function(){e.prototype._invalidateCache.call(this),this._cache.arcLengths=null},t.prototype.computeArcLengths=function(){var n,i=[],r=this.evaluateForT(Ft,0),s=0;i.push(0);for(var o=1;o<=this._subDivisions;o++)s+=Te(n=this.evaluateForT(Ft,o/this._subDivisions),r),i.push(s),r=n;return i},t.prototype.lengthAt=function(n){var i=this.arcLengths;return n*i[i.length-1]},t.prototype.getT=function(n){var i=this.arcLengths,r=i.length,s=n*i[r-1],o=fn(s,i);if(i[o]===s)return o/(r-1);var a=i[o];return(o+(s-a)/(i[o+1]-a))/(r-1)},t.prototype.getU=function(n){if(n===0)return 0;if(n===1)return 1;var i=this.arcLengths,r=i.length-1,s=i[r],o=n*r,a=Math.floor(o),c=i[a];if(o===a)return c/s;var h=a/r;return(c+Te(this.evaluateForT(Ft,h),this.evaluateForT(Ft,n)))/s},t})(or),ar=[[[-.906179845938664,.23692688505618908],[-.5384693101056831,.47862867049936647],[0,.5688888888888889],[.5384693101056831,.47862867049936647],[.906179845938664,.23692688505618908]],[[-.932469514203152,.17132449237917036],[-.6612093864662645,.3607615730481386],[-.2386191860831969,.46791393457269104],[.2386191860831969,.46791393457269104],[.6612093864662645,.3607615730481386],[.932469514203152,.17132449237917036]],[[-.9491079123427585,.1294849661688697],[-.7415311855993945,.27970539148927664],[-.4058451513773972,.3818300505051189],[0,.4179591836734694],[.4058451513773972,.3818300505051189],[.7415311855993945,.27970539148927664],[.9491079123427585,.1294849661688697]],[[-.9602898564975363,.10122853629037626],[-.7966664774136267,.22238103445337448],[-.525532409916329,.31370664587788727],[-.1834346424956498,.362683783378362],[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],[[-.9681602395076261,.08127438836157441],[-.8360311073266358,.1806481606948574],[-.6133714327005904,.26061069640293544],[-.3242534234038089,.31234707704000286],[0,.3302393550012598],[.3242534234038089,.31234707704000286],[.6133714327005904,.26061069640293544],[.8360311073266358,.1806481606948574],[.9681602395076261,.08127438836157441]],[[-.9739065285171717,.06667134430868814],[-.8650633666889845,.1494513491505806],[-.6794095682990244,.21908636251598204],[-.4333953941292472,.26926671930999635],[-.14887433898163122,.29552422471475287],[.14887433898163122,.29552422471475287],[.4333953941292472,.26926671930999635],[.6794095682990244,.21908636251598204],[.8650633666889845,.1494513491505806],[.9739065285171717,.06667134430868814]],[[-.978228658146056,.0556685671161736],[-.887062599768095,.125580369464904],[-.730152005574049,.186290210927734],[-.519096129206811,.23319376459199],[-.269543155952344,.262804544510246],[0,.2729250867779],[.269543155952344,.262804544510246],[.519096129206811,.23319376459199],[.730152005574049,.186290210927734],[.887062599768095,.125580369464904],[.978228658146056,.0556685671161736]],[[-.981560634246719,.0471753363865118],[-.904117256370474,.106939325995318],[-.769902674194304,.160078328543346],[-.587317954286617,.203167426723065],[-.36783149899818,.233492536538354],[-.125233408511468,.249147045813402],[.125233408511468,.249147045813402],[.36783149899818,.233492536538354],[.587317954286617,.203167426723065],[.769902674194304,.160078328543346],[.904117256370474,.106939325995318],[.981560634246719,.0471753363865118]],[[-.984183054718588,.0404840047653158],[-.917598399222977,.0921214998377284],[-.801578090733309,.138873510219787],[-.64234933944034,.178145980761945],[-.448492751036446,.207816047536888],[-.230458315955134,.226283180262897],[0,.232551553230873],[.230458315955134,.226283180262897],[.448492751036446,.207816047536888],[.64234933944034,.178145980761945],[.801578090733309,.138873510219787],[.917598399222977,.0921214998377284],[.984183054718588,.0404840047653158]],[[-.986283808696812,.0351194603317518],[-.928434883663573,.0801580871597602],[-.827201315069764,.121518570687903],[-.687292904811685,.157203167158193],[-.515248636358154,.185538397477937],[-.319112368927889,.205198463721295],[-.108054948707343,.215263853463157],[.108054948707343,.215263853463157],[.319112368927889,.205198463721295],[.515248636358154,.185538397477937],[.687292904811685,.157203167158193],[.827201315069764,.121518570687903],[.928434883663573,.0801580871597602],[.986283808696812,.0351194603317518]],[[-.987992518020485,.0307532419961172],[-.937273392400705,.0703660474881081],[-.848206583410427,.107159220467171],[-.72441773136017,.139570677926154],[-.570972172608538,.166269205816993],[-.394151347077563,.186161000015562],[-.201194093997434,.198431485327111],[0,.202578241925561],[.201194093997434,.198431485327111],[.394151347077563,.186161000015562],[.570972172608538,.166269205816993],[.72441773136017,.139570677926154],[.848206583410427,.107159220467171],[.937273392400705,.0703660474881081],[.987992518020485,.0307532419961172]],[[-.989400934991649,.027152459411754],[-.944575023073232,.0622535239386478],[-.865631202387831,.0951585116824927],[-.755404408355003,.124628971255533],[-.617876244402643,.149595988816576],[-.458016777657227,.169156519395002],[-.281603550779258,.182603415044923],[-.0950125098376374,.189450610455068],[.0950125098376374,.189450610455068],[.281603550779258,.182603415044923],[.458016777657227,.169156519395002],[.617876244402643,.149595988816576],[.755404408355003,.124628971255533],[.865631202387831,.0951585116824927],[.944575023073232,.0622535239386478],[.989400934991649,.027152459411754]],[[-.990575475314417,.0241483028685479],[-.950675521768767,.0554595293739872],[-.880239153726985,.0850361483171791],[-.781514003896801,.111883847193403],[-.65767115921669,.135136368468525],[-.512690537086476,.15404576107681],[-.351231763453876,.16800410215645],[-.178484181495847,.176562705366992],[0,.179446470356206],[.178484181495847,.176562705366992],[.351231763453876,.16800410215645],[.512690537086476,.15404576107681],[.65767115921669,.135136368468525],[.781514003896801,.111883847193403],[.880239153726985,.0850361483171791],[.950675521768767,.0554595293739872],[.990575475314417,.0241483028685479]],[[-.99156516842093,.0216160135264833],[-.955823949571397,.0497145488949698],[-.892602466497555,.076425730254889],[-.803704958972523,.100942044106287],[-.691687043060353,.122555206711478],[-.559770831073947,.14064291467065],[-.411751161462842,.154684675126265],[-.251886225691505,.164276483745832],[-.0847750130417353,.169142382963143],[.0847750130417353,.169142382963143],[.251886225691505,.164276483745832],[.411751161462842,.154684675126265],[.559770831073947,.14064291467065],[.691687043060353,.122555206711478],[.803704958972523,.100942044106287],[.892602466497555,.076425730254889],[.955823949571397,.0497145488949697],[.99156516842093,.0216160135264833]],[[-.992406843843584,.0194617882297264],[-.96020815213483,.0448142267656996],[-.903155903614817,.0690445427376412],[-.822714656537142,.0914900216224499],[-.720966177335229,.111566645547333],[-.600545304661681,.128753962539336],[-.46457074137596,.142606702173606],[-.316564099963629,.152766042065859],[-.160358645640225,.158968843393954],[0,.161054449848783],[.160358645640225,.158968843393954],[.316564099963629,.152766042065859],[.46457074137596,.142606702173606],[.600545304661681,.128753962539336],[.720966177335229,.111566645547333],[.822714656537142,.0914900216224499],[.903155903614817,.0690445427376412],[.96020815213483,.0448142267656996],[.992406843843584,.0194617882297264]],[[-.993128599185094,.0176140071391521],[-.963971927277913,.0406014298003869],[-.912234428251325,.062672048334109],[-.839116971822218,.0832767415767047],[-.74633190646015,.10193011981724],[-.636053680726515,.118194531961518],[-.510867001950827,.131688638449176],[-.373706088715419,.142096109318382],[-.227785851141645,.149172986472603],[-.0765265211334973,.152753387130725],[.0765265211334973,.152753387130725],[.227785851141645,.149172986472603],[.373706088715419,.142096109318382],[.510867001950827,.131688638449176],[.636053680726515,.118194531961518],[.74633190646015,.10193011981724],[.839116971822218,.0832767415767047],[.912234428251325,.062672048334109],[.963971927277913,.0406014298003869],[.993128599185094,.0176140071391521]],[[-.993752170620389,.0160172282577743],[-.967226838566306,.0369537897708524],[-.9200993341504,.0571344254268572],[-.853363364583317,.0761001136283793],[-.768439963475677,.0934444234560338],[-.667138804197412,.108797299167148],[-.551618835887219,.121831416053728],[-.424342120207438,.132268938633337],[-.288021316802401,.139887394791073],[-.145561854160895,.14452440398997],[0,.14608113364969],[.145561854160895,.14452440398997],[.288021316802401,.139887394791073],[.424342120207438,.132268938633337],[.551618835887219,.121831416053728],[.667138804197412,.108797299167148],[.768439963475677,.0934444234560338],[.853363364583317,.0761001136283793],[.9200993341504,.0571344254268572],[.967226838566306,.0369537897708524],[.993752170620389,.0160172282577743]],[[-.994294585482399,.0146279952982722],[-.970060497835428,.0337749015848141],[-.926956772187174,.0522933351526832],[-.8658125777203,.0697964684245204],[-.787816805979208,.0859416062170677],[-.694487263186682,.10041414444288],[-.587640403506911,.112932296080539],[-.469355837986757,.123252376810512],[-.341935820892084,.131173504787062],[-.207860426688221,.136541498346015],[-.0697392733197222,.139251872855631],[.0697392733197222,.139251872855631],[.207860426688221,.136541498346015],[.341935820892084,.131173504787062],[.469355837986757,.123252376810512],[.587640403506911,.112932296080539],[.694487263186682,.10041414444288],[.787816805979208,.0859416062170677],[.8658125777203,.0697964684245204],[.926956772187174,.0522933351526832],[.970060497835428,.0337749015848141],[.994294585482399,.0146279952982722]],[[-.994769334997552,.0134118594871417],[-.972542471218115,.0309880058569794],[-.932971086826016,.0480376717310846],[-.876752358270441,.0642324214085258],[-.804888401618839,.0792814117767189],[-.71866136313195,.0929157660600351],[-.619609875763646,.104892091464541],[-.509501477846007,.114996640222411],[-.39030103803029,.123049084306729],[-.264135680970344,.128905722188082],[-.133256824298466,.132462039404696],[0,.133654572186106],[.133256824298466,.132462039404696],[.264135680970344,.128905722188082],[.39030103803029,.123049084306729],[.509501477846007,.114996640222411],[.619609875763646,.104892091464541],[.71866136313195,.0929157660600351],[.804888401618839,.0792814117767189],[.876752358270441,.0642324214085258],[.932971086826016,.0480376717310846],[.972542471218115,.0309880058569794],[.994769334997552,.0134118594871417]],[[-.995187219997021,.0123412297999872],[-.974728555971309,.0285313886289336],[-.938274552002732,.0442774388174198],[-.886415527004401,.0592985849154367],[-.820001985973902,.0733464814110803],[-.740124191578554,.0861901615319532],[-.648093651936975,.0976186521041138],[-.545421471388839,.107444270115965],[-.433793507626045,.115505668053725],[-.315042679696163,.121670472927803],[-.191118867473616,.125837456346828],[-.0640568928626056,.127938195346752],[.0640568928626056,.127938195346752],[.191118867473616,.125837456346828],[.315042679696163,.121670472927803],[.433793507626045,.115505668053725],[.545421471388839,.107444270115965],[.648093651936975,.0976186521041138],[.740124191578554,.0861901615319532],[.820001985973902,.0733464814110803],[.886415527004401,.0592985849154367],[.938274552002732,.0442774388174198],[.974728555971309,.0285313886289336],[.995187219997021,.0123412297999872]],[[-.995556969790498,.0113937985010262],[-.976663921459517,.0263549866150321],[-.942974571228974,.0409391567013063],[-.894991997878275,.0549046959758351],[-.833442628760834,.0680383338123569],[-.759259263037357,.080140700335001],[-.673566368473468,.0910282619829636],[-.577662930241222,.10053594906705],[-.473002731445714,.108519624474263],[-.361172305809387,.114858259145711],[-.243866883720988,.119455763535784],[-.12286469261071,.12224244299031],[0,.123176053726715],[.12286469261071,.12224244299031],[.243866883720988,.119455763535784],[.361172305809387,.114858259145711],[.473002731445714,.108519624474263],[.577662930241222,.10053594906705],[.673566368473468,.0910282619829636],[.759259263037357,.080140700335001],[.833442628760834,.0680383338123569],[.894991997878275,.0549046959758351],[.942974571228974,.0409391567013063],[.976663921459517,.0263549866150321],[.995556969790498,.0113937985010262]],[[-.995885701145616,.010551372617343],[-.97838544595647,.0244178510926319],[-.947159066661714,.0379623832943627],[-.902637861984307,.0509758252971478],[-.845445942788498,.0632740463295748],[-.776385948820678,.0746841497656597],[-.696427260419957,.0850458943134852],[-.606692293017618,.0942138003559141],[-.508440714824505,.102059161094425],[-.403051755123486,.108471840528576],[-.292004839485956,.113361816546319],[-.17685882035689,.116660443485296],[-.0592300934293132,.118321415279262],[.0592300934293132,.118321415279262],[.17685882035689,.116660443485296],[.292004839485956,.113361816546319],[.403051755123486,.108471840528576],[.508440714824505,.102059161094425],[.606692293017618,.0942138003559141],[.696427260419957,.0850458943134852],[.776385948820678,.0746841497656597],[.845445942788498,.0632740463295748],[.902637861984307,.0509758252971478],[.947159066661714,.0379623832943627],[.97838544595647,.0244178510926319],[.995885701145616,.010551372617343]],[[-.996179262888988,.00979899605129436],[-.979923475961501,.0226862315961806],[-.950900557814705,.0352970537574197],[-.909482320677491,.047449412520615],[-.856207908018294,.0589835368598335],[-.791771639070508,.0697488237662455],[-.717013473739423,.0796048677730577],[-.632907971946495,.0884231585437569],[-.540551564579456,.0960887273700285],[-.441148251750026,.102501637817745],[-.335993903638508,.107578285788533],[-.226459365439536,.111252488356845],[-.113972585609529,.113476346108965],[0,.114220867378956],[.113972585609529,.113476346108965],[.226459365439536,.111252488356845],[.335993903638508,.107578285788533],[.441148251750026,.102501637817745],[.540551564579456,.0960887273700285],[.632907971946495,.0884231585437569],[.717013473739423,.0796048677730577],[.791771639070508,.0697488237662455],[.856207908018294,.0589835368598336],[.909482320677491,.047449412520615],[.950900557814705,.0352970537574197],[.979923475961501,.0226862315961806],[.996179262888988,.00979899605129436]],[[-.996442497573954,.00912428259309452],[-.981303165370872,.0211321125927712],[-.954259280628938,.0329014277823043],[-.915633026392132,.0442729347590042],[-.865892522574395,.0551073456757167],[-.805641370917179,.0652729239669995],[-.735610878013631,.0746462142345687],[-.656651094038864,.0831134172289012],[-.569720471811401,.0905717443930328],[-.475874224955118,.0969306579979299],[-.376251516089078,.10211296757806],[-.272061627635178,.106055765922846],[-.16456928213338,.108711192258294],[-.0550792898840342,.110047013016475],[.0550792898840342,.110047013016475],[.16456928213338,.108711192258294],[.272061627635178,.106055765922846],[.376251516089078,.10211296757806],[.475874224955118,.0969306579979299],[.569720471811401,.0905717443930328],[.656651094038864,.0831134172289012],[.735610878013631,.0746462142345687],[.805641370917179,.0652729239669995],[.865892522574395,.0551073456757167],[.915633026392132,.0442729347590042],[.954259280628938,.0329014277823043],[.981303165370872,.0211321125927712],[.996442497573954,.00912428259309452]],[[-.996679442260596,.00851690387874641],[-.982545505261413,.0197320850561227],[-.957285595778087,.0307404922020936],[-.921180232953058,.0414020625186828],[-.874637804920102,.0515948269024979],[-.818185487615252,.0612030906570791],[-.752462851734477,.0701179332550512],[-.678214537602686,.0782383271357637],[-.596281797138227,.0854722573661725],[-.507592955124227,.0917377571392587],[-.413152888174008,.0969638340944086],[-.314031637867639,.101091273759914],[-.211352286166001,.104073310077729],[-.106278230132679,.10587615509732],[0,.106479381718314],[.106278230132679,.10587615509732],[.211352286166001,.104073310077729],[.314031637867639,.101091273759914],[.413152888174008,.0969638340944086],[.507592955124227,.0917377571392587],[.596281797138227,.0854722573661725],[.678214537602686,.0782383271357637],[.752462851734477,.0701179332550512],[.818185487615252,.0612030906570791],[.874637804920102,.0515948269024979],[.921180232953058,.0414020625186828],[.957285595778087,.0307404922020936],[.982545505261413,.0197320850561227],[.996679442260596,.00851690387874641]],[[-.996893484074649,.0079681924961666],[-.983668123279747,.0184664683110909],[-.960021864968307,.0287847078833233],[-.926200047429274,.038799192569627],[-.882560535792052,.048402672830594],[-.829565762382768,.057493156217619],[-.767777432104826,.0659742298821805],[-.697850494793315,.0737559747377052],[-.620526182989242,.0807558952294202],[-.536624148142019,.0868997872010829],[-.447033769538089,.0921225222377861],[-.352704725530878,.0963687371746442],[-.254636926167889,.0995934205867952],[-.153869913608583,.101762389748405],[-.0514718425553176,.102852652893558],[.0514718425553176,.102852652893558],[.153869913608583,.101762389748405],[.254636926167889,.0995934205867952],[.352704725530878,.0963687371746442],[.447033769538089,.0921225222377861],[.536624148142019,.0868997872010829],[.620526182989242,.0807558952294202],[.697850494793315,.0737559747377052],[.767777432104826,.0659742298821805],[.829565762382768,.057493156217619],[.882560535792052,.048402672830594],[.926200047429274,.038799192569627],[.960021864968307,.0287847078833233],[.983668123279747,.0184664683110909],[.996893484074649,.0079681924961666]]],bi=ar.length+5,la=(function(e){function t(n,i,r){n===void 0&&(n=24),i===void 0&&(i=21);var s=e.call(this,r)||this;return s._nSamples=21,s._gauss=(function(o){if(o<5||o>bi)throw Error("Order for Gaussian Quadrature must be in the range of ".concat(5," and ").concat(bi,"."));return ar[o-5]})(n),s._nSamples=i,s}return ir(t,e),t.prototype._invalidateCache=function(){e.prototype._invalidateCache.call(this),this._cache.arcLengths=null,this._cache.samples=null},Object.defineProperty(t.prototype,"arcLengths",{get:function(){return this._cache.arcLengths||(this._cache.arcLengths=this.computeArcLengths()),this._cache.arcLengths},enumerable:!1,configurable:!0}),t.prototype.getSamples=function(n){if(this.points){if(this._cache.samples||(this._cache.samples=new Map),!this._cache.samples.has(n)){for(var i=this._nSamples,r=[],s=[],o=this.getCoefficients(n),a=0;a<i;++a){var c=a/(i-1);r.push(this.computeArcLength(n,0,c));var h=At(dn(Rt,c,o)),l=h===0?0:1/h;this.tension>.95&&(l=W(l,-1,1)),s.push(l)}var u=i-1,f=[],d=[],p=r[0],g=s[0],m=1/u;for(a=0;a<u;++a){var _=p,x=(p=r[a+1])-_,v=g,A=s[a+1];g=A;var S=m/x,M=(v+A-2*S)/(x*x),b=(3*S-2*v-A)/x;f.push(M),d.push(b)}this._cache.samples.set(n,[r,s,d,f])}return this._cache.samples.get(n)}},t.prototype.computeArcLength=function(n,i,r){if(i===void 0&&(i=0),r===void 0&&(r=1),i===r)return 0;for(var s=this.getCoefficients(n),o=.5*(r-i),a=0,c=0;c<this._gauss.length;c++){var h=this._gauss[c],l=h[0];a+=h[1]*At(dn(Rt,o*l+o+i,s))}return o*a},t.prototype.computeArcLengths=function(){if(this.points){var n=[];n.push(0);for(var i=this.closed?this.points.length:this.points.length-1,r=0,s=0;s<i;s++)r+=this.computeArcLength(s),n.push(r);return n}},t.prototype.inverse=function(n,i){var r=1/(this._nSamples-1),s=this.getSamples(n),o=s[0],a=s[1],c=s[2],h=s[3];if(i>=o[o.length-1])return 1;if(i<=0)return 0;var l=Math.max(0,fn(i,o)),u=l*r;if(o[l]===i)return u;var f=a[l],d=h[l],p=c[l],g=i-o[l];return((d*g+p)*g+f)*g+u},t.prototype.lengthAt=function(n){return n*this.arcLengths[this.arcLengths.length-1]},t.prototype.getT=function(n){var i=this.arcLengths,r=i.length,s=n*i[r-1],o=fn(s,i),a=o/(r-1);if(i[o]===s)return a;var c=s-i[o];return(o+this.inverse(o,c))/(r-1)},t.prototype.getU=function(n){if(n===0)return 0;if(n===1)return 1;var i=this.arcLengths,r=i.length-1,s=i[r],o=n*r,a=Math.floor(o),c=i[a];if(o===a)return c/s;var h=o-a;return(c+this.computeArcLength(a,0,h))/s},t})(or),cr=(function(){function e(t,n){n===void 0&&(n={});var i=this;this._cache=new Map;var r=(n=Se({tension:.5,alpha:0,closed:!1},n)).arcDivisions?new ha(n.arcDivisions,(function(){return i._invalidateCache()})):new la(n.numericalApproximationOrder,n.numericalInverseSamples,(function(){return i._invalidateCache()}));r.alpha=n.alpha,r.tension=n.tension,r.closed=n.closed,r.points=t,this._lmargin=n.lmargin||1-r.tension,this._curveMapper=r}return e.prototype.getTimeFromPosition=function(t,n){return n===void 0&&(n=!1),this._curveMapper.getT(n?W(t,0,1):t)},e.prototype.getPositionFromTime=function(t,n){return n===void 0&&(n=!1),this._curveMapper.getU(n?W(t,0,1):t)},e.prototype.getPositionFromLength=function(t,n){n===void 0&&(n=!1);var i=n?W(t,0,this.length):t;return this._curveMapper.getU(i/this.length)},e.prototype.getLengthAt=function(t,n){return t===void 0&&(t=1),n===void 0&&(n=!1),this._curveMapper.lengthAt(n?W(t,0,1):t)},e.prototype.getTimeAtKnot=function(t){if(t<0||t>this.points.length-1)throw Error("Invalid index!");return t===0?0:this.closed||t!==this.points.length-1?t/(this.closed?this.points.length:this.points.length-1):1},e.prototype.getPositionAtKnot=function(t){return this.getPositionFromTime(this.getTimeAtKnot(t))},e.prototype.getPointAtTime=function(t,n){return(t=W(t,0,1))===0?ue(this.points[0],n):t===1?ue(this.closed?this.points[0]:this.points[this.points.length-1],n):this._curveMapper.evaluateForT(Ft,t,n)},e.prototype.getPointAt=function(t,n){return this.getPointAtTime(this.getTimeFromPosition(t),n)},e.prototype.getTangentAt=function(t,n){var i=W(this.getTimeFromPosition(t),0,1);return this.getTangentAtTime(i,n)},e.prototype.getTangentAtTime=function(t,n){return ut(this._curveMapper.evaluateForT(Rt,t,n))},e.prototype.getNormalAt=function(t,n){var i=W(this.getTimeFromPosition(t),0,1);return this.getNormalAtTime(i,n)},e.prototype.getNormalAtTime=function(t,n){var i=ut(this._curveMapper.evaluateForT(Rt,t));if(!(i.length<2||i.length>3)){var r=n||new Array(i.length);if(i.length===2)return r[0]=-i[1],r[1]=i[0],r;var s=ut(this._curveMapper.evaluateForT(Ze,t));return ut(et(et(i,s),i),r)}},e.prototype.getFrenetFrames=function(t,n,i){if(n===void 0&&(n=0),i===void 0&&(i=1),!(n<0||i>1||i<n)){for(var r=new Array(t+1),s=new Array(t+1),o=0;o<=t;o++){var a=n===0&&i===1?o/t:n+o/t*(i-n);r[o]=this.getTangentAt(a)}if(this.dim===2){for(o=0;o<r.length;o++)s[o]=[-r[o][1],r[o][0]];return{tangents:r,normals:s}}if(this.dim===3){var c=new Array(t+1),h=void 0,l=Number.MAX_VALUE,u=Math.abs(r[0][0]),f=Math.abs(r[0][1]);u<=l&&(l=u,h=[1,0,0]),f<=l&&(l=f,h=[0,1,0]),Math.abs(r[0][2])<=l&&(h=[0,0,1]);var d=ut(et(r[0],h));for(s[0]=et(r[0],d),c[0]=et(r[0],s[0]),o=1;o<=t;o++){if(d=et(r[o-1],r[o]),s[o]=ue(s[o-1]),At(d)>Q){ut(d);var p=Math.acos(W(ae(r[o-1],r[o]),-1,1));wi(s[o-1],d,p,s[o])}c[o]=et(r[o],s[o])}if(this.closed===!0)for(p=Math.acos(W(ae(s[0],s[t]),-1,1))/t,ae(r[0],et(s[0],s[t]))>0&&(p=-p),o=1;o<=t;o++)wi(s[o],r[o],p*o,s[o]),c[o]=et(r[o],s[o]);return{tangents:r,normals:s,binormals:c}}}},e.prototype.getCurvatureAt=function(t){var n=W(this.getTimeFromPosition(t),0,1);return this.getCurvatureAtTime(n)},e.prototype.getCurvatureAtTime=function(t){var n=this._curveMapper.evaluateForT(Rt,t),i=this._curveMapper.evaluateForT(Ze,t),r=ut(n,[]),s=0,o=void 0;if(n.length===2){if((u=Math.pow(n[0]*n[0]+n[1]*n[1],1.5))!==0){var a=(n[0]*i[1]-n[1]*i[0])/u;o=a<0?[r[1],-r[0]]:[-r[1],r[0]],s=Math.abs(a)}}else if(n.length===3){var c=At(n),h=et(n,i);o=ut(et(h,n)),c!==0&&(s=At(h)/Math.pow(c,3))}else{c=At(n);var l=At(i),u=Math.pow(c,3),f=ae(n,i);u!==0&&(s=Math.sqrt(Math.pow(c,2)*Math.pow(l,2)-Math.pow(f,2))/u)}return{curvature:s,radius:s!==0?1/s:0,tangent:r,direction:o}},e.prototype.getDerivativeAt=function(t,n){var i=W(this.getTimeFromPosition(t),0,1);return this._curveMapper.evaluateForT(Rt,i,n)},e.prototype.getSecondDerivativeAt=function(t,n){var i=W(this.getTimeFromPosition(t),0,1);return this._curveMapper.evaluateForT(Ze,i,n)},e.prototype.getBoundingBox=function(t,n){if(t===void 0&&(t=0),n===void 0&&(n=1),t===0&&n===1&&this._cache.has("bbox"))return this._cache.get("bbox");for(var i=[],r=[],s=this.getTimeFromPosition(t),o=this.getTimeFromPosition(n),a=this.getPointAtTime(s),c=this.getPointAtTime(o),h=this.closed?this.points.length:this.points.length-1,l=Math.floor(h*s),u=Math.ceil(h*o),f=0;f<a.length;f++)i[f]=Math.min(a[f],c[f]),r[f]=Math.max(a[f],c[f]);for(var d=function(_){var x=un(_-1,p.points,p.closed)[2];if(_<u)for(var v=0;v<x.length;v++)x[v]<i[v]&&(i[v]=x[v]),x[v]>r[v]&&(r[v]=x[v]);if(p.tension<1){var A=h*s-(_-1),S=h*o-(_-1),M=function(k){return k>-Q&&k<=1+Q&&(_-1!==l||k>A)&&(_!==u||k<S)},b=p._curveMapper.getCoefficients(_-1),C=function(k){var O=b[k];rr(3*O[0],2*O[1],O[2]).filter(M).forEach((function(L){var z=Ft(L,b[k]);z<i[k]&&(i[k]=z),z>r[k]&&(r[k]=z)}))};for(v=0;v<b.length;v++)C(v)}},p=this,g=l+1;g<=u;g++)d(g);var m={min:i,max:r};return t===0&&n===1&&this._cache.set("bbox",m),m},e.prototype.getPoints=function(t,n,i,r){if(t===void 0&&(t=100),i===void 0&&(i=0),r===void 0&&(r=1),!t||t<=0)throw Error("Invalid arguments passed to getPoints(). You must specify at least 1 sample/segment.");if(!(i<0||r>1||r<i)){for(var s=[],o=0;o<=t;o++){var a=i===0&&r===1?o/t:i+o/t*(r-i);s.push(this.getPointAt(a,n&&new n))}return s}},e.prototype.getNearestPosition=function(t,n,i){var r=this;if(n===void 0&&(n=1e-5),n<=0||!Number.isFinite(n))throw Error("Invalid threshold. Must be a number greater than zero!");i=i||10*this.points.length-1;var s=new Array(t.length),o=1/0,a=0,c=this.createLookupTable((function(f){return r.getPointAt(f)}),i,{cacheKey:"lut_nearest_".concat(i)});Array.from(c.keys()).forEach((function(f){var d=c.get(f),p=Te(t,d);if(p<o)return o=p,a=f,!0}));for(var h=this.getTimeFromPosition(a),l=function(f){if(f>=0&&f<=1){r.getPointAtTime(f,s);var d=Te(t,s);if(d<o)return o=d,h=f,!0}},u=.005;u>n;)l(h-u)||l(h+u)||(u/=2);return{u:a=this._curveMapper.getU(h),distance:o,point:s}},e.prototype.getIntersects=function(t,n,i,r){var s=this;n===void 0&&(n=0),i===void 0&&(i=0),r===void 0&&(r=this._lmargin);var o=this.getIntersectsAsTime(t,n,i,r).map((function(a){return s.getPointAtTime(a)}));return Math.abs(i)===1?o.length===1?o[0]:null:o},e.prototype.getIntersectsAsPositions=function(t,n,i,r){var s=this;return n===void 0&&(n=0),i===void 0&&(i=0),r===void 0&&(r=this._lmargin),this.getIntersectsAsTime(t,n,i,r).map((function(o){return s.getPositionFromTime(o)}))},e.prototype.getIntersectsAsTime=function(t,n,i,r){n===void 0&&(n=0),i===void 0&&(i=0),r===void 0&&(r=this._lmargin);for(var s=n,o=new Set,a=this.closed?this.points.length:this.points.length-1,c=0;c<a&&(i===0||o.size<Math.abs(i));c+=1){var h=i<0?a-(c+1):c,l=un(h,this.points,this.closed),u=l[1],f=l[2],d=this._curveMapper.getCoefficients(h),p=void 0,g=void 0;if(u[s]<f[s]?(p=u[s],g=f[s]):(p=f[s],g=u[s]),t-r<=g&&t+r>=p){var m=ca(t,d[s]);i<0?m.sort((function(v,A){return A-v})):i>=0&&m.sort((function(v,A){return v-A}));for(var _=0;_<m.length;_++){var x=(m[_]+h)/a;if(o.add(x),i!==0&&o.size===Math.abs(i))break}}}return Array.from(o)},e.prototype.createLookupTable=function(t,n,i){if(!n||n<=1)throw Error("Invalid arguments passed to createLookupTable(). You must specify at least 2 samples.");var r=Se({from:0,to:1,cacheForceUpdate:!1},i),s=r.from,o=r.to,a=r.cacheKey,c=r.cacheForceUpdate;if(!(s<0||o>1||o<s)){var h=null;if(a&&!c&&this._cache.has(a))a&&this._cache.has(a)&&(h=this._cache.get(a));else{h=new Map;for(var l=0;l<n;l++){var u=s===0&&o===1?l/(n-1):s+l/(n-1)*(o-s),f=t(u);h.set(u,f)}a&&this._cache.set(a,h)}return h}},e.prototype.forEach=function(t,n,i,r){var s=this;i===void 0&&(i=0),r===void 0&&(r=1);var o=[];if(Number.isFinite(n)){var a=n;if(a<=1)throw Error("Invalid arguments passed to forEach(). You must specify at least 2 samples.");for(var c=0;c<a;c++){var h=i===0&&r===1?c/(a-1):i+c/(a-1)*(r-i);o.push(h)}}else Array.isArray(n)&&(o=n);var l=null;o.forEach((function(u,f){if(!Number.isFinite(u)||u<0||u>1)throw Error("Invalid position (u) for sample in forEach!");var d=s.getTimeFromPosition(u),p=t({u,t:d,i:f,prev:l});l={u,t:d,i:f,value:p}}))},e.prototype.map=function(t,n,i,r){var s=this;i===void 0&&(i=0),r===void 0&&(r=1);var o=[];if(Number.isFinite(n)){var a=n;if(a<=1)throw Error("Invalid arguments passed to map(). You must specify at least 2 samples.");for(var c=0;c<a;c++){var h=i===0&&r===1?c/(a-1):i+c/(a-1)*(r-i);o.push(h)}}else Array.isArray(n)&&(o=n);var l=null;return o.map((function(u,f){if(!Number.isFinite(u)||u<0||u>1)throw Error("Invalid position (u) for sample in map()!");var d=s.getTimeFromPosition(u),p=t({u,t:d,i:f,prev:l});return l={u,t:d,i:f,value:p},p}))},e.prototype.reduce=function(t,n,i,r,s){var o=this;r===void 0&&(r=0),s===void 0&&(s=1);var a=[];if(Number.isFinite(i)){var c=i;if(c<=1)throw Error("Invalid arguments passed to map(). You must specify at least 2 samples.");for(var h=0;h<c;h++){var l=r===0&&s===1?h/(c-1):r+h/(c-1)*(s-r);a.push(l)}}else Array.isArray(i)&&(a=i);return a.reduce((function(u,f,d){if(!Number.isFinite(f)||f<0||f>1)throw Error("Invalid position (u) for sample in map()!");var p=o.getTimeFromPosition(f);return t({acc:u,u:f,t:p,i:d})}),n)},e.prototype._invalidateCache=function(){return this._cache=new Map,this},e.prototype.reset=function(){this._curveMapper.reset()},Object.defineProperty(e.prototype,"points",{get:function(){return this._curveMapper.points},set:function(t){this._curveMapper.points=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tension",{get:function(){return this._curveMapper.tension},set:function(t){this._curveMapper.tension=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this._curveMapper.alpha},set:function(t){this._curveMapper.alpha=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"closed",{get:function(){return this._curveMapper.closed},set:function(t){this._curveMapper.closed=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._curveMapper.lengthAt(1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minX",{get:function(){return this.getBoundingBox().min[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxX",{get:function(){return this.getBoundingBox().max[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minY",{get:function(){return this.getBoundingBox().min[1]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxY",{get:function(){return this.getBoundingBox().max[1]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minZ",{get:function(){return this.getBoundingBox().min[2]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxZ",{get:function(){return this.getBoundingBox().max[2]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dim",{get:function(){var t;return((t=this.points[0])===null||t===void 0?void 0:t.length)||void 0},enumerable:!1,configurable:!0}),e})();class Ae{static newton(t,n=.01,i=1e3,r=.5,s=0,o=1){let c=r;for(let h=0;h<i;h++){const l=t(c);if(Math.abs(l)<n)return _t(c,s,o);const u=(t(c+1e-4)-l)/1e-4;c=c-l/u}}static bisect(t,n=.01,i=1e3,r=.5,s=0,o=1){let a=s,c=o,h=r,l,u;for(u=0;u<i;u++){if(l=t(h),Math.abs(l)<n)return h;l<0?c=h:a=h,h=(c+a)/2}return h}static findRoot(t,n=.01,i=1e3,r=.5,s=0,o=1){let a=Ae.newton(t,n,i,r);return a==null&&(a=Ae.bisect(t,n,i,r,s,o)),a}}class ua{static bisect(t,n=0,i=1,r=.005,s=4,o=10){const a=(f,d,p,g,m,_,x=0)=>{const v=(f+d)/2,A=t(v),S=N.distance(p,A),M=N.distance(A,g),b=S+M;if(x>=s&&Math.abs(b-m)<_||x>=o)return b;const C=_/2,k=x+1;return a(f,v,p,A,S,C,k)+a(v,d,A,g,M,C,k)},c=t(n),h=t(i),l=N.distance(c,h);return a(n,i,c,h,l,r)}static trapezoid(t,n=0,i=1,r=1e3){let s=0,o=t(n);const a=(i-n)/(r-1);for(let c=1;c<r;c++){const h=t(n+c*a),l=N.distance(o,h);s+=l,o=h}return s}}class fa{static search(t,n){let i=0,r=t.length-1,s=Math.floor(i+r/2);for(;s>i&&s<r;){const o=t[s],a=t[s+1];if(o!=null&&a!=null&&o<=n&&a>=n)return s;o!=null&&n<o?r=s:i=s,s=Math.floor(i+r/2)}return s}}class Ke extends cr{constructor(t,n){super(t,n),this.arcLengthLookup=[],this.findTForArcLength=this.findTForArcLength.bind(this),this.findTByRootForArcLength=this.findTByRootForArcLength.bind(this),this.findApproxTForArcLength=this.findApproxTForArcLength.bind(this),this.findTQuickForArcLength=this.findTQuickForArcLength.bind(this),this.generateArcLengthLookup=this.generateArcLengthLookup.bind(this),this.getArcLength=this.getArcLength.bind(this),this.getQuickArcLength=this.getQuickArcLength.bind(this),this.getPointAtArcLength=this.getPointAtArcLength.bind(this),this.getPointAt=this.getPointAt.bind(this)}findTForArcLength(t,n){let i;return n?.approxT?i=this.findApproxTForArcLength(t,n?.normalizedLength):n?.quickT?i=this.findTQuickForArcLength(t):i=this.findTByRootForArcLength(t),i}findTByRootForArcLength(t,n=.01,i=100){return t<=0?0:t>=this.length?1:Ae.findRoot(s=>t-this.getQuickArcLength(0,s),n,i,t/this.length)}findApproxTForArcLength(t,n){return t/(n||this.length)}findTQuickForArcLength(t){this.arcLengthLookup.length===0&&this.generateArcLengthLookup();const n=fa.search(this.arcLengthLookup,t),i=this.arcLengthLookup[n],r=this.arcLengthLookup[n+1];return(n+(t-i)/(r-i))/this.arcLengthLookup.length}generateArcLengthLookup(t=1e3){let n=this.getPointAt(0),i=0;for(let r=0;r<t;r++){const s=this.getPointAt(r/(t-1)),o=N.distance(n,s);i+=o,this.arcLengthLookup.push(i),n=s}}getArcLength(t=0,n=1){return t===0&&n===1?this.length:ua.bisect(r=>this.getPointAt(r),t,n,.002)}getQuickArcLength(t=0,n=1){let i=0,r=this.length;if(this.arcLengthLookup.length===0&&this.generateArcLengthLookup(),t!==0){const o=Math.floor(t*this.arcLengthLookup.length),a=this.arcLengthLookup[o],c=this.arcLengthLookup[o+1];i=a+t*this.arcLengthLookup.length%this.arcLengthLookup.length*(c-a)}if(n!==1){const o=Math.floor(n*this.arcLengthLookup.length),a=this.arcLengthLookup[o],c=this.arcLengthLookup[o+1];r=a+t*this.arcLengthLookup.length%this.arcLengthLookup.length*(c-a)}return r-i}getPointAtArcLength(t,n){const i=this.findTForArcLength(t,n);return this.getPointAt(i)}getPointAt(t){const n=_t(t,0,1);return super.getPointAt(n)}}const Si=.75,Ti=5e3,Ai=.001,da=1e3,pa=1e3,ga=5e-4,ma=.1,ya={approxT:!0};class zt{constructor(t,n){if(this.path=[],this.projectedPath=[],this._offset=0,t.length<1)throw new Error("Missing coordinates");if(t[0]&&t[0].length!==3)throw new Error("Coordinates should be in 3d");this.setPath(t,n),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.getPosition=this.getPosition.bind(this),this.getProjectedLength=this.getProjectedLength.bind(this),this.getTrajectory=this.getTrajectory.bind(this)}setPath(t,n={}){this.options={...ya,...n};const{arcDivisions:i,tension:r,calculateDisplacementFromBottom:s}=this.options;this.path=t,this.projectedPath=zt.toDisplacement(t);const[o]=this.projectedPath[this.projectedPath.length-1];this.displacement=o,this.interpolators={curve:n.curveInterpolator||new Ke(t),trajectory:n.trajectoryInterpolator||new Ke(t.map(h=>[h[0],h[1]]),{tension:r||Si,arcDivisions:i||Ti}),curtain:n.curtainInterpolator||new Ke(this.projectedPath,{tension:r||Si,arcDivisions:i||Ti})};const a=this.getTrajectoryVector(),c=a.map(h=>h*-1);s?(this.endVector=c,this.startVector=a):(this.endVector=a,this.startVector=c),this._curtainPathCache=void 0}project(t){const{curtain:n}=this.interpolators,{calculateDisplacementFromBottom:i}=this.options,r=_t(i?this.length-(t-this._offset):t-this._offset,0,this.length);return n.getPointAtArcLength(r,this.options)}curtainTangent(t){const{curtain:n}=this.interpolators,i=t-this._offset,r=n.findTForArcLength(i,this.options);return r&&n.getTangentAt(r)}getCurtainPath(t,n,i=!1){if(!this._curtainPathCache){const r=[];let s=Math.PI*2;for(let o=this._offset;o<=this.length+this._offset;o+=ma){const a=this.project(o),c=Math.atan2(a[1],a[0]);Math.abs(c-s)>ga&&(r.push({point:a,md:o}),s=c)}this._curtainPathCache=r}if(i){const r={point:this.project(t),md:t},s=this._curtainPathCache.filter(a=>a.md>t&&a.md<n),o={point:this.project(n),md:n};return[r,...s,o]}return this._curtainPathCache.filter(r=>r.md>=t&&r.md<=n)}unproject(t){const{normalizedLength:n,calculateDisplacementFromBottom:i}=this.options,r=i?this.displacement-t:t,s=n||this.length;if(r<0)return r;if(r>this.displacement)return s+(r-this.displacement);const o=this.interpolators.curtain.getIntersectsAsPositions(r,0,1);if(o&&o.length)return o[0]*s+this._offset}getProjectedLength(t){const{curtain:n}=this.interpolators,r=this.project(t)[0]/n.maxX;return Number.isFinite(r)?_t(r,0,1):0}getPosition(t){const{trajectory:n}=this.interpolators,i=this.getProjectedLength(t);return n.getPointAt(i)}getTrajectory(t,n=0,i=1){const r=n<0?-n:0,s=i>1?i-1:0,o=this.interpolators.trajectory.getPointAt(0),a=this.interpolators.trajectory.getPointAt(1);let c,h,l=0;const u=Math.max(0,n),f=Math.min(1,i),d=this.interpolators.trajectory.getPointAt(u),p=this.interpolators.trajectory.getPointAt(f);r?(c=[o[0]+this.startVector[0]*r*this.displacement,o[1]+this.startVector[1]*r*this.displacement],l=-N.distance(c,o)):n>0&&(l=N.distance(d,o)),s&&(h=[a[0]+this.endVector[0]*s*this.displacement,a[1]+this.endVector[1]*s*this.displacement]);const g=[],m=i-n,_=Math.floor(r/m*t),x=Math.ceil((f-u)/m*t),v=t-x-_;if(c){g.push(c);for(let S=1;S<_;S++){const M=S/_*r*this.displacement;g.push([c[0]-this.startVector[0]*M,c[1]-this.startVector[1]*M])}}const A=this.interpolators.trajectory.getPoints(x-1,null,u,f);if(g.push(...A),h){for(let S=1;S<v-1;S++){const M=S/v*s*this.displacement;g.push([p[0]+this.endVector[0]*M,p[1]+this.endVector[1]*M])}g.push(h)}return{points:g,offset:l}}getExtendedTrajectory(t,n=da,i=pa){if(!isFinite(n)||n<0)throw new Error("Invalid parameter, getExtendedTrajectory() must be called with a valid and positive startExtensionLength parameter");if(!isFinite(i)||i<0)throw new Error("Invalid parameter, getExtendedTrajectory() must be called with a valid and positive endExtensionLength parameter");const r=this.displacement+n+i,s=Math.floor(n/r*t),o=Math.max(Math.ceil(this.displacement/r*t),1),a=t-o-s,c=[],h=new N(this.interpolators.trajectory.getPointAt(0)),l=new N(this.startVector),u=n/s;for(let x=s;x>0;x--){const v=x*u,A=h.add(l.scale(v));c.push(A.toArray())}const f=this.interpolators.trajectory.getPoints(o,null,0,1);c.push(...f);const d=new N(this.interpolators.trajectory.getPointAt(1)),p=new N(this.endVector),g=i/(a-1);for(let x=1;x<a;x++){const v=x*g,A=d.add(p.scale(v));c.push(A.toArray())}const m=-n;return{points:c,offset:m}}getTrajectoryVector(){const{trajectoryAngle:t,calculateDisplacementFromBottom:n}=this.options;if(t!=null&&isFinite(t)){const r=Go(t);return new N(Math.cos(r),Math.sin(r)).toArray()}return zt.getDirectionVector(this.interpolators.trajectory,n?Ai:1-Ai,n?0:1)}static toDisplacement(t,n=0){let i=t[0],r=0;return t.map(o=>{const a=o[0]-i[0],c=o[1]-i[1];return r+=Math.sqrt(a**2+c**2),i=o,[n>0?n-r:r,o[2]||0]})}static getDirectionVector(t,n,i){const r=t.getPointAt(i),s=t.getPointAt(n);return ut([r[0]-s[0],r[1]-s[1]])}get length(){return this.interpolators.curve?.length??0}get offset(){return this._offset}set offset(t){this._curtainPathCache=void 0,this._offset=t}}var pn="http://www.w3.org/1999/xhtml";const Mi={svg:"http://www.w3.org/2000/svg",xhtml:pn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ie(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Mi.hasOwnProperty(t)?{space:Mi[t],local:e}:e}function _a(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===pn&&t.documentElement.namespaceURI===pn?t.createElement(e):t.createElementNS(n,e)}}function xa(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function hr(e){var t=Ie(e);return(t.local?xa:_a)(t)}function va(){}function Fn(e){return e==null?va:function(){return this.querySelector(e)}}function wa(e){typeof e!="function"&&(e=Fn(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=new Array(o),c,h,l=0;l<o;++l)(c=s[l])&&(h=e.call(c,c.__data__,l,s))&&("__data__"in c&&(h.__data__=c.__data__),a[l]=h);return new Z(i,this._parents)}function ba(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Sa(){return[]}function lr(e){return e==null?Sa:function(){return this.querySelectorAll(e)}}function Ta(e){return function(){return ba(e.apply(this,arguments))}}function Aa(e){typeof e=="function"?e=Ta(e):e=lr(e);for(var t=this._groups,n=t.length,i=[],r=[],s=0;s<n;++s)for(var o=t[s],a=o.length,c,h=0;h<a;++h)(c=o[h])&&(i.push(e.call(c,c.__data__,h,o)),r.push(c));return new Z(i,r)}function ur(e){return function(){return this.matches(e)}}function fr(e){return function(t){return t.matches(e)}}var Ma=Array.prototype.find;function Pa(e){return function(){return Ma.call(this.children,e)}}function Ca(){return this.firstElementChild}function La(e){return this.select(e==null?Ca:Pa(typeof e=="function"?e:fr(e)))}var ka=Array.prototype.filter;function Ea(){return Array.from(this.children)}function Fa(e){return function(){return ka.call(this.children,e)}}function Ra(e){return this.selectAll(e==null?Ea:Fa(typeof e=="function"?e:fr(e)))}function Ia(e){typeof e!="function"&&(e=ur(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=[],c,h=0;h<o;++h)(c=s[h])&&e.call(c,c.__data__,h,s)&&a.push(c);return new Z(i,this._parents)}function dr(e){return new Array(e.length)}function Oa(){return new Z(this._enter||this._groups.map(dr),this._parents)}function Me(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Me.prototype={constructor:Me,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function za(e){return function(){return e}}function Da(e,t,n,i,r,s){for(var o=0,a,c=t.length,h=s.length;o<h;++o)(a=t[o])?(a.__data__=s[o],i[o]=a):n[o]=new Me(e,s[o]);for(;o<c;++o)(a=t[o])&&(r[o]=a)}function Na(e,t,n,i,r,s,o){var a,c,h=new Map,l=t.length,u=s.length,f=new Array(l),d;for(a=0;a<l;++a)(c=t[a])&&(f[a]=d=o.call(c,c.__data__,a,t)+"",h.has(d)?r[a]=c:h.set(d,c));for(a=0;a<u;++a)d=o.call(e,s[a],a,s)+"",(c=h.get(d))?(i[a]=c,c.__data__=s[a],h.delete(d)):n[a]=new Me(e,s[a]);for(a=0;a<l;++a)(c=t[a])&&h.get(f[a])===c&&(r[a]=c)}function $a(e){return e.__data__}function Ba(e,t){if(!arguments.length)return Array.from(this,$a);var n=t?Na:Da,i=this._parents,r=this._groups;typeof e!="function"&&(e=za(e));for(var s=r.length,o=new Array(s),a=new Array(s),c=new Array(s),h=0;h<s;++h){var l=i[h],u=r[h],f=u.length,d=Ha(e.call(l,l&&l.__data__,h,i)),p=d.length,g=a[h]=new Array(p),m=o[h]=new Array(p),_=c[h]=new Array(f);n(l,u,g,m,_,d,t);for(var x=0,v=0,A,S;x<p;++x)if(A=g[x]){for(x>=v&&(v=x+1);!(S=m[v])&&++v<p;);A._next=S||null}}return o=new Z(o,i),o._enter=a,o._exit=c,o}function Ha(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Xa(){return new Z(this._exit||this._groups.map(dr),this._parents)}function Ua(e,t,n){var i=this.enter(),r=this,s=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?s.remove():n(s),i&&r?i.merge(r).order():r}function Va(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,r=n.length,s=i.length,o=Math.min(r,s),a=new Array(r),c=0;c<o;++c)for(var h=n[c],l=i[c],u=h.length,f=a[c]=new Array(u),d,p=0;p<u;++p)(d=h[p]||l[p])&&(f[p]=d);for(;c<r;++c)a[c]=n[c];return new Z(a,this._parents)}function Wa(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],r=i.length-1,s=i[r],o;--r>=0;)(o=i[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function Ya(e){e||(e=Ga);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var n=this._groups,i=n.length,r=new Array(i),s=0;s<i;++s){for(var o=n[s],a=o.length,c=r[s]=new Array(a),h,l=0;l<a;++l)(h=o[l])&&(c[l]=h);c.sort(t)}return new Z(r,this._parents).order()}function Ga(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function qa(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ja(){return Array.from(this)}function Za(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length;r<s;++r){var o=i[r];if(o)return o}return null}function Ka(){let e=0;for(const t of this)++e;return e}function Qa(){return!this.node()}function Ja(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var r=t[n],s=0,o=r.length,a;s<o;++s)(a=r[s])&&e.call(a,a.__data__,s,r);return this}function tc(e){return function(){this.removeAttribute(e)}}function ec(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nc(e,t){return function(){this.setAttribute(e,t)}}function ic(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function rc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function sc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function oc(e,t){var n=Ie(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?ec:tc:typeof t=="function"?n.local?sc:rc:n.local?ic:nc)(n,t))}function pr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ac(e){return function(){this.style.removeProperty(e)}}function cc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function hc(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function lc(e,t,n){return arguments.length>1?this.each((t==null?ac:typeof t=="function"?hc:cc)(e,t,n??"")):Dt(this.node(),e)}function Dt(e,t){return e.style.getPropertyValue(t)||pr(e).getComputedStyle(e,null).getPropertyValue(t)}function uc(e){return function(){delete this[e]}}function fc(e,t){return function(){this[e]=t}}function dc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function pc(e,t){return arguments.length>1?this.each((t==null?uc:typeof t=="function"?dc:fc)(e,t)):this.node()[e]}function gr(e){return e.trim().split(/^|\s+/)}function Rn(e){return e.classList||new mr(e)}function mr(e){this._node=e,this._names=gr(e.getAttribute("class")||"")}mr.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function yr(e,t){for(var n=Rn(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function _r(e,t){for(var n=Rn(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function gc(e){return function(){yr(this,e)}}function mc(e){return function(){_r(this,e)}}function yc(e,t){return function(){(t.apply(this,arguments)?yr:_r)(this,e)}}function _c(e,t){var n=gr(e+"");if(arguments.length<2){for(var i=Rn(this.node()),r=-1,s=n.length;++r<s;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?yc:t?gc:mc)(n,t))}function xc(){this.textContent=""}function vc(e){return function(){this.textContent=e}}function wc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function bc(e){return arguments.length?this.each(e==null?xc:(typeof e=="function"?wc:vc)(e)):this.node().textContent}function Sc(){this.innerHTML=""}function Tc(e){return function(){this.innerHTML=e}}function Ac(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Mc(e){return arguments.length?this.each(e==null?Sc:(typeof e=="function"?Ac:Tc)(e)):this.node().innerHTML}function Pc(){this.nextSibling&&this.parentNode.appendChild(this)}function Cc(){return this.each(Pc)}function Lc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function kc(){return this.each(Lc)}function Ec(e){var t=typeof e=="function"?e:hr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Fc(){return null}function Rc(e,t){var n=typeof e=="function"?e:hr(e),i=t==null?Fc:typeof t=="function"?t:Fn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function Ic(){var e=this.parentNode;e&&e.removeChild(this)}function Oc(){return this.each(Ic)}function zc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Dc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Nc(e){return this.select(e?Dc:zc)}function $c(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Bc(e){return function(t){e.call(this,t,this.__data__)}}function Hc(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function Xc(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,r=t.length,s;n<r;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++i]=s;++i?t.length=i:delete this.__on}}}function Uc(e,t,n){return function(){var i=this.__on,r,s=Bc(t);if(i){for(var o=0,a=i.length;o<a;++o)if((r=i[o]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=t;return}}this.addEventListener(e.type,s,n),r={type:e.type,name:e.name,value:t,listener:s,options:n},i?i.push(r):this.__on=[r]}}function Vc(e,t,n){var i=Hc(e+""),r,s=i.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,h=a.length,l;c<h;++c)for(r=0,l=a[c];r<s;++r)if((o=i[r]).type===l.type&&o.name===l.name)return l.value}return}for(a=t?Uc:Xc,r=0;r<s;++r)this.each(a(i[r],t,n));return this}function xr(e,t,n){var i=pr(e),r=i.CustomEvent;typeof r=="function"?r=new r(t,n):(r=i.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Wc(e,t){return function(){return xr(this,e,t)}}function Yc(e,t){return function(){return xr(this,e,t.apply(this,arguments))}}function Gc(e,t){return this.each((typeof t=="function"?Yc:Wc)(e,t))}function*qc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length,o;r<s;++r)(o=i[r])&&(yield o)}var vr=[null];function Z(e,t){this._groups=e,this._parents=t}function Jt(){return new Z([[document.documentElement]],vr)}function jc(){return this}Z.prototype=Jt.prototype={constructor:Z,select:wa,selectAll:Aa,selectChild:La,selectChildren:Ra,filter:Ia,data:Ba,enter:Oa,exit:Xa,join:Ua,merge:Va,selection:jc,order:Wa,sort:Ya,call:qa,nodes:ja,node:Za,size:Ka,empty:Qa,each:Ja,attr:oc,style:lc,property:pc,classed:_c,text:bc,html:Mc,raise:Cc,lower:kc,append:Ec,insert:Rc,remove:Oc,clone:Nc,datum:$c,on:Vc,dispatch:Gc,[Symbol.iterator]:qc};function j(e){return typeof e=="string"?new Z([[document.querySelector(e)]],[document.documentElement]):new Z([[e]],vr)}function Zc(e){let t;for(;t=e.sourceEvent;)e=t;return e}function mt(e,t){if(e=Zc(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}var Kc={value:()=>{}};function In(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new fe(n)}function fe(e){this._=e}function Qc(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}fe.prototype=In.prototype={constructor:fe,on:function(e,t){var n=this._,i=Qc(e+"",n),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(e=i[s]).type)&&(r=Jc(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<o;)if(r=(e=i[s]).type)n[r]=Pi(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Pi(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new fe(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,s;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],i=0,r=s.length;i<r;++i)s[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,s=i.length;r<s;++r)i[r].value.apply(t,n)}};function Jc(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function Pi(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=Kc,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}const gn={capture:!0,passive:!1};function mn(e){e.preventDefault(),e.stopImmediatePropagation()}function th(e){var t=e.document.documentElement,n=j(e).on("dragstart.drag",mn,gn);"onselectstart"in t?n.on("selectstart.drag",mn,gn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function eh(e,t){var n=e.document.documentElement,i=j(e).on("dragstart.drag",null);t&&(i.on("click.drag",mn,gn),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var Nt=0,Yt=0,Ut=0,wr=1e3,Pe,Gt,Ce=0,Lt=0,Oe=0,Kt=typeof performance=="object"&&performance.now?performance:Date,br=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function On(){return Lt||(br(nh),Lt=Kt.now()+Oe)}function nh(){Lt=0}function Le(){this._call=this._time=this._next=null}Le.prototype=Sr.prototype={constructor:Le,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?On():+n)+(t==null?0:+t),!this._next&&Gt!==this&&(Gt?Gt._next=this:Pe=this,Gt=this),this._call=e,this._time=n,yn()},stop:function(){this._call&&(this._call=null,this._time=1/0,yn())}};function Sr(e,t,n){var i=new Le;return i.restart(e,t,n),i}function ih(){On(),++Nt;for(var e=Pe,t;e;)(t=Lt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Nt}function Ci(){Lt=(Ce=Kt.now())+Oe,Nt=Yt=0;try{ih()}finally{Nt=0,sh(),Lt=0}}function rh(){var e=Kt.now(),t=e-Ce;t>wr&&(Oe-=t,Ce=e)}function sh(){for(var e,t=Pe,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Pe=n);Gt=e,yn(i)}function yn(e){if(!Nt){Yt&&(Yt=clearTimeout(Yt));var t=e-Lt;t>24?(e<1/0&&(Yt=setTimeout(Ci,e-Kt.now()-Oe)),Ut&&(Ut=clearInterval(Ut))):(Ut||(Ce=Kt.now(),Ut=setInterval(rh,wr)),Nt=1,br(Ci))}}function Li(e,t,n){var i=new Le;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var oh=In("start","end","cancel","interrupt"),ah=[],Tr=0,ki=1,_n=2,de=3,Ei=4,xn=5,pe=6;function ze(e,t,n,i,r,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;ch(e,n,{name:t,index:i,group:r,on:oh,tween:ah,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Tr})}function zn(e,t){var n=st(e,t);if(n.state>Tr)throw new Error("too late; already scheduled");return n}function ht(e,t){var n=st(e,t);if(n.state>de)throw new Error("too late; already running");return n}function st(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function ch(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=Sr(s,0,n.time);function s(h){n.state=ki,n.timer.restart(o,n.delay,n.time),n.delay<=h&&o(h-n.delay)}function o(h){var l,u,f,d;if(n.state!==ki)return c();for(l in i)if(d=i[l],d.name===n.name){if(d.state===de)return Li(o);d.state===Ei?(d.state=pe,d.timer.stop(),d.on.call("interrupt",e,e.__data__,d.index,d.group),delete i[l]):+l<t&&(d.state=pe,d.timer.stop(),d.on.call("cancel",e,e.__data__,d.index,d.group),delete i[l])}if(Li(function(){n.state===de&&(n.state=Ei,n.timer.restart(a,n.delay,n.time),a(h))}),n.state=_n,n.on.call("start",e,e.__data__,n.index,n.group),n.state===_n){for(n.state=de,r=new Array(f=n.tween.length),l=0,u=-1;l<f;++l)(d=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=d);r.length=u+1}}function a(h){for(var l=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(c),n.state=xn,1),u=-1,f=r.length;++u<f;)r[u].call(e,l);n.state===xn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=pe,n.timer.stop(),delete i[t];for(var h in i)return;delete e.__transition}}function ge(e,t){var n=e.__transition,i,r,s=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((i=n[o]).name!==t){s=!1;continue}r=i.state>_n&&i.state<xn,i.state=pe,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[o]}s&&delete e.__transition}}function hh(e){return this.each(function(){ge(this,e)})}function lh(e,t){var n,i;return function(){var r=ht(this,e),s=r.tween;if(s!==n){i=n=s;for(var o=0,a=i.length;o<a;++o)if(i[o].name===t){i=i.slice(),i.splice(o,1);break}}r.tween=i}}function uh(e,t,n){var i,r;if(typeof n!="function")throw new Error;return function(){var s=ht(this,e),o=s.tween;if(o!==i){r=(i=o).slice();for(var a={name:t,value:n},c=0,h=r.length;c<h;++c)if(r[c].name===t){r[c]=a;break}c===h&&r.push(a)}s.tween=r}}function fh(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=st(this.node(),n).tween,r=0,s=i.length,o;r<s;++r)if((o=i[r]).name===e)return o.value;return null}return this.each((t==null?lh:uh)(n,e,t))}function Dn(e,t,n){var i=e._id;return e.each(function(){var r=ht(this,i);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return st(r,i).value[t]}}function Ar(e,t){var n;return(typeof t=="number"?it:t instanceof pt?Zt:(n=pt(t))?(t=n,Zt):Zi)(e,t)}function dh(e){return function(){this.removeAttribute(e)}}function ph(e){return function(){this.removeAttributeNS(e.space,e.local)}}function gh(e,t,n){var i,r=n+"",s;return function(){var o=this.getAttribute(e);return o===r?null:o===i?s:s=t(i=o,n)}}function mh(e,t,n){var i,r=n+"",s;return function(){var o=this.getAttributeNS(e.space,e.local);return o===r?null:o===i?s:s=t(i=o,n)}}function yh(e,t,n){var i,r,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=a+"",o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a)))}}function _h(e,t,n){var i,r,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=a+"",o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a)))}}function xh(e,t){var n=Ie(e),i=n==="transform"?xo:Ar;return this.attrTween(e,typeof t=="function"?(n.local?_h:yh)(n,i,Dn(this,"attr."+e,t)):t==null?(n.local?ph:dh)(n):(n.local?mh:gh)(n,i,t))}function vh(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function wh(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function bh(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&wh(e,s)),n}return r._value=t,r}function Sh(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&vh(e,s)),n}return r._value=t,r}function Th(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=Ie(e);return this.tween(n,(i.local?bh:Sh)(i,t))}function Ah(e,t){return function(){zn(this,e).delay=+t.apply(this,arguments)}}function Mh(e,t){return t=+t,function(){zn(this,e).delay=t}}function Ph(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ah:Mh)(t,e)):st(this.node(),t).delay}function Ch(e,t){return function(){ht(this,e).duration=+t.apply(this,arguments)}}function Lh(e,t){return t=+t,function(){ht(this,e).duration=t}}function kh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ch:Lh)(t,e)):st(this.node(),t).duration}function Eh(e,t){if(typeof t!="function")throw new Error;return function(){ht(this,e).ease=t}}function Fh(e){var t=this._id;return arguments.length?this.each(Eh(t,e)):st(this.node(),t).ease}function Rh(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ht(this,e).ease=n}}function Ih(e){if(typeof e!="function")throw new Error;return this.each(Rh(this._id,e))}function Oh(e){typeof e!="function"&&(e=ur(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=[],c,h=0;h<o;++h)(c=s[h])&&e.call(c,c.__data__,h,s)&&a.push(c);return new gt(i,this._parents,this._name,this._id)}function zh(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,r=n.length,s=Math.min(i,r),o=new Array(i),a=0;a<s;++a)for(var c=t[a],h=n[a],l=c.length,u=o[a]=new Array(l),f,d=0;d<l;++d)(f=c[d]||h[d])&&(u[d]=f);for(;a<i;++a)o[a]=t[a];return new gt(o,this._parents,this._name,this._id)}function Dh(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Nh(e,t,n){var i,r,s=Dh(t)?zn:ht;return function(){var o=s(this,e),a=o.on;a!==i&&(r=(i=a).copy()).on(t,n),o.on=r}}function $h(e,t){var n=this._id;return arguments.length<2?st(this.node(),n).on.on(e):this.each(Nh(n,e,t))}function Bh(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Hh(){return this.on("end.remove",Bh(this._id))}function Xh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Fn(e));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o<r;++o)for(var a=i[o],c=a.length,h=s[o]=new Array(c),l,u,f=0;f<c;++f)(l=a[f])&&(u=e.call(l,l.__data__,f,a))&&("__data__"in l&&(u.__data__=l.__data__),h[f]=u,ze(h[f],t,n,f,h,st(l,n)));return new gt(s,this._parents,t,n)}function Uh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=lr(e));for(var i=this._groups,r=i.length,s=[],o=[],a=0;a<r;++a)for(var c=i[a],h=c.length,l,u=0;u<h;++u)if(l=c[u]){for(var f=e.call(l,l.__data__,u,c),d,p=st(l,n),g=0,m=f.length;g<m;++g)(d=f[g])&&ze(d,t,n,g,f,p);s.push(f),o.push(l)}return new gt(s,o,t,n)}var Vh=Jt.prototype.constructor;function Wh(){return new Vh(this._groups,this._parents)}function Yh(e,t){var n,i,r;return function(){var s=Dt(this,e),o=(this.style.removeProperty(e),Dt(this,e));return s===o?null:s===n&&o===i?r:r=t(n=s,i=o)}}function Mr(e){return function(){this.style.removeProperty(e)}}function Gh(e,t,n){var i,r=n+"",s;return function(){var o=Dt(this,e);return o===r?null:o===i?s:s=t(i=o,n)}}function qh(e,t,n){var i,r,s;return function(){var o=Dt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),Dt(this,e))),o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a))}}function jh(e,t){var n,i,r,s="style."+t,o="end."+s,a;return function(){var c=ht(this,e),h=c.on,l=c.value[s]==null?a||(a=Mr(t)):void 0;(h!==n||r!==l)&&(i=(n=h).copy()).on(o,r=l),c.on=i}}function Zh(e,t,n){var i=(e+="")=="transform"?_o:Ar;return t==null?this.styleTween(e,Yh(e,i)).on("end.style."+e,Mr(e)):typeof t=="function"?this.styleTween(e,qh(e,i,Dn(this,"style."+e,t))).each(jh(this._id,e)):this.styleTween(e,Gh(e,i,t),n).on("end.style."+e,null)}function Kh(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function Qh(e,t,n){var i,r;function s(){var o=t.apply(this,arguments);return o!==r&&(i=(r=o)&&Kh(e,o,n)),i}return s._value=t,s}function Jh(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,Qh(e,t,n??""))}function tl(e){return function(){this.textContent=e}}function el(e){return function(){var t=e(this);this.textContent=t??""}}function nl(e){return this.tween("text",typeof e=="function"?el(Dn(this,"text",e)):tl(e==null?"":e+""))}function il(e){return function(t){this.textContent=e.call(this,t)}}function rl(e){var t,n;function i(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&il(r)),t}return i._value=e,i}function sl(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,rl(e))}function ol(){for(var e=this._name,t=this._id,n=Pr(),i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,c,h=0;h<a;++h)if(c=o[h]){var l=st(c,t);ze(c,e,n,h,o,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new gt(i,this._parents,e,n)}function al(){var e,t,n=this,i=n._id,r=n.size();return new Promise(function(s,o){var a={value:o},c={value:function(){--r===0&&s()}};n.each(function(){var h=ht(this,i),l=h.on;l!==e&&(t=(e=l).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),h.on=t}),r===0&&s()})}var cl=0;function gt(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function Pr(){return++cl}var lt=Jt.prototype;gt.prototype={constructor:gt,select:Xh,selectAll:Uh,selectChild:lt.selectChild,selectChildren:lt.selectChildren,filter:Oh,merge:zh,selection:Wh,transition:ol,call:lt.call,nodes:lt.nodes,node:lt.node,size:lt.size,empty:lt.empty,each:lt.each,on:$h,attr:xh,attrTween:Th,style:Zh,styleTween:Jh,text:nl,textTween:sl,remove:Hh,tween:fh,delay:Ph,duration:kh,ease:Fh,easeVarying:Ih,end:al,[Symbol.iterator]:lt[Symbol.iterator]};function hl(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ll={time:null,delay:0,duration:250,ease:hl};function ul(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function fl(e){var t,n;e instanceof gt?(t=e._id,e=e._name):(t=Pr(),(n=ll).time=On(),e=e==null?null:e+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,c,h=0;h<a;++h)(c=o[h])&&ze(c,e,t,h,o,n||ul(c,t));return new gt(i,this._parents,e,t)}Jt.prototype.interrupt=hh;Jt.prototype.transition=fl;const ce=e=>()=>e;function dl(e,{sourceEvent:t,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function dt(e,t,n){this.k=e,this.x=t,this.y=n}dt.prototype={constructor:dt,scale:function(e){return e===1?this:new dt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new dt(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Nn=new dt(1,0,0);dt.prototype;function Qe(e){e.stopImmediatePropagation()}function Vt(e){e.preventDefault(),e.stopImmediatePropagation()}function pl(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function gl(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Fi(){return this.__zoom||Nn}function ml(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function yl(){return navigator.maxTouchPoints||"ontouchstart"in this}function _l(e,t,n){var i=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function xl(){var e=pl,t=gl,n=_l,i=ml,r=yl,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,c=So,h=In("start","zoom","end"),l,u,f,d=500,p=150,g=0,m=10;function _(y){y.property("__zoom",Fi).on("wheel.zoom",C,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",L).on("touchmove.zoom",z).on("touchend.zoom touchcancel.zoom",$).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(y,T,w,P){var F=y.selection?y.selection():y;F.property("__zoom",Fi),y!==F?S(y,T,w,P):F.interrupt().each(function(){M(this,arguments).event(P).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},_.scaleBy=function(y,T,w,P){_.scaleTo(y,function(){var F=this.__zoom.k,R=typeof T=="function"?T.apply(this,arguments):T;return F*R},w,P)},_.scaleTo=function(y,T,w,P){_.transform(y,function(){var F=t.apply(this,arguments),R=this.__zoom,I=w==null?A(F):typeof w=="function"?w.apply(this,arguments):w,D=R.invert(I),B=typeof T=="function"?T.apply(this,arguments):T;return n(v(x(R,B),I,D),F,o)},w,P)},_.translateBy=function(y,T,w,P){_.transform(y,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof w=="function"?w.apply(this,arguments):w),t.apply(this,arguments),o)},null,P)},_.translateTo=function(y,T,w,P,F){_.transform(y,function(){var R=t.apply(this,arguments),I=this.__zoom,D=P==null?A(R):typeof P=="function"?P.apply(this,arguments):P;return n(Nn.translate(D[0],D[1]).scale(I.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof w=="function"?-w.apply(this,arguments):-w),R,o)},P,F)};function x(y,T){return T=Math.max(s[0],Math.min(s[1],T)),T===y.k?y:new dt(T,y.x,y.y)}function v(y,T,w){var P=T[0]-w[0]*y.k,F=T[1]-w[1]*y.k;return P===y.x&&F===y.y?y:new dt(y.k,P,F)}function A(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function S(y,T,w,P){y.on("start.zoom",function(){M(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){M(this,arguments).event(P).end()}).tween("zoom",function(){var F=this,R=arguments,I=M(F,R).event(P),D=t.apply(F,R),B=w==null?A(D):typeof w=="function"?w.apply(F,R):w,U=Math.max(D[1][0]-D[0][0],D[1][1]-D[0][1]),H=F.__zoom,G=typeof T=="function"?T.apply(F,R):T,J=c(H.invert(B).concat(U/H.k),G.invert(B).concat(U/G.k));return function(V){if(V===1)V=G;else{var tt=J(V),$t=U/tt[2];V=new dt($t,B[0]-tt[0]*$t,B[1]-tt[1]*$t)}I.zoom(null,V)}})}function M(y,T,w){return!w&&y.__zooming||new b(y,T)}function b(y,T){this.that=y,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,T),this.taps=0}b.prototype={event:function(y){return y&&(this.sourceEvent=y),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(y,T){return this.mouse&&y!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var T=j(this.that).datum();h.call(y,this.that,new dl(y,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:h}),T)}};function C(y,...T){if(!e.apply(this,arguments))return;var w=M(this,T).event(y),P=this.__zoom,F=Math.max(s[0],Math.min(s[1],P.k*Math.pow(2,i.apply(this,arguments)))),R=mt(y);if(w.wheel)(w.mouse[0][0]!==R[0]||w.mouse[0][1]!==R[1])&&(w.mouse[1]=P.invert(w.mouse[0]=R)),clearTimeout(w.wheel);else{if(P.k===F)return;w.mouse=[R,P.invert(R)],ge(this),w.start()}Vt(y),w.wheel=setTimeout(I,p),w.zoom("mouse",n(v(x(P,F),w.mouse[0],w.mouse[1]),w.extent,o));function I(){w.wheel=null,w.end()}}function k(y,...T){if(f||!e.apply(this,arguments))return;var w=y.currentTarget,P=M(this,T,!0).event(y),F=j(y.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",U,!0),R=mt(y,w),I=y.clientX,D=y.clientY;th(y.view),Qe(y),P.mouse=[R,this.__zoom.invert(R)],ge(this),P.start();function B(H){if(Vt(H),!P.moved){var G=H.clientX-I,J=H.clientY-D;P.moved=G*G+J*J>g}P.event(H).zoom("mouse",n(v(P.that.__zoom,P.mouse[0]=mt(H,w),P.mouse[1]),P.extent,o))}function U(H){F.on("mousemove.zoom mouseup.zoom",null),eh(H.view,P.moved),Vt(H),P.event(H).end()}}function O(y,...T){if(e.apply(this,arguments)){var w=this.__zoom,P=mt(y.changedTouches?y.changedTouches[0]:y,this),F=w.invert(P),R=w.k*(y.shiftKey?.5:2),I=n(v(x(w,R),P,F),t.apply(this,T),o);Vt(y),a>0?j(this).transition().duration(a).call(S,I,P,y):j(this).call(_.transform,I,P,y)}}function L(y,...T){if(e.apply(this,arguments)){var w=y.touches,P=w.length,F=M(this,T,y.changedTouches.length===P).event(y),R,I,D,B;for(Qe(y),I=0;I<P;++I)D=w[I],B=mt(D,this),B=[B,this.__zoom.invert(B),D.identifier],F.touch0?!F.touch1&&F.touch0[2]!==B[2]&&(F.touch1=B,F.taps=0):(F.touch0=B,R=!0,F.taps=1+!!l);l&&(l=clearTimeout(l)),R&&(F.taps<2&&(u=B[0],l=setTimeout(function(){l=null},d)),ge(this),F.start())}}function z(y,...T){if(this.__zooming){var w=M(this,T).event(y),P=y.changedTouches,F=P.length,R,I,D,B;for(Vt(y),R=0;R<F;++R)I=P[R],D=mt(I,this),w.touch0&&w.touch0[2]===I.identifier?w.touch0[0]=D:w.touch1&&w.touch1[2]===I.identifier&&(w.touch1[0]=D);if(I=w.that.__zoom,w.touch1){var U=w.touch0[0],H=w.touch0[1],G=w.touch1[0],J=w.touch1[1],V=(V=G[0]-U[0])*V+(V=G[1]-U[1])*V,tt=(tt=J[0]-H[0])*tt+(tt=J[1]-H[1])*tt;I=x(I,Math.sqrt(V/tt)),D=[(U[0]+G[0])/2,(U[1]+G[1])/2],B=[(H[0]+J[0])/2,(H[1]+J[1])/2]}else if(w.touch0)D=w.touch0[0],B=w.touch0[1];else return;w.zoom("touch",n(v(I,D,B),w.extent,o))}}function $(y,...T){if(this.__zooming){var w=M(this,T).event(y),P=y.changedTouches,F=P.length,R,I;for(Qe(y),f&&clearTimeout(f),f=setTimeout(function(){f=null},d),R=0;R<F;++R)I=P[R],w.touch0&&w.touch0[2]===I.identifier?delete w.touch0:w.touch1&&w.touch1[2]===I.identifier&&delete w.touch1;if(w.touch1&&!w.touch0&&(w.touch0=w.touch1,delete w.touch1),w.touch0)w.touch0[1]=this.__zoom.invert(w.touch0[0]);else if(w.end(),w.taps===2&&(I=mt(I,this),Math.hypot(u[0]-I[0],u[1]-I[1])<m)){var D=j(this).on("dblclick.zoom");D&&D.apply(this,arguments)}}}return _.wheelDelta=function(y){return arguments.length?(i=typeof y=="function"?y:ce(+y),_):i},_.filter=function(y){return arguments.length?(e=typeof y=="function"?y:ce(!!y),_):e},_.touchable=function(y){return arguments.length?(r=typeof y=="function"?y:ce(!!y),_):r},_.extent=function(y){return arguments.length?(t=typeof y=="function"?y:ce([[+y[0][0],+y[0][1]],[+y[1][0],+y[1][1]]]),_):t},_.scaleExtent=function(y){return arguments.length?(s[0]=+y[0],s[1]=+y[1],_):[s[0],s[1]]},_.translateExtent=function(y){return arguments.length?(o[0][0]=+y[0][0],o[1][0]=+y[1][0],o[0][1]=+y[0][1],o[1][1]=+y[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(y){return arguments.length?(n=y,_):n},_.duration=function(y){return arguments.length?(a=+y,_):a},_.interpolate=function(y){return arguments.length?(c=y,_):c},_.on=function(){var y=h.on.apply(h,arguments);return y===h?_:y},_.clickDistance=function(y){return arguments.length?(g=(y=+y)*y,_):Math.sqrt(g)},_.tapDistance=function(y){return arguments.length?(m=+y,_):m},_}const vl=.1,wl=256;class Cr{constructor(t,n,i={maxZoomLevel:wl,minZoomLevel:vl}){this.xBounds=[0,1],this.yBounds=[0,1],this.translateBoundsX=[0,1],this.translateBoundsY=[0,1],this._zFactor=1,this._enableTranslateExtent=!1,this.container=j(t),this.options=i,this.onRescale=n,this.onZoom=this.onZoom.bind(this),this.calculateTransform=this.calculateTransform.bind(this),this.applyTransform=this.applyTransform.bind(this),this.recalculateZoomTransform=this.recalculateZoomTransform.bind(this),this.rescale=this.rescale.bind(this),this.adjustToSize=this.adjustToSize.bind(this),this.setViewport=this.setViewport.bind(this),this.currentStateAsEvent=this.currentStateAsEvent.bind(this),this.updateTranslateExtent=this.updateTranslateExtent.bind(this),this.scaleX=Ct().domain(this.xBounds).range([0,1]),this.scaleY=Ct().domain(this.yBounds).range([0,1]),this.init()}get width(){return this.scaleX.range()[1]??0}get height(){return this.scaleY.range()[1]??0}get xSpan(){const{xBounds:t}=this;return Math.abs(t[1]-t[0])}get ySpan(){const{yBounds:t}=this;return Math.abs(t[1]-t[0])}get viewportRatio(){return this.width/(this.height||1)}get xRatio(){const t=this.scaleX.domain();return Math.abs(this.width/(t[1]-t[0]))}get yRatio(){const t=this.scaleY.domain();return Math.abs(this.height/(t[1]-t[0]))}get zFactor(){return this._zFactor}set zFactor(t){this._zFactor=t,this.recalculateZoomTransform()}get isXInverted(){return this.xBounds[1]<this.xBounds[0]}get isYInverted(){return this.yBounds[1]<this.yBounds[0]}get enableTranslateExtent(){return this._enableTranslateExtent}set enableTranslateExtent(t){this._enableTranslateExtent=t,this.updateTranslateExtent()}updateTranslateExtent(){const{width:t,xSpan:n,zFactor:i,enableTranslateExtent:r,translateBoundsX:s,translateBoundsY:o}=this;let a=-1/0,c=-1/0,h=1/0,l=1/0;if(r){const u=t/n;a=s[0]*u,h=s[1]*u,c=o[0]*u*i,l=o[1]*u*i}this.zoom.translateExtent([[a,c],[h,l]])}currentStateAsEvent(){const{scaleX:t,scaleY:n,xBounds:i,yBounds:r,zFactor:s,viewportRatio:o,currentTransform:a,xRatio:c,yRatio:h,width:l,height:u}=this;return{xScale:t.copy(),yScale:n.copy(),xBounds:i,yBounds:r,zFactor:s,viewportRatio:o,xRatio:c,yRatio:h,width:l,height:u,transform:Object.assign({},a)}}rescale(){const{currentStateAsEvent:t}=this;this.onRescale(t())}init(){this.zoom=xl().scaleExtent([this.options.minZoomLevel,this.options.maxZoomLevel]).on("zoom",this.onZoom),this.container.call(this.zoom)}onZoom(t){const{transform:n}=t;n&&(this.applyTransform(n),this.rescale())}applyTransform(t){const{width:n,scaleX:i,scaleY:r,xSpan:s,xBounds:o,yBounds:a,zFactor:c}=this,{viewportRatio:h,isXInverted:l,isYInverted:u}=this,f=n*t.k,d=s/f,p=s/t.k,g=p/c/h,m=d*t.x,_=d/c*t.y,x=o[0]-(l?-m:m),v=a[0]-(u?-_:_);i.domain([x,x+(l?-p:p)]),r.domain([v,v+(u?-g:g)]),this.currentTransform=t}setViewport(t,n,i,r){const{zoom:s,container:o,calculateTransform:a,scaleX:c,scaleY:h,isXInverted:l}=this;if(t==null||i==null||isNaN(t)||isNaN(i)){const g=c.domain(),m=g[1]-g[0];(t==null||isNaN(t))&&(t=g[0]+m/2||0),(i==null||isNaN(i))&&(i=Math.abs(m)||1)}if(n==null||isNaN(n)){const g=h.domain();n=g[0]+(g[1]-g[0])/2||0}const u=l?-i:i,f=t-u/2,d=f+u,p=a(f,d,n);r!=null&&Number.isFinite(r)&&r>0?s.transform(o.transition().duration(r),p):s.transform(o,p)}setBounds(t,n){this.xBounds=t,this.yBounds=n,this.recalculateZoomTransform()}setTranslateBounds(t,n){this.translateBoundsX=t,this.translateBoundsY=n,this.updateTranslateExtent()}adjustToSize(t,n,i=!1){const{width:r,height:s,scaleX:o,scaleY:a,recalculateZoomTransform:c}=this;let h=0,l=0;if(typeof t=="number"&&typeof n=="number")l=n,h=t;else{const d=this.container.node();if(d){const{width:p,height:g}=d.getBoundingClientRect();h=p,l=g}}const u=Math.max(1,h),f=Math.max(1,l);!i&&r===u&&s===f||(o.range([0,u]),a.range([0,f]),c(),this.onRescale(this.currentStateAsEvent()))}calculateTransform(t,n,i){const{scaleX:r,xSpan:s,xBounds:o,yBounds:a,zFactor:c,viewportRatio:h,isXInverted:l,isYInverted:u}=this,[f,d]=r.range(),p=Math.abs(n-t),g=s/p,m=p/(d-f),_=i-(u?-p:p)/c/h/2,x=(o[0]-t)/(l?-m:m),v=(a[0]-_)/((u?-m:m)/c);return Nn.translate(x,v).scale(g)}recalculateZoomTransform(){const{scaleX:t,scaleY:n,container:i,calculateTransform:r,updateTranslateExtent:s}=this,[o,a]=t.domain(),[c,h]=n.domain(),l=c+(h-c)/2,u=r(o,a,l);s(),this.zoom.transform(i,u)}setZoomLevelBoundary(t){return this.zoom.scaleExtent(t),this}setMaxZoomLevel(t){const n=this.zoom.scaleExtent();return this.zoom.scaleExtent([n[0],t]),this}setMinZoomLevel(t){const n=this.zoom.scaleExtent();return this.zoom.scaleExtent([t,n[1]]),this}}const bl={order:1,layerOpacity:1,interactive:!1};class te{constructor(t,n){this._interactive=!1,this._id=t||`layer-${Math.floor(Math.random()*1e3)}`;const i=n||bl;this._order=i.order||1,this._options={...i},this.loading=!1,this._element=void 0,this._opacity=i.layerOpacity||1,this._visible=!0,this._interactive=i.interactive||!1,n&&n.data&&this.setData(n.data),this._referenceSystem=n?.referenceSystem,this.onMount=this.onMount.bind(this),this.onUnmount=this.onUnmount.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onRescale=this.onRescale.bind(this),this.onResize=this.onResize.bind(this),this.onOrderChanged=this.onOrderChanged.bind(this),this.onOpacityChanged=this.onOpacityChanged.bind(this),this.setVisibility=this.setVisibility.bind(this)}get id(){return this._id}get element(){return this._element}get options(){return this._options}set options(t){this._options=t}set isLoading(t){this.loading=t}get isLoading(){return this.loading}set opacity(t){this._opacity=t,this.onOpacityChanged(t)}get opacity(){return this._opacity}set order(t){this._order=t,this.onOrderChanged(t)}get order(){return this._order}set interactive(t){this._interactive=t,this.onInteractivityChanged(t)}get interactive(){return this._interactive}get referenceSystem(){return this._referenceSystem}set referenceSystem(t){this._referenceSystem=t}get data(){return this.getData()}set data(t){this.setData(t)}get isVisible(){return this._visible}getData(){return this._data}setData(t){this._data=t,this.element&&t!=null&&this.onUpdate({data:t})}clearData(t=!0){this._data=void 0,t&&(this.referenceSystem=void 0),this.onUpdate({})}setVisibility(t,n){this._visible=t}onMount(t){this._element=t.elm,this._options.onMount&&this._options.onMount(t,this)}onUnmount(t){this._options.onUnmount&&t!=null&&this._options.onUnmount(t,this)}onResize(t){this._options.onResize&&this._options.onResize(t,this)}onUpdate(t){t.data&&(this._data=t.data),this._options.onUpdate&&this._options.onUpdate(t,this)}onRescale(t){this.optionsRescale(t)}optionsRescale(t){this._options.onRescale&&this._options.onRescale(t,this)}getInternalLayerIds(){return[]}}const De=200,Ne=300,Lr=40,kr=30,Sl=100,Tl=.6,Al=.3,Ml=8,Pl=16,xt=64,Er=1;class bt extends te{onOpacityChanged(t){this.canvas&&this.updateStyle()}onOrderChanged(t){this.canvas&&this.updateStyle()}onInteractivityChanged(t){this.canvas&&this.updateStyle()}setVisibility(t){super.setVisibility(t),this.canvas&&this.updateStyle(t)}updateStyle(t){const i=t||this.isVisible?"visible":"hidden",r=this.interactive?"auto":"none";this.canvas?.setAttribute("style",`position:absolute;pointer-events:${r};z-index:${this.order};opacity:${this.opacity};visibility:${i}`)}onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n?.getAttribute("width")??"",10)||De,r=t.height||parseInt(n?.getAttribute("height")??"",10)||Ne;this.elm=n;let s;this.canvas||(s=document.createElement("canvas"),this.canvas=s,t.elm.appendChild(s)),this.canvas.setAttribute("id",`${this.id}`),this.canvas.setAttribute("width",`${i}px`),this.canvas.setAttribute("height",`${r}px`),this.canvas.setAttribute("class","canvas-layer"),this.updateStyle(),this.ctx=this.canvas.getContext("2d")??void 0}onUnmount(){super.onUnmount(),this.canvas?.remove(),this.canvas=void 0}onResize(t){const{ctx:n}=this,{width:i,height:r}=t;n?.canvas.setAttribute("width",`${i}px`),n?.canvas.setAttribute("height",`${r}px`)}onUpdate(t){super.onUpdate(t)}resetTransform(){this.ctx?.resetTransform()}setTransform(t){this.resetTransform();const n=t.xBounds[0]>t.xBounds[1],i=t.yBounds[0]>t.yBounds[1];this.ctx?.translate(t.xScale(0),t.yScale(0)),this.ctx?.scale(t.xRatio*(n?-1:1),t.yRatio*(i?-1:1))}clearCanvas(){const{ctx:t,canvas:n}=this;t?.save(),t?.resetTransform(),t?.clearRect(0,0,n?.width??0,n?.height??0),t?.restore()}}class Cl extends te{onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n?.getAttribute("width")??"",10)||De,r=t.height||parseInt(n?.getAttribute("height")??"",10)||Ne;this.elm||(this.elm=j(n).append("div"),this.elm.attr("id",`${this.id}`),this.elm.attr("class","html-layer"));const s=this.interactive?"auto":"none";this.elm.style("position","absolute").style("height",`${r}px`).style("width",`${i}px`).style("opacity",this.opacity).style("overflow","hidden").style("pointer-events",s).style("z-index",this.order)}onUnmount(){super.onUnmount(),this.elm?.remove(),this.elm=void 0}onResize(t){this.elm&&(super.onResize(t),this.elm.style("height",`${t.height}px`).style("width",`${t.width}px`))}setVisibility(t){super.setVisibility(t),this.elm&&this.elm.attr("visibility",t?"visible":"hidden")}onOpacityChanged(t){this.elm&&this.elm.style("opacity",t)}onOrderChanged(t){this.elm&&this.elm.style("z-index",t)}onInteractivityChanged(t){if(this.elm){const n=t?"auto":"none";this.elm.style("pointer-events",n)}}}class Fr extends te{onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n.getAttribute("width")??"",10)||De,r=t.height||parseInt(n.getAttribute("height")??"",10)||Ne;this.elm||(this.elm=j(n).append("svg"),this.elm.attr("id",`${this.id}`),this.elm.attr("class","svg-layer")),this.elm.attr("height",r).attr("width",i);const s=this.interactive?"auto":"none";this.elm.style("position","absolute").style("pointer-events",s).style("opacity",this.opacity).style("z-index",this.order)}onUnmount(){super.onUnmount(),this.elm?.remove(),this.elm=void 0}onResize(t){this.elm&&(super.onResize(t),this.elm.attr("height",t.height).attr("width",t.width))}setVisibility(t){super.setVisibility(t),this.elm&&this.elm.attr("visibility",t?"visible":"hidden")}onOpacityChanged(t){this.elm&&this.elm.style("opacity",t)}onOrderChanged(t){this.elm&&this.elm.style("z-index",t)}onInteractivityChanged(t){if(this.elm){const n=t?"auto":"none";this.elm.style("pointer-events",n)}}}class Ll{async init(t){const n={width:De,height:Ne,antialias:!0,backgroundAlpha:0,clearBeforeRender:!0,preserveDrawingBuffer:!0,...t};this.renderer=await E.autoDetectRenderer(n),this.stage=new E.Container}get canvas(){return this.renderer?.canvas}render(){this.stage!=null&&this.renderer?.render(this.stage)}}class $n extends te{constructor(t,n,i){super(n,i),this.ctx=t,this.container=new E.Container,this.ctx.stage?.addChild(this.container)}render(){this.ctx.render()}addChild(t){this.container.addChild(t)}clearLayer(){this.container.removeChildren().forEach(n=>{n.destroy()})}onMount(t){super.onMount(t),this.pixiViewContainer=this.element?.querySelector("#webgl-layer")??void 0,this.pixiViewContainer||(this.pixiViewContainer=document.createElement("div"),this.pixiViewContainer.setAttribute("id",`${this.id}`),this.pixiViewContainer.setAttribute("class","webgl-layer"),this.ctx.canvas!=null&&this.pixiViewContainer.appendChild(this.ctx.canvas),this.element?.appendChild(this.pixiViewContainer),this.updateStyle())}onUnmount(t){super.onUnmount(t),this.clearLayer(),this.ctx.stage?.removeChild(this.container),this.container.destroy(),this.pixiViewContainer?.remove(),this.pixiViewContainer=void 0}onResize(t){super.onResize(t),this.ctx.renderer?.resize(t.width,t.height)}onRescale(t){super.onRescale(t);const n=t.xBounds[0]>t.xBounds[1],i=t.yBounds[0]>t.yBounds[1];this.setContainerPosition(t.xScale(0),t.yScale(0)),this.setContainerScale(t.xRatio*(n?-1:1),t.yRatio*(i?-1:1))}setContainerPosition(t,n){this.container.position.set(t,n)}setContainerScale(t,n){this.container.scale.set(t,n)}updateStyle(t){const n=t||this.isVisible,i=this.interactive?"auto":"none";this.container.visible=n;const r=[["position","absolute"],["pointer-events",`${i}`],["z-index",`${this.order}`],["opacity",`${this.opacity}`]].map(s=>s.join(":")).join(";");this.pixiViewContainer?.setAttribute("style",r)}setVisibility(t,n){super.setVisibility(t,n),this.pixiViewContainer&&this.updateStyle(t)}onOpacityChanged(t){this.pixiViewContainer&&this.updateStyle()}onOrderChanged(t){this.pixiViewContainer&&this.updateStyle()}onInteractivityChanged(t){this.pixiViewContainer&&this.updateStyle()}renderType(){return this.ctx.renderer?.type}}function ee(e){throw new Error(`Unexpected object: ${JSON.stringify(e)}`)}const Rr=e=>e.kind==="pAndASymbol",Ir=e=>e.kind==="cementSqueeze",Or=e=>e.kind==="cementPlug",zr=(e,t,n)=>i=>{switch(i.kind){case"screen":return e(i);case"tubing":return t(i);case"completionSymbol":return n(i);default:return ee(i)}},K=(e,t)=>{switch(t){case"Perforation":return e.Perforation(t);case"Open hole gravel pack":return e.OpenHoleGravelPack(t);case"Open hole frac pack":return e.OpenHoleFracPack(t);case"Cased hole fracturation":return e.CasedHoleFracturation(t);case"Cased hole frac pack":return e.CasedHoleFracPack(t);case"Cased hole gravel pack":return e.CasedHoleGravelPack(t);default:return ee(t)}},kl=e=>K({Perforation:()=>!0,OpenHoleGravelPack:()=>!0,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind),El=e=>K({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!0,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!0},e.subKind),Dr=e=>K({Perforation:()=>!1,OpenHoleGravelPack:()=>!0,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!0},e.subKind);function Nr(e){return K({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!0,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!0},e.subKind)}function $r(e){return K({Perforation:()=>!0,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}function Br(e){return K({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!1},e.subKind)}function Fl(e){return K({Perforation:()=>!0,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}function Hr(e){return K({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!0},e.subKind)}function Rl(e){return K({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}const Xr=e=>e.subKind==="Cased hole fracturation",Ur=(e,t)=>e.start<t.end&&e.end>t.start,Vr=e=>({holeLayerId:`${e}-hole`,casingLayerId:`${e}-casing`,completionLayerId:`${e}-completion`,cementLayerId:`${e}-cement`,pAndALayerId:`${e}-pAndA`,perforationLayerId:`${e}-perforation`}),Wr={firstColor:"#8c541d",secondColor:"#eee3d8",lineColor:"#8b4513"},Yr={solidColor:"#dcdcdc",lineColor:"#575757",shoeSize:{width:Ml,length:Pl},windowOptions:{dashColor:"#dc0000",dashLength:5,spaceLength:3}},Gr={stroke:"rgba(0, 0, 0, 0.25)",yellow:"#FFFC00",grey:"gray",red:"#FF5050",outline:"black",transparent:"rgba(255, 255, 255, 0)",spikeWidth:50,spikeLength:50,packingOpacity:.7,fracLineCurve:10,fracLineLength:25,scalingFactor:25},qr={firstColor:"#c7b9ab",secondColor:"#5b5b5b",scalingFactor:4},jr={firstColor:"#8b6713",secondColor:"#000000",scalingFactor:4},Zr={scalingFactor:4,lineColor:"#63666a"},Kr={scalingFactor:1,innerColor:"#eeeeff",outerColor:"#777788"},Qr={firstColor:"#c7b9ab",secondColor:"#000000",scalingFactor:4},Jr=4,ts=2;function es(e){const[t]=e.domain();return Math.abs(e(t+1))}function ke(e,t,n,i){return _t(es(i)*e,t,n)}function Il(e,t){const n=e.x+e.width,i=t.x+t.width;return!(t.x>n||i<e.x)}function ns(e,t,n=Jr,i=ts){const r=e.x+e.width+n,s=t.x+t.width+n,o=e.y+e.height+i,a=t.y+t.height+i;return!(t.x-n>r||t.y-i>o||s+n<e.x||a+i<e.y)}function Ol(e,t){const n=e.x+e.width,i=t.x+t.width,r=e.y+e.height,s=t.y+t.height;if(t.x>n||t.y>r||i<e.x||s<e.y)return;const o=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),a=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return{dx:o,dy:a}}function vn(e,t,n=Jr,i=ts){const r=e.x+e.width,s=t.x+t.width,o=e.y+e.height,a=t.y+t.height;if(t.x-n>r||t.y-i>o||s+n<e.x||a+i<e.y)return;const c=e.x+e.width-t.x+n,h=e.y+e.height-t.y+i;return{dx:c,dy:h}}const zl=7,Dl=11,Nl=7,$l=20,Bl=120,Hl=19,Xl="rgba(0, 0, 0, 0.5)",Ul=5,Vl=5;function Wl(e,t){return e??t}const nt={topleft:"topleft",topright:"topright",bottomleft:"bottomleft",bottomright:"bottomright"};class Yl extends bt{constructor(t,n){super(t,n),this.callouts=[],this.groupFilter=[],this.renderAnnotation=(i,r,s,o,a,c)=>{this.renderText(i,s,o-a,a,c,"arial","bold"),this.renderText(r,s,o,a,c)},this.renderLine=(i,r,s,o,a,c,h=!0)=>{const{ctx:l}=this,u=h?i:i+s,f=h?i+s:i,d=r+2;l!=null&&(l.strokeStyle=c,l.lineWidth=1,l.beginPath(),l.moveTo(o,a),l.lineTo(u,d),l.lineTo(f,d),l.stroke())},this.minFontSize=n?.minFontSize||zl,this.maxFontSize=n?.maxFontSize||Dl,this.fontSizeFactor=n?.fontSizeFactor||Nl,this.offsetMin=n?.offsetMin||$l,this.offsetMax=n?.offsetMax||Bl,this.offsetFactor=n?.offsetFactor||Hl,this.fontColor=n?.fontColor,n?.backgroundColor?(this.backgroundActive=!0,this.backgroundColor=n.backgroundColor):(this.backgroundActive=!1,this.backgroundColor=Xl),this.backgroundPadding=n?.backgroundPadding||Ul,this.backgroundBorderRadius=Wl(n?.backgroundBorderRadius,Vl)}setGroupFilter(t){this.groupFilter=t,this.callouts=[],this.render()}onUpdate(t){super.onUpdate(t),this.callouts=[],this.render()}onRescale(t){super.onRescale(t);const n=this.rescaleEvent&&this.rescaleEvent.xRatio===t.xRatio;this.rescaleEvent=t,this.render(n)}render(t=!1){requestAnimationFrame(()=>{if(this.clearCanvas(),!this.data||!this.rescaleEvent||!this.referenceSystem)return;const{xScale:n,yScale:i,xBounds:r}=this.rescaleEvent,s=ke(this.fontSizeFactor,this.minFontSize,this.maxFontSize,n);if(!t||this.callouts.length<=0){const{data:o,ctx:a,groupFilter:c}=this,{calculateDisplacementFromBottom:h}=this.referenceSystem.options,l=h?r[0]<r[1]:r[0]>r[1],u=0;a!=null&&(a.font=`bold ${s}px arial`);const f=o.filter(p=>c.length<=0||c.includes(p.group)),d=ke(this.offsetFactor,this.offsetMin,this.offsetMax,n);this.callouts=this.positionCallouts(f,l,n,i,u,s,d)}this.callouts.forEach(o=>{const{pos:a,title:c,color:h}=o,l=n(a.x),u=i(a.y),f={x:l,y:u,width:o.boundingBox.width,height:s,offsetX:o.dx,offsetY:o.dy};this.renderCallout(c,o.label,f,h,o.alignment)})})}renderBackground(t,n,i,r,s){const{ctx:o}=this;if(o==null)return;const a=this.backgroundPadding,c=this.backgroundBorderRadius,h=this.measureTextWidth(t,s,"arial","bold"),l=this.measureTextWidth(n,s),u=Math.max(h,l)+a*2,f=(s+a)*2,d=i-a,p=r-2*s-a;if(o.fillStyle=this.backgroundColor,c>0){const g=d+u,m=p+f;o.beginPath(),o.moveTo(d+c,p),o.lineTo(g-c,p),o.quadraticCurveTo(g,p,g,p+c),o.lineTo(g,m-c),o.quadraticCurveTo(g,m,g-c,m),o.lineTo(d+c,m),o.quadraticCurveTo(d,m,d,m-c),o.lineTo(d,p+c),o.quadraticCurveTo(d,p,d+c,p),o.fill()}else o.fillRect(d,p,u,f)}renderText(t,n,i,r,s,o="arial",a="normal"){const{ctx:c}=this;c!=null&&(c.font=`${a} ${r}px ${o}`,c.fillStyle=this.fontColor||s,c.fillText(t,n,i))}measureTextWidth(t,n,i="arial",r="normal"){const{ctx:s}=this;return s==null?0:(s.font=`${r} ${n}px ${i}`,s.measureText(t).width)}renderPoint(t,n,i,r=3){const{ctx:s}=this;s!=null&&(s.fillStyle=i,s.beginPath(),s.moveTo(t,n),s.arc(t,n,r,0,Math.PI*2),s.fill())}renderCallout(t,n,i,r,s){const o=this.getPosition(i,s),{x:a,y:c}=o,{height:h,width:l,x:u,y:f}=i,d=s===nt.topright||s===nt.bottomright;this.backgroundActive&&this.renderBackground(t,n,a,c,h),this.renderAnnotation(t,n,a,c,h,r),this.renderPoint(u,f,r),this.renderLine(a,c,l,u,f,r,d)}getPosition(t,n){const{x:i,y:r,offsetX:s=0,offsetY:o=0,width:a}=t;switch(n){case nt.topleft:return{x:i-a-s,y:r-o};case nt.topright:return{x:i+s,y:r-o};case nt.bottomleft:return{x:i-a-s,y:r+o};case nt.bottomright:return{x:i+s,y:r+o};default:return{x:i,y:r}}}positionCallouts(t,n,i,r,s,o,a=20){if(t.length===0)return[];const c=n?nt.topleft:nt.topright,h=t.map(f=>{const d=f.pos?f.pos:this.referenceSystem?.project(f.md);return{title:f.title,label:f.label,color:f.color,pos:{x:d?.[0],y:d?.[1]},group:f.group,alignment:c,boundingBox:this.getAnnotationBoundingBox(f.title,f.label,d,i,r,o),dx:a,dy:a}}),l=[h[h.length-1]],u=[];return this.chooseTopOrBottomPosition(h,u,l),this.adjustTopPositions(l),this.adjustBottomPositions(u),h}getAnnotationBoundingBox(t,n,i,r,s,o){const{ctx:a}=this,c=r(i[0]),h=s(i[1]),l=a?.measureText(n).width??0,u=a?.measureText(t).width??0,f=Math.max(l,u);return{x:c,y:h,width:f,height:o*2+4}}chooseTopOrBottomPosition(t,n,i){for(let r=t.length-2;r>=0;--r){const s=t[r],o=i[0];ns(s.boundingBox,o.boundingBox)?(s.alignment=s.alignment===nt.topleft?nt.bottomright:nt.bottomleft,n.push(s),r>0&&i.unshift(t[--r])):i.unshift(s)}}adjustTopPositions(t){for(let n=t.length-2;n>=0;--n){const i=t[n];for(let r=t.length-1;r>n;--r){const s=t[r],o=vn(i.boundingBox,s.boundingBox);o&&(i.dy+=o.dy,i.boundingBox.y-=o.dy)}}}adjustBottomPositions(t){for(let n=t.length-2;n>=0;--n){const i=t[n];for(let r=t.length-1;r>n;--r){const s=t[r],o=vn(s.boundingBox,i.boundingBox);o&&(i.dy+=o.dy,i.boundingBox.y+=o.dy)}}}}const Gl=16,ql=6;function ft(e){const t=pt(e);if(t!=null){const n=t?.formatHex();return parseInt(n.replace("#","0x"))}else throw Error(`Could not format string ${e} to hex code.`)}function jl(e){return typeof e=="string"?e:`#${e.toString(Gl).padStart(ql,"0")}`}const Zl=1e4;class Kl extends bt{constructor(t,n){super(t,n),this.surfaceAreasPaths=[],this.surfaceLinesPaths=[],this.maxDepth=Zl,this.drawPolygonPath=(i,r)=>{const{ctx:s}=this;s!=null&&(s.fillStyle=i,s.fill(r))},this.drawLinePath=(i,r)=>{const{ctx:s}=this;s!=null&&(s.strokeStyle=i,s.stroke(r))},this.createPolygons=i=>{const r=[];let s=[];for(let o=0;o<i.length;o++){const a=!!i[o]?.[1];a&&(s===null&&(s=[]),s.push(i[o]?.[0],i[o]?.[1]));const c=o===i.length-1;if((!a||c)&&s.length>0){for(let h=a?o:o-1;h>=0&&i[h]?.[1];h--)s.push(i[h]?.[0],i[h]?.[2]||this.maxDepth);r.push(s),s=[]}}return r},this.generatePolygonPath=i=>{const r=new Path2D;r.moveTo(i[0],i[1]);for(let s=2;s<i.length;s+=2)r.lineTo(i[s],i[s+1]);return r.closePath(),r},this.generateLinePaths=i=>{const r=[],{data:s}=i;let o=!1,a;for(let c=0;c<s.length;c++)s[c]?.[1]?o&&a?a.lineTo(s[c]?.[0],s[c]?.[1]):(a=new Path2D,a.moveTo(s[c]?.[0],s[c]?.[1]),o=!0):o&&a&&(r.push(a),o=!1);return o&&a&&r.push(a),r},this.render=this.render.bind(this),this.generateSurfaceAreasPaths=this.generateSurfaceAreasPaths.bind(this),this.generateSurfaceLinesPaths=this.generateSurfaceLinesPaths.bind(this),this.drawPolygonPath=this.drawPolygonPath.bind(this),this.drawLinePath=this.drawLinePath.bind(this),this.updatePaths=this.updatePaths.bind(this)}onUpdate(t){super.onUpdate(t),this.updatePaths(),this.render()}onRescale(t){this.rescaleEvent=t,this.setTransform(this.rescaleEvent),this.render()}updatePaths(){this.data?(this.generateSurfaceAreasPaths(),this.generateSurfaceLinesPaths()):(this.surfaceAreasPaths=[],this.surfaceLinesPaths=[])}render(){!this.ctx||!this.rescaleEvent||requestAnimationFrame(()=>{this.clearCanvas(),this.surfaceAreasPaths.forEach(t=>this.drawPolygonPath(t.color,t.path)),this.surfaceLinesPaths.forEach(t=>this.drawLinePath(t.color,t.path))})}colorToCSSColor(t){return jl(t)}generateSurfaceAreasPaths(){this.surfaceAreasPaths=this.data?.areas.reduce((t,n)=>{const r=this.createPolygons(n.data).map(s=>({color:this.colorToCSSColor(n.color),path:this.generatePolygonPath(s)}));return t.push(...r),t},[])??[]}generateSurfaceLinesPaths(){this.surfaceLinesPaths=this.data?.lines.reduce((t,n)=>{const r=this.generateLinePaths(n).map(s=>({color:this.colorToCSSColor(n.color),path:s}));return t.push(...r),t},[])??[]}}function Bn(e,t){if(e.length<2)return-1;const n=20;let i=0,r=e.length-1,s=e[i]?.[0],o=e[r]?.[0];for(;r-i>n;){const c=Math.floor((r+i)/2),h=e[c]?.[0];if(s==null||o==null||h==null)return-1;if(t>=s&&t<h)r=c,o=e[r]?.[0];else if(t>=h&&t<=o)i=c,s=e[i]?.[0];else if(t<=s&&t>h)r=c,o=e[r]?.[0];else if(t<=h&&t>=o)i=c,s=e[i]?.[0];else return-1}let a=-1;for(let c=i;c<r;c++){const h=e[c]?.[0],l=e[c+1]?.[0];if(h!=null&&l!=null&&Math.min(h,l)<=t&&t<=Math.max(h,l)){a=c;break}}return a}function yt(e,t,n=0,i=0){let r=0;const s=Bn(e,t);if(s!==-1){const o=e[s]?.[1],a=e[s+1]?.[1];if(o&&a){const c=e[s]?.[0]??0,l=(e[s+1]?.[0]??0)-c,f=(t-c)/l;r=o*(1-f)+a*f,n&&n>r&&(r=n),i&&i<r&&(r=i)}}return r}const Hn=(e,t)=>({title:e.pickIdentifier||e.identifier,group:t,label:`${e.md} ${e.mdUnit} ${e.depthReferencePoint}`,color:t==="strat-picks"?"#227":"rgba(0,0,0,0.8)",md:e.md});function Ql(e){return e?e.map(t=>Hn(t,"ref-picks")):[]}function Jl(e){return e?e.filter(t=>t.entryPick.md===t.from).map(t=>Hn(t.entryPick,"strat-picks")):[]}function tu(e){return e?e.filter(t=>e.findIndex(n=>Math.abs(n.entryPick.md-t.exitPick.md)<.5)===-1).map(t=>Hn(t.exitPick,"strat-picks")).filter((t,n,i)=>n===i.findIndex(r=>r.title===t.title&&r.md===t.md)):[]}const eu=e=>[...Ql(e.nonUnitPicks),...Jl(e.unitPicks),...tu(e.unitPicks)].sort((t,n)=>t.md-n.md),nu=e=>({unitName:e.identifier,topSurface:e.top,baseSurface:e.base,ageBase:e.baseAge,ageTop:e.topAge,color:{r:e.colorR===null?255:e.colorR,g:e.colorG===null?255:e.colorG,b:e.colorB===null?255:e.colorB},level:e.stratUnitLevel,lithType:e.lithologyType,parent:e.stratUnitParent});function iu(e,t,n){if(n.length===0)return[[e,t]];const i=[];let r=e,s=0;for(;r<t&&s<n.length;){const o=n[s];o.from>r&&i.push([r,Math.min(o.from,t)]),r=Math.min(t,Math.max(e,o.to)),s+=1}return r<t&&i.push([r,t]),i}const ru=e=>e.map(nu);function su(e,t){const n=ru(t),i=[],r=[];return e.forEach(s=>{const o=n.filter(a=>s.pickIdentifier?.search(new RegExp(`(${a.topSurface}|${a.baseSurface})`,"i"))!==-1);o.length>0?o.forEach(a=>r.push({md:s.md,tvd:s.tvd,identifier:s.pickIdentifier,confidence:s.confidence,mdUnit:s.mdUnit,depthReferencePoint:s.depthReferencePoint,...a})):i.push({identifier:s.pickIdentifier,...s})}),{joined:r,nonUnitPicks:i}}function ou(e){const t=[];let n=null;const i=e.filter(r=>r.level).sort((r,s)=>r.unitName.localeCompare(s.unitName)||r.md-s.md||r.ageTop-s.ageTop);for(;i.length>0;){n=i.shift();const r=n.identifier;let s;const o=r===n.topSurface,a=r===n.baseSurface;if(o)s=n.baseSurface;else if(a)s=n.topSurface;else{console.warn(`Unable to match ${r} with top or base surface, ignored`);continue}let c,h;const l=i.find(u=>u.identifier===s);if(l)c=o?n:l,h=o?l:n,c.md>h.md&&([c,h]=[h,c]),i.splice(i.indexOf(l),1);else if(console.warn(`Unable to find ${s} pick for ${r}`),o)if(c=n,h=e.filter(u=>u.level).sort((u,f)=>u.md-f.md).find(u=>u.md>c.md),h)console.warn(`Using ${h.identifier} as base for ${r}`);else{console.warn(`Unable to find a base pick for ${r} pick at ${c.md}, ignored`);continue}else if(a)if(h=n,c=e.filter(u=>u.level).sort((u,f)=>f.md-u.md).find(u=>u.md<h.md),c)console.warn(`Using ${c.identifier} as top for ${r}`);else{console.warn(`Unable to find a top pick for ${r} pick at ${h.md}, ignored`);continue}else{console.warn(`${r} ignored`);continue}t.push({name:c.unitName,mdEntry:c.md,tvdEntry:c.tvd,color:c.color,level:c.level,entryPick:c,mdExit:h.md,tvdExit:h.tvd,exitPick:h,confidenceEntry:c.confidence,confidenceExit:h.confidence})}return t}function au(e,t){const{joined:n,nonUnitPicks:i}=su(e,t),s=ou(n).filter(a=>a.mdEntry<a.mdExit).sort((a,c)=>a.mdEntry-c.mdEntry||a.level-c.level).reverse(),o=[];for(;s.length>0;){const a=s.pop(),c=[];for(;s.length>0&&s[s.length-1]?.level>a.level;)c.push(s.pop());c.reverse(),c.push(a);const h=[];c.forEach(l=>{const u=iu(l.mdEntry,l.mdExit,h);h.push(...u.map(f=>({from:f[0],to:f[1],itm:l})))}),h.sort((l,u)=>l.from-u.from),o.push(...h.map(l=>({from:l.from,to:l.to,...l.itm})))}return{unitPicks:o,nonUnitPicks:i}}function cu(e,t){const n=e.map((s,o)=>o*t/e.length),i=Ct().domain(n).range(e);return Array.from(new Array(t).keys()).map(s=>{const o=pt(i(s))?.rgb();return o!=null?[o.r,o.g,o.b]:[0,0,0]})}const hu=e=>e?{x:e.minX,y:e.minTvdMsl,width:e.maxX-e.minX,height:e.maxTvdMsl-e.minTvdMsl}:{x:0,y:0,width:0,height:0};function lu(e,t){if(!(e&&e.datapoints))return null;const n=t.reduce((d,p)=>Math.min(d,p[0]),0),i=t.reduce((d,p)=>Math.max(d,p[0]),0),r=e.yAxisValues&&e.yAxisValues[0],s=e.yAxisValues&&e.yAxisValues[e.yAxisValues.length-1],o=e.datapoints||[],a=-o.reduce((d,p)=>Math.min(...p,d),0),c=o.reduce((d,p)=>Math.max(...p,d),0),h=Math.max(Math.abs(a),Math.abs(c)),l=-h,u=h;return{minX:n,maxX:i,minTvdMsl:r,maxTvdMsl:s,domain:{min:l,max:u,difference:u-l}}}async function uu(e,t,n,i={isLeftToRight:!0}){if(!(e&&e.datapoints&&e.datapoints.length>0))return;const{datapoints:r}=e,s=i?.seismicMin||i?.seismicRange||r.reduce((y,T)=>Math.min(...T,y),0),o=i?.seismicMax||i?.seismicRange||r.reduce((y,T)=>Math.max(...T,y),0),a=Math.max(Math.abs(s),Math.abs(o)),c=-a,l={min:c,difference:a-c},u=t[0]?.[0]-t[t.length-1]?.[0],f=Math.abs(Math.floor(u/5)),d=e.yAxisValues.length,p=1e3,g=cu(n,p),m=new Uint8ClampedArray(f*d*4);let _=0;const x=(p-1)/l.difference;let v=i?.isLeftToRight?t[0]?.[0]:t[t.length-1]?.[0];const A=u/f*(i?.isLeftToRight?-1:1);let S,M,b,C,k;const O=[0,0,0];let L;for(let y=0;y<f;y++){_=y*4;const T=Bn(t,v),w=t[T]?.[0],F=t[T+1]?.[0]-w,I=(v-w)/F;for(let D=0;D<d;D++)S=r[D]?.[T],M=r[D]?.[T+1],S==null||M==null?(k=O,L=0):(b=S*(1-I)+M*I,C=(b-l.min)*x,C=_t(~~C,0,p-1),k=g[C],L=255),m.set([k[0],k[1],k[2],L],_),_+=f*4;v+=A}const z=new ImageData(m,f,d);return await createImageBitmap(z,0,0,f,d)}const fu=2147483648,du=4294967295;function pu(e,t,n){const i=n.filter(d=>d.data.values),r=vu(i),s=new Map,o=_u(r,t,s);xu(o);const a=gu(r,e),c=Au(e,o,t),h=yu(s,c),u=[...mu(h,e),...Object.values(c).flat().filter(d=>!d.exclude)];return{lines:a,areas:u}}function gu(e,t){return e.filter(i=>i.visualization==="line").map(i=>({id:i.name,label:i.name,width:2,color:ft(i.color||"black"),data:t.map((r,s)=>[r[0],i.values[s]])}))}function mu(e,t){return e.map((i,r)=>{const s=r+1<e.length?e[r+1]:null;return{id:i.id,color:ft(i.color),data:t.map((o,a)=>[o[0],i.top[a],...s?[s.top[a]]:[]])}})}function yu(e,t){return Array.from(e.values()).sort((i,r)=>i.age-r.age).filter(i=>{const r=t[i.name],s=r&&r.length>0;return s||console.warn(`Intersection surface group '${i.name}' has no valid entries and will be discarded.`),s}).map((i,r)=>{const o=t[i.name][0];return{id:i.name,label:i.name,color:bu(r),top:o.data.map(a=>a[1])}})}function _u(e,t,n){const i=t&&t.find(o=>o.stratUnitLevel===1),r=i?i.identifier:"SEABED";return e.filter(o=>o.visualization==="interval"||o.visualization==="none").map(o=>{const a=[],c=is(t,o.name,a);c||console.warn(`No match for ${o.name} in strat column`);const h=a[0]||c,l=h&&h.identifier||r;return h&&!n.has(l)&&n.set(l,{age:h.topAge,name:h.identifier}),{...o,unit:c,group:l}})}function xu(e){e.sort((t,n)=>{if(!t.unit&&!n.unit)return 0;if(!t.unit)return-1;if(!n.unit)return 1;const i=t.isBase?t.unit.baseAge:t.unit.topAge,r=n.isBase?n.unit.baseAge:n.unit.topAge;return i!==r?i-r:t.isBase&&!n.isBase?1:!t.isBase&&n.isBase?-1:t.unit.stratUnitLevel-n.unit.stratUnitLevel})}function is(e,t,n=[]){const i=e.find(r=>r.identifier.toLowerCase()===t.toLowerCase());if(i){let r=i;do n.unshift(r),r=e.find(s=>s.identifier===r.stratUnitParent);while(r);return i}return null}function vu(e){return e.map(t=>{const n=t.visualSettings.displayName,i=n.replace(/\s(Base|Top)/gi,""),r=n.toLowerCase().endsWith("base");return{name:i,isBase:r,values:t.data.values,color:t.visualSettings.colors.crossSection,visualization:t.visualSettings.crossSection.toLowerCase()}})}function wu(e){return e.colorR===null||e.colorG===null||e.colorB===null?fu:e.colorR<<16|e.colorG<<8|e.colorB}const bu=Yi().domain([0,100]).range(To(Zt("#e6f1cf","#85906d"),10));function Su(e,t,n,i){const r=t+1;if(!n||r>=n.length)return;const s=n.findIndex(o=>o.isBase&&o.name===e.name);if(s!==-1)return s;for(let o=r;o<n.length;o++){const a=n[o];if(!a?.isBase||Tu(e,a,i))return o}}function Tu(e,t,n){const i=[];return is(n,e.name,i),i.some(r=>t.name===r.identifier)}function Au(e,t,n){return t.reduce((r,s,o)=>{if(!s.isBase){r[s.group]||(r[s.group]=[]);const a=Su(s,o,t,n);r[s.group]?.push({id:s.name,label:s.name,color:s.unit&&wu(s.unit)||du,exclude:s.visualization==="none"||!s.unit,data:e.map((c,h)=>{const l=s.values[h]!=null?Mu(a,t,h):void 0;return[c[0],s.values[h],l]})})}return r},{})}function Mu(e,t,n){if(!(!t||!e||e>=t.length)){for(let i=e;i<t.length;i++)if(t[i]?.values[n]!=null)return t[i]?.values[n]}}const Ri=.1,Je=1e3,Pu=150,Cu=30,Lu=10;function ku(e){if(!e||e.length===0)return[];const t=e?e.map(r=>[r.easting,r.northing,r.tvd,r.md]):[],n=rs(ss(t)),i=n[n.length-1]?.[0];return i!=null&&n.forEach((r,s)=>{n[s][0]=i-r[0]}),n}function Eu(e,t){if(!e||e.length===0)return[];const n=e?e.map(x=>[x.easting,x.northing,x.tvd,x.md]):[],i=new cr(n,{tension:.75,arcDivisions:5e3}),r=i.length,s=Math.round(r*Lu);let o;s>0?o=rs(i.getPoints(s),5e-4,10):o=[[n[0][0],n[0][1]]];const a=o[0],c=o[o.length-1],h=N.distance(a,c);let l;if(h<Pu){const v=t/180*Math.PI;l=new N(Math.cos(v),Math.sin(v)).mutable}else l=Fu(o,Cu);const u=Math.max(0,Je-r),f=u+r,d=[];let p=[];const g=l.toArray();u>0&&(p=gi(Math.ceil(u*Ri)).map(x=>l.set(g).scale(u*(1-x)).subFrom(a).toArray()),p.pop(),d.push(...p)),d.push(...o);const m=gi(Math.ceil(Je*Ri)).map(x=>l.set(g).scale(Je*x).add(c).toArray()).splice(1);return d.push(...m),ss(d,void 0,f)}function Fu(e,t){const n=N.zero.mutable;let i=0;const r=N.zero.mutable;for(let s=0;s<e.length-1;s++){const o=e.length-1-s;if(r.set(e[o]).sub(e[o-1]),n.add(r),i=n.magnitude,i>t)break}return i===0?new N([0,0]):n.scale(1/i)}function rs(e,t=.001,n=10){if(e.length<=4)return e;const[i,r]=e[0],s=e.map(l=>[l[0]-i,l[1]-r]);let[o,a]=s[0];const c=[e[0]];for(let l=1;l+1<s.length;l++){const[u,f]=s[l]??[],[d,p]=s[l+1]??[];if(u!=null&&f!=null&&d!=null&&p!=null&&(d-u!==0||p-f!==0)){const g=Math.abs(o*p-a*d+d*f-p*u+a*u-o*f)/Math.sqrt((d-o)**2+(p-a)**2),m=[o-u,a-f],_=Math.sqrt(m[0]**2+m[1]**2);(g>t||_>=n)&&(c.push([u+i,f+r]),[o,a]=[u,f])}}const h=s[s.length-1];return c.push([h[0]+i,h[1]+r]),c}function ss(e,t,n=0){let i=e[0],r=0;return e.map(o=>{const a=o[0]-i[0],c=o[1]-i[1];return r+=Math.sqrt(a**2+c**2),i=o,[n>0?n-r:r,o[2]??0]})}const Ru=18,Iu=8,Ou=13,zu="black",Du="Arial",Nu=70;class $u extends bt{constructor(t,n){super(t,n),this.defaultMargins=Ru,this.defaultMinFontSize=Iu,this.defaultMaxFontSize=Ou,this.defaultTextColor=zu,this.defaultFont=Du,this.isLabelsOnLeftSide=!0,this.maxFontSizeInWorldCoordinates=Nu,this.isXFlipped=!1,this.areasWithAvgTopDepth=[],this.drawAreaLabel=(i,r,s,o)=>{const{data:a}=i,{ctx:c,maxFontSizeInWorldCoordinates:h,isXFlipped:l}=this,{xScale:u,yScale:f,xRatio:d,yRatio:p,zFactor:g}=this.rescaleEvent;if(c==null)return;let m=this.checkDrawLabelsOnLeftSide();const x=(this.options.margins||this.defaultMargins)*(l?-1:1)/d,v=this.options.minFontSize||this.defaultMinFontSize;let S=(this.options.maxFontSize||this.defaultMaxFontSize)/p;S>h&&(S=h,S*p<v&&(S=v/p));const M=u.invert(u.range()[0])+x,b=u.invert(u.range()[1])-x,[C,k]=this.getSurfacesAreaEdges();c.save(),c.font=`${S*p}px ${this.options.font||this.defaultFont}`;let O=c.measureText(i.label??""),L=O.width/d;if(m){const X=M+(l?-L:L);(!l&&X>k||l&&X<k)&&(m=!1)}else{const X=b+(l?L:-L);(!l&&X<C||l&&X>C)&&(m=!0)}let z;const $=.07;m?z=l?Math.min(C,M):Math.max(C,M):z=l?Math.max(k,b):Math.min(k,b);const y=f.invert(f.range()[0]),T=f.invert(f.range()[1]),w=5,P=3,F=$*(L/P)*(m?1:-1)*(l?-1:1),R=L/w*(m?1:-1)*(l?-1:1),I=a.map(X=>[X[0],X[1]]),D=this.calcPos(I,z,P,F,y,T);if(!D)return;const B=a.map(X=>[X[0],X[2]]);let U=this.calcPos(B,z,P,F,y,T,r?.data.map(X=>[X[0],X[1]])??[],s,o);U||(U=new N(D.x,T));const H=U.y-D.y;if(H<S){if(H*p<v)return;S=H,c.font=`${S*p}px ${this.options.font||this.defaultFont}`,O=c.measureText(i.label??""),L=O.width/d}const G=m!==l?N.right:N.left,J=this.calcAreaDir(I,B,z,w,R,G,y,T,0,Math.PI/4,4,r?.data.map(X=>[X[0],X[1]])??[],s,o),V=Math.atan(Math.tan(J)*g),tt=z,$t=(D.y+U.y)/2,Ts=l?-V:V;c&&(c.textAlign=m?"left":"right",c.translate(u(tt),f($t)),c.rotate(Ts),c.fillStyle=this.options.textColor||this.defaultTextColor,c.font=`${S*p}px ${this.options.font||this.defaultFont}`,c.textBaseline="middle",c.fillText(i.label??"",0,0),c.restore())},this.drawLineLabel=i=>{const{ctx:r,isXFlipped:s}=this,{xScale:o,yScale:a,xRatio:c,yRatio:h,zFactor:l}=this.rescaleEvent;if(r==null)return;const u=this.checkDrawLabelsOnLeftSide(),f=this.getMarginsInWorldCoordinates(),p=(this.options.maxFontSize||this.defaultMaxFontSize)/h;r.save(),r.font=`${p*h}px ${this.options.font||this.defaultFont}`;const m=r.measureText(i.label).width/c,_=o.invert(o.range()[0])+f,x=o.invert(o.range()[1])-f,[v,A]=this.getSurfacesAreaEdges();let S;const M=5;u?S=s?Math.max(A,x):Math.min(A,x):S=s?Math.min(v,_):Math.max(v,_);const b=m/M*(u?-1:1),{data:C}=i,k=this.calcPos(C,S,M,b),O=this.calcLineDir(C,S,M,b,l,u?N.left:N.right);if(!k||!O)return;const L=S,z=k.y-Er-p/2,$=N.angleRight(O)-(u?Math.PI:0);r&&(r.textAlign=u?"right":"left",r.translate(o(L),a(z)),r.rotate($),r.fillStyle=this.colorToCSSColor(i.color),r.textBaseline="middle",r.fillText(i.label,0,0),r.restore())},this.render=this.render.bind(this),this.getMarginsInWorldCoordinates=this.getMarginsInWorldCoordinates.bind(this),this.getSurfacesAreaEdges=this.getSurfacesAreaEdges.bind(this),this.updateXFlipped=this.updateXFlipped.bind(this),this.generateSurfacesWithAvgDepth=this.generateSurfacesWithAvgDepth.bind(this)}get options(){return this._options}setData(t){super.setData(t),this.areasWithAvgTopDepth=[]}generateSurfacesWithAvgDepth(){const t=this.data?.areas??[];this.areasWithAvgTopDepth=t.reduce((n,i)=>{if(!i.label)return n;const r=i.data.reduce((o,a)=>(a[1]!=null&&(o.sum+=a[1],o.count++),o),{sum:0,count:0});if(r.count===0)return n;const s=r.sum/r.count;return n.push({...i,avgTopDepth:s}),n},[])}onMount(t){super.onMount(t)}onUpdate(t){super.onUpdate(t),this.render()}onRescale(t){this.rescaleEvent=t,this.updateXFlipped(),this.resetTransform(),this.render()}render(){this.rescaleEvent&&requestAnimationFrame(()=>{this.clearCanvas(),this.data&&(this.areasWithAvgTopDepth.length<=0&&this.generateSurfacesWithAvgDepth(),this.drawAreaLabels(),this.drawLineLabels())})}drawAreaLabels(){this.areasWithAvgTopDepth.forEach((t,n,i)=>{const r=i.reduce((s,o,a)=>(a>n&&(s==null||o.avgTopDepth<s.avgTopDepth)&&(s=o),s),null);this.drawAreaLabel(t,r,i,n)})}drawLineLabels(){this.data?.lines.filter(t=>t.label).forEach(t=>this.drawLineLabel(t))}colorToCSSColor(t){if(typeof t=="string")return t;let n=t.toString(16);return n="000000".substr(0,6-n.length)+n,`#${n}`}calcPos(t,n,i,r,s,o,a,c=null,h){const l=N.zero.mutable;let u=0;for(let f=0;f<i;f++){const d=n+f*r,p=yt(t,d,s,o);if(p){const g=this.getAlternativeYValueIfAvailable(d,s,o,a,c,h),m=g?Math.min(p,g):p;l.add(d,m),u++}}return u===0?null:N.divide(l,u)}getAlternativeYValueIfAvailable(t,n,i,r,s=null,o){if(!r)return null;let a=yt(r,t,n,i);if(a==null&&s&&o!=null){let c=o+1;for(;a==null&&c<s.length;){const h=s[c++];a=yt(h?.data.map(l=>[l[0],l[1]])??[],t,n,i)}}return a}calcLineDir(t,n,i,r,s,o=N.left,a,c){const h=o.mutable,l=yt(t,n,a,c);if(l===null)return h;const u=new N(n,l*s),f=N.zero.mutable;for(let d=1;d<=i;d++){const p=n+d*r,g=yt(t,n,a,c);g!==null&&(f.set(p,g*s),f.sub(u),h.add(f))}return h}calcAreaDir(t,n,i,r,s,o=N.left,a,c,h=0,l=Math.PI/4,u=4,f,d=null,p){const g=[],m=N.zero.mutable;let _;for(let b=0;b<=r;b++){const C=i+b*s,k=yt(t,C,a,c),O=yt(n,C,a,c)||c,L=this.getAlternativeYValueIfAvailable(C,a,c,f,d,p),z=L?Math.min(O,L):O;if(b===0){if(k===null)return N.angleRight(o);const $=(k+z)/2;_=new N(i,$)}else k!==null?(m.set(C,(k+z)/2),m.sub(_),g.push(N.angleRight(m))):g.push(N.angleRight(o))}const x=g[0],v=g.map(b=>b-x);let A=0;return v.reduce((b,C)=>{const k=(Math.abs(C)-h)/l,O=Math.pow(1-_t(k,0,1),u);return A+=O,b+C*O},0)/A+x}updateXFlipped(){const{xBounds:t}=this.rescaleEvent;this.isXFlipped=t[0]>t[1]}getMarginsInWorldCoordinates(){const{xRatio:t}=this.rescaleEvent;return(this.options.margins||this.defaultMargins)*(this.isXFlipped?-1:1)/t}getSurfacesAreaEdges(){const t=this.data?.areas.reduce((c,h)=>{const{data:l}=h,u=l.find(f=>f[1]!=null);u&&c.push(u[0]);for(let f=l.length-1;f>=0;f--)if(l[f]?.[1]!=null){c.push(l[f]?.[0]);break}return c},[])??[];t.push(...this.data?.lines.reduce((c,h)=>{const{data:l}=h,u=l.find(f=>f[1]!=null);u&&c.push(u[0]);for(let f=l.length-1;f>=0;f--)if(l[f]?.[1]!=null){c.push(l[f]?.[0]);break}return c},[])??[]);const n=Math.min(...t),i=Math.max(...t),r=this.getMarginsInWorldCoordinates(),{isXFlipped:s}=this,o=s?i+r:n+r,a=s?n-r:i-r;return[o,a]}checkDrawLabelsOnLeftSide(){const{referenceSystem:t,isXFlipped:n}=this;if(!t)return!0;const{xScale:i,yScale:r,xRatio:s}=this.rescaleEvent,o=200,[a,c]=i.domain(),[h,l]=r.domain();let u=t.interpolators.curtain.getIntersects(h,1,0);u.length===0&&(u=[t.interpolators.curtain.getPointAt(0)]);let f=t.interpolators.curtain.getIntersects(l,1,0);f.length===0&&(f=[t.interpolators.curtain.getPointAt(1)]);const d=Math.max(u[0]?.[0],f[0]?.[0]),p=Math.min(u[0]?.[0],f[0]?.[0]),g={left:n?d:p,right:n?p:d},m=this.getMarginsInWorldCoordinates(),_=a+m,x=c-m,[v,A]=this.getSurfacesAreaEdges(),S=n?Math.min(_,v):Math.max(_,v),M=n?Math.max(x,A):Math.min(x,A),b=Math.max(n?S-g.left:g.left-S,0),C=Math.max(n?g.right-M:M-g.right,0),k=b*s,O=C*s;return b>C||k>o||k<o&&O<o&&n||f[0]?.[1]<h}}const Bu=1e4;class Hu extends $n{constructor(){super(...arguments),this.isPreRendered=!1,this.createPolygons=t=>{const n=[];let i;for(let r=0;r<t.length;r++){const s=!!t[r]?.[1];s&&(i==null&&(i=[]),i.push(t[r]?.[0],t[r]?.[1]));const o=r===t.length-1;if((!s||o)&&i){for(let a=s?r:r-1;a>=0&&t[a]?.[1];a--)i.push(t[a]?.[0],t[a]?.[2]||Bu);n.push(i),i=void 0}}return n},this.generateAreaPolygon=t=>{const n=new E.Graphics;this.createPolygons(t.data).forEach(r=>n.poly(r)),n.setStrokeStyle({width:1,color:t.color,alpha:1}),n.fill({color:t.color}),this.addChild(n)},this.generateSurfaceLine=t=>{const n=new E.Graphics,{data:i}=t;n.setStrokeStyle({width:Er,color:t.color,alpha:1,alignment:.5});let s=!1;for(let o=0;o<i.length;o++){const a=i[o];a&&a[1]&&a[0]?s?n.lineTo(a[0],a[1]):(n.moveTo(a[0],a[1]),s=!0):s=!1}this.addChild(n)}}onRescale(t){super.onRescale(t),this.isPreRendered||(this.clearLayer(),this.preRender()),this.render()}onUpdate(t){super.onUpdate(t),this.isPreRendered=!1,this.clearLayer(),this.preRender(),this.render()}preRender(){const{data:t}=this;t&&(t.areas.forEach(n=>this.generateAreaPolygon(n)),t.lines.forEach(n=>this.generateSurfaceLine(n)),this.isPreRendered=!0)}}const os="lightgray",as="gray",cs=.25,hs=.75,Xu={minorColor:os,majorColor:as,minorWidth:cs,majorWidth:hs};class me extends bt{constructor(t,n){super(t,n),this._offsetX=0,this._offsetY=0,this.options={...this.options,...n||Xu},this.render=this.render.bind(this)}onUpdate(t){super.onUpdate(t),this.render(t)}onRescale(t){super.onRescale(t),this.render(t)}render(t){const{ctx:n}=this,{minorWidth:i,minorColor:r,majorWidth:s,majorColor:o}=this.options;if(!n||(this.clearCanvas(),!(t.xScale||t.yScale)))return;const a=t.xScale.copy(),c=t.yScale.copy(),h=a.domain(),l=c.domain(),u=this.offsetX,f=this.offsetY;a.domain([h[0]-u,h[1]-u]),c.domain([l[0]-f,l[1]-f]);const[d,p]=a.range(),[g,m]=c.range();n.lineWidth=i||cs,n.strokeStyle=r||os;const _=this.mapMinorTicks(a.ticks()),x=this.mapMinorTicks(c.ticks());this.renderTicksX(a,_,g,m),this.renderTicksY(c,x,d,p),n.lineWidth=s||hs,n.strokeStyle=o||as,this.renderTicksX(a,a.ticks(),g,m),this.renderTicksY(c,c.ticks(),d,p),n.restore()}renderTicksX(t,n,i,r){n.forEach(s=>{const o=t(s);this.ctx!=null&&(this.ctx.beginPath(),this.ctx.moveTo(o,i),this.ctx.lineTo(o,r),this.ctx.stroke())})}renderTicksY(t,n,i,r){n.forEach(s=>{const o=t(s);this.ctx!=null&&(this.ctx.beginPath(),this.ctx.moveTo(i,o),this.ctx.lineTo(r,o),this.ctx.stroke())})}mapMinorTicks(t){let n=[];return t.length>=2&&(n=t.map(i=>i+(t[1]-t[0])/2),n.pop()),n}get offsetX(){return this._offsetX}set offsetX(t){this._offsetX=t}get offsetY(){return this._offsetY}set offsetY(t){this._offsetY=t}}class Uu extends bt{onMount(t){super.onMount(t);const n=document.createElement("img");this.img=n,this.isLoading=!0}onUpdate(t){super.onUpdate(t),this.img!=null&&(this.img.src=t.url),this.render(t)}onRescale(t){super.onRescale(t),this.setTransform(t),this.render(t)}render(t){const n=parseInt(this.elm?.getAttribute("width")??"0",10),i=parseInt(this.elm?.getAttribute("height")??"0",10),{xScale:r,yScale:s,xRatio:o,yRatio:a,x:c,y:h}=t,l=n*(o||1),u=i*(a||1);this.clearCanvas(),this.img!=null&&(this.isLoading?this.img.onload=()=>{this.isLoading=!1,this.img!=null&&this.ctx?.drawImage(this.img,r(c||0),s(h||0),l,u)}:this.ctx?.drawImage(this.img,r(c||0),s(h||0),l,u))}}const Vu={dash:[10,5],width:1,color:16777215,alpha:1,scale:1,useTexture:!1,alignment:.5},ot=class ot{constructor(t,n={}){this.cursor=new E.Point,this.scale=1,this.graphics=t,n={...Vu,...n},this.dash=n.dash,this.dashSize=this.dash.reduce((i,r)=>i+r),this.useTexture=n.useTexture,this.options=n,this.setLineStyle()}setLineStyle(){const t=this.options;if(this.useTexture){const n=ot.getTexture(t,this.dashSize);this.graphics.lineTextureStyle({width:t.width*t.scale,color:t.color,alpha:t.alpha,texture:n,alignment:t.alignment})}else this.graphics.setStrokeStyle({width:t.width*t.scale,color:t.color,alpha:t.alpha,cap:t.cap,join:t.join,alignment:t.alignment});this.scale=t.scale}static distance(t,n,i,r){return Math.sqrt(Math.pow(i-t,2)+Math.pow(r-n,2))}moveTo(t,n){return this.lineLength=0,this.cursor.set(t,n),this.start=new E.Point(t,n),this.graphics.moveTo(this.cursor.x,this.cursor.y),this}lineTo(t,n,i){typeof this.lineLength===void 0&&this.moveTo(0,0);const s=ot.distance(this.cursor.x,this.cursor.y,t,n),o=Math.atan2(n-this.cursor.y,t-this.cursor.x),a=i&&t===this.start.x&&n===this.start.y;if(this.useTexture)if(this.graphics.moveTo(this.cursor.x,this.cursor.y),this.adjustLineStyle(o),a&&this.dash.length%2===0){const c=Math.min(this.dash[this.dash.length-1],s);this.graphics.lineTo(t-Math.cos(o)*c,n-Math.sin(o)*c),this.graphics.closePath()}else this.graphics.lineTo(t,n);else{const c=Math.cos(o),h=Math.sin(o);let l=this.cursor.x,u=this.cursor.y;const f=this.lineLength%(this.dashSize*this.scale);let d=0,p=0,g=0;for(let _=0;_<this.dash.length;_++){const x=this.dash[_]*this.scale;if(f<g+x){d=_,p=f-g;break}else g+=x}let m=s;for(;m>0;){const _=this.dash[d]*this.scale-p,x=m>_?_:m;if(a&&ot.distance(l+c*x,u+h*x,this.start.x,this.start.y)<=x){if(d%2===0){const A=ot.distance(l,u,this.start.x,this.start.y)-this.dash[this.dash.length-1]*this.scale;l+=c*A,u+=h*A,this.graphics.lineTo(l,u)}break}l+=c*x,u+=h*x,d%2?this.graphics.moveTo(l,u):this.graphics.lineTo(l,u),m-=x,d++,d=d===this.dash.length?0:d,p=0}}return this.lineLength+=s,this.cursor.set(t,n),this}closePath(){this.lineTo(this.start.x,this.start.y,!0)}drawCircle(t,n,i,r=80,s){const o=Math.PI*2/r;let a=0,c;s?(c=new E.Point(t+Math.cos(a)*i,n+Math.sin(a)*i),s.apply(c,c),this.moveTo(c[0],c[1])):(c=new E.Point(t+Math.cos(a)*i,n+Math.sin(a)*i),this.moveTo(c.x,c.y)),a+=o;for(let h=1;h<r+1;h++){const l=h===r?c:[t+Math.cos(a)*i,n+Math.sin(a)*i];this.lineTo(l[0],l[1]),a+=o}return this}drawEllipse(t,n,i,r,s=80,o){const a=Math.PI*2/s;let c;const h=new E.Point;for(let l=0;l<Math.PI*2;l+=a){let u=t-i*Math.sin(l),f=n-r*Math.cos(l);o&&(h.set(u,f),o.apply(h,h),u=h.x,f=h.y),l===0?(this.moveTo(u,f),c={x:u,y:f}):this.lineTo(u,f)}return this.lineTo(c.x,c.y,!0),this}drawPolygon(t,n){const i=new E.Point;if(typeof t[0]=="number")if(n){i.set(t[0],t[1]),n.apply(i,i),this.moveTo(i.x,i.y);for(let r=2;r<t.length;r+=2)i.set(t[r],t[r+1]),n.apply(i,i),this.lineTo(i.x,i.y,r===t.length-2)}else{this.moveTo(t[0],t[1]);for(let r=2;r<t.length;r+=2)this.lineTo(t[r],t[r+1],r===t.length-2)}else if(n){const r=t[0];i.copyFrom(r),n.apply(i,i),this.moveTo(i.x,i.y);for(let s=1;s<t.length;s++){const o=t[s];i.copyFrom(o),n.apply(i,i),this.lineTo(i.x,i.y,s===t.length-1)}}else{const r=t[0];this.moveTo(r.x,r.y);for(let s=1;s<t.length;s++){const o=t[s];this.lineTo(o.x,o.y,s===t.length-1)}}return this}drawRect(t,n,i,r,s){if(s){const o=new E.Point;o.set(t,n),s.apply(o,o),this.moveTo(o.x,o.y),o.set(t+i,n),s.apply(o,o),this.lineTo(o.x,o.y),o.set(t+i,n+r),s.apply(o,o),this.lineTo(o.x,o.y),o.set(t,n+r),s.apply(o,o),this.lineTo(o.x,o.y),o.set(t,n),s.apply(o,o),this.lineTo(o.x,o.y,!0)}else this.moveTo(t,n).lineTo(t+i,n).lineTo(t+i,n+r).lineTo(t,n+r).lineTo(t,n,!0);return this}adjustLineStyle(t){const n=this.graphics.line;n.matrix=new E.Matrix,t&&n.matrix.rotate(t),this.scale!==1&&n.matrix.scale(this.scale,this.scale);const i=-this.lineLength;n.matrix.translate(this.cursor.x+i*Math.cos(t),this.cursor.y+i*Math.sin(t)),this.graphics.lineStyle(n)}static getTexture(t,n){const i=t.dash.toString();if(ot.dashTextureCache[i])return ot.dashTextureCache[i];const r=document.createElement("canvas");r.width=n,r.height=Math.ceil(t.width);const s=r.getContext("2d");if(!s){console.warn("Did not get context from canvas");return}s.globalAlpha=t.alpha,s.lineWidth=t.width;let o=0;const a=t.width/2;s.moveTo(o,a);for(let h=0;h<t.dash.length;h+=2)o+=t.dash[h],s.lineTo(o,a),t.dash.length!==h+1&&(o+=t.dash[h+1],s.moveTo(o,a));s.strokeStyle="white",s.stroke();const c=ot.dashTextureCache[i]=E.Texture.from(r);return c.baseTexture.scaleMode=E.SCALE_MODES.NEAREST,c}};ot.dashTextureCache={};let wn=ot;const bn=e=>new N(e.x,e.y),Wu=e=>new E.Point(e[0],e[1]),ls=e=>{if(e.length<2)return[new N(0)];let t;return e.map((n,i,r)=>{const s=r[i],o=r[i+1];if(i<r.length-1&&s!=null&&o!=null){const a=bn(s);return t=bn(o).sub(a).rotate90().normalized(),t}return t})},us=(e,t,n)=>{const i=bn(e);return Wu(i.add(t.scale(n)))},Sn=(e,t,n)=>{if(e.length!==t.length)throw new Error("Number of vectors does not match number of points");return e.map((i,r)=>{const s=t[r];if(s!=null)return us(i,s,n);throw new Error(`Trying to read index ${r} of point ${i}, but no such vector was found!`)})},Ii=(e,t,n,i)=>e<=i&&n<=t,Yu=(e,t,n,i)=>e<i&&n<t,Gu=e=>Array.from(new Set(e)),$e=(e,t,n,i)=>{const r=i.filter(o=>Ii(e,t,o.start,o.end)),s=n.filter(o=>Ii(e,t,o.start,o.end));return{overlappingHoles:r,overlappingOuterStrings:s}},Be=([e,t],n)=>{const s=n.flatMap(a=>[a.start-1e-4,a.start,a.end,a.end+1e-4]).filter(a=>a>=e&&a<=t);return s.push(e),s.push(t),Gu(s).sort((a,c)=>a-c)},q=e=>e.kind==="casing"?e.innerDiameter:e.diameter,fs=(e,t,n,i)=>{const s=e.find(h=>h.start<=i&&h.end>=i),o=s?s.diameter:0,a=t.filter(h=>q(h)>o).sort((h,l)=>q(h)-q(l)).find(h=>h.start<=i&&h.end>=i),c=n.find(h=>h.start<=i&&h.end>=i&&h.diameter>o);return a?q(a):c?c.diameter:100},qu=(e,t,n,i)=>{const s=e.sort((a,c)=>c.diameter-a.diameter).find(a=>a.start<=n&&a.end>=n),o=t.find(a=>a.start<=n&&a.end>=n);return s&&i!=="Open hole frac pack"&&i!=="Open hole gravel pack"?q(s):o?o.diameter:100},ju=(e,t,n,i)=>{const s=e.sort((h,l)=>q(h)-q(l)).find(h=>h.start<=i&&h.end>=i);if(s)return q(s);const o=e.length?Math.min(...e.map(h=>q(h))):0,a=t.sort((h,l)=>q(h)-q(l)).find(h=>h.start<=i&&h.end>=i&&o<=q(h));if(a)return q(a);const c=n.find(h=>h.start<=i&&h.end>=i&&h.diameter);return c?c.diameter:100},Zu=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Xn(e.referenceIds,t,n);if(o.length===0)throw new Error(`Invalid cement data, can't find referenced casing/completion string for cement with id '${e.id}'`);o.sort((g,m)=>g.end-m.end);const c=o[o.length-1].end,{overlappingOuterStrings:h,overlappingHoles:l}=$e(e.toc,c,a,i),u=[...h,...l].map(g=>({start:g.start,end:g.end}));return Be([e.toc,c],u).flatMap((g,m,_)=>{if(m===_.length-1)return[];const x=_[m+1],v=fs(o,h,l,g);return[{top:g,bottom:x,diameter:v*r}]}).map(g=>({diameter:g.diameter,points:s(g.top,g.bottom)}))},Xn=(e,t,n)=>[...t,...n].reduce((i,r)=>e.includes(r.id)?{...i,attachedStrings:[...i.attachedStrings,r]}:{...i,nonAttachedStrings:[...i.nonAttachedStrings,r]},{attachedStrings:[],nonAttachedStrings:[]}),Ku=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Xn(e.referenceIds,t,n);if(o.length===0)throw new Error(`Invalid cement squeeze data, can't find referenced casing/completion for squeeze with id '${e.id}'`);const{overlappingOuterStrings:c,overlappingHoles:h}=$e(e.start,e.end,a,i),l=[...c,...h].map(p=>({start:p.start,end:p.end}));return Be([e.start,e.end],l).flatMap((p,g,m)=>{if(g===m.length-1)return[];const _=m[g+1],x=fs(o,c,h,p);return[{top:p,bottom:_,diameter:x*r}]}).map(p=>({diameter:p.diameter,points:s(p.top,p.bottom)}))},Qu=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Xn(e.referenceIds,t,n),{overlappingHoles:c,overlappingOuterStrings:h}=$e(e.start,e.end,a,i),l=[...o,...c,...h].map(p=>({start:p.start,end:p.end}));return Be([e.start,e.end],l).flatMap((p,g,m)=>{if(g===m.length-1)return[];const _=m[g+1],x=ju(o,h,c,p);return[{top:p,bottom:_,diameter:x*r}]}).map(p=>({diameter:p.diameter,points:s(p.top,p.bottom)}))},Ju=(e,t,n,i,r)=>{const o=t.createLinearGradient(0,0,0,e.height);return o.addColorStop(0,n),o.addColorStop(.5-r,i),o.addColorStop(.5+r,i),o.addColorStop(1,n),o},t0=({firstColor:e,secondColor:t},n,i)=>{const r=document.createElement("canvas");r.width=n,r.height=i;const s=r.getContext("2d");if(s==null)throw Error("Could not get canvas context!");return s.fillStyle=Ju(r,s,e,t,0),s.fillRect(0,0,r.width,r.height),E.Texture.from(r)},e0=({scalingFactor:e})=>{const t=document.createElement("canvas"),n=xt*e;t.width=n,t.height=n;const i=t.getContext("2d");if(i==null)throw Error("Could not get canvas context!");i.fillStyle="white",i.fillRect(0,0,t.width,t.height);const r=n/10;i.strokeStyle="#AAAAAA",i.lineWidth=r,i.beginPath();const s=n/3;for(let o=-t.width;o<t.width;o++)i.moveTo(-t.width+s*o,-t.height),i.lineTo(t.width+s*o,t.height*2);return i.stroke(),E.Texture.from(t)},n0=({innerColor:e,outerColor:t,scalingFactor:n})=>{const i=xt*n,r=document.createElement("canvas");r.width=i,r.height=i;const s=r.getContext("2d");if(s==null)throw Error("Could not get canvas context!");const o=s.createLinearGradient(0,0,0,i),a=.3,c=.7;return o.addColorStop(0,t),o.addColorStop(a,e),o.addColorStop(c,e),o.addColorStop(1,t),s.fillStyle=o,s.fillRect(0,0,r.width,r.height),E.Texture.from(r)},i0=({firstColor:e,secondColor:t,scalingFactor:n})=>{const i=document.createElement("canvas"),r=xt*n,s=n;i.width=r,i.height=r;const o=i.getContext("2d");if(o==null)throw Error("Could not get canvas context!");o.fillStyle=e,o.fillRect(0,0,i.width,i.height),o.lineWidth=s,o.fillStyle=t,o.beginPath();const a=r/12;for(let c=-i.width;c<i.width;c++)o.moveTo(-i.width+a*c,-i.height),o.lineTo(i.width+a*c,i.height);return o.stroke(),E.Texture.from(i)},r0=({firstColor:e,secondColor:t,scalingFactor:n})=>{const i=document.createElement("canvas"),r=xt*n;i.width=r,i.height=r;const s=i.getContext("2d");if(s==null)throw Error("Could not get canvas context!");s.fillStyle=e,s.fillRect(0,0,i.width,i.height),s.lineWidth=n,s.strokeStyle=t,s.beginPath(),s.setLineDash([20,10]);const o=r/12;for(let a=-i.width;a<i.width;a++)s.moveTo(-i.width+o*a,-i.height),s.lineTo(i.width+o*a,i.height*2);return s.stroke(),E.Texture.from(i)},s0=({firstColor:e,secondColor:t,scalingFactor:n})=>{const i=document.createElement("canvas"),r=xt*n,s=n;i.width=r,i.height=r;const o=i.getContext("2d");if(o==null)throw Error("Could not get canvas context!");o.lineWidth=s,o.fillStyle=e,o.strokeStyle=t,o.fillRect(0,0,i.width,i.height),o.beginPath(),o.setLineDash([20,10]);const a=r/12;for(let c=-i.width;c<i.width;c++)o.moveTo(-i.width+a*c,-i.height),o.lineTo(i.width+a*c,i.height*2);return o.stroke(),E.Texture.from(i)},ye=(e,t)=>{const n=ls(t),i=Sn(t,n,e);return{leftPath:Sn(t,n,-e),rightPath:i}},tn=(e,t)=>({kind:"casing",start:e,end:t}),o0=(e,t)=>({kind:"casing-window",start:e,end:t}),a0=e=>{const t=(e.windows||[]).filter(n=>Yu(e.start,e.end,n.start,n.end)).reduce(({intervals:n,lastBottom:i},r,s,o)=>{const a=i<r.start?tn(i,r.start):null,c=a?a.end:i,h=Math.max(c,r.start),l=Math.min(e.end,r.end),u=o0(h,l),f=l,p=s===o.length-1&&f<e.end?tn(f,e.end):null,g=[a,u,p].filter(m=>m!=null);return{intervals:[...n,...g],lastBottom:f}},{intervals:[],lastBottom:e.start});return t.intervals.length?t.intervals:[tn(e.start,e.end)]},c0=(e,t,n)=>{const i=t.diameter*e,r=i/2,o=t.innerDiameter*e/2,a=r-o,c=a0(t).map(h=>{const l=n(h.start,h.end),{leftPath:u,rightPath:f}=ye(r,l);return{kind:h.kind,leftPath:u,rightPath:f,pathPoints:l}});return{kind:"casing",id:t.id,referenceDiameter:i,referenceRadius:r,sections:c,casingWallWidth:a,hasShoe:t.hasShoe,bottom:t.end}},h0=(e,t,n,i,r)=>{const{overlappingOuterStrings:s,overlappingHoles:o}=$e(e.start,e.end,t,n),a=[...s,...o].map(u=>({start:u.start,end:u.end}));return Be([e.start,e.end],a).flatMap((u,f,d)=>{if(f===d.length-1)return[];const p=d[f+1],g=qu(s,o,u,e.subKind);return[{top:u,bottom:p,diameter:g*i}]}).map(u=>{const f=r(u.top,u.bottom);return{diameter:u.diameter,points:f}})},He=(e,t,n)=>{const{packingOpacity:i,yellow:r}=n;t.fillStyle=r,t.strokeStyle=r;const s=[0,0],o=[e.width,e.height];t.save(),t.globalAlpha=i,t.fillRect(...s,...o),t.restore()},Un=(e,t,n,i,r)=>{const{fracLineCurve:s}=i,o=10,a=e.width/o,c=n/3*i.scalingFactor,h=c/4,l=c/2,u=0,f=r==="diameter"?0:l;t.globalAlpha=i.packingOpacity;const d=()=>{for(let p=-1;p<o;p++){const g=[p*a+u+a/2,e.height/2-h-f-h];t.beginPath();const m=[...g],_=[g[0]-s*2,g[1]-h/4],x=[g[0],g[1]-h/2],v=[g[0]+s*2,g[1]-h/2-h/4],A=[g[0],g[1]-h];t.bezierCurveTo(...m,..._,...x),t.bezierCurveTo(...x,...v,...A),t.stroke()}for(let p=-1;p<o;p++){const g=[p*a+a+u+a/2,e.height/2+c/2+f];t.beginPath();const m=[...g],_=[g[0]-s*2,g[1]+h/4],x=[g[0],g[1]+h/2],v=[g[0]+s*2,g[1]+h/2+h/4],A=[g[0],g[1]+h];t.bezierCurveTo(...m,..._,...x),t.bezierCurveTo(...x,...v,...A),t.stroke()}};t.strokeStyle=i.yellow,t.lineWidth=6,t.save(),d(),t.restore(),t.lineWidth=1,t.strokeStyle=i.outline,d(),t.closePath()},l0=(e,t,n,i)=>{const s=e.width/4;t.strokeStyle=i.outline;const o=n/3*i.scalingFactor;t.lineWidth=1;const a=o/2;for(let c=0;c<=4;c++){const h=[c*s,e.height/2-o/2],l=[h[0]-s/2,h[1]-a],u=[h[0]-s,h[1]];t.beginPath(),t.moveTo(...h),t.lineTo(...l),t.lineTo(...u),t.fill(),t.lineWidth=1,t.stroke()}for(let c=0;c<=4;c++){const h=[c*s,e.height/2+o/2],l=[h[0]-s/2,h[1]+a],u=[h[0]-s,h[1]];t.beginPath(),t.moveTo(...h),t.lineTo(...l),t.lineTo(...u),t.fill(),t.lineWidth=1,t.stroke()}t.closePath()},ct=(e="Error!",t)=>{console.error(`${e}`);const n=document.createElement("canvas"),i=xt;n.width=i/2,n.height=i;const r=n.getContext("2d"),s=[0,0],o=[n.width,n.height];if(r==null)throw Error("Could not get canvas context!");return r.fillStyle="#ff00ff",r.fillRect(...s,...o),new E.Texture({source:new E.CanvasSource({resource:n,wrapMode:"clamp-to-edge"}),orig:new E.Rectangle(0,0,n.width,n.height),rotate:E.groupD8.MIRROR_HORIZONTAL})},vt=(e,t)=>{const n=document.createElement("canvas"),r=e.diameter*t.scalingFactor;n.width=r/2,n.height=r;const s=n.getContext("2d");if(s==null)throw Error("Could not get canvas context!");return{canvas:n,ctx:s}},wt=e=>new E.Texture({source:new E.CanvasSource({resource:e}),orig:new E.Rectangle(0,0,e.width,e.height),rotate:E.groupD8.MIRROR_HORIZONTAL}),u0=(e,t)=>n=>t.some(i=>n(i)&&Ur(e,i)),Vn={packing:()=>ct(),fracLines:()=>ct(),spikes:(e,t,n,i)=>{const{canvas:r,ctx:s}=vt(t,i),o=u0(e,n),a=o(Br),c=o(Xr),h=o(Hr),u=a||c||h?i.yellow:i.red;return s.globalAlpha=i.packingOpacity,e.isOpen?(s.fillStyle=u,s.strokeStyle=u):(s.fillStyle=i.grey,s.strokeStyle=i.grey),l0(r,s,t.diameter,i),h&&Un(r,s,t.diameter,i,"spike"),wt(r)}},ds={packing:()=>ct(),fracLines:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return Un(n,i,e.diameter,t,"diameter"),wt(n)},spikes:()=>ct()},Ee={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return He(n,i,t),wt(n)},fracLines:(e,t)=>{const{canvas:n}=vt(e,t);return wt(n)},spikes:()=>ct()},Wn={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return He(n,i,t),wt(n)},fracLines:()=>ct(),spikes:()=>ct()},Yn={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return He(n,i,t),wt(n)},fracLines:()=>ct(),spikes:()=>ct()},Gn={packing:(e,t,n)=>{const{canvas:i,ctx:r}=vt(t,n);return He(i,r,n),wt(i)},fracLines:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return Un(n,i,e.diameter,t,"diameter"),wt(n)},spikes:()=>ct()},f0=(e,t,n)=>K({Perforation:()=>Vn.packing(),CasedHoleFracturation:()=>Ee.packing(t,n),CasedHoleFracPack:()=>Ee.packing(t,n),OpenHoleGravelPack:()=>Yn.packing(t,n),OpenHoleFracPack:()=>Gn.packing(e,t,n),CasedHoleGravelPack:()=>Wn.packing(t,n)},e.subKind),d0=(e,t,n)=>K({Perforation:()=>Vn.fracLines(),OpenHoleGravelPack:()=>Yn.fracLines(),OpenHoleFracPack:()=>Gn.fracLines(t,n),CasedHoleFracturation:()=>ds.fracLines(t,n),CasedHoleGravelPack:()=>Wn.fracLines(),CasedHoleFracPack:()=>Ee.fracLines(t,n)},e.subKind),p0=(e,t,n,i)=>K({Perforation:()=>Vn.spikes(e,n,t,i),OpenHoleGravelPack:()=>Yn.spikes(),OpenHoleFracPack:()=>Gn.spikes(),CasedHoleFracturation:()=>ds.spikes(),CasedHoleGravelPack:()=>Wn.spikes(),CasedHoleFracPack:()=>Ee.spikes()},e.subKind);class g0 extends E.MeshGeometry{constructor(t){const n=We(t,i=>i.points.length);super({positions:new Float32Array(n*4),uvs:new Float32Array(n*4),indices:new Uint32Array((n-1)*6),shrinkBuffersToFit:!0}),this.segments=t,this.build()}get width(){return sn(this.segments,t=>t.diameter)}build(){const t=this.segments;if(!t)return;const n=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),r=this.getIndex(),s=We(t,p=>p.points.length);if(s<1)return;n.data.length/4!==s&&(n.data=new Float32Array(s*4),i.data=new Float32Array(s*4),r.data=new Uint16Array((s-1)*6));const o=i.data,a=r.data;o[0]=0,o[1]=0,o[2]=0,o[3]=1;const c=t.length,h=sn(t,p=>p.diameter);let l=0,u=0,f=0,d=0;for(let p=0;p<c;p++){let g=t[p]?.points[0];const m=h,_=t[p]?.diameter/h/2,x=t[p]?.points.length;for(let v=0;v<x;v++){const A=g.x-t[p]?.points[v]?.x,S=g.y-t[p]?.points[v]?.y,M=Math.sqrt(A*A+S*S);g=t[p]?.points[v],l+=M/m,o[u]=l,o[u+1]=.5-_,o[u+2]=l,o[u+3]=.5+_,u+=4}for(let v=0;v<x-1;v++)a[d++]=f,a[d++]=f+1,a[d++]=f+2,a[d++]=f+2,a[d++]=f+1,a[d++]=f+3,f+=2;f+=2}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.segments;if(We(t,s=>s.points.length)<1)return;const i=t.length;let r=0;for(let s=0;s<i;s++){let o=t[s]?.points[0],a,c=0,h=0;const l=this.buffers[0]?.data,u=t[s]?.points.length;let f=0;for(let d=0;d<u;d++){const p=t[s]?.points[d];f=r+d*4,d<t[s]?.points.length-1?a=t[s]?.points[d+1]:a=p,h=-(a.x-o.x),c=a.y-o.y;const g=Math.sqrt(c*c+h*h),m=t[s]?.diameter/2;c/=g,h/=g,c*=m,h*=m,l!=null&&(l[f]=p.x+c,l[f+1]=p.y+h,l[f+2]=p.x-c,l[f+3]=p.y-h),o=p}r=f+4}this.buffers[0]?.update()}update(){this.build()}}class m0 extends E.Mesh{constructor(t,n){const i=new g0(n);t.source.addressMode="repeat",super({geometry:i,texture:t}),this.autoUpdate=!0,this.onRender=()=>{const r=this.geometry;this.autoUpdate&&r.update()}}}class y0 extends E.MeshGeometry{constructor(t,n=200){super({positions:new Float32Array(t.length*4),uvs:new Float32Array(t.length*4),indices:new Uint32Array((t.length-1)*6)}),this.points=t,this._width=n,this.build()}get width(){return this._width}build(){const t=this.points;if(!t)return;const n=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),r=this.getIndex();if(t.length<1)return;n.data.length/4!==t.length&&(n.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),r.data=new Uint16Array((t.length-1)*6));const s=i.data,o=r.data;s[0]=0,s[1]=0,s[2]=0,s[3]=1;let a=0,c=t[0];const h=t.length;for(let u=0;u<h;u++){const f=u*4,d=c.x-t[u]?.x,p=c.y-t[u]?.y,g=Math.sqrt(d*d+p*p);c=t[u],a+=g/this._width,s[f]=a,s[f+1]=0,s[f+2]=a,s[f+3]=1}let l=0;for(let u=0;u<h-1;u++){const f=u*2;o[l++]=f,o[l++]=f+1,o[l++]=f+2,o[l++]=f+2,o[l++]=f+1,o[l++]=f+3}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let n=t[0],i,r=0,s=0;const o=this.buffers[0]?.data,a=t.length;for(let c=0;c<a;c++){const h=t[c],l=c*4;c<t.length-1?i=t[c+1]:i=h,s=-(i.x-n.x),r=i.y-n.y;const u=Math.sqrt(r*r+s*s),f=this._width/2;r/=u,s/=u,r*=f,s*=f,o[l]=h.x+r,o[l+1]=h.y+s,o[l+2]=h.x-r,o[l+3]=h.y-s,n=h}this.buffers[0]?.update()}update(){this.build()}}class _0 extends E.Mesh{constructor(t,n,i){const r=new y0(n,i);t.source.addressMode="repeat",super({geometry:r,texture:t}),this.autoUpdate=!0,this.onRender=()=>{const s=this.geometry;this.autoUpdate&&s.update()}}}class x0 extends E.MeshGeometry{constructor(t,n=200){super({positions:new Float32Array(t.length*4),uvs:new Float32Array(t.length*4),indices:new Uint32Array((t.length-1)*6)}),this.points=t,this._width=n,this.build()}build(){const t=this.points;if(!t)return;const n=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),r=this.getIndex();if(t.length<1)return;n.data.length/4!==t.length&&(n.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),r.data=new Uint16Array((t.length-1)*6));const s=t.length;let o=0,a=t[0];for(let d=0;d<s;d++){const p=a.x-t[d]?.x,g=a.y-t[d]?.y,m=Math.sqrt(p*p+g*g);a=t[d],o+=m}const c=i.data,h=r.data;c[0]=0,c[1]=0,c[2]=0,c[3]=1;let l=0,u=t[0];for(let d=0;d<s;d++){const p=d*4,g=u.x-t[d]?.x,m=u.y-t[d]?.y,_=Math.sqrt(g*g+m*m);u=t[d],l+=_/o,c[p]=l,c[p+1]=0,c[p+2]=l,c[p+3]=1}let f=0;for(let d=0;d<s-1;d++){const p=d*2;h[f++]=p,h[f++]=p+1,h[f++]=p+2,h[f++]=p+2,h[f++]=p+1,h[f++]=p+3}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let n=t[0],i,r=0,s=0;const o=this.buffers[0]?.data,a=t.length;for(let c=0;c<a;c++){const h=t[c],l=c*4;c<t.length-1?i=t[c+1]:i=h,s=-(i.x-n.x),r=i.y-n.y;const u=Math.sqrt(r*r+s*s),f=this._width/2;r/=u,s/=u,r*=f,s*=f,o[l]=h.x+r,o[l+1]=h.y+s,o[l+2]=h.x-r,o[l+3]=h.y-s,n=h}this.buffers[0]?.update()}update(){this.updateVertices()}}class v0 extends E.Mesh{constructor(t,n){const i=new x0(n,t.height);super({geometry:i,texture:t}),this.autoUpdate=!0,this.onRender=()=>{const r=this.geometry;(this.autoUpdate||r._width!==this.shader?.texture.height)&&(r._width=this.shader?.texture.height??0,r.update())}}}const w0=(e,t,n)=>i=>{switch(i.kind){case"casing":return e(i);case"cement":return t(i);case"cementSqueeze":return n(i);default:return ee(i)}},b0=e=>({exaggerationFactor:2,internalLayerOptions:Vr(e),holeOptions:Wr,casingOptions:Yr,cementOptions:qr,cementSqueezeOptions:jr,screenOptions:Zr,tubingOptions:Kr,cementPlugOptions:Qr,perforationOptions:Gr}),Re=class Re extends $n{constructor(t,n,i){super(t,n,i),this.internalLayerVisibility={holeLayerId:!0,casingLayerId:!0,completionLayerId:!0,cementLayerId:!0,pAndALayerId:!0,perforationLayerId:!0},this.cementTextureCache=null,this.cementSqueezeTextureCache=null,this.cementPlugTextureCache=null,this.holeTextureCache=null,this.screenTextureCache=null,this.tubingTextureCache=null,this.textureSymbolCacheArray=null,this.scalingFactors={height:600,zFactor:1,yScale:Ct()},this.getZFactorScaledPathForPoints=(r,s)=>{const o=c=>c*this.scalingFactors.zFactor;return(this.referenceSystem?.getCurtainPath(r,s,!0)??[]).map(c=>new E.Point(c.point[0],o(c.point[1])))},this.drawBigPolygon=(r,s=0)=>{const o=new E.Graphics;o.poly(r),o.fill(s),this.addChild(o)},this.perforationRopeAndTextureReferences=[],this.prepareSymbolRenderObject=r=>{const{exaggerationFactor:s=1}=this.options,o=r.diameter*s;return{pathPoints:this.getZFactorScaledPathForPoints(r.start,r.end),referenceDiameter:o,symbolKey:r.symbolKey}},this.drawSymbolComponent=({pathPoints:r,referenceDiameter:s,symbolKey:o})=>{const a=this.getSymbolTexture(o,s);this.drawSVGRope(r,a)},this.drawHoleSize=(r,s)=>{if(s==null)return;const o=this.getZFactorScaledPathForPoints(s.start,s.end);if(o.length===0)return;const{exaggerationFactor:a=1,holeOptions:c}=this.options,h=s.diameter*a,{rightPath:l,leftPath:u}=ye(h/2,o),f=this.getHoleTexture(c,h,r);this.drawHoleRope(o,f,r),this.drawOutline(u,l,ft(c.lineColor),Tl*a,"TopAndBottom",0)},this.drawCasing=r=>{const{casingOptions:s}=this.options,o=ft(s.solidColor),a=ft(s.lineColor);r.sections.forEach((c,h,l)=>{const u=Re.getOutlineClosureType(h,l.length-1),f=this.createCasingTexture(r.referenceDiameter);this.drawRope(c.pathPoints,f,o),c.kind==="casing-window"?this.drawCasingWindowOutline(c.leftPath,c.rightPath,s,r.casingWallWidth):this.drawOutline(c.leftPath,c.rightPath,a,r.casingWallWidth,u)})},this.generateShoe=(r,s,o,a)=>{const c=r-o,h=r,l=this.getZFactorScaledPathForPoints(c,h),u=ls(l),f=Sn(l,u,s*(a<0?-1:1)),d=l[l.length-1],p=u[u.length-1],g=us(d,p,a+s*(a<0?-1:1));return[...f,g]},this.createCementSqueezeShape=(r,s,o,a)=>{const{exaggerationFactor:c=1}=this.options;return Ku(r,s,o,a,c,this.getZFactorScaledPathForPoints)},this.createPerforationShape=(r,s,o)=>{const{exaggerationFactor:a=1}=this.options;return h0(r,s,o,a,this.getZFactorScaledPathForPoints)},this.options={...this.options,...b0(this.id),...i}}onUnmount(t){super.onUnmount(t),this.cementTextureCache=null,this.cementSqueezeTextureCache=null,this.holeTextureCache=null,this.screenTextureCache=null,this.tubingTextureCache=null,this.textureSymbolCacheArray=null}async onUpdate(t){super.onUpdate(t),this.clearLayer(),await this.preRender(),this.render()}async onRescale(t){const n=this.scalingFactors.zFactor!==t.zFactor;this.scalingFactors={height:t.height,zFactor:t.zFactor,yScale:t.yScale},super.optionsRescale(t);const i=this.yRatio(),r=t.xBounds[0]>t.xBounds[1],s=t.yBounds[0]>t.yBounds[1];this.setContainerPosition(t.xScale(0),t.yScale(0)),this.setContainerScale(t.xRatio*(r?-1:1),i*(s?-1:1)),n&&(this.clearLayer(),await this.preRender()),this.render()}async setVisibility(t,n){if(n===this.id){super.setVisibility(t,n);return}const{internalLayerOptions:i}=this.options,o=(i?Object.entries(i):[]).find(([a,c])=>c===n)?.[0];o&&(this.internalLayerVisibility[o]=t,this.clearLayer(),await this.preRender(),this.render())}getInternalLayerIds(){const{internalLayerOptions:t}=this.options;return t?Object.values(t):[]}yRatio(){const t=this.scalingFactors.yScale.domain(),i=(t[1]-t[0])*this.scalingFactors.zFactor,r=[t[0],t[0]+i];return Math.abs(this.scalingFactors.height/(r[1]-r[0]))}drawRope(t,n,i){if(t.length===0)return;const r=new E.MeshRope({texture:n,points:t,textureScale:1});r.tint=i||r.tint,this.addChild(r)}drawOutline(t,n,i,r=1,s="None",o=1){const a=t.map(u=>u.clone()).reverse(),c=n[0],h=a[0],l=new E.Graphics;l.moveTo(c.x,c.y),n.forEach(u=>l.lineTo(u.x,u.y)),(s==="None"||s==="Top")&&l.moveTo(h.x,h.y),a.forEach(u=>l.lineTo(u.x,u.y)),(s==="TopAndBottom"||s==="Top")&&l.lineTo(c.x,c.y),l.stroke({width:r,color:i,alignment:o}),this.addChild(l)}drawCasingWindowOutline(t,n,{lineColor:i,windowOptions:r},s=1){const o=!!this.referenceSystem?.options?.calculateDisplacementFromBottom,[a,c]=o?[t,n]:[n,t],[h,l]=o?[1,0]:[0,1],u=new E.Graphics,f=a[0];u.moveTo(f.x,f.y),a.forEach(g=>u.lineTo(g.x,g.y)),u.setStrokeStyle({width:s,color:ft(i),alignment:l});const d=new wn(u,{dash:[r.dashLength,r.spaceLength],color:ft(r.dashColor),width:s,alignment:h}),p=c[0];d.moveTo(p.x,p.y),c.forEach(g=>{d.lineTo(g.x,g.y)}),this.addChild(u)}async preRender(){if(!this.data||!this.referenceSystem)return;const{exaggerationFactor:t=1}=this.options,{holeSizes:n,casings:i,cements:r,completion:s,symbols:o,pAndA:a,perforations:c}=this.data;await this.updateSymbolCache(o),n.sort((g,m)=>m.diameter-g.diameter);const h=n.length>0?(sn(n,g=>g.diameter)??0)*t:Sl*t;this.internalLayerVisibility.holeLayerId&&n.forEach(g=>this.drawHoleSize(h,g)),i.sort((g,m)=>m.diameter-g.diameter);const l=i.map(g=>this.createCasingRenderObject(g)),u=r.map(g=>({kind:"cement",segments:Zu(g,i,s,n,t,this.getZFactorScaledPathForPoints),casingIds:(g.referenceIds||[]).filter(m=>m)})),[f,d]=a.reduce(([g,m],_)=>Ir(_)?[[_,...g],m]:[g,[_,...m]],[[],[]]),p=f.map(g=>({kind:"cementSqueeze",segments:this.createCementSqueezeShape(g,i,s,n),casingIds:g.referenceIds}));if(this.sortCementAndCasingRenderObjects(l,u,p).forEach(w0(g=>{this.internalLayerVisibility.casingLayerId&&(this.drawCasing(g),g.hasShoe&&this.drawShoe(g.bottom,g.referenceRadius))},g=>{if(this.internalLayerVisibility.cementLayerId){const m=this.getCementTexture();m&&this.drawComplexRope(g.segments,m)}},g=>{if(this.internalLayerVisibility.pAndALayerId){const m=this.getCementSqueezeTexture();m&&this.drawComplexRope(g.segments,m)}})),this.perforationRopeAndTextureReferences.forEach(({rope:g,texture:m})=>{g.destroyed||g.destroy({children:!0,texture:!0,textureSource:!0}),m&&m.destroy(!0)}),this.perforationRopeAndTextureReferences=[],this.internalLayerVisibility.perforationLayerId){const{perforationOptions:g}=this.options,m=c.filter(Dr),_=c.filter(Nr),x=c.filter($r);m.forEach(v=>{const S=this.createPerforationShape(v,i,n).reduce((M,b)=>(M[b.diameter]||(M[b.diameter]=[]),M[b.diameter]=[...M[b.diameter]??[],b],M),{});Object.values(S).forEach(M=>{const b=f0(v,M[0],g),C=this.drawComplexRope(M,b);C&&this.perforationRopeAndTextureReferences.push({rope:C,texture:b})})}),x.forEach(v=>{const M=this.createPerforationShape(v,i,n).map(b=>({...b,diameter:b.diameter*3})).reduce((b,C)=>(b[C.diameter]||(b[C.diameter]=[]),b[C.diameter]=[...b[C.diameter]??[],C],b),{});Object.values(M).forEach(b=>{b.forEach(C=>{const k=p0(v,c,C,g),O=this.drawComplexRope([C],k);O&&this.perforationRopeAndTextureReferences.push({rope:O,texture:k})})})}),_.forEach(v=>{const M=this.createPerforationShape(v,i,n).map(b=>({...b,diameter:b.diameter*3})).reduce((b,C)=>(b[C.diameter]||(b[C.diameter]=[]),b[C.diameter]=[...b[C.diameter]??[],C],b),{});Object.values(M).forEach(b=>{b.forEach(C=>{const k=d0(v,C,g),O=this.drawComplexRope([C],k);O&&this.perforationRopeAndTextureReferences.push({rope:O,texture:k})})})})}this.internalLayerVisibility.completionLayerId&&s.forEach(zr(g=>this.drawScreen(g),g=>this.drawTubing(g),g=>{const m=this.prepareSymbolRenderObject(g);this.drawSymbolComponent(m)})),this.internalLayerVisibility.pAndALayerId&&d.forEach(g=>{if(Rr(g)){const m=this.prepareSymbolRenderObject(g);this.drawSymbolComponent(m)}Or(g)&&this.drawCementPlug(g,i,s,n)})}async updateSymbolCache(t){if(this.textureSymbolCacheArray||(this.textureSymbolCacheArray={}),!t)return;const n=Object.keys(this.textureSymbolCacheArray),i=Object.entries(t).map(async([r,s])=>{!n.includes(r)&&this.textureSymbolCacheArray&&(this.textureSymbolCacheArray[r]=await E.Assets.load(s))});await Promise.all(i)}drawCementPlug(t,n,i,r){const{exaggerationFactor:s=1,cementPlugOptions:o}=this.options,a=Qu(t,n,i,r,s,this.getZFactorScaledPathForPoints);o&&this.drawComplexRope(a,this.getCementPlugTexture(o));const{rightPath:c,leftPath:h}=a.reduce((l,u)=>{const{leftPath:f,rightPath:d}=ye(u.diameter/2,u.points);return{rightPath:[...l.rightPath,...d],leftPath:[...l.leftPath,...f]}},{rightPath:[],leftPath:[]});this.drawOutline(h,c,ft("black"),.25,"TopAndBottom")}createCasingRenderObject(t){const{exaggerationFactor:n=1}=this.options;return c0(n,t,this.getZFactorScaledPathForPoints)}getCementPlugTexture(t){return this.cementPlugTextureCache||(this.cementPlugTextureCache=r0(t)),this.cementPlugTextureCache}drawSVGRope(t,n){if(t.length===0)return;const i=new v0(n,t);this.addChild(i)}getSymbolTexture(t,n){const i=this.textureSymbolCacheArray?.[t]?.source;return i?new E.Texture({source:i,orig:new E.Rectangle(0,0,0,n),rotate:E.groupD8.MAIN_DIAGONAL}):void 0}drawHoleRope(t,n,i){if(t.length===0)return;const r=new E.MeshRope({texture:n,points:t,textureScale:i/xt});this.addChild(r)}getHoleTexture(t,n,i){const r=xt,s=r,o=r,a=n/i*r;this.holeTextureCache||(this.holeTextureCache=t0(t,o,s));const c=this.holeTextureCache.source,h=(s-a)/2,l=new E.Rectangle(0,h,o,a);return new E.Texture({source:c,frame:l})}sortCementAndCasingRenderObjects(t,n,i){let r=0;const{result:s}=t.reduce((o,a)=>{const c=o.remainingCement.find(l=>l.casingIds.includes(a.id)),h=o.remainingCementSqueezes.filter(l=>l.casingIds.includes(a.id));return c&&(c.zIndex=r++),h.forEach(l=>l.zIndex=r++),a.zIndex=r++,{result:[...o.result,c,a,...h],remainingCement:o.remainingCement.filter(l=>l!==c),remainingCementSqueezes:o.remainingCementSqueezes.filter(l=>!h.includes(l))}},{result:[],remainingCement:n,remainingCementSqueezes:i});return s.filter(o=>o!=null).sort((o,a)=>o.zIndex-a.zIndex)}drawComplexRope(t,n){if(t.length===0)return;const i=new m0(n,t);return this.addChild(i),i}createCasingTexture(t){return new E.Texture({source:E.Texture.WHITE.source,orig:new E.Rectangle(0,0,16,t)})}drawShoe(t,n){const{exaggerationFactor:i=1,casingOptions:r}=this.options,s=r.shoeSize.width*i,o=r.shoeSize.length*i,a=this.generateShoe(t,n,o,s),c=this.generateShoe(t,n,o,-s);this.drawBigPolygon(c),this.drawBigPolygon(a)}getCementTexture(){if(!this.cementTextureCache){const{cementOptions:t}=this.options;t&&(this.cementTextureCache=i0(t))}return this.cementTextureCache}getCementSqueezeTexture(){if(!this.cementSqueezeTextureCache){const{cementSqueezeOptions:t}=this.options;t&&(this.cementSqueezeTextureCache=s0(t))}return this.cementSqueezeTextureCache}drawScreen({start:t,end:n,diameter:i}){const{exaggerationFactor:r=1,screenOptions:s}=this.options,o=r*i,a=this.getZFactorScaledPathForPoints(t,n),{leftPath:c,rightPath:h}=ye(o/2,a),l=this.getScreenTexture();l&&(this.drawCompletionRope(a,l,o),this.drawOutline(c,h,ft(s.lineColor),Al*r,"TopAndBottom"))}drawTubing({diameter:t,start:n,end:i}){const{exaggerationFactor:r=1,tubingOptions:s}=this.options,o=r*t,a=this.getZFactorScaledPathForPoints(n,i),c=this.getTubingTexture(s);this.drawCompletionRope(a,c,o)}getTubingTexture(t){return this.tubingTextureCache||(this.tubingTextureCache=n0(t)),this.tubingTextureCache}getScreenTexture(){if(!this.screenTextureCache){const{screenOptions:t}=this.options;t&&(this.screenTextureCache=e0(t))}return this.screenTextureCache}drawCompletionRope(t,n,i){if(t.length===0)return;const r=new _0(n,t,i);this.addChild(r)}};Re.getOutlineClosureType=(t,n)=>t===0?t===n?"TopAndBottom":"Top":t===n?"Bottom":"None";let Tn=Re;class S0 extends bt{onMount(t){super.onMount(t)}onUpdate(t){super.onUpdate(t),this.clearCanvas(),this.render()}onRescale(t){super.onRescale(t),this.setTransform(t),this.render()}render(){if(!this.data||!this.ctx||!this.data.image)return;const{ctx:t}=this,{options:n,image:i}=this.data;this.clearCanvas(),t.drawImage(i,n.x,n.y,n.width,n.height)}}function kt(e){return function(){return e}}const Oi=1e-12,An=Math.PI,Mn=2*An,Tt=1e-6,T0=Mn-Tt;function ps(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function A0(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return ps;const n=10**t;return function(i){this._+=i[0];for(let r=1,s=i.length;r<s;++r)this._+=Math.round(arguments[r]*n)/n+i[r]}}class M0{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?ps:A0(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,i,r){this._append`Q${+t},${+n},${this._x1=+i},${this._y1=+r}`}bezierCurveTo(t,n,i,r,s,o){this._append`C${+t},${+n},${+i},${+r},${this._x1=+s},${this._y1=+o}`}arcTo(t,n,i,r,s){if(t=+t,n=+n,i=+i,r=+r,s=+s,s<0)throw new Error(`negative radius: ${s}`);let o=this._x1,a=this._y1,c=i-t,h=r-n,l=o-t,u=a-n,f=l*l+u*u;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(f>Tt)if(!(Math.abs(u*c-h*l)>Tt)||!s)this._append`L${this._x1=t},${this._y1=n}`;else{let d=i-o,p=r-a,g=c*c+h*h,m=d*d+p*p,_=Math.sqrt(g),x=Math.sqrt(f),v=s*Math.tan((An-Math.acos((g+f-m)/(2*_*x)))/2),A=v/x,S=v/_;Math.abs(A-1)>Tt&&this._append`L${t+A*l},${n+A*u}`,this._append`A${s},${s},0,0,${+(u*d>l*p)},${this._x1=t+S*c},${this._y1=n+S*h}`}}arc(t,n,i,r,s,o){if(t=+t,n=+n,i=+i,o=!!o,i<0)throw new Error(`negative radius: ${i}`);let a=i*Math.cos(r),c=i*Math.sin(r),h=t+a,l=n+c,u=1^o,f=o?r-s:s-r;this._x1===null?this._append`M${h},${l}`:(Math.abs(this._x1-h)>Tt||Math.abs(this._y1-l)>Tt)&&this._append`L${h},${l}`,i&&(f<0&&(f=f%Mn+Mn),f>T0?this._append`A${i},${i},0,1,${u},${t-a},${n-c}A${i},${i},0,1,${u},${this._x1=h},${this._y1=l}`:f>Tt&&this._append`A${i},${i},0,${+(f>=An)},${u},${this._x1=t+i*Math.cos(s)},${this._y1=n+i*Math.sin(s)}`)}rect(t,n,i,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${i=+i}v${+r}h${-i}Z`}toString(){return this._}}function P0(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const i=Math.floor(n);if(!(i>=0))throw new RangeError(`invalid digits: ${n}`);t=i}return e},()=>new M0(t)}function C0(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function gs(e){this._context=e}gs.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function ms(e){return new gs(e)}function L0(e){return e[0]}function k0(e){return e[1]}function E0(e,t){var n=kt(!0),i=null,r=ms,s=null,o=P0(a);e=typeof e=="function"?e:e===void 0?L0:kt(e),t=typeof t=="function"?t:t===void 0?k0:kt(t);function a(c){var h,l=(c=C0(c)).length,u,f=!1,d;for(i==null&&(s=r(d=o())),h=0;h<=l;++h)!(h<l&&n(u=c[h],h,c))===f&&((f=!f)?s.lineStart():s.lineEnd()),f&&s.point(+e(u,h,c),+t(u,h,c));if(d)return s=null,d+""||null}return a.x=function(c){return arguments.length?(e=typeof c=="function"?c:kt(+c),a):e},a.y=function(c){return arguments.length?(t=typeof c=="function"?c:kt(+c),a):t},a.defined=function(c){return arguments.length?(n=typeof c=="function"?c:kt(!!c),a):n},a.curve=function(c){return arguments.length?(r=c,i!=null&&(s=r(i)),a):r},a.context=function(c){return arguments.length?(c==null?i=s=null:s=r(i=c),a):i},a}function zi(){}function Pn(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function Xe(e){this._context=e}Xe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Pn(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Pn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function F0(e){return new Xe(e)}function ys(e){this._context=e}ys.prototype={areaStart:zi,areaEnd:zi,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Pn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function R0(e){return new ys(e)}function _s(e,t){this._basis=new Xe(e),this._beta=t}_s.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var e=this._x,t=this._y,n=e.length-1;if(n>0)for(var i=e[0],r=t[0],s=e[n]-i,o=t[n]-r,a=-1,c;++a<=n;)c=a/n,this._basis.point(this._beta*e[a]+(1-this._beta)*(i+c*s),this._beta*t[a]+(1-this._beta)*(r+c*o));this._x=this._y=null,this._basis.lineEnd()},point:function(e,t){this._x.push(+e),this._y.push(+t)}};const I0=(function e(t){function n(i){return t===1?new Xe(i):new _s(i,t)}return n.beta=function(i){return e(+i)},n})(.85);function Di(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function qn(e,t){this._context=e,this._k=(1-t)/6}qn.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:Di(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:Di(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const O0=(function e(t){function n(i){return new qn(i,t)}return n.tension=function(i){return e(+i)},n})(0);function z0(e,t,n){var i=e._x1,r=e._y1,s=e._x2,o=e._y2;if(e._l01_a>Oi){var a=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,c=3*e._l01_a*(e._l01_a+e._l12_a);i=(i*a-e._x0*e._l12_2a+e._x2*e._l01_2a)/c,r=(r*a-e._y0*e._l12_2a+e._y2*e._l01_2a)/c}if(e._l23_a>Oi){var h=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,l=3*e._l23_a*(e._l23_a+e._l12_a);s=(s*h+e._x1*e._l23_2a-t*e._l12_2a)/l,o=(o*h+e._y1*e._l23_2a-n*e._l12_2a)/l}e._context.bezierCurveTo(i,r,s,o,e._x2,e._y2)}function xs(e,t){this._context=e,this._alpha=t}xs.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,i=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:z0(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const D0=(function e(t){function n(i){return t?new xs(i,t):new qn(i,0)}return n.alpha=function(i){return e(+i)},n})(.5);function Ni(e){return e<0?-1:1}function $i(e,t,n){var i=e._x1-e._x0,r=t-e._x1,s=(e._y1-e._y0)/(i||r<0&&-0),o=(n-e._y1)/(r||i<0&&-0),a=(s*r+o*i)/(i+r);return(Ni(s)+Ni(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(a))||0}function Bi(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function en(e,t,n){var i=e._x0,r=e._y0,s=e._x1,o=e._y1,a=(s-i)/3;e._context.bezierCurveTo(i+a,r+a*t,s-a,o-a*n,s,o)}function Fe(e){this._context=e}Fe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:en(this,this._t0,Bi(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,en(this,Bi(this,n=$i(this,e,t)),n);break;default:en(this,this._t0,n=$i(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function vs(e){this._context=new ws(e)}(vs.prototype=Object.create(Fe.prototype)).point=function(e,t){Fe.prototype.point.call(this,t,e)};function ws(e){this._context=e}ws.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,i,r,s){this._context.bezierCurveTo(t,e,i,n,s,r)}};function N0(e){return new Fe(e)}function $0(e){return new vs(e)}function bs(e){this._context=e}bs.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var i=Hi(e),r=Hi(t),s=0,o=1;o<n;++s,++o)this._context.bezierCurveTo(i[0][s],r[0][s],i[1][s],r[1][s],e[o],t[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function Hi(e){var t,n=e.length-1,i,r=new Array(n),s=new Array(n),o=new Array(n);for(r[0]=0,s[0]=2,o[0]=e[0]+2*e[1],t=1;t<n-1;++t)r[t]=1,s[t]=4,o[t]=4*e[t]+2*e[t+1];for(r[n-1]=2,s[n-1]=7,o[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)i=r[t]/s[t-1],s[t]-=i,o[t]-=i*o[t-1];for(r[n-1]=o[n-1]/s[n-1],t=n-2;t>=0;--t)r[t]=(o[t]-r[t+1])/s[t];for(s[n-1]=(e[n]+r[n-1])/2,t=0;t<n-1;++t)s[t]=2*e[t+1]-r[t+1];return[r,s]}function B0(e){return new bs(e)}function Ue(e,t){this._context=e,this._t=t}Ue.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function H0(e){return new Ue(e,.5)}function X0(e){return new Ue(e,0)}function U0(e){return new Ue(e,1)}const V0=.7,W0=.9,Y0=1;class G0 extends Fr{constructor(t,n){super(t,n),this.options={...this.options,...n},this.render=this.render.bind(this)}onUpdate(t){super.onUpdate(t),this.render()}onRescale(t){super.onRescale(t),this.elm&&(this.rescaleEvent=t,this.render())}render(){const{strokeWidth:t,stroke:n}=this.options;if(!this.elm)return;this.elm.select("g").remove();const i=this.data||this.referenceSystem&&this.referenceSystem.projectedPath;!i||!this.rescaleEvent||this.elm.append("g").attr("class","well-path").append("path").attr("d",this.renderWellborePath(i)).attr("stroke-width",t||"2px").attr("stroke",n||"red").attr("fill","none")}renderWellborePath(t){if(this.rescaleEvent!=null){const{xScale:n,yScale:i}=this.rescaleEvent,r=t.map(c=>[n(c[0]),i(c[1])]);let s;const{curveType:o,tension:a}=this.options;switch(o){default:case"curveCatmullRom":s=D0.alpha(a||V0);break;case"curveLinear":s=ms;break;case"curveBasis":s=F0;break;case"curveBasisClosed":s=R0;break;case"curveBundle":s=I0.beta(a||Y0);break;case"curveCardinal":s=O0.tension(a||W0);break;case"curveMonotoneX":s=N0;break;case"curveMonotoneY":s=$0;break;case"curveNatural":s=B0;break;case"curveStep":s=H0;break;case"curveStepAfter":s=U0;break;case"curveStepBefore":s=X0;break}return E0().curve(s)(r)??""}return""}}const Xi=(e,t)=>{switch(t.lineType){case"wavy":return e.wavy(t);case"dashed":return e.dashed(t);case"solid":return e.solid(t);default:return ee(t.lineType)}};class q0 extends bt{constructor(){super(...arguments),this.yScale=null,this.xScale=null}onMount(t){super.onMount(t)}onUpdate(t){super.onUpdate(t),this.clearCanvas(),this.render()}onRescale(t){super.onRescale(t),this.yScale=t.yScale,this.xScale=t.xScale,this.resetTransform(),this.render()}drawDashed(t){const{ctx:n}=this,{canvas:i}=this;if(n!=null&&i!=null){const r=this.yScale?.(t.depth);n.save(),n.strokeStyle=t.color,this.setCtxLineStyle(n,t),this.setCtxLineWidth(n,t),n.beginPath(),n.moveTo(0,r),n.lineTo(i.width,r),n.stroke(),n.restore(),t.text&&this.drawText(n,t,n.canvas.width,r)}}drawSolid(t){const{ctx:n}=this,{canvas:i}=this,r=this.yScale(t.depth);n!=null&&i!=null&&(n.save(),n.strokeStyle=t.color,this.setCtxLineStyle(n,t),this.setCtxLineWidth(n,t),n.beginPath(),n.moveTo(0,r),n.lineTo(i.width,r),n.stroke(),n.restore(),t.text&&this.drawText(n,t,n.canvas.width,r))}drawWavy(t){const{ctx:s,canvas:o}=this;if(this.xScale!=null&&this.yScale!=null&&o!=null&&s!=null){const a=ke(4,2.5,500,this.yScale),c=a*2,h=this.yScale(t.depth)-a,l=Math.ceil(o.width/c)+1,u=this.xScale(0)%c;s.save(),s.strokeStyle=t.color,this.setCtxLineStyle(s,t),this.setCtxLineWidth(s,t);for(let f=-1;f<l;f++)s.beginPath(),s.arc(f*c+u+a,h,a,0,Math.PI),s.stroke();s.restore(),t.text&&this.drawText(s,t,s.canvas.width,h)}}drawText(t,n,i,r){const s=n.textColor||"#000",o=n.fontSize||"10px sans-serif",a=10;t.save(),t.strokeStyle=s,t.font=o,t.textAlign="end",t.textBaseline="bottom",t.fillText(n.text??"",i-a,r),t.restore()}setCtxLineStyle(t,n){Xi({solid:()=>{t.setLineDash([])},dashed:()=>{t.setLineDash([8,10])},wavy:()=>{t.setLineDash([])}},n)}setCtxLineWidth(t,n){t.lineWidth=n.lineWidth||1}render(){!this.ctx||!this.yScale||!this.xScale||requestAnimationFrame(()=>{this.clearCanvas(),this.data?.forEach(t=>{Xi({solid:n=>this.drawSolid(n),dashed:n=>this.drawDashed(n),wavy:n=>this.drawWavy(n)},t)})})}}class Ss{constructor(t,n,i){if(this.layers=[],this.createAxis=r=>{const{container:s}=this;this._svgContainer=j(s).append("div").attr("class","axis").style("position","absolute").style("z-index","10").style("pointer-events","none");const o=this._svgContainer.append("svg").attr("height",`${s.offsetHeight}px`).attr("width",`${s.offsetWidth}px`),a=!0;return new nr(o,a,r.xLabel,r.yLabel,r.unitOfMeasure)},this.container=t,this.layerContainer=document.createElement("div"),this.layerContainer.className="layer-container",this.container.appendChild(this.layerContainer),this.adjustToSize(+(this.container.getAttribute("width")??0),+(this.container.getAttribute("height")??0)),this._zoomPanHandler=new Cr(t,r=>this.rescale(r)),n){const{xMin:r,xMax:s,yMin:o,yMax:a,xBounds:c,yBounds:h}=n;r!==void 0&&s!==void 0&&o!==void 0&&a!==void 0&&this._zoomPanHandler.setBounds([r,s],[o,a]),c&&h&&this._zoomPanHandler.setBounds(c,h)}else this._zoomPanHandler.setBounds([0,1],[0,1]);i&&(this._axis=this.createAxis(i)),this.rescale=this.rescale.bind(this)}addLayers(t){return t.forEach(n=>this.addLayer(n)),this}getLayers(){return this.layers}clearAllData(t=!0){return this.layers.forEach(n=>n.clearData(t)),this}addLayer(t,n){return this.layers.push(t),this.initLayer(t,n),this}removeLayer(t){const n=this.layers.find(i=>i.id===t);return n&&(n.onUnmount(),this.layers=this.layers.filter(i=>i.id!==t)),this}removeAllLayers(){const{layers:t}=this;return t.forEach(n=>{this.removeLayer(n.id)}),this}getLayer(t){return this.layers.find(n=>n.id===t||n.getInternalLayerIds().includes(t))}initLayer(t,n){const i={elm:this.layerContainer};t.onMount(i);const r=this.zoomPanHandler.currentStateAsEvent();if(t.onUpdate({...r,...n}),t.onRescale(r),this._svgContainer){const s=this.layers.length>0?this.layers.reduce((o,a)=>o.order>a.order?o:a).order:1;this._svgContainer.style("z-index",`${s+1}`)}return this}showLayer(t){const n=this.getLayer(t);return n?(n.setVisibility(!0,t),n.onRescale(this.zoomPanHandler.currentStateAsEvent()),this):this}hideLayer(t){const n=this.getLayer(t);return n?(n.setVisibility(!1,t),n.onRescale(this.zoomPanHandler.currentStateAsEvent()),this):this}adjustToSize(t,n){const i=Math.max(this._axis?t-Lr:t,0),r=Math.max(this._axis?n-kr:n,0);if(this._axis){const s={width:t,height:n};this._axis.onResize(s)}if(this.layers){const s={width:i,height:r};this.layers.forEach(o=>o.onResize(s))}this._zoomPanHandler&&this._zoomPanHandler.adjustToSize(i,r,!0)}setReferenceSystem(t){this.layers.forEach(n=>n.referenceSystem=t)}showAxis(){return this._axis?.show(),this}hideAxis(){return this._axis?.hide(),this}showAxisLabels(){return this._axis?.showLabels(),this}hideAxisLabels(){return this._axis?.hideLabels(),this}setAxisOffset(t,n){return this._axis&&(this._axis.offsetX=t,this._axis.offsetY=n,this.layers.filter(r=>r instanceof me).forEach(r=>{r.offsetX=t,r.offsetY=n})),this}setXAxisOffset(t){return this._axis&&(this._axis.offsetX=t,this.layers.filter(i=>i instanceof me).forEach(i=>{i.offsetX=t})),this}setYAxisOffset(t){return this._axis&&(this._axis.offsetY=t,this.layers.filter(i=>i instanceof me).forEach(i=>{i.offsetY=t})),this}setZoomLevelBoundary(t){return this._zoomPanHandler.setZoomLevelBoundary(t),this}setMaxZoomLevel(t){return this._zoomPanHandler.setMaxZoomLevel(t),this}setMinZoomLevel(t){return this._zoomPanHandler.setMinZoomLevel(t),this}destroy(){return this.removeAllLayers(),this.layerContainer.remove(),this._axis=void 0,this._svgContainer=void 0,this}get zoomPanHandler(){return this._zoomPanHandler}get axis(){return this._axis}rescale(t){this._axis&&this._axis.onRescale(t),this.layers&&this.layers.forEach(n=>n.isVisible===!0?n.onRescale(t):{})}}class j0{constructor(t,n){this.elements={},this.listeners={},this.enabled=!0;const i=j(n);this.elm=i.append("div").attr("id","overlay").style("z-index","11").style("position","absolute"),this.source=this.elm.node()??void 0;const{elm:r}=this;r.on("resize",s=>{const{width:o,height:a}=s.detail;r.style("width",`${o}px`).style("height",`${a}px`),this.enabled&&Object.keys(this.listeners).forEach(c=>{const h=this.elements[c]??void 0,l=this.listeners[c];l&&l.onResize&&requestAnimationFrame(()=>l.onResize?.({target:h,source:this.source,caller:t,width:o,height:a}))})}),r.on("mousemove",s=>{if(!this.enabled)return;const[o,a]=mt(s,this.elm.node());Object.keys(this.listeners).forEach(c=>{const h=this.elements[c]??void 0,l=this.listeners[c];l&&l.onMouseMove&&requestAnimationFrame(()=>l.onMouseMove?.({x:o,y:a,target:h,source:this.source,caller:t}))})}),r.on("mouseout",()=>{this.enabled&&Object.keys(this.listeners).forEach(s=>{const o=this.elements[s]||void 0,a=this.listeners[s];a&&a.onMouseExit&&requestAnimationFrame(()=>a.onMouseExit?.({target:o,source:this.source,caller:t}))})})}create(t,n){const i=this.elm.append("div").style("position","relative").style("pointer-events","none").node();if(i!=null)return this.elements[t]=i,n&&(this.listeners[t]=n),i}register(t,n){this.listeners[t]=n}remove(t){const n=this.elements[t];n&&(j(n).remove(),delete this.elements[t]),delete this.listeners[t]}setZIndex(t){this.elm.style("z-index",t)}destroy(){this.source?.remove()}}const Z0=(e,t)=>new j0(e,t);class K0{constructor(t){const{container:n,axisOptions:i,scaleOptions:r,referenceSystem:s,layers:o,path:a}=t;this._referenceSystem=s||a&&new zt(a),this._overlay=Z0(this,n),this.layerManager=new Ss(this._overlay.elm.node(),r,i),o&&(this.layerManager.addLayers(o),this.setOverlayZIndex(o))}setReferenceSystem(t){return this._referenceSystem=t,this.layerManager.setReferenceSystem(t),this}updatePath(t,n){return this.setReferenceSystem(new zt(t,n)),this}clearAllData(t=!0){return this.layerManager.clearAllData(t),this}addLayer(t,n){return this.layerManager.addLayer(t,n),this.setOverlayZIndex(this.layerManager.getLayers()),this}removeLayer(t){return this.layerManager.removeLayer(t),this}removeAllLayers(){return this.layerManager.removeAllLayers(),this}getLayer(t){return this.layerManager.getLayer(t)}showLayer(t){return this.layerManager.showLayer(t),this}hideLayer(t){return this.layerManager.hideLayer(t),this}adjustToSize(t,n){this.layerManager.adjustToSize(t,n);const i={width:Math.max(t-Lr,0),height:Math.max(n-kr,0)};return this.overlay.elm.dispatch("resize",{detail:i,bubbles:!0,cancelable:!0}),this}setViewport(t,n,i,r){return this.zoomPanHandler.setViewport(t,n,i,r),this}setBounds(t,n){return this.zoomPanHandler.setBounds(t,n),this}showAxis(){return this.layerManager.showAxis(),this}hideAxis(){return this.layerManager.hideAxis(),this}showAxisLabels(){return this.layerManager.showAxisLabels(),this}hideAxisLabels(){return this.layerManager.hideAxisLabels(),this}setAxisOffset(t,n){return this.layerManager.setAxisOffset(t,n),this}setXAxisOffset(t){return this.layerManager.setXAxisOffset(t),this}setYAxisOffset(t){return this.layerManager.setYAxisOffset(t),this}setZoomLevelBoundary(t){return this.zoomPanHandler.setZoomLevelBoundary(t),this}setMaxZoomLevel(t){return this.zoomPanHandler.setMaxZoomLevel(t),this}setMinZoomLevel(t){return this.zoomPanHandler.setMinZoomLevel(t),this}destroy(){return this.layerManager.destroy(),this._overlay.destroy(),this._referenceSystem=void 0,this}getHighestZIndex(t){return t.length>0?t.reduce((i,r)=>i.order>r.order?i:r).order:1}setOverlayZIndex(t){const n=this.getHighestZIndex(t);this.overlay.setZIndex(n+2)}get overlay(){return this._overlay}get referenceSystem(){return this._referenceSystem}get zoomPanHandler(){return this.layerManager.zoomPanHandler}get axis(){return this.layerManager.axis}get currentStateAsEvent(){return this.zoomPanHandler.currentStateAsEvent()}}exports.Axis=nr;exports.CalloutCanvasLayer=Yl;exports.CanvasLayer=bt;exports.Controller=K0;exports.GeomodelCanvasLayer=Kl;exports.GeomodelLabelsLayer=$u;exports.GeomodelLayerV2=Hu;exports.GridLayer=me;exports.HTMLLayer=Cl;exports.ImageLayer=Uu;exports.IntersectionReferenceSystem=zt;exports.Layer=te;exports.LayerManager=Ss;exports.PixiLayer=$n;exports.PixiRenderApplication=Ll;exports.ReferenceLineLayer=q0;exports.SVGLayer=Fr;exports.SchematicLayer=Tn;exports.SeismicCanvasLayer=S0;exports.WellborepathLayer=G0;exports.ZoomPanHandler=Cr;exports.assertNever=ee;exports.calcSize=ke;exports.defaultCasingOptions=Yr;exports.defaultCementOptions=qr;exports.defaultCementPlugOptions=Qr;exports.defaultCementSqueezeOptions=jr;exports.defaultHoleOptions=Wr;exports.defaultInternalLayerOptions=Vr;exports.defaultPerforationOptions=Gr;exports.defaultScreenOptions=Zr;exports.defaultTubingOptions=Kr;exports.findIndexOfSample=Bn;exports.findSampleAtPos=yt;exports.foldCompletion=zr;exports.foldPerforationSubKind=K;exports.generateProjectedTrajectory=Eu;exports.generateProjectedWellborePath=ku;exports.generateSeismicSliceImage=uu;exports.generateSurfaceData=pu;exports.getOverlap=Ol;exports.getOverlapOffset=vn;exports.getPicksData=eu;exports.getSeismicInfo=lu;exports.getSeismicOptions=hu;exports.hasFracLines=Nr;exports.hasPacking=Dr;exports.hasSpikes=$r;exports.intersect=Ur;exports.isCementPlug=Or;exports.isCementSqueeze=Ir;exports.isOpenHoleFracPack=Rl;exports.isOverlapping=ns;exports.isOverlappingHorizontally=Il;exports.isPAndASymbol=Rr;exports.isSubKindCasedHoleFracPack=Hr;exports.isSubKindCasedHoleFracturation=Xr;exports.isSubKindPerforation=Fl;exports.isSubkindCasedHoleGravelPack=Br;exports.pixelsPerUnit=es;exports.shouldPerforationStartAtCasingDiameter=El;exports.shouldPerforationStartAtHoleDiameter=kl;exports.transformFormationData=au;
|
|
15
2
|
//# sourceMappingURL=index.cjs.map
|