shop-components 0.1.16 → 0.1.18

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.
@@ -61981,7 +61981,7 @@ class pf extends be {
61981
61981
  linewidth: 2,
61982
61982
  dashSize: 0.03,
61983
61983
  gapSize: 0.02
61984
- })), this._text = new LS(), this._textWrapper = new zt(), this.add(this._line), this._showText && (this._text.fontSize = 0.06, this._text.color = "#666", this._text.textAlign = "justify", this._text.anchorX = "center", this._text.anchorY = "bottom", this._text.lineHeight = 1.8, this.add(this._textWrapper), this._textWrapper.add(this._text));
61984
+ })), this._text = new LS(), this._textWrapper = new zt(), this._line.frustumCulled = !1, this.add(this._line), this._showText && (this._text.fontSize = 0.06, this._text.color = "#666", this._text.textAlign = "justify", this._text.anchorX = "center", this._text.anchorY = "bottom", this._text.lineHeight = 1.8, this.add(this._textWrapper), this._textWrapper.add(this._text));
61985
61985
  }
61986
61986
  reset() {
61987
61987
  var A;
@@ -66629,20 +66629,20 @@ let Zr = class extends Yr {
66629
66629
  super.firstUpdated(n), this.container && ((A = this.container) == null || A.append(this.app.view), this.app.resizeTo = this.container, this.viewport.addChild(this._sprite));
66630
66630
  }
66631
66631
  setUV(n) {
66632
- const A = n.attributes.uv, e = n.index;
66633
- if (!e) {
66632
+ const { screenWidth: A, screenHeight: e } = this.viewport, t = n.attributes.uv, i = n.index;
66633
+ if (!i) {
66634
66634
  this.pathD = "";
66635
66635
  return;
66636
66636
  }
66637
- let t = [];
66638
- for (let r = 0; r < e.count; r += 3) {
66639
- const s = e.getX(r), o = e.getX(r + 1), a = e.getX(r + 2), l = [A.getX(s) * 200, A.getY(s) * 200], u = [A.getX(o) * 200, A.getY(o) * 200], c = [A.getX(a) * 200, A.getY(a) * 200];
66640
- t.push(l, u, c);
66637
+ let r = [];
66638
+ for (let o = 0; o < i.count; o += 3) {
66639
+ const a = i.getX(o), l = i.getX(o + 1), u = i.getX(o + 2), c = [t.getX(a) * A, t.getY(a) * e], h = [t.getX(l) * A, t.getY(l) * e], f = [t.getX(u) * A, t.getY(u) * e];
66640
+ r.push(c, h, f);
66641
66641
  }
66642
- let i = "";
66643
- t.forEach((r, s) => {
66644
- s % 3 === 0 ? i += `M${r[0]},${r[1]} ` : i += `L${r[0]},${r[1]} `, s % 3 === 2 && (i += "Z ");
66645
- }), t = [], this.pathD = i;
66642
+ let s = "";
66643
+ r.forEach((o, a) => {
66644
+ a % 3 === 0 ? s += `M${o[0]},${o[1]} ` : s += `L${o[0]},${o[1]} `, a % 3 === 2 && (s += "Z ");
66645
+ }), r = [], this.pathD = s;
66646
66646
  }
66647
66647
  async add(n, A) {
66648
66648
  this._imageUrl = n, this.logoSize = A, this._sprite.texture = await GA.fromURL(n), this.imageSize.width = this._sprite.texture.width, this.imageSize.height = this._sprite.texture.height, this.fit();
@@ -66663,13 +66663,14 @@ let Zr = class extends Yr {
66663
66663
  }), this.viewport.off("zoomed"), this.viewport.off("moved"), this.viewport.off("moved-end"), this.app.view.removeEventListener("wheel", this._wheelEvent), this.app.destroy(!0);
66664
66664
  }
66665
66665
  render() {
66666
+ const { screenWidth: n, screenHeight: A } = this.viewport;
66666
66667
  return Uv`
66667
66668
  <div class="cropper-container">
66668
66669
  <div class="rect"></div>
66669
66670
  <div class="axios-x"></div>
66670
66671
  <div class="axios-y"></div>
66671
66672
  <div class="cross"></div>
66672
- <svg class="uv-mask" viewBox="0 0 200 200">
66673
+ <svg class="uv-mask" viewBox="0 0 ${n} ${A}">
66673
66674
  <path d=${this.pathD} stroke-width="1" stroke="gray" stroke-opacity="0.3" fill="none"></path>
66674
66675
  </svg>
66675
66676
  </div>
@@ -9808,7 +9808,7 @@ if (edgeAlpha == 0.0) {
9808
9808
  `;function hj(n){const A=nv(n,{chained:!0,extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFTextureSize:{value:new dA},uTroikaSDFGlyphSize:{value:0},uTroikaSDFExponent:{value:0},uTroikaTotalBounds:{value:new ve(0,0,0,0)},uTroikaClipRect:{value:new ve(0,0,0,0)},uTroikaDistanceOffset:{value:0},uTroikaOutlineOpacity:{value:0},uTroikaFillOpacity:{value:1},uTroikaPositionOffset:{value:new dA},uTroikaCurveRadius:{value:0},uTroikaBlurRadius:{value:0},uTroikaStrokeWidth:{value:0},uTroikaStrokeColor:{value:new FA},uTroikaStrokeOpacity:{value:1},uTroikaOrient:{value:new le},uTroikaUseGlyphColors:{value:!0},uTroikaSDFDebug:{value:!1}},vertexDefs:oj,vertexTransform:aj,fragmentDefs:lj,fragmentColorTransform:cj,customRewriter({vertexShader:e,fragmentShader:t}){let i=/\buniform\s+vec3\s+diffuse\b/;return i.test(t)&&(t=t.replace(i,"varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g,"vTroikaGlyphColor"),i.test(e)||(e=e.replace(pS,`uniform vec3 diffuse;
9809
9809
  $&
9810
9810
  vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;
9811
- `))),{vertexShader:e,fragmentShader:t}}});return A.transparent=!0,Object.defineProperties(A,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),A}const ov=new Ki({color:16777215,side:st,transparent:!0}),DS=8421504,ES=new zA,Hf=new O,av=new O,xc=[],uj=new O,lv="+x+y";function LS(n){return Array.isArray(n)?n[0]:n}let OS=()=>{const n=new De(new Rn(1,1),ov);return OS=()=>n,n},qS=()=>{const n=new De(new Rn(1,1,32,1),ov);return qS=()=>n,n};const fj={type:"syncstart"},dj={type:"synccomplete"},NS=["font","fontSize","fontStyle","fontWeight","lang","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],pj=NS.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");class BS extends De{constructor(){const A=new sj;super(A,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.unicodeFontsURL=null,this.fontSize=.1,this.fontWeight="normal",this.fontStyle="normal",this.lang=null,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=DS,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=lv,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(A){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(A):(this._isSyncing=!0,this.dispatchEvent(fj),$k({text:this.text,font:this.font,lang:this.lang,fontSize:this.fontSize||.1,fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF,unicodeFontsURL:this.unicodeFontsURL},e=>{this._isSyncing=!1,this._textRenderInfo=e,this.geometry.updateGlyphs(e.glyphBounds,e.glyphAtlasIndices,e.blockBounds,e.chunkedBounds,e.glyphColors);const t=this._queuedSyncs;t&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{t.forEach(i=>i&&i())})),this.dispatchEvent(dj),A&&A()})))}onBeforeRender(A,e,t,i,r,s){this.sync(),r.isTroikaTextMaterial&&this._prepareForRender(r),r._hadOwnSide=r.hasOwnProperty("side"),this.geometry.setSide(r._actualSide=r.side),r.side=qt}onAfterRender(A,e,t,i,r,s){r._hadOwnSide?r.side=r._actualSide:delete r.side}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}get material(){let A=this._derivedMaterial;const e=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=ov.clone());if((!A||A.baseMaterial!==e)&&(A=this._derivedMaterial=hj(e),e.addEventListener("dispose",function t(){e.removeEventListener("dispose",t),A.dispose()})),this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY){let t=A._outlineMtl;return t||(t=A._outlineMtl=Object.create(A,{id:{value:A.id+.1}}),t.isTextOutlineMaterial=!0,t.depthWrite=!1,t.map=null,A.addEventListener("dispose",function i(){A.removeEventListener("dispose",i),t.dispose()})),[t,A]}else return A}set material(A){A&&A.isTroikaTextMaterial?(this._derivedMaterial=A,this._baseMaterial=A.baseMaterial):this._baseMaterial=A}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(A){this.geometry.detail=A}get curveRadius(){return this.geometry.curveRadius}set curveRadius(A){this.geometry.curveRadius=A}get customDepthMaterial(){return LS(this.material).getDepthMaterial()}get customDistanceMaterial(){return LS(this.material).getDistanceMaterial()}_prepareForRender(A){const e=A.isTextOutlineMaterial,t=A.uniforms,i=this.textRenderInfo;if(i){const{sdfTexture:o,blockBounds:a}=i;t.uTroikaSDFTexture.value=o,t.uTroikaSDFTextureSize.value.set(o.image.width,o.image.height),t.uTroikaSDFGlyphSize.value=i.sdfGlyphSize,t.uTroikaSDFExponent.value=i.sdfExponent,t.uTroikaTotalBounds.value.fromArray(a),t.uTroikaUseGlyphColors.value=!e&&!!i.glyphColors;let l=0,u=0,c=0,h,f,p,m=0,d=0;if(e){let{outlineWidth:y,outlineOffsetX:v,outlineOffsetY:w,outlineBlur:C,outlineOpacity:S}=this;l=this._parsePercent(y)||0,u=Math.max(0,this._parsePercent(C)||0),h=S,m=this._parsePercent(v)||0,d=this._parsePercent(w)||0}else c=Math.max(0,this._parsePercent(this.strokeWidth)||0),c&&(p=this.strokeColor,t.uTroikaStrokeColor.value.set(p??DS),f=this.strokeOpacity,f==null&&(f=1)),h=this.fillOpacity;t.uTroikaDistanceOffset.value=l,t.uTroikaPositionOffset.value.set(m,d),t.uTroikaBlurRadius.value=u,t.uTroikaStrokeWidth.value=c,t.uTroikaStrokeOpacity.value=f,t.uTroikaFillOpacity.value=h??1,t.uTroikaCurveRadius.value=this.curveRadius||0;let g=this.clipRect;if(g&&Array.isArray(g)&&g.length===4)t.uTroikaClipRect.value.fromArray(g);else{const y=(this.fontSize||.1)*100;t.uTroikaClipRect.value.set(a[0]-y,a[1]-y,a[2]+y,a[3]+y)}this.geometry.applyClipRect(t.uTroikaClipRect.value)}t.uTroikaSDFDebug.value=!!this.debugSDF,A.polygonOffset=!!this.depthOffset,A.polygonOffsetFactor=A.polygonOffsetUnits=this.depthOffset||0;const r=e?this.outlineColor||0:this.color;if(r==null)delete A.color;else{const o=A.hasOwnProperty("color")?A.color:A.color=new FA;(r!==o._input||typeof r=="object")&&o.set(o._input=r)}let s=this.orientation||lv;if(s!==A._orientation){let o=t.uTroikaOrient.value;s=s.replace(/[^-+xyz]/g,"");let a=s!==lv&&s.match(/^([-+])([xyz])([-+])([xyz])$/);if(a){let[,l,u,c,h]=a;Hf.set(0,0,0)[u]=l==="-"?1:-1,av.set(0,0,0)[h]=c==="-"?-1:1,ES.lookAt(uj,Hf.cross(av),av),o.setFromMatrix4(ES)}else o.identity();A._orientation=s}}_parsePercent(A){if(typeof A=="string"){let e=A.match(/^(-?[\d.]+)%$/),t=e?parseFloat(e[1]):NaN;A=(isNaN(t)?0:t/100)*this.fontSize}return A}localPositionToTextCoords(A,e=new dA){e.copy(A);const t=this.curveRadius;return t&&(e.x=Math.atan2(A.x,Math.abs(t)-Math.abs(A.z))*Math.abs(t)),e}worldPositionToTextCoords(A,e=new dA){return Hf.copy(A),this.localPositionToTextCoords(this.worldToLocal(Hf),e)}raycast(A,e){const{textRenderInfo:t,curveRadius:i}=this;if(t){const r=t.blockBounds,s=i?qS():OS(),o=s.geometry,{position:a,uv:l}=o.attributes;for(let u=0;u<l.count;u++){let c=r[0]+l.getX(u)*(r[2]-r[0]);const h=r[1]+l.getY(u)*(r[3]-r[1]);let f=0;i&&(f=i-Math.cos(c/i)*i,c=Math.sin(c/i)*i),a.setXYZ(u,c,h,f)}o.boundingSphere=this.geometry.boundingSphere,o.boundingBox=this.geometry.boundingBox,s.matrixWorld=this.matrixWorld,s.material.side=this.material.side,xc.length=0,s.raycast(A,xc);for(let u=0;u<xc.length;u++)xc[u].object=this,e.push(xc[u])}}copy(A){const e=this.geometry;return super.copy(A),this.geometry=e,pj.forEach(t=>{this[t]=A[t]}),this}clone(){return new this.constructor().copy(this)}}NS.forEach(n=>{const A="_private_"+n;Object.defineProperty(BS.prototype,n,{get(){return this[A]},set(e){e!==this[A]&&(this[A]=e,this._needsSync=!0)}})});class Uf extends Se{constructor(A,e=!0){super(),this._startWith=A,this._showText=e,this._line=new jh(new qe,new SD({color:"#666",scale:1,linewidth:2,dashSize:.03,gapSize:.02})),this._text=new BS,this._textWrapper=new zt,this.add(this._line),this._showText&&(this._text.fontSize=.06,this._text.color="#666",this._text.textAlign="justify",this._text.anchorX="center",this._text.anchorY="bottom",this._text.lineHeight=1.8,this.add(this._textWrapper),this._textWrapper.add(this._text))}reset(){var A;(A=this._line.geometry)==null||A.dispose(),this._line.computeLineDistances()}update(A,e){var r;(r=this._line.geometry)==null||r.dispose(),this._line.geometry.setFromPoints([A,e]),this._line.computeLineDistances();const t=A.distanceTo(e);this._startWith?this._text.text=`${this._startWith}${(t*1e3).toFixed(0)} mm`:this._text.text=`${(t*1e3).toFixed(0)} mm`;const i=new O;i.addVectors(A,e).multiplyScalar(.5),this._textWrapper.position.copy(i),this._text.lookAt(e),this._text.rotateY(Math.PI/2),this._text.rotateX(-Math.PI/3),this._text.sync()}updateDirection(A){this._textWrapper.lookAt(A)}updateSize(A){var i;const e=(i=this.parent)==null?void 0:i.position.clone();e==null||e.setY(this.position.y);let t=(e==null?void 0:e.distanceTo(A))||1;t*=1.2,t<5&&(t=5),this._tw&&this._tw.isPlaying()&&this._tw.stop(),this._tw=new ws.Tween(this._text).to({fontSize:t/100}).duration(300).easing(ws.Easing.Quintic.InOut).start()}dispose(){this._tw.stop(),this._text.dispose(),er(this)}}class zS extends Se{constructor(A,e){super(),this.radius=A,this._text=new gj(""),this._line=new Uf(void 0,!1),this._box=new De,this._box.geometry=new Xh(A,A+.003,128),this._box.material=new Ki({color:"#898989",side:st}),this.position.y=e,this._box.rotateX(-Math.PI/2),this.add(this._box),this.add(this._line),this.add(this._text)}hide(){this._text.hide(),this._line.visible=!1}show(){this._text.show(),this._line.visible=!0}update(A){var e;this.radius=A,(e=this._box.geometry)==null||e.dispose(),this._box.geometry=new Xh(A,A+.003,128),this._text.update((A*1e3).toFixed(0))}change(A){const e=A.clone();e.setY(0),e.normalize().multiplyScalar(this.radius),this._text.position.set(e.x,e.y,e.z),this._line.update(e,new O)}}class gj extends zg{constructor(A){const e=document.createElement("div");super(e),this._wrapper=document.createElement("div"),this._wrapper.style.fontSize="10px",this._wrapper.style.color="#898989",this._wrapper.style.whiteSpace="nowrap",this._wrapper.style.position="absolute",this._wrapper.style.transform="translateX(-50%)",this._wrapper.style.bottom="4px";const t=document.createElement("div");t.style.position="relative",t.style.zIndex="10",t.style.width=t.style.height="5px",t.style.borderRadius="50%",t.style.background="#ff6666",e.append(this._wrapper,t),this.update(A)}show(){this.element.style.display="block"}hide(){this.element.style.display="none"}update(A){this._wrapper.innerText="旋转半径:"+A+" mm"}}const cv="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAAAXNSR0IArs4c6QAADOlJREFUeF7t3Wt6GzcSQNGmNxZ7M5nZhZNd2N5MlI0N56NpWpJNif0oPAo4+ht0AbhVuN0NtJnT4g8BBKYlcJp25iaOAAILASgCBCYmQAATJ9/UESAANYDAxAQIYOLkmzoCBKAGEJiYAAFMnH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FAgRQMWvGjEAQAQIIAikMAhUJEEDFrBkzAkEECCAIpDAIVCRAABWzZswIBBEggCCQwiBQkQABVMyaMSMQRIAAgkAKg0BFAgRQMWvGjEAQgf8DKv6MH/R9oFMAAAAASUVORK5CYII=";class RS extends zg{constructor(A,e){const t=document.createElement("div");super(t),this.props=A,this.amr=e,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._update=()=>{if(this._looper=requestAnimationFrame(this._update),this._controlling){let s=(Date.now()-this._startAt)/200;s>4&&(s=4);let o=this._initial+.005*s*this._direction;if(o>this.props.max||o<this.props.min||(this._initial=o,!this.mechanism))return;this.mechanism.position.setY(o)}},A.userData&&A.userData.target&&e.traverse(s=>{s.name===A.userData.target.name&&(this.mechanism=s)}),t.style.fontSize="30px",t.style.color="#0066FF",t.style.cursor="pointer",t.style.pointerEvents="auto";const i=document.createElement("div");i.innerText="↑",i.style.position="absolute",i.style.left="0",i.style.transform="translateX(-50%)",i.style.marginBottom="5px",i.setAttribute("data-direction","up");const r=document.createElement("div");if(r.style.position="absolute",r.style.left="0",r.style.transform="translateX(-50%)",r.innerText="↓",i.style.bottom=r.style.top="8px",r.setAttribute("data-direction","down"),Array.from([i,r]).forEach(s=>{s.addEventListener("mousemove",()=>{s.style.color="#00FF95"}),s.addEventListener("mouseleave",()=>{s.style.color="#0066FF"}),s.addEventListener("pointerdown",()=>{this.mechanism&&(this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.y,this._direction=s.getAttribute("data-direction")==="up"?1:-1)}),s.addEventListener("pointerup",()=>{this._controlling=!1}),s.addEventListener("pointerleave",()=>{this._controlling=!1})}),A.userData&&(this._canRotate=A.userData.canRotate,this._canRotate)){const{rotateTarget:s,rotateDuration:o,rotateStep:a,rotateMax:l,rotateMin:u}=A.userData;let c;if(s&&(e.traverse(h=>{h.name===s.name&&(c=h)}),c)){const h=document.createElement("div");h.style.background=`url(${cv}) center no-repeat`,h.style.backgroundSize="100% auto",h.style.width=h.style.height="35px",h.style.position="absolute",h.style.top="0",h.style.transform="translateY(-50%) scaleX(-100%) rotateZ(-30deg) rotateX(-40deg)",h.style.marginBottom="5px",h.setAttribute("data-direction","left"),t.append(h);const f=document.createElement("div");f.style.background=`url(${cv}) center no-repeat`,f.style.backgroundSize="100% auto",f.style.width=f.style.height="35px",f.style.position="absolute",h.style.right=f.style.left="10px",f.style.top="0",f.style.transform="translateY(-50%) rotateZ(-30deg) rotateX(-40deg)",f.style.marginBottom="5px",f.setAttribute("data-direction","right"),t.append(f),Array.from([h,f]).forEach(p=>{p.addEventListener("mousemove",()=>{p.style.backgroundImage=`url(${mj})`}),p.addEventListener("mouseleave",()=>{p.style.backgroundImage=`url(${cv})`}),p.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;this._controllingRotate=!0,this._startAt=Date.now(),this._direction=p.getAttribute("data-direction")==="left"?-1:1;let m=a/180*Math.PI*this._direction+c.rotation.y;m>l/180*Math.PI?m=l/180*Math.PI:m<u/180*Math.PI&&(m=u/180*Math.PI),this._timer=new bu(c.rotation).to({y:m}).duration(o).start()}),p.addEventListener("pointerup",()=>{this._controllingRotate=!1}),p.addEventListener("pointerleave",()=>{this._controllingRotate=!1})})}}t.append(i,r),this.scale.set(.01,.01,.01),this.matrixAutoUpdate=!1,this.updateMatrix(),this._update()}dispose(){cancelAnimationFrame(this._looper),this.element.remove()}}class vj extends a5{constructor(A){const e=document.createElement("div");super(e),this.props=A,this._scale=.01,this._emitter=new Cs,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new dA,this._targetSize=new dA,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=a=>{const{pageX:l,pageY:u}=a;this.endNode.setPointerCapture(a.pointerId),this._mouseStart.set(l,u),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=a=>{if(!this._mouseStart.x)return;const{pageX:l,pageY:u}=a;let c=l-this._mouseStart.x,h=c+this._targetSize.x;this._sizeFlag==="height"&&(c=u-this._mouseStart.y,h=c*this._direction+this._targetSize.y);const f=h%10;h=h-f,c=(h-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(c=(h-this._targetSize.y)*this._direction),this._textNode.innerText=(h/100).toFixed(2)+" m",this.endNode.parentElement.style[this._sizeFlag]=`${h}px`},this._pointercancel=a=>{this.endNode.releasePointerCapture(a.pointerId),this._mouseStart.set(0,0)};const{start:t,end:i}=A,r=i.distanceTo(t);this.props.axios==="z"?this.props.axios="y":this.props.axios==="y"&&(this.props.axios="z"),this.props.axios==="y"&&(this._sizeFlag="height");const s=document.createElement("div");s.style.position="absolute",s.style.left="0",s.style.bottom="0",e.append(s),this._textNode=document.createElement("div"),this._textNode.innerText=r.toFixed(2)+" m",s.append(this._textNode);const o=document.createElement("div");this.endNode=o,o.style.position="absolute",o.style.left="auto",o.style.right="0",o.style.width="4px",o.style.height="4px",o.style.background="#0066FF",o.style.borderRadius="50%",o.style.margin="-2px -2px 0 0",o.style.cursor="pointer",s.append(o),this.scale.set(this._scale,this._scale,this._scale),e.style.fontSize="6px",e.style.color="#fff",s.style[this._sizeFlag]=r*100+"px",s.style.textAlign="center",this._sizeFlag==="height"?(s.style.borderLeft="0.1px dashed #fff",s.style.display="flex",s.style.alignItems="center",s.style.justifyContent="center",s.style.whiteSpace="nowrap",o.style.top="0",o.style.left="0",o.style.right="auto",o.style.margin="-2px 0 0 -2px"):s.style.borderBottom="0.1px dashed #fff",o.addEventListener("pointerdown",this._pointerdown),o.addEventListener("pointermove",this._pointermove),o.addEventListener("pointerup",this._pointercancel),i[this.props.axios]<t[this.props.axios]?this.rotateY(Math.PI):this._direction=-1}_getIndexByAxios(){return this.props.axios==="y"?1:this.props.axios==="z"?2:0}dispose(){this._lines.forEach(A=>A.dispose()),this._emitter.removeAllListeners(),this.endNode.removeEventListener("pointerdown",this._pointerdown),this.endNode.removeEventListener("pointermove",this._pointermove),this.endNode.removeEventListener("pointerup",this._pointercancel),this.element.remove(),this._caches.forEach(A=>A.clear()),this._caches=[]}}const yj="*{box-sizing:border-box}.pointer-container{width:20px;height:20px;pointer-events:auto;cursor:pointer;display:flex;align-items:center;justify-content:center}.pointer-container.active .point{transform:scale(3);background:#06f}.pointer-container:hover .point{transform:scale(4);background:#00ff95}.pointer-container:hover .value{opacity:1;transform:translate3d(-50%,0,0)}.pointer-container .point{width:3px;height:3px;border-radius:50%;background:#898989;transition:all .2s}.pointer-container .value{white-space:nowrap;pointer-events:none;font-size:12px;opacity:0;position:absolute;bottom:80%;left:50%;color:#898989;transform:translate3d(-50%,-14px,0);transition:all .2s}";var wj=Object.defineProperty,Cj=Object.getOwnPropertyDescriptor,hv=(n,A,e,t)=>{for(var i=t>1?void 0:t?Cj(A,e):A,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(t?s(A,e,i):s(i))||i);return t&&i&&wj(A,e,i),i};class xj extends Se{constructor(){super(),this._box3=new ye,this._line11=new Uf("长:"),this._line12=new Uf("宽:"),this._line13=new Uf("高:"),this._outline=new zS(0,0),this._radius=0,this._hasWidthConfig=!1,this._hasLengthConfig=!1,this._hasHeightConfig=!1,this.follow="",this.followOrigin=0,this.followScale=1,this.originOffset=0,this.translateCache=0,this._changeSize=k9(A=>{this._line11.updateSize(A),this._line12.updateSize(A),this._line13.updateSize(A)},100),this._change=()=>{if(!this._app)return;const A=this._app.camera;A&&(this._outline.change(A.position),this._changeSize(A.position),this._line13.updateDirection(A.position))},this.add(this._outline,this._line11,this._line12,this._line13)}get hasSizeConfig(){return{length:this._hasLengthConfig,width:this._hasWidthConfig,height:this._hasHeightConfig}}get size(){return this._box3.clone()}get radius(){return this._radius}init(A){this._app=A,this._app.controls.addEventListener("change",this._change)}reset(){this.hide()}generate(A,e=0){A&&(this._object=A),this.update(e)}show(){this.visible=!0,this._outline.visible=!0,this._outline.show(),this.traverse(A=>A.visible=!0)}hide(){this.visible=!1,this._outline.visible=!1,this._outline.hide(),this.traverse(A=>A.visible=!1)}dispose(){var A;(A=this._app)==null||A.controls.removeEventListener("change",this._change),this._line11.dispose(),this._line12.dispose(),this._line13.dispose()}update(A=0){if(!this._object)return;const e=this._object,{box:t,maxRadius:i,hasLength:r,hasHeight:s,hasWidth:o}=Mb(e);this._hasWidthConfig=o,this._hasLengthConfig=r,this._hasHeightConfig=s,this._box3.copy(t),this._radius=i,this.follow&&A&&(this.originOffset=(this.followOrigin-A)*this.followScale),this._outline.update(this._radius),this._change();const a=this._box3.min.x,l=this._box3.max.x,u=this._box3.min.z,c=this._box3.max.z,h=this._box3.min.y,f=this._box3.max.y;let p=.3;const m=new O(a,0,u),d=new O(l,0,u);this._line11.update(m.clone().sub(new O(0,0,p/1.8)),d.clone().sub(new O(0,0,p/1.8)));const g=new O(l,0,c);this._line12.update(d.clone().add(new O(p,0,0)),g.clone().add(new O(p,0,0)));const y=new O(a,h,u),v=new O(a,f,u),w=y.clone();w.z-=p/3;const C=v.clone();C.z-=p/3,this._line13.update(w,C)}}let Ic=class extends Kr{constructor(n,A=!1){super(),this.text="",this.active=!1,this.text=(n*1e3).toFixed(0),this.active=A}render(){return Z0`
9811
+ `))),{vertexShader:e,fragmentShader:t}}});return A.transparent=!0,Object.defineProperties(A,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),A}const ov=new Ki({color:16777215,side:st,transparent:!0}),DS=8421504,ES=new zA,Hf=new O,av=new O,xc=[],uj=new O,lv="+x+y";function LS(n){return Array.isArray(n)?n[0]:n}let OS=()=>{const n=new De(new Rn(1,1),ov);return OS=()=>n,n},qS=()=>{const n=new De(new Rn(1,1,32,1),ov);return qS=()=>n,n};const fj={type:"syncstart"},dj={type:"synccomplete"},NS=["font","fontSize","fontStyle","fontWeight","lang","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],pj=NS.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");class BS extends De{constructor(){const A=new sj;super(A,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.unicodeFontsURL=null,this.fontSize=.1,this.fontWeight="normal",this.fontStyle="normal",this.lang=null,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=DS,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=lv,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(A){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(A):(this._isSyncing=!0,this.dispatchEvent(fj),$k({text:this.text,font:this.font,lang:this.lang,fontSize:this.fontSize||.1,fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF,unicodeFontsURL:this.unicodeFontsURL},e=>{this._isSyncing=!1,this._textRenderInfo=e,this.geometry.updateGlyphs(e.glyphBounds,e.glyphAtlasIndices,e.blockBounds,e.chunkedBounds,e.glyphColors);const t=this._queuedSyncs;t&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{t.forEach(i=>i&&i())})),this.dispatchEvent(dj),A&&A()})))}onBeforeRender(A,e,t,i,r,s){this.sync(),r.isTroikaTextMaterial&&this._prepareForRender(r),r._hadOwnSide=r.hasOwnProperty("side"),this.geometry.setSide(r._actualSide=r.side),r.side=qt}onAfterRender(A,e,t,i,r,s){r._hadOwnSide?r.side=r._actualSide:delete r.side}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}get material(){let A=this._derivedMaterial;const e=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=ov.clone());if((!A||A.baseMaterial!==e)&&(A=this._derivedMaterial=hj(e),e.addEventListener("dispose",function t(){e.removeEventListener("dispose",t),A.dispose()})),this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY){let t=A._outlineMtl;return t||(t=A._outlineMtl=Object.create(A,{id:{value:A.id+.1}}),t.isTextOutlineMaterial=!0,t.depthWrite=!1,t.map=null,A.addEventListener("dispose",function i(){A.removeEventListener("dispose",i),t.dispose()})),[t,A]}else return A}set material(A){A&&A.isTroikaTextMaterial?(this._derivedMaterial=A,this._baseMaterial=A.baseMaterial):this._baseMaterial=A}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(A){this.geometry.detail=A}get curveRadius(){return this.geometry.curveRadius}set curveRadius(A){this.geometry.curveRadius=A}get customDepthMaterial(){return LS(this.material).getDepthMaterial()}get customDistanceMaterial(){return LS(this.material).getDistanceMaterial()}_prepareForRender(A){const e=A.isTextOutlineMaterial,t=A.uniforms,i=this.textRenderInfo;if(i){const{sdfTexture:o,blockBounds:a}=i;t.uTroikaSDFTexture.value=o,t.uTroikaSDFTextureSize.value.set(o.image.width,o.image.height),t.uTroikaSDFGlyphSize.value=i.sdfGlyphSize,t.uTroikaSDFExponent.value=i.sdfExponent,t.uTroikaTotalBounds.value.fromArray(a),t.uTroikaUseGlyphColors.value=!e&&!!i.glyphColors;let l=0,u=0,c=0,h,f,p,m=0,d=0;if(e){let{outlineWidth:y,outlineOffsetX:v,outlineOffsetY:w,outlineBlur:C,outlineOpacity:S}=this;l=this._parsePercent(y)||0,u=Math.max(0,this._parsePercent(C)||0),h=S,m=this._parsePercent(v)||0,d=this._parsePercent(w)||0}else c=Math.max(0,this._parsePercent(this.strokeWidth)||0),c&&(p=this.strokeColor,t.uTroikaStrokeColor.value.set(p??DS),f=this.strokeOpacity,f==null&&(f=1)),h=this.fillOpacity;t.uTroikaDistanceOffset.value=l,t.uTroikaPositionOffset.value.set(m,d),t.uTroikaBlurRadius.value=u,t.uTroikaStrokeWidth.value=c,t.uTroikaStrokeOpacity.value=f,t.uTroikaFillOpacity.value=h??1,t.uTroikaCurveRadius.value=this.curveRadius||0;let g=this.clipRect;if(g&&Array.isArray(g)&&g.length===4)t.uTroikaClipRect.value.fromArray(g);else{const y=(this.fontSize||.1)*100;t.uTroikaClipRect.value.set(a[0]-y,a[1]-y,a[2]+y,a[3]+y)}this.geometry.applyClipRect(t.uTroikaClipRect.value)}t.uTroikaSDFDebug.value=!!this.debugSDF,A.polygonOffset=!!this.depthOffset,A.polygonOffsetFactor=A.polygonOffsetUnits=this.depthOffset||0;const r=e?this.outlineColor||0:this.color;if(r==null)delete A.color;else{const o=A.hasOwnProperty("color")?A.color:A.color=new FA;(r!==o._input||typeof r=="object")&&o.set(o._input=r)}let s=this.orientation||lv;if(s!==A._orientation){let o=t.uTroikaOrient.value;s=s.replace(/[^-+xyz]/g,"");let a=s!==lv&&s.match(/^([-+])([xyz])([-+])([xyz])$/);if(a){let[,l,u,c,h]=a;Hf.set(0,0,0)[u]=l==="-"?1:-1,av.set(0,0,0)[h]=c==="-"?-1:1,ES.lookAt(uj,Hf.cross(av),av),o.setFromMatrix4(ES)}else o.identity();A._orientation=s}}_parsePercent(A){if(typeof A=="string"){let e=A.match(/^(-?[\d.]+)%$/),t=e?parseFloat(e[1]):NaN;A=(isNaN(t)?0:t/100)*this.fontSize}return A}localPositionToTextCoords(A,e=new dA){e.copy(A);const t=this.curveRadius;return t&&(e.x=Math.atan2(A.x,Math.abs(t)-Math.abs(A.z))*Math.abs(t)),e}worldPositionToTextCoords(A,e=new dA){return Hf.copy(A),this.localPositionToTextCoords(this.worldToLocal(Hf),e)}raycast(A,e){const{textRenderInfo:t,curveRadius:i}=this;if(t){const r=t.blockBounds,s=i?qS():OS(),o=s.geometry,{position:a,uv:l}=o.attributes;for(let u=0;u<l.count;u++){let c=r[0]+l.getX(u)*(r[2]-r[0]);const h=r[1]+l.getY(u)*(r[3]-r[1]);let f=0;i&&(f=i-Math.cos(c/i)*i,c=Math.sin(c/i)*i),a.setXYZ(u,c,h,f)}o.boundingSphere=this.geometry.boundingSphere,o.boundingBox=this.geometry.boundingBox,s.matrixWorld=this.matrixWorld,s.material.side=this.material.side,xc.length=0,s.raycast(A,xc);for(let u=0;u<xc.length;u++)xc[u].object=this,e.push(xc[u])}}copy(A){const e=this.geometry;return super.copy(A),this.geometry=e,pj.forEach(t=>{this[t]=A[t]}),this}clone(){return new this.constructor().copy(this)}}NS.forEach(n=>{const A="_private_"+n;Object.defineProperty(BS.prototype,n,{get(){return this[A]},set(e){e!==this[A]&&(this[A]=e,this._needsSync=!0)}})});class Uf extends Se{constructor(A,e=!0){super(),this._startWith=A,this._showText=e,this._line=new jh(new qe,new SD({color:"#666",scale:1,linewidth:2,dashSize:.03,gapSize:.02})),this._text=new BS,this._textWrapper=new zt,this._line.frustumCulled=!1,this.add(this._line),this._showText&&(this._text.fontSize=.06,this._text.color="#666",this._text.textAlign="justify",this._text.anchorX="center",this._text.anchorY="bottom",this._text.lineHeight=1.8,this.add(this._textWrapper),this._textWrapper.add(this._text))}reset(){var A;(A=this._line.geometry)==null||A.dispose(),this._line.computeLineDistances()}update(A,e){var r;(r=this._line.geometry)==null||r.dispose(),this._line.geometry.setFromPoints([A,e]),this._line.computeLineDistances();const t=A.distanceTo(e);this._startWith?this._text.text=`${this._startWith}${(t*1e3).toFixed(0)} mm`:this._text.text=`${(t*1e3).toFixed(0)} mm`;const i=new O;i.addVectors(A,e).multiplyScalar(.5),this._textWrapper.position.copy(i),this._text.lookAt(e),this._text.rotateY(Math.PI/2),this._text.rotateX(-Math.PI/3),this._text.sync()}updateDirection(A){this._textWrapper.lookAt(A)}updateSize(A){var i;const e=(i=this.parent)==null?void 0:i.position.clone();e==null||e.setY(this.position.y);let t=(e==null?void 0:e.distanceTo(A))||1;t*=1.2,t<5&&(t=5),this._tw&&this._tw.isPlaying()&&this._tw.stop(),this._tw=new ws.Tween(this._text).to({fontSize:t/100}).duration(300).easing(ws.Easing.Quintic.InOut).start()}dispose(){this._tw.stop(),this._text.dispose(),er(this)}}class zS extends Se{constructor(A,e){super(),this.radius=A,this._text=new gj(""),this._line=new Uf(void 0,!1),this._box=new De,this._box.geometry=new Xh(A,A+.003,128),this._box.material=new Ki({color:"#898989",side:st}),this.position.y=e,this._box.rotateX(-Math.PI/2),this.add(this._box),this.add(this._line),this.add(this._text)}hide(){this._text.hide(),this._line.visible=!1}show(){this._text.show(),this._line.visible=!0}update(A){var e;this.radius=A,(e=this._box.geometry)==null||e.dispose(),this._box.geometry=new Xh(A,A+.003,128),this._text.update((A*1e3).toFixed(0))}change(A){const e=A.clone();e.setY(0),e.normalize().multiplyScalar(this.radius),this._text.position.set(e.x,e.y,e.z),this._line.update(e,new O)}}class gj extends zg{constructor(A){const e=document.createElement("div");super(e),this._wrapper=document.createElement("div"),this._wrapper.style.fontSize="10px",this._wrapper.style.color="#898989",this._wrapper.style.whiteSpace="nowrap",this._wrapper.style.position="absolute",this._wrapper.style.transform="translateX(-50%)",this._wrapper.style.bottom="4px";const t=document.createElement("div");t.style.position="relative",t.style.zIndex="10",t.style.width=t.style.height="5px",t.style.borderRadius="50%",t.style.background="#ff6666",e.append(this._wrapper,t),this.update(A)}show(){this.element.style.display="block"}hide(){this.element.style.display="none"}update(A){this._wrapper.innerText="旋转半径:"+A+" mm"}}const cv="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAAAXNSR0IArs4c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BkzAkEECCAIpDAIVCRAABWzZswIBBEggCCQwiBQkQABVMyaMSMQRIAAgkAKg0BFAgRQMWvGjEAQAQIIAikMAhUJEEDFrBkzAkEECCAIpDAIVCRAABWzZswIBBEggCCQwiBQkQABVMyaMSMQRIAAgkAKg0BFAgRQMWvGjEAQAQIIAikMAhUJEEDFrBkzAkEECCAIpDAIVCRAABWzZswIBBEggCCQwiBQkQABVMyaMSMQRIAAgkAKg0BFAgRQMWvGjEAQgf8DKv6MH/R9oFMAAAAASUVORK5CYII=";class RS extends zg{constructor(A,e){const t=document.createElement("div");super(t),this.props=A,this.amr=e,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._update=()=>{if(this._looper=requestAnimationFrame(this._update),this._controlling){let s=(Date.now()-this._startAt)/200;s>4&&(s=4);let o=this._initial+.005*s*this._direction;if(o>this.props.max||o<this.props.min||(this._initial=o,!this.mechanism))return;this.mechanism.position.setY(o)}},A.userData&&A.userData.target&&e.traverse(s=>{s.name===A.userData.target.name&&(this.mechanism=s)}),t.style.fontSize="30px",t.style.color="#0066FF",t.style.cursor="pointer",t.style.pointerEvents="auto";const i=document.createElement("div");i.innerText="↑",i.style.position="absolute",i.style.left="0",i.style.transform="translateX(-50%)",i.style.marginBottom="5px",i.setAttribute("data-direction","up");const r=document.createElement("div");if(r.style.position="absolute",r.style.left="0",r.style.transform="translateX(-50%)",r.innerText="↓",i.style.bottom=r.style.top="8px",r.setAttribute("data-direction","down"),Array.from([i,r]).forEach(s=>{s.addEventListener("mousemove",()=>{s.style.color="#00FF95"}),s.addEventListener("mouseleave",()=>{s.style.color="#0066FF"}),s.addEventListener("pointerdown",()=>{this.mechanism&&(this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.y,this._direction=s.getAttribute("data-direction")==="up"?1:-1)}),s.addEventListener("pointerup",()=>{this._controlling=!1}),s.addEventListener("pointerleave",()=>{this._controlling=!1})}),A.userData&&(this._canRotate=A.userData.canRotate,this._canRotate)){const{rotateTarget:s,rotateDuration:o,rotateStep:a,rotateMax:l,rotateMin:u}=A.userData;let c;if(s&&(e.traverse(h=>{h.name===s.name&&(c=h)}),c)){const h=document.createElement("div");h.style.background=`url(${cv}) center no-repeat`,h.style.backgroundSize="100% auto",h.style.width=h.style.height="35px",h.style.position="absolute",h.style.top="0",h.style.transform="translateY(-50%) scaleX(-100%) rotateZ(-30deg) rotateX(-40deg)",h.style.marginBottom="5px",h.setAttribute("data-direction","left"),t.append(h);const f=document.createElement("div");f.style.background=`url(${cv}) center no-repeat`,f.style.backgroundSize="100% auto",f.style.width=f.style.height="35px",f.style.position="absolute",h.style.right=f.style.left="10px",f.style.top="0",f.style.transform="translateY(-50%) rotateZ(-30deg) rotateX(-40deg)",f.style.marginBottom="5px",f.setAttribute("data-direction","right"),t.append(f),Array.from([h,f]).forEach(p=>{p.addEventListener("mousemove",()=>{p.style.backgroundImage=`url(${mj})`}),p.addEventListener("mouseleave",()=>{p.style.backgroundImage=`url(${cv})`}),p.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;this._controllingRotate=!0,this._startAt=Date.now(),this._direction=p.getAttribute("data-direction")==="left"?-1:1;let m=a/180*Math.PI*this._direction+c.rotation.y;m>l/180*Math.PI?m=l/180*Math.PI:m<u/180*Math.PI&&(m=u/180*Math.PI),this._timer=new bu(c.rotation).to({y:m}).duration(o).start()}),p.addEventListener("pointerup",()=>{this._controllingRotate=!1}),p.addEventListener("pointerleave",()=>{this._controllingRotate=!1})})}}t.append(i,r),this.scale.set(.01,.01,.01),this.matrixAutoUpdate=!1,this.updateMatrix(),this._update()}dispose(){cancelAnimationFrame(this._looper),this.element.remove()}}class vj extends a5{constructor(A){const e=document.createElement("div");super(e),this.props=A,this._scale=.01,this._emitter=new Cs,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new dA,this._targetSize=new dA,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=a=>{const{pageX:l,pageY:u}=a;this.endNode.setPointerCapture(a.pointerId),this._mouseStart.set(l,u),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=a=>{if(!this._mouseStart.x)return;const{pageX:l,pageY:u}=a;let c=l-this._mouseStart.x,h=c+this._targetSize.x;this._sizeFlag==="height"&&(c=u-this._mouseStart.y,h=c*this._direction+this._targetSize.y);const f=h%10;h=h-f,c=(h-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(c=(h-this._targetSize.y)*this._direction),this._textNode.innerText=(h/100).toFixed(2)+" m",this.endNode.parentElement.style[this._sizeFlag]=`${h}px`},this._pointercancel=a=>{this.endNode.releasePointerCapture(a.pointerId),this._mouseStart.set(0,0)};const{start:t,end:i}=A,r=i.distanceTo(t);this.props.axios==="z"?this.props.axios="y":this.props.axios==="y"&&(this.props.axios="z"),this.props.axios==="y"&&(this._sizeFlag="height");const s=document.createElement("div");s.style.position="absolute",s.style.left="0",s.style.bottom="0",e.append(s),this._textNode=document.createElement("div"),this._textNode.innerText=r.toFixed(2)+" m",s.append(this._textNode);const o=document.createElement("div");this.endNode=o,o.style.position="absolute",o.style.left="auto",o.style.right="0",o.style.width="4px",o.style.height="4px",o.style.background="#0066FF",o.style.borderRadius="50%",o.style.margin="-2px -2px 0 0",o.style.cursor="pointer",s.append(o),this.scale.set(this._scale,this._scale,this._scale),e.style.fontSize="6px",e.style.color="#fff",s.style[this._sizeFlag]=r*100+"px",s.style.textAlign="center",this._sizeFlag==="height"?(s.style.borderLeft="0.1px dashed #fff",s.style.display="flex",s.style.alignItems="center",s.style.justifyContent="center",s.style.whiteSpace="nowrap",o.style.top="0",o.style.left="0",o.style.right="auto",o.style.margin="-2px 0 0 -2px"):s.style.borderBottom="0.1px dashed #fff",o.addEventListener("pointerdown",this._pointerdown),o.addEventListener("pointermove",this._pointermove),o.addEventListener("pointerup",this._pointercancel),i[this.props.axios]<t[this.props.axios]?this.rotateY(Math.PI):this._direction=-1}_getIndexByAxios(){return this.props.axios==="y"?1:this.props.axios==="z"?2:0}dispose(){this._lines.forEach(A=>A.dispose()),this._emitter.removeAllListeners(),this.endNode.removeEventListener("pointerdown",this._pointerdown),this.endNode.removeEventListener("pointermove",this._pointermove),this.endNode.removeEventListener("pointerup",this._pointercancel),this.element.remove(),this._caches.forEach(A=>A.clear()),this._caches=[]}}const yj="*{box-sizing:border-box}.pointer-container{width:20px;height:20px;pointer-events:auto;cursor:pointer;display:flex;align-items:center;justify-content:center}.pointer-container.active .point{transform:scale(3);background:#06f}.pointer-container:hover .point{transform:scale(4);background:#00ff95}.pointer-container:hover .value{opacity:1;transform:translate3d(-50%,0,0)}.pointer-container .point{width:3px;height:3px;border-radius:50%;background:#898989;transition:all .2s}.pointer-container .value{white-space:nowrap;pointer-events:none;font-size:12px;opacity:0;position:absolute;bottom:80%;left:50%;color:#898989;transform:translate3d(-50%,-14px,0);transition:all .2s}";var wj=Object.defineProperty,Cj=Object.getOwnPropertyDescriptor,hv=(n,A,e,t)=>{for(var i=t>1?void 0:t?Cj(A,e):A,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(t?s(A,e,i):s(i))||i);return t&&i&&wj(A,e,i),i};class xj extends Se{constructor(){super(),this._box3=new ye,this._line11=new Uf("长:"),this._line12=new Uf("宽:"),this._line13=new Uf("高:"),this._outline=new zS(0,0),this._radius=0,this._hasWidthConfig=!1,this._hasLengthConfig=!1,this._hasHeightConfig=!1,this.follow="",this.followOrigin=0,this.followScale=1,this.originOffset=0,this.translateCache=0,this._changeSize=k9(A=>{this._line11.updateSize(A),this._line12.updateSize(A),this._line13.updateSize(A)},100),this._change=()=>{if(!this._app)return;const A=this._app.camera;A&&(this._outline.change(A.position),this._changeSize(A.position),this._line13.updateDirection(A.position))},this.add(this._outline,this._line11,this._line12,this._line13)}get hasSizeConfig(){return{length:this._hasLengthConfig,width:this._hasWidthConfig,height:this._hasHeightConfig}}get size(){return this._box3.clone()}get radius(){return this._radius}init(A){this._app=A,this._app.controls.addEventListener("change",this._change)}reset(){this.hide()}generate(A,e=0){A&&(this._object=A),this.update(e)}show(){this.visible=!0,this._outline.visible=!0,this._outline.show(),this.traverse(A=>A.visible=!0)}hide(){this.visible=!1,this._outline.visible=!1,this._outline.hide(),this.traverse(A=>A.visible=!1)}dispose(){var A;(A=this._app)==null||A.controls.removeEventListener("change",this._change),this._line11.dispose(),this._line12.dispose(),this._line13.dispose()}update(A=0){if(!this._object)return;const e=this._object,{box:t,maxRadius:i,hasLength:r,hasHeight:s,hasWidth:o}=Mb(e);this._hasWidthConfig=o,this._hasLengthConfig=r,this._hasHeightConfig=s,this._box3.copy(t),this._radius=i,this.follow&&A&&(this.originOffset=(this.followOrigin-A)*this.followScale),this._outline.update(this._radius),this._change();const a=this._box3.min.x,l=this._box3.max.x,u=this._box3.min.z,c=this._box3.max.z,h=this._box3.min.y,f=this._box3.max.y;let p=.3;const m=new O(a,0,u),d=new O(l,0,u);this._line11.update(m.clone().sub(new O(0,0,p/1.8)),d.clone().sub(new O(0,0,p/1.8)));const g=new O(l,0,c);this._line12.update(d.clone().add(new O(p,0,0)),g.clone().add(new O(p,0,0)));const y=new O(a,h,u),v=new O(a,f,u),w=y.clone();w.z-=p/3;const C=v.clone();C.z-=p/3,this._line13.update(w,C)}}let Ic=class extends Kr{constructor(n,A=!1){super(),this.text="",this.active=!1,this.text=(n*1e3).toFixed(0),this.active=A}render(){return Z0`
9812
9812
  <div class="pointer-container ${this.active&&"active"}">
9813
9813
  <div class="point"></div>
9814
9814
  <div class="value">${this.text} mm</div>
@@ -9832,13 +9832,13 @@ vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;
9832
9832
  color *= newPeak * invPeak;
9833
9833
  float g = 1. - 3. / (desaturation * extraBrightness + 3.);
9834
9834
  return mix(color, vec3(1, 1, 1), g);
9835
- }`),this.camera.position.set(10,6,-10),this.camera.lookAt(new O);const{tiles:e}=R9();this.pathTracer=new i5(this.renderer),this.pathTracer.filterGlossyFactor=.6,this.pathTracer.renderScale=window.devicePixelRatio,this.pathTracer.bounces=10,this.pathTracer.transmissiveBounces=8,this.pathTracer.tiles.set(e,e),this.pathTracer.fadeDuration=0,this.pathTracer.setBVHWorker(new DK),this.controls.addEventListener("change",()=>{var t;this.sampleCount=0,(t=this.pathTracer)==null||t.updateCamera()}),this._composer=new r5(this.renderer),this._composer.setPixelRatio(window.devicePixelRatio),this._composer.addPass(new aE(this.scene,this.camera)),this._composer.addPass(new fE),this._outlinePass=new Kn(new dA(window.innerWidth,window.innerHeight),this.scene,this.camera),this._outlinePass.visibleEdgeColor.set(26367),this._outlinePass.edgeThickness=.5,this._outlinePass.hiddenEdgeColor.set(26367),this._outlinePass.edgeStrength=3,this._outlinePass.edgeGlow=0,this._composer.addPass(this._outlinePass),this._outlinePassError=new Kn(new dA(window.innerWidth,window.innerHeight),this.scene,this.camera),this._outlinePassError.visibleEdgeColor.set(16711680),this._outlinePassError.edgeThickness=.5,this._outlinePassError.hiddenEdgeColor.set(16711680),this._outlinePassError.edgeStrength=3,this._outlinePassError.edgeGlow=0,this._composer.addPass(this._outlinePassError),this._composer.renderTarget1.texture.colorSpace=je,this._composer.renderTarget2.texture.colorSpace=je,this._fxaaPass=new U1(lE),this._composer.addPass(this._fxaaPass),this._container.add(this.amr),this.scene.add(this._container),this.ticker(),this._loadEnv(),this._initEvents(),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground)}get usePathTracing(){return this._usePathTracing}set usePathTracing(A){A?(this.amr&&(this.amr.bodyOpacity=1),this.amr.slots.forEach(e=>e.hide()),this.lines.hide(),this.css3dRenderer.domElement.style.display="none",this.amr.sizeBox.hide(),this.pathTracer.renderToCanvas=!0):(this.amr.sizeBox.show(),this.amr.slots.forEach(e=>e.show()),this.lines.show(),this.css3dRenderer.domElement.style.display="block",this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this.scene.background=null),this._usePathTracing=A,this.controls.dampingFactor=A?1:_3,this.sampleCount=0}get fpsAverage(){return bb(this._fpsCache)}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}_loadEnv(){new nE(new N1).load(Ck,e=>{e.mapping=Ao,e.minFilter=we,e.magFilter=we,e.colorSpace=je,e.needsUpdate=!0,this._usePathTracing||(this.scene.environment=e,this.scene.environmentRotation.y=Math.PI*.1,this.scene.environmentIntensity=1),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown)}async generateBVH(){this.amr.slots.forEach(A=>A.hide()),this.css3dRenderer.domElement.style.display="none",this.lines.hide(),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.camera)}download(){return this.renderer.domElement.toDataURL("image/png")}clearAMR(){this.amr.clean(),this.usePathTracing=!1,this.lines.clear()}async exportAMR(){const A=this._container.clone(!0);return A.traverse(e=>{e.dispose&&(e.dispose(),e.removeFromParent())}),await Yb.parseAsync(A,{onlyVisible:!0,binary:!0})}async addAMR(A){this.amr.init(this),await this.amr.load(A)}generateEdges(){this._container.traverse(A=>{if(A instanceof De){const e=A.geometry.clone(),t=UK.generate(e);let i=t.next();for(;!i.done;)i=t.next();const r=new jh(i.value,new Nh({color:3355443}));r.position.z=-1.4,this.add(r),e.dispose()}})}select(A){typeof A=="string"||(Array.isArray(A)?this._outlinePass.selectedObjects=[...A]:this._outlinePass.selectedObjects=[A])}appendTo(A){A.append(this.renderer.domElement),A.append(this.stats.dom),A.append(this.lines),A.append(this.css2dRenderer.domElement),A.append(this.css3dRenderer.domElement),this.stats.dom.style.bottom="0",this.stats.dom.style.top="auto",this.resize(),this._resizeObserver=new ResizeObserver(this.resize),this._resizeObserver.observe(A)}add(A){this._container.add(A)}updatePosition(){this.lines.forceUpdate()}destroy(){var e,t;this.amr.destroy(),ws.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(e=this._fitAnimation)==null||e.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const A=this.renderer.domElement.parentElement;A&&((t=this._resizeObserver)==null||t.unobserve(A)),this.controls.dispose(),this.renderer.dispose(),this._composer.dispose(),this.scene.traverse(i=>{var r;i instanceof De?(i.geometry.dispose(),Array.isArray(i.material)?i.material.forEach(s=>s.dispose()):i.material&&i.material.dispose()):i instanceof jf?i.dispose():(r=i.dispose)==null||r.call(i),i.removeFromParent()})}}var XK=Object.defineProperty,QK=(n,A,e)=>A in n?XK(n,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[A]=e,pA=(n,A,e)=>(QK(n,typeof A!="symbol"?A+"":A,e),e);class Ti{constructor(A){pA(this,"parent"),pA(this,"paused"),this.parent=A,this.paused=!1}destroy(){}down(A){return!1}move(A){return!1}up(A){return!1}wheel(A){return!1}update(A){}resize(){}reset(){}pause(){this.paused=!0}resume(){this.paused=!1}}var VK=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},M3={exports:{}};(function(n,A){(function(){var e,t;t=function(i){return n.exports=i},e={linear:function(i,r,s,o){return s*i/o+r},easeInQuad:function(i,r,s,o){return s*(i/=o)*i+r},easeOutQuad:function(i,r,s,o){return-s*(i/=o)*(i-2)+r},easeInOutQuad:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i+r:-s/2*(--i*(i-2)-1)+r},easeInCubic:function(i,r,s,o){return s*(i/=o)*i*i+r},easeOutCubic:function(i,r,s,o){return s*((i=i/o-1)*i*i+1)+r},easeInOutCubic:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i*i+r:s/2*((i-=2)*i*i+2)+r},easeInQuart:function(i,r,s,o){return s*(i/=o)*i*i*i+r},easeOutQuart:function(i,r,s,o){return-s*((i=i/o-1)*i*i*i-1)+r},easeInOutQuart:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i*i*i+r:-s/2*((i-=2)*i*i*i-2)+r},easeInQuint:function(i,r,s,o){return s*(i/=o)*i*i*i*i+r},easeOutQuint:function(i,r,s,o){return s*((i=i/o-1)*i*i*i*i+1)+r},easeInOutQuint:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i*i*i*i+r:s/2*((i-=2)*i*i*i*i+2)+r},easeInSine:function(i,r,s,o){return-s*Math.cos(i/o*(Math.PI/2))+s+r},easeOutSine:function(i,r,s,o){return s*Math.sin(i/o*(Math.PI/2))+r},easeInOutSine:function(i,r,s,o){return-s/2*(Math.cos(Math.PI*i/o)-1)+r},easeInExpo:function(i,r,s,o){return i===0?r:s*Math.pow(2,10*(i/o-1))+r},easeOutExpo:function(i,r,s,o){return i===o?r+s:s*(-Math.pow(2,-10*i/o)+1)+r},easeInOutExpo:function(i,r,s,o){return(i/=o/2)<1?s/2*Math.pow(2,10*(i-1))+r:s/2*(-Math.pow(2,-10*--i)+2)+r},easeInCirc:function(i,r,s,o){return-s*(Math.sqrt(1-(i/=o)*i)-1)+r},easeOutCirc:function(i,r,s,o){return s*Math.sqrt(1-(i=i/o-1)*i)+r},easeInOutCirc:function(i,r,s,o){return(i/=o/2)<1?-s/2*(Math.sqrt(1-i*i)-1)+r:s/2*(Math.sqrt(1-(i-=2)*i)+1)+r},easeInElastic:function(i,r,s,o){var a,l,u;return u=1.70158,l=0,a=s,i===0||(i/=o),l||(l=o*.3),a<Math.abs(s)?(a=s,u=l/4):u=l/(2*Math.PI)*Math.asin(s/a),-(a*Math.pow(2,10*(i-=1))*Math.sin((i*o-u)*(2*Math.PI)/l))+r},easeOutElastic:function(i,r,s,o){var a,l,u;return u=1.70158,l=0,a=s,i===0||(i/=o),l||(l=o*.3),a<Math.abs(s)?(a=s,u=l/4):u=l/(2*Math.PI)*Math.asin(s/a),a*Math.pow(2,-10*i)*Math.sin((i*o-u)*(2*Math.PI)/l)+s+r},easeInOutElastic:function(i,r,s,o){var a,l,u;return u=1.70158,l=0,a=s,i===0||(i/=o/2),l||(l=o*(.3*1.5)),a<Math.abs(s)?(a=s,u=l/4):u=l/(2*Math.PI)*Math.asin(s/a),i<1?-.5*(a*Math.pow(2,10*(i-=1))*Math.sin((i*o-u)*(2*Math.PI)/l))+r:a*Math.pow(2,-10*(i-=1))*Math.sin((i*o-u)*(2*Math.PI)/l)*.5+s+r},easeInBack:function(i,r,s,o,a){return a===void 0&&(a=1.70158),s*(i/=o)*i*((a+1)*i-a)+r},easeOutBack:function(i,r,s,o,a){return a===void 0&&(a=1.70158),s*((i=i/o-1)*i*((a+1)*i+a)+1)+r},easeInOutBack:function(i,r,s,o,a){return a===void 0&&(a=1.70158),(i/=o/2)<1?s/2*(i*i*(((a*=1.525)+1)*i-a))+r:s/2*((i-=2)*i*(((a*=1.525)+1)*i+a)+2)+r},easeInBounce:function(i,r,s,o){var a;return a=e.easeOutBounce(o-i,0,s,o),s-a+r},easeOutBounce:function(i,r,s,o){return(i/=o)<1/2.75?s*(7.5625*i*i)+r:i<2/2.75?s*(7.5625*(i-=1.5/2.75)*i+.75)+r:i<2.5/2.75?s*(7.5625*(i-=2.25/2.75)*i+.9375)+r:s*(7.5625*(i-=2.625/2.75)*i+.984375)+r},easeInOutBounce:function(i,r,s,o){var a;return i<o/2?(a=e.easeInBounce(i*2,0,s,o),a*.5+r):(a=e.easeOutBounce(i*2-o,0,s,o),a*.5+s*.5+r)}},t(e)}).call(VK)})(M3);const P3=M3.exports;function yd(n,A){if(n){if(typeof n=="function")return n;if(typeof n=="string")return P3[n]}else return P3[A]}const $K={removeOnInterrupt:!1,ease:"linear",time:1e3};class AF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"startX"),pA(this,"startY"),pA(this,"deltaX"),pA(this,"deltaY"),pA(this,"keepCenter"),pA(this,"startWidth",null),pA(this,"startHeight",null),pA(this,"deltaWidth",null),pA(this,"deltaHeight",null),pA(this,"width",null),pA(this,"height",null),pA(this,"time",0),this.options=Object.assign({},$K,e),this.options.ease=yd(this.options.ease),this.setupPosition(),this.setupZoom(),this.time=0}setupPosition(){typeof this.options.position<"u"?(this.startX=this.parent.center.x,this.startY=this.parent.center.y,this.deltaX=this.options.position.x-this.parent.center.x,this.deltaY=this.options.position.y-this.parent.center.y,this.keepCenter=!1):this.keepCenter=!0}setupZoom(){this.width=null,this.height=null,typeof this.options.scale<"u"?this.width=this.parent.screenWidth/this.options.scale:typeof this.options.scaleX<"u"||typeof this.options.scaleY<"u"?(typeof this.options.scaleX<"u"&&(this.width=this.parent.screenWidth/this.options.scaleX),typeof this.options.scaleY<"u"&&(this.height=this.parent.screenHeight/this.options.scaleY)):(typeof this.options.width<"u"&&(this.width=this.options.width),typeof this.options.height<"u"&&(this.height=this.options.height)),this.width!==null&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),this.height!==null&&(this.startHeight=this.parent.screenHeightInWorldPixels,this.deltaHeight=this.height-this.startHeight)}down(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("animate"),!1}complete(){this.parent.plugins.remove("animate"),this.width!==null&&this.parent.fitWidth(this.width,this.keepCenter,this.height===null),this.height!==null&&this.parent.fitHeight(this.height,this.keepCenter,this.width===null),!this.keepCenter&&this.options.position&&this.parent.moveCenter(this.options.position),this.parent.emit("animate-end",this.parent),this.options.callbackOnComplete&&this.options.callbackOnComplete(this.parent)}update(A){if(this.paused)return;this.time+=A;const e=new VA(this.parent.scale.x,this.parent.scale.y);if(this.time>=this.options.time){const t=this.parent.width,i=this.parent.height;this.complete(),(t!==this.parent.width||i!==this.parent.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}else{const t=this.options.ease(this.time,0,1,this.options.time);if(this.width!==null){const i=this.startWidth,r=this.deltaWidth;this.parent.fitWidth(i+r*t,this.keepCenter,this.height===null)}if(this.height!==null){const i=this.startHeight,r=this.deltaHeight;this.parent.fitHeight(i+r*t,this.keepCenter,this.width===null)}if(this.width===null?this.parent.scale.x=this.parent.scale.y:this.height===null&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const i=this.startX,r=this.startY,s=this.deltaX,o=this.deltaY,a=new VA(this.parent.x,this.parent.y);this.parent.moveCenter(i+s*t,r+o*t),this.parent.emit("moved",{viewport:this.parent,original:a,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}}}const eF={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class tF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"left"),pA(this,"top"),pA(this,"right"),pA(this,"bottom"),pA(this,"underflowX"),pA(this,"underflowY"),pA(this,"ease"),pA(this,"toX"),pA(this,"toY"),this.options=Object.assign({},eF,e),this.ease=yd(this.options.ease,"easeInOutSine"),this.options.sides?this.options.sides==="all"?this.top=this.bottom=this.left=this.right=!0:this.options.sides==="horizontal"?(this.right=this.left=!0,this.top=this.bottom=!1):this.options.sides==="vertical"?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=this.options.sides.indexOf("top")!==-1,this.bottom=this.options.sides.indexOf("bottom")!==-1,this.left=this.options.sides.indexOf("left")!==-1,this.right=this.options.sides.indexOf("right")!==-1):this.left=this.top=this.right=this.bottom=!1;const t=this.options.underflow.toLowerCase();t==="center"?(this.underflowX=0,this.underflowY=0):(this.underflowX=t.indexOf("left")!==-1?-1:t.indexOf("right")!==-1?1:0,this.underflowY=t.indexOf("top")!==-1?-1:t.indexOf("bottom")!==-1?1:0),this.reset()}isActive(){return this.toX!==null||this.toY!==null}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(A){if(!this.paused){if(this.bounce(),this.toX){const e=this.toX;e.time+=A,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),e.time>=this.options.time?(this.parent.x=e.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(e.time,e.start,e.delta,this.options.time)}if(this.toY){const e=this.toY;e.time+=A,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),e.time>=this.options.time?(this.parent.y=e.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(e.time,e.start,e.delta,this.options.time)}}}calcUnderflowX(){let A;switch(this.underflowX){case-1:A=0;break;case 1:A=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:A=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}return A}calcUnderflowY(){let A;switch(this.underflowY){case-1:A=0;break;case 1:A=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:A=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}return A}oob(){const A=this.options.bounceBox;if(A){const e=typeof A.x>"u"?0:A.x,t=typeof A.y>"u"?0:A.y,i=typeof A.width>"u"?this.parent.worldWidth:A.width,r=typeof A.height>"u"?this.parent.worldHeight:A.height;return{left:this.parent.left<e,right:this.parent.right>i,top:this.parent.top<t,bottom:this.parent.bottom>r,topLeft:new VA(e*this.parent.scale.x,t*this.parent.scale.y),bottomRight:new VA(i*this.parent.scale.x-this.parent.screenWidth,r*this.parent.scale.y-this.parent.screenHeight)}}return{left:this.parent.left<0,right:this.parent.right>this.parent.worldWidth,top:this.parent.top<0,bottom:this.parent.bottom>this.parent.worldHeight,topLeft:new VA(0,0),bottomRight:new VA(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){var A,e;if(this.paused)return;let t,i=this.parent.plugins.get("decelerate",!0);i&&(i.x||i.y)&&(i.x&&i.percentChangeX===((A=i.options)==null?void 0:A.friction)||i.y&&i.percentChangeY===((e=i.options)==null?void 0:e.friction))&&(t=this.oob(),(t.left&&this.left||t.right&&this.right)&&(i.percentChangeX=this.options.friction),(t.top&&this.top||t.bottom&&this.bottom)&&(i.percentChangeY=this.options.friction));const r=this.parent.plugins.get("drag",!0)||{},s=this.parent.plugins.get("pinch",!0)||{};if(i=i||{},!(r!=null&&r.active)&&!(s!=null&&s.active)&&(!this.toX||!this.toY)&&(!i.x||!i.y)){t=t||this.oob();const o=t.topLeft,a=t.bottomRight;if(!this.toX&&!i.x){let l=null;t.left&&this.left?l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-o.x:t.right&&this.right&&(l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-a.x),l!==null&&this.parent.x!==l&&(this.toX={time:0,start:this.parent.x,delta:l-this.parent.x,end:l},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!i.y){let l=null;t.top&&this.top?l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-o.y:t.bottom&&this.bottom&&(l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-a.y),l!==null&&this.parent.y!==l&&(this.toY={time:0,start:this.parent.y,delta:l-this.parent.y,end:l},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const iF={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class nF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"last"),pA(this,"noUnderflow"),pA(this,"underflowX"),pA(this,"underflowY"),this.options=Object.assign({},iF,e),this.options.direction&&(this.options.left=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.right=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.top=this.options.direction==="y"||this.options.direction==="all"?!0:null,this.options.bottom=this.options.direction==="y"||this.options.direction==="all"?!0:null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const A=this.options.underflow.toLowerCase();A==="none"?this.noUnderflow=!0:A==="center"?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=A.indexOf("left")!==-1?-1:A.indexOf("right")!==-1?1:0,this.underflowY=A.indexOf("top")!==-1?-1:A.indexOf("bottom")!==-1?1:0,this.noUnderflow=!1)}move(){return this.update(),!1}update(){if(this.paused||this.parent.x===this.last.x&&this.parent.y===this.last.y&&this.parent.scale.x===this.last.scaleX&&this.parent.scale.y===this.last.scaleY)return;const A=new VA(this.parent.x,this.parent.y),e=this.parent.plugins.decelerate||{};if(this.options.left!==null||this.options.right!==null){let t=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x!==0&&(this.parent.x=0,t=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,t=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,t=!0)}else this.options.left!==null&&this.parent.left<(this.options.left===!0?0:this.options.left)&&(this.parent.x=-(this.options.left===!0?0:this.options.left)*this.parent.scale.x,e.x=0,t=!0),this.options.right!==null&&this.parent.right>(this.options.right===!0?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(this.options.right===!0?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,e.x=0,t=!0);t&&this.parent.emit("moved",{viewport:this.parent,original:A,type:"clamp-x"})}if(this.options.top!==null||this.options.bottom!==null){let t=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y!==0&&(this.parent.y=0,t=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,t=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,t=!0)}else this.options.top!==null&&this.parent.top<(this.options.top===!0?0:this.options.top)&&(this.parent.y=-(this.options.top===!0?0:this.options.top)*this.parent.scale.y,e.y=0,t=!0),this.options.bottom!==null&&this.parent.bottom>(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,e.y=0,t=!0);t&&this.parent.emit("moved",{viewport:this.parent,original:A,type:"clamp-y"})}this.last.x=this.parent.x,this.last.y=this.parent.y,this.last.scaleX=this.parent.scale.x,this.last.scaleY=this.parent.scale.y}reset(){this.update()}}const rF={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class sF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),this.options=Object.assign({},rF,e),this.clamp()}resize(){this.clamp()}clamp(){if(!this.paused){if(this.options.minWidth||this.options.minHeight||this.options.maxWidth||this.options.maxHeight){let A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight;if(this.options.minWidth!==null&&A<this.options.minWidth){const t=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/t,A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxWidth!==null&&A>this.options.maxWidth){const t=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/t,A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.minHeight!==null&&e<this.options.minHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxHeight!==null&&e>this.options.maxHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else if(this.options.minScale||this.options.maxScale){const A={x:null,y:null},e={x:null,y:null};if(typeof this.options.minScale=="number")A.x=this.options.minScale,A.y=this.options.minScale;else if(this.options.minScale!==null){const r=this.options.minScale;A.x=typeof r.x>"u"?null:r.x,A.y=typeof r.y>"u"?null:r.y}if(typeof this.options.maxScale=="number")e.x=this.options.maxScale,e.y=this.options.maxScale;else if(this.options.maxScale!==null){const r=this.options.maxScale;e.x=typeof r.x>"u"?null:r.x,e.y=typeof r.y>"u"?null:r.y}let t=this.parent.scale.x,i=this.parent.scale.y;A.x!==null&&t<A.x&&(t=A.x),e.x!==null&&t>e.x&&(t=e.x),A.y!==null&&i<A.y&&(i=A.y),e.y!==null&&i>e.y&&(i=e.y),(t!==this.parent.scale.x||i!==this.parent.scale.y)&&(this.parent.scale.set(t,i),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}}reset(){this.clamp()}}const oF={friction:.98,bounce:.8,minSpeed:.01},Vr=16;class aF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"x"),pA(this,"y"),pA(this,"percentChangeX"),pA(this,"percentChangeY"),pA(this,"saved"),pA(this,"timeSinceRelease"),this.options=Object.assign({},oF,e),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",t=>this.handleMoved(t))}down(){return this.saved=[],this.x=this.y=null,!1}isActive(){return!!(this.x||this.y)}move(){if(this.paused)return!1;const A=this.parent.input.count();return(A===1||A>1&&!this.parent.plugins.get("pinch",!0))&&(this.saved.push({x:this.parent.x,y:this.parent.y,time:performance.now()}),this.saved.length>60&&this.saved.splice(0,30)),!1}handleMoved(A){if(this.saved.length){const e=this.saved[this.saved.length-1];A.type==="clamp-x"&&A.original?e.x===A.original.x&&(e.x=this.parent.x):A.type==="clamp-y"&&A.original&&e.y===A.original.y&&(e.y=this.parent.y)}}up(){if(this.parent.input.count()===0&&this.saved.length){const A=performance.now();for(const e of this.saved)if(e.time>=A-100){const t=A-e.time;this.x=(this.parent.x-e.x)/t,this.y=(this.parent.y-e.y)/t,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(A){A=A||{},typeof A.x<"u"&&(this.x=A.x,this.percentChangeX=this.options.friction),typeof A.y<"u"&&(this.y=A.y,this.percentChangeY=this.options.friction)}update(A){if(this.paused)return;const e=this.x||this.y,t=this.timeSinceRelease,i=this.timeSinceRelease+A;if(this.x){const r=this.percentChangeX,s=Math.log(r);this.parent.x+=this.x*Vr/s*(Math.pow(r,i/Vr)-Math.pow(r,t/Vr)),this.x*=Math.pow(this.percentChangeX,A/Vr)}if(this.y){const r=this.percentChangeY,s=Math.log(r);this.parent.y+=this.y*Vr/s*(Math.pow(r,i/Vr)-Math.pow(r,t/Vr)),this.y*=Math.pow(this.percentChangeY,A/Vr)}this.timeSinceRelease+=A,this.x&&this.y?Math.abs(this.x)<this.options.minSpeed&&Math.abs(this.y)<this.options.minSpeed&&(this.x=0,this.y=0):(Math.abs(this.x||0)<this.options.minSpeed&&(this.x=0),Math.abs(this.y||0)<this.options.minSpeed&&(this.y=0)),e&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}}const lF={direction:"all",pressDrag:!0,wheel:!0,wheelScroll:1,reverse:!1,clampWheel:!1,underflow:"center",factor:1,mouseButtons:"all",keyToPress:null,ignoreKeyToPressOnTouch:!1,lineHeight:20,wheelSwapAxes:!1};class cF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"moved"),pA(this,"reverse"),pA(this,"xDirection"),pA(this,"yDirection"),pA(this,"keyIsPressed"),pA(this,"mouse"),pA(this,"underflowX"),pA(this,"underflowY"),pA(this,"last"),pA(this,"current"),pA(this,"windowEventHandlers",[]),this.options=Object.assign({},lF,e),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="x",this.yDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="y",this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(A){const e=i=>{A.includes(i.code)&&(this.keyIsPressed=!0)},t=i=>{A.includes(i.code)&&(this.keyIsPressed=!1)};this.addWindowEventHandler("keyup",t),this.addWindowEventHandler("keydown",e)}addWindowEventHandler(A,e){window.addEventListener(A,e),this.windowEventHandlers.push({event:A,handler:e})}destroy(){this.windowEventHandlers.forEach(({event:A,handler:e})=>{window.removeEventListener(A,e)})}mouseButtons(A){!A||A==="all"?this.mouse=[!0,!0,!0]:this.mouse=[A.indexOf("left")!==-1,A.indexOf("middle")!==-1,A.indexOf("right")!==-1]}parseUnderflow(){const A=this.options.underflow.toLowerCase();A==="center"?(this.underflowX=0,this.underflowY=0):(A.includes("left")?this.underflowX=-1:A.includes("right")?this.underflowX=1:this.underflowX=0,A.includes("top")?this.underflowY=-1:A.includes("bottom")?this.underflowY=1:this.underflowY=0)}checkButtons(A){const e=A.pointerType==="mouse",t=this.parent.input.count();return!!((t===1||t>1&&!this.parent.plugins.get("pinch",!0))&&(!e||this.mouse[A.button]))}checkKeyPress(A){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&A.data.pointerType==="touch"}down(A){return this.paused||!this.options.pressDrag?!1:this.checkButtons(A)&&this.checkKeyPress(A)?(this.last={x:A.global.x,y:A.global.y},this.current=A.pointerId,!0):(this.last=null,!1)}get active(){return this.moved}move(A){if(this.paused||!this.options.pressDrag)return!1;if(this.last&&this.current===A.data.pointerId){const e=A.global.x,t=A.global.y,i=this.parent.input.count();if(i===1||i>1&&!this.parent.plugins.get("pinch",!0)){const r=e-this.last.x,s=t-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(r)||this.yDirection&&this.parent.input.checkThreshold(s)){const o={x:e,y:t};return this.xDirection&&(this.parent.x+=(o.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(o.y-this.last.y)*this.options.factor),this.last=o,this.moved||this.parent.emit("drag-start",{event:A,screen:new VA(this.last.x,this.last.y),world:this.parent.toWorld(new VA(this.last.x,this.last.y)),viewport:this.parent}),this.moved=!0,this.parent.emit("moved",{viewport:this.parent,type:"drag"}),!0}}else this.moved=!1}return!1}up(A){if(this.paused)return!1;const e=this.parent.input.touches;if(e.length===1){const t=e[0];return t.last&&(this.last={x:t.last.x,y:t.last.y},this.current=t.id),this.moved=!1,!0}else if(this.last&&this.moved){const t=new VA(this.last.x,this.last.y);return this.parent.emit("drag-end",{event:A,screen:t,world:this.parent.toWorld(t),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(A){if(this.paused)return!1;if(this.options.wheel){const e=this.parent.plugins.get("wheel",!0);if(!e||!e.options.wheelZoom&&!A.ctrlKey){const t=A.deltaMode?this.options.lineHeight:1,i=[A.deltaX,A.deltaY],[r,s]=this.options.wheelSwapAxes?i.reverse():i;return this.xDirection&&(this.parent.x+=r*t*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=s*t*this.options.wheelScroll*this.reverse),this.options.clampWheel&&this.clamp(),this.parent.emit("wheel-scroll",this.parent),this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.options.passiveWheel||A.preventDefault(),this.parent.options.stopPropagation&&A.stopPropagation(),!0}}return!1}resume(){this.last=null,this.paused=!1}clamp(){const A=this.parent.plugins.get("decelerate",!0)||{};if(this.options.clampWheel!=="y")if(this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x=0;break;case 1:this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}else this.parent.left<0?(this.parent.x=0,A.x=0):this.parent.right>this.parent.worldWidth&&(this.parent.x=-this.parent.worldWidth*this.parent.scale.x+this.parent.screenWidth,A.x=0);if(this.options.clampWheel!=="x")if(this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y=0;break;case 1:this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}else this.parent.top<0&&(this.parent.y=0,A.y=0),this.parent.bottom>this.parent.worldHeight&&(this.parent.y=-this.parent.worldHeight*this.parent.scale.y+this.parent.screenHeight,A.y=0)}}const hF={speed:0,acceleration:null,radius:null};class uF extends Ti{constructor(A,e,t={}){super(A),pA(this,"options"),pA(this,"target"),pA(this,"velocity"),this.target=e,this.options=Object.assign({},hF,t),this.velocity={x:0,y:0}}update(A){if(this.paused)return;const e=this.parent.center;let t=this.target.x,i=this.target.y;if(this.options.radius)if(Math.sqrt(Math.pow(this.target.y-e.y,2)+Math.pow(this.target.x-e.x,2))>this.options.radius){const o=Math.atan2(this.target.y-e.y,this.target.x-e.x);t=this.target.x-Math.cos(o)*this.options.radius,i=this.target.y-Math.sin(o)*this.options.radius}else return;const r=t-e.x,s=i-e.y;if(r||s)if(this.options.speed)if(this.options.acceleration){const o=Math.atan2(i-e.y,t-e.x),a=Math.sqrt(Math.pow(r,2)+Math.pow(s,2));if(a){const l=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);a>l?this.velocity={x:Math.min(this.velocity.x+(this.options.acceleration*A,this.options.speed)),y:Math.min(this.velocity.y+(this.options.acceleration*A,this.options.speed))}:this.velocity={x:Math.max(this.velocity.x-this.options.acceleration*this.options.speed,0),y:Math.max(this.velocity.y-this.options.acceleration*this.options.speed,0)};const u=Math.cos(o)*this.velocity.x,c=Math.sin(o)*this.velocity.y,h=Math.abs(u)>Math.abs(r)?t:e.x+u,f=Math.abs(c)>Math.abs(s)?i:e.y+c;this.parent.moveCenter(h,f),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const o=Math.atan2(i-e.y,t-e.x),a=Math.cos(o)*this.options.speed,l=Math.sin(o)*this.options.speed,u=Math.abs(a)>Math.abs(r)?t:e.x+a,c=Math.abs(l)>Math.abs(s)?i:e.y+l;this.parent.moveCenter(u,c),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(t,i),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const fF={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};class dF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"reverse"),pA(this,"radiusSquared"),pA(this,"left"),pA(this,"top"),pA(this,"right"),pA(this,"bottom"),pA(this,"horizontal"),pA(this,"vertical"),this.options=Object.assign({},fF,e),this.reverse=this.options.reverse?1:-1,this.radiusSquared=typeof this.options.radius=="number"?Math.pow(this.options.radius,2):null,this.resize()}resize(){const A=this.options.distance;A!==null?(this.left=A,this.top=A,this.right=this.parent.screenWidth-A,this.bottom=this.parent.screenHeight-A):this.options.radius||(this.left=this.options.left,this.top=this.options.top,this.right=this.options.right===null?null:this.parent.screenWidth-this.options.right,this.bottom=this.options.bottom===null?null:this.parent.screenHeight-this.options.bottom)}down(){return this.paused||this.options.allowButtons||(this.horizontal=this.vertical=null),!1}move(A){if(this.paused||A.pointerType!=="mouse"&&A.pointerId!==1||!this.options.allowButtons&&A.buttons!==0)return!1;const e=A.global.x,t=A.global.y;if(this.radiusSquared){const i=this.parent.toScreen(this.parent.center);if(Math.pow(i.x-e,2)+Math.pow(i.y-t,2)>=this.radiusSquared){const r=Math.atan2(i.y-t,i.x-e);this.options.linear?(this.horizontal=Math.round(Math.cos(r))*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.round(Math.sin(r))*this.options.speed*this.reverse*(60/1e3)):(this.horizontal=Math.cos(r)*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.sin(r)*this.options.speed*this.reverse*(60/1e3))}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else this.left!==null&&e<this.left?this.horizontal=Number(this.reverse)*this.options.speed*(60/1e3):this.right!==null&&e>this.right?this.horizontal=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateHorizontal(),this.horizontal=0),this.top!==null&&t<this.top?this.vertical=Number(this.reverse)*this.options.speed*(60/1e3):this.bottom!==null&&t>this.bottom?this.vertical=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateVertical(),this.vertical=0);return!1}decelerateHorizontal(){const A=this.parent.plugins.get("decelerate",!0);this.horizontal&&A&&!this.options.noDecelerate&&A.activate({x:this.horizontal*this.options.speed*this.reverse/(1e3/60)})}decelerateVertical(){const A=this.parent.plugins.get("decelerate",!0);this.vertical&&A&&!this.options.noDecelerate&&A.activate({y:this.vertical*this.options.speed*this.reverse/(1e3/60)})}up(){return this.paused||(this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=null),!1}update(){if(!this.paused&&(this.horizontal||this.vertical)){const A=this.parent.center;this.horizontal&&(A.x+=this.horizontal*this.options.speed),this.vertical&&(A.y+=this.vertical*this.options.speed),this.parent.moveCenter(A),this.parent.emit("moved",{viewport:this.parent,type:"mouse-edges"})}}}const pF={noDrag:!1,percent:1,center:null,factor:1,axis:"all"};class gF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"active",!1),pA(this,"pinching",!1),pA(this,"moved",!1),pA(this,"lastCenter"),this.options=Object.assign({},pF,e)}down(){return this.parent.input.count()>=2?(this.active=!0,!0):!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}move(A){if(this.paused||!this.active)return!1;const e=A.global.x,t=A.global.y,i=this.parent.input.touches;if(i.length>=2){const r=i[0],s=i[1],o=r.last&&s.last?Math.sqrt(Math.pow(s.last.x-r.last.x,2)+Math.pow(s.last.y-r.last.y,2)):null;if(r.id===A.pointerId?r.last={x:e,y:t,data:A}:s.id===A.pointerId&&(s.last={x:e,y:t,data:A}),o){let a;const l=new VA(r.last.x+(s.last.x-r.last.x)/2,r.last.y+(s.last.y-r.last.y)/2);this.options.center||(a=this.parent.toLocal(l));let u=Math.sqrt(Math.pow(s.last.x-r.last.x,2)+Math.pow(s.last.y-r.last.y,2));u=u===0?u=1e-10:u;const c=(1-o/u)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=c),this.isAxisY()&&(this.parent.scale.y+=c),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:l});const h=this.parent.plugins.get("clamp-zoom",!0);if(h&&h.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const f=this.parent.toGlobal(a);this.parent.x+=(l.x-f.x)*this.options.factor,this.parent.y+=(l.y-f.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(l.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(l.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=l,this.moved=!0}else this.pinching||(this.parent.emit("pinch-start",this.parent),this.pinching=!0);return!0}return!1}up(){return this.pinching&&this.parent.input.touches.length<=1?(this.active=!1,this.lastCenter=null,this.pinching=!1,this.moved=!1,this.parent.emit("pinch-end",this.parent),!0):!1}}const mF={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class vF extends Ti{constructor(A,e,t,i={}){super(A),pA(this,"options"),pA(this,"ease"),pA(this,"x"),pA(this,"y"),pA(this,"percent"),pA(this,"snapping"),pA(this,"deltaX"),pA(this,"deltaY"),pA(this,"startX"),pA(this,"startY"),this.options=Object.assign({},mF,i),this.ease=yd(i.ease,"easeInOutSine"),this.x=e,this.y=t,this.options.forceStart&&this.snapStart()}snapStart(){this.percent=0,this.snapping={time:0};const A=this.options.topLeft?this.parent.corner:this.parent.center;this.deltaX=this.x-A.x,this.deltaY=this.y-A.y,this.startX=A.x,this.startY=A.y,this.parent.emit("snap-start",this.parent)}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap"):this.options.interrupt&&(this.snapping=null),!1}up(){if(this.parent.input.count()===0){const A=this.parent.plugins.get("decelerate",!0);A&&(A.x||A.y)&&(A.percentChangeX=A.percentChangeY=this.options.friction)}return!1}update(A){if(!this.paused&&!(this.options.interrupt&&this.parent.input.count()!==0))if(this.snapping){const e=this.snapping;e.time+=A;let t,i,r;const s=this.startX,o=this.startY,a=this.deltaX,l=this.deltaY;if(e.time>this.options.time)t=!0,i=s+a,r=o+l;else{const u=this.ease(e.time,0,1,this.options.time);i=s+a*u,r=o+l*u}this.options.topLeft?this.parent.moveCorner(i,r):this.parent.moveCenter(i,r),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),t&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const e=this.options.topLeft?this.parent.corner:this.parent.center;(e.x!==this.x||e.y!==this.y)&&this.snapStart()}}}const yF={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class wF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"ease"),pA(this,"xScale"),pA(this,"yScale"),pA(this,"xIndependent"),pA(this,"yIndependent"),pA(this,"snapping"),this.options=Object.assign({},yF,e),this.ease=yd(this.options.ease),this.xIndependent=!1,this.yIndependent=!1,this.xScale=0,this.yScale=0,this.options.width>0&&(this.xScale=A.screenWidth/this.options.width,this.xIndependent=!0),this.options.height>0&&(this.yScale=A.screenHeight/this.options.height,this.yIndependent=!0),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale,this.options.time===0?(A.container.scale.x=this.xScale,A.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):e.forceStart&&this.createSnapping()}createSnapping(){const A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,t=this.parent.screenWidth/this.xScale,i=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:A,startY:e,deltaX:t-A,deltaY:i-e},this.parent.emit("snap-zoom-start",this.parent)}resize(){this.snapping=null,this.options.width>0&&(this.xScale=this.parent.screenWidth/this.options.width),this.options.height>0&&(this.yScale=this.parent.screenHeight/this.options.height),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap-zoom"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap-zoom"):this.options.interrupt&&(this.snapping=null),!1}update(A){if(this.paused||this.options.interrupt&&this.parent.input.count()!==0)return;let e;if(!this.options.center&&!this.options.noMove&&(e=this.parent.center),!this.snapping)(this.parent.scale.x!==this.xScale||this.parent.scale.y!==this.yScale)&&this.createSnapping();else if(this.snapping){const t=this.snapping;if(t.time+=A,t.time>=this.options.time)this.parent.scale.set(this.xScale,this.yScale),this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom"),this.parent.emit("snap-zoom-end",this.parent),this.snapping=null;else{const r=this.snapping,s=this.ease(r.time,r.startX,r.deltaX,this.options.time),o=this.ease(r.time,r.startY,r.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/s,this.parent.scale.y=this.parent.screenHeight/o}const i=this.parent.plugins.get("clamp-zoom",!0);i&&i.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(e))}}resume(){this.snapping=null,super.resume()}}const CF={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all",keyToPress:null,trackpadPinch:!1,wheelZoom:!0};class xF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"smoothing"),pA(this,"smoothingCenter"),pA(this,"smoothingCount"),pA(this,"keyIsPressed"),this.options=Object.assign({},CF,e),this.keyIsPressed=!1,this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(A){window.addEventListener("keydown",e=>{A.includes(e.code)&&(this.keyIsPressed=!0)}),window.addEventListener("keyup",e=>{A.includes(e.code)&&(this.keyIsPressed=!1)})}checkKeyPress(){return!this.options.keyToPress||this.keyIsPressed}down(){return this.options.interrupt&&(this.smoothing=null),!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}update(){if(this.smoothing){const A=this.smoothingCenter,e=this.smoothing;let t;this.options.center||(t=this.parent.toLocal(A)),this.isAxisX()&&(this.parent.scale.x+=e.x),this.isAxisY()&&(this.parent.scale.y+=e.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const i=this.parent.plugins.get("clamp-zoom",!0);if(i&&i.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const r=this.parent.toGlobal(t);this.parent.x+=A.x-r.x,this.parent.y+=A.y-r.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.smoothingCount++,this.smoothingCount>=this.options.smooth&&(this.smoothing=null)}}pinch(A){if(this.paused)return;const e=this.parent.input.getPointerPosition(A),t=-A.deltaY*(A.deltaMode?this.options.lineHeight:1)/200,i=Math.pow(2,(1+this.options.percent)*t);let r;this.options.center||(r=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=i),this.isAxisY()&&(this.parent.scale.y*=i),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom",!0);if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const o=this.parent.toGlobal(r);this.parent.x+=e.x-o.x,this.parent.y+=e.y-o.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:A,viewport:this.parent})}wheel(A){if(this.paused||!this.checkKeyPress())return!1;if(A.ctrlKey&&this.options.trackpadPinch)this.pinch(A);else if(this.options.wheelZoom){const e=this.parent.input.getPointerPosition(A),t=(this.options.reverse?-1:1)*-A.deltaY*(A.deltaMode?this.options.lineHeight:1)/500,i=Math.pow(2,(1+this.options.percent)*t);if(this.options.smooth){const r={x:this.smoothing?this.smoothing.x*(this.options.smooth-this.smoothingCount):0,y:this.smoothing?this.smoothing.y*(this.options.smooth-this.smoothingCount):0};this.smoothing={x:((this.parent.scale.x+r.x)*i-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+r.y)*i-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=e}else{let r;this.options.center||(r=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=i),this.isAxisY()&&(this.parent.scale.y*=i),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom",!0);if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const o=this.parent.toGlobal(r);this.parent.x+=e.x-o.x,this.parent.y+=e.y-o.y}}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:A,viewport:this.parent})}return!this.parent.options.passiveWheel}}class IF{constructor(A){pA(this,"viewport"),pA(this,"clickedAvailable"),pA(this,"isMouseDown"),pA(this,"last"),pA(this,"wheelFunction"),pA(this,"touches"),this.viewport=A,this.touches=[],this.addListeners()}addListeners(){this.viewport.eventMode="static",this.viewport.forceHitArea||(this.viewport.hitArea=new ee(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.options.allowPreserveDragOutside?this.viewport.on("globalpointermove",this.move,this):this.viewport.on("pointermove",this.move,this),this.viewport.on("pointerup",this.up,this),this.viewport.on("pointerupoutside",this.up,this),this.viewport.on("pointercancel",this.up,this),this.viewport.options.allowPreserveDragOutside||this.viewport.on("pointerleave",this.up,this),this.wheelFunction=A=>this.handleWheel(A),this.viewport.options.events.domElement.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.events.domElement.removeEventListener("wheel",this.wheelFunction)}down(A){if(!(this.viewport.pause||!this.viewport.worldVisible)){if(A.pointerType==="mouse"?this.isMouseDown=!0:this.get(A.pointerId)||this.touches.push({id:A.pointerId,last:null}),this.count()===1){this.last=A.global.clone();const e=this.viewport.plugins.get("decelerate",!0),t=this.viewport.plugins.get("bounce",!0);(!e||!e.isActive())&&(!t||!t.isActive())?this.clickedAvailable=!0:this.clickedAvailable=!1}else this.clickedAvailable=!1;this.viewport.plugins.down(A)&&this.viewport.options.stopPropagation&&A.stopPropagation()}}clear(){this.isMouseDown=!1,this.touches=[],this.last=null}checkThreshold(A){return Math.abs(A)>=this.viewport.threshold}move(A){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.plugins.move(A);if(this.clickedAvailable&&this.last){const t=A.global.x-this.last.x,i=A.global.y-this.last.y;(this.checkThreshold(t)||this.checkThreshold(i))&&(this.clickedAvailable=!1)}e&&this.viewport.options.stopPropagation&&A.stopPropagation()}up(A){if(this.viewport.pause||!this.viewport.worldVisible)return;A.pointerType==="mouse"&&(this.isMouseDown=!1),A.pointerType!=="mouse"&&this.remove(A.pointerId);const e=this.viewport.plugins.up(A);this.clickedAvailable&&this.count()===0&&this.last&&(this.viewport.emit("clicked",{event:A,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this.viewport}),this.clickedAvailable=!1),e&&this.viewport.options.stopPropagation&&A.stopPropagation()}getPointerPosition(A){const e=new VA;return this.viewport.options.events.mapPositionToPoint(e,A.clientX,A.clientY),e}handleWheel(A){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.toLocal(this.getPointerPosition(A));this.viewport.left<=e.x&&e.x<=this.viewport.right&&this.viewport.top<=e.y&&e.y<=this.viewport.bottom&&this.viewport.plugins.wheel(A)&&!this.viewport.options.passiveWheel&&A.preventDefault()}pause(){this.touches=[],this.isMouseDown=!1}get(A){for(const e of this.touches)if(e.id===A)return e;return null}remove(A){for(let e=0;e<this.touches.length;e++)if(this.touches[e].id===A){this.touches.splice(e,1);return}}count(){return(this.isMouseDown?1:0)+this.touches.length}}const qc=["drag","pinch","wheel","follow","mouse-edges","decelerate","animate","bounce","snap-zoom","clamp-zoom","snap","clamp"];class bF{constructor(A){pA(this,"plugins"),pA(this,"list"),pA(this,"viewport"),this.viewport=A,this.list=[],this.plugins={}}add(A,e,t=qc.length){const i=this.plugins[A];i&&i.destroy(),this.plugins[A]=e;const r=qc.indexOf(A);r!==-1&&qc.splice(r,1),qc.splice(t,0,A),this.sort()}get(A,e){var t;return e&&(t=this.plugins[A])!=null&&t.paused?null:this.plugins[A]}update(A){for(const e of this.list)e.update(A)}resize(){for(const A of this.list)A.resize()}reset(){for(const A of this.list)A.reset()}removeAll(){this.list.forEach(A=>{A.destroy()}),this.plugins={},this.sort()}remove(A){var e;this.plugins[A]&&((e=this.plugins[A])==null||e.destroy(),delete this.plugins[A],this.viewport.emit("plugin-remove",A),this.sort())}pause(A){var e;(e=this.plugins[A])==null||e.pause()}resume(A){var e;(e=this.plugins[A])==null||e.resume()}sort(){this.list=[];for(const A of qc)this.plugins[A]&&this.list.push(this.plugins[A])}down(A){let e=!1;for(const t of this.list)t.down(A)&&(e=!0);return e}move(A){let e=!1;for(const t of this.viewport.plugins.list)t.move(A)&&(e=!0);return e}up(A){let e=!1;for(const t of this.list)t.up(A)&&(e=!0);return e}wheel(A){let e=!1;for(const t of this.list)t.wheel(A)&&(e=!0);return e}}const SF={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,disableOnContextMenu:!1,ticker:Zt.shared,allowPreserveDragOutside:!1};class _F extends wi{constructor(A){super(),pA(this,"moving"),pA(this,"screenWidth"),pA(this,"screenHeight"),pA(this,"threshold"),pA(this,"input"),pA(this,"plugins"),pA(this,"zooming"),pA(this,"lastViewport"),pA(this,"options"),pA(this,"_dirty"),pA(this,"_forceHitArea"),pA(this,"_hitAreaDefault"),pA(this,"_pause"),pA(this,"tickerFunction"),pA(this,"_worldWidth"),pA(this,"_worldHeight"),pA(this,"_disableOnContextMenu",e=>e.preventDefault()),this.options={...SF,...A},this.screenWidth=this.options.screenWidth,this.screenHeight=this.options.screenHeight,this._worldWidth=this.options.worldWidth,this._worldHeight=this.options.worldHeight,this.forceHitArea=this.options.forceHitArea,this.threshold=this.options.threshold,this.options.disableOnContextMenu&&this.options.events.domElement.addEventListener("contextmenu",this._disableOnContextMenu),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new IF(this),this.plugins=new bF(this)}destroy(A){!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.options.disableOnContextMenu&&this.options.events.domElement.removeEventListener("contextmenu",this._disableOnContextMenu),this.input.destroy(),super.destroy(A)}update(A){this.pause||(this.plugins.update(A),this.lastViewport&&(this.lastViewport.x!==this.x||this.lastViewport.y!==this.y?this.moving=!0:this.moving&&(this.emit("moved-end",this),this.moving=!1),this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y?this.zooming=!0:this.zooming&&(this.emit("zoomed-end",this),this.zooming=!1)),this.forceHitArea||(this._hitAreaDefault=new ee(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight),this.hitArea=this._hitAreaDefault),this._dirty=this._dirty||!this.lastViewport||this.lastViewport.x!==this.x||this.lastViewport.y!==this.y||this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y,this.lastViewport={x:this.x,y:this.y,scaleX:this.scale.x,scaleY:this.scale.y},this.emit("frame-end",this))}resize(A=window.innerWidth,e=window.innerHeight,t,i){this.screenWidth=A,this.screenHeight=e,typeof t<"u"&&(this._worldWidth=t),typeof i<"u"&&(this._worldHeight=i),this.plugins.resize(),this.dirty=!0}get worldWidth(){return this._worldWidth?this._worldWidth:this.width/this.scale.x}set worldWidth(A){this._worldWidth=A,this.plugins.resize()}get worldHeight(){return this._worldHeight?this._worldHeight:this.height/this.scale.y}set worldHeight(A){this._worldHeight=A,this.plugins.resize()}getVisibleBounds(){return new ee(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(A,e){return arguments.length===2?this.toLocal(new VA(A,e)):this.toLocal(A)}toScreen(A,e){return arguments.length===2?this.toGlobal(new VA(A,e)):this.toGlobal(A)}get worldScreenWidth(){return this.screenWidth/this.scale.x}get worldScreenHeight(){return this.screenHeight/this.scale.y}get screenWorldWidth(){return this.worldWidth*this.scale.x}get screenWorldHeight(){return this.worldHeight*this.scale.y}get center(){return new VA(this.worldScreenWidth/2-this.x/this.scale.x,this.worldScreenHeight/2-this.y/this.scale.y)}set center(A){this.moveCenter(A)}moveCenter(...A){let e,t;typeof A[0]=="number"?(e=A[0],t=A[1]):(e=A[0].x,t=A[0].y);const i=(this.worldScreenWidth/2-e)*this.scale.x,r=(this.worldScreenHeight/2-t)*this.scale.y;return(this.x!==i||this.y!==r)&&(this.position.set(i,r),this.plugins.reset(),this.dirty=!0),this}get corner(){return new VA(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(A){this.moveCorner(A)}moveCorner(...A){let e,t;return A.length===1?(e=-A[0].x*this.scale.x,t=-A[0].y*this.scale.y):(e=-A[0]*this.scale.x,t=-A[1]*this.scale.y),(e!==this.x||t!==this.y)&&(this.position.set(e,t),this.plugins.reset(),this.dirty=!0),this}get screenWidthInWorldPixels(){return this.screenWidth/this.scale.x}get screenHeightInWorldPixels(){return this.screenHeight/this.scale.y}findFitWidth(A){return this.screenWidth/A}findFitHeight(A){return this.screenHeight/A}findFit(A,e){const t=this.screenWidth/A,i=this.screenHeight/e;return Math.min(t,i)}findCover(A,e){const t=this.screenWidth/A,i=this.screenHeight/e;return Math.max(t,i)}fitWidth(A=this.worldWidth,e,t=!0,i){let r;e&&(r=this.center),this.scale.x=this.screenWidth/A,t&&(this.scale.y=this.scale.x);const s=this.plugins.get("clamp-zoom",!0);return!i&&s&&s.clamp(),e&&r&&this.moveCenter(r),this}fitHeight(A=this.worldHeight,e,t=!0,i){let r;e&&(r=this.center),this.scale.y=this.screenHeight/A,t&&(this.scale.x=this.scale.y);const s=this.plugins.get("clamp-zoom",!0);return!i&&s&&s.clamp(),e&&r&&this.moveCenter(r),this}fitWorld(A){let e;A&&(e=this.center),this.scale.x=this.screenWidth/this.worldWidth,this.scale.y=this.screenHeight/this.worldHeight,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const t=this.plugins.get("clamp-zoom",!0);return t&&t.clamp(),A&&e&&this.moveCenter(e),this}fit(A,e=this.worldWidth,t=this.worldHeight){let i;A&&(i=this.center),this.scale.x=this.screenWidth/e,this.scale.y=this.screenHeight/t,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const r=this.plugins.get("clamp-zoom",!0);return r&&r.clamp(),A&&i&&this.moveCenter(i),this}setZoom(A,e){let t;e&&(t=this.center),this.scale.set(A);const i=this.plugins.get("clamp-zoom",!0);return i&&i.clamp(),e&&t&&this.moveCenter(t),this}zoomPercent(A,e){return this.setZoom(this.scale.x+this.scale.x*A,e)}zoom(A,e){return this.fitWidth(A+this.worldScreenWidth,e),this}get scaled(){return this.scale.x}set scaled(A){this.setZoom(A,!0)}snapZoom(A){return this.plugins.add("snap-zoom",new wF(this,A)),this}OOB(){return{left:this.left<0,right:this.right>this.worldWidth,top:this.top<0,bottom:this.bottom>this.worldHeight,cornerPoint:new VA(this.worldWidth*this.scale.x-this.screenWidth,this.worldHeight*this.scale.y-this.screenHeight)}}get right(){return-this.x/this.scale.x+this.worldScreenWidth}set right(A){this.x=-A*this.scale.x+this.screenWidth,this.plugins.reset()}get left(){return-this.x/this.scale.x}set left(A){this.x=-A*this.scale.x,this.plugins.reset()}get top(){return-this.y/this.scale.y}set top(A){this.y=-A*this.scale.y,this.plugins.reset()}get bottom(){return-this.y/this.scale.y+this.worldScreenHeight}set bottom(A){this.y=-A*this.scale.y+this.screenHeight,this.plugins.reset()}get dirty(){return!!this._dirty}set dirty(A){this._dirty=A}get forceHitArea(){return this._forceHitArea}set forceHitArea(A){A?(this._forceHitArea=A,this.hitArea=A):(this._forceHitArea=null,this.hitArea=new ee(0,0,this.worldWidth,this.worldHeight))}drag(A){return this.plugins.add("drag",new cF(this,A)),this}clamp(A){return this.plugins.add("clamp",new nF(this,A)),this}decelerate(A){return this.plugins.add("decelerate",new aF(this,A)),this}bounce(A){return this.plugins.add("bounce",new tF(this,A)),this}pinch(A){return this.plugins.add("pinch",new gF(this,A)),this}snap(A,e,t){return this.plugins.add("snap",new vF(this,A,e,t)),this}follow(A,e){return this.plugins.add("follow",new uF(this,A,e)),this}wheel(A){return this.plugins.add("wheel",new xF(this,A)),this}animate(A){return this.plugins.add("animate",new AF(this,A)),this}clampZoom(A){return this.plugins.add("clamp-zoom",new sF(this,A)),this}mouseEdges(A){return this.plugins.add("mouse-edges",new dF(this,A)),this}get pause(){return!!this._pause}set pause(A){this._pause=A,this.lastViewport=null,this.moving=!1,this.zooming=!1,A&&this.input.pause()}ensureVisible(A,e,t,i,r){r&&(t>this.worldScreenWidth||i>this.worldScreenHeight)&&(this.fit(!0,t,i),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let s=!1;A<this.left?(this.left=A,s=!0):A+t>this.right&&(this.right=A+t,s=!0),e<this.top?(this.top=e,s=!0):e+i>this.bottom&&(this.bottom=e+i,s=!0),s&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}const MF="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAIrSURBVHic7dWhEcQwAAPBJEW4//bsJvzwg446YLcCkRvdc8598RljjNMTeHlOD4AvEwgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUC499779Aj+1lqnJ/DiQSAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIPwAhCgMRcz+Nz0AAAAASUVORK5CYII=";var PF=Object.defineProperty,TF=Object.getOwnPropertyDescriptor,Qa=(n,A,e,t)=>{for(var i=t>1?void 0:t?TF(A,e):A,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(t?s(A,e,i):s(i))||i);return t&&i&&PF(A,e,i),i};ue.Cropper=class extends Kr{constructor(){super(),this._domBoundingRect={x:0,y:0,width:0,height:0},this.app=new N2({backgroundAlpha:0,autoDensity:!0,resolution:2}),this.viewport=new _F({events:this.app.renderer.events,worldWidth:250,worldHeight:250}),this.imageSize={width:0,height:0},this.logoSize={width:0,height:0},this._imageUrl="",this._canvasScale=1,this.texture=new lt(this.app.view),this._timer=0,this._sprite=new ks,this.pathD="",this.getConfigs=()=>{const{screenWidth:A,screenHeight:e}=this.viewport;return{canvasWidth:A,canvasHeight:e,scale:this.viewport.scale.x,x:this.viewport.position.x,y:this.viewport.position.y,url:this._imageUrl}},this._onChanged=async()=>{if(!this.imageSize.width||!this.imageSize.height||!this.app.view.toDataURL)return;const A=this.app.view.toDataURL("image/png",.75),e=this.app.renderer.gl,{screenWidth:t,screenHeight:i}=this.viewport;if(this._timer&&clearTimeout(this._timer),e){const r=this.app.renderer.width,s=this.app.renderer.height,o=new Uint8Array(r*s*4);e.readPixels(0,0,r,s,e.RGBA,e.UNSIGNED_BYTE,o);let a=r,l=0,u=s,c=0;for(let g=0;g<s;g++)for(let y=0;y<r;y++){const v=(g*r+y)*4;o[v+3]>0&&(a=Math.min(a,y),l=Math.max(l,y),u=Math.min(u,g),c=Math.max(c,g))}const h=this.app.renderer.view.getBoundingClientRect(),f={x:a,y:u,width:l-a+1,height:c-u+1};(a>l||u>c)&&console.log("没有非透明区域"),this.axiosX&&(this.axiosX.style.display="none"),this.axiosY&&(this.axiosY.style.display="none");const p=2,m=t/2,d=i/2;if(h){const g={x:f.x*(h.width/this.app.renderer.width),y:(this.app.renderer.height-f.y-f.height)*(h.height/this.app.renderer.height),width:f.width*(h.width/this.app.renderer.width),height:f.height*(h.height/this.app.renderer.height)};this._domBoundingRect=g,this.boundRect&&(this.boundRect.style.left=`${g.x}px`,this.boundRect.style.top=`${g.y}px`,this.boundRect.style.width=`${g.width}px`,this.boundRect.style.height=`${g.height}px`);const y=g.x+g.width/2,v=g.y+g.height/2,w=m-y,C=d-v;Math.abs(w)<p&&(this.viewport.position.x+=w,this.axiosY&&(this.axiosY.style.display="block")),Math.abs(C)<p&&(this.viewport.position.y+=C,this.axiosX&&(this.axiosX.style.display="block"))}else Math.abs(this.viewport.position.x-m)<p&&(this.viewport.position.x=m,this.axiosY&&(this.axiosY.style.display="block")),Math.abs(this.viewport.position.y-d)<p&&(this.viewport.position.y=d,this.axiosX&&(this.axiosX.style.display="block"));this._timer=window.setTimeout(()=>{this.axiosX&&(this.axiosX.style.display="none"),this.axiosY&&(this.axiosY.style.display="none")},600)}this.dispatchEvent(new CustomEvent("image-change",{detail:{image:A},bubbles:!0,composed:!0}))},this._wheelEvent=A=>{A.preventDefault()},this.updateConfigs=async({canvasWidth:A,x:e,y:t,scale:i,url:r})=>{const{screenWidth:s}=this.viewport;this._canvasScale=s/A,await this.add(r,this.logoSize),this.viewport.scale.set(i*this._canvasScale),this.viewport.position.set(e*this._canvasScale,t*this._canvasScale)},this.app.stage.addChild(this.viewport),this.viewport.drag({}).pinch().wheel().decelerate({friction:0,bounce:1}).on("zoomed-end",this._onChanged).on("moved-end",this._onChanged),this.app.view.addEventListener("wheel",this._wheelEvent,{passive:!1})}get supports(){return["png","jpg","jpeg","svg","webp"]}get canvas(){return this.app.view}get imageScale(){const{screenWidth:A,screenHeight:e}=this.viewport,t=this.viewport.scale.x,i=this._sprite.width*t/2,r=this._sprite.height*t/2,s=this._domBoundingRect.width/i*(i/A),o=this._domBoundingRect.height/r*(r/e);return{x:s,y:o}}get imageRealSize(){const{x:A,y:e}=this.imageScale;let{width:t,height:i}=this.logoSize;const r=Math.max(t,i);return t=r*A,i=r*e,{width:t,height:i}}resize(A,e){this.app.renderer.resize(A,e),this.viewport.resize(A,e)}firstUpdated(A){var e;super.firstUpdated(A),this.container&&((e=this.container)==null||e.append(this.app.view),this.app.resizeTo=this.container,this.viewport.addChild(this._sprite))}setUV(A){const e=A.attributes.uv,t=A.index;if(!t){this.pathD="";return}let i=[];for(let s=0;s<t.count;s+=3){const o=t.getX(s),a=t.getX(s+1),l=t.getX(s+2),u=[e.getX(o)*200,e.getY(o)*200],c=[e.getX(a)*200,e.getY(a)*200],h=[e.getX(l)*200,e.getY(l)*200];i.push(u,c,h)}let r="";i.forEach((s,o)=>{o%3===0?r+=`M${s[0]},${s[1]} `:r+=`L${s[0]},${s[1]} `,o%3===2&&(r+="Z ")}),i=[],this.pathD=r}async add(A,e){this._imageUrl=A,this.logoSize=e,this._sprite.texture=await GA.fromURL(A),this.imageSize.width=this._sprite.texture.width,this.imageSize.height=this._sprite.texture.height,this.fit()}clear(){this._sprite.texture.destroy(!0),this.boundRect&&(this.boundRect.style.left="0px",this.boundRect.style.top="0px",this.boundRect.style.width="0px",this.boundRect.style.height="0px")}fit(){this.viewport.scale.set(1,1),this._sprite.anchor.set(.5,.5),this.viewport.moveCenter(this._sprite.position.x,this._sprite.position.y);const A=this.viewport.screenWidth,e=this.viewport.screenHeight,t=this._sprite.width/A,i=this._sprite.height/e,r=Math.max(t,i);this.viewport.scale.set(1/r,1/r)}disconnectedCallback(){super.disconnectedCallback(),this.viewport.destroy({children:!0,texture:!0,baseTexture:!0}),this.viewport.off("zoomed"),this.viewport.off("moved"),this.viewport.off("moved-end"),this.app.view.removeEventListener("wheel",this._wheelEvent),this.app.destroy(!0)}render(){return Z0`
9835
+ }`),this.camera.position.set(10,6,-10),this.camera.lookAt(new O);const{tiles:e}=R9();this.pathTracer=new i5(this.renderer),this.pathTracer.filterGlossyFactor=.6,this.pathTracer.renderScale=window.devicePixelRatio,this.pathTracer.bounces=10,this.pathTracer.transmissiveBounces=8,this.pathTracer.tiles.set(e,e),this.pathTracer.fadeDuration=0,this.pathTracer.setBVHWorker(new DK),this.controls.addEventListener("change",()=>{var t;this.sampleCount=0,(t=this.pathTracer)==null||t.updateCamera()}),this._composer=new r5(this.renderer),this._composer.setPixelRatio(window.devicePixelRatio),this._composer.addPass(new aE(this.scene,this.camera)),this._composer.addPass(new fE),this._outlinePass=new Kn(new dA(window.innerWidth,window.innerHeight),this.scene,this.camera),this._outlinePass.visibleEdgeColor.set(26367),this._outlinePass.edgeThickness=.5,this._outlinePass.hiddenEdgeColor.set(26367),this._outlinePass.edgeStrength=3,this._outlinePass.edgeGlow=0,this._composer.addPass(this._outlinePass),this._outlinePassError=new Kn(new dA(window.innerWidth,window.innerHeight),this.scene,this.camera),this._outlinePassError.visibleEdgeColor.set(16711680),this._outlinePassError.edgeThickness=.5,this._outlinePassError.hiddenEdgeColor.set(16711680),this._outlinePassError.edgeStrength=3,this._outlinePassError.edgeGlow=0,this._composer.addPass(this._outlinePassError),this._composer.renderTarget1.texture.colorSpace=je,this._composer.renderTarget2.texture.colorSpace=je,this._fxaaPass=new U1(lE),this._composer.addPass(this._fxaaPass),this._container.add(this.amr),this.scene.add(this._container),this.ticker(),this._loadEnv(),this._initEvents(),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground)}get usePathTracing(){return this._usePathTracing}set usePathTracing(A){A?(this.amr&&(this.amr.bodyOpacity=1),this.amr.slots.forEach(e=>e.hide()),this.lines.hide(),this.css3dRenderer.domElement.style.display="none",this.amr.sizeBox.hide(),this.pathTracer.renderToCanvas=!0):(this.amr.sizeBox.show(),this.amr.slots.forEach(e=>e.show()),this.lines.show(),this.css3dRenderer.domElement.style.display="block",this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this.scene.background=null),this._usePathTracing=A,this.controls.dampingFactor=A?1:_3,this.sampleCount=0}get fpsAverage(){return bb(this._fpsCache)}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}_loadEnv(){new nE(new N1).load(Ck,e=>{e.mapping=Ao,e.minFilter=we,e.magFilter=we,e.colorSpace=je,e.needsUpdate=!0,this._usePathTracing||(this.scene.environment=e,this.scene.environmentRotation.y=Math.PI*.1,this.scene.environmentIntensity=1),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown)}async generateBVH(){this.amr.slots.forEach(A=>A.hide()),this.css3dRenderer.domElement.style.display="none",this.lines.hide(),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.camera)}download(){return this.renderer.domElement.toDataURL("image/png")}clearAMR(){this.amr.clean(),this.usePathTracing=!1,this.lines.clear()}async exportAMR(){const A=this._container.clone(!0);return A.traverse(e=>{e.dispose&&(e.dispose(),e.removeFromParent())}),await Yb.parseAsync(A,{onlyVisible:!0,binary:!0})}async addAMR(A){this.amr.init(this),await this.amr.load(A)}generateEdges(){this._container.traverse(A=>{if(A instanceof De){const e=A.geometry.clone(),t=UK.generate(e);let i=t.next();for(;!i.done;)i=t.next();const r=new jh(i.value,new Nh({color:3355443}));r.position.z=-1.4,this.add(r),e.dispose()}})}select(A){typeof A=="string"||(Array.isArray(A)?this._outlinePass.selectedObjects=[...A]:this._outlinePass.selectedObjects=[A])}appendTo(A){A.append(this.renderer.domElement),A.append(this.stats.dom),A.append(this.lines),A.append(this.css2dRenderer.domElement),A.append(this.css3dRenderer.domElement),this.stats.dom.style.bottom="0",this.stats.dom.style.top="auto",this.resize(),this._resizeObserver=new ResizeObserver(this.resize),this._resizeObserver.observe(A)}add(A){this._container.add(A)}updatePosition(){this.lines.forceUpdate()}destroy(){var e,t;this.amr.destroy(),ws.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(e=this._fitAnimation)==null||e.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const A=this.renderer.domElement.parentElement;A&&((t=this._resizeObserver)==null||t.unobserve(A)),this.controls.dispose(),this.renderer.dispose(),this._composer.dispose(),this.scene.traverse(i=>{var r;i instanceof De?(i.geometry.dispose(),Array.isArray(i.material)?i.material.forEach(s=>s.dispose()):i.material&&i.material.dispose()):i instanceof jf?i.dispose():(r=i.dispose)==null||r.call(i),i.removeFromParent()})}}var XK=Object.defineProperty,QK=(n,A,e)=>A in n?XK(n,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[A]=e,pA=(n,A,e)=>(QK(n,typeof A!="symbol"?A+"":A,e),e);class Ti{constructor(A){pA(this,"parent"),pA(this,"paused"),this.parent=A,this.paused=!1}destroy(){}down(A){return!1}move(A){return!1}up(A){return!1}wheel(A){return!1}update(A){}resize(){}reset(){}pause(){this.paused=!0}resume(){this.paused=!1}}var VK=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},M3={exports:{}};(function(n,A){(function(){var e,t;t=function(i){return n.exports=i},e={linear:function(i,r,s,o){return s*i/o+r},easeInQuad:function(i,r,s,o){return s*(i/=o)*i+r},easeOutQuad:function(i,r,s,o){return-s*(i/=o)*(i-2)+r},easeInOutQuad:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i+r:-s/2*(--i*(i-2)-1)+r},easeInCubic:function(i,r,s,o){return s*(i/=o)*i*i+r},easeOutCubic:function(i,r,s,o){return s*((i=i/o-1)*i*i+1)+r},easeInOutCubic:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i*i+r:s/2*((i-=2)*i*i+2)+r},easeInQuart:function(i,r,s,o){return s*(i/=o)*i*i*i+r},easeOutQuart:function(i,r,s,o){return-s*((i=i/o-1)*i*i*i-1)+r},easeInOutQuart:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i*i*i+r:-s/2*((i-=2)*i*i*i-2)+r},easeInQuint:function(i,r,s,o){return s*(i/=o)*i*i*i*i+r},easeOutQuint:function(i,r,s,o){return s*((i=i/o-1)*i*i*i*i+1)+r},easeInOutQuint:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i*i*i*i+r:s/2*((i-=2)*i*i*i*i+2)+r},easeInSine:function(i,r,s,o){return-s*Math.cos(i/o*(Math.PI/2))+s+r},easeOutSine:function(i,r,s,o){return s*Math.sin(i/o*(Math.PI/2))+r},easeInOutSine:function(i,r,s,o){return-s/2*(Math.cos(Math.PI*i/o)-1)+r},easeInExpo:function(i,r,s,o){return i===0?r:s*Math.pow(2,10*(i/o-1))+r},easeOutExpo:function(i,r,s,o){return i===o?r+s:s*(-Math.pow(2,-10*i/o)+1)+r},easeInOutExpo:function(i,r,s,o){return(i/=o/2)<1?s/2*Math.pow(2,10*(i-1))+r:s/2*(-Math.pow(2,-10*--i)+2)+r},easeInCirc:function(i,r,s,o){return-s*(Math.sqrt(1-(i/=o)*i)-1)+r},easeOutCirc:function(i,r,s,o){return s*Math.sqrt(1-(i=i/o-1)*i)+r},easeInOutCirc:function(i,r,s,o){return(i/=o/2)<1?-s/2*(Math.sqrt(1-i*i)-1)+r:s/2*(Math.sqrt(1-(i-=2)*i)+1)+r},easeInElastic:function(i,r,s,o){var a,l,u;return u=1.70158,l=0,a=s,i===0||(i/=o),l||(l=o*.3),a<Math.abs(s)?(a=s,u=l/4):u=l/(2*Math.PI)*Math.asin(s/a),-(a*Math.pow(2,10*(i-=1))*Math.sin((i*o-u)*(2*Math.PI)/l))+r},easeOutElastic:function(i,r,s,o){var a,l,u;return u=1.70158,l=0,a=s,i===0||(i/=o),l||(l=o*.3),a<Math.abs(s)?(a=s,u=l/4):u=l/(2*Math.PI)*Math.asin(s/a),a*Math.pow(2,-10*i)*Math.sin((i*o-u)*(2*Math.PI)/l)+s+r},easeInOutElastic:function(i,r,s,o){var a,l,u;return u=1.70158,l=0,a=s,i===0||(i/=o/2),l||(l=o*(.3*1.5)),a<Math.abs(s)?(a=s,u=l/4):u=l/(2*Math.PI)*Math.asin(s/a),i<1?-.5*(a*Math.pow(2,10*(i-=1))*Math.sin((i*o-u)*(2*Math.PI)/l))+r:a*Math.pow(2,-10*(i-=1))*Math.sin((i*o-u)*(2*Math.PI)/l)*.5+s+r},easeInBack:function(i,r,s,o,a){return a===void 0&&(a=1.70158),s*(i/=o)*i*((a+1)*i-a)+r},easeOutBack:function(i,r,s,o,a){return a===void 0&&(a=1.70158),s*((i=i/o-1)*i*((a+1)*i+a)+1)+r},easeInOutBack:function(i,r,s,o,a){return a===void 0&&(a=1.70158),(i/=o/2)<1?s/2*(i*i*(((a*=1.525)+1)*i-a))+r:s/2*((i-=2)*i*(((a*=1.525)+1)*i+a)+2)+r},easeInBounce:function(i,r,s,o){var a;return a=e.easeOutBounce(o-i,0,s,o),s-a+r},easeOutBounce:function(i,r,s,o){return(i/=o)<1/2.75?s*(7.5625*i*i)+r:i<2/2.75?s*(7.5625*(i-=1.5/2.75)*i+.75)+r:i<2.5/2.75?s*(7.5625*(i-=2.25/2.75)*i+.9375)+r:s*(7.5625*(i-=2.625/2.75)*i+.984375)+r},easeInOutBounce:function(i,r,s,o){var a;return i<o/2?(a=e.easeInBounce(i*2,0,s,o),a*.5+r):(a=e.easeOutBounce(i*2-o,0,s,o),a*.5+s*.5+r)}},t(e)}).call(VK)})(M3);const P3=M3.exports;function yd(n,A){if(n){if(typeof n=="function")return n;if(typeof n=="string")return P3[n]}else return P3[A]}const $K={removeOnInterrupt:!1,ease:"linear",time:1e3};class AF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"startX"),pA(this,"startY"),pA(this,"deltaX"),pA(this,"deltaY"),pA(this,"keepCenter"),pA(this,"startWidth",null),pA(this,"startHeight",null),pA(this,"deltaWidth",null),pA(this,"deltaHeight",null),pA(this,"width",null),pA(this,"height",null),pA(this,"time",0),this.options=Object.assign({},$K,e),this.options.ease=yd(this.options.ease),this.setupPosition(),this.setupZoom(),this.time=0}setupPosition(){typeof this.options.position<"u"?(this.startX=this.parent.center.x,this.startY=this.parent.center.y,this.deltaX=this.options.position.x-this.parent.center.x,this.deltaY=this.options.position.y-this.parent.center.y,this.keepCenter=!1):this.keepCenter=!0}setupZoom(){this.width=null,this.height=null,typeof this.options.scale<"u"?this.width=this.parent.screenWidth/this.options.scale:typeof this.options.scaleX<"u"||typeof this.options.scaleY<"u"?(typeof this.options.scaleX<"u"&&(this.width=this.parent.screenWidth/this.options.scaleX),typeof this.options.scaleY<"u"&&(this.height=this.parent.screenHeight/this.options.scaleY)):(typeof this.options.width<"u"&&(this.width=this.options.width),typeof this.options.height<"u"&&(this.height=this.options.height)),this.width!==null&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),this.height!==null&&(this.startHeight=this.parent.screenHeightInWorldPixels,this.deltaHeight=this.height-this.startHeight)}down(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("animate"),!1}complete(){this.parent.plugins.remove("animate"),this.width!==null&&this.parent.fitWidth(this.width,this.keepCenter,this.height===null),this.height!==null&&this.parent.fitHeight(this.height,this.keepCenter,this.width===null),!this.keepCenter&&this.options.position&&this.parent.moveCenter(this.options.position),this.parent.emit("animate-end",this.parent),this.options.callbackOnComplete&&this.options.callbackOnComplete(this.parent)}update(A){if(this.paused)return;this.time+=A;const e=new VA(this.parent.scale.x,this.parent.scale.y);if(this.time>=this.options.time){const t=this.parent.width,i=this.parent.height;this.complete(),(t!==this.parent.width||i!==this.parent.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}else{const t=this.options.ease(this.time,0,1,this.options.time);if(this.width!==null){const i=this.startWidth,r=this.deltaWidth;this.parent.fitWidth(i+r*t,this.keepCenter,this.height===null)}if(this.height!==null){const i=this.startHeight,r=this.deltaHeight;this.parent.fitHeight(i+r*t,this.keepCenter,this.width===null)}if(this.width===null?this.parent.scale.x=this.parent.scale.y:this.height===null&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const i=this.startX,r=this.startY,s=this.deltaX,o=this.deltaY,a=new VA(this.parent.x,this.parent.y);this.parent.moveCenter(i+s*t,r+o*t),this.parent.emit("moved",{viewport:this.parent,original:a,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}}}const eF={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class tF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"left"),pA(this,"top"),pA(this,"right"),pA(this,"bottom"),pA(this,"underflowX"),pA(this,"underflowY"),pA(this,"ease"),pA(this,"toX"),pA(this,"toY"),this.options=Object.assign({},eF,e),this.ease=yd(this.options.ease,"easeInOutSine"),this.options.sides?this.options.sides==="all"?this.top=this.bottom=this.left=this.right=!0:this.options.sides==="horizontal"?(this.right=this.left=!0,this.top=this.bottom=!1):this.options.sides==="vertical"?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=this.options.sides.indexOf("top")!==-1,this.bottom=this.options.sides.indexOf("bottom")!==-1,this.left=this.options.sides.indexOf("left")!==-1,this.right=this.options.sides.indexOf("right")!==-1):this.left=this.top=this.right=this.bottom=!1;const t=this.options.underflow.toLowerCase();t==="center"?(this.underflowX=0,this.underflowY=0):(this.underflowX=t.indexOf("left")!==-1?-1:t.indexOf("right")!==-1?1:0,this.underflowY=t.indexOf("top")!==-1?-1:t.indexOf("bottom")!==-1?1:0),this.reset()}isActive(){return this.toX!==null||this.toY!==null}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(A){if(!this.paused){if(this.bounce(),this.toX){const e=this.toX;e.time+=A,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),e.time>=this.options.time?(this.parent.x=e.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(e.time,e.start,e.delta,this.options.time)}if(this.toY){const e=this.toY;e.time+=A,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),e.time>=this.options.time?(this.parent.y=e.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(e.time,e.start,e.delta,this.options.time)}}}calcUnderflowX(){let A;switch(this.underflowX){case-1:A=0;break;case 1:A=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:A=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}return A}calcUnderflowY(){let A;switch(this.underflowY){case-1:A=0;break;case 1:A=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:A=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}return A}oob(){const A=this.options.bounceBox;if(A){const e=typeof A.x>"u"?0:A.x,t=typeof A.y>"u"?0:A.y,i=typeof A.width>"u"?this.parent.worldWidth:A.width,r=typeof A.height>"u"?this.parent.worldHeight:A.height;return{left:this.parent.left<e,right:this.parent.right>i,top:this.parent.top<t,bottom:this.parent.bottom>r,topLeft:new VA(e*this.parent.scale.x,t*this.parent.scale.y),bottomRight:new VA(i*this.parent.scale.x-this.parent.screenWidth,r*this.parent.scale.y-this.parent.screenHeight)}}return{left:this.parent.left<0,right:this.parent.right>this.parent.worldWidth,top:this.parent.top<0,bottom:this.parent.bottom>this.parent.worldHeight,topLeft:new VA(0,0),bottomRight:new VA(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){var A,e;if(this.paused)return;let t,i=this.parent.plugins.get("decelerate",!0);i&&(i.x||i.y)&&(i.x&&i.percentChangeX===((A=i.options)==null?void 0:A.friction)||i.y&&i.percentChangeY===((e=i.options)==null?void 0:e.friction))&&(t=this.oob(),(t.left&&this.left||t.right&&this.right)&&(i.percentChangeX=this.options.friction),(t.top&&this.top||t.bottom&&this.bottom)&&(i.percentChangeY=this.options.friction));const r=this.parent.plugins.get("drag",!0)||{},s=this.parent.plugins.get("pinch",!0)||{};if(i=i||{},!(r!=null&&r.active)&&!(s!=null&&s.active)&&(!this.toX||!this.toY)&&(!i.x||!i.y)){t=t||this.oob();const o=t.topLeft,a=t.bottomRight;if(!this.toX&&!i.x){let l=null;t.left&&this.left?l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-o.x:t.right&&this.right&&(l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-a.x),l!==null&&this.parent.x!==l&&(this.toX={time:0,start:this.parent.x,delta:l-this.parent.x,end:l},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!i.y){let l=null;t.top&&this.top?l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-o.y:t.bottom&&this.bottom&&(l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-a.y),l!==null&&this.parent.y!==l&&(this.toY={time:0,start:this.parent.y,delta:l-this.parent.y,end:l},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const iF={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class nF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"last"),pA(this,"noUnderflow"),pA(this,"underflowX"),pA(this,"underflowY"),this.options=Object.assign({},iF,e),this.options.direction&&(this.options.left=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.right=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.top=this.options.direction==="y"||this.options.direction==="all"?!0:null,this.options.bottom=this.options.direction==="y"||this.options.direction==="all"?!0:null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const A=this.options.underflow.toLowerCase();A==="none"?this.noUnderflow=!0:A==="center"?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=A.indexOf("left")!==-1?-1:A.indexOf("right")!==-1?1:0,this.underflowY=A.indexOf("top")!==-1?-1:A.indexOf("bottom")!==-1?1:0,this.noUnderflow=!1)}move(){return this.update(),!1}update(){if(this.paused||this.parent.x===this.last.x&&this.parent.y===this.last.y&&this.parent.scale.x===this.last.scaleX&&this.parent.scale.y===this.last.scaleY)return;const A=new VA(this.parent.x,this.parent.y),e=this.parent.plugins.decelerate||{};if(this.options.left!==null||this.options.right!==null){let t=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x!==0&&(this.parent.x=0,t=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,t=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,t=!0)}else this.options.left!==null&&this.parent.left<(this.options.left===!0?0:this.options.left)&&(this.parent.x=-(this.options.left===!0?0:this.options.left)*this.parent.scale.x,e.x=0,t=!0),this.options.right!==null&&this.parent.right>(this.options.right===!0?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(this.options.right===!0?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,e.x=0,t=!0);t&&this.parent.emit("moved",{viewport:this.parent,original:A,type:"clamp-x"})}if(this.options.top!==null||this.options.bottom!==null){let t=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y!==0&&(this.parent.y=0,t=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,t=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,t=!0)}else this.options.top!==null&&this.parent.top<(this.options.top===!0?0:this.options.top)&&(this.parent.y=-(this.options.top===!0?0:this.options.top)*this.parent.scale.y,e.y=0,t=!0),this.options.bottom!==null&&this.parent.bottom>(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,e.y=0,t=!0);t&&this.parent.emit("moved",{viewport:this.parent,original:A,type:"clamp-y"})}this.last.x=this.parent.x,this.last.y=this.parent.y,this.last.scaleX=this.parent.scale.x,this.last.scaleY=this.parent.scale.y}reset(){this.update()}}const rF={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class sF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),this.options=Object.assign({},rF,e),this.clamp()}resize(){this.clamp()}clamp(){if(!this.paused){if(this.options.minWidth||this.options.minHeight||this.options.maxWidth||this.options.maxHeight){let A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight;if(this.options.minWidth!==null&&A<this.options.minWidth){const t=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/t,A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxWidth!==null&&A>this.options.maxWidth){const t=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/t,A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.minHeight!==null&&e<this.options.minHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxHeight!==null&&e>this.options.maxHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else if(this.options.minScale||this.options.maxScale){const A={x:null,y:null},e={x:null,y:null};if(typeof this.options.minScale=="number")A.x=this.options.minScale,A.y=this.options.minScale;else if(this.options.minScale!==null){const r=this.options.minScale;A.x=typeof r.x>"u"?null:r.x,A.y=typeof r.y>"u"?null:r.y}if(typeof this.options.maxScale=="number")e.x=this.options.maxScale,e.y=this.options.maxScale;else if(this.options.maxScale!==null){const r=this.options.maxScale;e.x=typeof r.x>"u"?null:r.x,e.y=typeof r.y>"u"?null:r.y}let t=this.parent.scale.x,i=this.parent.scale.y;A.x!==null&&t<A.x&&(t=A.x),e.x!==null&&t>e.x&&(t=e.x),A.y!==null&&i<A.y&&(i=A.y),e.y!==null&&i>e.y&&(i=e.y),(t!==this.parent.scale.x||i!==this.parent.scale.y)&&(this.parent.scale.set(t,i),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}}reset(){this.clamp()}}const oF={friction:.98,bounce:.8,minSpeed:.01},Vr=16;class aF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"x"),pA(this,"y"),pA(this,"percentChangeX"),pA(this,"percentChangeY"),pA(this,"saved"),pA(this,"timeSinceRelease"),this.options=Object.assign({},oF,e),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",t=>this.handleMoved(t))}down(){return this.saved=[],this.x=this.y=null,!1}isActive(){return!!(this.x||this.y)}move(){if(this.paused)return!1;const A=this.parent.input.count();return(A===1||A>1&&!this.parent.plugins.get("pinch",!0))&&(this.saved.push({x:this.parent.x,y:this.parent.y,time:performance.now()}),this.saved.length>60&&this.saved.splice(0,30)),!1}handleMoved(A){if(this.saved.length){const e=this.saved[this.saved.length-1];A.type==="clamp-x"&&A.original?e.x===A.original.x&&(e.x=this.parent.x):A.type==="clamp-y"&&A.original&&e.y===A.original.y&&(e.y=this.parent.y)}}up(){if(this.parent.input.count()===0&&this.saved.length){const A=performance.now();for(const e of this.saved)if(e.time>=A-100){const t=A-e.time;this.x=(this.parent.x-e.x)/t,this.y=(this.parent.y-e.y)/t,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(A){A=A||{},typeof A.x<"u"&&(this.x=A.x,this.percentChangeX=this.options.friction),typeof A.y<"u"&&(this.y=A.y,this.percentChangeY=this.options.friction)}update(A){if(this.paused)return;const e=this.x||this.y,t=this.timeSinceRelease,i=this.timeSinceRelease+A;if(this.x){const r=this.percentChangeX,s=Math.log(r);this.parent.x+=this.x*Vr/s*(Math.pow(r,i/Vr)-Math.pow(r,t/Vr)),this.x*=Math.pow(this.percentChangeX,A/Vr)}if(this.y){const r=this.percentChangeY,s=Math.log(r);this.parent.y+=this.y*Vr/s*(Math.pow(r,i/Vr)-Math.pow(r,t/Vr)),this.y*=Math.pow(this.percentChangeY,A/Vr)}this.timeSinceRelease+=A,this.x&&this.y?Math.abs(this.x)<this.options.minSpeed&&Math.abs(this.y)<this.options.minSpeed&&(this.x=0,this.y=0):(Math.abs(this.x||0)<this.options.minSpeed&&(this.x=0),Math.abs(this.y||0)<this.options.minSpeed&&(this.y=0)),e&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}}const lF={direction:"all",pressDrag:!0,wheel:!0,wheelScroll:1,reverse:!1,clampWheel:!1,underflow:"center",factor:1,mouseButtons:"all",keyToPress:null,ignoreKeyToPressOnTouch:!1,lineHeight:20,wheelSwapAxes:!1};class cF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"moved"),pA(this,"reverse"),pA(this,"xDirection"),pA(this,"yDirection"),pA(this,"keyIsPressed"),pA(this,"mouse"),pA(this,"underflowX"),pA(this,"underflowY"),pA(this,"last"),pA(this,"current"),pA(this,"windowEventHandlers",[]),this.options=Object.assign({},lF,e),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="x",this.yDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="y",this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(A){const e=i=>{A.includes(i.code)&&(this.keyIsPressed=!0)},t=i=>{A.includes(i.code)&&(this.keyIsPressed=!1)};this.addWindowEventHandler("keyup",t),this.addWindowEventHandler("keydown",e)}addWindowEventHandler(A,e){window.addEventListener(A,e),this.windowEventHandlers.push({event:A,handler:e})}destroy(){this.windowEventHandlers.forEach(({event:A,handler:e})=>{window.removeEventListener(A,e)})}mouseButtons(A){!A||A==="all"?this.mouse=[!0,!0,!0]:this.mouse=[A.indexOf("left")!==-1,A.indexOf("middle")!==-1,A.indexOf("right")!==-1]}parseUnderflow(){const A=this.options.underflow.toLowerCase();A==="center"?(this.underflowX=0,this.underflowY=0):(A.includes("left")?this.underflowX=-1:A.includes("right")?this.underflowX=1:this.underflowX=0,A.includes("top")?this.underflowY=-1:A.includes("bottom")?this.underflowY=1:this.underflowY=0)}checkButtons(A){const e=A.pointerType==="mouse",t=this.parent.input.count();return!!((t===1||t>1&&!this.parent.plugins.get("pinch",!0))&&(!e||this.mouse[A.button]))}checkKeyPress(A){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&A.data.pointerType==="touch"}down(A){return this.paused||!this.options.pressDrag?!1:this.checkButtons(A)&&this.checkKeyPress(A)?(this.last={x:A.global.x,y:A.global.y},this.current=A.pointerId,!0):(this.last=null,!1)}get active(){return this.moved}move(A){if(this.paused||!this.options.pressDrag)return!1;if(this.last&&this.current===A.data.pointerId){const e=A.global.x,t=A.global.y,i=this.parent.input.count();if(i===1||i>1&&!this.parent.plugins.get("pinch",!0)){const r=e-this.last.x,s=t-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(r)||this.yDirection&&this.parent.input.checkThreshold(s)){const o={x:e,y:t};return this.xDirection&&(this.parent.x+=(o.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(o.y-this.last.y)*this.options.factor),this.last=o,this.moved||this.parent.emit("drag-start",{event:A,screen:new VA(this.last.x,this.last.y),world:this.parent.toWorld(new VA(this.last.x,this.last.y)),viewport:this.parent}),this.moved=!0,this.parent.emit("moved",{viewport:this.parent,type:"drag"}),!0}}else this.moved=!1}return!1}up(A){if(this.paused)return!1;const e=this.parent.input.touches;if(e.length===1){const t=e[0];return t.last&&(this.last={x:t.last.x,y:t.last.y},this.current=t.id),this.moved=!1,!0}else if(this.last&&this.moved){const t=new VA(this.last.x,this.last.y);return this.parent.emit("drag-end",{event:A,screen:t,world:this.parent.toWorld(t),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(A){if(this.paused)return!1;if(this.options.wheel){const e=this.parent.plugins.get("wheel",!0);if(!e||!e.options.wheelZoom&&!A.ctrlKey){const t=A.deltaMode?this.options.lineHeight:1,i=[A.deltaX,A.deltaY],[r,s]=this.options.wheelSwapAxes?i.reverse():i;return this.xDirection&&(this.parent.x+=r*t*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=s*t*this.options.wheelScroll*this.reverse),this.options.clampWheel&&this.clamp(),this.parent.emit("wheel-scroll",this.parent),this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.options.passiveWheel||A.preventDefault(),this.parent.options.stopPropagation&&A.stopPropagation(),!0}}return!1}resume(){this.last=null,this.paused=!1}clamp(){const A=this.parent.plugins.get("decelerate",!0)||{};if(this.options.clampWheel!=="y")if(this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x=0;break;case 1:this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}else this.parent.left<0?(this.parent.x=0,A.x=0):this.parent.right>this.parent.worldWidth&&(this.parent.x=-this.parent.worldWidth*this.parent.scale.x+this.parent.screenWidth,A.x=0);if(this.options.clampWheel!=="x")if(this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y=0;break;case 1:this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}else this.parent.top<0&&(this.parent.y=0,A.y=0),this.parent.bottom>this.parent.worldHeight&&(this.parent.y=-this.parent.worldHeight*this.parent.scale.y+this.parent.screenHeight,A.y=0)}}const hF={speed:0,acceleration:null,radius:null};class uF extends Ti{constructor(A,e,t={}){super(A),pA(this,"options"),pA(this,"target"),pA(this,"velocity"),this.target=e,this.options=Object.assign({},hF,t),this.velocity={x:0,y:0}}update(A){if(this.paused)return;const e=this.parent.center;let t=this.target.x,i=this.target.y;if(this.options.radius)if(Math.sqrt(Math.pow(this.target.y-e.y,2)+Math.pow(this.target.x-e.x,2))>this.options.radius){const o=Math.atan2(this.target.y-e.y,this.target.x-e.x);t=this.target.x-Math.cos(o)*this.options.radius,i=this.target.y-Math.sin(o)*this.options.radius}else return;const r=t-e.x,s=i-e.y;if(r||s)if(this.options.speed)if(this.options.acceleration){const o=Math.atan2(i-e.y,t-e.x),a=Math.sqrt(Math.pow(r,2)+Math.pow(s,2));if(a){const l=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);a>l?this.velocity={x:Math.min(this.velocity.x+(this.options.acceleration*A,this.options.speed)),y:Math.min(this.velocity.y+(this.options.acceleration*A,this.options.speed))}:this.velocity={x:Math.max(this.velocity.x-this.options.acceleration*this.options.speed,0),y:Math.max(this.velocity.y-this.options.acceleration*this.options.speed,0)};const u=Math.cos(o)*this.velocity.x,c=Math.sin(o)*this.velocity.y,h=Math.abs(u)>Math.abs(r)?t:e.x+u,f=Math.abs(c)>Math.abs(s)?i:e.y+c;this.parent.moveCenter(h,f),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const o=Math.atan2(i-e.y,t-e.x),a=Math.cos(o)*this.options.speed,l=Math.sin(o)*this.options.speed,u=Math.abs(a)>Math.abs(r)?t:e.x+a,c=Math.abs(l)>Math.abs(s)?i:e.y+l;this.parent.moveCenter(u,c),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(t,i),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const fF={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};class dF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"reverse"),pA(this,"radiusSquared"),pA(this,"left"),pA(this,"top"),pA(this,"right"),pA(this,"bottom"),pA(this,"horizontal"),pA(this,"vertical"),this.options=Object.assign({},fF,e),this.reverse=this.options.reverse?1:-1,this.radiusSquared=typeof this.options.radius=="number"?Math.pow(this.options.radius,2):null,this.resize()}resize(){const A=this.options.distance;A!==null?(this.left=A,this.top=A,this.right=this.parent.screenWidth-A,this.bottom=this.parent.screenHeight-A):this.options.radius||(this.left=this.options.left,this.top=this.options.top,this.right=this.options.right===null?null:this.parent.screenWidth-this.options.right,this.bottom=this.options.bottom===null?null:this.parent.screenHeight-this.options.bottom)}down(){return this.paused||this.options.allowButtons||(this.horizontal=this.vertical=null),!1}move(A){if(this.paused||A.pointerType!=="mouse"&&A.pointerId!==1||!this.options.allowButtons&&A.buttons!==0)return!1;const e=A.global.x,t=A.global.y;if(this.radiusSquared){const i=this.parent.toScreen(this.parent.center);if(Math.pow(i.x-e,2)+Math.pow(i.y-t,2)>=this.radiusSquared){const r=Math.atan2(i.y-t,i.x-e);this.options.linear?(this.horizontal=Math.round(Math.cos(r))*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.round(Math.sin(r))*this.options.speed*this.reverse*(60/1e3)):(this.horizontal=Math.cos(r)*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.sin(r)*this.options.speed*this.reverse*(60/1e3))}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else this.left!==null&&e<this.left?this.horizontal=Number(this.reverse)*this.options.speed*(60/1e3):this.right!==null&&e>this.right?this.horizontal=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateHorizontal(),this.horizontal=0),this.top!==null&&t<this.top?this.vertical=Number(this.reverse)*this.options.speed*(60/1e3):this.bottom!==null&&t>this.bottom?this.vertical=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateVertical(),this.vertical=0);return!1}decelerateHorizontal(){const A=this.parent.plugins.get("decelerate",!0);this.horizontal&&A&&!this.options.noDecelerate&&A.activate({x:this.horizontal*this.options.speed*this.reverse/(1e3/60)})}decelerateVertical(){const A=this.parent.plugins.get("decelerate",!0);this.vertical&&A&&!this.options.noDecelerate&&A.activate({y:this.vertical*this.options.speed*this.reverse/(1e3/60)})}up(){return this.paused||(this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=null),!1}update(){if(!this.paused&&(this.horizontal||this.vertical)){const A=this.parent.center;this.horizontal&&(A.x+=this.horizontal*this.options.speed),this.vertical&&(A.y+=this.vertical*this.options.speed),this.parent.moveCenter(A),this.parent.emit("moved",{viewport:this.parent,type:"mouse-edges"})}}}const pF={noDrag:!1,percent:1,center:null,factor:1,axis:"all"};class gF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"active",!1),pA(this,"pinching",!1),pA(this,"moved",!1),pA(this,"lastCenter"),this.options=Object.assign({},pF,e)}down(){return this.parent.input.count()>=2?(this.active=!0,!0):!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}move(A){if(this.paused||!this.active)return!1;const e=A.global.x,t=A.global.y,i=this.parent.input.touches;if(i.length>=2){const r=i[0],s=i[1],o=r.last&&s.last?Math.sqrt(Math.pow(s.last.x-r.last.x,2)+Math.pow(s.last.y-r.last.y,2)):null;if(r.id===A.pointerId?r.last={x:e,y:t,data:A}:s.id===A.pointerId&&(s.last={x:e,y:t,data:A}),o){let a;const l=new VA(r.last.x+(s.last.x-r.last.x)/2,r.last.y+(s.last.y-r.last.y)/2);this.options.center||(a=this.parent.toLocal(l));let u=Math.sqrt(Math.pow(s.last.x-r.last.x,2)+Math.pow(s.last.y-r.last.y,2));u=u===0?u=1e-10:u;const c=(1-o/u)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=c),this.isAxisY()&&(this.parent.scale.y+=c),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:l});const h=this.parent.plugins.get("clamp-zoom",!0);if(h&&h.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const f=this.parent.toGlobal(a);this.parent.x+=(l.x-f.x)*this.options.factor,this.parent.y+=(l.y-f.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(l.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(l.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=l,this.moved=!0}else this.pinching||(this.parent.emit("pinch-start",this.parent),this.pinching=!0);return!0}return!1}up(){return this.pinching&&this.parent.input.touches.length<=1?(this.active=!1,this.lastCenter=null,this.pinching=!1,this.moved=!1,this.parent.emit("pinch-end",this.parent),!0):!1}}const mF={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class vF extends Ti{constructor(A,e,t,i={}){super(A),pA(this,"options"),pA(this,"ease"),pA(this,"x"),pA(this,"y"),pA(this,"percent"),pA(this,"snapping"),pA(this,"deltaX"),pA(this,"deltaY"),pA(this,"startX"),pA(this,"startY"),this.options=Object.assign({},mF,i),this.ease=yd(i.ease,"easeInOutSine"),this.x=e,this.y=t,this.options.forceStart&&this.snapStart()}snapStart(){this.percent=0,this.snapping={time:0};const A=this.options.topLeft?this.parent.corner:this.parent.center;this.deltaX=this.x-A.x,this.deltaY=this.y-A.y,this.startX=A.x,this.startY=A.y,this.parent.emit("snap-start",this.parent)}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap"):this.options.interrupt&&(this.snapping=null),!1}up(){if(this.parent.input.count()===0){const A=this.parent.plugins.get("decelerate",!0);A&&(A.x||A.y)&&(A.percentChangeX=A.percentChangeY=this.options.friction)}return!1}update(A){if(!this.paused&&!(this.options.interrupt&&this.parent.input.count()!==0))if(this.snapping){const e=this.snapping;e.time+=A;let t,i,r;const s=this.startX,o=this.startY,a=this.deltaX,l=this.deltaY;if(e.time>this.options.time)t=!0,i=s+a,r=o+l;else{const u=this.ease(e.time,0,1,this.options.time);i=s+a*u,r=o+l*u}this.options.topLeft?this.parent.moveCorner(i,r):this.parent.moveCenter(i,r),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),t&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const e=this.options.topLeft?this.parent.corner:this.parent.center;(e.x!==this.x||e.y!==this.y)&&this.snapStart()}}}const yF={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class wF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"ease"),pA(this,"xScale"),pA(this,"yScale"),pA(this,"xIndependent"),pA(this,"yIndependent"),pA(this,"snapping"),this.options=Object.assign({},yF,e),this.ease=yd(this.options.ease),this.xIndependent=!1,this.yIndependent=!1,this.xScale=0,this.yScale=0,this.options.width>0&&(this.xScale=A.screenWidth/this.options.width,this.xIndependent=!0),this.options.height>0&&(this.yScale=A.screenHeight/this.options.height,this.yIndependent=!0),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale,this.options.time===0?(A.container.scale.x=this.xScale,A.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):e.forceStart&&this.createSnapping()}createSnapping(){const A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,t=this.parent.screenWidth/this.xScale,i=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:A,startY:e,deltaX:t-A,deltaY:i-e},this.parent.emit("snap-zoom-start",this.parent)}resize(){this.snapping=null,this.options.width>0&&(this.xScale=this.parent.screenWidth/this.options.width),this.options.height>0&&(this.yScale=this.parent.screenHeight/this.options.height),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap-zoom"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap-zoom"):this.options.interrupt&&(this.snapping=null),!1}update(A){if(this.paused||this.options.interrupt&&this.parent.input.count()!==0)return;let e;if(!this.options.center&&!this.options.noMove&&(e=this.parent.center),!this.snapping)(this.parent.scale.x!==this.xScale||this.parent.scale.y!==this.yScale)&&this.createSnapping();else if(this.snapping){const t=this.snapping;if(t.time+=A,t.time>=this.options.time)this.parent.scale.set(this.xScale,this.yScale),this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom"),this.parent.emit("snap-zoom-end",this.parent),this.snapping=null;else{const r=this.snapping,s=this.ease(r.time,r.startX,r.deltaX,this.options.time),o=this.ease(r.time,r.startY,r.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/s,this.parent.scale.y=this.parent.screenHeight/o}const i=this.parent.plugins.get("clamp-zoom",!0);i&&i.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(e))}}resume(){this.snapping=null,super.resume()}}const CF={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all",keyToPress:null,trackpadPinch:!1,wheelZoom:!0};class xF extends Ti{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"smoothing"),pA(this,"smoothingCenter"),pA(this,"smoothingCount"),pA(this,"keyIsPressed"),this.options=Object.assign({},CF,e),this.keyIsPressed=!1,this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(A){window.addEventListener("keydown",e=>{A.includes(e.code)&&(this.keyIsPressed=!0)}),window.addEventListener("keyup",e=>{A.includes(e.code)&&(this.keyIsPressed=!1)})}checkKeyPress(){return!this.options.keyToPress||this.keyIsPressed}down(){return this.options.interrupt&&(this.smoothing=null),!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}update(){if(this.smoothing){const A=this.smoothingCenter,e=this.smoothing;let t;this.options.center||(t=this.parent.toLocal(A)),this.isAxisX()&&(this.parent.scale.x+=e.x),this.isAxisY()&&(this.parent.scale.y+=e.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const i=this.parent.plugins.get("clamp-zoom",!0);if(i&&i.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const r=this.parent.toGlobal(t);this.parent.x+=A.x-r.x,this.parent.y+=A.y-r.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.smoothingCount++,this.smoothingCount>=this.options.smooth&&(this.smoothing=null)}}pinch(A){if(this.paused)return;const e=this.parent.input.getPointerPosition(A),t=-A.deltaY*(A.deltaMode?this.options.lineHeight:1)/200,i=Math.pow(2,(1+this.options.percent)*t);let r;this.options.center||(r=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=i),this.isAxisY()&&(this.parent.scale.y*=i),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom",!0);if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const o=this.parent.toGlobal(r);this.parent.x+=e.x-o.x,this.parent.y+=e.y-o.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:A,viewport:this.parent})}wheel(A){if(this.paused||!this.checkKeyPress())return!1;if(A.ctrlKey&&this.options.trackpadPinch)this.pinch(A);else if(this.options.wheelZoom){const e=this.parent.input.getPointerPosition(A),t=(this.options.reverse?-1:1)*-A.deltaY*(A.deltaMode?this.options.lineHeight:1)/500,i=Math.pow(2,(1+this.options.percent)*t);if(this.options.smooth){const r={x:this.smoothing?this.smoothing.x*(this.options.smooth-this.smoothingCount):0,y:this.smoothing?this.smoothing.y*(this.options.smooth-this.smoothingCount):0};this.smoothing={x:((this.parent.scale.x+r.x)*i-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+r.y)*i-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=e}else{let r;this.options.center||(r=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=i),this.isAxisY()&&(this.parent.scale.y*=i),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom",!0);if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const o=this.parent.toGlobal(r);this.parent.x+=e.x-o.x,this.parent.y+=e.y-o.y}}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:A,viewport:this.parent})}return!this.parent.options.passiveWheel}}class IF{constructor(A){pA(this,"viewport"),pA(this,"clickedAvailable"),pA(this,"isMouseDown"),pA(this,"last"),pA(this,"wheelFunction"),pA(this,"touches"),this.viewport=A,this.touches=[],this.addListeners()}addListeners(){this.viewport.eventMode="static",this.viewport.forceHitArea||(this.viewport.hitArea=new ee(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.options.allowPreserveDragOutside?this.viewport.on("globalpointermove",this.move,this):this.viewport.on("pointermove",this.move,this),this.viewport.on("pointerup",this.up,this),this.viewport.on("pointerupoutside",this.up,this),this.viewport.on("pointercancel",this.up,this),this.viewport.options.allowPreserveDragOutside||this.viewport.on("pointerleave",this.up,this),this.wheelFunction=A=>this.handleWheel(A),this.viewport.options.events.domElement.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.events.domElement.removeEventListener("wheel",this.wheelFunction)}down(A){if(!(this.viewport.pause||!this.viewport.worldVisible)){if(A.pointerType==="mouse"?this.isMouseDown=!0:this.get(A.pointerId)||this.touches.push({id:A.pointerId,last:null}),this.count()===1){this.last=A.global.clone();const e=this.viewport.plugins.get("decelerate",!0),t=this.viewport.plugins.get("bounce",!0);(!e||!e.isActive())&&(!t||!t.isActive())?this.clickedAvailable=!0:this.clickedAvailable=!1}else this.clickedAvailable=!1;this.viewport.plugins.down(A)&&this.viewport.options.stopPropagation&&A.stopPropagation()}}clear(){this.isMouseDown=!1,this.touches=[],this.last=null}checkThreshold(A){return Math.abs(A)>=this.viewport.threshold}move(A){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.plugins.move(A);if(this.clickedAvailable&&this.last){const t=A.global.x-this.last.x,i=A.global.y-this.last.y;(this.checkThreshold(t)||this.checkThreshold(i))&&(this.clickedAvailable=!1)}e&&this.viewport.options.stopPropagation&&A.stopPropagation()}up(A){if(this.viewport.pause||!this.viewport.worldVisible)return;A.pointerType==="mouse"&&(this.isMouseDown=!1),A.pointerType!=="mouse"&&this.remove(A.pointerId);const e=this.viewport.plugins.up(A);this.clickedAvailable&&this.count()===0&&this.last&&(this.viewport.emit("clicked",{event:A,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this.viewport}),this.clickedAvailable=!1),e&&this.viewport.options.stopPropagation&&A.stopPropagation()}getPointerPosition(A){const e=new VA;return this.viewport.options.events.mapPositionToPoint(e,A.clientX,A.clientY),e}handleWheel(A){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.toLocal(this.getPointerPosition(A));this.viewport.left<=e.x&&e.x<=this.viewport.right&&this.viewport.top<=e.y&&e.y<=this.viewport.bottom&&this.viewport.plugins.wheel(A)&&!this.viewport.options.passiveWheel&&A.preventDefault()}pause(){this.touches=[],this.isMouseDown=!1}get(A){for(const e of this.touches)if(e.id===A)return e;return null}remove(A){for(let e=0;e<this.touches.length;e++)if(this.touches[e].id===A){this.touches.splice(e,1);return}}count(){return(this.isMouseDown?1:0)+this.touches.length}}const qc=["drag","pinch","wheel","follow","mouse-edges","decelerate","animate","bounce","snap-zoom","clamp-zoom","snap","clamp"];class bF{constructor(A){pA(this,"plugins"),pA(this,"list"),pA(this,"viewport"),this.viewport=A,this.list=[],this.plugins={}}add(A,e,t=qc.length){const i=this.plugins[A];i&&i.destroy(),this.plugins[A]=e;const r=qc.indexOf(A);r!==-1&&qc.splice(r,1),qc.splice(t,0,A),this.sort()}get(A,e){var t;return e&&(t=this.plugins[A])!=null&&t.paused?null:this.plugins[A]}update(A){for(const e of this.list)e.update(A)}resize(){for(const A of this.list)A.resize()}reset(){for(const A of this.list)A.reset()}removeAll(){this.list.forEach(A=>{A.destroy()}),this.plugins={},this.sort()}remove(A){var e;this.plugins[A]&&((e=this.plugins[A])==null||e.destroy(),delete this.plugins[A],this.viewport.emit("plugin-remove",A),this.sort())}pause(A){var e;(e=this.plugins[A])==null||e.pause()}resume(A){var e;(e=this.plugins[A])==null||e.resume()}sort(){this.list=[];for(const A of qc)this.plugins[A]&&this.list.push(this.plugins[A])}down(A){let e=!1;for(const t of this.list)t.down(A)&&(e=!0);return e}move(A){let e=!1;for(const t of this.viewport.plugins.list)t.move(A)&&(e=!0);return e}up(A){let e=!1;for(const t of this.list)t.up(A)&&(e=!0);return e}wheel(A){let e=!1;for(const t of this.list)t.wheel(A)&&(e=!0);return e}}const SF={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,disableOnContextMenu:!1,ticker:Zt.shared,allowPreserveDragOutside:!1};class _F extends wi{constructor(A){super(),pA(this,"moving"),pA(this,"screenWidth"),pA(this,"screenHeight"),pA(this,"threshold"),pA(this,"input"),pA(this,"plugins"),pA(this,"zooming"),pA(this,"lastViewport"),pA(this,"options"),pA(this,"_dirty"),pA(this,"_forceHitArea"),pA(this,"_hitAreaDefault"),pA(this,"_pause"),pA(this,"tickerFunction"),pA(this,"_worldWidth"),pA(this,"_worldHeight"),pA(this,"_disableOnContextMenu",e=>e.preventDefault()),this.options={...SF,...A},this.screenWidth=this.options.screenWidth,this.screenHeight=this.options.screenHeight,this._worldWidth=this.options.worldWidth,this._worldHeight=this.options.worldHeight,this.forceHitArea=this.options.forceHitArea,this.threshold=this.options.threshold,this.options.disableOnContextMenu&&this.options.events.domElement.addEventListener("contextmenu",this._disableOnContextMenu),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new IF(this),this.plugins=new bF(this)}destroy(A){!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.options.disableOnContextMenu&&this.options.events.domElement.removeEventListener("contextmenu",this._disableOnContextMenu),this.input.destroy(),super.destroy(A)}update(A){this.pause||(this.plugins.update(A),this.lastViewport&&(this.lastViewport.x!==this.x||this.lastViewport.y!==this.y?this.moving=!0:this.moving&&(this.emit("moved-end",this),this.moving=!1),this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y?this.zooming=!0:this.zooming&&(this.emit("zoomed-end",this),this.zooming=!1)),this.forceHitArea||(this._hitAreaDefault=new ee(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight),this.hitArea=this._hitAreaDefault),this._dirty=this._dirty||!this.lastViewport||this.lastViewport.x!==this.x||this.lastViewport.y!==this.y||this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y,this.lastViewport={x:this.x,y:this.y,scaleX:this.scale.x,scaleY:this.scale.y},this.emit("frame-end",this))}resize(A=window.innerWidth,e=window.innerHeight,t,i){this.screenWidth=A,this.screenHeight=e,typeof t<"u"&&(this._worldWidth=t),typeof i<"u"&&(this._worldHeight=i),this.plugins.resize(),this.dirty=!0}get worldWidth(){return this._worldWidth?this._worldWidth:this.width/this.scale.x}set worldWidth(A){this._worldWidth=A,this.plugins.resize()}get worldHeight(){return this._worldHeight?this._worldHeight:this.height/this.scale.y}set worldHeight(A){this._worldHeight=A,this.plugins.resize()}getVisibleBounds(){return new ee(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(A,e){return arguments.length===2?this.toLocal(new VA(A,e)):this.toLocal(A)}toScreen(A,e){return arguments.length===2?this.toGlobal(new VA(A,e)):this.toGlobal(A)}get worldScreenWidth(){return this.screenWidth/this.scale.x}get worldScreenHeight(){return this.screenHeight/this.scale.y}get screenWorldWidth(){return this.worldWidth*this.scale.x}get screenWorldHeight(){return this.worldHeight*this.scale.y}get center(){return new VA(this.worldScreenWidth/2-this.x/this.scale.x,this.worldScreenHeight/2-this.y/this.scale.y)}set center(A){this.moveCenter(A)}moveCenter(...A){let e,t;typeof A[0]=="number"?(e=A[0],t=A[1]):(e=A[0].x,t=A[0].y);const i=(this.worldScreenWidth/2-e)*this.scale.x,r=(this.worldScreenHeight/2-t)*this.scale.y;return(this.x!==i||this.y!==r)&&(this.position.set(i,r),this.plugins.reset(),this.dirty=!0),this}get corner(){return new VA(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(A){this.moveCorner(A)}moveCorner(...A){let e,t;return A.length===1?(e=-A[0].x*this.scale.x,t=-A[0].y*this.scale.y):(e=-A[0]*this.scale.x,t=-A[1]*this.scale.y),(e!==this.x||t!==this.y)&&(this.position.set(e,t),this.plugins.reset(),this.dirty=!0),this}get screenWidthInWorldPixels(){return this.screenWidth/this.scale.x}get screenHeightInWorldPixels(){return this.screenHeight/this.scale.y}findFitWidth(A){return this.screenWidth/A}findFitHeight(A){return this.screenHeight/A}findFit(A,e){const t=this.screenWidth/A,i=this.screenHeight/e;return Math.min(t,i)}findCover(A,e){const t=this.screenWidth/A,i=this.screenHeight/e;return Math.max(t,i)}fitWidth(A=this.worldWidth,e,t=!0,i){let r;e&&(r=this.center),this.scale.x=this.screenWidth/A,t&&(this.scale.y=this.scale.x);const s=this.plugins.get("clamp-zoom",!0);return!i&&s&&s.clamp(),e&&r&&this.moveCenter(r),this}fitHeight(A=this.worldHeight,e,t=!0,i){let r;e&&(r=this.center),this.scale.y=this.screenHeight/A,t&&(this.scale.x=this.scale.y);const s=this.plugins.get("clamp-zoom",!0);return!i&&s&&s.clamp(),e&&r&&this.moveCenter(r),this}fitWorld(A){let e;A&&(e=this.center),this.scale.x=this.screenWidth/this.worldWidth,this.scale.y=this.screenHeight/this.worldHeight,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const t=this.plugins.get("clamp-zoom",!0);return t&&t.clamp(),A&&e&&this.moveCenter(e),this}fit(A,e=this.worldWidth,t=this.worldHeight){let i;A&&(i=this.center),this.scale.x=this.screenWidth/e,this.scale.y=this.screenHeight/t,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const r=this.plugins.get("clamp-zoom",!0);return r&&r.clamp(),A&&i&&this.moveCenter(i),this}setZoom(A,e){let t;e&&(t=this.center),this.scale.set(A);const i=this.plugins.get("clamp-zoom",!0);return i&&i.clamp(),e&&t&&this.moveCenter(t),this}zoomPercent(A,e){return this.setZoom(this.scale.x+this.scale.x*A,e)}zoom(A,e){return this.fitWidth(A+this.worldScreenWidth,e),this}get scaled(){return this.scale.x}set scaled(A){this.setZoom(A,!0)}snapZoom(A){return this.plugins.add("snap-zoom",new wF(this,A)),this}OOB(){return{left:this.left<0,right:this.right>this.worldWidth,top:this.top<0,bottom:this.bottom>this.worldHeight,cornerPoint:new VA(this.worldWidth*this.scale.x-this.screenWidth,this.worldHeight*this.scale.y-this.screenHeight)}}get right(){return-this.x/this.scale.x+this.worldScreenWidth}set right(A){this.x=-A*this.scale.x+this.screenWidth,this.plugins.reset()}get left(){return-this.x/this.scale.x}set left(A){this.x=-A*this.scale.x,this.plugins.reset()}get top(){return-this.y/this.scale.y}set top(A){this.y=-A*this.scale.y,this.plugins.reset()}get bottom(){return-this.y/this.scale.y+this.worldScreenHeight}set bottom(A){this.y=-A*this.scale.y+this.screenHeight,this.plugins.reset()}get dirty(){return!!this._dirty}set dirty(A){this._dirty=A}get forceHitArea(){return this._forceHitArea}set forceHitArea(A){A?(this._forceHitArea=A,this.hitArea=A):(this._forceHitArea=null,this.hitArea=new ee(0,0,this.worldWidth,this.worldHeight))}drag(A){return this.plugins.add("drag",new cF(this,A)),this}clamp(A){return this.plugins.add("clamp",new nF(this,A)),this}decelerate(A){return this.plugins.add("decelerate",new aF(this,A)),this}bounce(A){return this.plugins.add("bounce",new tF(this,A)),this}pinch(A){return this.plugins.add("pinch",new gF(this,A)),this}snap(A,e,t){return this.plugins.add("snap",new vF(this,A,e,t)),this}follow(A,e){return this.plugins.add("follow",new uF(this,A,e)),this}wheel(A){return this.plugins.add("wheel",new xF(this,A)),this}animate(A){return this.plugins.add("animate",new AF(this,A)),this}clampZoom(A){return this.plugins.add("clamp-zoom",new sF(this,A)),this}mouseEdges(A){return this.plugins.add("mouse-edges",new dF(this,A)),this}get pause(){return!!this._pause}set pause(A){this._pause=A,this.lastViewport=null,this.moving=!1,this.zooming=!1,A&&this.input.pause()}ensureVisible(A,e,t,i,r){r&&(t>this.worldScreenWidth||i>this.worldScreenHeight)&&(this.fit(!0,t,i),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let s=!1;A<this.left?(this.left=A,s=!0):A+t>this.right&&(this.right=A+t,s=!0),e<this.top?(this.top=e,s=!0):e+i>this.bottom&&(this.bottom=e+i,s=!0),s&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}const MF="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAIrSURBVHic7dWhEcQwAAPBJEW4//bsJvzwg446YLcCkRvdc8598RljjNMTeHlOD4AvEwgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUC499779Aj+1lqnJ/DiQSAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIPwAhCgMRcz+Nz0AAAAASUVORK5CYII=";var PF=Object.defineProperty,TF=Object.getOwnPropertyDescriptor,Qa=(n,A,e,t)=>{for(var i=t>1?void 0:t?TF(A,e):A,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(t?s(A,e,i):s(i))||i);return t&&i&&PF(A,e,i),i};ue.Cropper=class extends Kr{constructor(){super(),this._domBoundingRect={x:0,y:0,width:0,height:0},this.app=new N2({backgroundAlpha:0,autoDensity:!0,resolution:2}),this.viewport=new _F({events:this.app.renderer.events,worldWidth:250,worldHeight:250}),this.imageSize={width:0,height:0},this.logoSize={width:0,height:0},this._imageUrl="",this._canvasScale=1,this.texture=new lt(this.app.view),this._timer=0,this._sprite=new ks,this.pathD="",this.getConfigs=()=>{const{screenWidth:A,screenHeight:e}=this.viewport;return{canvasWidth:A,canvasHeight:e,scale:this.viewport.scale.x,x:this.viewport.position.x,y:this.viewport.position.y,url:this._imageUrl}},this._onChanged=async()=>{if(!this.imageSize.width||!this.imageSize.height||!this.app.view.toDataURL)return;const A=this.app.view.toDataURL("image/png",.75),e=this.app.renderer.gl,{screenWidth:t,screenHeight:i}=this.viewport;if(this._timer&&clearTimeout(this._timer),e){const r=this.app.renderer.width,s=this.app.renderer.height,o=new Uint8Array(r*s*4);e.readPixels(0,0,r,s,e.RGBA,e.UNSIGNED_BYTE,o);let a=r,l=0,u=s,c=0;for(let g=0;g<s;g++)for(let y=0;y<r;y++){const v=(g*r+y)*4;o[v+3]>0&&(a=Math.min(a,y),l=Math.max(l,y),u=Math.min(u,g),c=Math.max(c,g))}const h=this.app.renderer.view.getBoundingClientRect(),f={x:a,y:u,width:l-a+1,height:c-u+1};(a>l||u>c)&&console.log("没有非透明区域"),this.axiosX&&(this.axiosX.style.display="none"),this.axiosY&&(this.axiosY.style.display="none");const p=2,m=t/2,d=i/2;if(h){const g={x:f.x*(h.width/this.app.renderer.width),y:(this.app.renderer.height-f.y-f.height)*(h.height/this.app.renderer.height),width:f.width*(h.width/this.app.renderer.width),height:f.height*(h.height/this.app.renderer.height)};this._domBoundingRect=g,this.boundRect&&(this.boundRect.style.left=`${g.x}px`,this.boundRect.style.top=`${g.y}px`,this.boundRect.style.width=`${g.width}px`,this.boundRect.style.height=`${g.height}px`);const y=g.x+g.width/2,v=g.y+g.height/2,w=m-y,C=d-v;Math.abs(w)<p&&(this.viewport.position.x+=w,this.axiosY&&(this.axiosY.style.display="block")),Math.abs(C)<p&&(this.viewport.position.y+=C,this.axiosX&&(this.axiosX.style.display="block"))}else Math.abs(this.viewport.position.x-m)<p&&(this.viewport.position.x=m,this.axiosY&&(this.axiosY.style.display="block")),Math.abs(this.viewport.position.y-d)<p&&(this.viewport.position.y=d,this.axiosX&&(this.axiosX.style.display="block"));this._timer=window.setTimeout(()=>{this.axiosX&&(this.axiosX.style.display="none"),this.axiosY&&(this.axiosY.style.display="none")},600)}this.dispatchEvent(new CustomEvent("image-change",{detail:{image:A},bubbles:!0,composed:!0}))},this._wheelEvent=A=>{A.preventDefault()},this.updateConfigs=async({canvasWidth:A,x:e,y:t,scale:i,url:r})=>{const{screenWidth:s}=this.viewport;this._canvasScale=s/A,await this.add(r,this.logoSize),this.viewport.scale.set(i*this._canvasScale),this.viewport.position.set(e*this._canvasScale,t*this._canvasScale)},this.app.stage.addChild(this.viewport),this.viewport.drag({}).pinch().wheel().decelerate({friction:0,bounce:1}).on("zoomed-end",this._onChanged).on("moved-end",this._onChanged),this.app.view.addEventListener("wheel",this._wheelEvent,{passive:!1})}get supports(){return["png","jpg","jpeg","svg","webp"]}get canvas(){return this.app.view}get imageScale(){const{screenWidth:A,screenHeight:e}=this.viewport,t=this.viewport.scale.x,i=this._sprite.width*t/2,r=this._sprite.height*t/2,s=this._domBoundingRect.width/i*(i/A),o=this._domBoundingRect.height/r*(r/e);return{x:s,y:o}}get imageRealSize(){const{x:A,y:e}=this.imageScale;let{width:t,height:i}=this.logoSize;const r=Math.max(t,i);return t=r*A,i=r*e,{width:t,height:i}}resize(A,e){this.app.renderer.resize(A,e),this.viewport.resize(A,e)}firstUpdated(A){var e;super.firstUpdated(A),this.container&&((e=this.container)==null||e.append(this.app.view),this.app.resizeTo=this.container,this.viewport.addChild(this._sprite))}setUV(A){const{screenWidth:e,screenHeight:t}=this.viewport,i=A.attributes.uv,r=A.index;if(!r){this.pathD="";return}let s=[];for(let a=0;a<r.count;a+=3){const l=r.getX(a),u=r.getX(a+1),c=r.getX(a+2),h=[i.getX(l)*e,i.getY(l)*t],f=[i.getX(u)*e,i.getY(u)*t],p=[i.getX(c)*e,i.getY(c)*t];s.push(h,f,p)}let o="";s.forEach((a,l)=>{l%3===0?o+=`M${a[0]},${a[1]} `:o+=`L${a[0]},${a[1]} `,l%3===2&&(o+="Z ")}),s=[],this.pathD=o}async add(A,e){this._imageUrl=A,this.logoSize=e,this._sprite.texture=await GA.fromURL(A),this.imageSize.width=this._sprite.texture.width,this.imageSize.height=this._sprite.texture.height,this.fit()}clear(){this._sprite.texture.destroy(!0),this.boundRect&&(this.boundRect.style.left="0px",this.boundRect.style.top="0px",this.boundRect.style.width="0px",this.boundRect.style.height="0px")}fit(){this.viewport.scale.set(1,1),this._sprite.anchor.set(.5,.5),this.viewport.moveCenter(this._sprite.position.x,this._sprite.position.y);const A=this.viewport.screenWidth,e=this.viewport.screenHeight,t=this._sprite.width/A,i=this._sprite.height/e,r=Math.max(t,i);this.viewport.scale.set(1/r,1/r)}disconnectedCallback(){super.disconnectedCallback(),this.viewport.destroy({children:!0,texture:!0,baseTexture:!0}),this.viewport.off("zoomed"),this.viewport.off("moved"),this.viewport.off("moved-end"),this.app.view.removeEventListener("wheel",this._wheelEvent),this.app.destroy(!0)}render(){const{screenWidth:A,screenHeight:e}=this.viewport;return Z0`
9836
9836
  <div class="cropper-container">
9837
9837
  <div class="rect"></div>
9838
9838
  <div class="axios-x"></div>
9839
9839
  <div class="axios-y"></div>
9840
9840
  <div class="cross"></div>
9841
- <svg class="uv-mask" viewBox="0 0 200 200">
9841
+ <svg class="uv-mask" viewBox="0 0 ${A} ${e}">
9842
9842
  <path d=${this.pathD} stroke-width="1" stroke="gray" stroke-opacity="0.3" fill="none"></path>
9843
9843
  </svg>
9844
9844
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shop-components",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Shop components",
5
5
  "main": "dist/shop-components.umd.js",
6
6
  "module": "dist/shop-components.mjs",