@equinor/esv-intersection 3.0.6 → 3.0.8
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/datautils/findsample.d.ts.map +1 -1
- package/dist/datautils/seismicimage.d.ts +1 -1
- package/dist/datautils/seismicimage.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +23 -19
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -2
- package/src/datautils/findsample.ts +19 -11
- package/src/datautils/seismicimage.ts +4 -4
package/dist/index.cjs
CHANGED
|
@@ -11,5 +11,5 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
11
11
|
|
|
12
12
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
13
13
|
and limitations under the License.
|
|
14
|
-
***************************************************************************** */var cn=function(e,t){return cn=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])},cn(e,t)};function Ln(e,t){function n(){this.constructor=e}cn(e,t),e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var hn=function(){return hn=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},hn.apply(this,arguments)};function _i(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 ln(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]:_i(r,s),o=e<a-1?t[e+2]:_i(s,r)}return[i,r,s,o]}function na(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 ia(e,t){for(var n=0;n<e.length;n++)e[n]=t;return e}function ra(e,t){for(var n=0;n<e.length;n++)e[n]=t(e[n],n);return e}function sa(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 be(e,t){t=t||new Array(e.length);for(var n=0;n<e.length;n++)t[n]=e[n];return t}function K(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e<t?t:e>n?n:e}function un(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 it=Math.pow(2,-42);function xi(e){var t=Math.pow(Math.abs(e),.3333333333333333);return e<0?-t:t}function er(e,t,n){if(Math.abs(e)<it)return Math.abs(t)<it?[]:[-n/t];var i=t*t-4*e*n;return Math.abs(i)<it?[-t/(2*e)]:i>0?[(-t+Math.sqrt(i))/(2*e),(-t-Math.sqrt(i))/(2*e)]:[]}function oa(e,t,n,i){if(Math.abs(e)<it)return er(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)<it)r=[xi(-o)];else if(Math.abs(o)<it)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)<it)r=[-1.5*o/s,3*o/s];else if(a>0)r=[(c=xi(-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 aa(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 ae(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 nr(e,t){for(var n=0,i=0;i<e.length;i++)n+=(e[i]-t[i])*(e[i]-t[i]);return n}function Et(e){for(var t=0,n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t)}function Se(e,t){var n=nr(e,t);return n===0?0:Math.sqrt(n)}function yt(e,t){var n=t?be(e,t):e,i=sa(n,function(s,o){return s+Math.pow(o,2)}),r=Math.sqrt(i);return r===0?ia(n,0):ra(n,function(s){return s/r})}function ca(e,t){if(e.length>2)throw Error("Only supported for 2d vectors");var n=t?be(e,t):e,i=-n[1];return n[1]=n[0],n[0]=i,n}function ha(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(nr(c,h),.5*r)},o=s(t,e),a=s(n,t)+o;return[0,o,a,s(i,n)+a]}function la(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?ha(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],p=t[h],d=n[h],g=i[h];if(a){var y=a[0],_=a[1],x=a[2],v=a[3];_-x!=0&&(y-_!=0&&y-x!=0&&(l=(1-s)*(x-_)*((f-p)/(y-_)-(f-d)/(y-x)+(p-d)/(_-x))),_-v!=0&&x-v!=0&&(u=(1-s)*(x-_)*((p-d)/(_-x)-(p-g)/(_-v)+(d-g)/(x-v))))}else l=(1-s)*(d-f)*.5,u=(1-s)*(g-p)*.5;var P=2*p-2*d+l+u,b=-3*p+3*d-2*l-u,S=l,T=p;c[h]=[P,b,S,T]}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 qe(e,t){return 6*t[0]*e+2*t[1]}function ua(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]:oa(n,i,r,s).filter(function(o){return o>-it&&o<=1+it}).map(function(o){return K(o,0,1)})}function fn(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 ir=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=na(n,this.points,this.closed),s=r.index;return fn(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=ln(t,this.points,this.closed),i=la(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}(),fa=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 Ln(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+=Se(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=un(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+Se(this.evaluateForT(Ft,h),this.evaluateForT(Ft,n)))/s},t}(ir),rr=[[[-.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]]],vi=rr.length+5,da=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>vi)throw Error("Order for Gaussian Quadrature must be in the range of ".concat(5," and ").concat(vi,"."));return rr[o-5]}(n),s._nSamples=i,s}return Ln(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=Et(fn(Rt,c,o)),l=h===0?0:1/h;this.tension>.95&&(l=K(l,-1,1)),s.push(l)}var u=i-1,f=[],p=[],d=r[0],g=s[0],y=1/u;for(a=0;a<u;++a){var _=d,x=(d=r[a+1])-_,v=g,P=s[a+1];g=P;var b=y/x,S=(v+P-2*b)/(x*x),T=(3*b-2*v-P)/x;f.push(S),p.push(T)}this._cache.samples.set(n,[r,s,p,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]*Et(fn(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,un(i,o)),u=l*r;if(o[l]===i)return u;var f=a[l],p=h[l],d=c[l],g=i-o[l];return((p*g+d)*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=un(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}(ir),kn=function(){function e(t,n){n===void 0&&(n={});var i=this;this._cache=new Map;var r=(n=hn({tension:.5,alpha:0,closed:!1},n)).arcDivisions?new fa(n.arcDivisions,function(){return i._invalidateCache()}):new da(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?K(t,0,1):t)},e.prototype.getPositionFromTime=function(t,n){return n===void 0&&(n=!1),this._curveMapper.getU(n?K(t,0,1):t)},e.prototype.getPositionFromLength=function(t,n){n===void 0&&(n=!1);var i=n?K(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?K(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=K(t,0,1))===0?be(this.points[0],n):t===1?be(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=K(this.getTimeFromPosition(t),0,1);return this.getTangentAtTime(i,n)},e.prototype.getTangentAtTime=function(t,n){return yt(this._curveMapper.evaluateForT(Rt,t,n))},e.prototype.getNormalAt=function(t,n){var i=K(this.getTimeFromPosition(t),0,1);return this.getNormalAtTime(i,n)},e.prototype.getNormalAtTime=function(t,n){var i=yt(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=yt(this._curveMapper.evaluateForT(qe,t));return yt(ae(ae(i,s),i),r)}},e.prototype.getCurvatureAt=function(t){var n=K(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(qe,t),r=yt(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=Et(n),h=ae(n,i);o=yt(ae(h,n)),c!==0&&(s=Et(h)/Math.pow(c,3))}else{c=Et(n);var l=Et(i),u=Math.pow(c,3),f=aa(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=K(this.getTimeFromPosition(t),0,1);return this._curveMapper.evaluateForT(Rt,i,n)},e.prototype.getSecondDerivativeAt=function(t,n){var i=K(this.getTimeFromPosition(t),0,1);return this._curveMapper.evaluateForT(qe,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 p=function(_){var x=ln(_-1,d.points,d.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(d.tension<1){var P=h*s-(_-1),b=h*o-(_-1),S=function(L){return L>-it&&L<=1+it&&(_-1!==l||L>P)&&(_!==u||L<b)},T=d._curveMapper.getCoefficients(_-1),R=function(L){var N=T[L];er(3*N[0],2*N[1],N[2]).filter(S).forEach(function(C){var O=Ft(C,T[L]);O<i[L]&&(i[L]=O),O>r[L]&&(r[L]=O)})};for(v=0;v<T.length;v++)R(v)}},d=this,g=l+1;g<=u;g++)p(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){var i=this;if(n===void 0&&(n=1e-5),n<=0||!Number.isFinite(n))throw Error("Invalid threshold. Must be a number greater than zero!");var r=10*this.points.length-1,s=new Array(t.length),o=1/0,a=0,c=this.createLookupTable(r);Array.from(c.keys()).forEach(function(f){var p=c.get(f),d=Se(t,p);if(d<o)return o=d,a=f,!0});for(var h=this.getTimeFromPosition(a),l=function(f){if(f>=0&&f<=1){i.getPointAtTime(f,s);var p=Se(t,s);if(p<o)return o=p,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=ln(h,this.points,this.closed),u=l[1],f=l[2],p=this._curveMapper.getCoefficients(h),d=void 0,g=void 0;if(u[s]<f[s]?(d=u[s],g=f[s]):(d=f[s],g=u[s]),t-r<=g&&t+r>=d){var y=ua(t,p[s]);i<0?y.sort(function(v,P){return P-v}):i>=0&&y.sort(function(v,P){return v-P});for(var _=0;_<y.length;_++){var x=(y[_]+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===void 0&&(n=0),i===void 0&&(i=1),!t||t<=1)throw Error("Invalid arguments passed to createLookupTable(). You must specify at least 2 samples.");if(!(n<0||i>1||i<n)){var r="lut_".concat(t,"_").concat(n,"_").concat(i);if(!this._cache.has(r)){for(var s=new Map,o=0;o<t;o++){var a=n===0&&i===1?o/(t-1):n+o/(t-1)*(i-n),c=this.getPointAt(a);s.set(a,c)}this._cache.set(r,s)}return this._cache.get(r)}},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)){if(n<=1)throw Error("Invalid arguments passed to forEach(). You must specify at least 2 samples.");for(var a=n,c=0;c<n;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 p=s.getTimeFromPosition(u),d=t({u,t:p,i:f,prev:l});l={u,t:p,i:f,value:d}})},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)){if(n<=1)throw Error("Invalid arguments passed to map(). You must specify at least 2 samples.");for(var a=n,c=0;c<n;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 p=s.getTimeFromPosition(u),d=t({u,t:p,i:f,prev:l});return l={u,t:p,i:f,value:d},d})},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)){if(i<=1)throw Error("Invalid arguments passed to map(). You must specify at least 2 samples.");for(var c=i,h=0;h<i;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,p){if(!Number.isFinite(f)||f<0||f>1)throw Error("Invalid position (u) for sample in map()!");var d=o.getTimeFromPosition(f);return t({acc:u,u:f,t:d,i:p})},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}),e}();(function(e){function t(n,i,r,s,o){return i===void 0&&(i=.5),r===void 0&&(r=300),s===void 0&&(s=!1),o===void 0&&(o=0),e.call(this,n.map(function(a){return[a[0],a[1]]}),{tension:i,alpha:o,arcDivisions:r,closed:s})||this}return Ln(t,e),t.prototype.x=function(n,i,r){i===void 0&&(i=0),r===void 0&&(r=this._lmargin);var s=this.getIntersects(n,1,i,r);return Math.abs(i)===1?s[0]:s.map(function(o){return o[0]})},t.prototype.y=function(n,i,r){i===void 0&&(i=0),r===void 0&&(r=this._lmargin);var s=this.getIntersects(n,0,i,r);return Math.abs(i)===1?s[1]:s.map(function(o){return o[1]})},t.prototype.getNormalAt=function(n,i){return yt(ca(this.getTangentAt(n,i)))},t.prototype.getAngleAt=function(n){var i=this.getTangentAt(n);return Math.atan2(i[1],i[0])},t.prototype.getBoundingBox=function(n,i){n===void 0&&(n=0),i===void 0&&(i=1);var r=e.prototype.getBoundingBox.call(this,n,i);return{x1:r.min[0],x2:r.max[0],y1:r.min[1],y2:r.max[1],min:r.min,max:r.max}},t})(kn);class Te{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}return null}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=Te.newton(t,n,i,r);return a==null&&(a=Te.bisect(t,n,i,r,s,o)),a}}class pa{static bisect(t,n=0,i=1,r=.005,s=4,o=10){const a=(f,p,d,g,y,_,x=0)=>{const v=(f+p)/2,P=t(v),b=D.distance(d,P),S=D.distance(P,g),T=b+S;if(x>=s&&Math.abs(T-y)<_||x>=o)return T;const R=_/2,L=x+1;return a(f,v,d,P,b,R,L)+a(v,p,P,g,S,R,L)},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 ga{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<=n&&a>=n)return s;n<o?r=s:i=s,s=Math.floor(i+r/2)}return s}}class je extends kn{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:Te.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=ga.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){if(t===0&&n===1)return this.length;const i=.002;return pa.bisect(r=>this.getPointAt(r),t,n,i)}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 wi=.75,bi=5e3,Si=.001,ma=1e3,ya=1e3,_a=5e-4,xa=.1,va={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={...va,...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 je(t),trajectory:n.trajectoryInterpolator||new je(t.map(h=>[h[0],h[1]]),{tension:r||wi,arcDivisions:i||bi}),curtain:n.curtainInterpolator||new je(this.projectedPath,{tension:r||wi,arcDivisions:i||bi})};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+=xa){const a=this.project(o),c=Math.atan2(a[1],a[0]);Math.abs(c-s)>_a&&(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);return o&&o.length?o[0]*s+this._offset:null}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),p=this.interpolators.trajectory.getPointAt(u),d=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(p,o)),s&&(h=[a[0]+this.endVector[0]*s*this.displacement,a[1]+this.endVector[1]*s*this.displacement]);const g=[],y=i-n,_=Math.floor(r/y*t),x=Math.ceil((f-u)/y*t),v=t-x-_;if(c){g.push(c);for(let b=1;b<_;b++){const S=b/_*r*this.displacement;g.push([c[0]-this.startVector[0]*S,c[1]-this.startVector[1]*S])}}const P=this.interpolators.trajectory.getPoints(x-1,null,u,f);if(g.push(...P),h){for(let b=1;b<v-1;b++){const S=b/v*s*this.displacement;g.push([d[0]+this.endVector[0]*S,d[1]+this.endVector[1]*S])}g.push(h)}return{points:g,offset:l}}getExtendedTrajectory(t,n=ma,i=ya){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 x=s;x>0;x--){const v=x*u,P=h.add(l.scale(v));c.push(P.toArray())}const f=this.interpolators.trajectory.getPoints(o,null,0,1);c.push(...f);const p=new D(this.interpolators.trajectory.getPointAt(1)),d=new D(this.endVector),g=i/(a-1);for(let x=1;x<a;x++){const v=x*g,P=p.add(d.scale(v));c.push(P.toArray())}const y=-n;return{points:c,offset:y}}getTrajectoryVector(){const{trajectoryAngle:t,calculateDisplacementFromBottom:n}=this.options;if(isFinite(t)){const r=qo(t);return new D(Math.cos(r),Math.sin(r)).toArray()}return zt.getDirectionVector(this.interpolators.trajectory,n?Si:1-Si,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 yt([r[0]-s[0],r[1]-s[1]])}get length(){return this.interpolators.curve.length}get offset(){return this._offset}set offset(t){this._curtainPathCache=void 0,this._offset=t}}var dn="http://www.w3.org/1999/xhtml";const Ti={svg:"http://www.w3.org/2000/svg",xhtml:dn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Fe(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ti.hasOwnProperty(t)?{space:Ti[t],local:e}:e}function wa(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===dn&&t.documentElement.namespaceURI===dn?t.createElement(e):t.createElementNS(n,e)}}function ba(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function sr(e){var t=Fe(e);return(t.local?ba:wa)(t)}function Sa(){}function En(e){return e==null?Sa:function(){return this.querySelector(e)}}function Ta(e){typeof e!="function"&&(e=En(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 j(i,this._parents)}function Ma(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Pa(){return[]}function or(e){return e==null?Pa:function(){return this.querySelectorAll(e)}}function Aa(e){return function(){return Ma(e.apply(this,arguments))}}function Ca(e){typeof e=="function"?e=Aa(e):e=or(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 j(i,r)}function ar(e){return function(){return this.matches(e)}}function cr(e){return function(t){return t.matches(e)}}var La=Array.prototype.find;function ka(e){return function(){return La.call(this.children,e)}}function Ea(){return this.firstElementChild}function Fa(e){return this.select(e==null?Ea:ka(typeof e=="function"?e:cr(e)))}var Ra=Array.prototype.filter;function Ia(){return Array.from(this.children)}function Oa(e){return function(){return Ra.call(this.children,e)}}function za(e){return this.selectAll(e==null?Ia:Oa(typeof e=="function"?e:cr(e)))}function Da(e){typeof e!="function"&&(e=ar(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 j(i,this._parents)}function hr(e){return new Array(e.length)}function Na(){return new j(this._enter||this._groups.map(hr),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 $a(e){return function(){return e}}function Ba(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 Ha(e,t,n,i,r,s,o){var a,c,h=new Map,l=t.length,u=s.length,f=new Array(l),p;for(a=0;a<l;++a)(c=t[a])&&(f[a]=p=o.call(c,c.__data__,a,t)+"",h.has(p)?r[a]=c:h.set(p,c));for(a=0;a<u;++a)p=o.call(e,s[a],a,s)+"",(c=h.get(p))?(i[a]=c,c.__data__=s[a],h.delete(p)):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 Xa(e){return e.__data__}function Va(e,t){if(!arguments.length)return Array.from(this,Xa);var n=t?Ha:Ba,i=this._parents,r=this._groups;typeof e!="function"&&(e=$a(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,p=Ua(e.call(l,l&&l.__data__,h,i)),d=p.length,g=a[h]=new Array(d),y=o[h]=new Array(d),_=c[h]=new Array(f);n(l,u,g,y,_,p,t);for(var x=0,v=0,P,b;x<d;++x)if(P=g[x]){for(x>=v&&(v=x+1);!(b=y[v])&&++v<d;);P._next=b||null}}return o=new j(o,i),o._enter=a,o._exit=c,o}function Ua(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ya(){return new j(this._exit||this._groups.map(hr),this._parents)}function Wa(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 Ga(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),p,d=0;d<u;++d)(p=h[d]||l[d])&&(f[d]=p);for(;c<r;++c)a[c]=n[c];return new j(a,this._parents)}function qa(){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 ja(e){e||(e=Za);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 j(r,this._parents).order()}function Za(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ka(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qa(){return Array.from(this)}function Ja(){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 tc(){let e=0;for(const t of this)++e;return e}function ec(){return!this.node()}function nc(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 ic(e){return function(){this.removeAttribute(e)}}function rc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sc(e,t){return function(){this.setAttribute(e,t)}}function oc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ac(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function cc(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 hc(e,t){var n=Fe(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?rc:ic:typeof t=="function"?n.local?cc:ac:n.local?oc:sc)(n,t))}function lr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lc(e){return function(){this.style.removeProperty(e)}}function uc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function fc(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function dc(e,t,n){return arguments.length>1?this.each((t==null?lc:typeof t=="function"?fc:uc)(e,t,n??"")):Dt(this.node(),e)}function Dt(e,t){return e.style.getPropertyValue(t)||lr(e).getComputedStyle(e,null).getPropertyValue(t)}function pc(e){return function(){delete this[e]}}function gc(e,t){return function(){this[e]=t}}function mc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yc(e,t){return arguments.length>1?this.each((t==null?pc:typeof t=="function"?mc:gc)(e,t)):this.node()[e]}function ur(e){return e.trim().split(/^|\s+/)}function Fn(e){return e.classList||new fr(e)}function fr(e){this._node=e,this._names=ur(e.getAttribute("class")||"")}fr.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 dr(e,t){for(var n=Fn(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function pr(e,t){for(var n=Fn(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function _c(e){return function(){dr(this,e)}}function xc(e){return function(){pr(this,e)}}function vc(e,t){return function(){(t.apply(this,arguments)?dr:pr)(this,e)}}function wc(e,t){var n=ur(e+"");if(arguments.length<2){for(var i=Fn(this.node()),r=-1,s=n.length;++r<s;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?vc:t?_c:xc)(n,t))}function bc(){this.textContent=""}function Sc(e){return function(){this.textContent=e}}function Tc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Mc(e){return arguments.length?this.each(e==null?bc:(typeof e=="function"?Tc:Sc)(e)):this.node().textContent}function Pc(){this.innerHTML=""}function Ac(e){return function(){this.innerHTML=e}}function Cc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Lc(e){return arguments.length?this.each(e==null?Pc:(typeof e=="function"?Cc:Ac)(e)):this.node().innerHTML}function kc(){this.nextSibling&&this.parentNode.appendChild(this)}function Ec(){return this.each(kc)}function Fc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Rc(){return this.each(Fc)}function Ic(e){var t=typeof e=="function"?e:sr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Oc(){return null}function zc(e,t){var n=typeof e=="function"?e:sr(e),i=t==null?Oc:typeof t=="function"?t:En(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function Dc(){var e=this.parentNode;e&&e.removeChild(this)}function Nc(){return this.each(Dc)}function $c(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Hc(e){return this.select(e?Bc:$c)}function Xc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Vc(e){return function(t){e.call(this,t,this.__data__)}}function Uc(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 Yc(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 Wc(e,t,n){return function(){var i=this.__on,r,s=Vc(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 Gc(e,t,n){var i=Uc(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?Wc:Yc,r=0;r<s;++r)this.each(a(i[r],t,n));return this}function gr(e,t,n){var i=lr(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 qc(e,t){return function(){return gr(this,e,t)}}function jc(e,t){return function(){return gr(this,e,t.apply(this,arguments))}}function Zc(e,t){return this.each((typeof t=="function"?jc:qc)(e,t))}function*Kc(){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 mr=[null];function j(e,t){this._groups=e,this._parents=t}function Jt(){return new j([[document.documentElement]],mr)}function Qc(){return this}j.prototype=Jt.prototype={constructor:j,select:Ta,selectAll:Ca,selectChild:Fa,selectChildren:za,filter:Da,data:Va,enter:Na,exit:Ya,join:Wa,merge:Ga,selection:Qc,order:qa,sort:ja,call:Ka,nodes:Qa,node:Ja,size:tc,empty:ec,each:nc,attr:hc,style:dc,property:yc,classed:wc,text:Mc,html:Lc,raise:Ec,lower:Rc,append:Ic,insert:zc,remove:Nc,clone:Hc,datum:Xc,on:Gc,dispatch:Zc,[Symbol.iterator]:Kc};function q(e){return typeof e=="string"?new j([[document.querySelector(e)]],[document.documentElement]):new j([[e]],mr)}function Jc(e){let t;for(;t=e.sourceEvent;)e=t;return e}function pt(e,t){if(e=Jc(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 th={value:()=>{}};function Rn(){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 ue(n)}function ue(e){this._=e}function eh(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}})}ue.prototype=Rn.prototype={constructor:ue,on:function(e,t){var n=this._,i=eh(e+"",n),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(e=i[s]).type)&&(r=nh(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]=Mi(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Mi(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 ue(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 nh(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function Mi(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=th,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}const pn={capture:!0,passive:!1};function gn(e){e.preventDefault(),e.stopImmediatePropagation()}function ih(e){var t=e.document.documentElement,n=q(e).on("dragstart.drag",gn,pn);"onselectstart"in t?n.on("selectstart.drag",gn,pn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function rh(e,t){var n=e.document.documentElement,i=q(e).on("dragstart.drag",null);t&&(i.on("click.drag",gn,pn),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,Wt=0,Vt=0,yr=1e3,Pe,Gt,Ae=0,Ct=0,Re=0,Kt=typeof performance=="object"&&performance.now?performance:Date,_r=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function In(){return Ct||(_r(sh),Ct=Kt.now()+Re)}function sh(){Ct=0}function Ce(){this._call=this._time=this._next=null}Ce.prototype=xr.prototype={constructor:Ce,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?In():+n)+(t==null?0:+t),!this._next&&Gt!==this&&(Gt?Gt._next=this:Pe=this,Gt=this),this._call=e,this._time=n,mn()},stop:function(){this._call&&(this._call=null,this._time=1/0,mn())}};function xr(e,t,n){var i=new Ce;return i.restart(e,t,n),i}function oh(){In(),++Nt;for(var e=Pe,t;e;)(t=Ct-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Nt}function Pi(){Ct=(Ae=Kt.now())+Re,Nt=Wt=0;try{oh()}finally{Nt=0,ch(),Ct=0}}function ah(){var e=Kt.now(),t=e-Ae;t>yr&&(Re-=t,Ae=e)}function ch(){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,mn(i)}function mn(e){if(!Nt){Wt&&(Wt=clearTimeout(Wt));var t=e-Ct;t>24?(e<1/0&&(Wt=setTimeout(Pi,e-Kt.now()-Re)),Vt&&(Vt=clearInterval(Vt))):(Vt||(Ae=Kt.now(),Vt=setInterval(ah,yr)),Nt=1,_r(Pi))}}function Ai(e,t,n){var i=new Ce;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var hh=Rn("start","end","cancel","interrupt"),lh=[],vr=0,Ci=1,yn=2,fe=3,Li=4,_n=5,de=6;function Ie(e,t,n,i,r,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;uh(e,n,{name:t,index:i,group:r,on:hh,tween:lh,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:vr})}function On(e,t){var n=rt(e,t);if(n.state>vr)throw new Error("too late; already scheduled");return n}function ct(e,t){var n=rt(e,t);if(n.state>fe)throw new Error("too late; already running");return n}function rt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function uh(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=xr(s,0,n.time);function s(h){n.state=Ci,n.timer.restart(o,n.delay,n.time),n.delay<=h&&o(h-n.delay)}function o(h){var l,u,f,p;if(n.state!==Ci)return c();for(l in i)if(p=i[l],p.name===n.name){if(p.state===fe)return Ai(o);p.state===Li?(p.state=de,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete i[l]):+l<t&&(p.state=de,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete i[l])}if(Ai(function(){n.state===fe&&(n.state=Li,n.timer.restart(a,n.delay,n.time),a(h))}),n.state=yn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===yn){for(n.state=fe,r=new Array(f=n.tween.length),l=0,u=-1;l<f;++l)(p=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=p);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=_n,1),u=-1,f=r.length;++u<f;)r[u].call(e,l);n.state===_n&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=de,n.timer.stop(),delete i[t];for(var h in i)return;delete e.__transition}}function pe(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>yn&&i.state<_n,i.state=de,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[o]}s&&delete e.__transition}}function fh(e){return this.each(function(){pe(this,e)})}function dh(e,t){var n,i;return function(){var r=ct(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 ph(e,t,n){var i,r;if(typeof n!="function")throw new Error;return function(){var s=ct(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 gh(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=rt(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?dh:ph)(n,e,t))}function zn(e,t,n){var i=e._id;return e.each(function(){var r=ct(this,i);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return rt(r,i).value[t]}}function wr(e,t){var n;return(typeof t=="number"?et:t instanceof ft?Zt:(n=ft(t))?(t=n,Zt):qi)(e,t)}function mh(e){return function(){this.removeAttribute(e)}}function yh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _h(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 xh(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 vh(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 wh(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 bh(e,t){var n=Fe(e),i=n==="transform"?vo:wr;return this.attrTween(e,typeof t=="function"?(n.local?wh:vh)(n,i,zn(this,"attr."+e,t)):t==null?(n.local?yh:mh)(n):(n.local?xh:_h)(n,i,t))}function Sh(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Th(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Mh(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&Th(e,s)),n}return r._value=t,r}function Ph(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&Sh(e,s)),n}return r._value=t,r}function Ah(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=Fe(e);return this.tween(n,(i.local?Mh:Ph)(i,t))}function Ch(e,t){return function(){On(this,e).delay=+t.apply(this,arguments)}}function Lh(e,t){return t=+t,function(){On(this,e).delay=t}}function kh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ch:Lh)(t,e)):rt(this.node(),t).delay}function Eh(e,t){return function(){ct(this,e).duration=+t.apply(this,arguments)}}function Fh(e,t){return t=+t,function(){ct(this,e).duration=t}}function Rh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Eh:Fh)(t,e)):rt(this.node(),t).duration}function Ih(e,t){if(typeof t!="function")throw new Error;return function(){ct(this,e).ease=t}}function Oh(e){var t=this._id;return arguments.length?this.each(Ih(t,e)):rt(this.node(),t).ease}function zh(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ct(this,e).ease=n}}function Dh(e){if(typeof e!="function")throw new Error;return this.each(zh(this._id,e))}function Nh(e){typeof e!="function"&&(e=ar(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 dt(i,this._parents,this._name,this._id)}function $h(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,p=0;p<l;++p)(f=c[p]||h[p])&&(u[p]=f);for(;a<i;++a)o[a]=t[a];return new dt(o,this._parents,this._name,this._id)}function Bh(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 Hh(e,t,n){var i,r,s=Bh(t)?On:ct;return function(){var o=s(this,e),a=o.on;a!==i&&(r=(i=a).copy()).on(t,n),o.on=r}}function Xh(e,t){var n=this._id;return arguments.length<2?rt(this.node(),n).on.on(e):this.each(Hh(n,e,t))}function Vh(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Uh(){return this.on("end.remove",Vh(this._id))}function Yh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=En(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,Ie(h[f],t,n,f,h,rt(l,n)));return new dt(s,this._parents,t,n)}function Wh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=or(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),p,d=rt(l,n),g=0,y=f.length;g<y;++g)(p=f[g])&&Ie(p,t,n,g,f,d);s.push(f),o.push(l)}return new dt(s,o,t,n)}var Gh=Jt.prototype.constructor;function qh(){return new Gh(this._groups,this._parents)}function jh(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 br(e){return function(){this.style.removeProperty(e)}}function Zh(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 Kh(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 Qh(e,t){var n,i,r,s="style."+t,o="end."+s,a;return function(){var c=ct(this,e),h=c.on,l=c.value[s]==null?a||(a=br(t)):void 0;(h!==n||r!==l)&&(i=(n=h).copy()).on(o,r=l),c.on=i}}function Jh(e,t,n){var i=(e+="")=="transform"?xo:wr;return t==null?this.styleTween(e,jh(e,i)).on("end.style."+e,br(e)):typeof t=="function"?this.styleTween(e,Kh(e,i,zn(this,"style."+e,t))).each(Qh(this._id,e)):this.styleTween(e,Zh(e,i,t),n).on("end.style."+e,null)}function tl(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function el(e,t,n){var i,r;function s(){var o=t.apply(this,arguments);return o!==r&&(i=(r=o)&&tl(e,o,n)),i}return s._value=t,s}function nl(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,el(e,t,n??""))}function il(e){return function(){this.textContent=e}}function rl(e){return function(){var t=e(this);this.textContent=t??""}}function sl(e){return this.tween("text",typeof e=="function"?rl(zn(this,"text",e)):il(e==null?"":e+""))}function ol(e){return function(t){this.textContent=e.call(this,t)}}function al(e){var t,n;function i(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&ol(r)),t}return i._value=e,i}function cl(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,al(e))}function hl(){for(var e=this._name,t=this._id,n=Sr(),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=rt(c,t);Ie(c,e,n,h,o,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new dt(i,this._parents,e,n)}function ll(){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=ct(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 ul=0;function dt(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function Sr(){return++ul}var ht=Jt.prototype;dt.prototype={constructor:dt,select:Yh,selectAll:Wh,selectChild:ht.selectChild,selectChildren:ht.selectChildren,filter:Nh,merge:$h,selection:qh,transition:hl,call:ht.call,nodes:ht.nodes,node:ht.node,size:ht.size,empty:ht.empty,each:ht.each,on:Xh,attr:bh,attrTween:Ah,style:Jh,styleTween:nl,text:sl,textTween:cl,remove:Uh,tween:gh,delay:kh,duration:Rh,ease:Oh,easeVarying:Dh,end:ll,[Symbol.iterator]:ht[Symbol.iterator]};function fl(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var dl={time:null,delay:0,duration:250,ease:fl};function pl(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 gl(e){var t,n;e instanceof dt?(t=e._id,e=e._name):(t=Sr(),(n=dl).time=In(),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])&&Ie(c,e,t,h,o,n||pl(c,t));return new dt(i,this._parents,e,t)}Jt.prototype.interrupt=fh;Jt.prototype.transition=gl;const ce=e=>()=>e;function ml(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 ut(e,t,n){this.k=e,this.x=t,this.y=n}ut.prototype={constructor:ut,scale:function(e){return e===1?this:new ut(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ut(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 Dn=new ut(1,0,0);ut.prototype;function Ze(e){e.stopImmediatePropagation()}function Ut(e){e.preventDefault(),e.stopImmediatePropagation()}function yl(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function _l(){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 ki(){return this.__zoom||Dn}function xl(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function vl(){return navigator.maxTouchPoints||"ontouchstart"in this}function wl(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 bl(){var e=yl,t=_l,n=wl,i=xl,r=vl,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,c=To,h=Rn("start","zoom","end"),l,u,f,p=500,d=150,g=0,y=10;function _(m){m.property("__zoom",ki).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",L).on("dblclick.zoom",N).filter(r).on("touchstart.zoom",C).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",$).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(m,M,w,A){var E=m.selection?m.selection():m;E.property("__zoom",ki),m!==E?b(m,M,w,A):E.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},_.scaleBy=function(m,M,w,A){_.scaleTo(m,function(){var E=this.__zoom.k,F=typeof M=="function"?M.apply(this,arguments):M;return E*F},w,A)},_.scaleTo=function(m,M,w,A){_.transform(m,function(){var E=t.apply(this,arguments),F=this.__zoom,I=w==null?P(E):typeof w=="function"?w.apply(this,arguments):w,z=F.invert(I),B=typeof M=="function"?M.apply(this,arguments):M;return n(v(x(F,B),I,z),E,o)},w,A)},_.translateBy=function(m,M,w,A){_.transform(m,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof w=="function"?w.apply(this,arguments):w),t.apply(this,arguments),o)},null,A)},_.translateTo=function(m,M,w,A,E){_.transform(m,function(){var F=t.apply(this,arguments),I=this.__zoom,z=A==null?P(F):typeof A=="function"?A.apply(this,arguments):A;return n(Dn.translate(z[0],z[1]).scale(I.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof w=="function"?-w.apply(this,arguments):-w),F,o)},A,E)};function x(m,M){return M=Math.max(s[0],Math.min(s[1],M)),M===m.k?m:new ut(M,m.x,m.y)}function v(m,M,w){var A=M[0]-w[0]*m.k,E=M[1]-w[1]*m.k;return A===m.x&&E===m.y?m:new ut(m.k,A,E)}function P(m){return[(+m[0][0]+ +m[1][0])/2,(+m[0][1]+ +m[1][1])/2]}function b(m,M,w,A){m.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var E=this,F=arguments,I=S(E,F).event(A),z=t.apply(E,F),B=w==null?P(z):typeof w=="function"?w.apply(E,F):w,V=Math.max(z[1][0]-z[0][0],z[1][1]-z[0][1]),H=E.__zoom,W=typeof M=="function"?M.apply(E,F):M,Q=c(H.invert(B).concat(V/H.k),W.invert(B).concat(V/W.k));return function(U){if(U===1)U=W;else{var J=Q(U),$t=V/J[2];U=new ut($t,B[0]-J[0]*$t,B[1]-J[1]*$t)}I.zoom(null,U)}})}function S(m,M,w){return!w&&m.__zooming||new T(m,M)}function T(m,M){this.that=m,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(m,M),this.taps=0}T.prototype={event:function(m){return m&&(this.sourceEvent=m),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(m,M){return this.mouse&&m!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&m!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&m!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(m){var M=q(this.that).datum();h.call(m,this.that,new ml(m,{sourceEvent:this.sourceEvent,target:_,type:m,transform:this.that.__zoom,dispatch:h}),M)}};function R(m,...M){if(!e.apply(this,arguments))return;var w=S(this,M).event(m),A=this.__zoom,E=Math.max(s[0],Math.min(s[1],A.k*Math.pow(2,i.apply(this,arguments)))),F=pt(m);if(w.wheel)(w.mouse[0][0]!==F[0]||w.mouse[0][1]!==F[1])&&(w.mouse[1]=A.invert(w.mouse[0]=F)),clearTimeout(w.wheel);else{if(A.k===E)return;w.mouse=[F,A.invert(F)],pe(this),w.start()}Ut(m),w.wheel=setTimeout(I,d),w.zoom("mouse",n(v(x(A,E),w.mouse[0],w.mouse[1]),w.extent,o));function I(){w.wheel=null,w.end()}}function L(m,...M){if(f||!e.apply(this,arguments))return;var w=m.currentTarget,A=S(this,M,!0).event(m),E=q(m.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",V,!0),F=pt(m,w),I=m.clientX,z=m.clientY;ih(m.view),Ze(m),A.mouse=[F,this.__zoom.invert(F)],pe(this),A.start();function B(H){if(Ut(H),!A.moved){var W=H.clientX-I,Q=H.clientY-z;A.moved=W*W+Q*Q>g}A.event(H).zoom("mouse",n(v(A.that.__zoom,A.mouse[0]=pt(H,w),A.mouse[1]),A.extent,o))}function V(H){E.on("mousemove.zoom mouseup.zoom",null),rh(H.view,A.moved),Ut(H),A.event(H).end()}}function N(m,...M){if(e.apply(this,arguments)){var w=this.__zoom,A=pt(m.changedTouches?m.changedTouches[0]:m,this),E=w.invert(A),F=w.k*(m.shiftKey?.5:2),I=n(v(x(w,F),A,E),t.apply(this,M),o);Ut(m),a>0?q(this).transition().duration(a).call(b,I,A,m):q(this).call(_.transform,I,A,m)}}function C(m,...M){if(e.apply(this,arguments)){var w=m.touches,A=w.length,E=S(this,M,m.changedTouches.length===A).event(m),F,I,z,B;for(Ze(m),I=0;I<A;++I)z=w[I],B=pt(z,this),B=[B,this.__zoom.invert(B),z.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},p)),pe(this),E.start())}}function O(m,...M){if(this.__zooming){var w=S(this,M).event(m),A=m.changedTouches,E=A.length,F,I,z,B;for(Ut(m),F=0;F<E;++F)I=A[F],z=pt(I,this),w.touch0&&w.touch0[2]===I.identifier?w.touch0[0]=z:w.touch1&&w.touch1[2]===I.identifier&&(w.touch1[0]=z);if(I=w.that.__zoom,w.touch1){var V=w.touch0[0],H=w.touch0[1],W=w.touch1[0],Q=w.touch1[1],U=(U=W[0]-V[0])*U+(U=W[1]-V[1])*U,J=(J=Q[0]-H[0])*J+(J=Q[1]-H[1])*J;I=x(I,Math.sqrt(U/J)),z=[(V[0]+W[0])/2,(V[1]+W[1])/2],B=[(H[0]+Q[0])/2,(H[1]+Q[1])/2]}else if(w.touch0)z=w.touch0[0],B=w.touch0[1];else return;w.zoom("touch",n(v(I,z,B),w.extent,o))}}function $(m,...M){if(this.__zooming){var w=S(this,M).event(m),A=m.changedTouches,E=A.length,F,I;for(Ze(m),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),F=0;F<E;++F)I=A[F],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=pt(I,this),Math.hypot(u[0]-I[0],u[1]-I[1])<y)){var z=q(this).on("dblclick.zoom");z&&z.apply(this,arguments)}}}return _.wheelDelta=function(m){return arguments.length?(i=typeof m=="function"?m:ce(+m),_):i},_.filter=function(m){return arguments.length?(e=typeof m=="function"?m:ce(!!m),_):e},_.touchable=function(m){return arguments.length?(r=typeof m=="function"?m:ce(!!m),_):r},_.extent=function(m){return arguments.length?(t=typeof m=="function"?m:ce([[+m[0][0],+m[0][1]],[+m[1][0],+m[1][1]]]),_):t},_.scaleExtent=function(m){return arguments.length?(s[0]=+m[0],s[1]=+m[1],_):[s[0],s[1]]},_.translateExtent=function(m){return arguments.length?(o[0][0]=+m[0][0],o[1][0]=+m[1][0],o[0][1]=+m[0][1],o[1][1]=+m[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(m){return arguments.length?(n=m,_):n},_.duration=function(m){return arguments.length?(a=+m,_):a},_.interpolate=function(m){return arguments.length?(c=m,_):c},_.on=function(){var m=h.on.apply(h,arguments);return m===h?_:m},_.clickDistance=function(m){return arguments.length?(g=(m=+m)*m,_):Math.sqrt(g)},_.tapDistance=function(m){return arguments.length?(y=+m,_):y},_}const Sl=.1,Tl=256;class Tr{constructor(t,n,i={maxZoomLevel:Tl,minZoomLevel:Sl}){this.zoom=null,this.elm=null,this.container=null,this.onRescale=null,this.options=null,this.xBounds=[0,1],this.yBounds=[0,1],this.translateBoundsX=[0,1],this.translateBoundsY=[0,1],this.scaleX=null,this.scaleY=null,this._zFactor=1,this.container=q(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=At().domain(this.xBounds).range([0,1]),this.scaleY=At().domain(this.yBounds).range([0,1]),this.init()}get width(){return this.scaleX.range()[1]}get height(){return this.scaleY.range()[1]}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=bl().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,p=s/f,d=s/t.k,g=d/c/h,y=p*t.x,_=p/c*t.y,x=o[0]-(l?-y:y),v=a[0]-(u?-_:_);i.domain([x,x+(l?-d:d)]),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(isNaN(t)||isNaN(i)){const g=c.domain(),y=g[1]-g[0];isNaN(t)&&(t=g[0]+y/2||0),isNaN(i)&&(i=Math.abs(y)||1)}if(isNaN(n)){const g=h.domain();n=g[0]+(g[1]-g[0])/2||0}const u=l?-i:i,f=t-u/2,p=f+u,d=a(f,p,n);Number.isFinite(r)&&r>0?s.transform(o.transition().duration(r),d):s.transform(o,d)}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>"u"||typeof t=="boolean"){const{width:p,height:d}=this.container.node().getBoundingClientRect();h=p,l=d}else h=t,l=n;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,p]=r.range(),d=Math.abs(n-t),g=s/d,y=d/(p-f),_=i-(u?-d:d)/c/h/2,x=(o[0]-t)/(l?-y:y),v=(a[0]-_)/((u?-y:y)/c);return Dn.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 Ml={order:1,layerOpacity:1,interactive:!1};class te{constructor(t,n){this._referenceSystem=null,this._interactive=!1,this._id=t||`layer-${Math.floor(Math.random()*1e3)}`;const i=n||Ml;this._order=i.order||1,this._options={...i},this.loading=!1,this._element=null,this._opacity=i.layerOpacity||1,this._visible=!0,this._interactive=i.interactive||!1,n&&n.data&&this.setData(n.data),this._referenceSystem=n&&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&&this.onUpdate({data:t})}clearData(t=!0){this._data=null,t&&(this.referenceSystem=null),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&&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 Oe=200,ze=300,Mr=40,Pr=30,Pl=100,Al=.6,Cl=.3,Ll=8,kl=16,xt=64,Ar=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)||Oe,r=t.height||parseInt(n.getAttribute("height"),10)||ze;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")}onUnmount(){super.onUnmount(),this.canvas.remove(),this.canvas=null}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,n.height),t.restore()}}class El extends te{onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n.getAttribute("width"),10)||Oe,r=t.height||parseInt(n.getAttribute("height"),10)||ze;this.elm||(this.elm=q(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=null}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 Cr extends te{onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n.getAttribute("width"),10)||Oe,r=t.height||parseInt(n.getAttribute("height"),10)||ze;this.elm||(this.elm=q(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=null}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 Fl{constructor(t){const n={width:Oe,height:ze,antialias:!0,backgroundAlpha:0,clearBeforeRender:!0,preserveDrawingBuffer:!0,...t};this.renderer=k.autoDetectRenderer(n),this.stage=new k.Container}destroy(){var i,r;this.stage.destroy({children:!0,texture:!0,baseTexture:!0}),this.stage=null;const t=this.renderer.type,n=this.renderer instanceof k.Renderer?(i=this.renderer)==null?void 0:i.gl:void 0;t===k.RENDERER_TYPE.WEBGL&&n&&((r=n==null?void 0:n.getExtension("WEBGL_lose_context"))==null||r.loseContext()),this.renderer.destroy(!0),this.renderer=null}get view(){return this.renderer.view}render(){this.renderer.render(this.stage)}}class Nn extends te{constructor(t,n,i){super(n,i),this.ctx=t,this.container=new k.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"),this.pixiViewContainer||(this.pixiViewContainer=document.createElement("div"),this.pixiViewContainer.setAttribute("id",`${this.id}`),this.pixiViewContainer.setAttribute("class","webgl-layer"),this.pixiViewContainer.appendChild(this.ctx.view),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 Lr=e=>e.kind==="pAndASymbol",kr=e=>e.kind==="cementSqueeze",Er=e=>e.kind==="cementPlug",Fr=(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)}},Z=(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)}},Rl=e=>Z({Perforation:()=>!0,OpenHoleGravelPack:()=>!0,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind),Il=e=>Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!0,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!0},e.subKind),Rr=e=>Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!0,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!0},e.subKind);function Ir(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!0,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!0},e.subKind)}function Or(e){return Z({Perforation:()=>!0,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}function zr(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!1},e.subKind)}function Ol(e){return Z({Perforation:()=>!0,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}function Dr(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!0},e.subKind)}function zl(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}const Nr=e=>e.subKind==="Cased hole fracturation",$r=(e,t)=>e.start<t.end&&e.end>t.start,Br=e=>({holeLayerId:`${e}-hole`,casingLayerId:`${e}-casing`,completionLayerId:`${e}-completion`,cementLayerId:`${e}-cement`,pAndALayerId:`${e}-pAndA`,perforationLayerId:`${e}-perforation`}),Hr={firstColor:"#8c541d",secondColor:"#eee3d8",lineColor:"#8b4513"},Xr={solidColor:"#dcdcdc",lineColor:"#575757",shoeSize:{width:Ll,length:kl},windowOptions:{dashColor:"#dc0000",dashLength:5,spaceLength:3}},Vr={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},Ur={firstColor:"#c7b9ab",secondColor:"#5b5b5b",scalingFactor:4},Yr={firstColor:"#8b6713",secondColor:"#000000",scalingFactor:4},Wr={scalingFactor:4,lineColor:"#63666a"},Gr={scalingFactor:1,innerColor:"#eeeeff",outerColor:"#777788"},qr={firstColor:"#c7b9ab",secondColor:"#000000",scalingFactor:4},jr=4,Zr=2;function Kr(e){const[t]=e.domain();return Math.abs(e(t+1))}function Le(e,t,n,i){return _t(Kr(i)*e,t,n)}function Dl(e,t){const n=e.x+e.width,i=t.x+t.width;return!(t.x>n||i<e.x)}function Qr(e,t,n=jr,i=Zr){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 Nl(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 null;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 xn(e,t,n=jr,i=Zr){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 null;const c=e.x+e.width-t.x+n,h=e.y+e.height-t.y+i;return{dx:c,dy:h}}const $l=7,Bl=11,Hl=7,Xl=20,Vl=120,Ul=19,tt={topleft:"topleft",topright:"topright",bottomleft:"bottomleft",bottomright:"bottomright"};class Yl extends bt{constructor(t,n){super(t,n),this.groupFilter=null,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,p=r+2;l.strokeStyle=c,l.lineWidth=1,l.beginPath(),l.moveTo(o,a),l.lineTo(u,p),l.lineTo(f,p),l.stroke()},this.minFontSize=n.minFontSize||$l,this.maxFontSize=n.maxFontSize||Bl,this.fontSizeFactor=n.fontSizeFactor||Hl,this.offsetMin=n.offsetMin||Xl,this.offsetMax=n.offsetMax||Vl,this.offsetFactor=n.offsetFactor||Ul}setGroupFilter(t){this.groupFilter=t,this.callouts=void 0,this.render()}onUpdate(t){super.onUpdate(t),this.callouts=void 0,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=Le(this.fontSizeFactor,this.minFontSize,this.maxFontSize,n);if(!t||!this.callouts){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.font=`bold ${s}px arial`;const f=o.filter(d=>!c||c.includes(d.group)),p=Le(this.offsetFactor,this.offsetMin,this.offsetMax,n);this.callouts=this.positionCallouts(f,l,n,i,u,s,p)}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)})})}renderText(t,n,i,r,s,o="arial",a="normal"){const{ctx:c}=this;c.font=`${a} ${r}px ${o}`,c.fillStyle=s,c.fillText(t,n,i)}renderPoint(t,n,i=3){const{ctx:r}=this;r.beginPath(),r.moveTo(t,n),r.arc(t,n,i,0,Math.PI*2),r.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,p=s===tt.topright||s===tt.bottomright;this.renderAnnotation(t,n,a,c,h,r),this.renderPoint(u,f),this.renderLine(a,c,l,u,f,r,p)}getPosition(t,n){const{x:i,y:r,offsetX:s,offsetY:o,width:a}=t;switch(n){case tt.topleft:return{x:i-a-s,y:r-o};case tt.topright:return{x:i+s,y:r-o};case tt.bottomleft:return{x:i-a-s,y:r+o};case tt.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?tt.topleft:tt.topright,h=t.map(f=>{const p=f.pos?f.pos:this.referenceSystem.project(f.md);return{title:f.title,label:f.label,color:f.color,pos:{x:p[0],y:p[1]},group:f.group,alignment:c,boundingBox:this.getAnnotationBoundingBox(f.title,f.label,p,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,u=a.measureText(t).width,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];Qr(s.boundingBox,o.boundingBox)?(s.alignment=s.alignment===tt.topleft?tt.bottomright:tt.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=xn(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=xn(s.boundingBox,i.boundingBox);o&&(i.dy+=o.dy,i.boundingBox.y+=o.dy)}}}}const Wl=16,Gl=6;function lt(e){const n=ft(e).formatHex();return parseInt(n.replace("#","0x"))}function ql(e){return typeof e=="string"?e:`#${e.toString(Wl).padStart(Gl,"0")}`}const jl=1e4;class Zl extends bt{constructor(t,n){super(t,n),this.surfaceAreasPaths=[],this.surfaceLinesPaths=[],this.maxDepth=jl,this.drawPolygonPath=(i,r)=>{const{ctx:s}=this;s.fillStyle=i,s.fill(r)},this.drawLinePath=(i,r)=>{const{ctx:s}=this;s.strokeStyle=i,s.stroke(r)},this.createPolygons=i=>{const r=[];let s=null;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){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=null}}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=null;for(let c=0;c<s.length;c++)s[c][1]?o?a.lineTo(s[c][0],s[c][1]):(a=new Path2D,a.moveTo(s[c][0],s[c][1]),o=!0):o&&(r.push(a),o=!1);return o&&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 ql(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 $n(e,t){let n=0,i=e.length-1;const r=20;let s=e[n][0],o=e[i][0];for(;i-n>r;){const c=Math.floor((i+n)/2),h=e[c][0];if(t>=s&&t<h)i=c,o=e[i][0];else if(t>=h&&t<=o)n=c,s=e[n][0];else if(t<=s&&t>h)i=c,o=e[i][0];else if(t<=h&&t>=o)n=c,s=e[n][0];else return-1}let a=-1;for(let c=n;c<i;c++){const h=e[c][0],l=e[c+1][0];if(Math.min(h,l)<=t&&t<=Math.max(h,l)){a=c;break}}return a}function gt(e,t,n=null,i=null){let r=null;const s=$n(e,t);if(s!==-1){const o=e[s][1],a=e[s+1][1];if(a&&a){const c=e[s][0],l=e[s+1][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 Bn=(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 Kl(e){return e?e.map(t=>Bn(t,"ref-picks")):[]}function Ql(e){return e?e.filter(t=>t.entryPick.md===t.from).map(t=>Bn(t.entryPick,"strat-picks")):[]}function Jl(e){return e?e.filter(t=>e.findIndex(n=>Math.abs(n.entryPick.md-t.exitPick.md)<.5)===-1).map(t=>Bn(t.exitPick,"strat-picks")).filter((t,n,i)=>n===i.findIndex(r=>r.title===t.title&&r.md===t.md)):[]}const tu=e=>[...Kl(e.nonUnitPicks),...Ql(e.unitPicks),...Jl(e.unitPicks)].sort((t,n)=>t.md-n.md),eu=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 nu(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 iu=e=>e.map(eu);function ru(e,t){const n=iu(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 su(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 ou(e,t){const{joined:n,nonUnitPicks:i}=ru(e,t),s=su(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=nu(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 au(e,t){const n=e.map((s,o)=>o*t/e.length),i=At().domain(n).range(e);return Array.from(new Array(t).keys()).map(s=>{const o=ft(i(s)).rgb();return[o.r,o.g,o.b]})}const cu=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 hu(e,t){if(!(e&&e.datapoints))return null;const n=t.reduce((p,d)=>Math.min(p,d[0]),0),i=t.reduce((p,d)=>Math.max(p,d[0]),0),r=e.yAxisValues&&e.yAxisValues[0],s=e.yAxisValues&&e.yAxisValues[e.yAxisValues.length-1],o=e.datapoints||[],a=-o.reduce((p,d)=>Math.min(...d,p),0),c=o.reduce((p,d)=>Math.max(...d,p),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 lu(e,t,n,i){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((m,M)=>Math.min(...M,m),0),o=(i==null?void 0:i.seismicMax)||(i==null?void 0:i.seismicRange)||r.reduce((m,M)=>Math.max(...M,m),0),a=Math.max(Math.abs(s),Math.abs(o)),c=-a,h=a,l={min:c,max:h,difference:h-c},u=t[0][0]-t[t.length-1][0],f=Math.abs(Math.floor(u/5)),p=e.yAxisValues.length,d=1e3,g=au(n,d),y=new Uint8ClampedArray(f*p*4);let _=0;const x=(d-1)/l.difference;let v=i!=null&&i.isLeftToRight?t[0][0]:t[t.length-1][0];const P=u/f*(i!=null&&i.isLeftToRight?-1:1);let b,S,T,R,L;const N=[0,0,0];let C;for(let m=0;m<f;m++){_=m*4;const M=$n(t,v),w=t[M][0],E=t[M+1][0]-w,I=(v-w)/E;for(let z=0;z<p;z++)b=r[z][M],S=r[z][M+1],b==null||S==null?(L=N,C=0):(T=b*(1-I)+S*I,R=(T-l.min)*x,R=_t(~~R,0,d-1),L=g[R],C=255),y.set([L[0],L[1],L[2],C],_),_+=f*4;v+=P}const O=new ImageData(y,f,p);return await createImageBitmap(O,0,0,f,p)}const uu=2147483648,fu=4294967295;function du(e,t,n){const i=n.filter(p=>p.data.values),r=xu(i),s=new Map,o=yu(r,t,s);_u(o);const a=pu(r,e),c=Tu(e,o,t),h=mu(s,c),u=[...gu(h,e),...Object.values(c).flat().filter(p=>!p.exclude)];return{lines:a,areas:u}}function pu(e,t){return e.filter(i=>i.visualization==="line").map(i=>({id:i.name,label:i.name,width:2,color:lt(i.color||"black"),data:t.map((r,s)=>[r[0],i.values[s]])}))}function gu(e,t){return e.map((i,r)=>{const s=r+1<e.length?e[r+1]:null;return{id:i.id,color:lt(i.color),data:t.map((o,a)=>[o[0],i.top[a],s?s.top[a]:null])}})}function mu(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:wu(r),top:o.data.map(a=>a[1])}})}function yu(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=Jr(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 _u(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 Jr(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 xu(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 vu(e){return e.colorR===null||e.colorG===null||e.colorB===null?uu:e.colorR<<16|e.colorG<<8|e.colorB}const wu=Ui().domain([0,100]).range(Mo(Zt("#e6f1cf","#85906d"),10));function bu(e,t,n,i){const r=t+1;if(!n||r>=n.length)return null;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||Su(e,a,i))return o}return null}function Su(e,t,n){const i=[];return Jr(n,e.name,i),i.some(r=>t.name===r.identifier)}function Tu(e,t,n){return t.reduce((r,s,o)=>{if(!s.isBase){r[s.group]||(r[s.group]=[]);const a=bu(s,o,t,n);r[s.group].push({id:s.name,label:s.name,color:s.unit&&vu(s.unit)||fu,exclude:s.visualization==="none"||!s.unit,data:e.map((c,h)=>{const l=s.values[h]!==null?Mu(a,t,h):null;return[c[0],s.values[h],l]})})}return r},{})}function Mu(e,t,n){if(!t||!e||e>=t.length)return null;for(let i=e;i<t.length;i++)if(t[i].values[n]!==null)return t[i].values[n];return null}const Ei=.1,Ke=1e3,Pu=150,Au=30,Cu=10;function Lu(e){if(!e||e.length===0)return[];const t=e?e.map(r=>[r.easting,r.northing,r.tvd,r.md]):[],n=ts(es(t)),i=n[n.length-1][0];return n.forEach((r,s)=>{n[s][0]=i-r[0]}),n}function ku(e,t){if(!e||e.length===0)return[];const n=e?e.map(x=>[x.easting,x.northing,x.tvd,x.md]):[],i=new kn(n,{tension:.75,arcDivisions:5e3}),r=i.length,s=Math.round(r*Cu);let o=null;s>0?o=ts(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=null;if(h<Pu){const v=t/180*Math.PI;l=new D(Math.cos(v),Math.sin(v)).mutable}else l=Eu(o,Au);const u=Math.max(0,Ke-r),f=u+r,p=[];let d=[];const g=l.toArray();u>0&&(d=pi(Math.ceil(u*Ei)).map(x=>l.set(g).scale(u*(1-x)).subFrom(a).toArray()),d.pop(),p.push(...d)),p.push(...o);const y=pi(Math.ceil(Ke*Ei)).map(x=>l.set(g).scale(Ke*x).add(c).toArray()).splice(1);return p.push(...y),es(p,null,f)}function Eu(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 ts(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],[p,d]=s[l+1];if(p-u!==0||d-f!==0){const g=Math.abs(o*d-a*p+p*f-d*u+a*u-o*f)/Math.sqrt((p-o)**2+(d-a)**2),y=[o-u,a-f],_=Math.sqrt(y[0]**2+y[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 es(e,t=null,n=0){let i=t||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 Fu=18,Ru=8,Iu=13,Ou="black",zu="Arial",Du=70;class Nu extends bt{constructor(t,n){super(t,n),this.defaultMargins=Fu,this.defaultMinFontSize=Ru,this.defaultMaxFontSize=Iu,this.defaultTextColor=Ou,this.defaultFont=zu,this.isLabelsOnLeftSide=!0,this.maxFontSizeInWorldCoordinates=Du,this.isXFlipped=!1,this.areasWithAvgTopDepth=null,this.drawAreaLabel=(i,r,s,o)=>{const{data:a}=i,{ctx:c,maxFontSizeInWorldCoordinates:h,isXFlipped:l}=this,{xScale:u,yScale:f,xRatio:p,yRatio:d,zFactor:g}=this.rescaleEvent;let y=this.checkDrawLabelsOnLeftSide();const x=(this.options.margins||this.defaultMargins)*(l?-1:1)/p,v=this.options.minFontSize||this.defaultMinFontSize;let b=(this.options.maxFontSize||this.defaultMaxFontSize)/d;b>h&&(b=h,b*d<v&&(b=v/d));const S=u.invert(u.range()[0])+x,T=u.invert(u.range()[1])-x,[R,L]=this.getSurfacesAreaEdges();c.save(),c.font=`${b*d}px ${this.options.font||this.defaultFont}`;let N=c.measureText(i.label),C=N.width/p;if(y){const X=S+(l?-C:C);(!l&&X>L||l&&X<L)&&(y=!1)}else{const X=T+(l?C:-C);(!l&&X<R||l&&X>R)&&(y=!0)}let O;const $=.07;y?O=l?Math.min(R,S):Math.max(R,S):O=l?Math.max(L,T):Math.min(L,T);const m=f.invert(f.range()[0]),M=f.invert(f.range()[1]),w=5,A=3,E=$*(C/A)*(y?1:-1)*(l?-1:1),F=C/w*(y?1:-1)*(l?-1:1),I=a.map(X=>[X[0],X[1]]),z=this.calcPos(I,O,A,E,m,M);if(!z)return;const B=a.map(X=>[X[0],X[2]]);let V=this.calcPos(B,O,A,E,m,M,r?r.data.map(X=>[X[0],X[1]]):null,s,o);V||(V=new D(z.x,M));const H=V.y-z.y;if(H<b){if(H*d<v)return;b=H,c.font=`${b*d}px ${this.options.font||this.defaultFont}`,N=c.measureText(i.label),C=N.width/p}const W=y!==l?D.right:D.left,Q=this.calcAreaDir(I,B,O,w,F,W,m,M,0,Math.PI/4,4,r?r.data.map(X=>[X[0],X[1]]):null,s,o),U=Math.atan(Math.tan(Q)*g),J=O,$t=(z.y+V.y)/2,Ss=l?-U:U;c.textAlign=y?"left":"right",c.translate(u(J),f($t)),c.rotate(Ss),c.fillStyle=this.options.textColor||this.defaultTextColor,c.font=`${b*d}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,u=this.checkDrawLabelsOnLeftSide(),f=this.getMarginsInWorldCoordinates(),d=(this.options.maxFontSize||this.defaultMaxFontSize)/h;r.save(),r.font=`${d*h}px ${this.options.font||this.defaultFont}`;const y=r.measureText(i.label).width/c,_=o.invert(o.range()[0])+f,x=o.invert(o.range()[1])-f,[v,P]=this.getSurfacesAreaEdges();let b;const S=5;u?b=s?Math.max(P,x):Math.min(P,x):b=s?Math.min(v,_):Math.max(v,_);const T=y/S*(u?-1:1),{data:R}=i,L=this.calcPos(R,b,S,T),N=this.calcLineDir(R,b,S,T,l,u?D.left:D.right);if(!L||!N)return;const C=b,O=L.y-Ar-d/2,$=D.angleRight(N)-(u?Math.PI:0);r.textAlign=u?"right":"left",r.translate(o(C),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=null}generateSurfacesWithAvgDepth(){const{areas:t}=this.data;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||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=null,o=null,a=null,c=null,h=null){const l=D.zero.mutable;let u=0;for(let f=0;f<i;f++){const p=n+f*r,d=gt(t,p,s,o);if(d){const g=this.getAlternativeYValueIfAvailable(p,s,o,a,c,h),y=g?Math.min(d,g):d;l.add(p,y),u++}}return u===0?null:D.divide(l,u)}getAlternativeYValueIfAvailable(t,n,i,r,s,o){if(!r)return null;let a=gt(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=gt(h.data.map(l=>[l[0],l[1]]),t,n,i)}}return a}calcLineDir(t,n,i,r,s,o=D.left,a=null,c=null){const h=o.mutable,l=gt(t,n,a,c);if(l===null)return h;const u=new D(n,l*s),f=D.zero.mutable;for(let p=1;p<=i;p++){const d=n+p*r,g=gt(t,n,a,c);g!==null&&(f.set(d,g*s),f.sub(u),h.add(f))}return h}calcAreaDir(t,n,i,r,s,o=D.left,a=null,c=null,h=0,l=Math.PI/4,u=4,f=null,p=null,d=null){const g=[],y=D.zero.mutable;let _;for(let T=0;T<=r;T++){const R=i+T*s,L=gt(t,R,a,c),N=gt(n,R,a,c)||c,C=this.getAlternativeYValueIfAvailable(R,a,c,f,p,d),O=C?Math.min(N,C):N;if(T===0){if(L===null)return D.angleRight(o);const $=(L+O)/2;_=new D(i,$)}else L!==null?(y.set(R,(L+O)/2),y.sub(_),g.push(D.angleRight(y))):g.push(D.angleRight(o))}const x=g[0],v=g.map(T=>T-x);let P=0;return v.reduce((T,R)=>{const L=(Math.abs(R)-h)/l,N=Math.pow(1-_t(L,0,1),u);return P+=N,T+R*N},0)/P+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 p=Math.max(u[0][0],f[0][0]),d=Math.min(u[0][0],f[0][0]),g={left:n?p:d,right:n?d:p},y=this.getMarginsInWorldCoordinates(),_=a+y,x=c-y,[v,P]=this.getSurfacesAreaEdges(),b=n?Math.min(_,v):Math.max(_,v),S=n?Math.max(x,P):Math.min(x,P),T=Math.max(n?b-g.left:g.left-b,0),R=Math.max(n?g.right-S:S-g.right,0),L=T*s,N=R*s;return T>R||L>o||L<o&&N<o&&n||f[0][1]<h}}const $u=1e4;class Bu extends Nn{constructor(){super(...arguments),this.isPreRendered=!1,this.createPolygons=t=>{const n=[];let i=null;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]||$u);n.push(i),i=null}}return n},this.generateAreaPolygon=t=>{const n=new k.Graphics;n.lineStyle(1,t.color,1),n.beginFill(t.color),this.createPolygons(t.data).forEach(r=>n.drawPolygon(r)),n.endFill(),this.addChild(n)},this.generateSurfaceLine=t=>{const n=new k.Graphics,{data:i}=t,r=.5;n.lineStyle(Ar,t.color,1,r,!0);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 ns="lightgray",is="gray",rs=.25,ss=.75,Hu={minorColor:ns,majorColor:is,minorWidth:rs,majorWidth:ss};class ge extends bt{constructor(t,n){super(t,n),this._offsetX=0,this._offsetY=0,this.options={...this.options,...n||Hu},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[p,d]=a.range(),[g,y]=c.range();n.lineWidth=i||rs,n.strokeStyle=r||ns;const _=this.mapMinorTicks(a.ticks()),x=this.mapMinorTicks(c.ticks());this.renderTicksX(a,_,g,y),this.renderTicksY(c,x,p,d),n.lineWidth=s||ss,n.strokeStyle=o||is,this.renderTicksX(a,a.ticks(),g,y),this.renderTicksY(c,c.ticks(),p,d),n.restore()}renderTicksX(t,n,i,r){n.forEach(s=>{const o=t(s);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.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 Xu 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.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"),10),i=parseInt(this.elm.getAttribute("height"),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.isLoading?this.img.onload=()=>{this.isLoading=!1,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},mt=class{constructor(e,t={}){this.cursor=new st.Point,this.scale=1,this.graphics=e,t={...Vu,...t},this.dash=t.dash,this.dashSize=this.dash.reduce((n,i)=>n+i),this.useTexture=t.useTexture,this.options=t,this.setLineStyle()}setLineStyle(){const e=this.options;if(this.useTexture){const t=mt.getTexture(e,this.dashSize);this.graphics.lineTextureStyle({width:e.width*e.scale,color:e.color,alpha:e.alpha,texture:t,alignment:e.alignment})}else this.graphics.lineStyle({width:e.width*e.scale,color:e.color,alpha:e.alpha,cap:e.cap,join:e.join,alignment:e.alignment});this.scale=e.scale}static distance(e,t,n,i){return Math.sqrt(Math.pow(n-e,2)+Math.pow(i-t,2))}moveTo(e,t){return this.lineLength=0,this.cursor.set(e,t),this.start=new st.Point(e,t),this.graphics.moveTo(this.cursor.x,this.cursor.y),this}lineTo(e,t,n){typeof this.lineLength===void 0&&this.moveTo(0,0);const i=mt.distance(this.cursor.x,this.cursor.y,e,t),r=Math.atan2(t-this.cursor.y,e-this.cursor.x),s=n&&e===this.start.x&&t===this.start.y;if(this.useTexture)if(this.graphics.moveTo(this.cursor.x,this.cursor.y),this.adjustLineStyle(r),s&&this.dash.length%2===0){const o=Math.min(this.dash[this.dash.length-1],i);this.graphics.lineTo(e-Math.cos(r)*o,t-Math.sin(r)*o),this.graphics.closePath()}else this.graphics.lineTo(e,t);else{const o=Math.cos(r),a=Math.sin(r);let c=this.cursor.x,h=this.cursor.y;const l=this.lineLength%(this.dashSize*this.scale);let u=0,f=0,p=0;for(let g=0;g<this.dash.length;g++){const y=this.dash[g]*this.scale;if(l<p+y){u=g,f=l-p;break}else p+=y}let d=i;for(;d>0;){const g=this.dash[u]*this.scale-f,y=d>g?g:d;if(s&&mt.distance(c+o*y,h+a*y,this.start.x,this.start.y)<=y){if(u%2===0){const x=mt.distance(c,h,this.start.x,this.start.y)-this.dash[this.dash.length-1]*this.scale;c+=o*x,h+=a*x,this.graphics.lineTo(c,h)}break}c+=o*y,h+=a*y,u%2?this.graphics.moveTo(c,h):this.graphics.lineTo(c,h),d-=y,u++,u=u===this.dash.length?0:u,f=0}}return this.lineLength+=i,this.cursor.set(e,t),this}closePath(){this.lineTo(this.start.x,this.start.y,!0)}drawCircle(e,t,n,i=80,r){const s=Math.PI*2/i;let o=0,a;r?(a=new st.Point(e+Math.cos(o)*n,t+Math.sin(o)*n),r.apply(a,a),this.moveTo(a[0],a[1])):(a=new st.Point(e+Math.cos(o)*n,t+Math.sin(o)*n),this.moveTo(a.x,a.y)),o+=s;for(let c=1;c<i+1;c++){const h=c===i?a:[e+Math.cos(o)*n,t+Math.sin(o)*n];this.lineTo(h[0],h[1]),o+=s}return this}drawEllipse(e,t,n,i,r=80,s){const o=Math.PI*2/r;let a;const c=new st.Point;for(let h=0;h<Math.PI*2;h+=o){let l=e-n*Math.sin(h),u=t-i*Math.cos(h);s&&(c.set(l,u),s.apply(c,c),l=c.x,u=c.y),h===0?(this.moveTo(l,u),a={x:l,y:u}):this.lineTo(l,u)}return this.lineTo(a.x,a.y,!0),this}drawPolygon(e,t){const n=new st.Point;if(typeof e[0]=="number")if(t){n.set(e[0],e[1]),t.apply(n,n),this.moveTo(n.x,n.y);for(let i=2;i<e.length;i+=2)n.set(e[i],e[i+1]),t.apply(n,n),this.lineTo(n.x,n.y,i===e.length-2)}else{this.moveTo(e[0],e[1]);for(let i=2;i<e.length;i+=2)this.lineTo(e[i],e[i+1],i===e.length-2)}else if(t){const i=e[0];n.copyFrom(i),t.apply(n,n),this.moveTo(n.x,n.y);for(let r=1;r<e.length;r++){const s=e[r];n.copyFrom(s),t.apply(n,n),this.lineTo(n.x,n.y,r===e.length-1)}}else{const i=e[0];this.moveTo(i.x,i.y);for(let r=1;r<e.length;r++){const s=e[r];this.lineTo(s.x,s.y,r===e.length-1)}}return this}drawRect(e,t,n,i,r){if(r){const s=new st.Point;s.set(e,t),r.apply(s,s),this.moveTo(s.x,s.y),s.set(e+n,t),r.apply(s,s),this.lineTo(s.x,s.y),s.set(e+n,t+i),r.apply(s,s),this.lineTo(s.x,s.y),s.set(e,t+i),r.apply(s,s),this.lineTo(s.x,s.y),s.set(e,t),r.apply(s,s),this.lineTo(s.x,s.y,!0)}else this.moveTo(e,t).lineTo(e+n,t).lineTo(e+n,t+i).lineTo(e,t+i).lineTo(e,t,!0);return this}adjustLineStyle(e){const t=this.graphics.line;t.matrix=new st.Matrix,e&&t.matrix.rotate(e),this.scale!==1&&t.matrix.scale(this.scale,this.scale);const n=-this.lineLength;t.matrix.translate(this.cursor.x+n*Math.cos(e),this.cursor.y+n*Math.sin(e)),this.graphics.lineStyle(t)}static getTexture(e,t){const n=e.dash.toString();if(mt.dashTextureCache[n])return mt.dashTextureCache[n];const i=document.createElement("canvas");i.width=t,i.height=Math.ceil(e.width);const r=i.getContext("2d");if(!r){console.warn("Did not get context from canvas");return}r.strokeStyle="white",r.globalAlpha=e.alpha,r.lineWidth=e.width;let s=0;const o=e.width/2;r.moveTo(s,o);for(let c=0;c<e.dash.length;c+=2)s+=e.dash[c],r.lineTo(s,o),e.dash.length!==c+1&&(s+=e.dash[c+1],r.moveTo(s,o));r.stroke();const a=mt.dashTextureCache[n]=st.Texture.from(i);return a.baseTexture.scaleMode=st.SCALE_MODES.NEAREST,a}};let os=mt;os.dashTextureCache={};const vn=e=>new D(e.x,e.y),Uu=e=>new k.Point(e[0],e[1]),as=e=>{if(e.length<2)return[new D(0)];let t;return e.map((n,i,r)=>{if(i<r.length-1){const s=vn(r[i]);return t=vn(r[i+1]).sub(s).rotate90().normalized(),t}return t})},cs=(e,t,n)=>{const i=vn(e);return Uu(i.add(t.scale(n)))},wn=(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];return cs(i,s,n)})},Fi=(e,t,n,i)=>e<=i&&n<=t,Yu=(e,t,n,i)=>e<i&&n<t,Wu=e=>Array.from(new Set(e)),De=(e,t,n,i)=>{const r=i.filter(o=>Fi(e,t,o.start,o.end)),s=n.filter(o=>Fi(e,t,o.start,o.end));return{overlappingHoles:r,overlappingOuterStrings:s}},Ne=([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),Wu(s).sort((a,c)=>a-c)},G=e=>e.kind==="casing"?e.innerDiameter:e.diameter,hs=(e,t,n,i)=>{const s=e.find(h=>h.start<=i&&h.end>=i),o=s?s.diameter:0,a=t.filter(h=>G(h)>o).sort((h,l)=>G(h)-G(l)).find(h=>h.start<=i&&h.end>=i),c=n.find(h=>h.start<=i&&h.end>=i&&h.diameter>o);return a?G(a):c?c.diameter:100},Gu=(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"?G(s):o?o.diameter:100},qu=(e,t,n,i)=>{const s=e.sort((h,l)=>G(h)-G(l)).find(h=>h.start<=i&&h.end>=i);if(s)return G(s);const o=e.length?Math.min(...e.map(h=>G(h))):0,a=t.sort((h,l)=>G(h)-G(l)).find(h=>h.start<=i&&h.end>=i&&o<=G(h));if(a)return G(a);const c=n.find(h=>h.start<=i&&h.end>=i&&h.diameter);return c?c.diameter:100},ju=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Hn(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}=De(e.toc,c,a,i),u=[...h,...l].map(g=>({start:g.start,end:g.end}));return Ne([e.toc,c],u).flatMap((g,y,_)=>{if(y===_.length-1)return[];const x=_[y+1],v=hs(o,h,l,g);return[{top:g,bottom:x,diameter:v*r}]}).map(g=>({diameter:g.diameter,points:s(g.top,g.bottom)}))},Hn=(e,t,n)=>[...t,...n].reduce((i,r)=>e.includes(r.id)?{...i,attachedStrings:[...i.attachedStrings,r]}:{...i,nonAttachedStrings:[...i.nonAttachedStrings,r]},{attachedStrings:[],nonAttachedStrings:[]}),Zu=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Hn(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}=De(e.start,e.end,a,i),l=[...c,...h].map(d=>({start:d.start,end:d.end}));return Ne([e.start,e.end],l).flatMap((d,g,y)=>{if(g===y.length-1)return[];const _=y[g+1],x=hs(o,c,h,d);return[{top:d,bottom:_,diameter:x*r}]}).map(d=>({diameter:d.diameter,points:s(d.top,d.bottom)}))},Ku=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Hn(e.referenceIds,t,n),{overlappingHoles:c,overlappingOuterStrings:h}=De(e.start,e.end,a,i),l=[...o,...c,...h].map(d=>({start:d.start,end:d.end}));return Ne([e.start,e.end],l).flatMap((d,g,y)=>{if(g===y.length-1)return[];const _=y[g+1],x=qu(o,h,c,d);return[{top:d,bottom:_,diameter:x*r}]}).map(d=>({diameter:d.diameter,points:s(d.top,d.bottom)}))},Qu=(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},Ju=({firstColor:e,secondColor:t},n,i)=>{const r=document.createElement("canvas");r.width=n,r.height=i;const s=r.getContext("2d");return s.fillStyle=Qu(r,s,e,t,0),s.fillRect(0,0,r.width,r.height),k.Texture.from(r)},t0=({scalingFactor:e})=>{const t=document.createElement("canvas"),n=xt*e;t.width=n,t.height=n;const i=t.getContext("2d");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(),k.Texture.from(t)},e0=({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"),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),k.Texture.from(r)},n0=({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");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(),k.Texture.from(i)},i0=({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");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(),k.Texture.from(i)},r0=({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");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(),k.Texture.from(i)},me=(e,t)=>{const n=as(t),i=wn(t,n,e);return{leftPath:wn(t,n,-e),rightPath:i}},Qe=(e,t)=>({kind:"casing",start:e,end:t}),s0=(e,t)=>({kind:"casing-window",start:e,end:t}),o0=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?Qe(i,r.start):null,c=a?a.end:i,h=Math.max(c,r.start),l=Math.min(e.end,r.end),u=s0(h,l),f=l,d=s===o.length-1&&f<e.end?Qe(f,e.end):null,g=[a,u,d].filter(y=>y);return{intervals:[...n,...g],lastBottom:f}},{intervals:[],lastBottom:e.start});return t.intervals.length?t.intervals:[Qe(e.start,e.end)]},a0=(e,t,n)=>{const i=t.diameter*e,r=i/2,o=t.innerDiameter*e/2,a=r-o,c=o0(t).map(h=>{const l=n(h.start,h.end),{leftPath:u,rightPath:f}=me(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}},c0=(e,t,n,i,r)=>{const{overlappingOuterStrings:s,overlappingHoles:o}=De(e.start,e.end,t,n),a=[...s,...o].map(u=>({start:u.start,end:u.end}));return Ne([e.start,e.end],a).flatMap((u,f,p)=>{if(f===p.length-1)return[];const d=p[f+1],g=Gu(s,o,u,e.subKind);return[{top:u,bottom:d,diameter:g*i}]}).map(u=>{const f=r(u.top,u.bottom);return{diameter:u.diameter,points:f}})},$e=(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()},Xn=(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 p=()=>{for(let d=-1;d<o;d++){const g=[d*a+u+a/2,e.height/2-h-f-h];t.beginPath();const y=[...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],P=[g[0],g[1]-h];t.bezierCurveTo(...y,..._,...x),t.bezierCurveTo(...x,...v,...P),t.stroke()}for(let d=-1;d<o;d++){const g=[d*a+a+u+a/2,e.height/2+c/2+f];t.beginPath();const y=[...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],P=[g[0],g[1]+h];t.bezierCurveTo(...y,..._,...x),t.bezierCurveTo(...x,...v,...P),t.stroke()}};t.strokeStyle=i.yellow,t.lineWidth=6,t.save(),p(),t.restore(),t.lineWidth=1,t.strokeStyle=i.outline,p(),t.closePath()},h0=(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()},at=(e="Error!",t)=>{console.error(`${e}`);const n=(t==null?void 0:t.canvas)||document.createElement("canvas"),i=xt;n.width=i/2,n.height=i;const r=(t==null?void 0:t.canvasCtx)||n.getContext("2d"),s=[0,0],o=[n.width,n.height];return r.fillStyle="#ff00ff",r.fillRect(...s,...o),new k.Texture(k.Texture.from(n,{wrapMode:k.WRAP_MODES.CLAMP}).baseTexture,null,new k.Rectangle(0,0,n.width,n.height),null,k.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");return{canvas:n,ctx:s}},wt=e=>new k.Texture(k.Texture.from(e,{wrapMode:k.WRAP_MODES.CLAMP}).baseTexture,null,new k.Rectangle(0,0,e.width,e.height),null,k.groupD8.MIRROR_HORIZONTAL),l0=(e,t)=>n=>t.some(i=>n(i)&&$r(e,i)),Vn={packing:()=>at(),fracLines:()=>at(),spikes:(e,t,n,i)=>{const{canvas:r,ctx:s}=vt(t,i),o=l0(e,n),a=o(zr),c=o(Nr),h=o(Dr),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),h0(r,s,t.diameter,i),h&&Xn(r,s,t.diameter,i,"spike"),wt(r)}},ls={packing:()=>at(),fracLines:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return Xn(n,i,e.diameter,t,"diameter"),wt(n)},spikes:()=>at()},ke={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return $e(n,i,t),wt(n)},fracLines:(e,t)=>{const{canvas:n}=vt(e,t);return wt(n)},spikes:()=>at()},Un={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return $e(n,i,t),wt(n)},fracLines:()=>at(),spikes:()=>at()},Yn={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return $e(n,i,t),wt(n)},fracLines:()=>at(),spikes:()=>at()},Wn={packing:(e,t,n)=>{const{canvas:i,ctx:r}=vt(t,n);return $e(i,r,n),wt(i)},fracLines:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return Xn(n,i,e.diameter,t,"diameter"),wt(n)},spikes:()=>at()},u0=(e,t,n)=>Z({Perforation:()=>Vn.packing(),CasedHoleFracturation:()=>ke.packing(t,n),CasedHoleFracPack:()=>ke.packing(t,n),OpenHoleGravelPack:()=>Yn.packing(t,n),OpenHoleFracPack:()=>Wn.packing(e,t,n),CasedHoleGravelPack:()=>Un.packing(t,n)},e.subKind),f0=(e,t,n)=>Z({Perforation:()=>Vn.fracLines(),OpenHoleGravelPack:()=>Yn.fracLines(),OpenHoleFracPack:()=>Wn.fracLines(t,n),CasedHoleFracturation:()=>ls.fracLines(t,n),CasedHoleGravelPack:()=>Un.fracLines(),CasedHoleFracPack:()=>ke.fracLines(t,n)},e.subKind),d0=(e,t,n,i)=>Z({Perforation:()=>Vn.spikes(e,n,t,i),OpenHoleGravelPack:()=>Yn.spikes(),OpenHoleFracPack:()=>Wn.spikes(),CasedHoleFracturation:()=>ls.spikes(),CasedHoleGravelPack:()=>Un.spikes(),CasedHoleFracPack:()=>ke.spikes()},e.subKind);class p0 extends k.MeshGeometry{constructor(t){const n=Ve(t,i=>i.points.length);super(new Float32Array(n*4),new Float32Array(n*4),new Uint16Array((n-1)*6)),this.segments=t,this.build()}get width(){return nn(this.segments,t=>t.diameter)}build(){const t=this.segments;if(!t)return;const n=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),r=this.getIndex(),s=Ve(t,d=>d.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=nn(t,d=>d.diameter);let l=0,u=0,f=0,p=0;for(let d=0;d<c;d++){let g=t[d].points[0];const y=h,_=t[d].diameter/h/2,x=t[d].points.length;for(let v=0;v<x;v++){const P=g.x-t[d].points[v].x,b=g.y-t[d].points[v].y,S=Math.sqrt(P*P+b*b);g=t[d].points[v],l+=S/y,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[p++]=f,a[p++]=f+1,a[p++]=f+2,a[p++]=f+2,a[p++]=f+1,a[p++]=f+3,f+=2;f+=2}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.segments;if(Ve(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 p=0;p<u;p++){const d=t[s].points[p];f=r+p*4,p<t[s].points.length-1?a=t[s].points[p+1]:a=d,h=-(a.x-o.x),c=a.y-o.y;const g=Math.sqrt(c*c+h*h),y=t[s].diameter/2;c/=g,h/=g,c*=y,h*=y,l[f]=d.x+c,l[f+1]=d.y+h,l[f+2]=d.x-c,l[f+3]=d.y-h,o=d}r=f+4}this.buffers[0].update()}update(){this.build()}}class g0 extends k.Mesh{constructor(t,n){const i=new p0(n),r=new k.MeshMaterial(t);t.baseTexture.wrapMode=k.WRAP_MODES.REPEAT,super(i,r),this.autoUpdate=!0}_render(t){const n=this.geometry;this.autoUpdate&&n.update(),super._render(t)}}class m0 extends k.MeshGeometry{constructor(t,n=200){super(new Float32Array(t.length*4),new Float32Array(t.length*4),new Uint16Array((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("aVertexPosition"),i=this.getBuffer("aTextureCoord"),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,p=c.x-t[u].x,d=c.y-t[u].y,g=Math.sqrt(p*p+d*d);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 y0 extends k.Mesh{constructor(t,n,i){const r=new m0(n,i),s=new k.MeshMaterial(t);t.baseTexture.wrapMode=k.WRAP_MODES.REPEAT,super(r,s),this.autoUpdate=!0}_render(t){const n=this.geometry;this.autoUpdate&&n.update(),super._render(t)}}class _0 extends k.MeshGeometry{constructor(t,n=200){super(new Float32Array(t.length*4),new Float32Array(t.length*4),new Uint16Array((t.length-1)*6)),this.points=t,this._width=n,this.build()}build(){const t=this.points;if(!t)return;const n=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),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 p=0;p<s;p++){const d=a.x-t[p].x,g=a.y-t[p].y,y=Math.sqrt(d*d+g*g);a=t[p],o+=y}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 p=0;p<s;p++){const d=p*4,g=u.x-t[p].x,y=u.y-t[p].y,_=Math.sqrt(g*g+y*y);u=t[p],l+=_/o,c[d]=l,c[d+1]=0,c[d+2]=l,c[d+3]=1}let f=0;for(let p=0;p<s-1;p++){const d=p*2;h[f++]=d,h[f++]=d+1,h[f++]=d+2,h[f++]=d+2,h[f++]=d+1,h[f++]=d+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 x0 extends k.Mesh{constructor(t,n){const i=new _0(n,t.height),r=new k.MeshMaterial(t);super(i,r),this.autoUpdate=!0}_render(t){const n=this.geometry;(this.autoUpdate||n._width!==this.shader.texture.height)&&(n._width=this.shader.texture.height,n.update()),super._render(t)}}const v0=(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)}},w0=e=>({exaggerationFactor:2,internalLayerOptions:Br(e),holeOptions:Hr,casingOptions:Xr,cementOptions:Ur,cementSqueezeOptions:Yr,screenOptions:Wr,tubingOptions:Gr,cementPlugOptions:qr,perforationOptions:Vr}),us=class extends Nn{constructor(e,t,n){super(e,t,n),this.internalLayerVisibility={holeLayerId:!0,casingLayerId:!0,completionLayerId:!0,cementLayerId:!0,pAndALayerId:!0,perforationLayerId:!0},this.scalingFactors={height:600,zFactor:1,yScale:At()},this.getZFactorScaledPathForPoints=(i,r)=>{const s=a=>a*this.scalingFactors.zFactor;return this.referenceSystem.getCurtainPath(i,r,!0).map(a=>new k.Point(a.point[0],s(a.point[1])))},this.drawBigPolygon=(i,r=0)=>{const s=new k.Graphics;s.beginFill(r),s.drawPolygon(i),s.endFill(),this.addChild(s)},this.perforationRopeAndTextureReferences=[],this.prepareSymbolRenderObject=i=>{const{exaggerationFactor:r}=this.options,s=i.diameter*r;return{pathPoints:this.getZFactorScaledPathForPoints(i.start,i.end),referenceDiameter:s,symbolKey:i.symbolKey}},this.drawSymbolComponent=({pathPoints:i,referenceDiameter:r,symbolKey:s})=>{const o=this.getSymbolTexture(s,r);this.drawSVGRope(i,o)},this.drawHoleSize=(i,r)=>{if(r==null)return;const s=this.getZFactorScaledPathForPoints(r.start,r.end);if(s.length===0)return;const{exaggerationFactor:o,holeOptions:a}=this.options,c=r.diameter*o,{rightPath:h,leftPath:l}=me(c/2,s),u=this.getHoleTexture(a,c,i);this.drawHoleRope(s,u,i),this.drawOutline(l,h,lt(a.lineColor),Al*o,"TopAndBottom",0)},this.drawCasing=i=>{const{casingOptions:r}=this.options,s=lt(r.solidColor),o=lt(r.lineColor);i.sections.forEach((a,c,h)=>{const l=us.getOutlineClosureType(c,h.length-1),u=this.createCasingTexture(i.referenceDiameter);this.drawRope(a.pathPoints,u,s),a.kind==="casing-window"?this.drawCasingWindowOutline(a.leftPath,a.rightPath,r,i.casingWallWidth):this.drawOutline(a.leftPath,a.rightPath,o,i.casingWallWidth,l)})},this.generateShoe=(i,r,s,o)=>{const a=i-s,c=i,h=this.getZFactorScaledPathForPoints(a,c),l=as(h),u=wn(h,l,r*(o<0?-1:1)),f=h[h.length-1],p=l[l.length-1],d=cs(f,p,o+r*(o<0?-1:1));return[...u,d]},this.createCementSqueezeShape=(i,r,s,o)=>{const{exaggerationFactor:a}=this.options;return Zu(i,r,s,o,a,this.getZFactorScaledPathForPoints)},this.createPerforationShape=(i,r,s)=>{const{exaggerationFactor:o}=this.options;return c0(i,r,s,o,this.getZFactorScaledPathForPoints)},this.options={...this.options,...w0(this.id),...n}}onUnmount(e){super.onUnmount(e),this.scalingFactors=null,this.cementTextureCache=null,this.cementSqueezeTextureCache=null,this.holeTextureCache=null,this.screenTextureCache=null,this.tubingTextureCache=null,this.textureSymbolCacheArray=null,this.internalLayerVisibility=null}onUpdate(e){super.onUpdate(e),this.clearLayer(),this.preRender(),this.render()}onRescale(e){const t=this.scalingFactors.zFactor!==e.zFactor;this.scalingFactors={height:e.height,zFactor:e.zFactor,yScale:e.yScale},super.optionsRescale(e);const n=this.yRatio(),i=e.xBounds[0]>e.xBounds[1],r=e.yBounds[0]>e.yBounds[1];this.setContainerPosition(e.xScale(0),e.yScale(0)),this.setContainerScale(e.xRatio*(i?-1:1),n*(r?-1:1)),t&&(this.clearLayer(),this.preRender()),this.render()}setVisibility(e,t){if(t===this.id){super.setVisibility(e,t);return}const{internalLayerOptions:n}=this.options,[i]=Object.entries(n).find(([r,s])=>s===t);i&&(this.internalLayerVisibility[i]=e,this.clearLayer(),this.preRender(),this.render())}getInternalLayerIds(){const{internalLayerOptions:e}=this.options;return Object.values(e)}yRatio(){const e=this.scalingFactors.yScale.domain(),n=(e[1]-e[0])*this.scalingFactors.zFactor,i=[e[0],e[0]+n];return Math.abs(this.scalingFactors.height/(i[1]-i[0]))}drawRope(e,t,n){if(e.length===0)return null;const i=new k.SimpleRope(t,e,1);i.tint=n||i.tint,this.addChild(i)}drawOutline(e,t,n,i=1,r="None",s=1){const o=e.map(l=>l.clone()).reverse(),a=t[0],c=o[0],h=new k.Graphics;h.lineStyle(i,n,void 0,s),h.moveTo(a.x,a.y),t.forEach(l=>h.lineTo(l.x,l.y)),(r==="None"||r==="Top")&&h.moveTo(c.x,c.y),o.forEach(l=>h.lineTo(l.x,l.y)),(r==="TopAndBottom"||r==="Top")&&h.lineTo(a.x,a.y),this.addChild(h)}drawCasingWindowOutline(e,t,{lineColor:n,windowOptions:i},r=1){var d,g;const s=!!((g=(d=this.referenceSystem)==null?void 0:d.options)!=null&&g.calculateDisplacementFromBottom),[o,a]=s?[e,t]:[t,e],[c,h]=s?[1,0]:[0,1],l=new k.Graphics;l.lineStyle(r,lt(n),void 0,h);const u=o[0];l.moveTo(u.x,u.y),o.forEach(y=>l.lineTo(y.x,y.y));const f=new os(l,{dash:[i.dashLength,i.spaceLength],color:lt(i.dashColor),width:r,alignment:c}),p=a[0];f.moveTo(p.x,p.y),a.forEach(y=>{f.lineTo(y.x,y.y)}),this.addChild(l)}preRender(){if(!this.data||!this.referenceSystem)return;const{exaggerationFactor:e}=this.options,{holeSizes:t,casings:n,cements:i,completion:r,symbols:s,pAndA:o,perforations:a}=this.data;this.updateSymbolCache(s),t.sort((d,g)=>g.diameter-d.diameter);const c=t.length>0?nn(t,d=>d.diameter)*e:Pl*e;this.internalLayerVisibility.holeLayerId&&t.forEach(d=>this.drawHoleSize(c,d)),n.sort((d,g)=>g.diameter-d.diameter);const h=n.map(d=>this.createCasingRenderObject(d)),l=i.map(d=>({kind:"cement",segments:ju(d,n,r,t,e,this.getZFactorScaledPathForPoints),casingIds:(d.referenceIds||[]).filter(g=>g)})),[u,f]=o.reduce(([d,g],y)=>kr(y)?[[y,...d],g]:[d,[y,...g]],[[],[]]),p=u.map(d=>({kind:"cementSqueeze",segments:this.createCementSqueezeShape(d,n,r,t),casingIds:d.referenceIds}));if(this.sortCementAndCasingRenderObjects(h,l,p).forEach(v0(d=>{this.internalLayerVisibility.casingLayerId&&(this.drawCasing(d),d.hasShoe&&this.drawShoe(d.bottom,d.referenceRadius))},d=>{this.internalLayerVisibility.cementLayerId&&this.drawComplexRope(d.segments,this.getCementTexture())},d=>{this.internalLayerVisibility.pAndALayerId&&this.drawComplexRope(d.segments,this.getCementSqueezeTexture())})),this.perforationRopeAndTextureReferences.forEach(({rope:d,texture:g})=>{d.destroy({children:!0,texture:!0,baseTexture:!0}),g.destroy(!0)}),this.perforationRopeAndTextureReferences=[],this.internalLayerVisibility.perforationLayerId){const{perforationOptions:d}=this.options,g=a.filter(Rr),y=a.filter(Ir),_=a.filter(Or);g.forEach(x=>{const P=this.createPerforationShape(x,n,t).reduce((b,S)=>(b[S.diameter]||(b[S.diameter]=[]),b[S.diameter]=[...b[S.diameter],S],b),{});Object.values(P).forEach(b=>{const S=u0(x,b[0],d),T=this.drawComplexRope(b,S);this.perforationRopeAndTextureReferences.push({rope:T,texture:S})})}),_.forEach(x=>{const b=this.createPerforationShape(x,n,t).map(S=>({...S,diameter:S.diameter*3})).reduce((S,T)=>(S[T.diameter]||(S[T.diameter]=[]),S[T.diameter]=[...S[T.diameter],T],S),{});Object.values(b).forEach(S=>{S.forEach(T=>{const R=d0(x,a,T,d),L=this.drawComplexRope([T],R);this.perforationRopeAndTextureReferences.push({rope:L,texture:R})})})}),y.forEach(x=>{const b=this.createPerforationShape(x,n,t).map(S=>({...S,diameter:S.diameter*3})).reduce((S,T)=>(S[T.diameter]||(S[T.diameter]=[]),S[T.diameter]=[...S[T.diameter],T],S),{});Object.values(b).forEach(S=>{S.forEach(T=>{const R=f0(x,T,d),L=this.drawComplexRope([T],R);this.perforationRopeAndTextureReferences.push({rope:L,texture:R})})})})}this.internalLayerVisibility.completionLayerId&&r.forEach(Fr(d=>this.drawScreen(d),d=>this.drawTubing(d),d=>{const g=this.prepareSymbolRenderObject(d);this.drawSymbolComponent(g)})),this.internalLayerVisibility.pAndALayerId&&f.forEach(d=>{if(Lr(d)){const g=this.prepareSymbolRenderObject(d);this.drawSymbolComponent(g)}Er(d)&&this.drawCementPlug(d,n,r,t)})}updateSymbolCache(e){if(this.textureSymbolCacheArray||(this.textureSymbolCacheArray={}),!e)return;const t=Object.keys(this.textureSymbolCacheArray);Object.entries(e).forEach(([n,i])=>{t.includes(n)||(this.textureSymbolCacheArray[n]=k.Texture.from(i))})}drawCementPlug(e,t,n,i){const{exaggerationFactor:r,cementPlugOptions:s}=this.options,o=Ku(e,t,n,i,r,this.getZFactorScaledPathForPoints);this.drawComplexRope(o,this.getCementPlugTexture(s));const{rightPath:a,leftPath:c}=o.reduce((h,l)=>{const{leftPath:u,rightPath:f}=me(l.diameter/2,l.points);return{rightPath:[...h.rightPath,...f],leftPath:[...h.leftPath,...u]}},{rightPath:[],leftPath:[]});this.drawOutline(c,a,lt("black"),.25,"TopAndBottom")}createCasingRenderObject(e){const{exaggerationFactor:t}=this.options;return a0(t,e,this.getZFactorScaledPathForPoints)}getCementPlugTexture(e){return this.cementPlugTextureCache||(this.cementPlugTextureCache=i0(e)),this.cementPlugTextureCache}drawSVGRope(e,t){if(e.length===0)return null;const n=new x0(t,e);this.addChild(n)}getSymbolTexture(e,t){return new k.Texture(this.textureSymbolCacheArray[e].baseTexture,null,new k.Rectangle(0,0,0,t),null,k.groupD8.MAIN_DIAGONAL)}drawHoleRope(e,t,n){if(e.length===0)return null;const i=new k.SimpleRope(t,e,n/xt);this.addChild(i)}getHoleTexture(e,t,n){const i=xt,r=i,s=i,o=t/n*i;this.holeTextureCache||(this.holeTextureCache=Ju(e,s,r));const a=this.holeTextureCache.baseTexture,c=(r-o)/2,h=new k.Rectangle(0,c,s,o);return new k.Texture(a,h)}sortCementAndCasingRenderObjects(e,t,n){let i=0;const{result:r}=e.reduce((s,o)=>{const a=s.remainingCement.find(h=>h.casingIds.includes(o.id)),c=s.remainingCementSqueezes.filter(h=>h.casingIds.includes(o.id));return a&&(a.zIndex=i++),c.forEach(h=>h.zIndex=i++),o.zIndex=i++,{result:[...s.result,a,o,...c],remainingCement:s.remainingCement.filter(h=>h!==a),remainingCementSqueezes:s.remainingCementSqueezes.filter(h=>!c.includes(h))}},{result:[],remainingCement:t,remainingCementSqueezes:n});return r.filter(s=>s!==void 0).sort((s,o)=>s.zIndex-o.zIndex)}drawComplexRope(e,t){if(e.length===0)return null;const n=new g0(t,e);return this.addChild(n),n}createCasingTexture(e){return new k.Texture(k.Texture.WHITE.baseTexture,null,new k.Rectangle(0,0,16,e))}drawShoe(e,t){const{exaggerationFactor:n,casingOptions:i}=this.options,r=i.shoeSize.width*n,s=i.shoeSize.length*n,o=this.generateShoe(e,t,s,r),a=this.generateShoe(e,t,s,-r);this.drawBigPolygon(a),this.drawBigPolygon(o)}getCementTexture(){if(!this.cementTextureCache){const{cementOptions:e}=this.options;this.cementTextureCache=n0(e)}return this.cementTextureCache}getCementSqueezeTexture(){if(!this.cementSqueezeTextureCache){const{cementSqueezeOptions:e}=this.options;this.cementSqueezeTextureCache=r0(e)}return this.cementSqueezeTextureCache}drawScreen({start:e,end:t,diameter:n}){const{exaggerationFactor:i,screenOptions:r}=this.options,s=i*n,o=this.getZFactorScaledPathForPoints(e,t),{leftPath:a,rightPath:c}=me(s/2,o),h=this.getScreenTexture();this.drawCompletionRope(o,h,s),this.drawOutline(a,c,lt(r.lineColor),Cl*i,"TopAndBottom")}drawTubing({diameter:e,start:t,end:n}){const{exaggerationFactor:i,tubingOptions:r}=this.options,s=i*e,o=this.getZFactorScaledPathForPoints(t,n),a=this.getTubingTexture(r);this.drawCompletionRope(o,a,s)}getTubingTexture(e){return this.tubingTextureCache||(this.tubingTextureCache=e0(e)),this.tubingTextureCache}getScreenTexture(){if(!this.screenTextureCache){const{screenOptions:e}=this.options;this.screenTextureCache=t0(e)}return this.screenTextureCache}drawCompletionRope(e,t,n){if(e.length===0)return;const i=new y0(t,e,n);this.addChild(i)}};let fs=us;fs.getOutlineClosureType=(e,t)=>e===0?e===t?"TopAndBottom":"Top":e===t?"Bottom":"None";class b0 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 Lt(e){return function(){return e}}const Ri=1e-12,bn=Math.PI,Sn=2*bn,Tt=1e-6,S0=Sn-Tt;function ds(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function T0(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return ds;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?ds:T0(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 p=i-o,d=r-a,g=c*c+h*h,y=p*p+d*d,_=Math.sqrt(g),x=Math.sqrt(f),v=s*Math.tan((bn-Math.acos((g+f-y)/(2*_*x)))/2),P=v/x,b=v/_;Math.abs(P-1)>Tt&&this._append`L${t+P*l},${n+P*u}`,this._append`A${s},${s},0,0,${+(u*p>l*d)},${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)>Tt||Math.abs(this._y1-l)>Tt)&&this._append`L${h},${l}`,i&&(f<0&&(f=f%Sn+Sn),f>S0?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>=bn)},${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 A0(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ps(e){this._context=e}ps.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 gs(e){return new ps(e)}function C0(e){return e[0]}function L0(e){return e[1]}function k0(e,t){var n=Lt(!0),i=null,r=gs,s=null,o=P0(a);e=typeof e=="function"?e:e===void 0?C0:Lt(e),t=typeof t=="function"?t:t===void 0?L0:Lt(t);function a(c){var h,l=(c=A0(c)).length,u,f=!1,p;for(i==null&&(s=r(p=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(p)return s=null,p+""||null}return a.x=function(c){return arguments.length?(e=typeof c=="function"?c:Lt(+c),a):e},a.y=function(c){return arguments.length?(t=typeof c=="function"?c:Lt(+c),a):t},a.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Lt(!!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 Ii(){}function Tn(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 Be(e){this._context=e}Be.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:Tn(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:Tn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function E0(e){return new Be(e)}function ms(e){this._context=e}ms.prototype={areaStart:Ii,areaEnd:Ii,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:Tn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function F0(e){return new ms(e)}function ys(e,t){this._basis=new Be(e),this._beta=t}ys.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 R0=function e(t){function n(i){return t===1?new Be(i):new ys(i,t)}return n.beta=function(i){return e(+i)},n}(.85);function Oi(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 Gn(e,t){this._context=e,this._k=(1-t)/6}Gn.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:Oi(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:Oi(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 I0=function e(t){function n(i){return new Gn(i,t)}return n.tension=function(i){return e(+i)},n}(0);function O0(e,t,n){var i=e._x1,r=e._y1,s=e._x2,o=e._y2;if(e._l01_a>Ri){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>Ri){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 _s(e,t){this._context=e,this._alpha=t}_s.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:O0(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 z0=function e(t){function n(i){return t?new _s(i,t):new Gn(i,0)}return n.alpha=function(i){return e(+i)},n}(.5);function zi(e){return e<0?-1:1}function Di(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(zi(s)+zi(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(a))||0}function Ni(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function Je(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 Ee(e){this._context=e}Ee.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:Je(this,this._t0,Ni(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,Je(this,Ni(this,n=Di(this,e,t)),n);break;default:Je(this,this._t0,n=Di(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function xs(e){this._context=new vs(e)}(xs.prototype=Object.create(Ee.prototype)).point=function(e,t){Ee.prototype.point.call(this,t,e)};function vs(e){this._context=e}vs.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 D0(e){return new Ee(e)}function N0(e){return new xs(e)}function ws(e){this._context=e}ws.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=$i(e),r=$i(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 $i(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 $0(e){return new ws(e)}function He(e,t){this._context=e,this._t=t}He.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 B0(e){return new He(e,.5)}function H0(e){return new He(e,0)}function X0(e){return new He(e,1)}const V0=.7,U0=.9,Y0=1;class W0 extends Cr{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){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=z0.alpha(a||V0);break;case"curveLinear":s=gs;break;case"curveBasis":s=E0;break;case"curveBasisClosed":s=F0;break;case"curveBundle":s=R0.beta(a||Y0);break;case"curveCardinal":s=I0.tension(a||U0);break;case"curveMonotoneX":s=D0;break;case"curveMonotoneY":s=N0;break;case"curveNatural":s=$0;break;case"curveStep":s=B0;break;case"curveStepAfter":s=X0;break;case"curveStepBefore":s=H0;break}return k0().curve(s)(r)}}const Bi=(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 G0 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,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.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}=this,{canvas:o}=this,a=Le(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){Bi({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=>{Bi({solid:i=>this.drawSolid(i),dashed:i=>this.drawDashed(i),wavy:i=>this.drawWavy(i)},n)})})}}class bs{constructor(t,n,i){if(this.layers=[],this.createAxis=r=>{const{container:s}=this;this._svgContainer=q(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 tr(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"),+this.container.getAttribute("height")),this._zoomPanHandler=new Tr(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-Mr:t,0),r=Math.max(this._axis?n-Pr: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.offsetX=t,this._axis.offsetY=n,this.layers.filter(r=>r instanceof ge).forEach(r=>{r.offsetX=t,r.offsetY=n}),this}setXAxisOffset(t){return this._axis.offsetX=t,this.layers.filter(i=>i instanceof ge).forEach(i=>{i.offsetX=t}),this}setYAxisOffset(t){return this._axis.offsetY=t,this.layers.filter(i=>i instanceof ge).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.layerContainer=void 0,this.container=void 0,this.layers=void 0,this._zoomPanHandler=void 0,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 q0{constructor(t,n){this.elements={},this.listeners={},this.enabled=!0;const i=q(n);this.elm=i.append("div").attr("id","overlay").style("z-index","11").style("position","absolute"),this.source=this.elm.node();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]||null,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]=pt(s,this.elm.node());Object.keys(this.listeners).forEach(c=>{const h=this.elements[c]||null,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]||null,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();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&&(q(n).remove(),delete this.elements[t]),delete this.listeners[t]}setZIndex(t){this.elm.style("z-index",t)}destroy(){this.source.remove()}}const j0=(e,t)=>new q0(e,t);class Z0{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=j0(this,n),this.layerManager=new bs(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-Mr,0),height:Math.max(n-Pr,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.layerManager=void 0,this._overlay=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=tr;exports.CalloutCanvasLayer=Yl;exports.CanvasLayer=bt;exports.Controller=Z0;exports.GeomodelCanvasLayer=Zl;exports.GeomodelLabelsLayer=Nu;exports.GeomodelLayerV2=Bu;exports.GridLayer=ge;exports.HTMLLayer=El;exports.ImageLayer=Xu;exports.IntersectionReferenceSystem=zt;exports.Layer=te;exports.LayerManager=bs;exports.PixiLayer=Nn;exports.PixiRenderApplication=Fl;exports.ReferenceLineLayer=G0;exports.SVGLayer=Cr;exports.SchematicLayer=fs;exports.SeismicCanvasLayer=b0;exports.WellborepathLayer=W0;exports.ZoomPanHandler=Tr;exports.assertNever=ee;exports.calcSize=Le;exports.defaultCasingOptions=Xr;exports.defaultCementOptions=Ur;exports.defaultCementPlugOptions=qr;exports.defaultCementSqueezeOptions=Yr;exports.defaultHoleOptions=Hr;exports.defaultInternalLayerOptions=Br;exports.defaultPerforationOptions=Vr;exports.defaultScreenOptions=Wr;exports.defaultTubingOptions=Gr;exports.findIndexOfSample=$n;exports.findSampleAtPos=gt;exports.foldCompletion=Fr;exports.foldPerforationSubKind=Z;exports.generateProjectedTrajectory=ku;exports.generateProjectedWellborePath=Lu;exports.generateSeismicSliceImage=lu;exports.generateSurfaceData=du;exports.getOverlap=Nl;exports.getOverlapOffset=xn;exports.getPicksData=tu;exports.getSeismicInfo=hu;exports.getSeismicOptions=cu;exports.hasFracLines=Ir;exports.hasPacking=Rr;exports.hasSpikes=Or;exports.intersect=$r;exports.isCementPlug=Er;exports.isCementSqueeze=kr;exports.isOpenHoleFracPack=zl;exports.isOverlapping=Qr;exports.isOverlappingHorizontally=Dl;exports.isPAndASymbol=Lr;exports.isSubKindCasedHoleFracPack=Dr;exports.isSubKindCasedHoleFracturation=Nr;exports.isSubKindPerforation=Ol;exports.isSubkindCasedHoleGravelPack=zr;exports.pixelsPerUnit=Kr;exports.shouldPerforationStartAtCasingDiameter=Il;exports.shouldPerforationStartAtHoleDiameter=Rl;exports.transformFormationData=ou;
|
|
14
|
+
***************************************************************************** */var cn=function(e,t){return cn=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])},cn(e,t)};function Ln(e,t){function n(){this.constructor=e}cn(e,t),e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var hn=function(){return hn=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},hn.apply(this,arguments)};function _i(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 ln(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]:_i(r,s),o=e<a-1?t[e+2]:_i(s,r)}return[i,r,s,o]}function na(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 ia(e,t){for(var n=0;n<e.length;n++)e[n]=t;return e}function ra(e,t){for(var n=0;n<e.length;n++)e[n]=t(e[n],n);return e}function sa(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 be(e,t){t=t||new Array(e.length);for(var n=0;n<e.length;n++)t[n]=e[n];return t}function K(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e<t?t:e>n?n:e}function un(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 it=Math.pow(2,-42);function xi(e){var t=Math.pow(Math.abs(e),.3333333333333333);return e<0?-t:t}function er(e,t,n){if(Math.abs(e)<it)return Math.abs(t)<it?[]:[-n/t];var i=t*t-4*e*n;return Math.abs(i)<it?[-t/(2*e)]:i>0?[(-t+Math.sqrt(i))/(2*e),(-t-Math.sqrt(i))/(2*e)]:[]}function oa(e,t,n,i){if(Math.abs(e)<it)return er(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)<it)r=[xi(-o)];else if(Math.abs(o)<it)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)<it)r=[-1.5*o/s,3*o/s];else if(a>0)r=[(c=xi(-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 aa(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 ae(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 nr(e,t){for(var n=0,i=0;i<e.length;i++)n+=(e[i]-t[i])*(e[i]-t[i]);return n}function Et(e){for(var t=0,n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t)}function Se(e,t){var n=nr(e,t);return n===0?0:Math.sqrt(n)}function yt(e,t){var n=t?be(e,t):e,i=sa(n,function(s,o){return s+Math.pow(o,2)}),r=Math.sqrt(i);return r===0?ia(n,0):ra(n,function(s){return s/r})}function ca(e,t){if(e.length>2)throw Error("Only supported for 2d vectors");var n=t?be(e,t):e,i=-n[1];return n[1]=n[0],n[0]=i,n}function ha(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(nr(c,h),.5*r)},o=s(t,e),a=s(n,t)+o;return[0,o,a,s(i,n)+a]}function la(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?ha(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],p=t[h],d=n[h],g=i[h];if(a){var y=a[0],_=a[1],x=a[2],v=a[3];_-x!=0&&(y-_!=0&&y-x!=0&&(l=(1-s)*(x-_)*((f-p)/(y-_)-(f-d)/(y-x)+(p-d)/(_-x))),_-v!=0&&x-v!=0&&(u=(1-s)*(x-_)*((p-d)/(_-x)-(p-g)/(_-v)+(d-g)/(x-v))))}else l=(1-s)*(d-f)*.5,u=(1-s)*(g-p)*.5;var P=2*p-2*d+l+u,b=-3*p+3*d-2*l-u,S=l,T=p;c[h]=[P,b,S,T]}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 qe(e,t){return 6*t[0]*e+2*t[1]}function ua(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]:oa(n,i,r,s).filter(function(o){return o>-it&&o<=1+it}).map(function(o){return K(o,0,1)})}function fn(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 ir=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=na(n,this.points,this.closed),s=r.index;return fn(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=ln(t,this.points,this.closed),i=la(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}(),fa=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 Ln(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+=Se(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=un(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+Se(this.evaluateForT(Ft,h),this.evaluateForT(Ft,n)))/s},t}(ir),rr=[[[-.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]]],vi=rr.length+5,da=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>vi)throw Error("Order for Gaussian Quadrature must be in the range of ".concat(5," and ").concat(vi,"."));return rr[o-5]}(n),s._nSamples=i,s}return Ln(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=Et(fn(Rt,c,o)),l=h===0?0:1/h;this.tension>.95&&(l=K(l,-1,1)),s.push(l)}var u=i-1,f=[],p=[],d=r[0],g=s[0],y=1/u;for(a=0;a<u;++a){var _=d,x=(d=r[a+1])-_,v=g,P=s[a+1];g=P;var b=y/x,S=(v+P-2*b)/(x*x),T=(3*b-2*v-P)/x;f.push(S),p.push(T)}this._cache.samples.set(n,[r,s,p,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]*Et(fn(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,un(i,o)),u=l*r;if(o[l]===i)return u;var f=a[l],p=h[l],d=c[l],g=i-o[l];return((p*g+d)*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=un(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}(ir),kn=function(){function e(t,n){n===void 0&&(n={});var i=this;this._cache=new Map;var r=(n=hn({tension:.5,alpha:0,closed:!1},n)).arcDivisions?new fa(n.arcDivisions,function(){return i._invalidateCache()}):new da(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?K(t,0,1):t)},e.prototype.getPositionFromTime=function(t,n){return n===void 0&&(n=!1),this._curveMapper.getU(n?K(t,0,1):t)},e.prototype.getPositionFromLength=function(t,n){n===void 0&&(n=!1);var i=n?K(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?K(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=K(t,0,1))===0?be(this.points[0],n):t===1?be(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=K(this.getTimeFromPosition(t),0,1);return this.getTangentAtTime(i,n)},e.prototype.getTangentAtTime=function(t,n){return yt(this._curveMapper.evaluateForT(Rt,t,n))},e.prototype.getNormalAt=function(t,n){var i=K(this.getTimeFromPosition(t),0,1);return this.getNormalAtTime(i,n)},e.prototype.getNormalAtTime=function(t,n){var i=yt(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=yt(this._curveMapper.evaluateForT(qe,t));return yt(ae(ae(i,s),i),r)}},e.prototype.getCurvatureAt=function(t){var n=K(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(qe,t),r=yt(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=Et(n),h=ae(n,i);o=yt(ae(h,n)),c!==0&&(s=Et(h)/Math.pow(c,3))}else{c=Et(n);var l=Et(i),u=Math.pow(c,3),f=aa(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=K(this.getTimeFromPosition(t),0,1);return this._curveMapper.evaluateForT(Rt,i,n)},e.prototype.getSecondDerivativeAt=function(t,n){var i=K(this.getTimeFromPosition(t),0,1);return this._curveMapper.evaluateForT(qe,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 p=function(_){var x=ln(_-1,d.points,d.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(d.tension<1){var P=h*s-(_-1),b=h*o-(_-1),S=function(L){return L>-it&&L<=1+it&&(_-1!==l||L>P)&&(_!==u||L<b)},T=d._curveMapper.getCoefficients(_-1),R=function(L){var N=T[L];er(3*N[0],2*N[1],N[2]).filter(S).forEach(function(C){var O=Ft(C,T[L]);O<i[L]&&(i[L]=O),O>r[L]&&(r[L]=O)})};for(v=0;v<T.length;v++)R(v)}},d=this,g=l+1;g<=u;g++)p(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){var i=this;if(n===void 0&&(n=1e-5),n<=0||!Number.isFinite(n))throw Error("Invalid threshold. Must be a number greater than zero!");var r=10*this.points.length-1,s=new Array(t.length),o=1/0,a=0,c=this.createLookupTable(r);Array.from(c.keys()).forEach(function(f){var p=c.get(f),d=Se(t,p);if(d<o)return o=d,a=f,!0});for(var h=this.getTimeFromPosition(a),l=function(f){if(f>=0&&f<=1){i.getPointAtTime(f,s);var p=Se(t,s);if(p<o)return o=p,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=ln(h,this.points,this.closed),u=l[1],f=l[2],p=this._curveMapper.getCoefficients(h),d=void 0,g=void 0;if(u[s]<f[s]?(d=u[s],g=f[s]):(d=f[s],g=u[s]),t-r<=g&&t+r>=d){var y=ua(t,p[s]);i<0?y.sort(function(v,P){return P-v}):i>=0&&y.sort(function(v,P){return v-P});for(var _=0;_<y.length;_++){var x=(y[_]+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===void 0&&(n=0),i===void 0&&(i=1),!t||t<=1)throw Error("Invalid arguments passed to createLookupTable(). You must specify at least 2 samples.");if(!(n<0||i>1||i<n)){var r="lut_".concat(t,"_").concat(n,"_").concat(i);if(!this._cache.has(r)){for(var s=new Map,o=0;o<t;o++){var a=n===0&&i===1?o/(t-1):n+o/(t-1)*(i-n),c=this.getPointAt(a);s.set(a,c)}this._cache.set(r,s)}return this._cache.get(r)}},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)){if(n<=1)throw Error("Invalid arguments passed to forEach(). You must specify at least 2 samples.");for(var a=n,c=0;c<n;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 p=s.getTimeFromPosition(u),d=t({u,t:p,i:f,prev:l});l={u,t:p,i:f,value:d}})},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)){if(n<=1)throw Error("Invalid arguments passed to map(). You must specify at least 2 samples.");for(var a=n,c=0;c<n;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 p=s.getTimeFromPosition(u),d=t({u,t:p,i:f,prev:l});return l={u,t:p,i:f,value:d},d})},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)){if(i<=1)throw Error("Invalid arguments passed to map(). You must specify at least 2 samples.");for(var c=i,h=0;h<i;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,p){if(!Number.isFinite(f)||f<0||f>1)throw Error("Invalid position (u) for sample in map()!");var d=o.getTimeFromPosition(f);return t({acc:u,u:f,t:d,i:p})},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}),e}();(function(e){function t(n,i,r,s,o){return i===void 0&&(i=.5),r===void 0&&(r=300),s===void 0&&(s=!1),o===void 0&&(o=0),e.call(this,n.map(function(a){return[a[0],a[1]]}),{tension:i,alpha:o,arcDivisions:r,closed:s})||this}return Ln(t,e),t.prototype.x=function(n,i,r){i===void 0&&(i=0),r===void 0&&(r=this._lmargin);var s=this.getIntersects(n,1,i,r);return Math.abs(i)===1?s[0]:s.map(function(o){return o[0]})},t.prototype.y=function(n,i,r){i===void 0&&(i=0),r===void 0&&(r=this._lmargin);var s=this.getIntersects(n,0,i,r);return Math.abs(i)===1?s[1]:s.map(function(o){return o[1]})},t.prototype.getNormalAt=function(n,i){return yt(ca(this.getTangentAt(n,i)))},t.prototype.getAngleAt=function(n){var i=this.getTangentAt(n);return Math.atan2(i[1],i[0])},t.prototype.getBoundingBox=function(n,i){n===void 0&&(n=0),i===void 0&&(i=1);var r=e.prototype.getBoundingBox.call(this,n,i);return{x1:r.min[0],x2:r.max[0],y1:r.min[1],y2:r.max[1],min:r.min,max:r.max}},t})(kn);class Te{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}return null}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=Te.newton(t,n,i,r);return a==null&&(a=Te.bisect(t,n,i,r,s,o)),a}}class pa{static bisect(t,n=0,i=1,r=.005,s=4,o=10){const a=(f,p,d,g,y,_,x=0)=>{const v=(f+p)/2,P=t(v),b=D.distance(d,P),S=D.distance(P,g),T=b+S;if(x>=s&&Math.abs(T-y)<_||x>=o)return T;const R=_/2,L=x+1;return a(f,v,d,P,b,R,L)+a(v,p,P,g,S,R,L)},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 ga{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<=n&&a>=n)return s;n<o?r=s:i=s,s=Math.floor(i+r/2)}return s}}class je extends kn{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:Te.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=ga.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){if(t===0&&n===1)return this.length;const i=.002;return pa.bisect(r=>this.getPointAt(r),t,n,i)}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 wi=.75,bi=5e3,Si=.001,ma=1e3,ya=1e3,_a=5e-4,xa=.1,va={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={...va,...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 je(t),trajectory:n.trajectoryInterpolator||new je(t.map(h=>[h[0],h[1]]),{tension:r||wi,arcDivisions:i||bi}),curtain:n.curtainInterpolator||new je(this.projectedPath,{tension:r||wi,arcDivisions:i||bi})};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+=xa){const a=this.project(o),c=Math.atan2(a[1],a[0]);Math.abs(c-s)>_a&&(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);return o&&o.length?o[0]*s+this._offset:null}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),p=this.interpolators.trajectory.getPointAt(u),d=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(p,o)),s&&(h=[a[0]+this.endVector[0]*s*this.displacement,a[1]+this.endVector[1]*s*this.displacement]);const g=[],y=i-n,_=Math.floor(r/y*t),x=Math.ceil((f-u)/y*t),v=t-x-_;if(c){g.push(c);for(let b=1;b<_;b++){const S=b/_*r*this.displacement;g.push([c[0]-this.startVector[0]*S,c[1]-this.startVector[1]*S])}}const P=this.interpolators.trajectory.getPoints(x-1,null,u,f);if(g.push(...P),h){for(let b=1;b<v-1;b++){const S=b/v*s*this.displacement;g.push([d[0]+this.endVector[0]*S,d[1]+this.endVector[1]*S])}g.push(h)}return{points:g,offset:l}}getExtendedTrajectory(t,n=ma,i=ya){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 x=s;x>0;x--){const v=x*u,P=h.add(l.scale(v));c.push(P.toArray())}const f=this.interpolators.trajectory.getPoints(o,null,0,1);c.push(...f);const p=new D(this.interpolators.trajectory.getPointAt(1)),d=new D(this.endVector),g=i/(a-1);for(let x=1;x<a;x++){const v=x*g,P=p.add(d.scale(v));c.push(P.toArray())}const y=-n;return{points:c,offset:y}}getTrajectoryVector(){const{trajectoryAngle:t,calculateDisplacementFromBottom:n}=this.options;if(isFinite(t)){const r=qo(t);return new D(Math.cos(r),Math.sin(r)).toArray()}return zt.getDirectionVector(this.interpolators.trajectory,n?Si:1-Si,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 yt([r[0]-s[0],r[1]-s[1]])}get length(){return this.interpolators.curve.length}get offset(){return this._offset}set offset(t){this._curtainPathCache=void 0,this._offset=t}}var dn="http://www.w3.org/1999/xhtml";const Ti={svg:"http://www.w3.org/2000/svg",xhtml:dn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Fe(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ti.hasOwnProperty(t)?{space:Ti[t],local:e}:e}function wa(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===dn&&t.documentElement.namespaceURI===dn?t.createElement(e):t.createElementNS(n,e)}}function ba(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function sr(e){var t=Fe(e);return(t.local?ba:wa)(t)}function Sa(){}function En(e){return e==null?Sa:function(){return this.querySelector(e)}}function Ta(e){typeof e!="function"&&(e=En(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 j(i,this._parents)}function Ma(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Pa(){return[]}function or(e){return e==null?Pa:function(){return this.querySelectorAll(e)}}function Aa(e){return function(){return Ma(e.apply(this,arguments))}}function Ca(e){typeof e=="function"?e=Aa(e):e=or(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 j(i,r)}function ar(e){return function(){return this.matches(e)}}function cr(e){return function(t){return t.matches(e)}}var La=Array.prototype.find;function ka(e){return function(){return La.call(this.children,e)}}function Ea(){return this.firstElementChild}function Fa(e){return this.select(e==null?Ea:ka(typeof e=="function"?e:cr(e)))}var Ra=Array.prototype.filter;function Ia(){return Array.from(this.children)}function Oa(e){return function(){return Ra.call(this.children,e)}}function za(e){return this.selectAll(e==null?Ia:Oa(typeof e=="function"?e:cr(e)))}function Da(e){typeof e!="function"&&(e=ar(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 j(i,this._parents)}function hr(e){return new Array(e.length)}function Na(){return new j(this._enter||this._groups.map(hr),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 $a(e){return function(){return e}}function Ba(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 Ha(e,t,n,i,r,s,o){var a,c,h=new Map,l=t.length,u=s.length,f=new Array(l),p;for(a=0;a<l;++a)(c=t[a])&&(f[a]=p=o.call(c,c.__data__,a,t)+"",h.has(p)?r[a]=c:h.set(p,c));for(a=0;a<u;++a)p=o.call(e,s[a],a,s)+"",(c=h.get(p))?(i[a]=c,c.__data__=s[a],h.delete(p)):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 Xa(e){return e.__data__}function Va(e,t){if(!arguments.length)return Array.from(this,Xa);var n=t?Ha:Ba,i=this._parents,r=this._groups;typeof e!="function"&&(e=$a(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,p=Ua(e.call(l,l&&l.__data__,h,i)),d=p.length,g=a[h]=new Array(d),y=o[h]=new Array(d),_=c[h]=new Array(f);n(l,u,g,y,_,p,t);for(var x=0,v=0,P,b;x<d;++x)if(P=g[x]){for(x>=v&&(v=x+1);!(b=y[v])&&++v<d;);P._next=b||null}}return o=new j(o,i),o._enter=a,o._exit=c,o}function Ua(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ya(){return new j(this._exit||this._groups.map(hr),this._parents)}function Wa(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 Ga(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),p,d=0;d<u;++d)(p=h[d]||l[d])&&(f[d]=p);for(;c<r;++c)a[c]=n[c];return new j(a,this._parents)}function qa(){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 ja(e){e||(e=Za);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 j(r,this._parents).order()}function Za(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ka(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qa(){return Array.from(this)}function Ja(){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 tc(){let e=0;for(const t of this)++e;return e}function ec(){return!this.node()}function nc(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 ic(e){return function(){this.removeAttribute(e)}}function rc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sc(e,t){return function(){this.setAttribute(e,t)}}function oc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ac(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function cc(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 hc(e,t){var n=Fe(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?rc:ic:typeof t=="function"?n.local?cc:ac:n.local?oc:sc)(n,t))}function lr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lc(e){return function(){this.style.removeProperty(e)}}function uc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function fc(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function dc(e,t,n){return arguments.length>1?this.each((t==null?lc:typeof t=="function"?fc:uc)(e,t,n??"")):Dt(this.node(),e)}function Dt(e,t){return e.style.getPropertyValue(t)||lr(e).getComputedStyle(e,null).getPropertyValue(t)}function pc(e){return function(){delete this[e]}}function gc(e,t){return function(){this[e]=t}}function mc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yc(e,t){return arguments.length>1?this.each((t==null?pc:typeof t=="function"?mc:gc)(e,t)):this.node()[e]}function ur(e){return e.trim().split(/^|\s+/)}function Fn(e){return e.classList||new fr(e)}function fr(e){this._node=e,this._names=ur(e.getAttribute("class")||"")}fr.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 dr(e,t){for(var n=Fn(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function pr(e,t){for(var n=Fn(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function _c(e){return function(){dr(this,e)}}function xc(e){return function(){pr(this,e)}}function vc(e,t){return function(){(t.apply(this,arguments)?dr:pr)(this,e)}}function wc(e,t){var n=ur(e+"");if(arguments.length<2){for(var i=Fn(this.node()),r=-1,s=n.length;++r<s;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?vc:t?_c:xc)(n,t))}function bc(){this.textContent=""}function Sc(e){return function(){this.textContent=e}}function Tc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Mc(e){return arguments.length?this.each(e==null?bc:(typeof e=="function"?Tc:Sc)(e)):this.node().textContent}function Pc(){this.innerHTML=""}function Ac(e){return function(){this.innerHTML=e}}function Cc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Lc(e){return arguments.length?this.each(e==null?Pc:(typeof e=="function"?Cc:Ac)(e)):this.node().innerHTML}function kc(){this.nextSibling&&this.parentNode.appendChild(this)}function Ec(){return this.each(kc)}function Fc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Rc(){return this.each(Fc)}function Ic(e){var t=typeof e=="function"?e:sr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Oc(){return null}function zc(e,t){var n=typeof e=="function"?e:sr(e),i=t==null?Oc:typeof t=="function"?t:En(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function Dc(){var e=this.parentNode;e&&e.removeChild(this)}function Nc(){return this.each(Dc)}function $c(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Hc(e){return this.select(e?Bc:$c)}function Xc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Vc(e){return function(t){e.call(this,t,this.__data__)}}function Uc(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 Yc(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 Wc(e,t,n){return function(){var i=this.__on,r,s=Vc(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 Gc(e,t,n){var i=Uc(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?Wc:Yc,r=0;r<s;++r)this.each(a(i[r],t,n));return this}function gr(e,t,n){var i=lr(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 qc(e,t){return function(){return gr(this,e,t)}}function jc(e,t){return function(){return gr(this,e,t.apply(this,arguments))}}function Zc(e,t){return this.each((typeof t=="function"?jc:qc)(e,t))}function*Kc(){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 mr=[null];function j(e,t){this._groups=e,this._parents=t}function Jt(){return new j([[document.documentElement]],mr)}function Qc(){return this}j.prototype=Jt.prototype={constructor:j,select:Ta,selectAll:Ca,selectChild:Fa,selectChildren:za,filter:Da,data:Va,enter:Na,exit:Ya,join:Wa,merge:Ga,selection:Qc,order:qa,sort:ja,call:Ka,nodes:Qa,node:Ja,size:tc,empty:ec,each:nc,attr:hc,style:dc,property:yc,classed:wc,text:Mc,html:Lc,raise:Ec,lower:Rc,append:Ic,insert:zc,remove:Nc,clone:Hc,datum:Xc,on:Gc,dispatch:Zc,[Symbol.iterator]:Kc};function q(e){return typeof e=="string"?new j([[document.querySelector(e)]],[document.documentElement]):new j([[e]],mr)}function Jc(e){let t;for(;t=e.sourceEvent;)e=t;return e}function pt(e,t){if(e=Jc(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 th={value:()=>{}};function Rn(){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 ue(n)}function ue(e){this._=e}function eh(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}})}ue.prototype=Rn.prototype={constructor:ue,on:function(e,t){var n=this._,i=eh(e+"",n),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(e=i[s]).type)&&(r=nh(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]=Mi(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Mi(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 ue(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 nh(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function Mi(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=th,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}const pn={capture:!0,passive:!1};function gn(e){e.preventDefault(),e.stopImmediatePropagation()}function ih(e){var t=e.document.documentElement,n=q(e).on("dragstart.drag",gn,pn);"onselectstart"in t?n.on("selectstart.drag",gn,pn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function rh(e,t){var n=e.document.documentElement,i=q(e).on("dragstart.drag",null);t&&(i.on("click.drag",gn,pn),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,Wt=0,Vt=0,yr=1e3,Pe,Gt,Ae=0,Ct=0,Re=0,Kt=typeof performance=="object"&&performance.now?performance:Date,_r=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function In(){return Ct||(_r(sh),Ct=Kt.now()+Re)}function sh(){Ct=0}function Ce(){this._call=this._time=this._next=null}Ce.prototype=xr.prototype={constructor:Ce,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?In():+n)+(t==null?0:+t),!this._next&&Gt!==this&&(Gt?Gt._next=this:Pe=this,Gt=this),this._call=e,this._time=n,mn()},stop:function(){this._call&&(this._call=null,this._time=1/0,mn())}};function xr(e,t,n){var i=new Ce;return i.restart(e,t,n),i}function oh(){In(),++Nt;for(var e=Pe,t;e;)(t=Ct-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Nt}function Pi(){Ct=(Ae=Kt.now())+Re,Nt=Wt=0;try{oh()}finally{Nt=0,ch(),Ct=0}}function ah(){var e=Kt.now(),t=e-Ae;t>yr&&(Re-=t,Ae=e)}function ch(){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,mn(i)}function mn(e){if(!Nt){Wt&&(Wt=clearTimeout(Wt));var t=e-Ct;t>24?(e<1/0&&(Wt=setTimeout(Pi,e-Kt.now()-Re)),Vt&&(Vt=clearInterval(Vt))):(Vt||(Ae=Kt.now(),Vt=setInterval(ah,yr)),Nt=1,_r(Pi))}}function Ai(e,t,n){var i=new Ce;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var hh=Rn("start","end","cancel","interrupt"),lh=[],vr=0,Ci=1,yn=2,fe=3,Li=4,_n=5,de=6;function Ie(e,t,n,i,r,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;uh(e,n,{name:t,index:i,group:r,on:hh,tween:lh,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:vr})}function On(e,t){var n=rt(e,t);if(n.state>vr)throw new Error("too late; already scheduled");return n}function ct(e,t){var n=rt(e,t);if(n.state>fe)throw new Error("too late; already running");return n}function rt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function uh(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=xr(s,0,n.time);function s(h){n.state=Ci,n.timer.restart(o,n.delay,n.time),n.delay<=h&&o(h-n.delay)}function o(h){var l,u,f,p;if(n.state!==Ci)return c();for(l in i)if(p=i[l],p.name===n.name){if(p.state===fe)return Ai(o);p.state===Li?(p.state=de,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete i[l]):+l<t&&(p.state=de,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete i[l])}if(Ai(function(){n.state===fe&&(n.state=Li,n.timer.restart(a,n.delay,n.time),a(h))}),n.state=yn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===yn){for(n.state=fe,r=new Array(f=n.tween.length),l=0,u=-1;l<f;++l)(p=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=p);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=_n,1),u=-1,f=r.length;++u<f;)r[u].call(e,l);n.state===_n&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=de,n.timer.stop(),delete i[t];for(var h in i)return;delete e.__transition}}function pe(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>yn&&i.state<_n,i.state=de,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[o]}s&&delete e.__transition}}function fh(e){return this.each(function(){pe(this,e)})}function dh(e,t){var n,i;return function(){var r=ct(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 ph(e,t,n){var i,r;if(typeof n!="function")throw new Error;return function(){var s=ct(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 gh(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=rt(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?dh:ph)(n,e,t))}function zn(e,t,n){var i=e._id;return e.each(function(){var r=ct(this,i);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return rt(r,i).value[t]}}function wr(e,t){var n;return(typeof t=="number"?et:t instanceof ft?Zt:(n=ft(t))?(t=n,Zt):qi)(e,t)}function mh(e){return function(){this.removeAttribute(e)}}function yh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _h(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 xh(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 vh(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 wh(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 bh(e,t){var n=Fe(e),i=n==="transform"?vo:wr;return this.attrTween(e,typeof t=="function"?(n.local?wh:vh)(n,i,zn(this,"attr."+e,t)):t==null?(n.local?yh:mh)(n):(n.local?xh:_h)(n,i,t))}function Sh(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Th(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Mh(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&Th(e,s)),n}return r._value=t,r}function Ph(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&Sh(e,s)),n}return r._value=t,r}function Ah(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=Fe(e);return this.tween(n,(i.local?Mh:Ph)(i,t))}function Ch(e,t){return function(){On(this,e).delay=+t.apply(this,arguments)}}function Lh(e,t){return t=+t,function(){On(this,e).delay=t}}function kh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ch:Lh)(t,e)):rt(this.node(),t).delay}function Eh(e,t){return function(){ct(this,e).duration=+t.apply(this,arguments)}}function Fh(e,t){return t=+t,function(){ct(this,e).duration=t}}function Rh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Eh:Fh)(t,e)):rt(this.node(),t).duration}function Ih(e,t){if(typeof t!="function")throw new Error;return function(){ct(this,e).ease=t}}function Oh(e){var t=this._id;return arguments.length?this.each(Ih(t,e)):rt(this.node(),t).ease}function zh(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ct(this,e).ease=n}}function Dh(e){if(typeof e!="function")throw new Error;return this.each(zh(this._id,e))}function Nh(e){typeof e!="function"&&(e=ar(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 dt(i,this._parents,this._name,this._id)}function $h(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,p=0;p<l;++p)(f=c[p]||h[p])&&(u[p]=f);for(;a<i;++a)o[a]=t[a];return new dt(o,this._parents,this._name,this._id)}function Bh(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 Hh(e,t,n){var i,r,s=Bh(t)?On:ct;return function(){var o=s(this,e),a=o.on;a!==i&&(r=(i=a).copy()).on(t,n),o.on=r}}function Xh(e,t){var n=this._id;return arguments.length<2?rt(this.node(),n).on.on(e):this.each(Hh(n,e,t))}function Vh(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Uh(){return this.on("end.remove",Vh(this._id))}function Yh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=En(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,Ie(h[f],t,n,f,h,rt(l,n)));return new dt(s,this._parents,t,n)}function Wh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=or(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),p,d=rt(l,n),g=0,y=f.length;g<y;++g)(p=f[g])&&Ie(p,t,n,g,f,d);s.push(f),o.push(l)}return new dt(s,o,t,n)}var Gh=Jt.prototype.constructor;function qh(){return new Gh(this._groups,this._parents)}function jh(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 br(e){return function(){this.style.removeProperty(e)}}function Zh(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 Kh(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 Qh(e,t){var n,i,r,s="style."+t,o="end."+s,a;return function(){var c=ct(this,e),h=c.on,l=c.value[s]==null?a||(a=br(t)):void 0;(h!==n||r!==l)&&(i=(n=h).copy()).on(o,r=l),c.on=i}}function Jh(e,t,n){var i=(e+="")=="transform"?xo:wr;return t==null?this.styleTween(e,jh(e,i)).on("end.style."+e,br(e)):typeof t=="function"?this.styleTween(e,Kh(e,i,zn(this,"style."+e,t))).each(Qh(this._id,e)):this.styleTween(e,Zh(e,i,t),n).on("end.style."+e,null)}function tl(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function el(e,t,n){var i,r;function s(){var o=t.apply(this,arguments);return o!==r&&(i=(r=o)&&tl(e,o,n)),i}return s._value=t,s}function nl(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,el(e,t,n??""))}function il(e){return function(){this.textContent=e}}function rl(e){return function(){var t=e(this);this.textContent=t??""}}function sl(e){return this.tween("text",typeof e=="function"?rl(zn(this,"text",e)):il(e==null?"":e+""))}function ol(e){return function(t){this.textContent=e.call(this,t)}}function al(e){var t,n;function i(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&ol(r)),t}return i._value=e,i}function cl(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,al(e))}function hl(){for(var e=this._name,t=this._id,n=Sr(),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=rt(c,t);Ie(c,e,n,h,o,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new dt(i,this._parents,e,n)}function ll(){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=ct(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 ul=0;function dt(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function Sr(){return++ul}var ht=Jt.prototype;dt.prototype={constructor:dt,select:Yh,selectAll:Wh,selectChild:ht.selectChild,selectChildren:ht.selectChildren,filter:Nh,merge:$h,selection:qh,transition:hl,call:ht.call,nodes:ht.nodes,node:ht.node,size:ht.size,empty:ht.empty,each:ht.each,on:Xh,attr:bh,attrTween:Ah,style:Jh,styleTween:nl,text:sl,textTween:cl,remove:Uh,tween:gh,delay:kh,duration:Rh,ease:Oh,easeVarying:Dh,end:ll,[Symbol.iterator]:ht[Symbol.iterator]};function fl(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var dl={time:null,delay:0,duration:250,ease:fl};function pl(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 gl(e){var t,n;e instanceof dt?(t=e._id,e=e._name):(t=Sr(),(n=dl).time=In(),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])&&Ie(c,e,t,h,o,n||pl(c,t));return new dt(i,this._parents,e,t)}Jt.prototype.interrupt=fh;Jt.prototype.transition=gl;const ce=e=>()=>e;function ml(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 ut(e,t,n){this.k=e,this.x=t,this.y=n}ut.prototype={constructor:ut,scale:function(e){return e===1?this:new ut(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ut(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 Dn=new ut(1,0,0);ut.prototype;function Ze(e){e.stopImmediatePropagation()}function Ut(e){e.preventDefault(),e.stopImmediatePropagation()}function yl(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function _l(){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 ki(){return this.__zoom||Dn}function xl(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function vl(){return navigator.maxTouchPoints||"ontouchstart"in this}function wl(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 bl(){var e=yl,t=_l,n=wl,i=xl,r=vl,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,c=To,h=Rn("start","zoom","end"),l,u,f,p=500,d=150,g=0,y=10;function _(m){m.property("__zoom",ki).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",L).on("dblclick.zoom",N).filter(r).on("touchstart.zoom",C).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",$).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(m,M,w,A){var E=m.selection?m.selection():m;E.property("__zoom",ki),m!==E?b(m,M,w,A):E.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},_.scaleBy=function(m,M,w,A){_.scaleTo(m,function(){var E=this.__zoom.k,F=typeof M=="function"?M.apply(this,arguments):M;return E*F},w,A)},_.scaleTo=function(m,M,w,A){_.transform(m,function(){var E=t.apply(this,arguments),F=this.__zoom,I=w==null?P(E):typeof w=="function"?w.apply(this,arguments):w,z=F.invert(I),B=typeof M=="function"?M.apply(this,arguments):M;return n(v(x(F,B),I,z),E,o)},w,A)},_.translateBy=function(m,M,w,A){_.transform(m,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof w=="function"?w.apply(this,arguments):w),t.apply(this,arguments),o)},null,A)},_.translateTo=function(m,M,w,A,E){_.transform(m,function(){var F=t.apply(this,arguments),I=this.__zoom,z=A==null?P(F):typeof A=="function"?A.apply(this,arguments):A;return n(Dn.translate(z[0],z[1]).scale(I.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof w=="function"?-w.apply(this,arguments):-w),F,o)},A,E)};function x(m,M){return M=Math.max(s[0],Math.min(s[1],M)),M===m.k?m:new ut(M,m.x,m.y)}function v(m,M,w){var A=M[0]-w[0]*m.k,E=M[1]-w[1]*m.k;return A===m.x&&E===m.y?m:new ut(m.k,A,E)}function P(m){return[(+m[0][0]+ +m[1][0])/2,(+m[0][1]+ +m[1][1])/2]}function b(m,M,w,A){m.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var E=this,F=arguments,I=S(E,F).event(A),z=t.apply(E,F),B=w==null?P(z):typeof w=="function"?w.apply(E,F):w,V=Math.max(z[1][0]-z[0][0],z[1][1]-z[0][1]),H=E.__zoom,W=typeof M=="function"?M.apply(E,F):M,Q=c(H.invert(B).concat(V/H.k),W.invert(B).concat(V/W.k));return function(U){if(U===1)U=W;else{var J=Q(U),$t=V/J[2];U=new ut($t,B[0]-J[0]*$t,B[1]-J[1]*$t)}I.zoom(null,U)}})}function S(m,M,w){return!w&&m.__zooming||new T(m,M)}function T(m,M){this.that=m,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(m,M),this.taps=0}T.prototype={event:function(m){return m&&(this.sourceEvent=m),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(m,M){return this.mouse&&m!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&m!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&m!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(m){var M=q(this.that).datum();h.call(m,this.that,new ml(m,{sourceEvent:this.sourceEvent,target:_,type:m,transform:this.that.__zoom,dispatch:h}),M)}};function R(m,...M){if(!e.apply(this,arguments))return;var w=S(this,M).event(m),A=this.__zoom,E=Math.max(s[0],Math.min(s[1],A.k*Math.pow(2,i.apply(this,arguments)))),F=pt(m);if(w.wheel)(w.mouse[0][0]!==F[0]||w.mouse[0][1]!==F[1])&&(w.mouse[1]=A.invert(w.mouse[0]=F)),clearTimeout(w.wheel);else{if(A.k===E)return;w.mouse=[F,A.invert(F)],pe(this),w.start()}Ut(m),w.wheel=setTimeout(I,d),w.zoom("mouse",n(v(x(A,E),w.mouse[0],w.mouse[1]),w.extent,o));function I(){w.wheel=null,w.end()}}function L(m,...M){if(f||!e.apply(this,arguments))return;var w=m.currentTarget,A=S(this,M,!0).event(m),E=q(m.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",V,!0),F=pt(m,w),I=m.clientX,z=m.clientY;ih(m.view),Ze(m),A.mouse=[F,this.__zoom.invert(F)],pe(this),A.start();function B(H){if(Ut(H),!A.moved){var W=H.clientX-I,Q=H.clientY-z;A.moved=W*W+Q*Q>g}A.event(H).zoom("mouse",n(v(A.that.__zoom,A.mouse[0]=pt(H,w),A.mouse[1]),A.extent,o))}function V(H){E.on("mousemove.zoom mouseup.zoom",null),rh(H.view,A.moved),Ut(H),A.event(H).end()}}function N(m,...M){if(e.apply(this,arguments)){var w=this.__zoom,A=pt(m.changedTouches?m.changedTouches[0]:m,this),E=w.invert(A),F=w.k*(m.shiftKey?.5:2),I=n(v(x(w,F),A,E),t.apply(this,M),o);Ut(m),a>0?q(this).transition().duration(a).call(b,I,A,m):q(this).call(_.transform,I,A,m)}}function C(m,...M){if(e.apply(this,arguments)){var w=m.touches,A=w.length,E=S(this,M,m.changedTouches.length===A).event(m),F,I,z,B;for(Ze(m),I=0;I<A;++I)z=w[I],B=pt(z,this),B=[B,this.__zoom.invert(B),z.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},p)),pe(this),E.start())}}function O(m,...M){if(this.__zooming){var w=S(this,M).event(m),A=m.changedTouches,E=A.length,F,I,z,B;for(Ut(m),F=0;F<E;++F)I=A[F],z=pt(I,this),w.touch0&&w.touch0[2]===I.identifier?w.touch0[0]=z:w.touch1&&w.touch1[2]===I.identifier&&(w.touch1[0]=z);if(I=w.that.__zoom,w.touch1){var V=w.touch0[0],H=w.touch0[1],W=w.touch1[0],Q=w.touch1[1],U=(U=W[0]-V[0])*U+(U=W[1]-V[1])*U,J=(J=Q[0]-H[0])*J+(J=Q[1]-H[1])*J;I=x(I,Math.sqrt(U/J)),z=[(V[0]+W[0])/2,(V[1]+W[1])/2],B=[(H[0]+Q[0])/2,(H[1]+Q[1])/2]}else if(w.touch0)z=w.touch0[0],B=w.touch0[1];else return;w.zoom("touch",n(v(I,z,B),w.extent,o))}}function $(m,...M){if(this.__zooming){var w=S(this,M).event(m),A=m.changedTouches,E=A.length,F,I;for(Ze(m),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),F=0;F<E;++F)I=A[F],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=pt(I,this),Math.hypot(u[0]-I[0],u[1]-I[1])<y)){var z=q(this).on("dblclick.zoom");z&&z.apply(this,arguments)}}}return _.wheelDelta=function(m){return arguments.length?(i=typeof m=="function"?m:ce(+m),_):i},_.filter=function(m){return arguments.length?(e=typeof m=="function"?m:ce(!!m),_):e},_.touchable=function(m){return arguments.length?(r=typeof m=="function"?m:ce(!!m),_):r},_.extent=function(m){return arguments.length?(t=typeof m=="function"?m:ce([[+m[0][0],+m[0][1]],[+m[1][0],+m[1][1]]]),_):t},_.scaleExtent=function(m){return arguments.length?(s[0]=+m[0],s[1]=+m[1],_):[s[0],s[1]]},_.translateExtent=function(m){return arguments.length?(o[0][0]=+m[0][0],o[1][0]=+m[1][0],o[0][1]=+m[0][1],o[1][1]=+m[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(m){return arguments.length?(n=m,_):n},_.duration=function(m){return arguments.length?(a=+m,_):a},_.interpolate=function(m){return arguments.length?(c=m,_):c},_.on=function(){var m=h.on.apply(h,arguments);return m===h?_:m},_.clickDistance=function(m){return arguments.length?(g=(m=+m)*m,_):Math.sqrt(g)},_.tapDistance=function(m){return arguments.length?(y=+m,_):y},_}const Sl=.1,Tl=256;class Tr{constructor(t,n,i={maxZoomLevel:Tl,minZoomLevel:Sl}){this.zoom=null,this.elm=null,this.container=null,this.onRescale=null,this.options=null,this.xBounds=[0,1],this.yBounds=[0,1],this.translateBoundsX=[0,1],this.translateBoundsY=[0,1],this.scaleX=null,this.scaleY=null,this._zFactor=1,this.container=q(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=At().domain(this.xBounds).range([0,1]),this.scaleY=At().domain(this.yBounds).range([0,1]),this.init()}get width(){return this.scaleX.range()[1]}get height(){return this.scaleY.range()[1]}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=bl().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,p=s/f,d=s/t.k,g=d/c/h,y=p*t.x,_=p/c*t.y,x=o[0]-(l?-y:y),v=a[0]-(u?-_:_);i.domain([x,x+(l?-d:d)]),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(isNaN(t)||isNaN(i)){const g=c.domain(),y=g[1]-g[0];isNaN(t)&&(t=g[0]+y/2||0),isNaN(i)&&(i=Math.abs(y)||1)}if(isNaN(n)){const g=h.domain();n=g[0]+(g[1]-g[0])/2||0}const u=l?-i:i,f=t-u/2,p=f+u,d=a(f,p,n);Number.isFinite(r)&&r>0?s.transform(o.transition().duration(r),d):s.transform(o,d)}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>"u"||typeof t=="boolean"){const{width:p,height:d}=this.container.node().getBoundingClientRect();h=p,l=d}else h=t,l=n;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,p]=r.range(),d=Math.abs(n-t),g=s/d,y=d/(p-f),_=i-(u?-d:d)/c/h/2,x=(o[0]-t)/(l?-y:y),v=(a[0]-_)/((u?-y:y)/c);return Dn.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 Ml={order:1,layerOpacity:1,interactive:!1};class te{constructor(t,n){this._referenceSystem=null,this._interactive=!1,this._id=t||`layer-${Math.floor(Math.random()*1e3)}`;const i=n||Ml;this._order=i.order||1,this._options={...i},this.loading=!1,this._element=null,this._opacity=i.layerOpacity||1,this._visible=!0,this._interactive=i.interactive||!1,n&&n.data&&this.setData(n.data),this._referenceSystem=n&&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&&this.onUpdate({data:t})}clearData(t=!0){this._data=null,t&&(this.referenceSystem=null),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&&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 Oe=200,ze=300,Mr=40,Pr=30,Pl=100,Al=.6,Cl=.3,Ll=8,kl=16,xt=64,Ar=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)||Oe,r=t.height||parseInt(n.getAttribute("height"),10)||ze;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")}onUnmount(){super.onUnmount(),this.canvas.remove(),this.canvas=null}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,n.height),t.restore()}}class El extends te{onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n.getAttribute("width"),10)||Oe,r=t.height||parseInt(n.getAttribute("height"),10)||ze;this.elm||(this.elm=q(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=null}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 Cr extends te{onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n.getAttribute("width"),10)||Oe,r=t.height||parseInt(n.getAttribute("height"),10)||ze;this.elm||(this.elm=q(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=null}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 Fl{constructor(t){const n={width:Oe,height:ze,antialias:!0,backgroundAlpha:0,clearBeforeRender:!0,preserveDrawingBuffer:!0,...t};this.renderer=k.autoDetectRenderer(n),this.stage=new k.Container}destroy(){var i,r;this.stage.destroy({children:!0,texture:!0,baseTexture:!0}),this.stage=null;const t=this.renderer.type,n=this.renderer instanceof k.Renderer?(i=this.renderer)==null?void 0:i.gl:void 0;t===k.RENDERER_TYPE.WEBGL&&n&&((r=n==null?void 0:n.getExtension("WEBGL_lose_context"))==null||r.loseContext()),this.renderer.destroy(!0),this.renderer=null}get view(){return this.renderer.view}render(){this.renderer.render(this.stage)}}class Nn extends te{constructor(t,n,i){super(n,i),this.ctx=t,this.container=new k.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"),this.pixiViewContainer||(this.pixiViewContainer=document.createElement("div"),this.pixiViewContainer.setAttribute("id",`${this.id}`),this.pixiViewContainer.setAttribute("class","webgl-layer"),this.pixiViewContainer.appendChild(this.ctx.view),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 Lr=e=>e.kind==="pAndASymbol",kr=e=>e.kind==="cementSqueeze",Er=e=>e.kind==="cementPlug",Fr=(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)}},Z=(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)}},Rl=e=>Z({Perforation:()=>!0,OpenHoleGravelPack:()=>!0,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind),Il=e=>Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!0,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!0},e.subKind),Rr=e=>Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!0,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!0},e.subKind);function Ir(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!0,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!0},e.subKind)}function Or(e){return Z({Perforation:()=>!0,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}function zr(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!1},e.subKind)}function Ol(e){return Z({Perforation:()=>!0,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}function Dr(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!0},e.subKind)}function zl(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}const Nr=e=>e.subKind==="Cased hole fracturation",$r=(e,t)=>e.start<t.end&&e.end>t.start,Br=e=>({holeLayerId:`${e}-hole`,casingLayerId:`${e}-casing`,completionLayerId:`${e}-completion`,cementLayerId:`${e}-cement`,pAndALayerId:`${e}-pAndA`,perforationLayerId:`${e}-perforation`}),Hr={firstColor:"#8c541d",secondColor:"#eee3d8",lineColor:"#8b4513"},Xr={solidColor:"#dcdcdc",lineColor:"#575757",shoeSize:{width:Ll,length:kl},windowOptions:{dashColor:"#dc0000",dashLength:5,spaceLength:3}},Vr={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},Ur={firstColor:"#c7b9ab",secondColor:"#5b5b5b",scalingFactor:4},Yr={firstColor:"#8b6713",secondColor:"#000000",scalingFactor:4},Wr={scalingFactor:4,lineColor:"#63666a"},Gr={scalingFactor:1,innerColor:"#eeeeff",outerColor:"#777788"},qr={firstColor:"#c7b9ab",secondColor:"#000000",scalingFactor:4},jr=4,Zr=2;function Kr(e){const[t]=e.domain();return Math.abs(e(t+1))}function Le(e,t,n,i){return _t(Kr(i)*e,t,n)}function Dl(e,t){const n=e.x+e.width,i=t.x+t.width;return!(t.x>n||i<e.x)}function Qr(e,t,n=jr,i=Zr){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 Nl(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 null;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 xn(e,t,n=jr,i=Zr){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 null;const c=e.x+e.width-t.x+n,h=e.y+e.height-t.y+i;return{dx:c,dy:h}}const $l=7,Bl=11,Hl=7,Xl=20,Vl=120,Ul=19,tt={topleft:"topleft",topright:"topright",bottomleft:"bottomleft",bottomright:"bottomright"};class Yl extends bt{constructor(t,n){super(t,n),this.groupFilter=null,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,p=r+2;l.strokeStyle=c,l.lineWidth=1,l.beginPath(),l.moveTo(o,a),l.lineTo(u,p),l.lineTo(f,p),l.stroke()},this.minFontSize=n.minFontSize||$l,this.maxFontSize=n.maxFontSize||Bl,this.fontSizeFactor=n.fontSizeFactor||Hl,this.offsetMin=n.offsetMin||Xl,this.offsetMax=n.offsetMax||Vl,this.offsetFactor=n.offsetFactor||Ul}setGroupFilter(t){this.groupFilter=t,this.callouts=void 0,this.render()}onUpdate(t){super.onUpdate(t),this.callouts=void 0,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=Le(this.fontSizeFactor,this.minFontSize,this.maxFontSize,n);if(!t||!this.callouts){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.font=`bold ${s}px arial`;const f=o.filter(d=>!c||c.includes(d.group)),p=Le(this.offsetFactor,this.offsetMin,this.offsetMax,n);this.callouts=this.positionCallouts(f,l,n,i,u,s,p)}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)})})}renderText(t,n,i,r,s,o="arial",a="normal"){const{ctx:c}=this;c.font=`${a} ${r}px ${o}`,c.fillStyle=s,c.fillText(t,n,i)}renderPoint(t,n,i=3){const{ctx:r}=this;r.beginPath(),r.moveTo(t,n),r.arc(t,n,i,0,Math.PI*2),r.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,p=s===tt.topright||s===tt.bottomright;this.renderAnnotation(t,n,a,c,h,r),this.renderPoint(u,f),this.renderLine(a,c,l,u,f,r,p)}getPosition(t,n){const{x:i,y:r,offsetX:s,offsetY:o,width:a}=t;switch(n){case tt.topleft:return{x:i-a-s,y:r-o};case tt.topright:return{x:i+s,y:r-o};case tt.bottomleft:return{x:i-a-s,y:r+o};case tt.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?tt.topleft:tt.topright,h=t.map(f=>{const p=f.pos?f.pos:this.referenceSystem.project(f.md);return{title:f.title,label:f.label,color:f.color,pos:{x:p[0],y:p[1]},group:f.group,alignment:c,boundingBox:this.getAnnotationBoundingBox(f.title,f.label,p,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,u=a.measureText(t).width,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];Qr(s.boundingBox,o.boundingBox)?(s.alignment=s.alignment===tt.topleft?tt.bottomright:tt.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=xn(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=xn(s.boundingBox,i.boundingBox);o&&(i.dy+=o.dy,i.boundingBox.y+=o.dy)}}}}const Wl=16,Gl=6;function lt(e){const n=ft(e).formatHex();return parseInt(n.replace("#","0x"))}function ql(e){return typeof e=="string"?e:`#${e.toString(Wl).padStart(Gl,"0")}`}const jl=1e4;class Zl extends bt{constructor(t,n){super(t,n),this.surfaceAreasPaths=[],this.surfaceLinesPaths=[],this.maxDepth=jl,this.drawPolygonPath=(i,r)=>{const{ctx:s}=this;s.fillStyle=i,s.fill(r)},this.drawLinePath=(i,r)=>{const{ctx:s}=this;s.strokeStyle=i,s.stroke(r)},this.createPolygons=i=>{const r=[];let s=null;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){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=null}}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=null;for(let c=0;c<s.length;c++)s[c][1]?o?a.lineTo(s[c][0],s[c][1]):(a=new Path2D,a.moveTo(s[c][0],s[c][1]),o=!0):o&&(r.push(a),o=!1);return o&&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 ql(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 $n(e,t){var c,h,l,u,f,p,d,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 _=Math.floor((r+i)/2),x=(l=e[_])==null?void 0:l[0];if(s==null||o==null||x==null)return-1;if(t>=s&&t<x)r=_,o=(u=e[r])==null?void 0:u[0];else if(t>=x&&t<=o)i=_,s=(f=e[i])==null?void 0:f[0];else if(t<=s&&t>x)r=_,o=(p=e[r])==null?void 0:p[0];else if(t<=x&&t>=o)i=_,s=(d=e[i])==null?void 0:d[0];else return-1}let a=-1;for(let _=i;_<r;_++){const x=(g=e[_])==null?void 0:g[0],v=(y=e[_+1])==null?void 0:y[0];if(x!=null&&v!=null&&Math.min(x,v)<=t&&t<=Math.max(x,v)){a=_;break}}return a}function gt(e,t,n=null,i=null){let r=null;const s=$n(e,t);if(s!==-1){const o=e[s][1],a=e[s+1][1];if(a&&a){const c=e[s][0],l=e[s+1][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 Bn=(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 Kl(e){return e?e.map(t=>Bn(t,"ref-picks")):[]}function Ql(e){return e?e.filter(t=>t.entryPick.md===t.from).map(t=>Bn(t.entryPick,"strat-picks")):[]}function Jl(e){return e?e.filter(t=>e.findIndex(n=>Math.abs(n.entryPick.md-t.exitPick.md)<.5)===-1).map(t=>Bn(t.exitPick,"strat-picks")).filter((t,n,i)=>n===i.findIndex(r=>r.title===t.title&&r.md===t.md)):[]}const tu=e=>[...Kl(e.nonUnitPicks),...Ql(e.unitPicks),...Jl(e.unitPicks)].sort((t,n)=>t.md-n.md),eu=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 nu(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 iu=e=>e.map(eu);function ru(e,t){const n=iu(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 su(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 ou(e,t){const{joined:n,nonUnitPicks:i}=ru(e,t),s=su(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=nu(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 au(e,t){const n=e.map((s,o)=>o*t/e.length),i=At().domain(n).range(e);return Array.from(new Array(t).keys()).map(s=>{const o=ft(i(s)).rgb();return[o.r,o.g,o.b]})}const cu=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 hu(e,t){if(!(e&&e.datapoints))return null;const n=t.reduce((p,d)=>Math.min(p,d[0]),0),i=t.reduce((p,d)=>Math.max(p,d[0]),0),r=e.yAxisValues&&e.yAxisValues[0],s=e.yAxisValues&&e.yAxisValues[e.yAxisValues.length-1],o=e.datapoints||[],a=-o.reduce((p,d)=>Math.min(...d,p),0),c=o.reduce((p,d)=>Math.max(...d,p),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 lu(e,t,n,i={isLeftToRight:!0}){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((m,M)=>Math.min(...M,m),0),o=(i==null?void 0:i.seismicMax)||(i==null?void 0:i.seismicRange)||r.reduce((m,M)=>Math.max(...M,m),0),a=Math.max(Math.abs(s),Math.abs(o)),c=-a,h=a,l={min:c,max:h,difference:h-c},u=t[0][0]-t[t.length-1][0],f=Math.abs(Math.floor(u/5)),p=e.yAxisValues.length,d=1e3,g=au(n,d),y=new Uint8ClampedArray(f*p*4);let _=0;const x=(d-1)/l.difference;let v=(i==null?void 0:i.isLeftToRight)==null?t[0][0]:t[t.length-1][0];const P=u/f*(i!=null&&i.isLeftToRight?-1:1);let b,S,T,R,L;const N=[0,0,0];let C;for(let m=0;m<f;m++){_=m*4;const M=$n(t,v),w=t[M][0],E=t[M+1][0]-w,I=(v-w)/E;for(let z=0;z<p;z++)b=r[z][M],S=r[z][M+1],b==null||S==null?(L=N,C=0):(T=b*(1-I)+S*I,R=(T-l.min)*x,R=_t(~~R,0,d-1),L=g[R],C=255),y.set([L[0],L[1],L[2],C],_),_+=f*4;v+=P}const O=new ImageData(y,f,p);return await createImageBitmap(O,0,0,f,p)}const uu=2147483648,fu=4294967295;function du(e,t,n){const i=n.filter(p=>p.data.values),r=xu(i),s=new Map,o=yu(r,t,s);_u(o);const a=pu(r,e),c=Tu(e,o,t),h=mu(s,c),u=[...gu(h,e),...Object.values(c).flat().filter(p=>!p.exclude)];return{lines:a,areas:u}}function pu(e,t){return e.filter(i=>i.visualization==="line").map(i=>({id:i.name,label:i.name,width:2,color:lt(i.color||"black"),data:t.map((r,s)=>[r[0],i.values[s]])}))}function gu(e,t){return e.map((i,r)=>{const s=r+1<e.length?e[r+1]:null;return{id:i.id,color:lt(i.color),data:t.map((o,a)=>[o[0],i.top[a],s?s.top[a]:null])}})}function mu(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:wu(r),top:o.data.map(a=>a[1])}})}function yu(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=Jr(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 _u(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 Jr(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 xu(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 vu(e){return e.colorR===null||e.colorG===null||e.colorB===null?uu:e.colorR<<16|e.colorG<<8|e.colorB}const wu=Ui().domain([0,100]).range(Mo(Zt("#e6f1cf","#85906d"),10));function bu(e,t,n,i){const r=t+1;if(!n||r>=n.length)return null;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||Su(e,a,i))return o}return null}function Su(e,t,n){const i=[];return Jr(n,e.name,i),i.some(r=>t.name===r.identifier)}function Tu(e,t,n){return t.reduce((r,s,o)=>{if(!s.isBase){r[s.group]||(r[s.group]=[]);const a=bu(s,o,t,n);r[s.group].push({id:s.name,label:s.name,color:s.unit&&vu(s.unit)||fu,exclude:s.visualization==="none"||!s.unit,data:e.map((c,h)=>{const l=s.values[h]!==null?Mu(a,t,h):null;return[c[0],s.values[h],l]})})}return r},{})}function Mu(e,t,n){if(!t||!e||e>=t.length)return null;for(let i=e;i<t.length;i++)if(t[i].values[n]!==null)return t[i].values[n];return null}const Ei=.1,Ke=1e3,Pu=150,Au=30,Cu=10;function Lu(e){if(!e||e.length===0)return[];const t=e?e.map(r=>[r.easting,r.northing,r.tvd,r.md]):[],n=ts(es(t)),i=n[n.length-1][0];return n.forEach((r,s)=>{n[s][0]=i-r[0]}),n}function ku(e,t){if(!e||e.length===0)return[];const n=e?e.map(x=>[x.easting,x.northing,x.tvd,x.md]):[],i=new kn(n,{tension:.75,arcDivisions:5e3}),r=i.length,s=Math.round(r*Cu);let o=null;s>0?o=ts(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=null;if(h<Pu){const v=t/180*Math.PI;l=new D(Math.cos(v),Math.sin(v)).mutable}else l=Eu(o,Au);const u=Math.max(0,Ke-r),f=u+r,p=[];let d=[];const g=l.toArray();u>0&&(d=pi(Math.ceil(u*Ei)).map(x=>l.set(g).scale(u*(1-x)).subFrom(a).toArray()),d.pop(),p.push(...d)),p.push(...o);const y=pi(Math.ceil(Ke*Ei)).map(x=>l.set(g).scale(Ke*x).add(c).toArray()).splice(1);return p.push(...y),es(p,null,f)}function Eu(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 ts(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],[p,d]=s[l+1];if(p-u!==0||d-f!==0){const g=Math.abs(o*d-a*p+p*f-d*u+a*u-o*f)/Math.sqrt((p-o)**2+(d-a)**2),y=[o-u,a-f],_=Math.sqrt(y[0]**2+y[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 es(e,t=null,n=0){let i=t||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 Fu=18,Ru=8,Iu=13,Ou="black",zu="Arial",Du=70;class Nu extends bt{constructor(t,n){super(t,n),this.defaultMargins=Fu,this.defaultMinFontSize=Ru,this.defaultMaxFontSize=Iu,this.defaultTextColor=Ou,this.defaultFont=zu,this.isLabelsOnLeftSide=!0,this.maxFontSizeInWorldCoordinates=Du,this.isXFlipped=!1,this.areasWithAvgTopDepth=null,this.drawAreaLabel=(i,r,s,o)=>{const{data:a}=i,{ctx:c,maxFontSizeInWorldCoordinates:h,isXFlipped:l}=this,{xScale:u,yScale:f,xRatio:p,yRatio:d,zFactor:g}=this.rescaleEvent;let y=this.checkDrawLabelsOnLeftSide();const x=(this.options.margins||this.defaultMargins)*(l?-1:1)/p,v=this.options.minFontSize||this.defaultMinFontSize;let b=(this.options.maxFontSize||this.defaultMaxFontSize)/d;b>h&&(b=h,b*d<v&&(b=v/d));const S=u.invert(u.range()[0])+x,T=u.invert(u.range()[1])-x,[R,L]=this.getSurfacesAreaEdges();c.save(),c.font=`${b*d}px ${this.options.font||this.defaultFont}`;let N=c.measureText(i.label),C=N.width/p;if(y){const X=S+(l?-C:C);(!l&&X>L||l&&X<L)&&(y=!1)}else{const X=T+(l?C:-C);(!l&&X<R||l&&X>R)&&(y=!0)}let O;const $=.07;y?O=l?Math.min(R,S):Math.max(R,S):O=l?Math.max(L,T):Math.min(L,T);const m=f.invert(f.range()[0]),M=f.invert(f.range()[1]),w=5,A=3,E=$*(C/A)*(y?1:-1)*(l?-1:1),F=C/w*(y?1:-1)*(l?-1:1),I=a.map(X=>[X[0],X[1]]),z=this.calcPos(I,O,A,E,m,M);if(!z)return;const B=a.map(X=>[X[0],X[2]]);let V=this.calcPos(B,O,A,E,m,M,r?r.data.map(X=>[X[0],X[1]]):null,s,o);V||(V=new D(z.x,M));const H=V.y-z.y;if(H<b){if(H*d<v)return;b=H,c.font=`${b*d}px ${this.options.font||this.defaultFont}`,N=c.measureText(i.label),C=N.width/p}const W=y!==l?D.right:D.left,Q=this.calcAreaDir(I,B,O,w,F,W,m,M,0,Math.PI/4,4,r?r.data.map(X=>[X[0],X[1]]):null,s,o),U=Math.atan(Math.tan(Q)*g),J=O,$t=(z.y+V.y)/2,Ss=l?-U:U;c.textAlign=y?"left":"right",c.translate(u(J),f($t)),c.rotate(Ss),c.fillStyle=this.options.textColor||this.defaultTextColor,c.font=`${b*d}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,u=this.checkDrawLabelsOnLeftSide(),f=this.getMarginsInWorldCoordinates(),d=(this.options.maxFontSize||this.defaultMaxFontSize)/h;r.save(),r.font=`${d*h}px ${this.options.font||this.defaultFont}`;const y=r.measureText(i.label).width/c,_=o.invert(o.range()[0])+f,x=o.invert(o.range()[1])-f,[v,P]=this.getSurfacesAreaEdges();let b;const S=5;u?b=s?Math.max(P,x):Math.min(P,x):b=s?Math.min(v,_):Math.max(v,_);const T=y/S*(u?-1:1),{data:R}=i,L=this.calcPos(R,b,S,T),N=this.calcLineDir(R,b,S,T,l,u?D.left:D.right);if(!L||!N)return;const C=b,O=L.y-Ar-d/2,$=D.angleRight(N)-(u?Math.PI:0);r.textAlign=u?"right":"left",r.translate(o(C),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=null}generateSurfacesWithAvgDepth(){const{areas:t}=this.data;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||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=null,o=null,a=null,c=null,h=null){const l=D.zero.mutable;let u=0;for(let f=0;f<i;f++){const p=n+f*r,d=gt(t,p,s,o);if(d){const g=this.getAlternativeYValueIfAvailable(p,s,o,a,c,h),y=g?Math.min(d,g):d;l.add(p,y),u++}}return u===0?null:D.divide(l,u)}getAlternativeYValueIfAvailable(t,n,i,r,s,o){if(!r)return null;let a=gt(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=gt(h.data.map(l=>[l[0],l[1]]),t,n,i)}}return a}calcLineDir(t,n,i,r,s,o=D.left,a=null,c=null){const h=o.mutable,l=gt(t,n,a,c);if(l===null)return h;const u=new D(n,l*s),f=D.zero.mutable;for(let p=1;p<=i;p++){const d=n+p*r,g=gt(t,n,a,c);g!==null&&(f.set(d,g*s),f.sub(u),h.add(f))}return h}calcAreaDir(t,n,i,r,s,o=D.left,a=null,c=null,h=0,l=Math.PI/4,u=4,f=null,p=null,d=null){const g=[],y=D.zero.mutable;let _;for(let T=0;T<=r;T++){const R=i+T*s,L=gt(t,R,a,c),N=gt(n,R,a,c)||c,C=this.getAlternativeYValueIfAvailable(R,a,c,f,p,d),O=C?Math.min(N,C):N;if(T===0){if(L===null)return D.angleRight(o);const $=(L+O)/2;_=new D(i,$)}else L!==null?(y.set(R,(L+O)/2),y.sub(_),g.push(D.angleRight(y))):g.push(D.angleRight(o))}const x=g[0],v=g.map(T=>T-x);let P=0;return v.reduce((T,R)=>{const L=(Math.abs(R)-h)/l,N=Math.pow(1-_t(L,0,1),u);return P+=N,T+R*N},0)/P+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 p=Math.max(u[0][0],f[0][0]),d=Math.min(u[0][0],f[0][0]),g={left:n?p:d,right:n?d:p},y=this.getMarginsInWorldCoordinates(),_=a+y,x=c-y,[v,P]=this.getSurfacesAreaEdges(),b=n?Math.min(_,v):Math.max(_,v),S=n?Math.max(x,P):Math.min(x,P),T=Math.max(n?b-g.left:g.left-b,0),R=Math.max(n?g.right-S:S-g.right,0),L=T*s,N=R*s;return T>R||L>o||L<o&&N<o&&n||f[0][1]<h}}const $u=1e4;class Bu extends Nn{constructor(){super(...arguments),this.isPreRendered=!1,this.createPolygons=t=>{const n=[];let i=null;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]||$u);n.push(i),i=null}}return n},this.generateAreaPolygon=t=>{const n=new k.Graphics;n.lineStyle(1,t.color,1),n.beginFill(t.color),this.createPolygons(t.data).forEach(r=>n.drawPolygon(r)),n.endFill(),this.addChild(n)},this.generateSurfaceLine=t=>{const n=new k.Graphics,{data:i}=t,r=.5;n.lineStyle(Ar,t.color,1,r,!0);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 ns="lightgray",is="gray",rs=.25,ss=.75,Hu={minorColor:ns,majorColor:is,minorWidth:rs,majorWidth:ss};class ge extends bt{constructor(t,n){super(t,n),this._offsetX=0,this._offsetY=0,this.options={...this.options,...n||Hu},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[p,d]=a.range(),[g,y]=c.range();n.lineWidth=i||rs,n.strokeStyle=r||ns;const _=this.mapMinorTicks(a.ticks()),x=this.mapMinorTicks(c.ticks());this.renderTicksX(a,_,g,y),this.renderTicksY(c,x,p,d),n.lineWidth=s||ss,n.strokeStyle=o||is,this.renderTicksX(a,a.ticks(),g,y),this.renderTicksY(c,c.ticks(),p,d),n.restore()}renderTicksX(t,n,i,r){n.forEach(s=>{const o=t(s);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.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 Xu 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.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"),10),i=parseInt(this.elm.getAttribute("height"),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.isLoading?this.img.onload=()=>{this.isLoading=!1,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},mt=class{constructor(e,t={}){this.cursor=new st.Point,this.scale=1,this.graphics=e,t={...Vu,...t},this.dash=t.dash,this.dashSize=this.dash.reduce((n,i)=>n+i),this.useTexture=t.useTexture,this.options=t,this.setLineStyle()}setLineStyle(){const e=this.options;if(this.useTexture){const t=mt.getTexture(e,this.dashSize);this.graphics.lineTextureStyle({width:e.width*e.scale,color:e.color,alpha:e.alpha,texture:t,alignment:e.alignment})}else this.graphics.lineStyle({width:e.width*e.scale,color:e.color,alpha:e.alpha,cap:e.cap,join:e.join,alignment:e.alignment});this.scale=e.scale}static distance(e,t,n,i){return Math.sqrt(Math.pow(n-e,2)+Math.pow(i-t,2))}moveTo(e,t){return this.lineLength=0,this.cursor.set(e,t),this.start=new st.Point(e,t),this.graphics.moveTo(this.cursor.x,this.cursor.y),this}lineTo(e,t,n){typeof this.lineLength===void 0&&this.moveTo(0,0);const i=mt.distance(this.cursor.x,this.cursor.y,e,t),r=Math.atan2(t-this.cursor.y,e-this.cursor.x),s=n&&e===this.start.x&&t===this.start.y;if(this.useTexture)if(this.graphics.moveTo(this.cursor.x,this.cursor.y),this.adjustLineStyle(r),s&&this.dash.length%2===0){const o=Math.min(this.dash[this.dash.length-1],i);this.graphics.lineTo(e-Math.cos(r)*o,t-Math.sin(r)*o),this.graphics.closePath()}else this.graphics.lineTo(e,t);else{const o=Math.cos(r),a=Math.sin(r);let c=this.cursor.x,h=this.cursor.y;const l=this.lineLength%(this.dashSize*this.scale);let u=0,f=0,p=0;for(let g=0;g<this.dash.length;g++){const y=this.dash[g]*this.scale;if(l<p+y){u=g,f=l-p;break}else p+=y}let d=i;for(;d>0;){const g=this.dash[u]*this.scale-f,y=d>g?g:d;if(s&&mt.distance(c+o*y,h+a*y,this.start.x,this.start.y)<=y){if(u%2===0){const x=mt.distance(c,h,this.start.x,this.start.y)-this.dash[this.dash.length-1]*this.scale;c+=o*x,h+=a*x,this.graphics.lineTo(c,h)}break}c+=o*y,h+=a*y,u%2?this.graphics.moveTo(c,h):this.graphics.lineTo(c,h),d-=y,u++,u=u===this.dash.length?0:u,f=0}}return this.lineLength+=i,this.cursor.set(e,t),this}closePath(){this.lineTo(this.start.x,this.start.y,!0)}drawCircle(e,t,n,i=80,r){const s=Math.PI*2/i;let o=0,a;r?(a=new st.Point(e+Math.cos(o)*n,t+Math.sin(o)*n),r.apply(a,a),this.moveTo(a[0],a[1])):(a=new st.Point(e+Math.cos(o)*n,t+Math.sin(o)*n),this.moveTo(a.x,a.y)),o+=s;for(let c=1;c<i+1;c++){const h=c===i?a:[e+Math.cos(o)*n,t+Math.sin(o)*n];this.lineTo(h[0],h[1]),o+=s}return this}drawEllipse(e,t,n,i,r=80,s){const o=Math.PI*2/r;let a;const c=new st.Point;for(let h=0;h<Math.PI*2;h+=o){let l=e-n*Math.sin(h),u=t-i*Math.cos(h);s&&(c.set(l,u),s.apply(c,c),l=c.x,u=c.y),h===0?(this.moveTo(l,u),a={x:l,y:u}):this.lineTo(l,u)}return this.lineTo(a.x,a.y,!0),this}drawPolygon(e,t){const n=new st.Point;if(typeof e[0]=="number")if(t){n.set(e[0],e[1]),t.apply(n,n),this.moveTo(n.x,n.y);for(let i=2;i<e.length;i+=2)n.set(e[i],e[i+1]),t.apply(n,n),this.lineTo(n.x,n.y,i===e.length-2)}else{this.moveTo(e[0],e[1]);for(let i=2;i<e.length;i+=2)this.lineTo(e[i],e[i+1],i===e.length-2)}else if(t){const i=e[0];n.copyFrom(i),t.apply(n,n),this.moveTo(n.x,n.y);for(let r=1;r<e.length;r++){const s=e[r];n.copyFrom(s),t.apply(n,n),this.lineTo(n.x,n.y,r===e.length-1)}}else{const i=e[0];this.moveTo(i.x,i.y);for(let r=1;r<e.length;r++){const s=e[r];this.lineTo(s.x,s.y,r===e.length-1)}}return this}drawRect(e,t,n,i,r){if(r){const s=new st.Point;s.set(e,t),r.apply(s,s),this.moveTo(s.x,s.y),s.set(e+n,t),r.apply(s,s),this.lineTo(s.x,s.y),s.set(e+n,t+i),r.apply(s,s),this.lineTo(s.x,s.y),s.set(e,t+i),r.apply(s,s),this.lineTo(s.x,s.y),s.set(e,t),r.apply(s,s),this.lineTo(s.x,s.y,!0)}else this.moveTo(e,t).lineTo(e+n,t).lineTo(e+n,t+i).lineTo(e,t+i).lineTo(e,t,!0);return this}adjustLineStyle(e){const t=this.graphics.line;t.matrix=new st.Matrix,e&&t.matrix.rotate(e),this.scale!==1&&t.matrix.scale(this.scale,this.scale);const n=-this.lineLength;t.matrix.translate(this.cursor.x+n*Math.cos(e),this.cursor.y+n*Math.sin(e)),this.graphics.lineStyle(t)}static getTexture(e,t){const n=e.dash.toString();if(mt.dashTextureCache[n])return mt.dashTextureCache[n];const i=document.createElement("canvas");i.width=t,i.height=Math.ceil(e.width);const r=i.getContext("2d");if(!r){console.warn("Did not get context from canvas");return}r.strokeStyle="white",r.globalAlpha=e.alpha,r.lineWidth=e.width;let s=0;const o=e.width/2;r.moveTo(s,o);for(let c=0;c<e.dash.length;c+=2)s+=e.dash[c],r.lineTo(s,o),e.dash.length!==c+1&&(s+=e.dash[c+1],r.moveTo(s,o));r.stroke();const a=mt.dashTextureCache[n]=st.Texture.from(i);return a.baseTexture.scaleMode=st.SCALE_MODES.NEAREST,a}};let os=mt;os.dashTextureCache={};const vn=e=>new D(e.x,e.y),Uu=e=>new k.Point(e[0],e[1]),as=e=>{if(e.length<2)return[new D(0)];let t;return e.map((n,i,r)=>{if(i<r.length-1){const s=vn(r[i]);return t=vn(r[i+1]).sub(s).rotate90().normalized(),t}return t})},cs=(e,t,n)=>{const i=vn(e);return Uu(i.add(t.scale(n)))},wn=(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];return cs(i,s,n)})},Fi=(e,t,n,i)=>e<=i&&n<=t,Yu=(e,t,n,i)=>e<i&&n<t,Wu=e=>Array.from(new Set(e)),De=(e,t,n,i)=>{const r=i.filter(o=>Fi(e,t,o.start,o.end)),s=n.filter(o=>Fi(e,t,o.start,o.end));return{overlappingHoles:r,overlappingOuterStrings:s}},Ne=([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),Wu(s).sort((a,c)=>a-c)},G=e=>e.kind==="casing"?e.innerDiameter:e.diameter,hs=(e,t,n,i)=>{const s=e.find(h=>h.start<=i&&h.end>=i),o=s?s.diameter:0,a=t.filter(h=>G(h)>o).sort((h,l)=>G(h)-G(l)).find(h=>h.start<=i&&h.end>=i),c=n.find(h=>h.start<=i&&h.end>=i&&h.diameter>o);return a?G(a):c?c.diameter:100},Gu=(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"?G(s):o?o.diameter:100},qu=(e,t,n,i)=>{const s=e.sort((h,l)=>G(h)-G(l)).find(h=>h.start<=i&&h.end>=i);if(s)return G(s);const o=e.length?Math.min(...e.map(h=>G(h))):0,a=t.sort((h,l)=>G(h)-G(l)).find(h=>h.start<=i&&h.end>=i&&o<=G(h));if(a)return G(a);const c=n.find(h=>h.start<=i&&h.end>=i&&h.diameter);return c?c.diameter:100},ju=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Hn(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}=De(e.toc,c,a,i),u=[...h,...l].map(g=>({start:g.start,end:g.end}));return Ne([e.toc,c],u).flatMap((g,y,_)=>{if(y===_.length-1)return[];const x=_[y+1],v=hs(o,h,l,g);return[{top:g,bottom:x,diameter:v*r}]}).map(g=>({diameter:g.diameter,points:s(g.top,g.bottom)}))},Hn=(e,t,n)=>[...t,...n].reduce((i,r)=>e.includes(r.id)?{...i,attachedStrings:[...i.attachedStrings,r]}:{...i,nonAttachedStrings:[...i.nonAttachedStrings,r]},{attachedStrings:[],nonAttachedStrings:[]}),Zu=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Hn(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}=De(e.start,e.end,a,i),l=[...c,...h].map(d=>({start:d.start,end:d.end}));return Ne([e.start,e.end],l).flatMap((d,g,y)=>{if(g===y.length-1)return[];const _=y[g+1],x=hs(o,c,h,d);return[{top:d,bottom:_,diameter:x*r}]}).map(d=>({diameter:d.diameter,points:s(d.top,d.bottom)}))},Ku=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Hn(e.referenceIds,t,n),{overlappingHoles:c,overlappingOuterStrings:h}=De(e.start,e.end,a,i),l=[...o,...c,...h].map(d=>({start:d.start,end:d.end}));return Ne([e.start,e.end],l).flatMap((d,g,y)=>{if(g===y.length-1)return[];const _=y[g+1],x=qu(o,h,c,d);return[{top:d,bottom:_,diameter:x*r}]}).map(d=>({diameter:d.diameter,points:s(d.top,d.bottom)}))},Qu=(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},Ju=({firstColor:e,secondColor:t},n,i)=>{const r=document.createElement("canvas");r.width=n,r.height=i;const s=r.getContext("2d");return s.fillStyle=Qu(r,s,e,t,0),s.fillRect(0,0,r.width,r.height),k.Texture.from(r)},t0=({scalingFactor:e})=>{const t=document.createElement("canvas"),n=xt*e;t.width=n,t.height=n;const i=t.getContext("2d");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(),k.Texture.from(t)},e0=({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"),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),k.Texture.from(r)},n0=({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");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(),k.Texture.from(i)},i0=({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");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(),k.Texture.from(i)},r0=({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");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(),k.Texture.from(i)},me=(e,t)=>{const n=as(t),i=wn(t,n,e);return{leftPath:wn(t,n,-e),rightPath:i}},Qe=(e,t)=>({kind:"casing",start:e,end:t}),s0=(e,t)=>({kind:"casing-window",start:e,end:t}),o0=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?Qe(i,r.start):null,c=a?a.end:i,h=Math.max(c,r.start),l=Math.min(e.end,r.end),u=s0(h,l),f=l,d=s===o.length-1&&f<e.end?Qe(f,e.end):null,g=[a,u,d].filter(y=>y);return{intervals:[...n,...g],lastBottom:f}},{intervals:[],lastBottom:e.start});return t.intervals.length?t.intervals:[Qe(e.start,e.end)]},a0=(e,t,n)=>{const i=t.diameter*e,r=i/2,o=t.innerDiameter*e/2,a=r-o,c=o0(t).map(h=>{const l=n(h.start,h.end),{leftPath:u,rightPath:f}=me(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}},c0=(e,t,n,i,r)=>{const{overlappingOuterStrings:s,overlappingHoles:o}=De(e.start,e.end,t,n),a=[...s,...o].map(u=>({start:u.start,end:u.end}));return Ne([e.start,e.end],a).flatMap((u,f,p)=>{if(f===p.length-1)return[];const d=p[f+1],g=Gu(s,o,u,e.subKind);return[{top:u,bottom:d,diameter:g*i}]}).map(u=>{const f=r(u.top,u.bottom);return{diameter:u.diameter,points:f}})},$e=(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()},Xn=(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 p=()=>{for(let d=-1;d<o;d++){const g=[d*a+u+a/2,e.height/2-h-f-h];t.beginPath();const y=[...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],P=[g[0],g[1]-h];t.bezierCurveTo(...y,..._,...x),t.bezierCurveTo(...x,...v,...P),t.stroke()}for(let d=-1;d<o;d++){const g=[d*a+a+u+a/2,e.height/2+c/2+f];t.beginPath();const y=[...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],P=[g[0],g[1]+h];t.bezierCurveTo(...y,..._,...x),t.bezierCurveTo(...x,...v,...P),t.stroke()}};t.strokeStyle=i.yellow,t.lineWidth=6,t.save(),p(),t.restore(),t.lineWidth=1,t.strokeStyle=i.outline,p(),t.closePath()},h0=(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()},at=(e="Error!",t)=>{console.error(`${e}`);const n=(t==null?void 0:t.canvas)||document.createElement("canvas"),i=xt;n.width=i/2,n.height=i;const r=(t==null?void 0:t.canvasCtx)||n.getContext("2d"),s=[0,0],o=[n.width,n.height];return r.fillStyle="#ff00ff",r.fillRect(...s,...o),new k.Texture(k.Texture.from(n,{wrapMode:k.WRAP_MODES.CLAMP}).baseTexture,null,new k.Rectangle(0,0,n.width,n.height),null,k.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");return{canvas:n,ctx:s}},wt=e=>new k.Texture(k.Texture.from(e,{wrapMode:k.WRAP_MODES.CLAMP}).baseTexture,null,new k.Rectangle(0,0,e.width,e.height),null,k.groupD8.MIRROR_HORIZONTAL),l0=(e,t)=>n=>t.some(i=>n(i)&&$r(e,i)),Vn={packing:()=>at(),fracLines:()=>at(),spikes:(e,t,n,i)=>{const{canvas:r,ctx:s}=vt(t,i),o=l0(e,n),a=o(zr),c=o(Nr),h=o(Dr),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),h0(r,s,t.diameter,i),h&&Xn(r,s,t.diameter,i,"spike"),wt(r)}},ls={packing:()=>at(),fracLines:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return Xn(n,i,e.diameter,t,"diameter"),wt(n)},spikes:()=>at()},ke={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return $e(n,i,t),wt(n)},fracLines:(e,t)=>{const{canvas:n}=vt(e,t);return wt(n)},spikes:()=>at()},Un={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return $e(n,i,t),wt(n)},fracLines:()=>at(),spikes:()=>at()},Yn={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return $e(n,i,t),wt(n)},fracLines:()=>at(),spikes:()=>at()},Wn={packing:(e,t,n)=>{const{canvas:i,ctx:r}=vt(t,n);return $e(i,r,n),wt(i)},fracLines:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return Xn(n,i,e.diameter,t,"diameter"),wt(n)},spikes:()=>at()},u0=(e,t,n)=>Z({Perforation:()=>Vn.packing(),CasedHoleFracturation:()=>ke.packing(t,n),CasedHoleFracPack:()=>ke.packing(t,n),OpenHoleGravelPack:()=>Yn.packing(t,n),OpenHoleFracPack:()=>Wn.packing(e,t,n),CasedHoleGravelPack:()=>Un.packing(t,n)},e.subKind),f0=(e,t,n)=>Z({Perforation:()=>Vn.fracLines(),OpenHoleGravelPack:()=>Yn.fracLines(),OpenHoleFracPack:()=>Wn.fracLines(t,n),CasedHoleFracturation:()=>ls.fracLines(t,n),CasedHoleGravelPack:()=>Un.fracLines(),CasedHoleFracPack:()=>ke.fracLines(t,n)},e.subKind),d0=(e,t,n,i)=>Z({Perforation:()=>Vn.spikes(e,n,t,i),OpenHoleGravelPack:()=>Yn.spikes(),OpenHoleFracPack:()=>Wn.spikes(),CasedHoleFracturation:()=>ls.spikes(),CasedHoleGravelPack:()=>Un.spikes(),CasedHoleFracPack:()=>ke.spikes()},e.subKind);class p0 extends k.MeshGeometry{constructor(t){const n=Ve(t,i=>i.points.length);super(new Float32Array(n*4),new Float32Array(n*4),new Uint16Array((n-1)*6)),this.segments=t,this.build()}get width(){return nn(this.segments,t=>t.diameter)}build(){const t=this.segments;if(!t)return;const n=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),r=this.getIndex(),s=Ve(t,d=>d.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=nn(t,d=>d.diameter);let l=0,u=0,f=0,p=0;for(let d=0;d<c;d++){let g=t[d].points[0];const y=h,_=t[d].diameter/h/2,x=t[d].points.length;for(let v=0;v<x;v++){const P=g.x-t[d].points[v].x,b=g.y-t[d].points[v].y,S=Math.sqrt(P*P+b*b);g=t[d].points[v],l+=S/y,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[p++]=f,a[p++]=f+1,a[p++]=f+2,a[p++]=f+2,a[p++]=f+1,a[p++]=f+3,f+=2;f+=2}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.segments;if(Ve(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 p=0;p<u;p++){const d=t[s].points[p];f=r+p*4,p<t[s].points.length-1?a=t[s].points[p+1]:a=d,h=-(a.x-o.x),c=a.y-o.y;const g=Math.sqrt(c*c+h*h),y=t[s].diameter/2;c/=g,h/=g,c*=y,h*=y,l[f]=d.x+c,l[f+1]=d.y+h,l[f+2]=d.x-c,l[f+3]=d.y-h,o=d}r=f+4}this.buffers[0].update()}update(){this.build()}}class g0 extends k.Mesh{constructor(t,n){const i=new p0(n),r=new k.MeshMaterial(t);t.baseTexture.wrapMode=k.WRAP_MODES.REPEAT,super(i,r),this.autoUpdate=!0}_render(t){const n=this.geometry;this.autoUpdate&&n.update(),super._render(t)}}class m0 extends k.MeshGeometry{constructor(t,n=200){super(new Float32Array(t.length*4),new Float32Array(t.length*4),new Uint16Array((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("aVertexPosition"),i=this.getBuffer("aTextureCoord"),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,p=c.x-t[u].x,d=c.y-t[u].y,g=Math.sqrt(p*p+d*d);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 y0 extends k.Mesh{constructor(t,n,i){const r=new m0(n,i),s=new k.MeshMaterial(t);t.baseTexture.wrapMode=k.WRAP_MODES.REPEAT,super(r,s),this.autoUpdate=!0}_render(t){const n=this.geometry;this.autoUpdate&&n.update(),super._render(t)}}class _0 extends k.MeshGeometry{constructor(t,n=200){super(new Float32Array(t.length*4),new Float32Array(t.length*4),new Uint16Array((t.length-1)*6)),this.points=t,this._width=n,this.build()}build(){const t=this.points;if(!t)return;const n=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),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 p=0;p<s;p++){const d=a.x-t[p].x,g=a.y-t[p].y,y=Math.sqrt(d*d+g*g);a=t[p],o+=y}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 p=0;p<s;p++){const d=p*4,g=u.x-t[p].x,y=u.y-t[p].y,_=Math.sqrt(g*g+y*y);u=t[p],l+=_/o,c[d]=l,c[d+1]=0,c[d+2]=l,c[d+3]=1}let f=0;for(let p=0;p<s-1;p++){const d=p*2;h[f++]=d,h[f++]=d+1,h[f++]=d+2,h[f++]=d+2,h[f++]=d+1,h[f++]=d+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 x0 extends k.Mesh{constructor(t,n){const i=new _0(n,t.height),r=new k.MeshMaterial(t);super(i,r),this.autoUpdate=!0}_render(t){const n=this.geometry;(this.autoUpdate||n._width!==this.shader.texture.height)&&(n._width=this.shader.texture.height,n.update()),super._render(t)}}const v0=(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)}},w0=e=>({exaggerationFactor:2,internalLayerOptions:Br(e),holeOptions:Hr,casingOptions:Xr,cementOptions:Ur,cementSqueezeOptions:Yr,screenOptions:Wr,tubingOptions:Gr,cementPlugOptions:qr,perforationOptions:Vr}),us=class extends Nn{constructor(e,t,n){super(e,t,n),this.internalLayerVisibility={holeLayerId:!0,casingLayerId:!0,completionLayerId:!0,cementLayerId:!0,pAndALayerId:!0,perforationLayerId:!0},this.scalingFactors={height:600,zFactor:1,yScale:At()},this.getZFactorScaledPathForPoints=(i,r)=>{const s=a=>a*this.scalingFactors.zFactor;return this.referenceSystem.getCurtainPath(i,r,!0).map(a=>new k.Point(a.point[0],s(a.point[1])))},this.drawBigPolygon=(i,r=0)=>{const s=new k.Graphics;s.beginFill(r),s.drawPolygon(i),s.endFill(),this.addChild(s)},this.perforationRopeAndTextureReferences=[],this.prepareSymbolRenderObject=i=>{const{exaggerationFactor:r}=this.options,s=i.diameter*r;return{pathPoints:this.getZFactorScaledPathForPoints(i.start,i.end),referenceDiameter:s,symbolKey:i.symbolKey}},this.drawSymbolComponent=({pathPoints:i,referenceDiameter:r,symbolKey:s})=>{const o=this.getSymbolTexture(s,r);this.drawSVGRope(i,o)},this.drawHoleSize=(i,r)=>{if(r==null)return;const s=this.getZFactorScaledPathForPoints(r.start,r.end);if(s.length===0)return;const{exaggerationFactor:o,holeOptions:a}=this.options,c=r.diameter*o,{rightPath:h,leftPath:l}=me(c/2,s),u=this.getHoleTexture(a,c,i);this.drawHoleRope(s,u,i),this.drawOutline(l,h,lt(a.lineColor),Al*o,"TopAndBottom",0)},this.drawCasing=i=>{const{casingOptions:r}=this.options,s=lt(r.solidColor),o=lt(r.lineColor);i.sections.forEach((a,c,h)=>{const l=us.getOutlineClosureType(c,h.length-1),u=this.createCasingTexture(i.referenceDiameter);this.drawRope(a.pathPoints,u,s),a.kind==="casing-window"?this.drawCasingWindowOutline(a.leftPath,a.rightPath,r,i.casingWallWidth):this.drawOutline(a.leftPath,a.rightPath,o,i.casingWallWidth,l)})},this.generateShoe=(i,r,s,o)=>{const a=i-s,c=i,h=this.getZFactorScaledPathForPoints(a,c),l=as(h),u=wn(h,l,r*(o<0?-1:1)),f=h[h.length-1],p=l[l.length-1],d=cs(f,p,o+r*(o<0?-1:1));return[...u,d]},this.createCementSqueezeShape=(i,r,s,o)=>{const{exaggerationFactor:a}=this.options;return Zu(i,r,s,o,a,this.getZFactorScaledPathForPoints)},this.createPerforationShape=(i,r,s)=>{const{exaggerationFactor:o}=this.options;return c0(i,r,s,o,this.getZFactorScaledPathForPoints)},this.options={...this.options,...w0(this.id),...n}}onUnmount(e){super.onUnmount(e),this.scalingFactors=null,this.cementTextureCache=null,this.cementSqueezeTextureCache=null,this.holeTextureCache=null,this.screenTextureCache=null,this.tubingTextureCache=null,this.textureSymbolCacheArray=null,this.internalLayerVisibility=null}onUpdate(e){super.onUpdate(e),this.clearLayer(),this.preRender(),this.render()}onRescale(e){const t=this.scalingFactors.zFactor!==e.zFactor;this.scalingFactors={height:e.height,zFactor:e.zFactor,yScale:e.yScale},super.optionsRescale(e);const n=this.yRatio(),i=e.xBounds[0]>e.xBounds[1],r=e.yBounds[0]>e.yBounds[1];this.setContainerPosition(e.xScale(0),e.yScale(0)),this.setContainerScale(e.xRatio*(i?-1:1),n*(r?-1:1)),t&&(this.clearLayer(),this.preRender()),this.render()}setVisibility(e,t){if(t===this.id){super.setVisibility(e,t);return}const{internalLayerOptions:n}=this.options,[i]=Object.entries(n).find(([r,s])=>s===t);i&&(this.internalLayerVisibility[i]=e,this.clearLayer(),this.preRender(),this.render())}getInternalLayerIds(){const{internalLayerOptions:e}=this.options;return Object.values(e)}yRatio(){const e=this.scalingFactors.yScale.domain(),n=(e[1]-e[0])*this.scalingFactors.zFactor,i=[e[0],e[0]+n];return Math.abs(this.scalingFactors.height/(i[1]-i[0]))}drawRope(e,t,n){if(e.length===0)return null;const i=new k.SimpleRope(t,e,1);i.tint=n||i.tint,this.addChild(i)}drawOutline(e,t,n,i=1,r="None",s=1){const o=e.map(l=>l.clone()).reverse(),a=t[0],c=o[0],h=new k.Graphics;h.lineStyle(i,n,void 0,s),h.moveTo(a.x,a.y),t.forEach(l=>h.lineTo(l.x,l.y)),(r==="None"||r==="Top")&&h.moveTo(c.x,c.y),o.forEach(l=>h.lineTo(l.x,l.y)),(r==="TopAndBottom"||r==="Top")&&h.lineTo(a.x,a.y),this.addChild(h)}drawCasingWindowOutline(e,t,{lineColor:n,windowOptions:i},r=1){var d,g;const s=!!((g=(d=this.referenceSystem)==null?void 0:d.options)!=null&&g.calculateDisplacementFromBottom),[o,a]=s?[e,t]:[t,e],[c,h]=s?[1,0]:[0,1],l=new k.Graphics;l.lineStyle(r,lt(n),void 0,h);const u=o[0];l.moveTo(u.x,u.y),o.forEach(y=>l.lineTo(y.x,y.y));const f=new os(l,{dash:[i.dashLength,i.spaceLength],color:lt(i.dashColor),width:r,alignment:c}),p=a[0];f.moveTo(p.x,p.y),a.forEach(y=>{f.lineTo(y.x,y.y)}),this.addChild(l)}preRender(){if(!this.data||!this.referenceSystem)return;const{exaggerationFactor:e}=this.options,{holeSizes:t,casings:n,cements:i,completion:r,symbols:s,pAndA:o,perforations:a}=this.data;this.updateSymbolCache(s),t.sort((d,g)=>g.diameter-d.diameter);const c=t.length>0?nn(t,d=>d.diameter)*e:Pl*e;this.internalLayerVisibility.holeLayerId&&t.forEach(d=>this.drawHoleSize(c,d)),n.sort((d,g)=>g.diameter-d.diameter);const h=n.map(d=>this.createCasingRenderObject(d)),l=i.map(d=>({kind:"cement",segments:ju(d,n,r,t,e,this.getZFactorScaledPathForPoints),casingIds:(d.referenceIds||[]).filter(g=>g)})),[u,f]=o.reduce(([d,g],y)=>kr(y)?[[y,...d],g]:[d,[y,...g]],[[],[]]),p=u.map(d=>({kind:"cementSqueeze",segments:this.createCementSqueezeShape(d,n,r,t),casingIds:d.referenceIds}));if(this.sortCementAndCasingRenderObjects(h,l,p).forEach(v0(d=>{this.internalLayerVisibility.casingLayerId&&(this.drawCasing(d),d.hasShoe&&this.drawShoe(d.bottom,d.referenceRadius))},d=>{this.internalLayerVisibility.cementLayerId&&this.drawComplexRope(d.segments,this.getCementTexture())},d=>{this.internalLayerVisibility.pAndALayerId&&this.drawComplexRope(d.segments,this.getCementSqueezeTexture())})),this.perforationRopeAndTextureReferences.forEach(({rope:d,texture:g})=>{d.destroy({children:!0,texture:!0,baseTexture:!0}),g.destroy(!0)}),this.perforationRopeAndTextureReferences=[],this.internalLayerVisibility.perforationLayerId){const{perforationOptions:d}=this.options,g=a.filter(Rr),y=a.filter(Ir),_=a.filter(Or);g.forEach(x=>{const P=this.createPerforationShape(x,n,t).reduce((b,S)=>(b[S.diameter]||(b[S.diameter]=[]),b[S.diameter]=[...b[S.diameter],S],b),{});Object.values(P).forEach(b=>{const S=u0(x,b[0],d),T=this.drawComplexRope(b,S);this.perforationRopeAndTextureReferences.push({rope:T,texture:S})})}),_.forEach(x=>{const b=this.createPerforationShape(x,n,t).map(S=>({...S,diameter:S.diameter*3})).reduce((S,T)=>(S[T.diameter]||(S[T.diameter]=[]),S[T.diameter]=[...S[T.diameter],T],S),{});Object.values(b).forEach(S=>{S.forEach(T=>{const R=d0(x,a,T,d),L=this.drawComplexRope([T],R);this.perforationRopeAndTextureReferences.push({rope:L,texture:R})})})}),y.forEach(x=>{const b=this.createPerforationShape(x,n,t).map(S=>({...S,diameter:S.diameter*3})).reduce((S,T)=>(S[T.diameter]||(S[T.diameter]=[]),S[T.diameter]=[...S[T.diameter],T],S),{});Object.values(b).forEach(S=>{S.forEach(T=>{const R=f0(x,T,d),L=this.drawComplexRope([T],R);this.perforationRopeAndTextureReferences.push({rope:L,texture:R})})})})}this.internalLayerVisibility.completionLayerId&&r.forEach(Fr(d=>this.drawScreen(d),d=>this.drawTubing(d),d=>{const g=this.prepareSymbolRenderObject(d);this.drawSymbolComponent(g)})),this.internalLayerVisibility.pAndALayerId&&f.forEach(d=>{if(Lr(d)){const g=this.prepareSymbolRenderObject(d);this.drawSymbolComponent(g)}Er(d)&&this.drawCementPlug(d,n,r,t)})}updateSymbolCache(e){if(this.textureSymbolCacheArray||(this.textureSymbolCacheArray={}),!e)return;const t=Object.keys(this.textureSymbolCacheArray);Object.entries(e).forEach(([n,i])=>{t.includes(n)||(this.textureSymbolCacheArray[n]=k.Texture.from(i))})}drawCementPlug(e,t,n,i){const{exaggerationFactor:r,cementPlugOptions:s}=this.options,o=Ku(e,t,n,i,r,this.getZFactorScaledPathForPoints);this.drawComplexRope(o,this.getCementPlugTexture(s));const{rightPath:a,leftPath:c}=o.reduce((h,l)=>{const{leftPath:u,rightPath:f}=me(l.diameter/2,l.points);return{rightPath:[...h.rightPath,...f],leftPath:[...h.leftPath,...u]}},{rightPath:[],leftPath:[]});this.drawOutline(c,a,lt("black"),.25,"TopAndBottom")}createCasingRenderObject(e){const{exaggerationFactor:t}=this.options;return a0(t,e,this.getZFactorScaledPathForPoints)}getCementPlugTexture(e){return this.cementPlugTextureCache||(this.cementPlugTextureCache=i0(e)),this.cementPlugTextureCache}drawSVGRope(e,t){if(e.length===0)return null;const n=new x0(t,e);this.addChild(n)}getSymbolTexture(e,t){return new k.Texture(this.textureSymbolCacheArray[e].baseTexture,null,new k.Rectangle(0,0,0,t),null,k.groupD8.MAIN_DIAGONAL)}drawHoleRope(e,t,n){if(e.length===0)return null;const i=new k.SimpleRope(t,e,n/xt);this.addChild(i)}getHoleTexture(e,t,n){const i=xt,r=i,s=i,o=t/n*i;this.holeTextureCache||(this.holeTextureCache=Ju(e,s,r));const a=this.holeTextureCache.baseTexture,c=(r-o)/2,h=new k.Rectangle(0,c,s,o);return new k.Texture(a,h)}sortCementAndCasingRenderObjects(e,t,n){let i=0;const{result:r}=e.reduce((s,o)=>{const a=s.remainingCement.find(h=>h.casingIds.includes(o.id)),c=s.remainingCementSqueezes.filter(h=>h.casingIds.includes(o.id));return a&&(a.zIndex=i++),c.forEach(h=>h.zIndex=i++),o.zIndex=i++,{result:[...s.result,a,o,...c],remainingCement:s.remainingCement.filter(h=>h!==a),remainingCementSqueezes:s.remainingCementSqueezes.filter(h=>!c.includes(h))}},{result:[],remainingCement:t,remainingCementSqueezes:n});return r.filter(s=>s!==void 0).sort((s,o)=>s.zIndex-o.zIndex)}drawComplexRope(e,t){if(e.length===0)return null;const n=new g0(t,e);return this.addChild(n),n}createCasingTexture(e){return new k.Texture(k.Texture.WHITE.baseTexture,null,new k.Rectangle(0,0,16,e))}drawShoe(e,t){const{exaggerationFactor:n,casingOptions:i}=this.options,r=i.shoeSize.width*n,s=i.shoeSize.length*n,o=this.generateShoe(e,t,s,r),a=this.generateShoe(e,t,s,-r);this.drawBigPolygon(a),this.drawBigPolygon(o)}getCementTexture(){if(!this.cementTextureCache){const{cementOptions:e}=this.options;this.cementTextureCache=n0(e)}return this.cementTextureCache}getCementSqueezeTexture(){if(!this.cementSqueezeTextureCache){const{cementSqueezeOptions:e}=this.options;this.cementSqueezeTextureCache=r0(e)}return this.cementSqueezeTextureCache}drawScreen({start:e,end:t,diameter:n}){const{exaggerationFactor:i,screenOptions:r}=this.options,s=i*n,o=this.getZFactorScaledPathForPoints(e,t),{leftPath:a,rightPath:c}=me(s/2,o),h=this.getScreenTexture();this.drawCompletionRope(o,h,s),this.drawOutline(a,c,lt(r.lineColor),Cl*i,"TopAndBottom")}drawTubing({diameter:e,start:t,end:n}){const{exaggerationFactor:i,tubingOptions:r}=this.options,s=i*e,o=this.getZFactorScaledPathForPoints(t,n),a=this.getTubingTexture(r);this.drawCompletionRope(o,a,s)}getTubingTexture(e){return this.tubingTextureCache||(this.tubingTextureCache=e0(e)),this.tubingTextureCache}getScreenTexture(){if(!this.screenTextureCache){const{screenOptions:e}=this.options;this.screenTextureCache=t0(e)}return this.screenTextureCache}drawCompletionRope(e,t,n){if(e.length===0)return;const i=new y0(t,e,n);this.addChild(i)}};let fs=us;fs.getOutlineClosureType=(e,t)=>e===0?e===t?"TopAndBottom":"Top":e===t?"Bottom":"None";class b0 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 Lt(e){return function(){return e}}const Ri=1e-12,bn=Math.PI,Sn=2*bn,Tt=1e-6,S0=Sn-Tt;function ds(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function T0(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return ds;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?ds:T0(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 p=i-o,d=r-a,g=c*c+h*h,y=p*p+d*d,_=Math.sqrt(g),x=Math.sqrt(f),v=s*Math.tan((bn-Math.acos((g+f-y)/(2*_*x)))/2),P=v/x,b=v/_;Math.abs(P-1)>Tt&&this._append`L${t+P*l},${n+P*u}`,this._append`A${s},${s},0,0,${+(u*p>l*d)},${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)>Tt||Math.abs(this._y1-l)>Tt)&&this._append`L${h},${l}`,i&&(f<0&&(f=f%Sn+Sn),f>S0?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>=bn)},${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 A0(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ps(e){this._context=e}ps.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 gs(e){return new ps(e)}function C0(e){return e[0]}function L0(e){return e[1]}function k0(e,t){var n=Lt(!0),i=null,r=gs,s=null,o=P0(a);e=typeof e=="function"?e:e===void 0?C0:Lt(e),t=typeof t=="function"?t:t===void 0?L0:Lt(t);function a(c){var h,l=(c=A0(c)).length,u,f=!1,p;for(i==null&&(s=r(p=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(p)return s=null,p+""||null}return a.x=function(c){return arguments.length?(e=typeof c=="function"?c:Lt(+c),a):e},a.y=function(c){return arguments.length?(t=typeof c=="function"?c:Lt(+c),a):t},a.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Lt(!!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 Ii(){}function Tn(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 Be(e){this._context=e}Be.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:Tn(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:Tn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function E0(e){return new Be(e)}function ms(e){this._context=e}ms.prototype={areaStart:Ii,areaEnd:Ii,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:Tn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function F0(e){return new ms(e)}function ys(e,t){this._basis=new Be(e),this._beta=t}ys.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 R0=function e(t){function n(i){return t===1?new Be(i):new ys(i,t)}return n.beta=function(i){return e(+i)},n}(.85);function Oi(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 Gn(e,t){this._context=e,this._k=(1-t)/6}Gn.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:Oi(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:Oi(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 I0=function e(t){function n(i){return new Gn(i,t)}return n.tension=function(i){return e(+i)},n}(0);function O0(e,t,n){var i=e._x1,r=e._y1,s=e._x2,o=e._y2;if(e._l01_a>Ri){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>Ri){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 _s(e,t){this._context=e,this._alpha=t}_s.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:O0(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 z0=function e(t){function n(i){return t?new _s(i,t):new Gn(i,0)}return n.alpha=function(i){return e(+i)},n}(.5);function zi(e){return e<0?-1:1}function Di(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(zi(s)+zi(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(a))||0}function Ni(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function Je(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 Ee(e){this._context=e}Ee.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:Je(this,this._t0,Ni(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,Je(this,Ni(this,n=Di(this,e,t)),n);break;default:Je(this,this._t0,n=Di(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function xs(e){this._context=new vs(e)}(xs.prototype=Object.create(Ee.prototype)).point=function(e,t){Ee.prototype.point.call(this,t,e)};function vs(e){this._context=e}vs.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 D0(e){return new Ee(e)}function N0(e){return new xs(e)}function ws(e){this._context=e}ws.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=$i(e),r=$i(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 $i(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 $0(e){return new ws(e)}function He(e,t){this._context=e,this._t=t}He.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 B0(e){return new He(e,.5)}function H0(e){return new He(e,0)}function X0(e){return new He(e,1)}const V0=.7,U0=.9,Y0=1;class W0 extends Cr{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){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=z0.alpha(a||V0);break;case"curveLinear":s=gs;break;case"curveBasis":s=E0;break;case"curveBasisClosed":s=F0;break;case"curveBundle":s=R0.beta(a||Y0);break;case"curveCardinal":s=I0.tension(a||U0);break;case"curveMonotoneX":s=D0;break;case"curveMonotoneY":s=N0;break;case"curveNatural":s=$0;break;case"curveStep":s=B0;break;case"curveStepAfter":s=X0;break;case"curveStepBefore":s=H0;break}return k0().curve(s)(r)}}const Bi=(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 G0 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,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.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}=this,{canvas:o}=this,a=Le(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){Bi({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=>{Bi({solid:i=>this.drawSolid(i),dashed:i=>this.drawDashed(i),wavy:i=>this.drawWavy(i)},n)})})}}class bs{constructor(t,n,i){if(this.layers=[],this.createAxis=r=>{const{container:s}=this;this._svgContainer=q(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 tr(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"),+this.container.getAttribute("height")),this._zoomPanHandler=new Tr(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-Mr:t,0),r=Math.max(this._axis?n-Pr: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.offsetX=t,this._axis.offsetY=n,this.layers.filter(r=>r instanceof ge).forEach(r=>{r.offsetX=t,r.offsetY=n}),this}setXAxisOffset(t){return this._axis.offsetX=t,this.layers.filter(i=>i instanceof ge).forEach(i=>{i.offsetX=t}),this}setYAxisOffset(t){return this._axis.offsetY=t,this.layers.filter(i=>i instanceof ge).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.layerContainer=void 0,this.container=void 0,this.layers=void 0,this._zoomPanHandler=void 0,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 q0{constructor(t,n){this.elements={},this.listeners={},this.enabled=!0;const i=q(n);this.elm=i.append("div").attr("id","overlay").style("z-index","11").style("position","absolute"),this.source=this.elm.node();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]||null,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]=pt(s,this.elm.node());Object.keys(this.listeners).forEach(c=>{const h=this.elements[c]||null,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]||null,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();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&&(q(n).remove(),delete this.elements[t]),delete this.listeners[t]}setZIndex(t){this.elm.style("z-index",t)}destroy(){this.source.remove()}}const j0=(e,t)=>new q0(e,t);class Z0{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=j0(this,n),this.layerManager=new bs(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-Mr,0),height:Math.max(n-Pr,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.layerManager=void 0,this._overlay=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=tr;exports.CalloutCanvasLayer=Yl;exports.CanvasLayer=bt;exports.Controller=Z0;exports.GeomodelCanvasLayer=Zl;exports.GeomodelLabelsLayer=Nu;exports.GeomodelLayerV2=Bu;exports.GridLayer=ge;exports.HTMLLayer=El;exports.ImageLayer=Xu;exports.IntersectionReferenceSystem=zt;exports.Layer=te;exports.LayerManager=bs;exports.PixiLayer=Nn;exports.PixiRenderApplication=Fl;exports.ReferenceLineLayer=G0;exports.SVGLayer=Cr;exports.SchematicLayer=fs;exports.SeismicCanvasLayer=b0;exports.WellborepathLayer=W0;exports.ZoomPanHandler=Tr;exports.assertNever=ee;exports.calcSize=Le;exports.defaultCasingOptions=Xr;exports.defaultCementOptions=Ur;exports.defaultCementPlugOptions=qr;exports.defaultCementSqueezeOptions=Yr;exports.defaultHoleOptions=Hr;exports.defaultInternalLayerOptions=Br;exports.defaultPerforationOptions=Vr;exports.defaultScreenOptions=Wr;exports.defaultTubingOptions=Gr;exports.findIndexOfSample=$n;exports.findSampleAtPos=gt;exports.foldCompletion=Fr;exports.foldPerforationSubKind=Z;exports.generateProjectedTrajectory=ku;exports.generateProjectedWellborePath=Lu;exports.generateSeismicSliceImage=lu;exports.generateSurfaceData=du;exports.getOverlap=Nl;exports.getOverlapOffset=xn;exports.getPicksData=tu;exports.getSeismicInfo=hu;exports.getSeismicOptions=cu;exports.hasFracLines=Ir;exports.hasPacking=Rr;exports.hasSpikes=Or;exports.intersect=$r;exports.isCementPlug=Er;exports.isCementSqueeze=kr;exports.isOpenHoleFracPack=zl;exports.isOverlapping=Qr;exports.isOverlappingHorizontally=Dl;exports.isPAndASymbol=Lr;exports.isSubKindCasedHoleFracPack=Dr;exports.isSubKindCasedHoleFracturation=Nr;exports.isSubKindPerforation=Ol;exports.isSubkindCasedHoleGravelPack=zr;exports.pixelsPerUnit=Kr;exports.shouldPerforationStartAtCasingDiameter=Il;exports.shouldPerforationStartAtHoleDiameter=Rl;exports.transformFormationData=ou;
|
|
15
15
|
//# sourceMappingURL=index.cjs.map
|